@duckcodeailabs/dql-cli 1.13.1 → 1.13.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/dist/apps-api.d.ts +249 -7
  2. package/dist/apps-api.d.ts.map +1 -1
  3. package/dist/apps-api.js +2855 -160
  4. package/dist/apps-api.js.map +1 -1
  5. package/dist/assets/dql-notebook/assets/{AgentLogPage-D6fgEAEy.js → AgentLogPage-B3ugEb3H.js} +1 -1
  6. package/dist/assets/dql-notebook/assets/{AiBuildDialog-8miXFPse.js → AiBuildDialog-BK_TDNcM.js} +1 -1
  7. package/dist/assets/dql-notebook/assets/{AiBuildResult-DPJ_SI0R.js → AiBuildResult-Cob_Lj05.js} +8 -8
  8. package/dist/assets/dql-notebook/assets/{AiSidePanel-NVA6lZnn.js → AiSidePanel-CzIgxmP9.js} +1 -1
  9. package/dist/assets/dql-notebook/assets/AnalyticsHome-C2vJ2fxY.js +6 -0
  10. package/dist/assets/dql-notebook/assets/AppsView-DEWQ0sHT.js +5588 -0
  11. package/dist/assets/dql-notebook/assets/BlockStudio-CaDNTKMM.js +55 -0
  12. package/dist/assets/dql-notebook/assets/{BusinessArtifactView-DtRMiaF4.js → BusinessArtifactView-zwUOtddi.js} +1 -1
  13. package/dist/assets/dql-notebook/assets/DbtFirstModelingPage-BlnhTMu3.js +22 -0
  14. package/dist/assets/dql-notebook/assets/{GitPage-CazC-eTR.js → GitPage-Coevr9NJ.js} +3 -3
  15. package/dist/assets/dql-notebook/assets/GlobalAiRail-BTZS11x5.js +1 -0
  16. package/dist/assets/dql-notebook/assets/GovernedContextPage-CjyyM_ne.js +7 -0
  17. package/dist/assets/dql-notebook/assets/{HelpDocsPage-DMHPsVqP.js → HelpDocsPage-C1UeP85v.js} +1 -1
  18. package/dist/assets/dql-notebook/assets/{HomePage-DcSI4dnU.js → HomePage-zGPFIvOY.js} +1 -1
  19. package/dist/assets/dql-notebook/assets/{LineageDAG-BJ6xz06u.js → LineageDAG-DbXnQWu3.js} +1 -1
  20. package/dist/assets/dql-notebook/assets/{LineageDetailView-8WrQm-MF.js → LineageDetailView-Ch1Db01I.js} +1 -1
  21. package/dist/assets/dql-notebook/assets/{LineageDrawer-hnqCW_t-.js → LineageDrawer-DLxqJO6D.js} +1 -1
  22. package/dist/assets/dql-notebook/assets/{LineagePathBreadcrumb-B4LZTUsl.js → LineagePathBreadcrumb-B2tNdkr_.js} +3 -3
  23. package/dist/assets/dql-notebook/assets/{MiniLineageGraph-CotnRuxa.js → MiniLineageGraph-0gY-ZwCy.js} +1 -1
  24. package/dist/assets/dql-notebook/assets/{NewBlockModal-DHn-CEEW.js → NewBlockModal-DKVkXD20.js} +1 -1
  25. package/dist/assets/dql-notebook/assets/{NewNotebookModal-BPGp-8oq.js → NewNotebookModal-BUIByvYT.js} +1 -1
  26. package/dist/assets/dql-notebook/assets/{NotebookEditor-B0OTHM6W.js → NotebookEditor-D2fIUxjE.js} +5 -5
  27. package/dist/assets/dql-notebook/assets/{ReadinessPage-CoOIpxWq.js → ReadinessPage-Ci4LyNiQ.js} +1 -1
  28. package/dist/assets/dql-notebook/assets/{SetupOnboarding-DxK_mFzf.js → SetupOnboarding-BF7ai_0t.js} +1 -1
  29. package/dist/assets/dql-notebook/assets/SkillsPage-BgYrgirJ.js +10 -0
  30. package/dist/assets/dql-notebook/assets/{TrustBadge-ZuD5N5Ww.js → TrustBadge-Bob1Laiq.js} +1 -1
  31. package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-IxDUKSG8.js +88 -0
  32. package/dist/assets/dql-notebook/assets/{answer-to-notebook-WAVAYjBv.js → answer-to-notebook-Dk42N0pU.js} +1 -1
  33. package/dist/assets/dql-notebook/assets/{arrow-left-L8odLbyN.js → arrow-left-DKuuTw9l.js} +1 -1
  34. package/dist/assets/dql-notebook/assets/{arrow-right-WIF1V9a9.js → arrow-right-TH8_ufKG.js} +1 -1
  35. package/dist/assets/dql-notebook/assets/{book-open-text-BpqWMa4m.js → book-open-text-B-dcHHn0.js} +1 -1
  36. package/dist/assets/dql-notebook/assets/{circle-x-CQBOM0b0.js → circle-x-BOc2KCZQ.js} +1 -1
  37. package/dist/assets/dql-notebook/assets/{dagre.esm-DlZi7NR3.js → dagre.esm-CPT_vn5p.js} +1 -1
  38. package/dist/assets/dql-notebook/assets/{external-link-DYqdQIGp.js → external-link-DtOfpYc6.js} +1 -1
  39. package/dist/assets/dql-notebook/assets/{grip-vertical-HmUijbwN.js → grip-vertical-B8joDDH9.js} +1 -1
  40. package/dist/assets/dql-notebook/assets/index-B3shyZsg.css +1 -0
  41. package/dist/assets/dql-notebook/assets/index-DJRMz64S.js +635 -0
  42. package/dist/assets/dql-notebook/assets/link-2-DMZPHawg.js +6 -0
  43. package/dist/assets/dql-notebook/assets/{list-tree-DGKqCxmz.js → list-tree-Dw0qlxPK.js} +1 -1
  44. package/dist/assets/dql-notebook/assets/{minimize-2-C8dvqCxX.js → minimize-2-DUiSrPS3.js} +1 -1
  45. package/dist/assets/dql-notebook/assets/{panel-right-open-yuVkIo5n.js → panel-right-open-BrrFrRZQ.js} +1 -1
  46. package/dist/assets/dql-notebook/assets/{bot-CLR1V6dO.js → play-Ced0HT9g.js} +7 -2
  47. package/dist/assets/dql-notebook/assets/{rotate-ccw-Di0kRnrM.js → rotate-ccw-D_9U9o7X.js} +1 -1
  48. package/dist/assets/dql-notebook/assets/{semantic-fields-BMQV0li8.js → semantic-fields-BlDOaonV.js} +1 -1
  49. package/dist/assets/dql-notebook/assets/{sliders-horizontal-alebptlJ.js → sliders-horizontal-BDt6KRGR.js} +1 -1
  50. package/dist/assets/dql-notebook/assets/{star-CgCQbnXc.js → star-CxUbF_BW.js} +1 -1
  51. package/dist/assets/dql-notebook/assets/{triangle-alert-SyuSZ4ht.js → triangle-alert-COWnsSdh.js} +1 -1
  52. package/dist/assets/dql-notebook/assets/upload-DSFC2kJX.js +6 -0
  53. package/dist/assets/dql-notebook/assets/usePersistedAgentThreadId-DYdx896E.js +32 -0
  54. package/dist/assets/dql-notebook/assets/{user-round-J4PQHxo9.js → user-round-Bfu7fosn.js} +1 -1
  55. package/dist/assets/dql-notebook/assets/{wand-sparkles-c4WDXTCk.js → wand-sparkles-DSpG0c0j.js} +1 -1
  56. package/dist/assets/dql-notebook/assets/{workflow-NtRLaq7n.js → workflow-B1_pj9gq.js} +1 -1
  57. package/dist/assets/dql-notebook/assets/{wrench-CS1f1Zv4.js → wrench-CvfM03KZ.js} +1 -1
  58. package/dist/assets/dql-notebook/assets/{x-CbKEfe5m.js → x-B4coLiOl.js} +1 -1
  59. package/dist/assets/dql-notebook/index.html +2 -2
  60. package/dist/commands/app.d.ts.map +1 -1
  61. package/dist/commands/app.js +65 -133
  62. package/dist/commands/app.js.map +1 -1
  63. package/dist/commands/model.js +21 -2
  64. package/dist/commands/model.js.map +1 -1
  65. package/dist/llm/providers/dql-agent-provider.d.ts +16 -0
  66. package/dist/llm/providers/dql-agent-provider.d.ts.map +1 -1
  67. package/dist/llm/providers/dql-agent-provider.js +65 -2
  68. package/dist/llm/providers/dql-agent-provider.js.map +1 -1
  69. package/dist/local-runtime.d.ts +112 -19
  70. package/dist/local-runtime.d.ts.map +1 -1
  71. package/dist/local-runtime.js +2026 -694
  72. package/dist/local-runtime.js.map +1 -1
  73. package/dist/package.json +10 -10
  74. package/dist/sql-result-filter.d.ts +9 -0
  75. package/dist/sql-result-filter.d.ts.map +1 -1
  76. package/dist/sql-result-filter.js +25 -0
  77. package/dist/sql-result-filter.js.map +1 -1
  78. package/package.json +10 -10
  79. package/dist/assets/dql-notebook/assets/AgentAnswerCard-c8QUo6NH.js +0 -5
  80. package/dist/assets/dql-notebook/assets/AnalyticsHome-DgwnRW71.js +0 -6
  81. package/dist/assets/dql-notebook/assets/AppsView-B6LYUpgm.js +0 -4578
  82. package/dist/assets/dql-notebook/assets/BlockStudio--jNw9XUI.js +0 -60
  83. package/dist/assets/dql-notebook/assets/DbtFirstModelingPage-DhBsLCYr.js +0 -22
  84. package/dist/assets/dql-notebook/assets/GlobalAiRail-1Tgweuu2.js +0 -1
  85. package/dist/assets/dql-notebook/assets/GovernedContextPage-C7qGrH3d.js +0 -16
  86. package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-duFXXNV_.js +0 -88
  87. package/dist/assets/dql-notebook/assets/index-Cpx47jCH.js +0 -634
  88. package/dist/assets/dql-notebook/assets/index-DKu4CZt3.css +0 -1
  89. package/dist/assets/dql-notebook/assets/upload-BPhfea_E.js +0 -11
  90. package/dist/assets/dql-notebook/assets/usePersistedAgentThreadId-Bnl9gWhj.js +0 -28
