@duckcodeailabs/dql-cli 1.13.0 → 1.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/args.d.ts +2 -0
- package/dist/args.d.ts.map +1 -1
- package/dist/args.js +3 -0
- package/dist/args.js.map +1 -1
- package/dist/assets/dql-notebook/assets/{AgentAnswerCard-Cp0eh6zU.js → AgentAnswerCard-c8QUo6NH.js} +4 -4
- package/dist/assets/dql-notebook/assets/{AgentLogPage-CBGEoGmU.js → AgentLogPage-D6fgEAEy.js} +1 -1
- package/dist/assets/dql-notebook/assets/{AiBuildDialog-CwAD3tXE.js → AiBuildDialog-8miXFPse.js} +1 -1
- package/dist/assets/dql-notebook/assets/{AiBuildResult-CyqTuQe5.js → AiBuildResult-DPJ_SI0R.js} +3 -3
- package/dist/assets/dql-notebook/assets/{AiSidePanel-DjB8PWHG.js → AiSidePanel-NVA6lZnn.js} +1 -1
- package/dist/assets/dql-notebook/assets/{AnalyticsHome-B7BkvA-R.js → AnalyticsHome-DgwnRW71.js} +2 -2
- package/dist/assets/dql-notebook/assets/AppsView-B6LYUpgm.js +4578 -0
- package/dist/assets/dql-notebook/assets/BlockStudio--jNw9XUI.js +60 -0
- package/dist/assets/dql-notebook/assets/{BusinessArtifactView-C4SZVNW-.js → BusinessArtifactView-DtRMiaF4.js} +1 -1
- package/dist/assets/dql-notebook/assets/DbtFirstModelingPage-DhBsLCYr.js +22 -0
- package/dist/assets/dql-notebook/assets/{GitPage-BfVD4tVq.js → GitPage-CazC-eTR.js} +1 -1
- package/dist/assets/dql-notebook/assets/GlobalAiRail-1Tgweuu2.js +1 -0
- package/dist/assets/dql-notebook/assets/GovernedContextPage-C7qGrH3d.js +16 -0
- package/dist/assets/dql-notebook/assets/{HelpDocsPage-BDPNVot1.js → HelpDocsPage-DMHPsVqP.js} +1 -1
- package/dist/assets/dql-notebook/assets/{HomePage-DiOnRhEG.js → HomePage-DcSI4dnU.js} +1 -1
- package/dist/assets/dql-notebook/assets/{LineageDAG-BiUFX2KL.js → LineageDAG-BJ6xz06u.js} +1 -1
- package/dist/assets/dql-notebook/assets/{LineageDetailView-CfbSvlPJ.js → LineageDetailView-8WrQm-MF.js} +1 -1
- package/dist/assets/dql-notebook/assets/{LineageDrawer-CgTScaGB.js → LineageDrawer-hnqCW_t-.js} +1 -1
- package/dist/assets/dql-notebook/assets/{LineagePathBreadcrumb-D7ZA7k68.js → LineagePathBreadcrumb-B4LZTUsl.js} +1 -1
- package/dist/assets/dql-notebook/assets/{MiniLineageGraph-GkD4y17x.js → MiniLineageGraph-CotnRuxa.js} +1 -1
- package/dist/assets/dql-notebook/assets/{NewBlockModal-B9TfRjt7.js → NewBlockModal-DHn-CEEW.js} +1 -1
- package/dist/assets/dql-notebook/assets/{NewNotebookModal-BbO9NKUl.js → NewNotebookModal-BPGp-8oq.js} +1 -1
- package/dist/assets/dql-notebook/assets/{NotebookEditor-CuMpvXR9.js → NotebookEditor-B0OTHM6W.js} +26 -31
- package/dist/assets/dql-notebook/assets/{ReadinessPage-BROJ9YBM.js → ReadinessPage-CoOIpxWq.js} +1 -1
- package/dist/assets/dql-notebook/assets/{SetupOnboarding-BCcZlpuQ.js → SetupOnboarding-DxK_mFzf.js} +1 -1
- package/dist/assets/dql-notebook/assets/{TrustBadge-vQQh8d0D.js → TrustBadge-ZuD5N5Ww.js} +1 -1
- package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-duFXXNV_.js +88 -0
- package/dist/assets/dql-notebook/assets/{answer-to-notebook-DuqCcDDl.js → answer-to-notebook-WAVAYjBv.js} +1 -1
- package/dist/assets/dql-notebook/assets/{arrow-left-CMe1kkOL.js → arrow-left-L8odLbyN.js} +1 -1
- package/dist/assets/dql-notebook/assets/{arrow-right-DvB_DONr.js → arrow-right-WIF1V9a9.js} +1 -1
- package/dist/assets/dql-notebook/assets/{book-open-text-CJ3NAvrs.js → book-open-text-BpqWMa4m.js} +1 -1
- package/dist/assets/dql-notebook/assets/{bot-CV8DYRrt.js → bot-CLR1V6dO.js} +1 -1
- package/dist/assets/dql-notebook/assets/{circle-x-BCgtha1W.js → circle-x-CQBOM0b0.js} +1 -1
- package/dist/assets/dql-notebook/assets/{dagre.esm-GKp7qoUL.js → dagre.esm-DlZi7NR3.js} +1 -1
- package/dist/assets/dql-notebook/assets/{external-link-C-PXokWV.js → external-link-DYqdQIGp.js} +1 -1
- package/dist/assets/dql-notebook/assets/{grip-vertical-B4EHbGXW.js → grip-vertical-HmUijbwN.js} +1 -1
- package/dist/assets/dql-notebook/assets/{index-1mIC_XX4.js → index-Cpx47jCH.js} +43 -43
- package/dist/assets/dql-notebook/assets/{list-tree-BRFpEmvV.js → list-tree-DGKqCxmz.js} +1 -1
- package/dist/assets/dql-notebook/assets/{minimize-2-CDwSCGlO.js → minimize-2-C8dvqCxX.js} +1 -1
- package/dist/assets/dql-notebook/assets/{panel-right-open-CunA1xO7.js → panel-right-open-yuVkIo5n.js} +1 -1
- package/dist/assets/dql-notebook/assets/{rotate-ccw-DOrfTZk8.js → rotate-ccw-Di0kRnrM.js} +1 -1
- package/dist/assets/dql-notebook/assets/{semantic-fields-AfQvjt5R.js → semantic-fields-BMQV0li8.js} +1 -1
- package/dist/assets/dql-notebook/assets/sliders-horizontal-alebptlJ.js +6 -0
- package/dist/assets/dql-notebook/assets/{star-DDhv4e8M.js → star-CgCQbnXc.js} +1 -1
- package/dist/assets/dql-notebook/assets/{triangle-alert-2ZXx8wAu.js → triangle-alert-SyuSZ4ht.js} +1 -1
- package/dist/assets/dql-notebook/assets/upload-BPhfea_E.js +11 -0
- package/dist/assets/dql-notebook/assets/usePersistedAgentThreadId-Bnl9gWhj.js +28 -0
- package/dist/assets/dql-notebook/assets/{user-round-BA074kiQ.js → user-round-J4PQHxo9.js} +1 -1
- package/dist/assets/dql-notebook/assets/{wand-sparkles-CEYHLt9b.js → wand-sparkles-c4WDXTCk.js} +1 -1
- package/dist/assets/dql-notebook/assets/{workflow-CZtyrcR-.js → workflow-NtRLaq7n.js} +1 -1
- package/dist/assets/dql-notebook/assets/{wrench-Ong23-wu.js → wrench-CS1f1Zv4.js} +1 -1
- package/dist/assets/dql-notebook/assets/{x-CSo1M3tu.js → x-CbKEfe5m.js} +1 -1
- package/dist/assets/dql-notebook/index.html +1 -1
- package/dist/commands/model.d.ts.map +1 -1
- package/dist/commands/model.js +62 -1
- package/dist/commands/model.js.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/local-runtime.d.ts +10 -0
- package/dist/local-runtime.d.ts.map +1 -1
- package/dist/local-runtime.js +1061 -17
- package/dist/local-runtime.js.map +1 -1
- package/dist/package.json +10 -10
- package/package.json +10 -10
- package/dist/assets/dql-notebook/assets/AppsView-CUrqtEGC.js +0 -4583
- package/dist/assets/dql-notebook/assets/BlockStudio-Bl0aGQJR.js +0 -60
- package/dist/assets/dql-notebook/assets/DbtFirstModelingPage-B0uxitnx.js +0 -22
- package/dist/assets/dql-notebook/assets/GlobalAiRail-DUwdy3fB.js +0 -1
- package/dist/assets/dql-notebook/assets/GovernedContextPage-D9f26ZFb.js +0 -7
- package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-Dj4AXAhT.js +0 -83
- package/dist/assets/dql-notebook/assets/chevron-up-HxU1l85K.js +0 -6
- package/dist/assets/dql-notebook/assets/link-2-BLx-goet.js +0 -6
- package/dist/assets/dql-notebook/assets/maximize-2-CCd5uRIZ.js +0 -6
- package/dist/assets/dql-notebook/assets/pencil-D_I14Wyk.js +0 -6
- package/dist/assets/dql-notebook/assets/usePersistedAgentThreadId-3rzkZrqc.js +0 -18
package/dist/assets/dql-notebook/assets/{AiBuildResult-CyqTuQe5.js → AiBuildResult-DPJ_SI0R.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
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
|
|
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";/**
|
|
2
2
|
* @license lucide-react v0.563.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -28,6 +28,6 @@ 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 se,a5 as Be
|
|
|
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
|
|
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(`
|
|
32
32
|
`),d=n.replace(/\s+$/g,"").split(`
|
|
33
|
-
`),o=i.length,p=d.length,a=Array.from({length:o+1},()=>new Array(p+1).fill(0));for(let r=o-1;r>=0;r--)for(let s=p-1;s>=0;s--)a[r][s]=i[r]===d[s]?a[r+1][s+1]+1:Math.max(a[r+1][s],a[r][s+1]);const x=[];let f=0,c=0;for(;f<o&&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<o;)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,o]=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:()=>o(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(o=>t.jsx("li",{style:{fontSize:11,color:e.textSecondary,lineHeight:1.4,fontFamily:e.font},children:o},o))}):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",o=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," · ",o," allowed relation",o===1?"":"s"," · review required"]}),p?t.jsx("span",{style:{color:e.warning},children:p}):null]})}function he({t:e,skills:n,onOpenSkills:i}){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((d,o)=>t.jsxs(de.Fragment,{children:[o>0?t.jsx("span",{"aria-hidden":!0,style:{color:e.textMuted},children:","}):null,t.jsx("button",{type:"button",onClick:i,title:d.description??`Open the ${d.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:d.id})]},d.id))]})}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,o=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:o,background:`${o}14`,border:`1px solid ${o}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,o]=u.useState([]),[p,a]=u.useState(!0),[x,f]=u.useState("");u.useEffect(()=>{let s=!1;return a(!0),E.getBlockLibrary().then(y=>{s||o(Array.isArray(y==null?void 0:y.blocks)?y.blocks.map(g=>({name:g.name,domain:g.domain,path:g.path})):[])}).catch(()=>{s||o([])}).finally(()=>{s||a(!1)}),()=>{s=!0}},[]);const c=d.filter(s=>{if(!x.trim())return!0;const y=x.toLowerCase();return s.name.toLowerCase().includes(y)||s.path.toLowerCase().includes(y)||(s.domain??"").toLowerCase().includes(y)}).slice(0,40),r=d.find(s=>s.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:s=>f(s.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(se,{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:s=>{if(s.key==="Enter"){const y=s.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(s=>{const y=s.path===n;return t.jsxs("button",{type:"button",onClick:()=>i(s.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:s.name}),t.jsxs("span",{style:{fontSize:10.5,color:e.textMuted,fontFamily:e.font,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[s.domain?`${s.domain} · `:"",s.path]})]}),y?t.jsx(K,{size:14,strokeWidth:2,color:e.accent,style:{marginLeft:"auto",flexShrink:0}}):null]},s.path)})})]})}function Ke({t:e,value:n,onChange:i}){const{state:d,dispatch:o}=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:()=>o({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 oe(e,{variant:"primary",size:"md"})}function w(e){return oe(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 ot(){const{state:e,dispatch:n}=U();return u.useCallback(async(i,d)=>{const o={name:i.split("/").pop()??`${d}.dql`,path:i,type:"block",folder:"blocks"};e.files.some(a=>a.path===i)||n({type:"FILE_ADDED",file:o});const p=await E.openBlockStudio(i);n({type:"OPEN_BLOCK_STUDIO",file:o,payload:p})},[n,e.files])}export{st as A,Qe as C,he as G,ge as R,ot as u};
|
|
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};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as te,r as o,j as n,S as ne,L as ie}from"./index-
|
|
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";/**
|
|
2
2
|
* @license lucide-react v0.563.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
package/dist/assets/dql-notebook/assets/{AnalyticsHome-B7BkvA-R.js → AnalyticsHome-DgwnRW71.js}
RENAMED
|
@@ -1,6 +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-
|
|
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-Cpx47jCH.js";import{u as ue,f as fe,c as pe}from"./answer-to-notebook-WAVAYjBv.js";import{U as he}from"./UnifiedAgentRunPanel-duFXXNV_.js";import{S as G}from"./star-CgCQbnXc.js";import{P as me}from"./usePersistedAgentThreadId-Bnl9gWhj.js";import"./react-CRB3T2We.js";import"./AgentAnswerCard-c8QUo6NH.js";import"./TrustBadge-ZuD5N5Ww.js";import"./AiBuildResult-DPJ_SI0R.js";import"./user-round-J4PQHxo9.js";import"./triangle-alert-SyuSZ4ht.js";import"./rotate-ccw-Di0kRnrM.js";import"./x-CbKEfe5m.js";import"./list-tree-DGKqCxmz.js";import"./wrench-CS1f1Zv4.js";import"./minimize-2-C8dvqCxX.js";import"./arrow-right-WIF1V9a9.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 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"}]],xe=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 Ae(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 Ae(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 Ze(){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:l})=>{if(r)return;const m=l.filter(x=>x.surface==="ask"||x.surface==="notebook"&&!x.notebookPath),g=new Set([...i,...b()]),k=m.filter(x=>!g.has(x.id));a(x=>C(ye(x,k,g))),!j&&k[0]&&y(ee(k[0].id))}).catch(()=>{}).finally(()=>{r||w(!1)}),()=>{r=!0}},[j]);const T=f.useMemo(()=>{var r;return((r=p.find(i=>i.id===h))==null?void 0:r.items)??[]},[p,h]),E=f.useMemo(()=>{var r;return(r=p.find(i=>i.id===h))==null?void 0:r.threadId},[p,h]),_=f.useCallback(r=>{r.length!==0&&a(i=>{const l=i.find(x=>x.id===h);if(l&&l.items.length>=r.length)return i;const m=new Date().toISOString(),k=[{id:h,title:De(r),createdAt:(l==null?void 0:l.createdAt)??m,updatedAt:m,items:r,threadId:l==null?void 0:l.threadId},...i.filter(x=>x.id!==h)].slice(0,N);return C(k)})},[h]),$=f.useCallback(r=>{a(i=>{const l=i.find(g=>g.id===h),m=new Date().toISOString();return C(l?i.map(g=>g.id===h?{...g,threadId:r}:g):[{id:h,title:"New chat",createdAt:m,updatedAt:m,items:[],threadId:r},...i])})},[h]),M=f.useCallback((r,i)=>{var g;const l=i.trim();if(!l)return;a(k=>C(k.map(x=>x.id===r?{...x,title:l}:x)));const m=(g=p.find(k=>k.id===r))==null?void 0:g.threadId;m&&R.updateAgentThread(m,{title:l}).catch(()=>{})},[p]),O=f.useCallback(r=>{const i=p.find(m=>m.id===r),l=!(i!=null&&i.favorite);a(m=>C(m.map(g=>g.id===r?{...g,favorite:l}:g))),i!=null&&i.threadId&&R.updateAgentThread(i.threadId,{favorite:l}).catch(()=>{})},[p]),P=f.useCallback(()=>{I||y(F())},[I]),c=f.useCallback(r=>{I||y(r)},[I]),A=f.useCallback(r=>{var l;if(I)return;const i=(l=p.find(m=>m.id===r))==null?void 0:l.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)=>{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:c,onDelete:A,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:_,threadId:E,onThreadIdChange:$,onRunningChange:D,onOpenResearch:z,onOpenApp:q,onInsertSql:(r,i,l)=>S({sql:r,title:i,question:l==null?void 0:l.question,sourceRunId:l==null?void 0:l.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,E]=f.useState(""),_=t.filter(c=>c.favorite),$=t.filter(c=>!c.favorite),M=c=>{D(c.id),E(c.title)},O=()=>{I&&T.trim()&&d(I,T),D(null)},P=c=>{const A=c.id===s,q=h===c.id,z=I===c.id;return o.jsxs("div",{onMouseEnter:()=>y(c.id),onMouseLeave:()=>y(S=>S===c.id?null:S),style:{position:"relative",display:"flex",alignItems:"center"},children:[z?o.jsx("input",{autoFocus:!0,value:T,onChange:S=>E(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(c.id),onDoubleClick:()=>M(c),disabled:n&&!A,title:n&&!A?j:`${c.title} — double-click to rename`,style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:8,padding:"8px 10px",borderRadius:7,border:"none",background:A?`${e.accent}1f`:q?`${e.textPrimary}0d`:"transparent",color:A?e.accent:e.textSecondary,cursor:n&&!A?"not-allowed":"pointer",opacity:n&&!A?.5:1,textAlign:"left",fontSize:12.5,fontWeight:A?600:500,paddingRight:q?56:10},children:[A&&n?o.jsx(J,{size:13,style:{flexShrink:0,color:e.accent,animation:"dql-agent-run-spin 0.8s linear infinite"}}):c.favorite?o.jsx(G,{size:13,style:{flexShrink:0,color:e.accent},fill:"currentColor"}):o.jsx(xe,{size:13,style:{flexShrink:0,opacity:.7}}),o.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:A&&n?"Working…":c.title}),q?null:o.jsx("span",{style:{flexShrink:0,fontSize:10,color:A&&n?e.accent:e.textMuted,fontWeight:A&&n?650:400},children:A&&n?"Live":Te(c.updatedAt)})]}),q&&!z?o.jsxs("div",{style:{position:"absolute",right:4,display:"inline-flex",gap:2},children:[o.jsx(W,{t:e,label:c.favorite?"Unpin conversation":"Pin conversation",onClick:()=>w(c.id),children:o.jsx(G,{size:12,fill:c.favorite?"currentColor":"none"})}),o.jsx(W,{t:e,label:"Rename conversation",onClick:()=>M(c),children:o.jsx(me,{size:12})}),o.jsx(W,{t:e,label:"Delete conversation",onClick:()=>a(c.id),children:o.jsx(le,{size:12})})]}):null]},c.id)};return o.jsxs("aside",{style:{width:248,flexShrink:0,borderRight:`1px solid ${e.headerBorder}`,background:e.cellBg,display:"flex",flexDirection:"column",minHeight:0},children:[o.jsx("div",{style:{padding:12},children:o.jsxs("button",{type:"button",onClick: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:[_.length>0?o.jsxs(o.Fragment,{children:[o.jsx(L,{t:e,children:"Favourites"}),_.map(c=>P(c)),o.jsx(L,{t:e,children:"Recent"})]}):o.jsx(L,{t:e,children:"Recent"}),$.map(c=>P(c))]})}),o.jsxs("div",{style:{padding:"10px 12px",borderTop:`1px solid ${e.headerBorder}`,display:"flex",alignItems:"center",gap:7,fontSize:11,color:e.textMuted},children:[o.jsx(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{Ze as AnalyticsHome,ke as askNotebookCellFromPayload,ye as mergePersistedAskConversations};
|
|
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"}]],xe=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 Ae(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 Ae(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 Ye(){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:l})=>{if(r)return;const m=l.filter(x=>x.surface==="ask"||x.surface==="notebook"&&!x.notebookPath),g=new Set([...i,...b()]),k=m.filter(x=>!g.has(x.id));a(x=>C(ye(x,k,g))),!j&&k[0]&&y(ee(k[0].id))}).catch(()=>{}).finally(()=>{r||w(!1)}),()=>{r=!0}},[j]);const T=f.useMemo(()=>{var r;return((r=p.find(i=>i.id===h))==null?void 0:r.items)??[]},[p,h]),E=f.useMemo(()=>{var r;return(r=p.find(i=>i.id===h))==null?void 0:r.threadId},[p,h]),_=f.useCallback(r=>{r.length!==0&&a(i=>{const l=i.find(x=>x.id===h);if(l&&l.items.length>=r.length)return i;const m=new Date().toISOString(),k=[{id:h,title:De(r),createdAt:(l==null?void 0:l.createdAt)??m,updatedAt:m,items:r,threadId:l==null?void 0:l.threadId},...i.filter(x=>x.id!==h)].slice(0,N);return C(k)})},[h]),$=f.useCallback(r=>{a(i=>{const l=i.find(g=>g.id===h),m=new Date().toISOString();return C(l?i.map(g=>g.id===h?{...g,threadId:r}:g):[{id:h,title:"New chat",createdAt:m,updatedAt:m,items:[],threadId:r},...i])})},[h]),M=f.useCallback((r,i)=>{var g;const l=i.trim();if(!l)return;a(k=>C(k.map(x=>x.id===r?{...x,title:l}:x)));const m=(g=p.find(k=>k.id===r))==null?void 0:g.threadId;m&&R.updateAgentThread(m,{title:l}).catch(()=>{})},[p]),O=f.useCallback(r=>{const i=p.find(m=>m.id===r),l=!(i!=null&&i.favorite);a(m=>C(m.map(g=>g.id===r?{...g,favorite:l}:g))),i!=null&&i.threadId&&R.updateAgentThread(i.threadId,{favorite:l}).catch(()=>{})},[p]),P=f.useCallback(()=>{I||y(F())},[I]),c=f.useCallback(r=>{I||y(r)},[I]),A=f.useCallback(r=>{var l;if(I)return;const i=(l=p.find(m=>m.id===r))==null?void 0:l.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)=>{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:c,onDelete:A,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:_,threadId:E,onThreadIdChange:$,onRunningChange:D,onOpenResearch:z,onOpenApp:q,onInsertSql:(r,i,l)=>S({sql:r,title:i,question:l==null?void 0:l.question,sourceRunId:l==null?void 0:l.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,E]=f.useState(""),_=t.filter(c=>c.favorite),$=t.filter(c=>!c.favorite),M=c=>{D(c.id),E(c.title)},O=()=>{I&&T.trim()&&d(I,T),D(null)},P=c=>{const A=c.id===s,q=h===c.id,z=I===c.id;return o.jsxs("div",{onMouseEnter:()=>y(c.id),onMouseLeave:()=>y(S=>S===c.id?null:S),style:{position:"relative",display:"flex",alignItems:"center"},children:[z?o.jsx("input",{autoFocus:!0,value:T,onChange:S=>E(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(c.id),onDoubleClick:()=>M(c),disabled:n&&!A,title:n&&!A?j:`${c.title} — double-click to rename`,style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:8,padding:"8px 10px",borderRadius:7,border:"none",background:A?`${e.accent}1f`:q?`${e.textPrimary}0d`:"transparent",color:A?e.accent:e.textSecondary,cursor:n&&!A?"not-allowed":"pointer",opacity:n&&!A?.5:1,textAlign:"left",fontSize:12.5,fontWeight:A?600:500,paddingRight:q?56:10},children:[A&&n?o.jsx(J,{size:13,style:{flexShrink:0,color:e.accent,animation:"dql-agent-run-spin 0.8s linear infinite"}}):c.favorite?o.jsx(G,{size:13,style:{flexShrink:0,color:e.accent},fill:"currentColor"}):o.jsx(xe,{size:13,style:{flexShrink:0,opacity:.7}}),o.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:A&&n?"Working…":c.title}),q?null:o.jsx("span",{style:{flexShrink:0,fontSize:10,color:A&&n?e.accent:e.textMuted,fontWeight:A&&n?650:400},children:A&&n?"Live":Te(c.updatedAt)})]}),q&&!z?o.jsxs("div",{style:{position:"absolute",right:4,display:"inline-flex",gap:2},children:[o.jsx(W,{t:e,label:c.favorite?"Unpin conversation":"Pin conversation",onClick:()=>w(c.id),children:o.jsx(G,{size:12,fill:c.favorite?"currentColor":"none"})}),o.jsx(W,{t:e,label:"Rename conversation",onClick:()=>M(c),children:o.jsx(me,{size:12})}),o.jsx(W,{t:e,label:"Delete conversation",onClick:()=>a(c.id),children:o.jsx(le,{size:12})})]}):null]},c.id)};return o.jsxs("aside",{style:{width:248,flexShrink:0,borderRight:`1px solid ${e.headerBorder}`,background:e.cellBg,display:"flex",flexDirection:"column",minHeight:0},children:[o.jsx("div",{style:{padding:12},children:o.jsxs("button",{type:"button",onClick: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:[_.length>0?o.jsxs(o.Fragment,{children:[o.jsx(L,{t:e,children:"Favourites"}),_.map(c=>P(c)),o.jsx(L,{t:e,children:"Recent"})]}):o.jsx(L,{t:e,children:"Recent"}),$.map(c=>P(c))]})}),o.jsxs("div",{style:{padding:"10px 12px",borderTop:`1px solid ${e.headerBorder}`,display:"flex",alignItems:"center",gap:7,fontSize:11,color:e.textMuted},children:[o.jsx(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{Ye as AnalyticsHome,ke as askNotebookCellFromPayload,ye as mergePersistedAskConversations};
|