@@ -1 +1 @@
1
- import{u as x,t as m,j as n,G as y,aH as j,r as b,f as k}from"./index-Cpx47jCH.js";import{A as S}from"./arrow-left-L8odLbyN.js";import{W as M}from"./wrench-CS1f1Zv4.js";import{C as v}from"./circle-x-CQBOM0b0.js";import"./react-CRB3T2We.js";function H(){const{state:e,dispatch:t}=x(),r=m[e.themeMode],s=e.agentLogRun;return s?n.jsxs("div",{style:{padding:"20px 28px",fontFamily:r.font,color:r.textPrimary,maxWidth:900,margin:"0 auto"},children:[n.jsxs("button",{type:"button",onClick:()=>t({type:"SET_MAIN_VIEW",view:"ask"}),style:C(r),children:[n.jsx(S,{size:14})," Back to Ask AI"]}),n.jsx(w,{run:s,t:r}),n.jsx(z,{run:s,t:r}),u(s).reason&&n.jsx(W,{run:s,t:r}),s.evaluations.length>0&&n.jsx(I,{run:s,t:r})]}):n.jsx("div",{style:{padding:32,color:r.textMuted,fontFamily:r.font},children:"No agent run selected. Open one from the “View steps” link on an AI answer."})}function w({run:e,t}){const r=f(e.startedAt,e.completedAt);return n.jsxs("div",{style:{marginBottom:20},children:[n.jsx("div",{style:{fontSize:18,fontWeight:600,marginBottom:8,lineHeight:1.35},children:e.question}),n.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",alignItems:"center"},children:[n.jsxs("span",{style:c(t),children:[n.jsx(y,{size:12})," ",p(e.route)]}),n.jsx("span",{style:N(t,e.trustState),children:_(e.trustState)}),r!=null&&n.jsxs("span",{style:c(t),children:[n.jsx(j,{size:12})," ",g(r)," total"]}),n.jsx("span",{style:{...c(t),color:t.textMuted},children:e.status})]})]})}function z({run:e,t}){const r=b.useMemo(()=>$(e),[e]),s=r.reduce((i,o)=>Math.max(i,o.deltaMs),0);return n.jsxs("section",{style:{marginBottom:22},children:[n.jsx(d,{t,children:"What the agent did · where the time went"}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:r.map(i=>{const o=s>0&&i.deltaMs===s&&i.deltaMs>=250;return n.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10,padding:"8px 10px",borderRadius:8,background:o?l(t.warning,.1):t.cellBg,border:`1px solid ${o?l(t.warning,.4):t.cellBorder}`},children:[n.jsx("span",{style:{marginTop:1,color:i.isTool?t.accent:t.textMuted,flexShrink:0},children:i.isTool?n.jsx(M,{size:13}):n.jsx("span",{style:{fontSize:13},children:"•"})}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsx("div",{style:{fontSize:13,fontWeight:500},children:i.label}),i.detail&&n.jsx("div",{style:{fontSize:12,color:t.textMuted,marginTop:2,wordBreak:"break-word"},children:i.detail})]}),n.jsx("span",{style:{fontSize:12,fontFamily:t.fontMono,color:o?t.warning:t.textMuted,fontWeight:o?600:400,flexShrink:0,whiteSpace:"nowrap"},children:i.deltaMs>0?`+${g(i.deltaMs)}`:"—"})]},i.key)})}),s>=1e3&&n.jsx("div",{style:{fontSize:12,color:t.textMuted,marginTop:8},children:"The highlighted step took the longest. Long generation/tool steps usually mean the question fell through to LLM generation — a governed metric or certified block would answer it instantly."})]})}function W({run:e,t}){const r=u(e);return n.jsxs("section",{style:{marginBottom:22},children:[n.jsx(d,{t,children:"Why this route"}),n.jsxs("div",{style:{fontSize:13,color:t.textSecondary,lineHeight:1.5},children:[r.reason,typeof r.confidence=="number"&&n.jsxs("span",{style:{color:t.textMuted},children:[" · confidence ",(r.confidence*100).toFixed(0),"%"]})]})]})}function u(e){const t=e.routeDecision;return{reason:typeof(t==null?void 0:t.reason)=="string"?t.reason:void 0,confidence:typeof(t==null?void 0:t.confidence)=="number"?t.confidence:void 0}}function I({run:e,t}){return n.jsxs("section",{style:{marginBottom:22},children:[n.jsx(d,{t,children:"Governance checks"}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:e.evaluations.map(r=>n.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8,fontSize:13},children:[n.jsx("span",{style:{marginTop:1,color:r.passed?t.success:t.error,flexShrink:0},children:r.passed?n.jsx(k,{size:14}):n.jsx(v,{size:14})}),n.jsxs("div",{children:[n.jsx("span",{style:{fontWeight:500},children:r.label}),!r.passed&&r.message&&n.jsxs("span",{style:{color:t.textMuted},children:[" — ",r.message]})]})]},r.id))})]})}function d({t:e,children:t}){return n.jsx("div",{style:{fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:.6,color:e.textMuted,marginBottom:10},children:t})}function $(e){var i;const t=[...e.events].sort((o,a)=>o.at.localeCompare(a.at)),r=[];let s=e.startedAt??((i=t[0])==null?void 0:i.at);for(const o of t){const a=T(o);if(!a)continue;const h=f(s,o.at)??0;r.push({key:o.id,label:a,detail:A(o),deltaMs:h,isTool:B(o)}),s=o.at}return r}function B(e){const t=e.payload;return typeof(t==null?void 0:t.tool)=="string"}function T(e){switch(e.type){case"run.started":return"Started";case"route.decided":return`Routed to ${p(e.route)}`;case"plan.created":return"Planned the approach";case"step.started":return L(e)??"Working";case"executor.started":return R(e.route);case"evaluation.recorded":return"Checked grounding & trust";case"repair.attempted":return"Repaired and retried";case"replan.decided":return"Re-planned";case"escalated":return"Escalated to a deeper approach";case"artifact.created":return"Produced the answer";case"step.completed":return"Step complete";case"run.completed":return"Done";case"run.failed":return"Failed";default:return null}}function A(e){const t=e.payload;if(typeof(t==null?void 0:t.tool)=="string")return`tool: ${t.tool}`;if(e.type==="route.decided"||e.type==="run.failed")return e.message||void 0}function L(e){var r;const t=(r=e.payload)==null?void 0:r.goal;return t?`Working on: ${D(t,80)}`:null}function R(e){switch(e){case"certified_answer":return"Searching certified blocks & governed metrics";case"generated_answer":return"Composing the answer (semantic compile → generation)";case"research":return"Researching across governed data";case"app_build":return"Assembling the app";case"sql_cell":return"Writing the query";case"dql_block_draft":return"Drafting the block";case"modeling_draft":return"Drafting modeling changes";case"skill_draft":return"Drafting Skill guidance";case"conversation":return"Replying";default:return"Working"}}function p(e){return e?e.replace(/_/g," "):"the answer"}function _(e){return String(e).replace(/_/g," ")}function f(e,t){if(!e||!t)return null;const r=Date.parse(e),s=Date.parse(t);return Number.isNaN(r)||Number.isNaN(s)?null:Math.max(0,s-r)}function g(e){return e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(e<1e4?1:0)}s`}function D(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}function l(e,t){const r=e.trim(),s=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(r);if(!s)return e;let i,o,a;return s[1].length===3?(i=parseInt(s[1][0]+s[1][0],16),o=parseInt(s[1][1]+s[1][1],16),a=parseInt(s[1][2]+s[1][2],16)):(i=parseInt(s[1].slice(0,2),16),o=parseInt(s[1].slice(2,4),16),a=parseInt(s[1].slice(4,6),16)),`rgba(${i}, ${o}, ${a}, ${t})`}function C(e){return{display:"inline-flex",alignItems:"center",gap:6,marginBottom:16,background:"transparent",border:"none",cursor:"pointer",color:e.textMuted,fontSize:13,fontFamily:e.font,padding:0}}function c(e){return{display:"inline-flex",alignItems:"center",gap:5,fontSize:12,padding:"3px 9px",borderRadius:999,background:e.pillBg,border:`1px solid ${e.cellBorder}`,color:e.textSecondary}}function N(e,t){const r=t==="certified"?e.success:t==="blocked"?e.error:e.accent;return{display:"inline-flex",alignItems:"center",gap:5,fontSize:12,padding:"3px 9px",borderRadius:999,background:l(r,.12),border:`1px solid ${l(r,.4)}`,color:r,fontWeight:500}}export{H as AgentLogPage};
1
+ import{u as x,t as m,j as n,G as y,aJ as j,r as b,f as k}from"./index-DJRMz64S.js";import{A as S}from"./arrow-left-DKuuTw9l.js";import{W as M}from"./wrench-CvfM03KZ.js";import{C as v}from"./circle-x-BOc2KCZQ.js";import"./react-CRB3T2We.js";function H(){const{state:e,dispatch:t}=x(),r=m[e.themeMode],s=e.agentLogRun;return s?n.jsxs("div",{style:{padding:"20px 28px",fontFamily:r.font,color:r.textPrimary,maxWidth:900,margin:"0 auto"},children:[n.jsxs("button",{type:"button",onClick:()=>t({type:"SET_MAIN_VIEW",view:"ask"}),style:C(r),children:[n.jsx(S,{size:14})," Back to Ask AI"]}),n.jsx(w,{run:s,t:r}),n.jsx(z,{run:s,t:r}),u(s).reason&&n.jsx(W,{run:s,t:r}),s.evaluations.length>0&&n.jsx(I,{run:s,t:r})]}):n.jsx("div",{style:{padding:32,color:r.textMuted,fontFamily:r.font},children:"No agent run selected. Open one from the “View steps” link on an AI answer."})}function w({run:e,t}){const r=f(e.startedAt,e.completedAt);return n.jsxs("div",{style:{marginBottom:20},children:[n.jsx("div",{style:{fontSize:18,fontWeight:600,marginBottom:8,lineHeight:1.35},children:e.question}),n.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",alignItems:"center"},children:[n.jsxs("span",{style:c(t),children:[n.jsx(y,{size:12})," ",p(e.route)]}),n.jsx("span",{style:N(t,e.trustState),children:_(e.trustState)}),r!=null&&n.jsxs("span",{style:c(t),children:[n.jsx(j,{size:12})," ",g(r)," total"]}),n.jsx("span",{style:{...c(t),color:t.textMuted},children:e.status})]})]})}function z({run:e,t}){const r=b.useMemo(()=>$(e),[e]),s=r.reduce((i,o)=>Math.max(i,o.deltaMs),0);return n.jsxs("section",{style:{marginBottom:22},children:[n.jsx(d,{t,children:"What the agent did · where the time went"}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:r.map(i=>{const o=s>0&&i.deltaMs===s&&i.deltaMs>=250;return n.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10,padding:"8px 10px",borderRadius:8,background:o?l(t.warning,.1):t.cellBg,border:`1px solid ${o?l(t.warning,.4):t.cellBorder}`},children:[n.jsx("span",{style:{marginTop:1,color:i.isTool?t.accent:t.textMuted,flexShrink:0},children:i.isTool?n.jsx(M,{size:13}):n.jsx("span",{style:{fontSize:13},children:"•"})}),n.jsxs("div",{style:{flex:1,minWidth:0},children:[n.jsx("div",{style:{fontSize:13,fontWeight:500},children:i.label}),i.detail&&n.jsx("div",{style:{fontSize:12,color:t.textMuted,marginTop:2,wordBreak:"break-word"},children:i.detail})]}),n.jsx("span",{style:{fontSize:12,fontFamily:t.fontMono,color:o?t.warning:t.textMuted,fontWeight:o?600:400,flexShrink:0,whiteSpace:"nowrap"},children:i.deltaMs>0?`+${g(i.deltaMs)}`:"—"})]},i.key)})}),s>=1e3&&n.jsx("div",{style:{fontSize:12,color:t.textMuted,marginTop:8},children:"The highlighted step took the longest. Long generation/tool steps usually mean the question fell through to LLM generation — a governed metric or certified block would answer it instantly."})]})}function W({run:e,t}){const r=u(e);return n.jsxs("section",{style:{marginBottom:22},children:[n.jsx(d,{t,children:"Why this route"}),n.jsxs("div",{style:{fontSize:13,color:t.textSecondary,lineHeight:1.5},children:[r.reason,typeof r.confidence=="number"&&n.jsxs("span",{style:{color:t.textMuted},children:[" · confidence ",(r.confidence*100).toFixed(0),"%"]})]})]})}function u(e){const t=e.routeDecision;return{reason:typeof(t==null?void 0:t.reason)=="string"?t.reason:void 0,confidence:typeof(t==null?void 0:t.confidence)=="number"?t.confidence:void 0}}function I({run:e,t}){return n.jsxs("section",{style:{marginBottom:22},children:[n.jsx(d,{t,children:"Governance checks"}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:e.evaluations.map(r=>n.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8,fontSize:13},children:[n.jsx("span",{style:{marginTop:1,color:r.passed?t.success:t.error,flexShrink:0},children:r.passed?n.jsx(k,{size:14}):n.jsx(v,{size:14})}),n.jsxs("div",{children:[n.jsx("span",{style:{fontWeight:500},children:r.label}),!r.passed&&r.message&&n.jsxs("span",{style:{color:t.textMuted},children:[" — ",r.message]})]})]},r.id))})]})}function d({t:e,children:t}){return n.jsx("div",{style:{fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:.6,color:e.textMuted,marginBottom:10},children:t})}function $(e){var i;const t=[...e.events].sort((o,a)=>o.at.localeCompare(a.at)),r=[];let s=e.startedAt??((i=t[0])==null?void 0:i.at);for(const o of t){const a=T(o);if(!a)continue;const h=f(s,o.at)??0;r.push({key:o.id,label:a,detail:A(o),deltaMs:h,isTool:B(o)}),s=o.at}return r}function B(e){const t=e.payload;return typeof(t==null?void 0:t.tool)=="string"}function T(e){switch(e.type){case"run.started":return"Started";case"route.decided":return`Routed to ${p(e.route)}`;case"plan.created":return"Planned the approach";case"step.started":return L(e)??"Working";case"executor.started":return R(e.route);case"evaluation.recorded":return"Checked grounding & trust";case"repair.attempted":return"Repaired and retried";case"replan.decided":return"Re-planned";case"escalated":return"Escalated to a deeper approach";case"artifact.created":return"Produced the answer";case"step.completed":return"Step complete";case"run.completed":return"Done";case"run.failed":return"Failed";default:return null}}function A(e){const t=e.payload;if(typeof(t==null?void 0:t.tool)=="string")return`tool: ${t.tool}`;if(e.type==="route.decided"||e.type==="run.failed")return e.message||void 0}function L(e){var r;const t=(r=e.payload)==null?void 0:r.goal;return t?`Working on: ${D(t,80)}`:null}function R(e){switch(e){case"certified_answer":return"Searching certified blocks & governed metrics";case"generated_answer":return"Composing the answer (semantic compile → generation)";case"research":return"Researching across governed data";case"app_build":return"Assembling the app";case"sql_cell":return"Writing the query";case"dql_block_draft":return"Drafting the block";case"modeling_draft":return"Drafting modeling changes";case"skill_draft":return"Drafting Skill guidance";case"conversation":return"Replying";default:return"Working"}}function p(e){return e?e.replace(/_/g," "):"the answer"}function _(e){return String(e).replace(/_/g," ")}function f(e,t){if(!e||!t)return null;const r=Date.parse(e),s=Date.parse(t);return Number.isNaN(r)||Number.isNaN(s)?null:Math.max(0,s-r)}function g(e){return e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(e<1e4?1:0)}s`}function D(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}function l(e,t){const r=e.trim(),s=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(r);if(!s)return e;let i,o,a;return s[1].length===3?(i=parseInt(s[1][0]+s[1][0],16),o=parseInt(s[1][1]+s[1][1],16),a=parseInt(s[1][2]+s[1][2],16)):(i=parseInt(s[1].slice(0,2),16),o=parseInt(s[1].slice(2,4),16),a=parseInt(s[1].slice(4,6),16)),`rgba(${i}, ${o}, ${a}, ${t})`}function C(e){return{display:"inline-flex",alignItems:"center",gap:6,marginBottom:16,background:"transparent",border:"none",cursor:"pointer",color:e.textMuted,fontSize:13,fontFamily:e.font,padding:0}}function c(e){return{display:"inline-flex",alignItems:"center",gap:5,fontSize:12,padding:"3px 9px",borderRadius:999,background:e.pillBg,border:`1px solid ${e.cellBorder}`,color:e.textSecondary}}function N(e,t){const r=t==="certified"?e.success:t==="blocked"?e.error:e.accent;return{display:"inline-flex",alignItems:"center",gap:5,fontSize:12,padding:"3px 9px",borderRadius:999,background:l(r,.12),border:`1px solid ${l(r,.4)}`,color:r,fontWeight:500}}export{H as AgentLogPage};
@@ -1 +1 @@
1
- import{u,t as f,r as a,j as o,S as h,m as b}from"./index-Cpx47jCH.js";import{s as g}from"./ai-build-bus-1BR770pY.js";import{u as y,A as k}from"./AiBuildResult-DPJ_SI0R.js";import{X as j}from"./x-CbKEfe5m.js";import"./react-CRB3T2We.js";import"./user-round-J4PQHxo9.js";import"./triangle-alert-SyuSZ4ht.js";import"./rotate-ccw-Di0kRnrM.js";function z(){const{state:n,dispatch:c}=u(),t=f[n.themeMode],[e,l]=a.useState(null),p=y();if(a.useEffect(()=>g(i=>l(i)),[]),!e)return null;const s=()=>l(null),m=i=>{const r=i.trim();if(!r)return;const d=b("sql",r);d.name="ai_sql_preview",c({type:"ADD_CELL",cell:d})},x=(i,r)=>{p(i,r).finally(s)};return o.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"Ask AI to build",style:v,children:o.jsxs("div",{style:{width:"min(720px, calc(100vw - 32px))",maxHeight:"min(760px, calc(100vh - 64px))",background:t.appBg,border:`1px solid ${t.headerBorder}`,borderRadius:12,boxShadow:"0 24px 80px rgba(0,0,0,0.34)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"11px 14px",borderBottom:`1px solid ${t.headerBorder}`},children:[o.jsx("div",{style:{width:30,height:30,borderRadius:8,background:`${t.accent}16`,border:`1px solid ${t.accent}38`,color:t.accent,display:"inline-flex",alignItems:"center",justifyContent:"center",flex:"0 0 auto"},children:o.jsx(h,{size:16,strokeWidth:2.2})}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsx("div",{style:{fontSize:14,fontWeight:850,color:t.textPrimary,fontFamily:t.font},children:e.mode==="edit"?"Ask AI to modify a block":"Ask AI to build a block"}),o.jsx("div",{style:{fontSize:11.5,color:t.textMuted,fontFamily:t.font,marginTop:1},children:e.sourceLabel??(e.mode==="edit"?"Describe the change and review a before/after diff. Nothing is certified.":"Generate a draft from your dbt + semantic context. Nothing is certified.")})]}),o.jsx("button",{type:"button",onClick:s,title:"Close",style:{width:28,height:28,borderRadius:6,border:`1px solid ${t.btnBorder}`,background:t.btnBg,color:t.textSecondary,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},children:o.jsx(j,{size:15,strokeWidth:2})})]}),o.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto"},children:o.jsx(k,{themeMode:n.themeMode,initialTarget:e.target,lockTarget:e.lockTarget,initialPrompt:e.prompt,context:e.context,initialMode:e.mode,initialBlockPath:e.blockPath,onInsertCell:m,onOpenBlock:x},`${e.target}:${e.mode??"create"}:${e.blockPath??""}:${e.prompt??""}:${e.sourceLabel??""}`)})]})})}const v={position:"fixed",inset:0,zIndex:60,background:"rgba(0,0,0,0.32)",display:"flex",alignItems:"center",justifyContent:"center",padding:16};export{z as AiBuildDialog};
1
+ import{u,t as f,r as a,j as o,S as h,m as b}from"./index-DJRMz64S.js";import{s as g}from"./ai-build-bus-1BR770pY.js";import{u as y,A as k}from"./AiBuildResult-Cob_Lj05.js";import{X as j}from"./x-B4coLiOl.js";import"./react-CRB3T2We.js";import"./user-round-Bfu7fosn.js";import"./triangle-alert-COWnsSdh.js";import"./rotate-ccw-D_9U9o7X.js";function z(){const{state:n,dispatch:c}=u(),t=f[n.themeMode],[e,l]=a.useState(null),p=y();if(a.useEffect(()=>g(i=>l(i)),[]),!e)return null;const s=()=>l(null),m=i=>{const r=i.trim();if(!r)return;const d=b("sql",r);d.name="ai_sql_preview",c({type:"ADD_CELL",cell:d})},x=(i,r)=>{p(i,r).finally(s)};return o.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"Ask AI to build",style:v,children:o.jsxs("div",{style:{width:"min(720px, calc(100vw - 32px))",maxHeight:"min(760px, calc(100vh - 64px))",background:t.appBg,border:`1px solid ${t.headerBorder}`,borderRadius:12,boxShadow:"0 24px 80px rgba(0,0,0,0.34)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"11px 14px",borderBottom:`1px solid ${t.headerBorder}`},children:[o.jsx("div",{style:{width:30,height:30,borderRadius:8,background:`${t.accent}16`,border:`1px solid ${t.accent}38`,color:t.accent,display:"inline-flex",alignItems:"center",justifyContent:"center",flex:"0 0 auto"},children:o.jsx(h,{size:16,strokeWidth:2.2})}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsx("div",{style:{fontSize:14,fontWeight:850,color:t.textPrimary,fontFamily:t.font},children:e.mode==="edit"?"Ask AI to modify a block":"Ask AI to build a block"}),o.jsx("div",{style:{fontSize:11.5,color:t.textMuted,fontFamily:t.font,marginTop:1},children:e.sourceLabel??(e.mode==="edit"?"Describe the change and review a before/after diff. Nothing is certified.":"Generate a draft from your dbt + semantic context. Nothing is certified.")})]}),o.jsx("button",{type:"button",onClick:s,title:"Close",style:{width:28,height:28,borderRadius:6,border:`1px solid ${t.btnBorder}`,background:t.btnBg,color:t.textSecondary,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},children:o.jsx(j,{size:15,strokeWidth:2})})]}),o.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto"},children:o.jsx(k,{themeMode:n.themeMode,initialTarget:e.target,lockTarget:e.lockTarget,initialPrompt:e.prompt,context:e.context,initialMode:e.mode,initialBlockPath:e.blockPath,onInsertCell:m,onOpenBlock:x},`${e.target}:${e.mode??"create"}:${e.blockPath??""}:${e.prompt??""}:${e.sourceLabel??""}`)})]})})}const v={position:"fixed",inset:0,zIndex:60,background:"rgba(0,0,0,0.32)",display:"flex",alignItems:"center",justifyContent:"center",padding:16};export{z as AiBuildDialog};
@@ -1,33 +1,33 @@
1
- import{c as M,u as U,r as u,a as E,j as t,B as Q,t as Ce,S as V,L as oe,a5 as Be,ap as Fe,f as K,b as se,T as re,d as le,e as ae,R as de}from"./index-Cpx47jCH.js";import{U as ce,G as pe}from"./user-round-J4PQHxo9.js";import{T as ue}from"./triangle-alert-SyuSZ4ht.js";import{R as Y}from"./rotate-ccw-Di0kRnrM.js";/**
1
+ import{c as F,u as U,r as u,a as E,j as t,B as Q,t as Ce,S as V,L as oe,a5 as Be,ar as Me,f as K,b as re,T as se,d as le,e as ae,R as de}from"./index-DJRMz64S.js";import{U as ce,G as pe}from"./user-round-Bfu7fosn.js";import{T as ue}from"./triangle-alert-COWnsSdh.js";import{R as Y}from"./rotate-ccw-D_9U9o7X.js";/**
2
2
  * @license lucide-react v0.563.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const Me=[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Re=M("badge-check",Me);/**
6
+ */const Fe=[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Re=F("badge-check",Fe);/**
7
7
  * @license lucide-react v0.563.0 - ISC
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */const Le=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],fe=M("file-code-corner",Le);/**
11
+ */const Le=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],fe=F("file-code-corner",Le);/**
12
12
  * @license lucide-react v0.563.0 - ISC
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
- */const $e=[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v7",key:"1yj91y"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["circle",{cx:"19",cy:"18",r:"3",key:"1qljk2"}],["path",{d:"M12 18H7a2 2 0 0 1-2-2V9",key:"16sdep"}],["path",{d:"m9 15 3 3-3 3",key:"1m3kbl"}]],_e=M("git-compare-arrows",$e);/**
16
+ */const $e=[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v7",key:"1yj91y"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["circle",{cx:"19",cy:"18",r:"3",key:"1qljk2"}],["path",{d:"M12 18H7a2 2 0 0 1-2-2V9",key:"16sdep"}],["path",{d:"m9 15 3 3-3 3",key:"1m3kbl"}]],_e=F("git-compare-arrows",$e);/**
17
17
  * @license lucide-react v0.563.0 - ISC
18
18
  *
19
19
  * This source code is licensed under the ISC license.
20
20
  * See the LICENSE file in the root directory of this source tree.
21
- */const De=[["path",{d:"m15 12-9.373 9.373a1 1 0 0 1-3.001-3L12 9",key:"1hayfq"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{d:"m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172v-.344a2 2 0 0 0-.586-1.414l-1.657-1.657A6 6 0 0 0 12.516 3H9l1.243 1.243A6 6 0 0 1 12 8.485V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",key:"15ts47"}]],Ie=M("hammer",De);/**
21
+ */const De=[["path",{d:"m15 12-9.373 9.373a1 1 0 0 1-3.001-3L12 9",key:"1hayfq"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{d:"m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172v-.344a2 2 0 0 0-.586-1.414l-1.657-1.657A6 6 0 0 0 12.516 3H9l1.243 1.243A6 6 0 0 1 12 8.485V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",key:"15ts47"}]],Ie=F("hammer",De);/**
22
22
  * @license lucide-react v0.563.0 - ISC
23
23
  *
24
24
  * This source code is licensed under the ISC license.
25
25
  * See the LICENSE file in the root directory of this source tree.
26
- */const Pe=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],xe=M("square-pen",Pe);/**
26
+ */const Pe=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],xe=F("square-pen",Pe);/**
27
27
  * @license lucide-react v0.563.0 - ISC
28
28
  *
29
29
  * This source code is licensed under the ISC license.
30
30
  * See the LICENSE file in the root directory of this source tree.
31
- */const qe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],A=M("square-plus",qe),Ee={cell:"Cell",block:"Block"};function ot({themeMode:e,initialTarget:n="cell",lockTarget:i=!1,initialPrompt:d="",context:s,onInsertCell:p,onOpenBlock:a,quickActions:x,initialMode:f="create",initialBlockPath:c}){const r=Ce[e],{dispatch:o}=U(),y=u.useCallback(()=>{o({type:"SET_MAIN_VIEW",view:"skills"})},[o]),[g,R]=u.useState(f==="edit"?"block":n),[k,L]=u.useState(d),[z,v]=u.useState("idle"),[m,j]=u.useState(null),[W,b]=u.useState(null),[C,Se]=u.useState(null),[ve,D]=u.useState(!1),T=u.useRef(""),[S,we]=u.useState(f),[B,X]=u.useState(c),[I,ze]=u.useState(void 0);u.useEffect(()=>{let l=!1;return E.getIdentity().then(h=>{!l&&(h!=null&&h.owner)&&Se(h.owner)}).catch(()=>{}),()=>{l=!0}},[]);const P=u.useCallback(async(l,h)=>{const O=l.trim();if(!O)return;const te=h==="block"&&S==="edit";if(!(te&&!B)){T.current=O,v("building"),b(null),D(!1);try{const _=await E.aiBuild({prompt:O,context:s,target:h,...C?{owner:C}:{},...h==="block"?{mode:S}:{},...te&&B?{blockPath:B}:{},...I?{domain:I}:{}});j(_),v("ready")}catch(_){b(_ instanceof Error&&_.message?_.message:"Could not build that. Try rewording the request."),j(null),v("error")}}},[s,C,S,B,I]),ee=u.useCallback(()=>{P(k,g)},[k,P,g]),We=u.useCallback(l=>{const h=l.target&&!i?l.target:g;l.target&&!i&&R(l.target),L(l.prompt),P(l.prompt,h)},[i,P,g]),H=u.useCallback(()=>{v("idle"),j(null),b(null),D(!1),!k.trim()&&T.current&&L(T.current)},[k]),$=u.useCallback(()=>{j(null),b(null),D(!1),v("idle")},[]),F=z==="building",q=g==="block"&&S==="edit",N=q&&!B;return t.jsx("div",{style:{display:"flex",flexDirection:"column",minHeight:0,height:"100%",overflow:"auto"},children:t.jsxs("div",{style:{padding:12,display:"grid",gap:10},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[t.jsx("div",{role:"group","aria-label":"Build target",style:ne(r),children:["cell","block"].map(l=>{const h=g===l;return t.jsxs("button",{type:"button",disabled:i&&!h,onClick:()=>{i||(R(l),$())},"aria-pressed":h,style:ie(r,h,i&&!h),children:[l==="cell"?t.jsx(A,{size:13,strokeWidth:2}):t.jsx(Q,{size:13,strokeWidth:2}),Ee[l]]},l)})}),t.jsx("span",{style:{fontSize:11,color:r.textMuted,fontFamily:r.font},children:g==="cell"?"Create a review-required SQL preview for a notebook cell.":S==="edit"?"Rewrite an existing draft DQL block.":"Generate a reusable draft DQL block."}),C&&t.jsxs("span",{title:"Drafts are attributed to you",style:{marginLeft:"auto",display:"inline-flex",alignItems:"center",gap:5,fontSize:11,color:r.textMuted,fontFamily:r.font},children:[t.jsx(ce,{size:12,strokeWidth:2}),"drafting as ",C]})]}),g==="block"?t.jsx(Ke,{t:r,value:I,onChange:ze}):null,g==="block"?t.jsxs("div",{style:{display:"grid",gap:8},children:[t.jsx("div",{role:"group","aria-label":"Block build mode",style:ne(r),children:["create","edit"].map(l=>{const h=S===l;return t.jsxs("button",{type:"button",onClick:()=>{we(l),$(),l==="create"&&X(void 0)},"aria-pressed":h,style:ie(r,h,!1),children:[l==="create"?t.jsx(A,{size:13,strokeWidth:2}):t.jsx(xe,{size:13,strokeWidth:2}),l==="create"?"New block":"Modify existing"]},l)})}),S==="edit"?t.jsx(Ve,{t:r,selectedPath:B,onSelect:l=>{X(l),$()}}):null]}):null,x&&x.length>0?t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:x.map(l=>t.jsxs("button",{type:"button",disabled:F,onClick:()=>We(l),style:{...w(r),opacity:F?.6:1},children:[t.jsx(V,{size:12,strokeWidth:2})," ",l.label]},l.label))}):null,t.jsxs("div",{style:{display:"grid",gap:7},children:[t.jsx("textarea",{value:k,onChange:l=>L(l.target.value),onKeyDown:l=>{l.key==="Enter"&&(l.metaKey||l.ctrlKey)&&(l.preventDefault(),ee())},rows:3,placeholder:g==="cell"?'Describe the preview SQL you want, e.g. "monthly revenue by region for the last 12 months".':S==="edit"?'Describe the change, e.g. "add a 12-month trailing window and exclude test accounts".':'Describe the reusable block, e.g. "active customers by signup cohort".',style:Ze(r)}),s!=null&&s.cellSql?t.jsxs("div",{style:{fontSize:10.5,color:r.textMuted,fontFamily:r.font},children:["Using the active SQL cell",s.selection?" and your selection":""," as context."]}):null,N?t.jsx("div",{style:{fontSize:10.5,color:r.textMuted,fontFamily:r.font},children:"Pick the block you want to modify above."}):null,t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:t.jsxs("button",{type:"button",onClick:ee,disabled:F||!k.trim()||N,style:{...J(r),opacity:F||!k.trim()||N?.6:1},children:[F?t.jsx(oe,{size:13,strokeWidth:2}):t.jsx(Ie,{size:13,strokeWidth:2}),F?q?"Updating…":"Building…":q?"Update block":"Build"]})})]}),z==="error"&&t.jsx(Ye,{t:r,message:W??"Could not build that.",onRefine:H}),z==="ready"&&(m==null?void 0:m.target)==="cell"&&t.jsx(Te,{t:r,sql:m.sql,explanation:m.explanation,appliedSkills:m.appliedSkills,diagnostics:m.diagnostics,route:m.route,inserted:ve,onInsert:()=>{p==null||p(m.sql),D(!0)},onRefine:H,onDiscard:$,onOpenSkills:y}),z==="ready"&&(m==null?void 0:m.target)==="block"&&t.jsx(He,{t:r,result:m,owner:C,editing:q,onOpen:()=>a==null?void 0:a(m.path,m.name),onRefine:H,onDiscard:$,onOpenSkills:y})]})})}function Ae(){return{heading:"SQL preview",badge:"Review-required",guidance:"Use this as a notebook preview. For reusable governed analytics, promote the reviewed logic into a DQL draft.",insertLabel:"Insert preview",insertedLabel:"Preview inserted"}}function Te({t:e,sql:n,explanation:i,appliedSkills:d,diagnostics:s,route:p,inserted:a,onInsert:x,onRefine:f,onDiscard:c,onOpenSkills:r}){const o=Ae();return t.jsxs("section",{style:Z(e),children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t.jsx(V,{size:14,strokeWidth:2,color:e.accent}),t.jsx("div",{style:{fontSize:12.5,fontWeight:800,color:e.textPrimary,fontFamily:e.font},children:o.heading}),t.jsx("span",{style:je(e),children:o.badge}),t.jsx(ge,{t:e,route:p})]}),i?t.jsx("div",{style:{fontSize:12,color:e.textSecondary,lineHeight:1.5,fontFamily:e.font},children:i}):null,t.jsx("div",{style:{fontSize:11.5,color:e.textMuted,lineHeight:1.45,fontFamily:e.font},children:o.guidance}),t.jsx(me,{t:e,code:n}),t.jsx(he,{t:e,skills:d,onOpenSkills:r}),t.jsx(ye,{t:e,diagnostics:s}),t.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[t.jsxs("button",{type:"button",onClick:x,disabled:a,style:{...J(e),opacity:a?.65:1},children:[a?t.jsx(K,{size:13,strokeWidth:2}):t.jsx(A,{size:13,strokeWidth:2}),a?o.insertedLabel:o.insertLabel]}),t.jsxs("button",{type:"button",onClick:f,style:w(e),children:[t.jsx(Y,{size:13,strokeWidth:2})," Refine"]}),t.jsxs("button",{type:"button",onClick:c,style:w(e),children:[t.jsx(re,{size:13,strokeWidth:2})," Discard"]})]})]})}function He({t:e,result:n,owner:i,editing:d,onOpen:s,onRefine:p,onDiscard:a,onOpenSkills:x}){const[f,c]=u.useState(!1),{name:r,description:o,sqlPreview:y,grain:g,outputs:R,examples:k,certifierVerdict:L,appliedSkills:z,diagnostics:v,route:m,previousSql:j}=n,W=d||typeof j=="string";return t.jsxs("section",{style:Z(e),children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t.jsx(Q,{size:14,strokeWidth:2,color:e.accent}),t.jsx("div",{style:{fontSize:13,fontWeight:850,color:e.textPrimary,fontFamily:e.font},children:r}),t.jsx("span",{style:je(e),children:W?"AI-edited · draft":"AI-generated · draft"}),g?t.jsxs("span",{style:Je(e),children:["grain ",g]}):null,t.jsx(ge,{t:e,route:m})]}),o?t.jsx("div",{style:{fontSize:12,color:e.textSecondary,lineHeight:1.5,fontFamily:e.font},children:o}):null,W&&typeof j=="string"?t.jsx(Oe,{t:e,previousSql:j,nextSql:y}):t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>c(b=>!b),style:ke(e),children:[f?t.jsx(le,{size:13,strokeWidth:2}):t.jsx(ae,{size:13,strokeWidth:2}),f?"Hide SQL this block will run":"Show SQL this block will run"]}),f?t.jsx("div",{style:{marginTop:7},children:t.jsx(me,{t:e,code:y})}):null]}),R.length>0?t.jsxs("div",{style:{display:"grid",gap:5},children:[t.jsx(G,{t:e,children:"Outputs"}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:5},children:R.map(b=>t.jsx("span",{style:Xe(e),children:b},b))})]}):null,k.length>0?t.jsxs("div",{style:{display:"grid",gap:5},children:[t.jsx(G,{t:e,children:"Answers questions like"}),t.jsx("ul",{style:{margin:0,padding:"0 0 0 16px",display:"grid",gap:3},children:k.slice(0,3).map(b=>t.jsx("li",{style:{fontSize:11.5,color:e.textSecondary,lineHeight:1.45,fontFamily:e.font},children:b},b))})]}):null,t.jsx(Qe,{t:e,verdict:L}),t.jsx(he,{t:e,skills:z,onOpenSkills:x}),t.jsx(ye,{t:e,diagnostics:v}),i?t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:11,color:e.textMuted,fontFamily:e.font},children:[t.jsx(ce,{size:12,strokeWidth:2})," drafting as ",i]}):null,t.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[t.jsxs("button",{type:"button",onClick:s,style:J(e),children:[W?t.jsx(xe,{size:13,strokeWidth:2}):t.jsx(Q,{size:13,strokeWidth:2}),W?"Update block in Block Studio":"Open in Block Studio"]}),t.jsxs("button",{type:"button",onClick:p,style:w(e),children:[t.jsx(Y,{size:13,strokeWidth:2})," Refine"]}),t.jsxs("button",{type:"button",onClick:a,style:w(e),children:[t.jsx(re,{size:13,strokeWidth:2})," Discard"]})]})]})}function Ne(e,n){const i=e.replace(/\s+$/g,"").split(`
31
+ */const qe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],A=F("square-plus",qe),Ee={cell:"Cell",block:"Block"};function ot({themeMode:e,initialTarget:n="cell",lockTarget:i=!1,initialPrompt:d="",context:r,onInsertCell:p,onOpenBlock:a,quickActions:x,initialMode:f="create",initialBlockPath:c}){const s=Ce[e],{dispatch:o}=U(),y=u.useCallback(()=>{o({type:"SET_MAIN_VIEW",view:"skills"})},[o]),[g,R]=u.useState(f==="edit"?"block":n),[k,L]=u.useState(d),[z,v]=u.useState("idle"),[m,j]=u.useState(null),[W,b]=u.useState(null),[C,Se]=u.useState(null),[ve,D]=u.useState(!1),T=u.useRef(""),[S,we]=u.useState(f),[B,X]=u.useState(c),[I,ze]=u.useState(void 0);u.useEffect(()=>{let l=!1;return E.getIdentity().then(h=>{!l&&(h!=null&&h.owner)&&Se(h.owner)}).catch(()=>{}),()=>{l=!0}},[]);const P=u.useCallback(async(l,h)=>{const O=l.trim();if(!O)return;const te=h==="block"&&S==="edit";if(!(te&&!B)){T.current=O,v("building"),b(null),D(!1);try{const _=await E.aiBuild({prompt:O,context:r,target:h,...C?{owner:C}:{},...h==="block"?{mode:S}:{},...te&&B?{blockPath:B}:{},...I?{domain:I}:{}});j(_),v("ready")}catch(_){b(_ instanceof Error&&_.message?_.message:"Could not build that. Try rewording the request."),j(null),v("error")}}},[r,C,S,B,I]),ee=u.useCallback(()=>{P(k,g)},[k,P,g]),We=u.useCallback(l=>{const h=l.target&&!i?l.target:g;l.target&&!i&&R(l.target),L(l.prompt),P(l.prompt,h)},[i,P,g]),H=u.useCallback(()=>{v("idle"),j(null),b(null),D(!1),!k.trim()&&T.current&&L(T.current)},[k]),$=u.useCallback(()=>{j(null),b(null),D(!1),v("idle")},[]),M=z==="building",q=g==="block"&&S==="edit",N=q&&!B;return t.jsx("div",{style:{display:"flex",flexDirection:"column",minHeight:0,height:"100%",overflow:"auto"},children:t.jsxs("div",{style:{padding:12,display:"grid",gap:10},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[t.jsx("div",{role:"group","aria-label":"Build target",style:ne(s),children:["cell","block"].map(l=>{const h=g===l;return t.jsxs("button",{type:"button",disabled:i&&!h,onClick:()=>{i||(R(l),$())},"aria-pressed":h,style:ie(s,h,i&&!h),children:[l==="cell"?t.jsx(A,{size:13,strokeWidth:2}):t.jsx(Q,{size:13,strokeWidth:2}),Ee[l]]},l)})}),t.jsx("span",{style:{fontSize:11,color:s.textMuted,fontFamily:s.font},children:g==="cell"?"Create a review-required SQL preview for a notebook cell.":S==="edit"?"Rewrite an existing draft DQL block.":"Generate a reusable draft DQL block."}),C&&t.jsxs("span",{title:"Drafts are attributed to you",style:{marginLeft:"auto",display:"inline-flex",alignItems:"center",gap:5,fontSize:11,color:s.textMuted,fontFamily:s.font},children:[t.jsx(ce,{size:12,strokeWidth:2}),"drafting as ",C]})]}),g==="block"?t.jsx(Ke,{t:s,value:I,onChange:ze}):null,g==="block"?t.jsxs("div",{style:{display:"grid",gap:8},children:[t.jsx("div",{role:"group","aria-label":"Block build mode",style:ne(s),children:["create","edit"].map(l=>{const h=S===l;return t.jsxs("button",{type:"button",onClick:()=>{we(l),$(),l==="create"&&X(void 0)},"aria-pressed":h,style:ie(s,h,!1),children:[l==="create"?t.jsx(A,{size:13,strokeWidth:2}):t.jsx(xe,{size:13,strokeWidth:2}),l==="create"?"New block":"Modify existing"]},l)})}),S==="edit"?t.jsx(Ve,{t:s,selectedPath:B,onSelect:l=>{X(l),$()}}):null]}):null,x&&x.length>0?t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:x.map(l=>t.jsxs("button",{type:"button",disabled:M,onClick:()=>We(l),style:{...w(s),opacity:M?.6:1},children:[t.jsx(V,{size:12,strokeWidth:2})," ",l.label]},l.label))}):null,t.jsxs("div",{style:{display:"grid",gap:7},children:[t.jsx("textarea",{value:k,onChange:l=>L(l.target.value),onKeyDown:l=>{l.key==="Enter"&&(l.metaKey||l.ctrlKey)&&(l.preventDefault(),ee())},rows:3,placeholder:g==="cell"?'Describe the preview SQL you want, e.g. "monthly revenue by region for the last 12 months".':S==="edit"?'Describe the change, e.g. "add a 12-month trailing window and exclude test accounts".':'Describe the reusable block, e.g. "active customers by signup cohort".',style:Ze(s)}),r!=null&&r.cellSql?t.jsxs("div",{style:{fontSize:10.5,color:s.textMuted,fontFamily:s.font},children:["Using the active SQL cell",r.selection?" and your selection":""," as context."]}):null,N?t.jsx("div",{style:{fontSize:10.5,color:s.textMuted,fontFamily:s.font},children:"Pick the block you want to modify above."}):null,t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:t.jsxs("button",{type:"button",onClick:ee,disabled:M||!k.trim()||N,style:{...J(s),opacity:M||!k.trim()||N?.6:1},children:[M?t.jsx(oe,{size:13,strokeWidth:2}):t.jsx(Ie,{size:13,strokeWidth:2}),M?q?"Updating…":"Building…":q?"Update block":"Build"]})})]}),z==="error"&&t.jsx(Ye,{t:s,message:W??"Could not build that.",onRefine:H}),z==="ready"&&(m==null?void 0:m.target)==="cell"&&t.jsx(Te,{t:s,sql:m.sql,explanation:m.explanation,appliedSkills:m.appliedSkills,diagnostics:m.diagnostics,route:m.route,inserted:ve,onInsert:()=>{p==null||p(m.sql),D(!0)},onRefine:H,onDiscard:$,onOpenSkills:y}),z==="ready"&&(m==null?void 0:m.target)==="block"&&t.jsx(He,{t:s,result:m,owner:C,editing:q,onOpen:()=>a==null?void 0:a(m.path,m.name),onRefine:H,onDiscard:$,onOpenSkills:y})]})})}function Ae(){return{heading:"SQL preview",badge:"Review-required",guidance:"Use this as a notebook preview. For reusable governed analytics, promote the reviewed logic into a DQL draft.",insertLabel:"Insert preview",insertedLabel:"Preview inserted"}}function Te({t:e,sql:n,explanation:i,appliedSkills:d,diagnostics:r,route:p,inserted:a,onInsert:x,onRefine:f,onDiscard:c,onOpenSkills:s}){const o=Ae();return t.jsxs("section",{style:Z(e),children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t.jsx(V,{size:14,strokeWidth:2,color:e.accent}),t.jsx("div",{style:{fontSize:12.5,fontWeight:800,color:e.textPrimary,fontFamily:e.font},children:o.heading}),t.jsx("span",{style:je(e),children:o.badge}),t.jsx(ge,{t:e,route:p})]}),i?t.jsx("div",{style:{fontSize:12,color:e.textSecondary,lineHeight:1.5,fontFamily:e.font},children:i}):null,t.jsx("div",{style:{fontSize:11.5,color:e.textMuted,lineHeight:1.45,fontFamily:e.font},children:o.guidance}),t.jsx(me,{t:e,code:n}),t.jsx(he,{t:e,skills:d,onOpenSkills:s}),t.jsx(ye,{t:e,diagnostics:r}),t.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[t.jsxs("button",{type:"button",onClick:x,disabled:a,style:{...J(e),opacity:a?.65:1},children:[a?t.jsx(K,{size:13,strokeWidth:2}):t.jsx(A,{size:13,strokeWidth:2}),a?o.insertedLabel:o.insertLabel]}),t.jsxs("button",{type:"button",onClick:f,style:w(e),children:[t.jsx(Y,{size:13,strokeWidth:2})," Refine"]}),t.jsxs("button",{type:"button",onClick:c,style:w(e),children:[t.jsx(se,{size:13,strokeWidth:2})," Discard"]})]})]})}function He({t:e,result:n,owner:i,editing:d,onOpen:r,onRefine:p,onDiscard:a,onOpenSkills:x}){const[f,c]=u.useState(!1),{name:s,description:o,sqlPreview:y,grain:g,outputs:R,examples:k,certifierVerdict:L,appliedSkills:z,diagnostics:v,route:m,previousSql:j}=n,W=d||typeof j=="string";return t.jsxs("section",{style:Z(e),children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t.jsx(Q,{size:14,strokeWidth:2,color:e.accent}),t.jsx("div",{style:{fontSize:13,fontWeight:850,color:e.textPrimary,fontFamily:e.font},children:s}),t.jsx("span",{style:je(e),children:W?"AI-edited · draft":"AI-generated · draft"}),g?t.jsxs("span",{style:Je(e),children:["grain ",g]}):null,t.jsx(ge,{t:e,route:m})]}),o?t.jsx("div",{style:{fontSize:12,color:e.textSecondary,lineHeight:1.5,fontFamily:e.font},children:o}):null,W&&typeof j=="string"?t.jsx(Oe,{t:e,previousSql:j,nextSql:y}):t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>c(b=>!b),style:ke(e),children:[f?t.jsx(le,{size:13,strokeWidth:2}):t.jsx(ae,{size:13,strokeWidth:2}),f?"Hide SQL this block will run":"Show SQL this block will run"]}),f?t.jsx("div",{style:{marginTop:7},children:t.jsx(me,{t:e,code:y})}):null]}),R.length>0?t.jsxs("div",{style:{display:"grid",gap:5},children:[t.jsx(G,{t:e,children:"Outputs"}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:5},children:R.map(b=>t.jsx("span",{style:Xe(e),children:b},b))})]}):null,k.length>0?t.jsxs("div",{style:{display:"grid",gap:5},children:[t.jsx(G,{t:e,children:"Answers questions like"}),t.jsx("ul",{style:{margin:0,padding:"0 0 0 16px",display:"grid",gap:3},children:k.slice(0,3).map(b=>t.jsx("li",{style:{fontSize:11.5,color:e.textSecondary,lineHeight:1.45,fontFamily:e.font},children:b},b))})]}):null,t.jsx(Qe,{t:e,verdict:L}),t.jsx(he,{t:e,skills:z,onOpenSkills:x}),t.jsx(ye,{t:e,diagnostics:v}),i?t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:11,color:e.textMuted,fontFamily:e.font},children:[t.jsx(ce,{size:12,strokeWidth:2})," drafting as ",i]}):null,t.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[t.jsxs("button",{type:"button",onClick:r,style:J(e),children:[W?t.jsx(xe,{size:13,strokeWidth:2}):t.jsx(Q,{size:13,strokeWidth:2}),W?"Update block in Block Studio":"Open in Block Studio"]}),t.jsxs("button",{type:"button",onClick:p,style:w(e),children:[t.jsx(Y,{size:13,strokeWidth:2})," Refine"]}),t.jsxs("button",{type:"button",onClick:a,style:w(e),children:[t.jsx(se,{size:13,strokeWidth:2})," Discard"]})]})]})}function Ne(e,n){const i=e.replace(/\s+$/g,"").split(`
32
32
  `),d=n.replace(/\s+$/g,"").split(`
33
- `),s=i.length,p=d.length,a=Array.from({length:s+1},()=>new Array(p+1).fill(0));for(let r=s-1;r>=0;r--)for(let o=p-1;o>=0;o--)a[r][o]=i[r]===d[o]?a[r+1][o+1]+1:Math.max(a[r+1][o],a[r][o+1]);const x=[];let f=0,c=0;for(;f<s&&c<p;)i[f]===d[c]?(x.push({kind:"context",text:i[f]}),f++,c++):a[f+1][c]>=a[f][c+1]?(x.push({kind:"remove",text:i[f]}),f++):(x.push({kind:"add",text:d[c]}),c++);for(;f<s;)x.push({kind:"remove",text:i[f]}),f++;for(;c<p;)x.push({kind:"add",text:d[c]}),c++;return x}function Oe({t:e,previousSql:n,nextSql:i}){const[d,s]=u.useState(!0),p=de.useMemo(()=>Ne(n.trim(),i.trim()),[n,i]),a=p.filter(c=>c.kind==="add").length,x=p.filter(c=>c.kind==="remove").length,f=a===0&&x===0;return t.jsxs("div",{style:{display:"grid",gap:7},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t.jsxs("button",{type:"button",onClick:()=>s(c=>!c),style:ke(e),children:[d?t.jsx(le,{size:13,strokeWidth:2}):t.jsx(ae,{size:13,strokeWidth:2}),t.jsx(_e,{size:13,strokeWidth:2}),d?"Hide what changed":"Show what changed"]}),f?t.jsx("span",{style:{fontSize:11,color:e.textMuted,fontFamily:e.font},children:"No SQL changes."}):t.jsxs("span",{style:{fontSize:11,color:e.textMuted,fontFamily:e.font},children:[t.jsxs("span",{style:{color:e.success,fontWeight:700},children:["+",a]})," ",t.jsxs("span",{style:{color:e.error,fontWeight:700},children:["-",x]})," line",a+x===1?"":"s"]})]}),d?t.jsx("pre",{style:{...be(e),padding:0},children:t.jsx("code",{style:{display:"block",fontFamily:e.fontMono,fontSize:11.5,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:p.map((c,r)=>t.jsxs("span",{style:{display:"block",padding:"0 11px",color:c.kind==="add"?e.success:c.kind==="remove"?e.error:e.textPrimary,background:c.kind==="add"?`${e.success}14`:c.kind==="remove"?`${e.error}14`:"transparent"},children:[t.jsx("span",{"aria-hidden":!0,style:{userSelect:"none",opacity:.7},children:c.kind==="add"?"+ ":c.kind==="remove"?"- ":" "}),c.text||" "]},r))})}):null]})}function Qe({t:e,verdict:n}){if(!n)return null;const i=n.ready&&n.blocking.length===0,d=i?[]:[...n.blocking,...n.warnings];return t.jsxs("div",{style:{display:"grid",gap:5},children:[t.jsx(G,{t:e,children:"What's missing to certify"}),i?t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:12,color:e.success,fontFamily:e.font},children:[t.jsx(K,{size:14,strokeWidth:2}),"Grain, outputs, and context are set."]}):t.jsxs("div",{style:{display:"grid",gap:4},children:[t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:12,color:e.warning,fontFamily:e.font},children:[t.jsx(ue,{size:14,strokeWidth:2}),"Needs an owner and passing tests before it can be certified."]}),d.length>0?t.jsx("ul",{style:{margin:0,padding:"0 0 0 16px",display:"grid",gap:2},children:d.map(s=>t.jsx("li",{style:{fontSize:11,color:e.textSecondary,lineHeight:1.4,fontFamily:e.font},children:s},s))}):null]})]})}function ye({t:e,diagnostics:n}){if(!n)return null;const i=n.sourceTrust==="governed_semantic_source",d=n.activeDomain?`domain ${n.activeDomain}`:"project metadata",s=n.allowedRelations.length,p=n.warnings[0];return t.jsxs("div",{style:{display:"grid",gap:3,fontSize:10.5,color:e.textMuted,lineHeight:1.4,fontFamily:e.font},children:[t.jsxs("span",{title:n.contextPackId?`Context pack ${n.contextPackId}`:void 0,children:[i?"Built from governed semantic context":"Exploratory DBT-grounded draft"," · ",d," · ",s," allowed relation",s===1?"":"s"," · review required"]}),p?t.jsx("span",{style:{color:e.warning},children:p}):null]})}function he({t:e,skills:n,onOpenSkills:i,onSuggestCorrection:d}){return!n||n.length===0?null:t.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:5,fontSize:11,color:e.textMuted,fontFamily:e.font},children:[t.jsx(pe,{size:12,strokeWidth:2}),t.jsx("span",{children:"guided by"}),n.map((s,p)=>t.jsxs(de.Fragment,{children:[p>0?t.jsx("span",{"aria-hidden":!0,style:{color:e.textMuted},children:","}):null,t.jsx("button",{type:"button",onClick:i,title:s.description??`Open the ${s.id} skill`,style:{padding:0,border:"none",background:"transparent",color:e.accent,fontSize:11,fontWeight:700,fontFamily:e.font,cursor:"pointer",textDecoration:"underline",textUnderlineOffset:2},children:s.id})]},s.id)),d&&n.length===1?t.jsx("button",{type:"button",onClick:()=>d(n[0]),style:{marginLeft:5,border:"1px solid var(--border-subtle)",borderRadius:6,background:"var(--bg-1)",color:e.accent,padding:"3px 7px",cursor:"pointer",fontSize:10},children:"Suggest skill correction"}):null]})}const Ge={certified_block:{tone:"success",icon:Re},semantic_metric:{tone:"accent",icon:V},generated_sql:{tone:"textMuted",icon:fe},business_context:{tone:"accent",icon:pe},no_answer:null};function ge({t:e,route:n}){var a;if(!n)return null;const i=Ge[n.tier];if(!i)return null;const d=i.icon,s=e[i.tone]??e.textMuted,p=((a=n.label)==null?void 0:a.trim())||Ue(n);return t.jsxs("span",{title:n.ref?`${p} (${n.ref})`:p,style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:10.5,fontWeight:700,color:s,background:`${s}14`,border:`1px solid ${s}3a`,borderRadius:999,padding:"2px 9px",fontFamily:e.font,maxWidth:"100%"},children:[t.jsx(d,{size:11,strokeWidth:2.2,style:{flexShrink:0}}),t.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p})]})}function Ue(e){switch(e.tier){case"certified_block":return e.ref?`Certified block ${e.ref}`:"Certified block";case"semantic_metric":return e.ref?`Answered from metric ${e.ref}`:"Answered from metric";case"generated_sql":return"Generated SQL preview";case"business_context":return"From business context";default:return""}}function Ve({t:e,selectedPath:n,onSelect:i}){const[d,s]=u.useState([]),[p,a]=u.useState(!0),[x,f]=u.useState("");u.useEffect(()=>{let o=!1;return a(!0),E.getBlockLibrary().then(y=>{o||s(Array.isArray(y==null?void 0:y.blocks)?y.blocks.map(g=>({name:g.name,domain:g.domain,path:g.path})):[])}).catch(()=>{o||s([])}).finally(()=>{o||a(!1)}),()=>{o=!0}},[]);const c=d.filter(o=>{if(!x.trim())return!0;const y=x.toLowerCase();return o.name.toLowerCase().includes(y)||o.path.toLowerCase().includes(y)||(o.domain??"").toLowerCase().includes(y)}).slice(0,40),r=d.find(o=>o.path===n);return t.jsxs("div",{style:{display:"grid",gap:7,border:`1px solid ${e.cellBorder}`,borderRadius:8,background:e.cellBg,padding:9},children:[t.jsxs("div",{style:{position:"relative"},children:[t.jsx(Fe,{size:13,strokeWidth:2,color:e.textMuted,style:{position:"absolute",left:9,top:"50%",transform:"translateY(-50%)"}}),t.jsx("input",{type:"text",value:x,onChange:o=>f(o.target.value),placeholder:r?`Modifying ${r.name} — search to change`:"Search blocks to modify…",style:{width:"100%",border:`1px solid ${e.btnBorder}`,borderRadius:7,background:e.appBg,color:e.textPrimary,fontSize:12,fontFamily:e.font,padding:"7px 9px 7px 28px",boxSizing:"border-box"}})]}),p?t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:11.5,color:e.textMuted,fontFamily:e.font,padding:"4px 2px"},children:[t.jsx(oe,{size:12,strokeWidth:2})," Loading blocks…"]}):d.length===0?t.jsxs("div",{style:{fontSize:11.5,color:e.textMuted,fontFamily:e.font,padding:"2px 2px",lineHeight:1.45},children:["No blocks found. Type the block file path you want to modify, then press Enter.",t.jsx("input",{type:"text",defaultValue:n??"",onKeyDown:o=>{if(o.key==="Enter"){const y=o.target.value.trim();y&&i(y)}},placeholder:"blocks/revenue_by_region.dql",style:{marginTop:6,width:"100%",border:`1px solid ${e.btnBorder}`,borderRadius:7,background:e.appBg,color:e.textPrimary,fontSize:12,fontFamily:e.fontMono,padding:"7px 9px",boxSizing:"border-box"}})]}):t.jsx("div",{style:{display:"grid",gap:3,maxHeight:184,overflow:"auto"},children:c.length===0?t.jsxs("div",{style:{fontSize:11.5,color:e.textMuted,fontFamily:e.font,padding:"4px 2px"},children:["No blocks match “",x,"”."]}):c.map(o=>{const y=o.path===n;return t.jsxs("button",{type:"button",onClick:()=>i(o.path),style:{display:"flex",alignItems:"center",gap:8,textAlign:"left",width:"100%",border:`1px solid ${y?e.accent:"transparent"}`,background:y?`${e.accent}14`:"transparent",borderRadius:6,padding:"6px 8px",cursor:"pointer"},children:[t.jsx(fe,{size:13,strokeWidth:2,color:y?e.accent:e.textMuted,style:{flexShrink:0}}),t.jsxs("span",{style:{minWidth:0,display:"grid",gap:1},children:[t.jsx("span",{style:{fontSize:12,fontWeight:700,color:e.textPrimary,fontFamily:e.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:o.name}),t.jsxs("span",{style:{fontSize:10.5,color:e.textMuted,fontFamily:e.font,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[o.domain?`${o.domain} · `:"",o.path]})]}),y?t.jsx(K,{size:14,strokeWidth:2,color:e.accent,style:{marginLeft:"auto",flexShrink:0}}):null]},o.path)})})]})}function Ke({t:e,value:n,onChange:i}){const{state:d,dispatch:s}=U(),p=Be(n,d.authoredDomains);return t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:11,fontWeight:700,color:e.textSecondary,fontFamily:e.font},children:"Domain"}),t.jsxs("select",{value:n??"",onChange:a=>i(a.target.value||void 0),style:{border:`1px solid ${e.btnBorder}`,borderRadius:7,background:e.btnBg,color:n?e.textPrimary:e.textMuted,fontSize:12,fontFamily:e.font,padding:"5px 9px",cursor:"pointer"},children:[t.jsx("option",{value:"",children:p.length===0?"No domains yet":"No domain"}),p.map(a=>t.jsx("option",{value:a.value,disabled:a.disabled,children:a.label},a.value))]}),t.jsxs("button",{type:"button",onClick:()=>s({type:"SET_MAIN_VIEW",view:"domains"}),style:w(e),title:"Create a new domain on the Domains page",children:[t.jsx(A,{size:12,strokeWidth:2})," New"]})]})}function Ye({t:e,message:n,onRefine:i}){return t.jsxs("section",{style:{...Z(e),borderColor:`${e.error}66`},children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[t.jsx(ue,{size:15,strokeWidth:2,color:e.error,style:{marginTop:1,flexShrink:0}}),t.jsx("div",{style:{fontSize:12.5,color:e.textPrimary,lineHeight:1.5,fontFamily:e.font},children:n})]}),t.jsx("div",{style:{display:"flex",gap:8},children:t.jsxs("button",{type:"button",onClick:i,style:w(e),children:[t.jsx(Y,{size:13,strokeWidth:2})," Refine and try again"]})})]})}function me({t:e,code:n}){return t.jsx("pre",{style:be(e),children:t.jsx("code",{style:{fontFamily:e.fontMono,fontSize:11.5,color:e.textPrimary,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:n.trim()})})}function G({t:e,children:n}){return t.jsx("div",{style:{fontSize:10,fontWeight:800,letterSpacing:"0.05em",textTransform:"uppercase",color:e.textMuted,fontFamily:e.font},children:n})}function ne(e){return{display:"inline-flex",padding:2,gap:2,border:`1px solid ${e.btnBorder}`,borderRadius:8,background:e.btnBg}}function ie(e,n,i){return{display:"inline-flex",alignItems:"center",gap:5,padding:"5px 11px",borderRadius:6,border:"1px solid transparent",background:n?e.accent:"transparent",color:n?"#ffffff":e.textSecondary,fontSize:12,fontWeight:n?800:600,fontFamily:e.font,cursor:i?"default":"pointer",opacity:i?.45:1}}function Ze(e){return{width:"100%",resize:"vertical",border:`1px solid ${e.btnBorder}`,borderRadius:8,background:e.cellBg,color:e.textPrimary,fontSize:12.5,fontFamily:e.font,lineHeight:1.5,padding:"9px 11px",boxSizing:"border-box"}}function Z(e){return{border:`1px solid ${e.cellBorder}`,borderRadius:10,background:e.cellBg,padding:12,display:"grid",gap:10}}function be(e){return{margin:0,border:`1px solid ${e.cellBorder}`,borderRadius:8,background:e.appBg,padding:"9px 11px",overflow:"auto",maxHeight:280}}function J(e){return se(e,{variant:"primary",size:"md"})}function w(e){return se(e,{variant:"ghost",size:"md"})}function ke(e){return{display:"inline-flex",alignItems:"center",gap:5,padding:0,border:"none",background:"transparent",color:e.accent,fontSize:11.5,fontWeight:700,fontFamily:e.font,cursor:"pointer"}}function je(e){return{fontSize:10,fontWeight:800,letterSpacing:"0.03em",textTransform:"uppercase",color:e.accent,background:`${e.accent}18`,border:`1px solid ${e.accent}40`,borderRadius:999,padding:"2px 8px",fontFamily:e.font}}function Je(e){return{fontSize:10.5,fontWeight:600,color:e.textMuted,background:e.btnBg,border:`1px solid ${e.btnBorder}`,borderRadius:999,padding:"2px 8px",fontFamily:e.font}}function Xe(e){return{fontSize:11,fontWeight:600,color:e.textSecondary,background:e.btnBg,border:`1px solid ${e.btnBorder}`,borderRadius:6,padding:"3px 8px",fontFamily:e.fontMono}}function st(){const{state:e,dispatch:n}=U();return u.useCallback(async(i,d)=>{const s={name:i.split("/").pop()??`${d}.dql`,path:i,type:"block",folder:"blocks"};e.files.some(a=>a.path===i)||n({type:"FILE_ADDED",file:s});const p=await E.openBlockStudio(i);n({type:"OPEN_BLOCK_STUDIO",file:s,payload:p})},[n,e.files])}export{ot as A,Qe as C,he as G,ge as R,st as u};
33
+ `),r=i.length,p=d.length,a=Array.from({length:r+1},()=>new Array(p+1).fill(0));for(let s=r-1;s>=0;s--)for(let o=p-1;o>=0;o--)a[s][o]=i[s]===d[o]?a[s+1][o+1]+1:Math.max(a[s+1][o],a[s][o+1]);const x=[];let f=0,c=0;for(;f<r&&c<p;)i[f]===d[c]?(x.push({kind:"context",text:i[f]}),f++,c++):a[f+1][c]>=a[f][c+1]?(x.push({kind:"remove",text:i[f]}),f++):(x.push({kind:"add",text:d[c]}),c++);for(;f<r;)x.push({kind:"remove",text:i[f]}),f++;for(;c<p;)x.push({kind:"add",text:d[c]}),c++;return x}function Oe({t:e,previousSql:n,nextSql:i}){const[d,r]=u.useState(!0),p=de.useMemo(()=>Ne(n.trim(),i.trim()),[n,i]),a=p.filter(c=>c.kind==="add").length,x=p.filter(c=>c.kind==="remove").length,f=a===0&&x===0;return t.jsxs("div",{style:{display:"grid",gap:7},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t.jsxs("button",{type:"button",onClick:()=>r(c=>!c),style:ke(e),children:[d?t.jsx(le,{size:13,strokeWidth:2}):t.jsx(ae,{size:13,strokeWidth:2}),t.jsx(_e,{size:13,strokeWidth:2}),d?"Hide what changed":"Show what changed"]}),f?t.jsx("span",{style:{fontSize:11,color:e.textMuted,fontFamily:e.font},children:"No SQL changes."}):t.jsxs("span",{style:{fontSize:11,color:e.textMuted,fontFamily:e.font},children:[t.jsxs("span",{style:{color:e.success,fontWeight:700},children:["+",a]})," ",t.jsxs("span",{style:{color:e.error,fontWeight:700},children:["-",x]})," line",a+x===1?"":"s"]})]}),d?t.jsx("pre",{style:{...be(e),padding:0},children:t.jsx("code",{style:{display:"block",fontFamily:e.fontMono,fontSize:11.5,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:p.map((c,s)=>t.jsxs("span",{style:{display:"block",padding:"0 11px",color:c.kind==="add"?e.success:c.kind==="remove"?e.error:e.textPrimary,background:c.kind==="add"?`${e.success}14`:c.kind==="remove"?`${e.error}14`:"transparent"},children:[t.jsx("span",{"aria-hidden":!0,style:{userSelect:"none",opacity:.7},children:c.kind==="add"?"+ ":c.kind==="remove"?"- ":" "}),c.text||" "]},s))})}):null]})}function Qe({t:e,verdict:n}){if(!n)return null;const i=n.ready&&n.blocking.length===0,d=i?[]:[...n.blocking,...n.warnings];return t.jsxs("div",{style:{display:"grid",gap:5},children:[t.jsx(G,{t:e,children:"What's missing to certify"}),i?t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:12,color:e.success,fontFamily:e.font},children:[t.jsx(K,{size:14,strokeWidth:2}),"Grain, outputs, and context are set."]}):t.jsxs("div",{style:{display:"grid",gap:4},children:[t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:12,color:e.warning,fontFamily:e.font},children:[t.jsx(ue,{size:14,strokeWidth:2}),"Needs an owner and passing tests before it can be certified."]}),d.length>0?t.jsx("ul",{style:{margin:0,padding:"0 0 0 16px",display:"grid",gap:2},children:d.map(r=>t.jsx("li",{style:{fontSize:11,color:e.textSecondary,lineHeight:1.4,fontFamily:e.font},children:r},r))}):null]})]})}function ye({t:e,diagnostics:n}){if(!n)return null;const i=n.sourceTrust==="governed_semantic_source",d=n.activeDomain?`domain ${n.activeDomain}`:"project metadata",r=n.allowedRelations.length,p=n.warnings[0];return t.jsxs("div",{style:{display:"grid",gap:3,fontSize:10.5,color:e.textMuted,lineHeight:1.4,fontFamily:e.font},children:[t.jsxs("span",{title:n.contextPackId?`Context pack ${n.contextPackId}`:void 0,children:[i?"Built from governed semantic context":"Exploratory DBT-grounded draft"," · ",d," · ",r," allowed relation",r===1?"":"s"," · review required"]}),p?t.jsx("span",{style:{color:e.warning},children:p}):null]})}function he({t:e,skills:n,onOpenSkills:i,onSuggestCorrection:d}){return!n||n.length===0?null:t.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:5,fontSize:11,color:e.textMuted,fontFamily:e.font},children:[t.jsx(pe,{size:12,strokeWidth:2}),t.jsx("span",{children:"guided by"}),n.map((r,p)=>t.jsxs(de.Fragment,{children:[p>0?t.jsx("span",{"aria-hidden":!0,style:{color:e.textMuted},children:","}):null,t.jsx("button",{type:"button",onClick:i,title:r.description??`Open the ${r.id} skill`,style:{padding:0,border:"none",background:"transparent",color:e.accent,fontSize:11,fontWeight:700,fontFamily:e.font,cursor:"pointer",textDecoration:"underline",textUnderlineOffset:2},children:r.id})]},r.id)),d&&n.length===1?t.jsx("button",{type:"button",onClick:()=>d(n[0]),style:{marginLeft:5,border:"1px solid var(--border-subtle)",borderRadius:6,background:"var(--bg-1)",color:e.accent,padding:"3px 7px",cursor:"pointer",fontSize:10},children:"Suggest skill correction"}):null]})}const Ge={certified_block:{tone:"success",icon:Re},semantic_metric:{tone:"accent",icon:V},generated_sql:{tone:"textMuted",icon:fe},business_context:{tone:"accent",icon:pe},no_answer:null};function ge({t:e,route:n}){var a;if(!n)return null;const i=Ge[n.tier];if(!i)return null;const d=i.icon,r=e[i.tone]??e.textMuted,p=((a=n.label)==null?void 0:a.trim())||Ue(n);return t.jsxs("span",{title:n.ref?`${p} (${n.ref})`:p,style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:10.5,fontWeight:700,color:r,background:`${r}14`,border:`1px solid ${r}3a`,borderRadius:999,padding:"2px 9px",fontFamily:e.font,maxWidth:"100%"},children:[t.jsx(d,{size:11,strokeWidth:2.2,style:{flexShrink:0}}),t.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p})]})}function Ue(e){switch(e.tier){case"certified_block":return e.ref?`Certified block ${e.ref}`:"Certified block";case"semantic_metric":return e.ref?`Answered from metric ${e.ref}`:"Answered from metric";case"generated_sql":return"Generated SQL preview";case"business_context":return"From business context";default:return""}}function Ve({t:e,selectedPath:n,onSelect:i}){const[d,r]=u.useState([]),[p,a]=u.useState(!0),[x,f]=u.useState("");u.useEffect(()=>{let o=!1;return a(!0),E.getBlockLibrary().then(y=>{o||r(Array.isArray(y==null?void 0:y.blocks)?y.blocks.map(g=>({name:g.name,domain:g.domain,path:g.path})):[])}).catch(()=>{o||r([])}).finally(()=>{o||a(!1)}),()=>{o=!0}},[]);const c=d.filter(o=>{if(!x.trim())return!0;const y=x.toLowerCase();return o.name.toLowerCase().includes(y)||o.path.toLowerCase().includes(y)||(o.domain??"").toLowerCase().includes(y)}).slice(0,40),s=d.find(o=>o.path===n);return t.jsxs("div",{style:{display:"grid",gap:7,border:`1px solid ${e.cellBorder}`,borderRadius:8,background:e.cellBg,padding:9},children:[t.jsxs("div",{style:{position:"relative"},children:[t.jsx(Me,{size:13,strokeWidth:2,color:e.textMuted,style:{position:"absolute",left:9,top:"50%",transform:"translateY(-50%)"}}),t.jsx("input",{type:"text",value:x,onChange:o=>f(o.target.value),placeholder:s?`Modifying ${s.name} — search to change`:"Search blocks to modify…",style:{width:"100%",border:`1px solid ${e.btnBorder}`,borderRadius:7,background:e.appBg,color:e.textPrimary,fontSize:12,fontFamily:e.font,padding:"7px 9px 7px 28px",boxSizing:"border-box"}})]}),p?t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:11.5,color:e.textMuted,fontFamily:e.font,padding:"4px 2px"},children:[t.jsx(oe,{size:12,strokeWidth:2})," Loading blocks…"]}):d.length===0?t.jsxs("div",{style:{fontSize:11.5,color:e.textMuted,fontFamily:e.font,padding:"2px 2px",lineHeight:1.45},children:["No blocks found. Type the block file path you want to modify, then press Enter.",t.jsx("input",{type:"text",defaultValue:n??"",onKeyDown:o=>{if(o.key==="Enter"){const y=o.target.value.trim();y&&i(y)}},placeholder:"blocks/revenue_by_region.dql",style:{marginTop:6,width:"100%",border:`1px solid ${e.btnBorder}`,borderRadius:7,background:e.appBg,color:e.textPrimary,fontSize:12,fontFamily:e.fontMono,padding:"7px 9px",boxSizing:"border-box"}})]}):t.jsx("div",{style:{display:"grid",gap:3,maxHeight:184,overflow:"auto"},children:c.length===0?t.jsxs("div",{style:{fontSize:11.5,color:e.textMuted,fontFamily:e.font,padding:"4px 2px"},children:["No blocks match “",x,"”."]}):c.map(o=>{const y=o.path===n;return t.jsxs("button",{type:"button",onClick:()=>i(o.path),style:{display:"flex",alignItems:"center",gap:8,textAlign:"left",width:"100%",border:`1px solid ${y?e.accent:"transparent"}`,background:y?`${e.accent}14`:"transparent",borderRadius:6,padding:"6px 8px",cursor:"pointer"},children:[t.jsx(fe,{size:13,strokeWidth:2,color:y?e.accent:e.textMuted,style:{flexShrink:0}}),t.jsxs("span",{style:{minWidth:0,display:"grid",gap:1},children:[t.jsx("span",{style:{fontSize:12,fontWeight:700,color:e.textPrimary,fontFamily:e.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:o.name}),t.jsxs("span",{style:{fontSize:10.5,color:e.textMuted,fontFamily:e.font,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[o.domain?`${o.domain} · `:"",o.path]})]}),y?t.jsx(K,{size:14,strokeWidth:2,color:e.accent,style:{marginLeft:"auto",flexShrink:0}}):null]},o.path)})})]})}function Ke({t:e,value:n,onChange:i}){const{state:d,dispatch:r}=U(),p=Be(n,d.authoredDomains);return t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:11,fontWeight:700,color:e.textSecondary,fontFamily:e.font},children:"Domain"}),t.jsxs("select",{value:n??"",onChange:a=>i(a.target.value||void 0),style:{border:`1px solid ${e.btnBorder}`,borderRadius:7,background:e.btnBg,color:n?e.textPrimary:e.textMuted,fontSize:12,fontFamily:e.font,padding:"5px 9px",cursor:"pointer"},children:[t.jsx("option",{value:"",children:p.length===0?"No domains yet":"No domain"}),p.map(a=>t.jsx("option",{value:a.value,disabled:a.disabled,children:a.label},a.value))]}),t.jsxs("button",{type:"button",onClick:()=>r({type:"SET_MAIN_VIEW",view:"domains"}),style:w(e),title:"Create a new domain in the Modeling workspace",children:[t.jsx(A,{size:12,strokeWidth:2})," New"]})]})}function Ye({t:e,message:n,onRefine:i}){return t.jsxs("section",{style:{...Z(e),borderColor:`${e.error}66`},children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[t.jsx(ue,{size:15,strokeWidth:2,color:e.error,style:{marginTop:1,flexShrink:0}}),t.jsx("div",{style:{fontSize:12.5,color:e.textPrimary,lineHeight:1.5,fontFamily:e.font},children:n})]}),t.jsx("div",{style:{display:"flex",gap:8},children:t.jsxs("button",{type:"button",onClick:i,style:w(e),children:[t.jsx(Y,{size:13,strokeWidth:2})," Refine and try again"]})})]})}function me({t:e,code:n}){return t.jsx("pre",{style:be(e),children:t.jsx("code",{style:{fontFamily:e.fontMono,fontSize:11.5,color:e.textPrimary,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:n.trim()})})}function G({t:e,children:n}){return t.jsx("div",{style:{fontSize:10,fontWeight:800,letterSpacing:"0.05em",textTransform:"uppercase",color:e.textMuted,fontFamily:e.font},children:n})}function ne(e){return{display:"inline-flex",padding:2,gap:2,border:`1px solid ${e.btnBorder}`,borderRadius:8,background:e.btnBg}}function ie(e,n,i){return{display:"inline-flex",alignItems:"center",gap:5,padding:"5px 11px",borderRadius:6,border:"1px solid transparent",background:n?e.accent:"transparent",color:n?"#ffffff":e.textSecondary,fontSize:12,fontWeight:n?800:600,fontFamily:e.font,cursor:i?"default":"pointer",opacity:i?.45:1}}function Ze(e){return{width:"100%",resize:"vertical",border:`1px solid ${e.btnBorder}`,borderRadius:8,background:e.cellBg,color:e.textPrimary,fontSize:12.5,fontFamily:e.font,lineHeight:1.5,padding:"9px 11px",boxSizing:"border-box"}}function Z(e){return{border:`1px solid ${e.cellBorder}`,borderRadius:10,background:e.cellBg,padding:12,display:"grid",gap:10}}function be(e){return{margin:0,border:`1px solid ${e.cellBorder}`,borderRadius:8,background:e.appBg,padding:"9px 11px",overflow:"auto",maxHeight:280}}function J(e){return re(e,{variant:"primary",size:"md"})}function w(e){return re(e,{variant:"ghost",size:"md"})}function ke(e){return{display:"inline-flex",alignItems:"center",gap:5,padding:0,border:"none",background:"transparent",color:e.accent,fontSize:11.5,fontWeight:700,fontFamily:e.font,cursor:"pointer"}}function je(e){return{fontSize:10,fontWeight:800,letterSpacing:"0.03em",textTransform:"uppercase",color:e.accent,background:`${e.accent}18`,border:`1px solid ${e.accent}40`,borderRadius:999,padding:"2px 8px",fontFamily:e.font}}function Je(e){return{fontSize:10.5,fontWeight:600,color:e.textMuted,background:e.btnBg,border:`1px solid ${e.btnBorder}`,borderRadius:999,padding:"2px 8px",fontFamily:e.font}}function Xe(e){return{fontSize:11,fontWeight:600,color:e.textSecondary,background:e.btnBg,border:`1px solid ${e.btnBorder}`,borderRadius:6,padding:"3px 8px",fontFamily:e.fontMono}}function rt(){const{state:e,dispatch:n}=U();return u.useCallback(async(i,d)=>{const r={name:i.split("/").pop()??`${d}.dql`,path:i,type:"block",folder:"blocks"};e.files.some(a=>a.path===i)||n({type:"FILE_ADDED",file:r});const p=await E.openBlockStudio(i);n({type:"OPEN_BLOCK_STUDIO",file:r,payload:p})},[n,e.files])}export{ot as A,Qe as C,he as G,ge as R,rt as u};
@@ -1,4 +1,4 @@
1
- import{c as te,r as o,j as n,S as ne,L as ie}from"./index-Cpx47jCH.js";import{M as re}from"./minimize-2-C8dvqCxX.js";import{M as oe}from"./usePersistedAgentThreadId-Bnl9gWhj.js";import{X as ae}from"./x-CbKEfe5m.js";/**
1
+ import{c as te,r as o,j as n,S as ne,L as ie}from"./index-DJRMz64S.js";import{M as re}from"./minimize-2-DUiSrPS3.js";import{M as oe}from"./usePersistedAgentThreadId-DYdx896E.js";import{X as ae}from"./x-B4coLiOl.js";/**
2
2
  * @license lucide-react v0.563.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -0,0 +1,6 @@
1
+ import{c as ne,h as re,i as ie,k as oe,t as se,r as f,a as R,j as o,m as ae,P as de,L as J,l as ce,T as le}from"./index-DJRMz64S.js";import{u as ue,f as fe,c as pe}from"./answer-to-notebook-Dk42N0pU.js";import{U as he}from"./UnifiedAgentRunPanel-IxDUKSG8.js";import{S as G}from"./star-CxUbF_BW.js";import{P as me}from"./usePersistedAgentThreadId-DYdx896E.js";import"./react-CRB3T2We.js";import"./AiBuildResult-Cob_Lj05.js";import"./user-round-Bfu7fosn.js";import"./triangle-alert-COWnsSdh.js";import"./rotate-ccw-D_9U9o7X.js";import"./x-B4coLiOl.js";import"./list-tree-Dw0qlxPK.js";import"./wrench-CvfM03KZ.js";import"./minimize-2-DUiSrPS3.js";import"./arrow-right-TH8_ufKG.js";import"./TrustBadge-Bob1Laiq.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 ge=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],Ae=ne("message-square",ge),H="dql-ask-domain-scope",K="dql-ask-domain-context";function Y(e){if(e)try{const t=JSON.parse(e);return typeof t.domain!="string"||!t.domain.trim()?void 0:{domain:t.domain.trim(),purpose:typeof t.purpose=="string"?t.purpose:void 0,modelAreaId:typeof t.modelAreaId=="string"?t.modelAreaId:void 0}}catch{return}}function xe(e,t){try{const s=Y(e.getItem(K));return e.removeItem(K),s?(t.setItem(H,JSON.stringify(s)),s):Y(t.getItem(H))}catch{return}}function Se(e,t){try{t||e.removeItem(H)}catch{}}function ve(){if(!(typeof window>"u"))return xe(window.sessionStorage,window.localStorage)}function Ie(e){typeof window>"u"||Se(window.localStorage,e)}const B="dql-ask-conversations",Z="dql-ask-active-conversation",Q="dql-ask-deleted-thread-queue",N=100;function we(e){return(e??"AI analysis").replace(/[^a-zA-Z0-9_ -]+/g," ").replace(/\s+/g,"_").replace(/^_+|_+$/g,"").slice(0,48)||"ai_analysis"}function ke(e){var v,p,a,d,w;const t=(p=(v=e.dqlArtifact)==null?void 0:v.source)==null?void 0:p.trim(),s=(a=e.sql)==null?void 0:a.trim(),n=t||s;if(!n)return;const u=ae(t?"dql":"sql",n);return u.name=we(e.title??((d=e.dqlArtifact)==null?void 0:d.name)),e.result&&(u.result=e.result,u.status="success",u.executionCount=1),e.chartConfig&&(u.chartConfig=e.chartConfig),u.correctionProvenance=pe({question:e.question,generatedSql:e.sql??((w=e.dqlArtifact)==null?void 0:w.compiledSql),generatedDql:t,sourceRunId:e.sourceRunId}),e.dqlArtifact&&(u.dqlArtifact={source:e.dqlArtifact.source,sql:e.sql,name:e.dqlArtifact.name,sourcePath:e.dqlArtifact.sourcePath,kind:e.dqlArtifact.kind,metrics:e.dqlArtifact.metrics,dimensions:e.dqlArtifact.dimensions,parameters:e.dqlArtifact.parameters,parameterValues:e.dqlArtifact.parameterValues,persistence:e.dqlArtifact.persistence,trustState:e.dqlArtifact.trustState,compiledSql:e.dqlArtifact.compiledSql??e.sql,reviewState:e.dqlArtifact.trustState==="certified"?"certified":"review_required",...e.question?{question:e.question}:{}},u.dqlParameterValues=e.dqlArtifact.parameterValues),u}function F(){return`conv_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function ee(e){return`conv_server_${e}`}function ye(e,t,s=new Set){const n=t.filter(a=>!s.has(a.id)),u=new Map(e.flatMap(a=>a.threadId?[[a.threadId,a]]:[])),v=n.map(a=>{var w;const d=u.get(a.id);return{id:(d==null?void 0:d.id)??ee(a.id),title:((w=a.title)==null?void 0:w.trim())||(d!=null&&d.title&&d.title!=="New chat"?d.title:"Recovered chat"),createdAt:(d==null?void 0:d.createdAt)??a.createdAt,updatedAt:a.updatedAt>((d==null?void 0:d.updatedAt)??"")?a.updatedAt:(d==null?void 0:d.updatedAt)??a.updatedAt,items:(d==null?void 0:d.items)??[],threadId:a.id,favorite:a.favorite??(d==null?void 0:d.favorite)??!1}}),p=new Set(n.map(a=>a.id));return[...v,...e.filter(a=>(!a.threadId||!p.has(a.threadId))&&(!a.threadId||!s.has(a.threadId)))].sort((a,d)=>d.updatedAt.localeCompare(a.updatedAt)).slice(0,N)}function b(){if(typeof window>"u")return new Set;try{const e=JSON.parse(window.localStorage.getItem(Q)??"[]");return new Set(Array.isArray(e)?e.filter(t=>typeof t=="string"):[])}catch{return new Set}}function te(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Q,JSON.stringify([...e].slice(-N)))}catch{}}function Ce(e){const t=b();t.add(e),te(t)}function U(e){const t=b();t.delete(e),te(t)}function qe(e){return Array.isArray(e)?e.flatMap(t=>{if(!t||typeof t!="object")return[];const s=t;if(s.kind==="run"&&s.run&&typeof s.run=="object"){const n=s.run;n.nextActions=Array.isArray(n.nextActions)?n.nextActions:[],n.artifacts=Array.isArray(n.artifacts)?n.artifacts:[],n.evaluations=Array.isArray(n.evaluations)?n.evaluations:[],n.steps=Array.isArray(n.steps)?n.steps:[]}return[t]}):[]}function be(){if(typeof window>"u")return[];try{const e=window.localStorage.getItem(B);if(!e)return[];const t=JSON.parse(e);if(!Array.isArray(t))return[];const s=b();return t.filter(n=>!n.threadId||!s.has(n.threadId)).map(n=>({...n,items:qe(n.items)}))}catch{return[]}}function je(){if(!(typeof window>"u"))try{return window.localStorage.getItem(Z)??void 0}catch{return}}function X(e){return e.map(t=>({...t,items:t.items.map(s=>s.kind==="run"?{...s,run:{...s.run,events:[]}}:s)}))}function C(e){const t=e.slice(0,N);if(typeof window>"u")return t;try{return window.localStorage.setItem(B,JSON.stringify(X(t))),t}catch{const s=t.slice(0,8);try{window.localStorage.setItem(B,JSON.stringify(X(s)))}catch{}return s}}function De(e){const t=e.find(n=>n.kind==="user"),s=t&&t.kind==="user"?t.text.trim():"";return s?s.length>48?`${s.slice(0,48).trimEnd()}…`:s:"New chat"}function Te(e){const t=new Date(e).getTime();if(Number.isNaN(t))return"";const s=Date.now()-t,n=Math.floor(s/6e4);if(n<1)return"just now";if(n<60)return`${n}m`;const u=Math.floor(n/60);if(u<24)return`${u}h`;const v=Math.floor(u/24);return v<7?`${v}d`:new Date(e).toLocaleDateString()}function Ke(){var V;const e=re(ie(r=>({activeFile:r.activeFile,themeMode:r.themeMode}))),t=oe(),s=ue(),n=se[e.themeMode],[u,v]=f.useState(()=>ve()),[p,a]=f.useState(()=>be()),[d,w]=f.useState(!0),j=f.useMemo(()=>p.length>0,[]),[h,y]=f.useState(()=>{const r=je();return r&&p.some(i=>i.id===r)?r:F()}),[I,D]=f.useState(!1);f.useEffect(()=>{try{window.localStorage.setItem(Z,h)}catch{}},[h]),f.useEffect(()=>{for(const r of b())R.deleteAgentThread(r).then(()=>U(r)).catch(()=>{})},[]),f.useEffect(()=>{let r=!1;const i=b();return R.listAgentThreads({limit:N}).then(({threads:c})=>{if(r)return;const m=c.filter(A=>A.surface==="ask"||A.surface==="notebook"&&!A.notebookPath),g=new Set([...i,...b()]),k=m.filter(A=>!g.has(A.id));a(A=>C(ye(A,k,g))),!j&&k[0]&&y(ee(k[0].id))}).catch(()=>{}).finally(()=>{r||w(!1)}),()=>{r=!0}},[j]);const T=f.useMemo(()=>{var r;return((r=p.find(i=>i.id===h))==null?void 0:r.items)??[]},[p,h]),_=f.useMemo(()=>{var r;return(r=p.find(i=>i.id===h))==null?void 0:r.threadId},[p,h]),E=f.useCallback(r=>{r.length!==0&&a(i=>{const c=i.find(A=>A.id===h);if(c&&c.items.length>=r.length)return i;const m=new Date().toISOString(),k=[{id:h,title:De(r),createdAt:(c==null?void 0:c.createdAt)??m,updatedAt:m,items:r,threadId:c==null?void 0:c.threadId},...i.filter(A=>A.id!==h)].slice(0,N);return C(k)})},[h]),$=f.useCallback(r=>{a(i=>{const c=i.find(g=>g.id===h),m=new Date().toISOString();return C(c?i.map(g=>g.id===h?{...g,threadId:r}:g):[{id:h,title:"New chat",createdAt:m,updatedAt:m,items:[],threadId:r},...i])})},[h]),M=f.useCallback((r,i)=>{var g;const c=i.trim();if(!c)return;a(k=>C(k.map(A=>A.id===r?{...A,title:c}:A)));const m=(g=p.find(k=>k.id===r))==null?void 0:g.threadId;m&&R.updateAgentThread(m,{title:c}).catch(()=>{})},[p]),O=f.useCallback(r=>{const i=p.find(m=>m.id===r),c=!(i!=null&&i.favorite);a(m=>C(m.map(g=>g.id===r?{...g,favorite:c}:g))),i!=null&&i.threadId&&R.updateAgentThread(i.threadId,{favorite:c}).catch(()=>{})},[p]),P=f.useCallback(()=>{I||y(F())},[I]),l=f.useCallback(r=>{I||y(r)},[I]),x=f.useCallback(r=>{var c;if(I)return;const i=(c=p.find(m=>m.id===r))==null?void 0:c.threadId;i&&(Ce(i),R.deleteAgentThread(i).then(()=>U(i)).catch(()=>{})),a(m=>C(m.filter(g=>g.id!==r))),r===h&&y(F())},[h,p,I]),q=(r,i,c)=>{if(c){t({type:"OPEN_APP_DRAFT",draftId:c,appId:r,dashboardId:i});return}t({type:"OPEN_APP",appId:r,dashboardId:i})},z=(r,i)=>{t({type:"OPEN_GLOBAL_AI",audience:"stakeholder",context:{title:"Research",scopeHint:"Follow up on this research",selectedObject:{kind:"research",id:r,path:i}}})},S=f.useCallback(r=>{if(!e.activeFile||e.activeFile.type==="block"){s(r);return}const i=ke(r);i&&(t({type:"ADD_CELL",cell:i}),t({type:"SET_MAIN_VIEW",view:"notebook"}),fe(i.id))},[t,s,e.activeFile]);return o.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",overflow:"hidden",background:n.appBg},children:[o.jsx(Re,{t:n,conversations:p,activeId:h,busy:I,loading:d,onNewChat:P,onSelect:l,onDelete:x,onRename:M,onToggleFavorite:O}),o.jsx("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:o.jsx(he,{themeMode:e.themeMode,title:"Ask your data",askLayout:!0,scopeHint:u?`Scoped to ${u.domain}${u.modelAreaId?` · ${(V=u.modelAreaId.split("::").at(-1))==null?void 0:V.replace(/_/g," ")}`:""}${u.purpose?` for ${u.purpose}`:""}`:"Ask a question or request deep research",onClearScope:u?()=>{v(void 0),Ie(void 0)}:void 0,workspaceContext:u,audience:"stakeholder",initialMode:"auto",initialItems:T,onItemsChange:E,threadId:_,onThreadIdChange:$,onRunningChange:D,onOpenResearch:z,onOpenApp:q,onInsertSql:(r,i,c)=>S({sql:r,title:i,question:c==null?void 0:c.question,sourceRunId:c==null?void 0:c.sourceRunId}),onInsertDql:S,insertDqlActionLabel:"Open in notebook"},h)})]})}function Re({t:e,conversations:t,activeId:s,busy:n,loading:u,onNewChat:v,onSelect:p,onDelete:a,onRename:d,onToggleFavorite:w}){const j=n?"Finish the current question first":void 0,[h,y]=f.useState(null),[I,D]=f.useState(null),[T,_]=f.useState(""),E=t.filter(l=>l.favorite),$=t.filter(l=>!l.favorite),M=l=>{D(l.id),_(l.title)},O=()=>{I&&T.trim()&&d(I,T),D(null)},P=l=>{const x=l.id===s,q=h===l.id,z=I===l.id;return o.jsxs("div",{onMouseEnter:()=>y(l.id),onMouseLeave:()=>y(S=>S===l.id?null:S),style:{position:"relative",display:"flex",alignItems:"center"},children:[z?o.jsx("input",{autoFocus:!0,value:T,onChange:S=>_(S.target.value),onBlur:O,onKeyDown:S=>{S.key==="Enter"&&(S.preventDefault(),O()),S.key==="Escape"&&(S.preventDefault(),D(null))},"aria-label":"Conversation name",style:{flex:1,minWidth:0,padding:"7px 10px",borderRadius:7,border:`1px solid ${e.accent}`,background:e.appBg,color:e.textPrimary,fontSize:12.5,fontWeight:600}}):o.jsxs("button",{type:"button",onClick:()=>p(l.id),onDoubleClick:()=>M(l),disabled:n&&!x,title:n&&!x?j:`${l.title} — double-click to rename`,style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:8,padding:"8px 10px",borderRadius:7,border:"none",background:x?`${e.accent}1f`:q?`${e.textPrimary}0d`:"transparent",color:x?e.accent:e.textSecondary,cursor:n&&!x?"not-allowed":"pointer",opacity:n&&!x?.5:1,textAlign:"left",fontSize:12.5,fontWeight:x?600:500,paddingRight:q?56:10},children:[x&&n?o.jsx(J,{size:13,style:{flexShrink:0,color:e.accent,animation:"dql-agent-run-spin 0.8s linear infinite"}}):l.favorite?o.jsx(G,{size:13,style:{flexShrink:0,color:e.accent},fill:"currentColor"}):o.jsx(Ae,{size:13,style:{flexShrink:0,opacity:.7}}),o.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:x&&n?"Working…":l.title}),q?null:o.jsx("span",{style:{flexShrink:0,fontSize:10,color:x&&n?e.accent:e.textMuted,fontWeight:x&&n?650:400},children:x&&n?"Live":Te(l.updatedAt)})]}),q&&!z?o.jsxs("div",{style:{position:"absolute",right:4,display:"inline-flex",gap:2},children:[o.jsx(W,{t:e,label:l.favorite?"Unpin conversation":"Pin conversation",onClick:()=>w(l.id),children:o.jsx(G,{size:12,fill:l.favorite?"currentColor":"none"})}),o.jsx(W,{t:e,label:"Rename conversation",onClick:()=>M(l),children:o.jsx(me,{size:12})}),o.jsx(W,{t:e,label:"Delete conversation",onClick:()=>a(l.id),children:o.jsx(le,{size:12})})]}):null]},l.id)};return o.jsxs("aside",{style:{width:248,flexShrink:0,borderRight:`1px solid ${e.headerBorder}`,background:e.cellBg,display:"flex",flexDirection:"column",minHeight:0},children:[o.jsx("div",{style:{padding:12},children:o.jsxs("button",{type:"button",onClick:v,disabled:n,title:j,style:{width:"100%",display:"inline-flex",alignItems:"center",gap:8,justifyContent:"center",padding:"9px 12px",borderRadius:8,border:`1px solid ${e.accent}`,background:e.accent,color:"var(--accent-on, #fff)",fontSize:13,fontWeight:650,cursor:n?"not-allowed":"pointer",opacity:n?.55:1},children:[o.jsx(de,{size:15,strokeWidth:2.4})," New chat"]})}),o.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:"0 8px 12px",display:"flex",flexDirection:"column",gap:2},children:u&&t.length===0?o.jsxs("div",{style:{padding:"10px 8px",display:"flex",alignItems:"center",gap:7,fontSize:11.5,color:e.textMuted},children:[o.jsx(J,{size:13,style:{animation:"dql-agent-run-spin 0.8s linear infinite"}}),"Restoring project chats…"]}):t.length===0?o.jsx("div",{style:{padding:"10px 8px",fontSize:11.5,color:e.textMuted,lineHeight:1.5},children:"No past chats yet. Your conversations show up here so you can pick up where you left off."}):o.jsxs(o.Fragment,{children:[E.length>0?o.jsxs(o.Fragment,{children:[o.jsx(L,{t:e,children:"Favourites"}),E.map(l=>P(l)),o.jsx(L,{t:e,children:"Recent"})]}):o.jsx(L,{t:e,children:"Recent"}),$.map(l=>P(l))]})}),o.jsxs("div",{style:{padding:"10px 12px",borderTop:`1px solid ${e.headerBorder}`,display:"flex",alignItems:"center",gap:7,fontSize:11,color:e.textMuted},children:[o.jsx(ce,{size:12,style:{flexShrink:0,color:e.success}}),o.jsx("span",{children:"Private project history · not committed to Git"})]})]})}function L({t:e,children:t}){return o.jsx("div",{style:{padding:"8px 8px 4px",fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",color:e.textMuted},children:t})}function W({t:e,label:t,onClick:s,children:n}){return o.jsx("button",{type:"button","aria-label":t,title:t,onClick:u=>{u.stopPropagation(),s()},style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,borderRadius:5,border:"none",background:e.cellBg,color:e.textMuted,cursor:"pointer"},children:n})}export{Ke as AnalyticsHome,ke as askNotebookCellFromPayload,ye as mergePersistedAskConversations};