@duckcodeailabs/dql-cli 1.12.8 → 1.12.10

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 (63) hide show
  1. package/dist/assets/dql-notebook/assets/{AgentAnswerCard-D1VcQOTJ.js → AgentAnswerCard-Dp4odOLE.js} +1 -1
  2. package/dist/assets/dql-notebook/assets/{AgentLogPage-DKvtW4Fq.js → AgentLogPage-uvVs284-.js} +1 -1
  3. package/dist/assets/dql-notebook/assets/{AiBuildDialog-apJ4HoK3.js → AiBuildDialog-DEUS19WF.js} +1 -1
  4. package/dist/assets/dql-notebook/assets/{AiBuildResult-CvNitmsw.js → AiBuildResult-B9KmBRsh.js} +1 -1
  5. package/dist/assets/dql-notebook/assets/{AiSidePanel-B2cqbPJr.js → AiSidePanel-C7BZVSkM.js} +1 -1
  6. package/dist/assets/dql-notebook/assets/{AnalyticsHome-D5I-Okbz.js → AnalyticsHome-4TgtH6SB.js} +1 -1
  7. package/dist/assets/dql-notebook/assets/{AppsView-DLtjogVz.js → AppsView-CnfNtk5W.js} +3 -3
  8. package/dist/assets/dql-notebook/assets/{BlockStudio-BmNsIfNK.js → BlockStudio-DUXN3MKz.js} +1 -1
  9. package/dist/assets/dql-notebook/assets/{BusinessArtifactView-Bvn5X8uW.js → BusinessArtifactView-D8FIgrkF.js} +1 -1
  10. package/dist/assets/dql-notebook/assets/{DbtFirstModelingPage-DnpVGZJv.js → DbtFirstModelingPage-DR8hTZ95.js} +1 -1
  11. package/dist/assets/dql-notebook/assets/{GitPage-C_5u2aCj.js → GitPage-BS2sm9zh.js} +1 -1
  12. package/dist/assets/dql-notebook/assets/{GlobalAiRail-ZOHo4H6j.js → GlobalAiRail-B_MZsB0z.js} +1 -1
  13. package/dist/assets/dql-notebook/assets/{GovernedContextPage-CUaYIqfd.js → GovernedContextPage-CNM5UCAH.js} +1 -1
  14. package/dist/assets/dql-notebook/assets/{HelpDocsPage-6SmmBvJh.js → HelpDocsPage-Bc5pLakt.js} +1 -1
  15. package/dist/assets/dql-notebook/assets/{HomePage-LDu8z_nW.js → HomePage-DQSo-K4y.js} +1 -1
  16. package/dist/assets/dql-notebook/assets/{LineageDAG-VFSCvevO.js → LineageDAG-RdpWmGmR.js} +1 -1
  17. package/dist/assets/dql-notebook/assets/{LineageDetailView-CuGG_JDv.js → LineageDetailView-CZEx2r1H.js} +1 -1
  18. package/dist/assets/dql-notebook/assets/{LineageDrawer-B2SVsEw1.js → LineageDrawer-P7ZdOW8-.js} +1 -1
  19. package/dist/assets/dql-notebook/assets/{LineagePathBreadcrumb-qWhGM3bh.js → LineagePathBreadcrumb-DTUMFkJ8.js} +1 -1
  20. package/dist/assets/dql-notebook/assets/{MiniLineageGraph-BHxUFWDi.js → MiniLineageGraph-Ctp_yFh8.js} +1 -1
  21. package/dist/assets/dql-notebook/assets/{NewBlockModal-oo3fU5OW.js → NewBlockModal-BLtjuWGy.js} +1 -1
  22. package/dist/assets/dql-notebook/assets/{NewNotebookModal-Bl78Nnjz.js → NewNotebookModal-xgaKB2kI.js} +1 -1
  23. package/dist/assets/dql-notebook/assets/NotebookEditor-D6RgLQw-.js +202 -0
  24. package/dist/assets/dql-notebook/assets/{ReadinessPage-CL2EJLKo.js → ReadinessPage-C8hATaT_.js} +1 -1
  25. package/dist/assets/dql-notebook/assets/{SetupOnboarding-Cqw2NuAn.js → SetupOnboarding-DX2f53J2.js} +1 -1
  26. package/dist/assets/dql-notebook/assets/{TrustBadge-C4jIUuEE.js → TrustBadge-DPnKzRSY.js} +1 -1
  27. package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-CwxQ4T19.js +83 -0
  28. package/dist/assets/dql-notebook/assets/{answer-to-notebook-mhY-MBsX.js → answer-to-notebook-Bm9oByWA.js} +1 -1
  29. package/dist/assets/dql-notebook/assets/{arrow-left-CwMW-Dnz.js → arrow-left-D2FbLWqh.js} +1 -1
  30. package/dist/assets/dql-notebook/assets/{arrow-right-CJ_6d0z7.js → arrow-right-OYItAZ-s.js} +1 -1
  31. package/dist/assets/dql-notebook/assets/{book-open-text-B2q44mou.js → book-open-text-BnnirfAc.js} +1 -1
  32. package/dist/assets/dql-notebook/assets/{bot-CbsSLtXR.js → bot-BJNxPYFm.js} +1 -1
  33. package/dist/assets/dql-notebook/assets/{chevron-up-DSMkEFrK.js → chevron-up-DM5LX-26.js} +1 -1
  34. package/dist/assets/dql-notebook/assets/{circle-x-C5hi2hCq.js → circle-x-Dic_-4tF.js} +1 -1
  35. package/dist/assets/dql-notebook/assets/{dagre.esm-BT65gOyC.js → dagre.esm-C9zxjHHX.js} +1 -1
  36. package/dist/assets/dql-notebook/assets/{external-link-sDmXu1pG.js → external-link-DHxAcoCE.js} +1 -1
  37. package/dist/assets/dql-notebook/assets/{grip-vertical-Ca_E_fRZ.js → grip-vertical-02I-EOjL.js} +1 -1
  38. package/dist/assets/dql-notebook/assets/{index-CcZ8Dw84.js → index-Ca3UeUWI.js} +3 -3
  39. package/dist/assets/dql-notebook/assets/{link-2-DaVaJfdX.js → link-2-Delh-lai.js} +1 -1
  40. package/dist/assets/dql-notebook/assets/{list-tree-DMGqPCsV.js → list-tree-BrIZg6l6.js} +1 -1
  41. package/dist/assets/dql-notebook/assets/{maximize-2-CVJP65sF.js → maximize-2-CQOA-bbN.js} +1 -1
  42. package/dist/assets/dql-notebook/assets/{minimize-2-BnsbPUr5.js → minimize-2-CUDBPkwe.js} +1 -1
  43. package/dist/assets/dql-notebook/assets/{panel-right-open-BTTos1w4.js → panel-right-open-CwhZfkKJ.js} +1 -1
  44. package/dist/assets/dql-notebook/assets/{pencil-BDR0kEX-.js → pencil-Cf6-MgpT.js} +1 -1
  45. package/dist/assets/dql-notebook/assets/{rotate-ccw-DrQw5ZrW.js → rotate-ccw-DndbJAiz.js} +1 -1
  46. package/dist/assets/dql-notebook/assets/{semantic-fields-CgqeBot0.js → semantic-fields-DwKPY_mU.js} +1 -1
  47. package/dist/assets/dql-notebook/assets/{star-DBVkbHOE.js → star-DvcMC9wZ.js} +1 -1
  48. package/dist/assets/dql-notebook/assets/{triangle-alert-_FtKJhjm.js → triangle-alert-DUf4Ook0.js} +1 -1
  49. package/dist/assets/dql-notebook/assets/{usePersistedAgentThreadId-BG1TZXp_.js → usePersistedAgentThreadId-DbdBi0oH.js} +1 -1
  50. package/dist/assets/dql-notebook/assets/{user-round-DkUToep7.js → user-round-DSt0xU3K.js} +1 -1
  51. package/dist/assets/dql-notebook/assets/{wand-sparkles-TgacCrJg.js → wand-sparkles-ro8Cq0ro.js} +1 -1
  52. package/dist/assets/dql-notebook/assets/{workflow-z-B8gUF9.js → workflow-DVJXehjU.js} +1 -1
  53. package/dist/assets/dql-notebook/assets/{wrench-CgXGBYJ-.js → wrench-DxUnoHtz.js} +1 -1
  54. package/dist/assets/dql-notebook/assets/{x-FQc3jbQ8.js → x-9Gtb3EAd.js} +1 -1
  55. package/dist/assets/dql-notebook/index.html +1 -1
  56. package/dist/local-runtime.d.ts +71 -1
  57. package/dist/local-runtime.d.ts.map +1 -1
  58. package/dist/local-runtime.js +558 -54
  59. package/dist/local-runtime.js.map +1 -1
  60. package/dist/package.json +10 -10
  61. package/package.json +10 -10
  62. package/dist/assets/dql-notebook/assets/NotebookEditor-BWMX6Xfi.js +0 -202
  63. package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-CZjUHLl5.js +0 -83
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/HomePage-LDu8z_nW.js","assets/TrustBadge-C4jIUuEE.js","assets/arrow-right-CJ_6d0z7.js","assets/triangle-alert-_FtKJhjm.js","assets/book-open-text-B2q44mou.js","assets/workflow-z-B8gUF9.js","assets/react-CRB3T2We.js","assets/AnalyticsHome-D5I-Okbz.js","assets/answer-to-notebook-mhY-MBsX.js","assets/UnifiedAgentRunPanel-CZjUHLl5.js","assets/AgentAnswerCard-D1VcQOTJ.js","assets/usePersistedAgentThreadId-BG1TZXp_.js","assets/AiBuildResult-CvNitmsw.js","assets/user-round-DkUToep7.js","assets/rotate-ccw-DrQw5ZrW.js","assets/x-FQc3jbQ8.js","assets/pencil-BDR0kEX-.js","assets/list-tree-DMGqPCsV.js","assets/wrench-CgXGBYJ-.js","assets/chevron-up-DSMkEFrK.js","assets/star-DBVkbHOE.js","assets/GlobalAiRail-ZOHo4H6j.js","assets/AiSidePanel-B2cqbPJr.js","assets/minimize-2-BnsbPUr5.js","assets/maximize-2-CVJP65sF.js","assets/NotebookEditor-BWMX6Xfi.js","assets/LineagePathBreadcrumb-qWhGM3bh.js","assets/codemirror-1_I9gm6Z.js","assets/semantic-fields-CgqeBot0.js","assets/MiniLineageGraph-BHxUFWDi.js","assets/dagre.esm-BT65gOyC.js","assets/dagre-BZV40eAE.css","assets/link-2-DaVaJfdX.js","assets/NewNotebookModal-Bl78Nnjz.js","assets/NewBlockModal-oo3fU5OW.js","assets/SetupOnboarding-Cqw2NuAn.js","assets/arrow-left-CwMW-Dnz.js","assets/BlockStudio-BmNsIfNK.js","assets/panel-right-open-BTTos1w4.js","assets/bot-CbsSLtXR.js","assets/BusinessArtifactView-Bvn5X8uW.js","assets/LineageDetailView-CuGG_JDv.js","assets/LineageDAG-VFSCvevO.js","assets/HelpDocsPage-6SmmBvJh.js","assets/GitPage-C_5u2aCj.js","assets/external-link-sDmXu1pG.js","assets/ReadinessPage-CL2EJLKo.js","assets/ai-build-bus-1BR770pY.js","assets/wand-sparkles-TgacCrJg.js","assets/AgentLogPage-DKvtW4Fq.js","assets/circle-x-C5hi2hCq.js","assets/GovernedContextPage-CUaYIqfd.js","assets/DbtFirstModelingPage-DnpVGZJv.js","assets/AppsView-DLtjogVz.js","assets/grip-vertical-Ca_E_fRZ.js","assets/LineageDrawer-B2SVsEw1.js","assets/AiBuildDialog-apJ4HoK3.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/HomePage-DQSo-K4y.js","assets/TrustBadge-DPnKzRSY.js","assets/arrow-right-OYItAZ-s.js","assets/triangle-alert-DUf4Ook0.js","assets/book-open-text-BnnirfAc.js","assets/workflow-DVJXehjU.js","assets/react-CRB3T2We.js","assets/AnalyticsHome-4TgtH6SB.js","assets/answer-to-notebook-Bm9oByWA.js","assets/UnifiedAgentRunPanel-CwxQ4T19.js","assets/AgentAnswerCard-Dp4odOLE.js","assets/usePersistedAgentThreadId-DbdBi0oH.js","assets/AiBuildResult-B9KmBRsh.js","assets/user-round-DSt0xU3K.js","assets/rotate-ccw-DndbJAiz.js","assets/x-9Gtb3EAd.js","assets/pencil-Cf6-MgpT.js","assets/list-tree-BrIZg6l6.js","assets/wrench-DxUnoHtz.js","assets/chevron-up-DM5LX-26.js","assets/star-DvcMC9wZ.js","assets/GlobalAiRail-B_MZsB0z.js","assets/AiSidePanel-C7BZVSkM.js","assets/minimize-2-CUDBPkwe.js","assets/maximize-2-CQOA-bbN.js","assets/NotebookEditor-D6RgLQw-.js","assets/LineagePathBreadcrumb-DTUMFkJ8.js","assets/codemirror-1_I9gm6Z.js","assets/semantic-fields-DwKPY_mU.js","assets/MiniLineageGraph-Ctp_yFh8.js","assets/dagre.esm-C9zxjHHX.js","assets/dagre-BZV40eAE.css","assets/link-2-Delh-lai.js","assets/NewNotebookModal-xgaKB2kI.js","assets/NewBlockModal-BLtjuWGy.js","assets/SetupOnboarding-DX2f53J2.js","assets/arrow-left-D2FbLWqh.js","assets/BlockStudio-DUXN3MKz.js","assets/panel-right-open-CwhZfkKJ.js","assets/bot-BJNxPYFm.js","assets/BusinessArtifactView-D8FIgrkF.js","assets/LineageDetailView-CZEx2r1H.js","assets/LineageDAG-RdpWmGmR.js","assets/HelpDocsPage-Bc5pLakt.js","assets/GitPage-BS2sm9zh.js","assets/external-link-DHxAcoCE.js","assets/ReadinessPage-C8hATaT_.js","assets/ai-build-bus-1BR770pY.js","assets/wand-sparkles-ro8Cq0ro.js","assets/AgentLogPage-uvVs284-.js","assets/circle-x-Dic_-4tF.js","assets/GovernedContextPage-CNM5UCAH.js","assets/DbtFirstModelingPage-DR8hTZ95.js","assets/AppsView-CnfNtk5W.js","assets/grip-vertical-02I-EOjL.js","assets/LineageDrawer-P7ZdOW8-.js","assets/AiBuildDialog-DEUS19WF.js"])))=>i.map(i=>d[i]);
2
2
  var Nd=Object.defineProperty;var Bd=(e,t,n)=>t in e?Nd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ee=(e,t,n)=>Bd(e,typeof t!="symbol"?t+"":t,n);import{r as $a,a as Oa,g as Pa}from"./react-CRB3T2We.js";function Fd(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const o in r)if(o!=="default"&&!(o in e)){const i=Object.getOwnPropertyDescriptor(r,o);i&&Object.defineProperty(e,o,i.get?i:{enumerable:!0,get:()=>r[o]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const i of o)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(o){if(o.ep)return;o.ep=!0;const i=n(o);fetch(o.href,i)}})();var ao={exports:{}},jn={};/**
3
3
  * @license React
4
4
  * react-jsx-runtime.production.min.js
@@ -402,7 +402,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
402
402
  * This source code is licensed under the ISC license.
403
403
  * See the LICENSE file in the root directory of this source tree.
404
404
  */const Ex=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],zc=Y("trash-2",Ex);function Ax(e,t){if(!t)return 1;const n=(e.label+" "+e.group+" "+(e.keywords||"")).toLowerCase(),r=t.toLowerCase();if(n.includes(r))return 100-n.indexOf(r);let o=0;for(const i of n)if(i===r[o]&&o++,o===r.length)return 10;return 0}function Tx(e,t){const n=e.mode??"both";return n==="both"||n===t}function Rx({open:e,onClose:t}){const{state:n,dispatch:r}=ve(),[o,i]=u.useState(""),[l,a]=u.useState(0),d=u.useRef(null);u.useEffect(()=>{e&&(i(""),a(0))},[e]);const c=u.useMemo(()=>{const g=v=>r(v),S=()=>t(),x=v=>()=>{v(),S()},b=[["Files","files",Ay],["Lineage","lineage",Ny],["Git","git",Sn],["Block Library","block_library",Ps],["Apps","apps",Gy],["Connections","connection",ox]],k=[{mode:"obsidian",label:"Obsidian"},{mode:"paper",label:"Paper"},{mode:"white",label:"White"}],C=[];C.push({id:"sidebar.toggle",label:n.sidebarOpen?"Hide sidebar":"Show sidebar",group:"View",icon:nx,shortcut:"⌘B",mode:"studio",run:x(()=>g({type:"TOGGLE_SIDEBAR"}))},{id:"inspector.toggle",label:n.inspectorOpen?"Hide inspector":"Show inspector",group:"View",icon:n.inspectorOpen?dy:Lc,shortcut:"⌘⇧I",mode:"studio",run:x(()=>g({type:"TOGGLE_INSPECTOR"}))},{id:"dashboard.toggle",label:n.dashboardMode?"Exit dashboard mode":"Enter dashboard mode",group:"View",icon:zy,shortcut:"⌘D",run:x(()=>g({type:"TOGGLE_DASHBOARD_MODE"}))},{id:"dev.toggle",label:"Toggle dev panel",group:"View",icon:Cx,shortcut:"⌘J",mode:"studio",run:x(()=>g({type:"TOGGLE_DEV_PANEL"}))});for(const[v,w,A]of b)C.push({id:`panel.${w}`,label:`Go to ${v}`,group:"Navigate",icon:A,mode:"studio",run:x(()=>{g({type:"SET_SIDEBAR_PANEL",panel:w}),w!=="lineage"&&!n.sidebarOpen&&g({type:"TOGGLE_SIDEBAR"})})});C.push({id:"notebook.new",label:"New notebook…",group:"Create",icon:Nc,mode:"studio",run:x(()=>g({type:"OPEN_NEW_NOTEBOOK_MODAL"}))},{id:"block.new",label:"New block…",group:"Create",icon:Sx,mode:"studio",run:x(()=>g({type:"OPEN_NEW_BLOCK_MODAL"}))});const E=n.themeMode==="dark"||n.themeMode==="midnight"?"obsidian":n.themeMode==="light"?"paper":n.themeMode==="arctic"?"white":n.themeMode;for(const v of k)v.mode!==E&&C.push({id:`theme.${v.mode}`,label:`Switch to ${v.label}`,group:"Theme",icon:ex,keywords:"appearance color",run:x(()=>g({type:"SET_THEME",mode:v.mode}))});return C},[n.sidebarOpen,n.inspectorOpen,n.themeMode,n.dashboardMode,n.appMode,n.sidebarPanel,r,t]),f=u.useMemo(()=>{const S=c.filter(x=>Tx(x,n.appMode)).map(x=>({a:x,s:Ax(x,o)})).filter(x=>x.s>0);return S.sort((x,b)=>b.s-x.s),S.map(x=>x.a)},[c,o,n.appMode]);u.useEffect(()=>{a(0)},[o]),u.useEffect(()=>{var S;const g=(S=d.current)==null?void 0:S.querySelector(`[data-palette-idx="${l}"]`);g==null||g.scrollIntoView({block:"nearest"})},[l]);const p=g=>{var S;g.key==="ArrowDown"?(g.preventDefault(),a(x=>Math.min(f.length-1,x+1))):g.key==="ArrowUp"?(g.preventDefault(),a(x=>Math.max(0,x-1))):g.key==="Enter"&&(g.preventDefault(),(S=f[l])==null||S.run())};let h="";return s.jsx(dh,{open:e,onOpenChange:g=>!g&&t(),children:s.jsxs(uh,{children:[s.jsx(ph,{style:{position:"fixed",inset:0,background:le("surfaceOverlay"),zIndex:zn.overlay}}),s.jsxs(fh,{"aria-label":"Command palette",style:{position:"fixed",top:"18vh",left:"50%",transform:"translateX(-50%)",width:"92vw",maxWidth:620,background:le("surfaceRaised"),color:le("textPrimary"),border:`1px solid ${le("borderDefault")}`,borderRadius:Lt.lg,boxShadow:le("shadowLg"),zIndex:zn.modal,display:"flex",flexDirection:"column",overflow:"hidden"},onKeyDown:p,children:[s.jsx(hh,{style:{position:"absolute",left:-9999},children:"Command palette"}),s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:he[2],padding:`${he[3]}px ${he[4]}px`,borderBottom:`1px solid ${le("borderSubtle")}`},children:[s.jsx(iy,{size:14,strokeWidth:1.75,color:le("textMuted")}),s.jsx("input",{autoFocus:!0,value:o,onChange:g=>i(g.target.value),placeholder:"Type a command…",style:{flex:1,border:"none",outline:"none",background:"transparent",color:le("textPrimary"),fontSize:Fe.md}})]}),s.jsxs("div",{ref:d,style:{maxHeight:360,overflowY:"auto",padding:`${he[1]}px 0`},children:[f.length===0&&s.jsx("div",{style:{padding:he[4],fontSize:Fe.sm,color:le("textMuted"),textAlign:"center"},children:"No matching commands"}),f.map((g,S)=>{const x=g.group!==h;h=g.group;const b=S===l,k=g.icon;return s.jsxs(De.Fragment,{children:[x&&s.jsx("div",{style:{padding:`${he[2]}px ${he[4]}px ${he[1]}px`},children:s.jsx(Oc,{tone:"neutral",children:g.group})}),s.jsxs("div",{"data-palette-idx":S,role:"option","aria-selected":b,onMouseEnter:()=>a(S),onMouseDown:C=>{C.preventDefault(),g.run()},style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:he[3],padding:`${he[2]}px ${he[4]}px`,fontSize:Fe.sm,cursor:"pointer",background:b?le("surfaceHover"):"transparent",color:le("textPrimary")},children:[s.jsxs("span",{style:{display:"flex",alignItems:"center",gap:he[2],minWidth:0,flex:1},children:[k&&s.jsx(k,{size:14,strokeWidth:1.75}),s.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:g.label})]}),g.shortcut&&s.jsx(sg,{shortcut:g.shortcut})]})]},g.id)})]})]})]})})}function Qo(e){const t=Tt(e);if(!t)return;const n=Px(t.kind),r=_x(t.source);if(!n||!r)return;const o=Wx(t.limit);return{kind:n,source:r,name:ot(t.name),sourcePath:ot(t.sourcePath),metrics:Yo(t.metrics),dimensions:Yo(t.dimensions),filters:Dx(t.filters),timeDimension:Mx(t.timeDimension),orderBy:Ix(t.orderBy),parameters:Lx(t.parameters),parameterValues:zx(t.parameterValues),persistence:qx(t.persistence),trustState:Ux(t.trustState),compiledSql:ot(t.compiledSql),executionReceipt:Ox(t.executionReceipt),filterableColumns:$x(t.filterableColumns),...o===void 0?{}:{limit:o}}}function _x(e){return typeof e=="string"&&e.trim().length>0?e:void 0}function $x(e){if(!Array.isArray(e))return;const t=e.flatMap(n=>{const r=Tt(n),o=ot(r==null?void 0:r.column),i=ot(r==null?void 0:r.predicateTarget);return o&&i?[{column:o,predicateTarget:i}]:[]});return t.length>0?t:void 0}function Ox(e){const t=Tt(e);if(!t)return;const n=gr(t.sourceFingerprint),r=gr(t.compiledSqlFingerprint),o=gr(t.parameterFingerprint),i=gr(t.resultFingerprint);return n&&r&&o&&i?{sourceFingerprint:n,compiledSqlFingerprint:r,parameterFingerprint:o,resultFingerprint:i}:void 0}function gr(e){return typeof e=="string"&&/^[a-f0-9]{64}$/i.test(e.trim())?e.trim().toLowerCase():void 0}function Px(e){return e==="certified_block"||e==="semantic_block"||e==="sql_block"?e:void 0}function Dx(e){if(!Array.isArray(e))return;const t=e.flatMap(n=>{const r=Tt(n);if(!r)return[];const o=ot(r.dimension),i=ot(r.operator);return!o||!i?[]:[{dimension:o,operator:i,values:Yo(r.values)??[]}]});return t.length?t:void 0}function Mx(e){const t=Tt(e);if(!t)return;const n=ot(t.name),r=ot(t.granularity);return n&&r?{name:n,granularity:r}:void 0}function Ix(e){if(!Array.isArray(e))return;const t=e.flatMap(n=>{const r=Tt(n);if(!r)return[];const o=ot(r.name),i=r.direction==="asc"||r.direction==="desc"?r.direction:void 0;return o&&i?[{name:o,direction:i}]:[]});return t.length?t:void 0}function Lx(e){if(!Array.isArray(e))return;const t=new Set,n=e.flatMap(r=>{const o=Tt(r),i=ot(o==null?void 0:o.name),l=Nx(o==null?void 0:o.type),a=Bx(o==null?void 0:o.policy);if(!o||!i||!l||!a||t.has(i))return[];t.add(i);const d=Fx(o.binding);return[{name:i,type:l,required:o.required===!0,...o.default===void 0?{}:{default:o.default},policy:a,...d?{binding:d}:{}}]});return n.length?n:void 0}function Nx(e){return e==="string"||e==="number"||e==="boolean"||e==="date"||e==="string[]"||e==="number[]"||e==="date[]"?e:void 0}function Bx(e){return e==="dynamic"||e==="static"||e==="business"||e==="derived"||e==="optional"||e==="ambiguous_review_required"?e:void 0}function Fx(e){const t=Tt(e);if(!t)return;if(t.kind==="sql_value")return{kind:"sql_value"};if(t.kind==="limit")return{kind:"limit"};const n=ot(t.field);if(t.kind==="semantic_filter"&&n&&(t.operator==="equals"||t.operator==="in"||t.operator==="gte"||t.operator==="lte"))return{kind:"semantic_filter",field:n,operator:t.operator}}function zx(e){const t=Tt(e);if(!t)return;const n=Object.entries(t).filter(([r])=>r.trim().length>0);return n.length?Object.fromEntries(n):void 0}function qx(e){return e==="transient"||e==="saved"?e:void 0}function Ux(e){return e==="certified"||e==="governed"||e==="review_required"?e:void 0}function Tt(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function ot(e){return typeof e=="string"&&e.trim().length>0?e.trim():void 0}function Yo(e){if(!Array.isArray(e))return;const t=e.filter(n=>typeof n=="string"&&n.trim().length>0).map(n=>n.trim());return t.length?t:void 0}function Wx(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?Math.floor(e):void 0}const qc="dql_token",Fi="dql.server-token.v1";function Kx(e){var r;return((r=new URLSearchParams(e.replace(/^#/,"")).get(qc))==null?void 0:r.trim())||void 0}function Vx(e){const t=new URLSearchParams(e.replace(/^#/,""));t.delete(qc);const n=t.toString();return n?`#${n}`:""}function Hx(){var e;if(!(typeof window>"u"))try{const t=Kx(window.location.hash);if(t){window.sessionStorage.setItem(Fi,t);const n=Vx(window.location.hash);return window.history.replaceState(window.history.state,"",`${window.location.pathname}${window.location.search}${n}`),t}return((e=window.sessionStorage.getItem(Fi))==null?void 0:e.trim())||void 0}catch{return}}const zi=Hx();function $n(e){const t=new Headers(e);return zi&&t.set("Authorization",`Bearer ${zi}`),t}const Gx={totals:{modelsScanned:0,businessModels:0,plumbingExcluded:0,metricsFound:0},willGenerate:0,willSkip:0,domains:[],config:{businessLayers:[],excludeLayers:[],maxPerDomain:0,minScore:0,aiEnrichment:"auto"}};function yr(){return{total:0,tracked:0,changed:0,untracked:0,ignored:0,paths:[]}}const On=window.location.origin;class vt extends Error{constructor(n){super(n.message);Ee(this,"status");Ee(this,"code");Ee(this,"recoverable");Ee(this,"details");Ee(this,"nextActions");Ee(this,"requestId");Ee(this,"snapshotId");this.name="DqlApiError",this.status=n.status,this.code=n.code,this.recoverable=n.recoverable,this.details=n.details,this.nextActions=n.nextActions,this.requestId=n.requestId,this.snapshotId=n.snapshotId}}function Xo(e,t){const n=t.trim()||e.statusText||`HTTP ${e.status}`;if(!t.trim())return new vt({message:n,status:e.status});try{const r=JSON.parse(t),o=typeof(r==null?void 0:r.message)=="string"&&r.message.trim()?r.message:typeof(r==null?void 0:r.error)=="string"&&r.error.trim()?r.error:n;return new vt({message:o,status:e.status,code:typeof(r==null?void 0:r.code)=="string"?r.code:void 0,recoverable:typeof(r==null?void 0:r.recoverable)=="boolean"?r.recoverable:void 0,details:r==null?void 0:r.details,nextActions:Array.isArray(r==null?void 0:r.nextActions)?r.nextActions.filter(i=>typeof i=="string"):void 0,requestId:typeof(r==null?void 0:r.requestId)=="string"?r.requestId:void 0,snapshotId:typeof(r==null?void 0:r.snapshotId)=="string"?r.snapshotId:void 0})}catch{return new vt({message:n,status:e.status})}}const So=new Map;async function j(e,t){if(((t==null?void 0:t.method)??"GET").toUpperCase()==="GET"&&!(t!=null&&t.signal)&&!(t!=null&&t.body)){const o=So.get(e);if(o)return o;const i=qi(e,t).finally(()=>{So.delete(e)});return So.set(e,i),i}return qi(e,t)}async function qi(e,t){var r;let n;try{const o=$n(t==null?void 0:t.headers);o.has("Content-Type")||o.set("Content-Type","application/json"),n=await fetch(`${On}${e}`,{...t,headers:o})}catch(o){if((r=t==null?void 0:t.signal)!=null&&r.aborted)throw o;const i=o instanceof Error&&o.message?` ${o.message}`:"";throw new Error(`Unable to reach the local DQL notebook server. Check that it is still running, then retry.${i}`)}if(!n.ok){const o=await n.text().catch(()=>"");throw Xo(n,o)}if(n.status!==204)return n.json()}async function Jx(e,t){if(!e.body)throw new Error("Agent run stream is not available in this browser.");const n=e.body.getReader(),r=new TextDecoder;let o="",i;const l=a=>{const d=a.split(/\r?\n/);let c="message";const f=[];for(const h of d)h.startsWith("event:")&&(c=h.slice(6).trim()),h.startsWith("data:")&&f.push(h.slice(5).trimStart());if(f.length===0)return;const p=JSON.parse(f.join(`
405
- `));if(c==="agent-run-event")t({kind:"event",event:p});else if(c==="agent-run-answer-delta"){const h=typeof(p==null?void 0:p.delta)=="string"?p.delta:"";h&&t({kind:"answer-delta",delta:h})}else if(c==="agent-run-complete")i=p,t({kind:"complete",run:i});else if(c==="agent-run-error")throw new Error(typeof(p==null?void 0:p.error)=="string"?p.error:"Agent run failed.")};for(;;){const{value:a,done:d}=await n.read();if(a){o+=r.decode(a,{stream:!d});let c=o.search(/\r?\n\r?\n/);for(;c>=0;){const f=o.slice(0,c);o=o.slice(o[c]==="\r"?c+4:c+2),l(f),c=o.search(/\r?\n\r?\n/)}}if(d)break}if(o.trim()&&l(o),!i)throw new Error("Agent run stream ended before completion.");return i}function cn(e){var r;const t=Array.isArray(e==null?void 0:e.columns)?e.columns.map(o=>typeof o=="string"?o:typeof(o==null?void 0:o.name)=="string"?o.name:String(o)):[],n=e!=null&&e.semanticRefs&&typeof e.semanticRefs=="object"?{metrics:Array.isArray(e.semanticRefs.metrics)?e.semanticRefs.metrics.map(String):[],dimensions:Array.isArray(e.semanticRefs.dimensions)?e.semanticRefs.dimensions.map(String):[]}:void 0;return{columns:t,rows:Array.isArray(e==null?void 0:e.rows)?e.rows:[],rowCount:(e==null?void 0:e.rowCount)??((r=e==null?void 0:e.rows)==null?void 0:r.length)??0,executionTime:(e==null?void 0:e.executionTime)??(e==null?void 0:e.executionTimeMs)??0,...n?{semanticRefs:n}:{}}}function wt(e){var n;const t=e!=null&&e.resultPreview&&typeof e.resultPreview=="object"?cn(e.resultPreview):void 0;return{...e,domain:typeof(e==null?void 0:e.domain)=="string"&&e.domain.trim()?e.domain:void 0,owner:typeof(e==null?void 0:e.owner)=="string"&&e.owner.trim()?e.owner:void 0,warnings:Array.isArray(e==null?void 0:e.warnings)?e.warnings:[],dqlCandidateIds:Array.isArray(e==null?void 0:e.dqlCandidateIds)?e.dqlCandidateIds:[],dqlArtifact:Qo(e==null?void 0:e.dqlArtifact),dqlPromotionAction:sb((e==null?void 0:e.dqlPromotionAction)??((n=e==null?void 0:e.dqlPromotion)==null?void 0:n.recommendedAction)),dqlPromotion:Uc(e==null?void 0:e.dqlPromotion),researchPlan:Qx(e==null?void 0:e.researchPlan),reviewChecklist:rb(e==null?void 0:e.reviewChecklist,e),...t?{resultPreview:t}:{resultPreview:void 0}}}function Qx(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t=e,n=t.evidence&&typeof t.evidence=="object"&&!Array.isArray(t.evidence)?t.evidence:{},r=t.preview&&typeof t.preview=="object"&&!Array.isArray(t.preview)?t.preview:{},o=t.promotion&&typeof t.promotion=="object"&&!Array.isArray(t.promotion)?t.promotion:{},i=t.sqlState==="generated"||t.sqlState==="reviewed"?t.sqlState:"missing",l=r.status==="ready"||r.status==="error"?r.status:"not_run",a=o.path==="review_context"||o.path==="run_preview"||o.path==="reuse_existing"||o.path==="create_dql_draft"||o.path==="open_certification"||o.path==="complete_review"?o.path:"needs_sql",d=typeof r.rowCount=="number"&&Number.isFinite(r.rowCount)?r.rowCount:void 0;return{sqlState:i,grain:typeof t.grain=="string"&&t.grain.trim()?t.grain:void 0,parameterPolicy:Yx(t.parameterPolicy),allowedFilters:Array.isArray(t.allowedFilters)?t.allowedFilters.map(String).filter(Boolean):[],evidence:{trustLabel:typeof n.trustLabel=="string"&&n.trustLabel.trim()?n.trustLabel:void 0,contextPackId:typeof n.contextPackId=="string"&&n.contextPackId.trim()?n.contextPackId:void 0,evidenceCount:ge(n.evidenceCount),relationCount:ge(n.relationCount),missingContextCount:ge(n.missingContextCount)},preview:{status:l,...d===void 0?{}:{rowCount:d}},promotion:{path:a,duplicateDecision:typeof o.duplicateDecision=="string"&&o.duplicateDecision.trim()?o.duplicateDecision:void 0},reviewFocus:Array.isArray(t.reviewFocus)?t.reviewFocus.map(String).filter(Boolean):[],generatedAt:typeof t.generatedAt=="string"&&t.generatedAt.trim()?t.generatedAt:new Date(0).toISOString()}}function Yx(e){return Array.isArray(e)?e.flatMap(t=>{if(!t||typeof t!="object"||Array.isArray(t))return[];const n=t,r=typeof n.name=="string"&&n.name.trim()?n.name:void 0,o=typeof n.policy=="string"&&n.policy.trim()?n.policy:void 0;return r&&o?[{name:r,policy:o}]:[]}):[]}function ge(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function sn(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function Xx(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{};return{totalReviewCount:ge(t.totalReviewCount),openReviewCount:ge(t.openReviewCount),terminalReviewCount:ge(t.terminalReviewCount),draftCreatedCount:ge(t.draftCreatedCount),certifiedCount:ge(t.certifiedCount),completedCount:ge(t.completedCount),rejectedCount:ge(t.rejectedCount),draftCreationRate:sn(t.draftCreationRate),certifyConversionRate:sn(t.certifyConversionRate),medianOpenReviewAgeMs:sn(t.medianOpenReviewAgeMs),medianTimeToDraftMs:sn(t.medianTimeToDraftMs),medianTimeToCertificationMs:sn(t.medianTimeToCertificationMs),medianTimeToTerminalMs:sn(t.medianTimeToTerminalMs)}}function Zx(e){const t=e&&typeof e=="object"?e:{},n=t.counts&&typeof t.counts=="object"?t.counts:{},r=t.health&&typeof t.health=="object"?t.health:{},o=t.search&&typeof t.search=="object"?t.search:{},i=t.updatedAt&&typeof t.updatedAt=="object"?t.updatedAt:{},l=t.limits&&typeof t.limits=="object"?t.limits:{};return{counts:{totalRuns:ge(n.totalRuns),activeRuns:ge(n.activeRuns),closedRuns:ge(n.closedRuns),notebooks:ge(n.notebooks),domains:ge(n.domains),owners:ge(n.owners),sourceLinkedRuns:ge(n.sourceLinkedRuns)},health:{staleOpenRuns:ge(r.staleOpenRuns),expiredOpenRuns:ge(r.expiredOpenRuns),staleThresholdDays:ge(r.staleThresholdDays)||7,expiredThresholdDays:ge(r.expiredThresholdDays)||30,oldestOpenUpdatedAt:typeof r.oldestOpenUpdatedAt=="string"&&r.oldestOpenUpdatedAt.trim()?r.oldestOpenUpdatedAt:void 0,newestOpenUpdatedAt:typeof r.newestOpenUpdatedAt=="string"&&r.newestOpenUpdatedAt.trim()?r.newestOpenUpdatedAt:void 0},search:{indexed:o.indexed===!0,indexRows:ge(o.indexRows),indexVersion:typeof o.indexVersion=="string"&&o.indexVersion.trim()?o.indexVersion:void 0,stale:o.stale===!0},updatedAt:{oldest:typeof i.oldest=="string"&&i.oldest.trim()?i.oldest:void 0,newest:typeof i.newest=="string"&&i.newest.trim()?i.newest:void 0},limits:{pageSize:ge(l.pageSize)||25,maxPageSize:ge(l.maxPageSize)||500,sourceCoverageLimit:ge(l.sourceCoverageLimit)||1e4,seedCellLimit:ge(l.seedCellLimit)||1e3},warnings:Array.isArray(t.warnings)?t.warnings.filter(a=>typeof a=="string"):[]}}function eb(e){return e==="diagnose_change"||e==="driver_breakdown"||e==="segment_compare"||e==="entity_drilldown"||e==="anomaly_investigation"||e==="trust_gap_review"?e:"ad_hoc_analysis"}function tb(e){const t=typeof e=="string"?e:"";return(t.split(/[\\/]/).pop()??t).replace(/\.dqlnb$/i,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim()||"Untitled notebook"}function nb(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},n=r=>typeof t[r]=="number"&&Number.isFinite(t[r])?t[r]:0;return{fix_blockers:n("fix_blockers"),review_sql:n("review_sql"),review_context:n("review_context"),run_preview:n("run_preview"),reuse_existing:n("reuse_existing"),create_dql_draft:n("create_dql_draft"),open_certification:n("open_certification"),complete_review:n("complete_review"),continue_review:n("continue_review")}}function xr(e){return e==="fix_blockers"||e==="review_sql"||e==="review_context"||e==="run_preview"||e==="reuse_existing"||e==="create_dql_draft"||e==="open_certification"||e==="complete_review"||e==="continue_review"?e:void 0}function rb(e,t){var c,f;if(e&&typeof e=="object"&&Array.isArray(e.items))return{readyForDqlDraft:e.readyForDqlDraft===!0,readyForCertificationReview:e.readyForCertificationReview===!0,blockers:Array.isArray(e.blockers)?e.blockers.filter(p=>typeof p=="string"):[],warnings:Array.isArray(e.warnings)?e.warnings.filter(p=>typeof p=="string"):[],items:e.items.map(p=>({id:typeof p.id=="string"?p.id:"item",label:typeof p.label=="string"?p.label:"Review item",status:p.status==="passed"||p.status==="pending"||p.status==="warning"||p.status==="blocked"?p.status:"pending",detail:typeof p.detail=="string"?p.detail:""}))};const n=!!t.reviewedSql,r=n||!!t.generatedSql,o=((c=t.resultPreview)==null?void 0:c.rowCount)??((f=t.resultPreview)==null?void 0:f.rows.length)??0,i=!!(t.resultPreview&&(t.resultPreview.columns.length>0||o>0)),l=!!t.draftBlockPath,a=!!(t.contextPackId||t.evidence),d=t.dqlPromotionAction==="reuse_existing";return{readyForDqlDraft:!!(!d&&t.question&&n&&a&&t.status!=="error"),readyForCertificationReview:!!(!d&&t.question&&n&&a&&i&&l),blockers:t.status==="error"?[t.error??"Preview failed."]:[],warnings:i||d?[]:["Run a bounded preview before certification review."],items:[{id:"question",label:"Question",status:t.question?"passed":"blocked",detail:t.question?"Business question is captured.":"Add a business question."},{id:"sql",label:"Reviewed SQL",status:r||d?"passed":"blocked",detail:d&&!r?"Existing DQL should be reused; no new SQL is required.":r?"SQL is available.":"Add SQL before promotion."},{id:"evidence",label:"Evidence",status:a||d?"passed":"warning",detail:a?"Context evidence is saved.":d?"Reuse evidence is captured in the recommendation.":"Preview and save metadata context."},{id:"preview",label:"Preview",status:i||d?"passed":"pending",detail:i?"Preview result is available.":d?"Certified block reuse does not require a new raw SQL preview.":"Run a bounded preview."},{id:"dql_draft",label:"DQL draft",status:l||d?"passed":"pending",detail:l?`Draft saved at ${t.draftBlockPath}.`:d?"No new DQL draft is required.":"Create a DQL draft after review."}]}}function ob(e){var r,o,i,l;const t=e&&typeof e=="object"?e:{},n=t.routeDecision&&typeof t.routeDecision=="object"?{route:typeof t.routeDecision.route=="string"?t.routeDecision.route:void 0,intent:typeof t.routeDecision.intent=="string"?t.routeDecision.intent:void 0,reason:typeof t.routeDecision.reason=="string"?t.routeDecision.reason:void 0}:void 0;return{contextPackId:typeof t.contextPackId=="string"?t.contextPackId:"",trustLabel:typeof t.trustLabel=="string"?t.trustLabel:void 0,routeDecision:n,evidence:Array.isArray(t.evidence)?t.evidence.map(a=>({objectKey:typeof a.objectKey=="string"?a.objectKey:void 0,objectType:typeof a.objectType=="string"?a.objectType:void 0,name:typeof a.name=="string"?a.name:"Evidence",role:typeof a.role=="string"?a.role:void 0,reason:typeof a.reason=="string"?a.reason:""})):[],summaries:Array.isArray(t.summaries)?t.summaries.map(a=>({title:typeof a.title=="string"?a.title:"Context",detail:typeof a.detail=="string"?a.detail:"",objectType:typeof a.objectType=="string"?a.objectType:void 0,reason:typeof a.reason=="string"?a.reason:void 0})):[],relations:Array.isArray(t.relations)?t.relations.map(a=>({relation:typeof a.relation=="string"?a.relation:"",name:typeof a.name=="string"?a.name:"Relation",source:typeof a.source=="string"?a.source:"",columns:Array.isArray(a.columns)?a.columns.map(String):[]})).filter(a=>a.relation||a.name):[],missingContext:Array.isArray(t.missingContext)?t.missingContext.map(a=>({kind:typeof a.kind=="string"?a.kind:"metadata",message:typeof a.message=="string"?a.message:"",severity:typeof a.severity=="string"?a.severity:"warning"})).filter(a=>a.message):[],warnings:Array.isArray(t.warnings)?t.warnings.filter(a=>typeof a=="string"):[],topRejected:Array.isArray(t.topRejected)?t.topRejected.map(a=>({name:typeof a.name=="string"?a.name:"Rejected context",objectType:typeof a.objectType=="string"?a.objectType:void 0,reason:typeof a.reason=="string"?a.reason:"",score:typeof a.score=="number"&&Number.isFinite(a.score)?a.score:void 0})).filter(a=>a.reason):[],counts:{objects:typeof((r=t.counts)==null?void 0:r.objects)=="number"?t.counts.objects:0,evidence:typeof((o=t.counts)==null?void 0:o.evidence)=="number"?t.counts.evidence:0,relations:typeof((i=t.counts)==null?void 0:i.relations)=="number"?t.counts.relations:0,warnings:typeof((l=t.counts)==null?void 0:l.warnings)=="number"?t.counts.warnings:0}}}function sb(e){return e==="reuse_existing"||e==="extend_existing"||e==="create_replacement"||e==="create_new"||e==="review_required"?e:void 0}function Uc(e){if(!(!e||typeof e!="object"))return{importId:typeof e.importId=="string"?e.importId:"",candidateIds:Array.isArray(e.candidateIds)?e.candidateIds.filter(t=>typeof t=="string"):[],draftBlockPath:typeof e.draftBlockPath=="string"?e.draftBlockPath:void 0,recommendedAction:typeof e.recommendedAction=="string"?e.recommendedAction:void 0,similarityMatches:Array.isArray(e.similarityMatches)?e.similarityMatches:[],candidates:Array.isArray(e.candidates)?e.candidates.map(t=>({...t,similarityMatches:Array.isArray(t.similarityMatches)?t.similarityMatches:[],parameterPolicy:Array.isArray(t.parameterPolicy)?t.parameterPolicy:[],allowedFilters:Array.isArray(t.allowedFilters)?t.allowedFilters:[],warnings:Array.isArray(t.warnings)?t.warnings:[]})):[],createdAt:typeof e.createdAt=="string"?e.createdAt:""}}const N={async getDbtFirstModeling(){return j("/api/modeling/dbt-first")},async getDbtModelingNode(e){return j(`/api/modeling/dbt-first/nodes/${encodeURIComponent(e)}`)},async getDbtModelingNodes(e){return j("/api/modeling/dbt-first/nodes/batch",{method:"POST",body:JSON.stringify({uniqueIds:e})})},async getDbtModelInventory(e={}){const t=new URLSearchParams;return e.q&&t.set("q",e.q),e.domain&&t.set("domain",e.domain),e.cursor!==void 0&&t.set("cursor",String(e.cursor)),e.limit!==void 0&&t.set("limit",String(e.limit)),j(`/api/modeling/dbt-first/inventory?${t.toString()}`)},async getDomainWorkspaces(){return j("/api/domain-workspaces")},async getRelatedDomainProducts(e){return j(`/api/domain-workspaces/${encodeURIComponent(e)}/related-products`)},async getAllRelatedDomainProducts(){return j("/api/domain-workspaces/related-products")},async getDomainKnowledge(e){return j(`/api/domain-workspaces/${encodeURIComponent(e)}/knowledge`)},async previewModelingChange(e,t){return j("/api/modeling/dbt-first/preview",{method:"POST",body:JSON.stringify({change:e,expectedSnapshotId:t})})},async applyModelingChange(e,t,n){return j("/api/modeling/dbt-first/apply",{method:"POST",body:JSON.stringify({change:e,fingerprint:t,expectedSnapshotId:n})})},async validateModelingRelationship(e,t){return(await j("/api/modeling/dbt-first/relationships/validate",{method:"POST",body:JSON.stringify({relationship:e,expectedSnapshotId:t})})).evidence},async previewDbtSourcePatch(e,t){return j("/api/modeling/dbt-first/dbt-source/preview",{method:"POST",body:JSON.stringify({change:e,expectedSnapshotId:t})})},async applyDbtSourcePatch(e,t,n){return j("/api/modeling/dbt-first/dbt-source/apply",{method:"POST",body:JSON.stringify({change:e,expectedFingerprint:t,expectedSnapshotId:n})})},async getSettingsEnvStatus(){try{return await j("/api/settings/env-status")}catch{return{groups:[]}}},async getProposeReadiness(e){try{return await j("/api/propose",{method:"POST",body:JSON.stringify(e??{})})}catch{return{ready:!1,reason:"Unable to reach the propose engine. Is the local DQL server running?",summary:{modelsScanned:0,businessModels:0,plumbingExcluded:0,metricsFound:0,proposalsRanked:0,draftsExisting:0,readyForReview:0,blockingTotal:0,warningTotal:0},plan:Gx,proposals:[]}}},async generateProposeDrafts(e){try{return await j("/api/propose/generate",{method:"POST",body:JSON.stringify(e)})}catch(t){return{ready:!1,reason:t instanceof Error?t.message:"Unable to reach the propose engine.",draftsWritten:0,draftsSkipped:0,proposals:[]}}},async proposePreview(e){return j(`/api/propose/preview?slug=${encodeURIComponent(e)}`)},async aiBuild(e){return j("/api/ai/build",{method:"POST",body:JSON.stringify(e)})},async createAgentRun(e){return(await j("/api/agent-runs",{method:"POST",body:JSON.stringify(e)})).run},async createAgentRunStream(e,t,n){let r;try{r=await fetch(`${On}/api/agent-runs?stream=1`,{method:"POST",headers:$n({"Content-Type":"application/json"}),body:JSON.stringify(e),signal:n})}catch(o){if(n!=null&&n.aborted)throw o;const i=o instanceof Error&&o.message?` ${o.message}`:"";throw new Error(`Unable to reach the local DQL notebook server. Check that it is still running, then retry.${i}`)}if(!r.ok){const o=await r.text().catch(()=>"");throw Xo(r,o)}return Jx(r,t)},async listAgentRuns(e){const t=new URLSearchParams;typeof(e==null?void 0:e.limit)=="number"&&Number.isFinite(e.limit)&&t.set("limit",String(e.limit));const n=t.toString()?`?${t.toString()}`:"";return j(`/api/agent-runs${n}`)},async getAgentRun(e){const t=await this.getAgentRunState(e);if(t.lifecycleState!=="terminal")throw new Error(`Agent run ${e} is still ${t.lifecycleState}.`);return t.run},async getAgentRunState(e){return j(`/api/agent-runs/${encodeURIComponent(e)}`)},async deriveAnalyticalRepair(e,t){return j(`/api/agent-runs/${encodeURIComponent(e)}/analytical-repair`,{method:"POST",body:JSON.stringify({repair:t})})},async cancelAgentRun(e){return j(`/api/agent-runs/${encodeURIComponent(e)}/cancel`,{method:"POST"})},async listAgentThreads(e){const t=new URLSearchParams;typeof(e==null?void 0:e.limit)=="number"&&Number.isFinite(e.limit)&&t.set("limit",String(e.limit)),e!=null&&e.archived&&t.set("archived","1");const n=t.toString()?`?${t.toString()}`:"";return j(`/api/agent/threads${n}`)},async createAgentThread(e={}){return(await j("/api/agent/threads",{method:"POST",body:JSON.stringify(e)})).thread},async getAgentThread(e){return j(`/api/agent/threads/${encodeURIComponent(e)}`)},async updateAgentThread(e,t){return j(`/api/agent/threads/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})},async archiveAgentThread(e){return j(`/api/agent/threads/${encodeURIComponent(e)}/archive`,{method:"POST"})},async deleteAgentThread(e){return j(`/api/agent/threads/${encodeURIComponent(e)}`,{method:"DELETE"})},async requestCertification(e){return j("/api/agent-runs/request-certification",{method:"POST",body:JSON.stringify(e)})},async getIdentity(){return j("/api/identity")},async getProviderSettings(){try{return await j("/api/settings/providers")}catch{return{providers:[]}}},async getProviderCliStatus(){try{return await j("/api/settings/providers/cli-status")}catch{return{status:{}}}},async saveProviderSettings(e){return j("/api/settings/providers",{method:"POST",body:JSON.stringify(e)})},async startOAuth(e){return j(`/api/auth/${e}/start`,{method:"POST"})},async getOAuthStatus(e){return j(`/api/auth/${e}/status`)},async signOutOAuth(e){return j(`/api/auth/${e}/signout`,{method:"POST"})},async testProviderSettings(e,t){try{return await j("/api/settings/providers/test",{method:"POST",body:JSON.stringify({id:e,...t})})}catch(n){return{ok:!1,message:n instanceof Error?n.message:String(n)}}},async getRemoteMcpSettings(){try{return await j("/api/settings/mcp")}catch{return{settings:{path:"",entries:[],warnings:[]}}}},async saveRemoteMcpSettings(e){return j("/api/settings/mcp",{method:"POST",body:JSON.stringify({entries:e})})},async recordAgentCorrection(e){return j("/api/agent/learnings/correction",{method:"POST",body:JSON.stringify(e)})},async listAgentHints(e){const t=e?`?status=${encodeURIComponent(e)}`:"";return j(`/api/agent/hints${t}`)},async reviewAgentHint(e,t,n){return j(`/api/agent/hints/${encodeURIComponent(e)}/review`,{method:"POST",body:JSON.stringify({decision:t,...n?{note:n}:{}})})},async updateAgentHint(e,t){return j(`/api/agent/hints/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})},async transitionAgentHint(e,t){return j(`/api/agent/hints/${encodeURIComponent(e)}/lifecycle`,{method:"POST",body:JSON.stringify(t)})},async listAgentMemory(e){const t=e?`?scope=${encodeURIComponent(e)}`:"";try{return await j(`/api/agent/memory${t}`)}catch{return{memories:[]}}},async saveAgentMemory(e){return j("/api/agent/memory",{method:"POST",body:JSON.stringify(e)})},async deleteAgentMemory(e){return j(`/api/agent/memory?id=${encodeURIComponent(e)}`,{method:"DELETE"})},async ensureAgentMemoryFiles(){return j("/api/agent/memory/default-files",{method:"POST"})},async listNotebooks(){try{return await j("/api/notebooks")}catch{return[]}},async readNotebook(e){return j(`/api/notebook-content?path=${encodeURIComponent(e)}`)},async deleteNotebook(e){return j(`/api/notebooks?path=${encodeURIComponent(e)}`,{method:"DELETE"})},async createNotebook(e,t,n={}){return j("/api/notebooks",{method:"POST",body:JSON.stringify({name:e,template:t,...n})})},async createBlock(e,t){return j("/api/blocks",{method:"POST",body:JSON.stringify({name:e,...t})})},async getBlockLibrary(){try{return await j("/api/blocks/library")}catch{return{blocks:[]}}},async getApps(){try{return await j("/api/apps")}catch{return{apps:[]}}},async updateBlockStatus(e,t){return j("/api/blocks/status",{method:"POST",body:JSON.stringify({path:e,newStatus:t})})},async getBlockHistory(e){try{return await j(`/api/blocks/history?path=${encodeURIComponent(e)}`)}catch{return{entries:[]}}},async runBlockTests(e,t){return j("/api/blocks/run-tests",{method:"POST",body:JSON.stringify({source:e,path:t})})},async getBlockStudioCatalog(e={}){const t=new URLSearchParams;e.includeSemantic===!1&&t.set("includeSemantic","false");const n=t.toString();return j(`/api/block-studio/catalog${n?`?${n}`:""}`)},async getBlockStudioDbtStatus(){return j("/api/block-studio/dbt-status")},async openBlockStudio(e){return j(`/api/block-studio/open?path=${encodeURIComponent(e)}`)},async getBlockBody(e){return j(`/api/blocks/body?path=${encodeURIComponent(e)}`)},async validateBlockStudio(e,t){return j("/api/block-studio/validate",{method:"POST",body:JSON.stringify({source:e,path:t})})},async runBlockStudio(e,t,n){return j("/api/block-studio/run",{method:"POST",body:JSON.stringify({source:e,path:t,parameters:n})})},async getCertifiedBlockParameters(e){return j(`/api/blocks/parameters?name=${encodeURIComponent(e)}`)},async invokeCertifiedBlock(e,t,n){var o,i,l,a,d,c;const r=await j("/api/blocks/invoke",{method:"POST",body:JSON.stringify({blockName:e,parameters:t,question:n})});return{parameters:Array.isArray(r==null?void 0:r.parameters)?r.parameters:[],result:{...cn(r==null?void 0:r.result),...typeof((o=r==null?void 0:r.result)==null?void 0:o.sql)=="string"?{sql:r.result.sql}:{},...typeof((i=r==null?void 0:r.result)==null?void 0:i.blockName)=="string"?{blockName:r.result.blockName}:{},...typeof((l=r==null?void 0:r.result)==null?void 0:l.blockPath)=="string"?{blockPath:r.result.blockPath}:{},...(a=r==null?void 0:r.result)!=null&&a.chartConfig?{chartConfig:r.result.chartConfig}:{},...Array.isArray((d=r==null?void 0:r.result)==null?void 0:d.parameters)?{parameters:r.result.parameters}:{},...typeof((c=r==null?void 0:r.result)==null?void 0:c.auditId)=="string"?{auditId:r.result.auditId}:{}}}},async addDqlArtifactResultFilter(e,t,n,r){const o=await j("/api/dql/artifacts/add-filter",{method:"POST",body:JSON.stringify({artifact:e,resultColumns:t,column:n,value:r})}),i=Qo(o==null?void 0:o.artifact);if(!i)throw new Error("Adding the filter input returned an invalid artifact contract.");return{artifact:i,parameterName:String((o==null?void 0:o.parameterName)??n)}},async invokeDqlArtifact(e,t,n,r){var l,a,d,c,f,p;const o=await j("/api/dql/artifacts/execute",{method:"POST",body:JSON.stringify({artifact:e,parameters:t,question:n,blockName:r})}),i=Qo(o==null?void 0:o.artifact);if(!i)throw new Error("DQL artifact execution returned an invalid artifact contract.");return{artifact:i,parameters:i.parameters??[],result:{...cn(o==null?void 0:o.result),...typeof((l=o==null?void 0:o.result)==null?void 0:l.sql)=="string"?{sql:o.result.sql}:{},...typeof((a=o==null?void 0:o.result)==null?void 0:a.blockName)=="string"?{blockName:o.result.blockName}:{},...typeof((d=o==null?void 0:o.result)==null?void 0:d.blockPath)=="string"?{blockPath:o.result.blockPath}:{},...(c=o==null?void 0:o.result)!=null&&c.chartConfig?{chartConfig:o.result.chartConfig}:{},...Array.isArray((f=o==null?void 0:o.result)==null?void 0:f.parameters)?{parameters:o.result.parameters}:{},...typeof((p=o==null?void 0:o.result)==null?void 0:p.auditId)=="string"?{auditId:o.result.auditId}:{}}}},async composeSemanticBlock(e){return j("/api/block-studio/compose-semantic",{method:"POST",body:JSON.stringify({question:e})})},async saveBlockStudio(e){return j("/api/block-studio/save",{method:"POST",body:JSON.stringify(e)})},async saveAgentBlockDraft(e){return j("/api/block-studio/agent-drafts",{method:"POST",body:JSON.stringify(e)})},async deleteBlockStudio(e){return j(`/api/block-studio/block?path=${encodeURIComponent(e)}`,{method:"DELETE"})},async previewBlockStudioImport(e){return j("/api/block-studio/import/preview",{method:"POST",body:JSON.stringify(e)})},async listBlockStudioImports(){return j("/api/block-studio/imports")},async createBlockStudioImport(e){return j("/api/block-studio/imports",{method:"POST",body:JSON.stringify(e)})},async createDqlGenerationSession(e){return j("/api/block-studio/ai-imports",{method:"POST",body:JSON.stringify(e)})},async getDqlGenerationSession(e){return j(`/api/block-studio/ai-imports/${encodeURIComponent(e)}`)},async getBlockStudioImport(e){return j(`/api/block-studio/imports/${encodeURIComponent(e)}`)},async deleteBlockStudioImport(e){return j(`/api/block-studio/imports/${encodeURIComponent(e)}`,{method:"DELETE"})},async clearBlockStudioImports(){return j("/api/block-studio/imports",{method:"DELETE"})},async updateBlockStudioImportCandidate(e,t,n){return j(`/api/block-studio/imports/${encodeURIComponent(e)}/candidates/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)})},async updateDqlGenerationCandidate(e,t,n){return j(`/api/block-studio/ai-imports/${encodeURIComponent(e)}/candidates/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)})},async matchSqlForBlockReuse(e,t){return j("/api/block-studio/match-sql",{method:"POST",body:JSON.stringify({sql:e,...t??{}})})},async previewDqlGenerationCandidate(e,t){return j(`/api/block-studio/ai-imports/${encodeURIComponent(e)}/candidates/${encodeURIComponent(t)}/preview`,{method:"POST"})},async certifyDqlGenerationCandidate(e,t){return j(`/api/block-studio/ai-imports/${encodeURIComponent(e)}/candidates/${encodeURIComponent(t)}/certify`,{method:"POST"})},async saveSelectedDqlGenerationCandidates(e,t){return j(`/api/block-studio/ai-imports/${encodeURIComponent(e)}/save-selected`,{method:"POST",body:JSON.stringify(t)})},async runBlockStudioImportCandidate(e,t){return j(`/api/block-studio/imports/${encodeURIComponent(e)}/candidates/${encodeURIComponent(t)}/run`,{method:"POST"})},async saveBlockStudioImportCandidate(e,t){return j(`/api/block-studio/imports/${encodeURIComponent(e)}/candidates/${encodeURIComponent(t)}/save`,{method:"POST"})},async saveAllBlockStudioImportCandidates(e){return j(`/api/block-studio/imports/${encodeURIComponent(e)}/save-all`,{method:"POST"})},async assistBlockStudioImportCandidate(e,t,n){return j(`/api/block-studio/imports/${encodeURIComponent(e)}/candidates/${encodeURIComponent(t)}/ai-assist`,{method:"POST",body:JSON.stringify({action:n})})},async getSemanticLayerDiagnostics(){return j("/api/semantic-layer/diagnostics")},async reloadSemanticLayer(){return j("/api/semantic-layer/reload",{method:"POST"})},async certifyBlockStudio(e){const t=await fetch(`${On}/api/block-studio/certify`,{headers:$n({"Content-Type":"application/json"}),method:"POST",body:JSON.stringify(e)}),n=await t.json().catch(()=>({ok:!1,error:t.statusText}));if(!t.ok&&t.status!==422)throw new Error(JSON.stringify(n));return n},async saveAsBlock(e){return j("/api/blocks/save-from-cell",{method:"POST",body:JSON.stringify(e)})},async getBlockTemplates(){try{return(await j("/api/blocks/templates")).templates}catch{return[]}},async listBlocks(e){try{return(await j("/api/notebooks")).filter(n=>n.type==="block"&&(!e||n.path.startsWith(`blocks/${e}/`)))}catch{return[]}},async saveNotebook(e,t){return j("/api/notebook-content",{method:"PUT",body:JSON.stringify({path:e,content:t})})},async executeQuery(e,t,n,r){var i,l,a;const o=await j("/api/query",{method:"POST",body:JSON.stringify({sql:e,executionContext:n,executionTarget:r}),signal:t});if(n!=null&&n.runId&&typeof((i=o==null?void 0:o.executionContext)==null?void 0:i.runId)=="string"&&o.executionContext.runId!==n.runId)throw new vt({message:"The notebook server returned a result for a different cell run. The stale result was rejected.",status:409,code:"STALE_CELL_EXECUTION",details:{expected:n,received:o.executionContext}});return{...cn(o),executionTarget:((l=o==null?void 0:o.executionTarget)==null?void 0:l.target)==="local"?{target:"local"}:((a=o==null?void 0:o.executionTarget)==null?void 0:a.target)==="connection"?{target:"connection",...typeof o.executionTarget.connectionName=="string"?{connectionName:o.executionTarget.connectionName}:{}}:void 0,compiledSql:typeof(o==null?void 0:o.compiledSql)=="string"?o.compiledSql:void 0,executedSql:typeof(o==null?void 0:o.executedSql)=="string"?o.executedSql:void 0,targetBinding:o!=null&&o.targetBinding&&typeof o.targetBinding=="object"?o.targetBinding:void 0,executionReceipt:o!=null&&o.executionReceipt&&typeof o.executionReceipt=="object"?o.executionReceipt:void 0}},async previewGeneratedSql(e,t){try{const n=await j("/api/ai/sql-draft/preview",{method:"POST",body:JSON.stringify({sql:e}),signal:t});return{ok:!0,result:cn(n.result)}}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async executeNotebookCell(e,t,n){var o,i,l,a,d,c;const r=await j("/api/notebook/execute",{method:"POST",body:JSON.stringify({cell:{id:e.id,type:e.type,source:e.content,title:e.name,config:e.chartConfig},executionTarget:e.executionTarget,parameters:((o=e.blockBinding)==null?void 0:o.state)==="bound"?e.blockBinding.parameterValues:e.dqlParameterValues,executionContext:n}),signal:t});if(n!=null&&n.runId&&typeof((i=r==null?void 0:r.executionContext)==null?void 0:i.runId)=="string"&&r.executionContext.runId!==n.runId)throw new vt({message:"The notebook server returned a result for a different semantic cell run. The stale result was rejected.",status:409,code:"STALE_CELL_EXECUTION",details:{expected:n,received:r.executionContext}});return{cellType:String((r==null?void 0:r.cellType)??e.type),cellId:typeof((l=r==null?void 0:r.executionContext)==null?void 0:l.cellId)=="string"?r.executionContext.cellId:void 0,runId:typeof((a=r==null?void 0:r.executionContext)==null?void 0:a.runId)=="string"?r.executionContext.runId:void 0,title:typeof(r==null?void 0:r.title)=="string"?r.title:void 0,blockName:typeof(r==null?void 0:r.blockName)=="string"?r.blockName:void 0,blockPath:typeof(r==null?void 0:r.blockPath)=="string"?r.blockPath:void 0,chartConfig:r!=null&&r.chartConfig&&typeof r.chartConfig=="object"?r.chartConfig:void 0,tests:Array.isArray(r==null?void 0:r.tests)?r.tests:void 0,result:r!=null&&r.result?cn(r.result):null,executionTarget:((d=r==null?void 0:r.executionTarget)==null?void 0:d.target)==="local"?{target:"local"}:((c=r==null?void 0:r.executionTarget)==null?void 0:c.target)==="connection"?{target:"connection",...typeof r.executionTarget.connectionName=="string"?{connectionName:r.executionTarget.connectionName}:{}}:void 0,engine:(r==null?void 0:r.engine)==="native"||(r==null?void 0:r.engine)==="metricflow-cli"||(r==null?void 0:r.engine)==="dbt-cloud"?r.engine:void 0,semanticTrace:r!=null&&r.semanticTrace&&typeof r.semanticTrace=="object"?r.semanticTrace:void 0,compiledSql:typeof(r==null?void 0:r.compiledSql)=="string"?r.compiledSql:void 0,executedSql:typeof(r==null?void 0:r.executedSql)=="string"?r.executedSql:void 0,targetBinding:r!=null&&r.targetBinding&&typeof r.targetBinding=="object"?r.targetBinding:void 0,executionReceipt:r!=null&&r.executionReceipt&&typeof r.executionReceipt=="object"?r.executionReceipt:void 0}},async getDatasets(){return j("/api/datasets")},async importDataset(e){if(e.file){const t=new FormData;t.set("file",e.file,e.file.name);for(const[r,o]of Object.entries(e))r==="file"||o===void 0||t.set(r,Array.isArray(o)?o.join(","):String(o));const n=await fetch(`${On}/api/datasets/import`,{method:"POST",headers:$n(),body:t});if(!n.ok){const r=await n.text().catch(()=>"");throw Xo(n,r)}return n.json()}return j("/api/datasets/import",{method:"POST",body:JSON.stringify(e)})},async refreshDataset(e){return j(`/api/datasets/${encodeURIComponent(e)}/refresh`,{method:"POST"})},async updateDatasetSchema(e,t){return j(`/api/datasets/${encodeURIComponent(e)}/schema`,{method:"POST",body:JSON.stringify({overrides:t})})},async renameDataset(e,t,n){return j(`/api/datasets/${encodeURIComponent(e)}/rename`,{method:"POST",body:JSON.stringify({name:t,alias:n})})},async pinDataset(e,t=!0){return j(`/api/datasets/${encodeURIComponent(e)}/pin`,{method:"POST",body:JSON.stringify({pinned:t})})},async removeDataset(e){await j(`/api/datasets/${encodeURIComponent(e)}`,{method:"DELETE"})},async stageDataset(e){return j("/api/datasets/stage",{method:"POST",body:JSON.stringify(e)})},async listNotebookResearch(e){var o,i,l,a,d,c,f,p,h,g,S,x,b,k,C,E,v,w,A,R;const t=new URLSearchParams;typeof e=="string"?e&&t.set("path",e):e&&(e.path&&t.set("path",e.path),e.sourceCellId&&t.set("sourceCellId",e.sourceCellId),e.domain&&t.set("domain",e.domain),e.owner&&t.set("owner",e.owner),e.intent&&t.set("intent",e.intent),e.search&&t.set("q",e.search),e.status&&t.set("status",e.status),e.reviewStatus&&t.set("reviewStatus",e.reviewStatus),e.promotionAction&&t.set("promotionAction",e.promotionAction),e.readiness&&t.set("readiness",e.readiness),e.age&&t.set("age",e.age),e.nextAction&&t.set("nextAction",e.nextAction),e.activeOnly&&t.set("activeOnly","true"),e.sort&&t.set("sort",e.sort),typeof e.limit=="number"&&t.set("limit",String(e.limit)),typeof e.offset=="number"&&t.set("offset",String(e.offset)));const n=t.toString()?`?${t.toString()}`:"",r=await j(`/api/notebook/research${n}`);return{runs:r.runs.map(wt),total:typeof r.total=="number"?r.total:r.runs.length,domains:Array.isArray(r.domains)?r.domains.map(y=>({domain:typeof y.domain=="string"&&y.domain.trim()?y.domain:"uncategorized",total:typeof y.total=="number"?y.total:0,draftReady:typeof y.draftReady=="number"?y.draftReady:0,certificationReady:typeof y.certificationReady=="number"?y.certificationReady:0,blocked:typeof y.blocked=="number"?y.blocked:0,staleOpen:typeof y.staleOpen=="number"?y.staleOpen:0,expiredOpen:typeof y.expiredOpen=="number"?y.expiredOpen:0,nextAction:xr(y.nextAction),nextActionCount:typeof y.nextActionCount=="number"&&Number.isFinite(y.nextActionCount)?Math.max(0,Math.floor(y.nextActionCount)):void 0})):[],owners:Array.isArray(r.owners)?r.owners.map(y=>({owner:typeof y.owner=="string"&&y.owner.trim()?y.owner:"unassigned",total:typeof y.total=="number"?y.total:0,draftReady:typeof y.draftReady=="number"?y.draftReady:0,certificationReady:typeof y.certificationReady=="number"?y.certificationReady:0,blocked:typeof y.blocked=="number"?y.blocked:0,staleOpen:typeof y.staleOpen=="number"?y.staleOpen:0,expiredOpen:typeof y.expiredOpen=="number"?y.expiredOpen:0,nextAction:xr(y.nextAction),nextActionCount:typeof y.nextActionCount=="number"&&Number.isFinite(y.nextActionCount)?Math.max(0,Math.floor(y.nextActionCount)):void 0})):[],intents:Array.isArray(r.intents)?r.intents.map(y=>({intent:eb(y.intent),total:typeof y.total=="number"?y.total:0,draftReady:typeof y.draftReady=="number"?y.draftReady:0,certificationReady:typeof y.certificationReady=="number"?y.certificationReady:0,blocked:typeof y.blocked=="number"?y.blocked:0,staleOpen:typeof y.staleOpen=="number"?y.staleOpen:0,expiredOpen:typeof y.expiredOpen=="number"?y.expiredOpen:0,nextAction:xr(y.nextAction),nextActionCount:typeof y.nextActionCount=="number"&&Number.isFinite(y.nextActionCount)?Math.max(0,Math.floor(y.nextActionCount)):void 0})):[],notebooks:Array.isArray(r.notebooks)?r.notebooks.map(y=>({path:typeof y.path=="string"&&y.path.trim()?y.path:"notebooks/untitled.dqlnb",title:typeof y.title=="string"&&y.title.trim()?y.title:tb(y.path),total:typeof y.total=="number"?y.total:0,draftReady:typeof y.draftReady=="number"?y.draftReady:0,certificationReady:typeof y.certificationReady=="number"?y.certificationReady:0,blocked:typeof y.blocked=="number"?y.blocked:0,staleOpen:typeof y.staleOpen=="number"?y.staleOpen:0,expiredOpen:typeof y.expiredOpen=="number"?y.expiredOpen:0,nextAction:xr(y.nextAction),nextActionCount:typeof y.nextActionCount=="number"&&Number.isFinite(y.nextActionCount)?Math.max(0,Math.floor(y.nextActionCount)):void 0})):[],counts:{total:typeof((o=r.counts)==null?void 0:o.total)=="number"?r.counts.total:r.runs.length,ready:typeof((i=r.counts)==null?void 0:i.ready)=="number"?r.counts.ready:0,needsReview:typeof((l=r.counts)==null?void 0:l.needsReview)=="number"?r.counts.needsReview:0,dqlDrafts:typeof((a=r.counts)==null?void 0:a.dqlDrafts)=="number"?r.counts.dqlDrafts:0,errors:typeof((d=r.counts)==null?void 0:d.errors)=="number"?r.counts.errors:0,reuseExisting:typeof((c=r.counts)==null?void 0:c.reuseExisting)=="number"?r.counts.reuseExisting:0,extendExisting:typeof((f=r.counts)==null?void 0:f.extendExisting)=="number"?r.counts.extendExisting:0,replacements:typeof((p=r.counts)==null?void 0:p.replacements)=="number"?r.counts.replacements:0,createNew:typeof((h=r.counts)==null?void 0:h.createNew)=="number"?r.counts.createNew:0,draftReady:typeof((g=r.counts)==null?void 0:g.draftReady)=="number"?r.counts.draftReady:0,certificationReady:typeof((S=r.counts)==null?void 0:S.certificationReady)=="number"?r.counts.certificationReady:0,blocked:typeof((x=r.counts)==null?void 0:x.blocked)=="number"?r.counts.blocked:0,staleOpen:typeof((b=r.counts)==null?void 0:b.staleOpen)=="number"?r.counts.staleOpen:0,expiredOpen:typeof((k=r.counts)==null?void 0:k.expiredOpen)=="number"?r.counts.expiredOpen:0,sourceLinked:typeof((C=r.counts)==null?void 0:C.sourceLinked)=="number"?r.counts.sourceLinked:0,nextActions:nb((E=r.counts)==null?void 0:E.nextActions)},groupCounts:{domains:typeof((v=r.groupCounts)==null?void 0:v.domains)=="number"&&Number.isFinite(r.groupCounts.domains)?Math.max(0,Math.floor(r.groupCounts.domains)):Array.isArray(r.domains)?r.domains.length:0,owners:typeof((w=r.groupCounts)==null?void 0:w.owners)=="number"&&Number.isFinite(r.groupCounts.owners)?Math.max(0,Math.floor(r.groupCounts.owners)):Array.isArray(r.owners)?r.owners.length:0,intents:typeof((A=r.groupCounts)==null?void 0:A.intents)=="number"&&Number.isFinite(r.groupCounts.intents)?Math.max(0,Math.floor(r.groupCounts.intents)):Array.isArray(r.intents)?r.intents.length:0,notebooks:typeof((R=r.groupCounts)==null?void 0:R.notebooks)=="number"&&Number.isFinite(r.groupCounts.notebooks)?Math.max(0,Math.floor(r.groupCounts.notebooks)):Array.isArray(r.notebooks)?r.notebooks.length:0},reviewMetrics:Xx(r.reviewMetrics),limit:r.limit,offset:typeof r.offset=="number"?r.offset:0}},async getNotebookResearchDiagnostics(){const e=await j("/api/notebook/research/diagnostics");return Zx(e)},async createNotebookResearch(e){const t=await j("/api/notebook/research",{method:"POST",body:JSON.stringify(e)});return wt(t.run)},async seedNotebookResearchFromCells(e){const t=await j("/api/notebook/research/seed-cells",{method:"POST",body:JSON.stringify(e)});return{created:Array.isArray(t.created)?t.created.map(wt):[],createdCount:typeof t.createdCount=="number"?t.createdCount:Array.isArray(t.created)?t.created.length:0,skippedCount:typeof t.skippedCount=="number"?t.skippedCount:0,limitApplied:t.limitApplied===!0}},async listNotebookResearchSourceCoverage(e){const t=await j("/api/notebook/research/source-coverage",{method:"POST",body:JSON.stringify({path:e.path,sourceCellIds:e.sourceCellIds,sourceCells:e.sourceCells,limit:e.limit})});return{runs:Array.isArray(t.runs)?t.runs.map(wt):[],requestedCount:typeof t.requestedCount=="number"?t.requestedCount:e.sourceCellIds.length,matchedCount:typeof t.matchedCount=="number"?t.matchedCount:Array.isArray(t.runs)?t.runs.length:0,limitApplied:t.limitApplied===!0}},async previewNotebookResearchContext(e){const t=await j("/api/notebook/research/context-preview",{method:"POST",body:JSON.stringify(e)});return ob(t)},async getNotebookResearch(e){const t=await j(`/api/notebook/research/${encodeURIComponent(e)}`);return wt(t.run)},async updateNotebookResearch(e,t){const n=await j(`/api/notebook/research/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)});return wt(n.run)},async runNotebookResearch(e,t){const n=await j(`/api/notebook/research/${encodeURIComponent(e)}/run`,{method:"POST",body:JSON.stringify(t??{})});return wt(n.run)},async checkNotebookResearchReuse(e,t){const n=await j(`/api/notebook/research/${encodeURIComponent(e)}/reuse-check`,{method:"POST",body:JSON.stringify(t??{})});return{...n,run:wt(n.run),promotion:Uc(n.promotion)??n.promotion}},async promoteNotebookResearchToDql(e,t){const n=await j(`/api/notebook/research/${encodeURIComponent(e)}/promote-dql`,{method:"POST",body:JSON.stringify(t??{})});return{...n,run:wt(n.run)}},async getSchema(){try{const e=await fetch(`${On}/api/schema`,{headers:$n()});if(e.ok)return await e.json();const t=await e.json().catch(()=>null);return t!=null&&t.error&&console.warn(`[dql] schema introspection failed: ${t.error}`),(t==null?void 0:t.fallback)??[]}catch(e){return console.warn("[dql] getSchema request failed",e),[]}},async getConnections(){try{return await j("/api/connections")}catch{return{default:"unknown",connections:{}}}},async previewDbtProfiles(e){return j("/api/connections/dbt-profiles/preview",{method:"POST",body:JSON.stringify({path:e})})},async saveConnections(e,t){return j("/api/connections",{method:"PUT",body:JSON.stringify({connections:e,defaultConnectionName:t})})},async previewConnectionMetadataScope(e,t={}){return j(`/api/connections/${encodeURIComponent(e)}/metadata-scope/preview`,{method:"POST",body:JSON.stringify(t)})},async discoverConnectionMetadataScopes(e){return j(`/api/connections/${encodeURIComponent(e)}/metadata-scope/discovery`,{method:"POST"})},async getConnectionMetadataScope(e){return j(`/api/connections/${encodeURIComponent(e)}/metadata-scope`)},async applyConnectionMetadataScope(e,t){return j(`/api/connections/${encodeURIComponent(e)}/metadata-scope`,{method:"PUT",body:JSON.stringify(t)})},async refreshConnectionMetadata(e){return j(`/api/connections/${encodeURIComponent(e)}/metadata-sync`,{method:"POST"})},async installConnector(e){return j("/api/connectors/install",{method:"POST",body:JSON.stringify({driver:e})})},async testConnection(){try{return await j("/api/test-connection",{method:"POST",body:JSON.stringify({})})}catch(e){return{ok:!1,message:e.message??"Connection failed"}}},async getSemanticRuntimeSettings(){return j("/api/semantic-runtime")},async getMetricFlowInstallerStatus(){return j("/api/semantic-runtime/metricflow/installer")},async installMetricFlow(e){return j("/api/semantic-runtime/metricflow/install",{method:"POST",body:JSON.stringify(e?{adapter:e}:{})})},async testDbtCloudSemanticRuntime(e){try{return await j("/api/semantic-runtime/dbt-cloud/test",{method:"POST",body:JSON.stringify(e)})}catch(t){return{ok:!1,error:(t==null?void 0:t.message)??"dbt Cloud Semantic Layer test failed."}}},async applyDbtCloudSemanticRuntime(e){return j("/api/semantic-runtime/dbt-cloud/apply",{method:"POST",body:JSON.stringify(e)})},async setSemanticRuntimePreference(e){return j("/api/semantic-runtime/preference",{method:"POST",body:JSON.stringify({preference:e})})},async getSemanticLayer(){try{return await j("/api/semantic-layer")}catch{return{available:!1,provider:null,metrics:[],measures:[],dimensions:[],timeDimensions:[],entities:[],hierarchies:[],semanticModels:[],savedQueries:[],domains:[],tags:[],favorites:[],recentlyUsed:[],lastSyncTime:null}}},async getSemanticTree(){return(await j("/api/semantic-layer/tree")).tree},async getSemanticObject(e){return j(`/api/semantic-layer/object/${encodeURIComponent(e)}`)},async getSetupLaunch(){return j("/api/onboarding/launch")},async acknowledgeSetupLaunch(){return j("/api/onboarding/acknowledge",{method:"POST",body:"{}"})},async getOnboardingStatus(){return j("/api/onboarding/status")},async previewDbtOnboarding(e){return j("/api/onboarding/dbt/preview",{method:"POST",body:JSON.stringify(e)})},async applyDbtOnboarding(e){return j("/api/onboarding/dbt/apply",{method:"POST",body:JSON.stringify({...e,fingerprint:e.expectedFingerprint})})},async refreshDbtOnboarding(e={}){return j("/api/onboarding/refresh",{method:"POST",body:JSON.stringify(e)})},async getOnboardingJob(e){return j(`/api/onboarding/jobs/${encodeURIComponent(e)}`)},async cancelOnboardingJob(e){return j(`/api/onboarding/jobs/${encodeURIComponent(e)}`,{method:"DELETE"})},async discoverOnboardingDomains(e={}){return j("/api/onboarding/domains/discover",{method:"POST",body:JSON.stringify(e)})},async applyOnboardingDomains(e){return j("/api/onboarding/domains/apply",{method:"POST",body:JSON.stringify(e)})},async importSemanticLayer(e){return j("/api/semantic-layer/import",{method:"POST",body:JSON.stringify(e)})},async syncSemanticLayer(){return j("/api/semantic-layer/sync",{method:"POST",body:JSON.stringify({})})},async previewSemanticImport(e){return j("/api/semantic-layer/import-preview",{method:"POST",body:JSON.stringify(e)})},async previewSyncDiff(){return j("/api/semantic-layer/sync-preview",{method:"POST",body:JSON.stringify({})})},async searchSemanticLayer(e){const t=new URLSearchParams;e.query&&t.set("q",e.query),e.domain&&t.set("domain",e.domain),e.tag&&t.set("tag",e.tag),e.type&&t.set("type",e.type);try{return await j(`/api/semantic-layer/search?${t.toString()}`)}catch{return{metrics:[],measures:[],dimensions:[],timeDimensions:[],entities:[],hierarchies:[],semanticModels:[],savedQueries:[]}}},async getFavorites(){try{return(await j("/api/user-prefs/favorites")).favorites}catch{return[]}},async toggleFavorite(e){return(await j("/api/user-prefs/favorites",{method:"POST",body:JSON.stringify({name:e})})).favorites},async getRecentlyUsed(){try{return(await j("/api/user-prefs/recent")).recentlyUsed}catch{return[]}},async trackUsage(e){try{return(await j("/api/user-prefs/recent",{method:"POST",body:JSON.stringify({name:e})})).recentlyUsed}catch{return[]}},async getCompatibleDimensions(e){const t=new URLSearchParams;e.length>0&&t.set("metrics",e.join(","));try{return(await j(`/api/semantic-layer/compatible-dims?${t.toString()}`)).dimensions}catch{return[]}},async getCompatibility(e){const t=new URLSearchParams;e.length>0&&t.set("metrics",e.join(","));const n=await j(`/api/semantic-layer/compatible-dims?${t.toString()}`);return{dimensions:n.dimensions??[],engine:n.engine??"native",incompatible:n.incompatible??[],degraded:n.degraded??null}},async composeQuery(e,t,n){try{return await j("/api/semantic-query",{method:"POST",body:JSON.stringify({metrics:e,dimensions:t,timeDimension:n})})}catch(r){return{error:r.message??"Failed to compose query"}}},async previewSemanticBuilder(e){try{return await j("/api/semantic-builder/preview",{method:"POST",body:JSON.stringify(e)})}catch(t){return t instanceof vt?{error:t.message,code:t.code,details:t.details}:{error:t instanceof Error?t.message:"Failed to preview semantic block"}}},async saveSemanticBuilder(e){return j("/api/semantic-builder/save",{method:"POST",body:JSON.stringify(e)})},async createMetric(e){try{return await j("/api/semantic-layer/metric",{method:"POST",body:JSON.stringify(e)})}catch(t){return{ok:!1,error:t.message??"Failed to create metric"}}},async describeTable(e){const t=e.split("."),n=t.length>1?t[t.length-1]:e,r=t.length>1?t.slice(0,-1).join("."):"",o=new URLSearchParams({table:n});r&&o.set("schema",r);try{return await j(`/api/describe-table?${o.toString()}`)}catch{return[]}},async fetchLineage(){try{return await j("/api/lineage")}catch{return{nodes:[],edges:[]}}},async searchLineage(e){try{return await j(`/api/lineage/search?q=${encodeURIComponent(e)}`)}catch{return{matches:[]}}},async queryLineage(e){var n;const t=new URLSearchParams;e.focus&&t.set("focus",e.focus),e.search&&t.set("search",e.search),(n=e.types)!=null&&n.length&&t.set("types",e.types.join(",")),e.domain&&t.set("domain",e.domain),e.upstreamDepth!==void 0&&t.set("upstreamDepth",String(e.upstreamDepth)),e.downstreamDepth!==void 0&&t.set("downstreamDepth",String(e.downstreamDepth));try{return await j(`/api/lineage/query?${t.toString()}`)}catch{return{graph:{nodes:[],edges:[]},matches:[]}}},async fetchLineageNode(e){try{return await j(`/api/lineage/node/${encodeURIComponent(e)}`)}catch{return null}},async fetchBusiness360(e){try{return await j(`/api/lineage/business-360/${encodeURIComponent(e)}`)}catch{return null}},async fetchBlockLineage(e){try{return await j(`/api/lineage/block/${encodeURIComponent(e)}`)}catch{return null}},async fetchImpactAnalysis(e){try{return await j(`/api/lineage/impact/${encodeURIComponent(e)}`)}catch{return null}},async fetchLineagePaths(e,t){try{const n=new URLSearchParams;t!=null&&t.maxDepth&&n.set("maxDepth",String(t.maxDepth)),t!=null&&t.maxPaths&&n.set("maxPaths",String(t.maxPaths));const r=n.toString(),o=`/api/lineage/paths/${encodeURIComponent(e)}${r?`?${r}`:""}`;return await j(o)}catch{return null}},async fetchGitStatus(){try{return await j("/api/git/status")}catch{return{inRepo:!1,branch:null,ahead:0,behind:0,changes:[]}}},async fetchGitLog(e=20){try{return await j(`/api/git/log?limit=${e}`)}catch{return{inRepo:!1,commits:[]}}},async fetchRunSnapshot(e){try{return await j(`/api/run-snapshot?path=${encodeURIComponent(e)}`)}catch{return{found:!1,snapshot:null}}},async saveRunSnapshot(e,t){await j("/api/run-snapshot",{method:"PUT",body:JSON.stringify({path:e,snapshot:t})})},async fetchGitDiff(e,t){try{const n=new URLSearchParams;e&&n.set("path",e),t&&n.set("staged","true");const r=n.toString();return await j(`/api/git/diff${r?`?${r}`:""}`)}catch{return{inRepo:!1,diff:"",before:null,after:null,diffReport:null}}},async fetchGitBranches(){try{return await j("/api/git/branches")}catch{return{inRepo:!1,current:null,branches:[]}}},async fetchGitRemote(){try{return await j("/api/git/remote")}catch{return{inRepo:!1,url:null,name:null}}},async fetchGitGovernedContext(){try{return await j("/api/git/governed-context")}catch{return{inRepo:!1,trackingReady:!1,legacyBroadIgnore:!1,domains:yr(),skills:yr(),artifacts:yr(),learning:yr()}}},async enableGitGovernedContextTracking(){try{return await j("/api/git/governed-context/enable",{method:"POST",body:"{}"})}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}},async gitStage(e){try{return await j("/api/git/stage",{method:"POST",body:JSON.stringify({paths:e})})}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}},async gitUnstage(e){try{return await j("/api/git/unstage",{method:"POST",body:JSON.stringify({paths:e})})}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}},async gitDiscard(e){try{return await j("/api/git/discard",{method:"POST",body:JSON.stringify({paths:e})})}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}},async gitCommit(e,t=!1){try{return await j("/api/git/commit",{method:"POST",body:JSON.stringify({message:e,stageAll:t})})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async gitPush(){try{return await j("/api/git/push",{method:"POST",body:"{}"})}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}},async gitPull(){try{return await j("/api/git/pull",{method:"POST",body:"{}"})}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}},async gitCreateBranch(e,t=!0){try{return await j("/api/git/branch",{method:"POST",body:JSON.stringify({name:e,checkout:t})})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async gitCreateReview(e){try{return await j("/api/git/review",{method:"POST",body:JSON.stringify(e)})}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}},async gitOpenReview(e){try{return await j("/api/git/review/open",{method:"POST",body:JSON.stringify(e)})}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}},async gitCheckout(e){try{return await j("/api/git/checkout",{method:"POST",body:JSON.stringify({name:e})})}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}},async listApps(){try{const{apps:e}=await j("/api/apps");return e}catch{return[]}},async listAppsStrict(){const{apps:e}=await j("/api/apps");return e},async recommendAppBlocks(e){try{const{blocks:t}=await j("/api/apps/recommend-blocks",{method:"POST",body:JSON.stringify(e)});return t}catch{return[]}},async createApp(e){return j("/api/apps",{method:"POST",body:JSON.stringify(e)})},async generateApp(e){try{return await j("/api/apps/generate",{method:"POST",body:JSON.stringify(e)})}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}},async createAppAiBuild(e){try{return await j("/api/apps/ai-builds",{method:"POST",body:JSON.stringify(e)})}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}},async getAppAiBuild(e){try{const{session:t}=await j(`/api/apps/ai-builds/${encodeURIComponent(e)}`);return t}catch{return null}},async proposeAppAiBuild(e){try{return await j("/api/apps/ai-builds/propose",{method:"POST",body:JSON.stringify(e)})}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}},async commitAppAiBuild(e,t={}){try{return await j(`/api/apps/ai-builds/${encodeURIComponent(e)}/commit`,{method:"POST",body:JSON.stringify(t)})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async getApp(e){try{return await j(`/api/apps/${encodeURIComponent(e)}`)}catch{return null}},async attachAppNotebook(e,t){try{return await j(`/api/apps/${encodeURIComponent(e)}/notebooks`,{method:"POST",body:JSON.stringify(t)})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async listAppNotebookCandidates(e){try{const{notebooks:t}=await j(`/api/apps/${encodeURIComponent(e)}/notebook-candidates`);return t}catch{return[]}},async createAppNotebook(e,t){try{return await j(`/api/apps/${encodeURIComponent(e)}/notebooks/create`,{method:"POST",body:JSON.stringify(t)})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async previewAppNotebook(e,t){try{return await j(`/api/apps/${encodeURIComponent(e)}/notebooks/preview?path=${encodeURIComponent(t)}`)}catch{return null}},async runAppNotebook(e,t){try{return await j(`/api/apps/${encodeURIComponent(e)}/notebooks/run`,{method:"POST",body:JSON.stringify({path:t})})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async listAppConversations(e){try{const{conversations:t}=await j(`/api/apps/${encodeURIComponent(e)}/conversations`);return t}catch{return[]}},async createAppConversation(e,t){try{return await j(`/api/apps/${encodeURIComponent(e)}/conversations`,{method:"POST",body:JSON.stringify(t)})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async getAppConversation(e,t){try{const{conversation:n}=await j(`/api/apps/${encodeURIComponent(e)}/conversations/${encodeURIComponent(t)}`);return n}catch{return null}},async updateAppConversation(e,t,n){try{return await j(`/api/apps/${encodeURIComponent(e)}/conversations/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)})}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}},async deleteAppConversation(e,t){try{return await j(`/api/apps/${encodeURIComponent(e)}/conversations/${encodeURIComponent(t)}`,{method:"DELETE"})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async listAppInvestigations(e,t){try{const n=new URLSearchParams;t&&n.set("dashboardId",t);const r=n.toString(),{investigations:o}=await j(`/api/apps/${encodeURIComponent(e)}/investigations${r?`?${r}`:""}`);return o}catch{return[]}},async createAppInvestigation(e,t){try{return await j(`/api/apps/${encodeURIComponent(e)}/investigations`,{method:"POST",body:JSON.stringify(t)})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async getAppInvestigation(e,t){try{const{investigation:n}=await j(`/api/apps/${encodeURIComponent(e)}/investigations/${encodeURIComponent(t)}`);return n}catch{return null}},async runAppInvestigation(e,t,n){try{return await j(`/api/apps/${encodeURIComponent(e)}/investigations/${encodeURIComponent(t)}/run`,{method:"POST",body:JSON.stringify(n??{})})}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}},async pinAppInvestigation(e,t,n){try{return await j(`/api/apps/${encodeURIComponent(e)}/investigations/${encodeURIComponent(t)}/pin`,{method:"POST",body:JSON.stringify(n??{})})}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}},async getDashboard(e,t){try{return await j(`/api/apps/${encodeURIComponent(e)}/dashboards/${encodeURIComponent(t)}`)}catch{return null}},async dashboardFilterOptions(e,t){try{const n=new URLSearchParams({block:e,column:t});return await j(`/api/dashboard/filter-options?${n.toString()}`)}catch{return null}},async getAppEditorCatalog(e,t){try{const n=new URLSearchParams;t!=null&&t.domain&&n.set("domain",t.domain),(t==null?void 0:t.certifiedOnly)===!1&&n.set("certifiedOnly","false");const r=n.toString();return await j(`/api/apps/${encodeURIComponent(e)}/editor/catalog${r?`?${r}`:""}`)}catch{return null}},async createAppDashboard(e,t){try{return await j(`/api/apps/${encodeURIComponent(e)}/dashboards`,{method:"POST",body:JSON.stringify(t)})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async patchDashboardLayout(e,t,n){try{return await j(`/api/apps/${encodeURIComponent(e)}/dashboards/${encodeURIComponent(t)}/layout`,{method:"PATCH",body:JSON.stringify({layout:n})})}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}},async askApp(e,t){try{return await j(`/api/apps/${encodeURIComponent(e)}/ask`,{method:"POST",body:JSON.stringify(t)})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async promoteApp(e,t){try{return await j(`/api/apps/${encodeURIComponent(e)}/promote`,{method:"POST",body:JSON.stringify(t??{})})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async recommendVisualization(e){try{return await j("/api/visualizations/recommend",{method:"POST",body:JSON.stringify(e)})}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}},async recommendDashboardTile(e,t,n){try{return await j(`/api/apps/${encodeURIComponent(e)}/dashboards/${encodeURIComponent(t)}/tiles/recommend`,{method:"POST",body:JSON.stringify(n)})}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}},async createAiPin(e,t){try{return await j(`/api/apps/${encodeURIComponent(e)}/ai-pins`,{method:"POST",body:JSON.stringify(t)})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async listAiPins(e,t){try{const n=new URLSearchParams;t&&n.set("dashboardId",t);const r=n.toString(),{pins:o}=await j(`/api/apps/${encodeURIComponent(e)}/ai-pins${r?`?${r}`:""}`);return o}catch{return[]}},async refreshAiPin(e,t){try{return await j(`/api/apps/${encodeURIComponent(e)}/ai-pins/${encodeURIComponent(t)}/refresh`,{method:"POST"})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async promoteAiPin(e,t){try{return await j(`/api/apps/${encodeURIComponent(e)}/ai-pins/${encodeURIComponent(t)}/promote`,{method:"POST"})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async fetchScopedLineage(e){try{const t=new URLSearchParams;return e.domain&&t.set("domain",e.domain),e.appId&&t.set("appId",e.appId),e.dashboardId&&t.set("dashboardId",e.dashboardId),e.blockId&&t.set("blockId",e.blockId),await j(`/api/lineage/scope?${t.toString()}`)}catch{return null}},async runDashboard(e,t,n){try{return await j(`/api/apps/${encodeURIComponent(e)}/dashboards/${encodeURIComponent(t)}/run`,{method:"POST",body:JSON.stringify({variables:n??{}})})}catch{return null}},async getDashboardStory(e,t,n){try{return await j(`/api/apps/${encodeURIComponent(e)}/dashboards/${encodeURIComponent(t)}/story`,{method:"POST",body:JSON.stringify({runId:n})})}catch{return null}},async saveDashboard(e,t,n){try{return{ok:!!(await j(`/api/apps/${encodeURIComponent(e)}/dashboards/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify(n)})).ok}}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}},async getPersona(){try{const{persona:e}=await j("/api/persona");return e}catch{return null}},async setPersona(e,t){try{const{persona:n}=await j("/api/persona",{method:"POST",body:JSON.stringify({userId:e,appId:t})});return n}catch{return null}},async clearPersona(){try{await j("/api/persona",{method:"DELETE"})}catch{}},async getSkills(){return j("/api/skills")},async getSkillPathSettings(){return j("/api/skills/settings")},async updateSkillPath(e){return j("/api/skills/settings",{method:"PUT",body:JSON.stringify({path:e})})},async getSkillOptions(e=""){const t=e.trim()?`?q=${encodeURIComponent(e.trim())}`:"";return j(`/api/skills/options${t}`)},async createSkill(e){return j("/api/skills",{method:"POST",body:JSON.stringify({skill:e})})},async updateSkill(e,t){return j(`/api/skills/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify({skill:t})})},async getEmbeddingSettings(){return j("/api/settings/embeddings")},async saveEmbeddingSettings(e){return j("/api/settings/embeddings",{method:"PUT",body:JSON.stringify(e)})},async listEmbeddingModels(e){const t=e?`?endpoint=${encodeURIComponent(e)}`:"";return j(`/api/settings/embeddings/models${t}`)},async installEmbeddingModel(e,t){return j("/api/settings/embeddings/install",{method:"POST",body:JSON.stringify({model:e,endpoint:t})})},async testEmbeddingProvider(){return j("/api/settings/embeddings/test",{method:"POST"})},async reindexEmbeddings(){return j("/api/settings/embeddings/reindex",{method:"POST"})},async deleteSkill(e){return j(`/api/skills/${encodeURIComponent(e)}`,{method:"DELETE"})},async getDomains(){try{return await j("/api/domains")}catch{return{domains:[]}}},async createDomain(e){return j("/api/domains",{method:"POST",body:JSON.stringify({domain:e})})},async updateDomain(e,t){return j(`/api/domains/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify({domain:t})})},async deleteDomain(e){return j(`/api/domains/${encodeURIComponent(e)}`,{method:"DELETE"})},async startContextBootstrap(e={}){return j("/api/context-bootstrap",{method:"POST",body:JSON.stringify(e)})},async getContextBootstrap(e){return j(`/api/context-bootstrap/${encodeURIComponent(e)}`)},async getLatestContextBootstrap(){return(await j("/api/context-bootstrap/latest")).session??null},async saveContextBootstrapSelected(e,t){return j(`/api/context-bootstrap/${encodeURIComponent(e)}/save-selected`,{method:"POST",body:JSON.stringify({candidateIds:t})})}},ib={source_table:"#8a8d96",dbt_model:"#4a74c9",dbt_source:"#4a74c9",term:"#0a6b5e",block:"#b26b1f",business_view:"#c14545",metric:"#6b5dd3",dimension:"#0a6b5e",domain:"#7c5cff",chart:"#c14590",notebook:"#2e8b57",dashboard:"#2e8b57",app:"#2e8b57"},ab={source_table:"TBL",dbt_model:"DBT",dbt_source:"SRC",term:"TERM",block:"BLK",business_view:"VIEW",metric:"MET",dimension:"DIM",domain:"DOM",chart:"CHT",notebook:"NB",dashboard:"DASH",app:"APP"},Wc={source_table:"Source Table",dbt_model:"dbt Model",dbt_source:"dbt Source",term:"Business Term",block:"DQL Block",business_view:"Business View",metric:"Metric",dimension:"Dimension",domain:"Domain",chart:"Chart",notebook:"Notebook",dashboard:"Dashboard",app:"App"},L1={reads_from:"#8b949e",feeds_into:"#56d364",defines:"#39c5cf",composes:"#f2cc60",aggregates:"#388bfd",visualizes:"#f778ba",depends_on:"#ff7b72",contains:"#d2a8ff",crosses_domain:"#d2a8ff",certified_by:"#56d364"},N1={reads_from:"reads from",feeds_into:"feeds into",defines:"defines",composes:"composes into",aggregates:"aggregates into",visualizes:"visualizes",depends_on:"dbt depends on",contains:"contains",crosses_domain:"crosses domain",certified_by:"certified by"},lb={source:"#79c0ff",transform:"#ff7b72",answer:"#56d364",consumption:"#d2a8ff"},Ui={source:"Sources",transform:"Transform",answer:"Answer",consumption:"Consumption"},Wi=["source","transform","answer","consumption"],B1=["term","business_view","block","metric","dimension","domain","source_table","dbt_source","dbt_model","chart","notebook","dashboard","app"],F1=["source_table","dbt_source","dbt_model"],cb=["term","domain","business_view","metric","dimension","block"];[...cb];function db(e){if(e.layer)return e.layer;switch(e.type){case"source_table":case"dbt_source":return"source";case"dbt_model":return"transform";case"term":case"block":case"business_view":case"metric":case"dimension":case"domain":return"answer";case"chart":case"notebook":case"dashboard":case"app":return"consumption";default:return"answer"}}function ub(){const{state:e,dispatch:t}=ve(),n=e.inspectorContext;return s.jsxs("aside",{"aria-label":"Inspector",style:{width:320,borderLeft:`1px solid ${le("borderSubtle")}`,background:le("surfaceBase"),color:le("textPrimary"),display:"flex",flexDirection:"column",overflow:"hidden",flexShrink:0},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:`${he[3]}px ${he[4]}px`,borderBottom:`1px solid ${le("borderSubtle")}`},children:[s.jsx("div",{style:{fontSize:Fe.sm,fontWeight:ts.semibold},children:n?pb(n):"Inspector"}),s.jsx("button",{onClick:()=>t({type:"SET_INSPECTOR",open:!1}),"aria-label":"Close inspector",style:{background:"transparent",border:"none",color:le("textMuted"),cursor:"pointer",fontSize:Fe.md,padding:2,borderRadius:Lt.sm},children:"×"})]}),s.jsx("div",{style:{flex:1,overflow:"auto",padding:he[4]},children:n?s.jsx(fb,{context:n}):s.jsx(yb,{})})]})}function pb(e){switch(e.kind){case"cell":return"Cell";case"lineage-node":return"Lineage node";case"metric":return"Metric"}}function fb({context:e}){return e.kind==="cell"?s.jsx(hb,{cellId:e.cellId}):e.kind==="lineage-node"?s.jsx(mb,{nodeId:e.nodeId}):s.jsx(gb,{name:e.name})}function hb({cellId:e}){const{state:t}=ve(),n=t.cells.find(r=>r.id===e);return n?s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:he[3],fontSize:Fe.sm},children:[s.jsx(Ae,{label:"Type",children:n.type}),s.jsx(Ae,{label:"ID",children:s.jsx("code",{style:{fontFamily:"var(--dql-font-mono, monospace)"},children:n.id})}),s.jsxs(Ae,{label:"Length",children:[n.content.length," chars"]}),n.status&&s.jsx(Ae,{label:"Status",children:n.status})]}):s.jsx(Lr,{children:"No matching cell in the active notebook."})}function mb({nodeId:e}){const[t,n]=u.useState(null),[r,o]=u.useState(!0);if(u.useEffect(()=>{let a=!1;return o(!0),N.fetchLineageNode(e).then(d=>{a||(n(d),o(!1))}).catch(()=>{a||o(!1)}),()=>{a=!0}},[e]),r)return s.jsx(Lr,{children:"Loading node…"});if(!t||!t.node)return s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:he[3]},children:[s.jsx(Ae,{label:"Node ID",children:s.jsx("code",{style:{fontFamily:"var(--dql-font-mono, monospace)"},children:e})}),s.jsx(Lr,{children:"No metadata available for this node."})]});const i=t.node,l=i.metadata??{};return s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:he[3]},children:[s.jsx(Ae,{label:"Name",children:i.name??e}),s.jsx(Ae,{label:"Type",children:Wc[i.type]??i.type}),i.domain&&s.jsx(Ae,{label:"Domain",children:i.domain}),i.owner&&s.jsx(Ae,{label:"Owner",children:i.owner}),i.status&&s.jsx(Ae,{label:"Status",children:i.status}),typeof l.termType=="string"&&s.jsx(Ae,{label:"Term Type",children:l.termType}),typeof l.description=="string"&&s.jsx(Ae,{label:"Description",children:l.description}),Array.isArray(l.identifiers)&&l.identifiers.length>0&&s.jsx(Ae,{label:"Identifiers",children:l.identifiers.map(String).join(", ")}),Array.isArray(l.synonyms)&&l.synonyms.length>0&&s.jsx(Ae,{label:"Synonyms",children:l.synonyms.map(String).join(", ")}),typeof l.businessOutcome=="string"&&s.jsx(Ae,{label:"Business Outcome",children:l.businessOutcome}),i.layer&&s.jsx(Ae,{label:"Layer",children:i.layer}),s.jsx(Ae,{label:"Upstream",children:t.incoming.length}),s.jsx(Ae,{label:"Downstream",children:t.outgoing.length}),(i.path||l.filePath)&&s.jsx(Ae,{label:"Path",children:s.jsx("code",{style:{fontFamily:"var(--dql-font-mono, monospace)",fontSize:Fe.xs},children:i.path??l.filePath})})]})}function gb({name:e}){return s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:he[3]},children:[s.jsx(Ae,{label:"Metric",children:e}),s.jsx(Lr,{children:"Definition, dimensions, and governance surface will render here."})]})}function Ae({label:e,children:t}){return s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[s.jsx("div",{style:{fontSize:Fe.xs,color:le("textMuted"),textTransform:"uppercase",letterSpacing:.5,fontWeight:ts.medium},children:e}),s.jsx("div",{style:{fontSize:Fe.sm,color:le("textPrimary")},children:t})]})}function Lr({children:e}){return s.jsx("div",{style:{fontSize:Fe.sm,color:le("textSecondary"),lineHeight:1.5,background:le("surfaceSunken"),border:`1px solid ${le("borderSubtle")}`,borderRadius:Lt.md,padding:he[3]},children:e})}function yb(){return s.jsx("div",{style:{fontSize:Fe.sm,color:le("textMuted"),lineHeight:1.5},children:"Select a cell, lineage node, or metric to inspect its details here."})}const Pn={appBg:"--color-bg-primary",sidebarBg:"--color-bg-secondary",activityBarBg:"--color-bg-sunken",headerBg:"--color-bg-toolbar",headerBorder:"--color-border-primary",cellBg:"--color-bg-card",cellBorder:"--color-border-subtle",cellBorderActive:"--color-accent-blue",cellBorderRunning:"--color-status-success",textPrimary:"--color-text-primary",textSecondary:"--color-text-secondary",textMuted:"--color-text-tertiary",editorBg:"--color-bg-surface",editorBorder:"--color-border-subtle",tableBorder:"--color-border-subtle",tableHeaderBg:"--color-bg-secondary",tableRowHover:"--color-bg-hover",accent:"--color-accent-blue",accentHover:"--color-accent-blue",success:"--color-status-success",error:"--color-status-error",warning:"--color-status-warning",btnBg:"--color-bg-tertiary",btnBorder:"--color-border-primary",btnHover:"--color-bg-hover",sidebarItemHover:"--color-bg-hover",sidebarItemActive:"--color-bg-active",scrollbarThumb:"--color-border-secondary",modalBg:"--color-bg-secondary",modalOverlay:"--color-bg-overlay",inputBg:"--color-bg-sunken",inputBorder:"--color-border-subtle",pillBg:"--color-bg-tertiary",font:"--font-ui",fontMono:"--font-mono",fontSerif:"--font-ui"},Ki={appBg:"#fbfaf7",sidebarBg:"#fbfaf7",activityBarBg:"#ffffff",headerBg:"#ffffff",headerBorder:"#e9e6e0",cellBg:"#ffffff",cellBorder:"#e9e6e0",cellBorderActive:"#6b5dd3",cellBorderRunning:"#2e8b57",textPrimary:"#1a1a1a",textSecondary:"#4a4a52",textMuted:"#8a8d96",editorBg:"#fbfaf7",editorBorder:"#e9e6e0",tableBorder:"#f0eee9",tableHeaderBg:"#faf9f7",tableRowHover:"#f3f0ea",accent:"#6b5dd3",accentHover:"#5c4fc2",success:"#2e8b57",error:"#c14545",warning:"#b26b1f",btnBg:"#ffffff",btnBorder:"#e9e6e0",btnHover:"#f3f0ea",sidebarItemHover:"#f3f0ea",sidebarItemActive:"#f3f0fb",scrollbarThumb:"#d9d5cc",modalBg:"#ffffff",modalOverlay:"rgba(26,26,26,0.40)",inputBg:"#fbfaf7",inputBorder:"#e9e6e0",pillBg:"#f3f0ea",font:"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",fontMono:"'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Monaco, Consolas, monospace",fontSerif:"'Inter', -apple-system, BlinkMacSystemFont, sans-serif"};function Vi(e){if(typeof document>"u")return Ki[e];const t=Pn[e];return getComputedStyle(document.documentElement).getPropertyValue(t).trim()||Ki[e]}function xb(){return new Proxy({},{get(e,t){if(typeof t=="string"&&t in Pn)return Vi(t)},has(e,t){return typeof t=="string"&&t in Pn},ownKeys(){return Object.keys(Pn)},getOwnPropertyDescriptor(e,t){if(!(typeof t!="string"||!(t in Pn)))return{enumerable:!0,configurable:!0,value:Vi(t)}}})}const Kt=xb(),ze={obsidian:Kt,paper:Kt,white:Kt,dark:Kt,light:Kt,midnight:Kt,arctic:Kt};function it(e,t="0 0 24 24"){return function({size:r=16,strokeWidth:o=1.75,...i}){return s.jsx("svg",{width:r,height:r,viewBox:t,fill:"none",stroke:"currentColor",strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round",...i,children:e})}}const bb=it(s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3",y:"3",width:"8",height:"8",rx:"1.5"}),s.jsx("rect",{x:"13",y:"3",width:"8",height:"8",rx:"1.5"}),s.jsx("rect",{x:"3",y:"13",width:"8",height:"8",rx:"1.5"}),s.jsx("rect",{x:"13",y:"13",width:"8",height:"8",rx:"1.5"})]}));it(s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 2l8 3v6c0 5-3.5 9-8 11-4.5-2-8-6-8-11V5l8-3z"}),s.jsx("path",{d:"M9 12l2 2 4-4"})]}));const vb=it(s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"5",cy:"12",r:"2"}),s.jsx("circle",{cx:"19",cy:"5",r:"2"}),s.jsx("circle",{cx:"19",cy:"19",r:"2"}),s.jsx("path",{d:"M7 12l10-6M7 12l10 6"})]})),z1=it(s.jsxs(s.Fragment,{children:[s.jsx("ellipse",{cx:"12",cy:"5",rx:"8",ry:"3"}),s.jsx("path",{d:"M4 5v6c0 1.66 3.58 3 8 3s8-1.34 8-3V5"}),s.jsx("path",{d:"M4 11v6c0 1.66 3.58 3 8 3s8-1.34 8-3v-6"})]}));it(s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M4 4h8a8 8 0 010 16H4z"}),s.jsx("path",{d:"M16 20l4 4"})]}));it(s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M3 3v18h18"}),s.jsx("path",{d:"M7 15l4-4 4 4 5-7"})]}));it(s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),s.jsx("path",{d:"M3 9h18M9 3v18"})]}));it(s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),s.jsx("path",{d:"M8 12h8M12 8v8"})]}));const q1=it(s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M4 7h16M4 12h16M4 17h10"}),s.jsx("circle",{cx:"18",cy:"17",r:"2"})]}));it(s.jsx(s.Fragment,{children:s.jsx("path",{d:"M3 5h18l-7 9v5l-4-2v-3L3 5z"})}));it(s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M4 4h10l6 6v10H4z"}),s.jsx("path",{d:"M14 4v6h6"}),s.jsx("path",{d:"M8 14l3 3 5-5"})]}));it(s.jsx(s.Fragment,{children:s.jsx("path",{d:"M21 12a8 8 0 01-11.5 7.2L4 21l1.8-5.5A8 8 0 1121 12z"})}));const Kc=44,Vc=188,Hc="dql-activitybar-expanded";function Sb(){var e;if(typeof window>"u")return!1;try{return((e=window.localStorage)==null?void 0:e.getItem(Hc))==="1"}catch{return!1}}function kb(e){var t;try{(t=window.localStorage)==null||t.setItem(Hc,e?"1":"0")}catch{}}function Hi({title:e,icon:t,active:n,expanded:r,onClick:o,t:i}){const[l,a]=u.useState(!1),d=s.jsxs("button",{"aria-label":e,onClick:o,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:{width:r?Vc-12:Kc-8,height:32,display:"flex",alignItems:"center",justifyContent:r?"flex-start":"center",gap:10,padding:r?"0 10px":0,marginLeft:r?6:4,marginRight:r?6:4,background:n?i.accent+"1f":l?i.textPrimary+"0f":"transparent",border:"none",borderRadius:6,cursor:"pointer",color:n?i.accent:l?i.textPrimary:i.textSecondary,transition:"background 0.15s, color 0.15s",fontFamily:i.font,fontSize:13,fontWeight:n?500:400,textAlign:"left",overflow:"hidden",whiteSpace:"nowrap"},children:[s.jsx("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,width:18,height:18},children:t}),r&&s.jsx("span",{style:{flex:1,textOverflow:"ellipsis",overflow:"hidden"},children:e})]});return r?d:s.jsx(gl,{content:e,side:"right",children:d})}function wb(){const{state:e,dispatch:t}=ve(),n=ze[e.themeMode],[r,o]=u.useState(Sb);u.useEffect(()=>{kb(r)},[r]);function i(d){if(d==="home"||d==="ask"||d==="modeling"){t({type:"SET_MAIN_VIEW",view:d});return}if(d==="lineage"){t({type:"SET_SIDEBAR_PANEL",panel:"lineage"});return}if(d==="connection"||d==="git"||d==="apps"||d==="readiness"||d==="skills"||d==="domains"||d==="settings"){t({type:"SET_SIDEBAR_PANEL",panel:d});return}e.sidebarPanel===d&&e.sidebarOpen?t({type:"TOGGLE_SIDEBAR"}):t({type:"SET_SIDEBAR_PANEL",panel:d})}const l=[{label:"Insights",items:[{key:"apps",title:"Apps",icon:s.jsx(Xy,{size:16,strokeWidth:1.75}),active:e.mainView==="apps"},{key:"ask",title:"Ask",icon:s.jsx(Wy,{size:16,strokeWidth:1.75}),active:e.mainView==="ask"}]},{label:"Build",items:[{key:"files",title:"Notebooks",icon:s.jsx(Ms,{size:16,strokeWidth:1.75}),active:e.sidebarPanel==="files"&&e.sidebarOpen},{key:"block_library",title:"Blocks",icon:s.jsx(bb,{size:16}),active:e.sidebarPanel==="block_library"&&e.sidebarOpen},{key:"lineage",title:"Lineage",icon:s.jsx(vb,{size:16}),active:e.mainView==="lineage"||e.mainView==="lineage_detail"}]},{label:"Govern",items:[{key:"domains",title:"Domains",icon:s.jsx(Jo,{size:16,strokeWidth:1.75}),active:e.mainView==="domains"||e.mainView==="modeling"||e.mainView==="skills"},{key:"git",title:"Source control",icon:s.jsx(Sn,{size:16,strokeWidth:1.75}),active:e.mainView==="git"},{key:"settings",title:"Settings",icon:s.jsx(px,{size:16,strokeWidth:1.75}),active:e.mainView==="settings"||e.mainView==="connection"}]}],a=[{key:"help",title:"Help",icon:s.jsx(ny,{size:16,strokeWidth:1.75}),active:e.mainView==="help",onClick:()=>t({type:"SET_MAIN_VIEW",view:"help"})}];return s.jsxs("div",{style:{width:r?Vc:Kc,flexShrink:0,background:n.activityBarBg,borderRight:`1px solid ${n.headerBorder}`,display:"flex",flexDirection:"column",paddingTop:6,paddingBottom:6,gap:2,userSelect:"none",transition:"width 0.18s ease",overflow:"hidden"},children:[s.jsx("div",{style:{display:"flex",justifyContent:r?"flex-end":"center",paddingLeft:r?6:0,paddingRight:r?6:0,marginBottom:4},children:s.jsx(gl,{content:r?"Collapse":"Expand",side:"right",children:s.jsx("button",{"aria-label":r?"Collapse sidebar rail":"Expand sidebar rail",onClick:()=>o(d=>!d),style:{width:28,height:26,display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",border:"none",borderRadius:5,cursor:"pointer",color:n.textMuted,padding:0},onMouseEnter:d=>{d.currentTarget.style.color=n.textPrimary,d.currentTarget.style.background=n.textPrimary+"0f"},onMouseLeave:d=>{d.currentTarget.style.color=n.textMuted,d.currentTarget.style.background="transparent"},children:r?s.jsx(Jg,{size:14,strokeWidth:2}):s.jsx(Yg,{size:14,strokeWidth:2})})})}),l.map((d,c)=>s.jsxs(De.Fragment,{children:[c>0?s.jsx("div",{style:{height:1,margin:r?"8px 10px 2px":"8px 12px",background:n.headerBorder}}):null,r?s.jsx("div",{style:{fontSize:10,fontWeight:600,color:n.textMuted,letterSpacing:"0.04em",padding:"4px 12px 2px"},children:d.label}):null,d.items.map(f=>s.jsx(Hi,{title:f.title,icon:f.icon,active:f.active,expanded:r,onClick:()=>i(f.key),t:n},f.key))]},d.label)),s.jsx("div",{style:{flex:1}}),a.map(d=>s.jsx(Hi,{title:d.title,icon:d.icon,active:d.active,expanded:r,onClick:d.onClick,t:n},d.key))]})}const jb=2e4,U1="application/dql-semantic-ref",Gi=new Map;let Vn=null;function Cb(e){N.trackUsage(e),window.dispatchEvent(new CustomEvent("dql:semantic-used",{detail:{name:e}}))}async function Ji(e,t){const n=`${e}:${t.toLowerCase()}`,r=Gi.get(n);if(r&&Date.now()<r.expiresAt)return r.items;const o=new URLSearchParams({kind:e,q:t,limit:"50"}),i=await fetch(`${window.location.origin}/api/editor/completions?${o.toString()}`);if(!i.ok)throw new Error(`Failed to load semantic completions: HTTP ${i.status}`);const l=await i.json(),a=Array.isArray(l.completions)?l.completions:[];return Gi.set(n,{items:a,expiresAt:Date.now()+jb}),a}function Gc(e,t,n){const r=n??e.state.selection.main.from;e.dispatch({changes:{from:r,to:n??e.state.selection.main.to,insert:t},selection:{anchor:r+t.length}}),e.focus()}function W1(e){Vn=e}function K1(e){Vn===e&&(Vn=null)}function Eb(e){return Vn?(Gc(Vn,e),!0):!1}function V1(e,t,n){const r=n?e.posAtCoords(n)??e.state.selection.main.from:e.state.selection.main.from;Gc(e,t,r)}function Qi(e,t,n){return{label:e.name,detail:e.type==="metric"?"@metric":"@dim",type:e.type==="metric"?"function":"variable",info:`${e.label}${e.description?`
405
+ `));if(c==="agent-run-event")t({kind:"event",event:p});else if(c==="agent-run-answer-delta"){const h=typeof(p==null?void 0:p.delta)=="string"?p.delta:"";h&&t({kind:"answer-delta",delta:h})}else if(c==="agent-run-complete")i=p,t({kind:"complete",run:i});else if(c==="agent-run-error")throw new Error(typeof(p==null?void 0:p.error)=="string"?p.error:"Agent run failed.")};for(;;){const{value:a,done:d}=await n.read();if(a){o+=r.decode(a,{stream:!d});let c=o.search(/\r?\n\r?\n/);for(;c>=0;){const f=o.slice(0,c);o=o.slice(o[c]==="\r"?c+4:c+2),l(f),c=o.search(/\r?\n\r?\n/)}}if(d)break}if(o.trim()&&l(o),!i)throw new Error("Agent run stream ended before completion.");return i}function cn(e){var r;const t=Array.isArray(e==null?void 0:e.columns)?e.columns.map(o=>typeof o=="string"?o:typeof(o==null?void 0:o.name)=="string"?o.name:String(o)):[],n=e!=null&&e.semanticRefs&&typeof e.semanticRefs=="object"?{metrics:Array.isArray(e.semanticRefs.metrics)?e.semanticRefs.metrics.map(String):[],dimensions:Array.isArray(e.semanticRefs.dimensions)?e.semanticRefs.dimensions.map(String):[]}:void 0;return{columns:t,rows:Array.isArray(e==null?void 0:e.rows)?e.rows:[],rowCount:(e==null?void 0:e.rowCount)??((r=e==null?void 0:e.rows)==null?void 0:r.length)??0,executionTime:(e==null?void 0:e.executionTime)??(e==null?void 0:e.executionTimeMs)??0,...n?{semanticRefs:n}:{}}}function wt(e){var n;const t=e!=null&&e.resultPreview&&typeof e.resultPreview=="object"?cn(e.resultPreview):void 0;return{...e,domain:typeof(e==null?void 0:e.domain)=="string"&&e.domain.trim()?e.domain:void 0,owner:typeof(e==null?void 0:e.owner)=="string"&&e.owner.trim()?e.owner:void 0,warnings:Array.isArray(e==null?void 0:e.warnings)?e.warnings:[],dqlCandidateIds:Array.isArray(e==null?void 0:e.dqlCandidateIds)?e.dqlCandidateIds:[],dqlArtifact:Qo(e==null?void 0:e.dqlArtifact),dqlPromotionAction:sb((e==null?void 0:e.dqlPromotionAction)??((n=e==null?void 0:e.dqlPromotion)==null?void 0:n.recommendedAction)),dqlPromotion:Uc(e==null?void 0:e.dqlPromotion),researchPlan:Qx(e==null?void 0:e.researchPlan),reviewChecklist:rb(e==null?void 0:e.reviewChecklist,e),...t?{resultPreview:t}:{resultPreview:void 0}}}function Qx(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t=e,n=t.evidence&&typeof t.evidence=="object"&&!Array.isArray(t.evidence)?t.evidence:{},r=t.preview&&typeof t.preview=="object"&&!Array.isArray(t.preview)?t.preview:{},o=t.promotion&&typeof t.promotion=="object"&&!Array.isArray(t.promotion)?t.promotion:{},i=t.sqlState==="generated"||t.sqlState==="reviewed"?t.sqlState:"missing",l=r.status==="ready"||r.status==="error"?r.status:"not_run",a=o.path==="review_context"||o.path==="run_preview"||o.path==="reuse_existing"||o.path==="create_dql_draft"||o.path==="open_certification"||o.path==="complete_review"?o.path:"needs_sql",d=typeof r.rowCount=="number"&&Number.isFinite(r.rowCount)?r.rowCount:void 0;return{sqlState:i,grain:typeof t.grain=="string"&&t.grain.trim()?t.grain:void 0,parameterPolicy:Yx(t.parameterPolicy),allowedFilters:Array.isArray(t.allowedFilters)?t.allowedFilters.map(String).filter(Boolean):[],evidence:{trustLabel:typeof n.trustLabel=="string"&&n.trustLabel.trim()?n.trustLabel:void 0,contextPackId:typeof n.contextPackId=="string"&&n.contextPackId.trim()?n.contextPackId:void 0,evidenceCount:ge(n.evidenceCount),relationCount:ge(n.relationCount),missingContextCount:ge(n.missingContextCount)},preview:{status:l,...d===void 0?{}:{rowCount:d}},promotion:{path:a,duplicateDecision:typeof o.duplicateDecision=="string"&&o.duplicateDecision.trim()?o.duplicateDecision:void 0},reviewFocus:Array.isArray(t.reviewFocus)?t.reviewFocus.map(String).filter(Boolean):[],generatedAt:typeof t.generatedAt=="string"&&t.generatedAt.trim()?t.generatedAt:new Date(0).toISOString()}}function Yx(e){return Array.isArray(e)?e.flatMap(t=>{if(!t||typeof t!="object"||Array.isArray(t))return[];const n=t,r=typeof n.name=="string"&&n.name.trim()?n.name:void 0,o=typeof n.policy=="string"&&n.policy.trim()?n.policy:void 0;return r&&o?[{name:r,policy:o}]:[]}):[]}function ge(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function sn(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function Xx(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{};return{totalReviewCount:ge(t.totalReviewCount),openReviewCount:ge(t.openReviewCount),terminalReviewCount:ge(t.terminalReviewCount),draftCreatedCount:ge(t.draftCreatedCount),certifiedCount:ge(t.certifiedCount),completedCount:ge(t.completedCount),rejectedCount:ge(t.rejectedCount),draftCreationRate:sn(t.draftCreationRate),certifyConversionRate:sn(t.certifyConversionRate),medianOpenReviewAgeMs:sn(t.medianOpenReviewAgeMs),medianTimeToDraftMs:sn(t.medianTimeToDraftMs),medianTimeToCertificationMs:sn(t.medianTimeToCertificationMs),medianTimeToTerminalMs:sn(t.medianTimeToTerminalMs)}}function Zx(e){const t=e&&typeof e=="object"?e:{},n=t.counts&&typeof t.counts=="object"?t.counts:{},r=t.health&&typeof t.health=="object"?t.health:{},o=t.search&&typeof t.search=="object"?t.search:{},i=t.updatedAt&&typeof t.updatedAt=="object"?t.updatedAt:{},l=t.limits&&typeof t.limits=="object"?t.limits:{};return{counts:{totalRuns:ge(n.totalRuns),activeRuns:ge(n.activeRuns),closedRuns:ge(n.closedRuns),notebooks:ge(n.notebooks),domains:ge(n.domains),owners:ge(n.owners),sourceLinkedRuns:ge(n.sourceLinkedRuns)},health:{staleOpenRuns:ge(r.staleOpenRuns),expiredOpenRuns:ge(r.expiredOpenRuns),staleThresholdDays:ge(r.staleThresholdDays)||7,expiredThresholdDays:ge(r.expiredThresholdDays)||30,oldestOpenUpdatedAt:typeof r.oldestOpenUpdatedAt=="string"&&r.oldestOpenUpdatedAt.trim()?r.oldestOpenUpdatedAt:void 0,newestOpenUpdatedAt:typeof r.newestOpenUpdatedAt=="string"&&r.newestOpenUpdatedAt.trim()?r.newestOpenUpdatedAt:void 0},search:{indexed:o.indexed===!0,indexRows:ge(o.indexRows),indexVersion:typeof o.indexVersion=="string"&&o.indexVersion.trim()?o.indexVersion:void 0,stale:o.stale===!0},updatedAt:{oldest:typeof i.oldest=="string"&&i.oldest.trim()?i.oldest:void 0,newest:typeof i.newest=="string"&&i.newest.trim()?i.newest:void 0},limits:{pageSize:ge(l.pageSize)||25,maxPageSize:ge(l.maxPageSize)||500,sourceCoverageLimit:ge(l.sourceCoverageLimit)||1e4,seedCellLimit:ge(l.seedCellLimit)||1e3},warnings:Array.isArray(t.warnings)?t.warnings.filter(a=>typeof a=="string"):[]}}function eb(e){return e==="diagnose_change"||e==="driver_breakdown"||e==="segment_compare"||e==="entity_drilldown"||e==="anomaly_investigation"||e==="trust_gap_review"?e:"ad_hoc_analysis"}function tb(e){const t=typeof e=="string"?e:"";return(t.split(/[\\/]/).pop()??t).replace(/\.dqlnb$/i,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim()||"Untitled notebook"}function nb(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},n=r=>typeof t[r]=="number"&&Number.isFinite(t[r])?t[r]:0;return{fix_blockers:n("fix_blockers"),review_sql:n("review_sql"),review_context:n("review_context"),run_preview:n("run_preview"),reuse_existing:n("reuse_existing"),create_dql_draft:n("create_dql_draft"),open_certification:n("open_certification"),complete_review:n("complete_review"),continue_review:n("continue_review")}}function xr(e){return e==="fix_blockers"||e==="review_sql"||e==="review_context"||e==="run_preview"||e==="reuse_existing"||e==="create_dql_draft"||e==="open_certification"||e==="complete_review"||e==="continue_review"?e:void 0}function rb(e,t){var c,f;if(e&&typeof e=="object"&&Array.isArray(e.items))return{readyForDqlDraft:e.readyForDqlDraft===!0,readyForCertificationReview:e.readyForCertificationReview===!0,blockers:Array.isArray(e.blockers)?e.blockers.filter(p=>typeof p=="string"):[],warnings:Array.isArray(e.warnings)?e.warnings.filter(p=>typeof p=="string"):[],items:e.items.map(p=>({id:typeof p.id=="string"?p.id:"item",label:typeof p.label=="string"?p.label:"Review item",status:p.status==="passed"||p.status==="pending"||p.status==="warning"||p.status==="blocked"?p.status:"pending",detail:typeof p.detail=="string"?p.detail:""}))};const n=!!t.reviewedSql,r=n||!!t.generatedSql,o=((c=t.resultPreview)==null?void 0:c.rowCount)??((f=t.resultPreview)==null?void 0:f.rows.length)??0,i=!!(t.resultPreview&&(t.resultPreview.columns.length>0||o>0)),l=!!t.draftBlockPath,a=!!(t.contextPackId||t.evidence),d=t.dqlPromotionAction==="reuse_existing";return{readyForDqlDraft:!!(!d&&t.question&&n&&a&&t.status!=="error"),readyForCertificationReview:!!(!d&&t.question&&n&&a&&i&&l),blockers:t.status==="error"?[t.error??"Preview failed."]:[],warnings:i||d?[]:["Run a bounded preview before certification review."],items:[{id:"question",label:"Question",status:t.question?"passed":"blocked",detail:t.question?"Business question is captured.":"Add a business question."},{id:"sql",label:"Reviewed SQL",status:r||d?"passed":"blocked",detail:d&&!r?"Existing DQL should be reused; no new SQL is required.":r?"SQL is available.":"Add SQL before promotion."},{id:"evidence",label:"Evidence",status:a||d?"passed":"warning",detail:a?"Context evidence is saved.":d?"Reuse evidence is captured in the recommendation.":"Preview and save metadata context."},{id:"preview",label:"Preview",status:i||d?"passed":"pending",detail:i?"Preview result is available.":d?"Certified block reuse does not require a new raw SQL preview.":"Run a bounded preview."},{id:"dql_draft",label:"DQL draft",status:l||d?"passed":"pending",detail:l?`Draft saved at ${t.draftBlockPath}.`:d?"No new DQL draft is required.":"Create a DQL draft after review."}]}}function ob(e){var r,o,i,l;const t=e&&typeof e=="object"?e:{},n=t.routeDecision&&typeof t.routeDecision=="object"?{route:typeof t.routeDecision.route=="string"?t.routeDecision.route:void 0,intent:typeof t.routeDecision.intent=="string"?t.routeDecision.intent:void 0,reason:typeof t.routeDecision.reason=="string"?t.routeDecision.reason:void 0}:void 0;return{contextPackId:typeof t.contextPackId=="string"?t.contextPackId:"",trustLabel:typeof t.trustLabel=="string"?t.trustLabel:void 0,routeDecision:n,evidence:Array.isArray(t.evidence)?t.evidence.map(a=>({objectKey:typeof a.objectKey=="string"?a.objectKey:void 0,objectType:typeof a.objectType=="string"?a.objectType:void 0,name:typeof a.name=="string"?a.name:"Evidence",role:typeof a.role=="string"?a.role:void 0,reason:typeof a.reason=="string"?a.reason:""})):[],summaries:Array.isArray(t.summaries)?t.summaries.map(a=>({title:typeof a.title=="string"?a.title:"Context",detail:typeof a.detail=="string"?a.detail:"",objectType:typeof a.objectType=="string"?a.objectType:void 0,reason:typeof a.reason=="string"?a.reason:void 0})):[],relations:Array.isArray(t.relations)?t.relations.map(a=>({relation:typeof a.relation=="string"?a.relation:"",name:typeof a.name=="string"?a.name:"Relation",source:typeof a.source=="string"?a.source:"",columns:Array.isArray(a.columns)?a.columns.map(String):[]})).filter(a=>a.relation||a.name):[],missingContext:Array.isArray(t.missingContext)?t.missingContext.map(a=>({kind:typeof a.kind=="string"?a.kind:"metadata",message:typeof a.message=="string"?a.message:"",severity:typeof a.severity=="string"?a.severity:"warning"})).filter(a=>a.message):[],warnings:Array.isArray(t.warnings)?t.warnings.filter(a=>typeof a=="string"):[],topRejected:Array.isArray(t.topRejected)?t.topRejected.map(a=>({name:typeof a.name=="string"?a.name:"Rejected context",objectType:typeof a.objectType=="string"?a.objectType:void 0,reason:typeof a.reason=="string"?a.reason:"",score:typeof a.score=="number"&&Number.isFinite(a.score)?a.score:void 0})).filter(a=>a.reason):[],counts:{objects:typeof((r=t.counts)==null?void 0:r.objects)=="number"?t.counts.objects:0,evidence:typeof((o=t.counts)==null?void 0:o.evidence)=="number"?t.counts.evidence:0,relations:typeof((i=t.counts)==null?void 0:i.relations)=="number"?t.counts.relations:0,warnings:typeof((l=t.counts)==null?void 0:l.warnings)=="number"?t.counts.warnings:0}}}function sb(e){return e==="reuse_existing"||e==="extend_existing"||e==="create_replacement"||e==="create_new"||e==="review_required"?e:void 0}function Uc(e){if(!(!e||typeof e!="object"))return{importId:typeof e.importId=="string"?e.importId:"",candidateIds:Array.isArray(e.candidateIds)?e.candidateIds.filter(t=>typeof t=="string"):[],draftBlockPath:typeof e.draftBlockPath=="string"?e.draftBlockPath:void 0,recommendedAction:typeof e.recommendedAction=="string"?e.recommendedAction:void 0,similarityMatches:Array.isArray(e.similarityMatches)?e.similarityMatches:[],candidates:Array.isArray(e.candidates)?e.candidates.map(t=>({...t,similarityMatches:Array.isArray(t.similarityMatches)?t.similarityMatches:[],parameterPolicy:Array.isArray(t.parameterPolicy)?t.parameterPolicy:[],allowedFilters:Array.isArray(t.allowedFilters)?t.allowedFilters:[],warnings:Array.isArray(t.warnings)?t.warnings:[]})):[],createdAt:typeof e.createdAt=="string"?e.createdAt:""}}const N={async getDbtFirstModeling(){return j("/api/modeling/dbt-first")},async getDbtModelingNode(e){return j(`/api/modeling/dbt-first/nodes/${encodeURIComponent(e)}`)},async getDbtModelingNodes(e){return j("/api/modeling/dbt-first/nodes/batch",{method:"POST",body:JSON.stringify({uniqueIds:e})})},async getDbtModelInventory(e={}){const t=new URLSearchParams;return e.q&&t.set("q",e.q),e.domain&&t.set("domain",e.domain),e.cursor!==void 0&&t.set("cursor",String(e.cursor)),e.limit!==void 0&&t.set("limit",String(e.limit)),j(`/api/modeling/dbt-first/inventory?${t.toString()}`)},async getDomainWorkspaces(){return j("/api/domain-workspaces")},async getRelatedDomainProducts(e){return j(`/api/domain-workspaces/${encodeURIComponent(e)}/related-products`)},async getAllRelatedDomainProducts(){return j("/api/domain-workspaces/related-products")},async getDomainKnowledge(e){return j(`/api/domain-workspaces/${encodeURIComponent(e)}/knowledge`)},async previewModelingChange(e,t){return j("/api/modeling/dbt-first/preview",{method:"POST",body:JSON.stringify({change:e,expectedSnapshotId:t})})},async applyModelingChange(e,t,n){return j("/api/modeling/dbt-first/apply",{method:"POST",body:JSON.stringify({change:e,fingerprint:t,expectedSnapshotId:n})})},async validateModelingRelationship(e,t){return(await j("/api/modeling/dbt-first/relationships/validate",{method:"POST",body:JSON.stringify({relationship:e,expectedSnapshotId:t})})).evidence},async previewDbtSourcePatch(e,t){return j("/api/modeling/dbt-first/dbt-source/preview",{method:"POST",body:JSON.stringify({change:e,expectedSnapshotId:t})})},async applyDbtSourcePatch(e,t,n){return j("/api/modeling/dbt-first/dbt-source/apply",{method:"POST",body:JSON.stringify({change:e,expectedFingerprint:t,expectedSnapshotId:n})})},async getSettingsEnvStatus(){try{return await j("/api/settings/env-status")}catch{return{groups:[]}}},async getProposeReadiness(e){try{return await j("/api/propose",{method:"POST",body:JSON.stringify(e??{})})}catch{return{ready:!1,reason:"Unable to reach the propose engine. Is the local DQL server running?",summary:{modelsScanned:0,businessModels:0,plumbingExcluded:0,metricsFound:0,proposalsRanked:0,draftsExisting:0,readyForReview:0,blockingTotal:0,warningTotal:0},plan:Gx,proposals:[]}}},async generateProposeDrafts(e){try{return await j("/api/propose/generate",{method:"POST",body:JSON.stringify(e)})}catch(t){return{ready:!1,reason:t instanceof Error?t.message:"Unable to reach the propose engine.",draftsWritten:0,draftsSkipped:0,proposals:[]}}},async proposePreview(e){return j(`/api/propose/preview?slug=${encodeURIComponent(e)}`)},async aiBuild(e){return j("/api/ai/build",{method:"POST",body:JSON.stringify(e)})},async createAgentRun(e){return(await j("/api/agent-runs",{method:"POST",body:JSON.stringify(e)})).run},async createAgentRunStream(e,t,n){let r;try{r=await fetch(`${On}/api/agent-runs?stream=1`,{method:"POST",headers:$n({"Content-Type":"application/json"}),body:JSON.stringify(e),signal:n})}catch(o){if(n!=null&&n.aborted)throw o;const i=o instanceof Error&&o.message?` ${o.message}`:"";throw new Error(`Unable to reach the local DQL notebook server. Check that it is still running, then retry.${i}`)}if(!r.ok){const o=await r.text().catch(()=>"");throw Xo(r,o)}return Jx(r,t)},async listAgentRuns(e){const t=new URLSearchParams;typeof(e==null?void 0:e.limit)=="number"&&Number.isFinite(e.limit)&&t.set("limit",String(e.limit));const n=t.toString()?`?${t.toString()}`:"";return j(`/api/agent-runs${n}`)},async getAgentRun(e){const t=await this.getAgentRunState(e);if(t.lifecycleState!=="terminal")throw new Error(`Agent run ${e} is still ${t.lifecycleState}.`);return t.run},async getAgentRunState(e){return j(`/api/agent-runs/${encodeURIComponent(e)}`)},async deriveAnalyticalRepair(e,t){return j(`/api/agent-runs/${encodeURIComponent(e)}/analytical-repair`,{method:"POST",body:JSON.stringify({repair:t})})},async repairAgentRunExecution(e,t){return j(`/api/agent-runs/${encodeURIComponent(e)}/repair-execution`,{method:"POST",body:JSON.stringify({threadId:t})})},async cancelAgentRun(e){return j(`/api/agent-runs/${encodeURIComponent(e)}/cancel`,{method:"POST"})},async listAgentThreads(e){const t=new URLSearchParams;typeof(e==null?void 0:e.limit)=="number"&&Number.isFinite(e.limit)&&t.set("limit",String(e.limit)),e!=null&&e.archived&&t.set("archived","1");const n=t.toString()?`?${t.toString()}`:"";return j(`/api/agent/threads${n}`)},async createAgentThread(e={}){return(await j("/api/agent/threads",{method:"POST",body:JSON.stringify(e)})).thread},async getAgentThread(e){return j(`/api/agent/threads/${encodeURIComponent(e)}`)},async updateAgentThread(e,t){return j(`/api/agent/threads/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})},async archiveAgentThread(e){return j(`/api/agent/threads/${encodeURIComponent(e)}/archive`,{method:"POST"})},async deleteAgentThread(e){return j(`/api/agent/threads/${encodeURIComponent(e)}`,{method:"DELETE"})},async requestCertification(e){return j("/api/agent-runs/request-certification",{method:"POST",body:JSON.stringify(e)})},async getIdentity(){return j("/api/identity")},async getProviderSettings(){try{return await j("/api/settings/providers")}catch{return{providers:[]}}},async getProviderCliStatus(){try{return await j("/api/settings/providers/cli-status")}catch{return{status:{}}}},async saveProviderSettings(e){return j("/api/settings/providers",{method:"POST",body:JSON.stringify(e)})},async startOAuth(e){return j(`/api/auth/${e}/start`,{method:"POST"})},async getOAuthStatus(e){return j(`/api/auth/${e}/status`)},async signOutOAuth(e){return j(`/api/auth/${e}/signout`,{method:"POST"})},async testProviderSettings(e,t){try{return await j("/api/settings/providers/test",{method:"POST",body:JSON.stringify({id:e,...t})})}catch(n){return{ok:!1,message:n instanceof Error?n.message:String(n)}}},async getRemoteMcpSettings(){try{return await j("/api/settings/mcp")}catch{return{settings:{path:"",entries:[],warnings:[]}}}},async saveRemoteMcpSettings(e){return j("/api/settings/mcp",{method:"POST",body:JSON.stringify({entries:e})})},async recordAgentCorrection(e){return j("/api/agent/learnings/correction",{method:"POST",body:JSON.stringify(e)})},async listAgentHints(e){const t=e?`?status=${encodeURIComponent(e)}`:"";return j(`/api/agent/hints${t}`)},async reviewAgentHint(e,t,n){return j(`/api/agent/hints/${encodeURIComponent(e)}/review`,{method:"POST",body:JSON.stringify({decision:t,...n?{note:n}:{}})})},async updateAgentHint(e,t){return j(`/api/agent/hints/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})},async transitionAgentHint(e,t){return j(`/api/agent/hints/${encodeURIComponent(e)}/lifecycle`,{method:"POST",body:JSON.stringify(t)})},async listAgentMemory(e){const t=e?`?scope=${encodeURIComponent(e)}`:"";try{return await j(`/api/agent/memory${t}`)}catch{return{memories:[]}}},async saveAgentMemory(e){return j("/api/agent/memory",{method:"POST",body:JSON.stringify(e)})},async deleteAgentMemory(e){return j(`/api/agent/memory?id=${encodeURIComponent(e)}`,{method:"DELETE"})},async ensureAgentMemoryFiles(){return j("/api/agent/memory/default-files",{method:"POST"})},async listNotebooks(){try{return await j("/api/notebooks")}catch{return[]}},async readNotebook(e){return j(`/api/notebook-content?path=${encodeURIComponent(e)}`)},async deleteNotebook(e){return j(`/api/notebooks?path=${encodeURIComponent(e)}`,{method:"DELETE"})},async createNotebook(e,t,n={}){return j("/api/notebooks",{method:"POST",body:JSON.stringify({name:e,template:t,...n})})},async createBlock(e,t){return j("/api/blocks",{method:"POST",body:JSON.stringify({name:e,...t})})},async getBlockLibrary(){try{return await j("/api/blocks/library")}catch{return{blocks:[]}}},async getApps(){try{return await j("/api/apps")}catch{return{apps:[]}}},async updateBlockStatus(e,t){return j("/api/blocks/status",{method:"POST",body:JSON.stringify({path:e,newStatus:t})})},async getBlockHistory(e){try{return await j(`/api/blocks/history?path=${encodeURIComponent(e)}`)}catch{return{entries:[]}}},async runBlockTests(e,t){return j("/api/blocks/run-tests",{method:"POST",body:JSON.stringify({source:e,path:t})})},async getBlockStudioCatalog(e={}){const t=new URLSearchParams;e.includeSemantic===!1&&t.set("includeSemantic","false");const n=t.toString();return j(`/api/block-studio/catalog${n?`?${n}`:""}`)},async getBlockStudioDbtStatus(){return j("/api/block-studio/dbt-status")},async openBlockStudio(e){return j(`/api/block-studio/open?path=${encodeURIComponent(e)}`)},async getBlockBody(e){return j(`/api/blocks/body?path=${encodeURIComponent(e)}`)},async validateBlockStudio(e,t){return j("/api/block-studio/validate",{method:"POST",body:JSON.stringify({source:e,path:t})})},async runBlockStudio(e,t,n){return j("/api/block-studio/run",{method:"POST",body:JSON.stringify({source:e,path:t,parameters:n})})},async getCertifiedBlockParameters(e){return j(`/api/blocks/parameters?name=${encodeURIComponent(e)}`)},async invokeCertifiedBlock(e,t,n){var o,i,l,a,d,c;const r=await j("/api/blocks/invoke",{method:"POST",body:JSON.stringify({blockName:e,parameters:t,question:n})});return{parameters:Array.isArray(r==null?void 0:r.parameters)?r.parameters:[],result:{...cn(r==null?void 0:r.result),...typeof((o=r==null?void 0:r.result)==null?void 0:o.sql)=="string"?{sql:r.result.sql}:{},...typeof((i=r==null?void 0:r.result)==null?void 0:i.blockName)=="string"?{blockName:r.result.blockName}:{},...typeof((l=r==null?void 0:r.result)==null?void 0:l.blockPath)=="string"?{blockPath:r.result.blockPath}:{},...(a=r==null?void 0:r.result)!=null&&a.chartConfig?{chartConfig:r.result.chartConfig}:{},...Array.isArray((d=r==null?void 0:r.result)==null?void 0:d.parameters)?{parameters:r.result.parameters}:{},...typeof((c=r==null?void 0:r.result)==null?void 0:c.auditId)=="string"?{auditId:r.result.auditId}:{}}}},async addDqlArtifactResultFilter(e,t,n,r,o){const i=await j("/api/dql/artifacts/add-filter",{method:"POST",body:JSON.stringify({artifact:e,resultColumns:t,column:n,value:r,executionTarget:o})}),l=Qo(i==null?void 0:i.artifact);if(!l)throw new Error("Adding the filter input returned an invalid artifact contract.");return{artifact:l,parameterName:String((i==null?void 0:i.parameterName)??n)}},async invokeDqlArtifact(e,t,n,r,o){var a,d,c,f,p,h;const i=await j("/api/dql/artifacts/execute",{method:"POST",body:JSON.stringify({artifact:e,parameters:t,question:n,blockName:r,executionTarget:o})}),l=Qo(i==null?void 0:i.artifact);if(!l)throw new Error("DQL artifact execution returned an invalid artifact contract.");return{artifact:l,parameters:l.parameters??[],result:{...cn(i==null?void 0:i.result),...typeof((a=i==null?void 0:i.result)==null?void 0:a.sql)=="string"?{sql:i.result.sql}:{},...typeof((d=i==null?void 0:i.result)==null?void 0:d.blockName)=="string"?{blockName:i.result.blockName}:{},...typeof((c=i==null?void 0:i.result)==null?void 0:c.blockPath)=="string"?{blockPath:i.result.blockPath}:{},...(f=i==null?void 0:i.result)!=null&&f.chartConfig?{chartConfig:i.result.chartConfig}:{},...Array.isArray((p=i==null?void 0:i.result)==null?void 0:p.parameters)?{parameters:i.result.parameters}:{},...typeof((h=i==null?void 0:i.result)==null?void 0:h.auditId)=="string"?{auditId:i.result.auditId}:{}}}},async composeSemanticBlock(e){return j("/api/block-studio/compose-semantic",{method:"POST",body:JSON.stringify({question:e})})},async saveBlockStudio(e){return j("/api/block-studio/save",{method:"POST",body:JSON.stringify(e)})},async saveAgentBlockDraft(e){return j("/api/block-studio/agent-drafts",{method:"POST",body:JSON.stringify(e)})},async deleteBlockStudio(e){return j(`/api/block-studio/block?path=${encodeURIComponent(e)}`,{method:"DELETE"})},async previewBlockStudioImport(e){return j("/api/block-studio/import/preview",{method:"POST",body:JSON.stringify(e)})},async listBlockStudioImports(){return j("/api/block-studio/imports")},async createBlockStudioImport(e){return j("/api/block-studio/imports",{method:"POST",body:JSON.stringify(e)})},async createDqlGenerationSession(e){return j("/api/block-studio/ai-imports",{method:"POST",body:JSON.stringify(e)})},async getDqlGenerationSession(e){return j(`/api/block-studio/ai-imports/${encodeURIComponent(e)}`)},async getBlockStudioImport(e){return j(`/api/block-studio/imports/${encodeURIComponent(e)}`)},async deleteBlockStudioImport(e){return j(`/api/block-studio/imports/${encodeURIComponent(e)}`,{method:"DELETE"})},async clearBlockStudioImports(){return j("/api/block-studio/imports",{method:"DELETE"})},async updateBlockStudioImportCandidate(e,t,n){return j(`/api/block-studio/imports/${encodeURIComponent(e)}/candidates/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)})},async updateDqlGenerationCandidate(e,t,n){return j(`/api/block-studio/ai-imports/${encodeURIComponent(e)}/candidates/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)})},async matchSqlForBlockReuse(e,t){return j("/api/block-studio/match-sql",{method:"POST",body:JSON.stringify({sql:e,...t??{}})})},async previewDqlGenerationCandidate(e,t){return j(`/api/block-studio/ai-imports/${encodeURIComponent(e)}/candidates/${encodeURIComponent(t)}/preview`,{method:"POST"})},async certifyDqlGenerationCandidate(e,t){return j(`/api/block-studio/ai-imports/${encodeURIComponent(e)}/candidates/${encodeURIComponent(t)}/certify`,{method:"POST"})},async saveSelectedDqlGenerationCandidates(e,t){return j(`/api/block-studio/ai-imports/${encodeURIComponent(e)}/save-selected`,{method:"POST",body:JSON.stringify(t)})},async runBlockStudioImportCandidate(e,t){return j(`/api/block-studio/imports/${encodeURIComponent(e)}/candidates/${encodeURIComponent(t)}/run`,{method:"POST"})},async saveBlockStudioImportCandidate(e,t){return j(`/api/block-studio/imports/${encodeURIComponent(e)}/candidates/${encodeURIComponent(t)}/save`,{method:"POST"})},async saveAllBlockStudioImportCandidates(e){return j(`/api/block-studio/imports/${encodeURIComponent(e)}/save-all`,{method:"POST"})},async assistBlockStudioImportCandidate(e,t,n){return j(`/api/block-studio/imports/${encodeURIComponent(e)}/candidates/${encodeURIComponent(t)}/ai-assist`,{method:"POST",body:JSON.stringify({action:n})})},async getSemanticLayerDiagnostics(){return j("/api/semantic-layer/diagnostics")},async reloadSemanticLayer(){return j("/api/semantic-layer/reload",{method:"POST"})},async certifyBlockStudio(e){const t=await fetch(`${On}/api/block-studio/certify`,{headers:$n({"Content-Type":"application/json"}),method:"POST",body:JSON.stringify(e)}),n=await t.json().catch(()=>({ok:!1,error:t.statusText}));if(!t.ok&&t.status!==422)throw new Error(JSON.stringify(n));return n},async saveAsBlock(e){return j("/api/blocks/save-from-cell",{method:"POST",body:JSON.stringify(e)})},async getBlockTemplates(){try{return(await j("/api/blocks/templates")).templates}catch{return[]}},async listBlocks(e){try{return(await j("/api/notebooks")).filter(n=>n.type==="block"&&(!e||n.path.startsWith(`blocks/${e}/`)))}catch{return[]}},async saveNotebook(e,t){return j("/api/notebook-content",{method:"PUT",body:JSON.stringify({path:e,content:t})})},async executeQuery(e,t,n,r){var i,l,a;const o=await j("/api/query",{method:"POST",body:JSON.stringify({sql:e,executionContext:n,executionTarget:r}),signal:t});if(n!=null&&n.runId&&typeof((i=o==null?void 0:o.executionContext)==null?void 0:i.runId)=="string"&&o.executionContext.runId!==n.runId)throw new vt({message:"The notebook server returned a result for a different cell run. The stale result was rejected.",status:409,code:"STALE_CELL_EXECUTION",details:{expected:n,received:o.executionContext}});return{...cn(o),executionTarget:((l=o==null?void 0:o.executionTarget)==null?void 0:l.target)==="local"?{target:"local"}:((a=o==null?void 0:o.executionTarget)==null?void 0:a.target)==="connection"?{target:"connection",...typeof o.executionTarget.connectionName=="string"?{connectionName:o.executionTarget.connectionName}:{}}:void 0,compiledSql:typeof(o==null?void 0:o.compiledSql)=="string"?o.compiledSql:void 0,executedSql:typeof(o==null?void 0:o.executedSql)=="string"?o.executedSql:void 0,targetBinding:o!=null&&o.targetBinding&&typeof o.targetBinding=="object"?o.targetBinding:void 0,executionReceipt:o!=null&&o.executionReceipt&&typeof o.executionReceipt=="object"?o.executionReceipt:void 0}},async previewGeneratedSql(e,t){try{const n=await j("/api/ai/sql-draft/preview",{method:"POST",body:JSON.stringify({sql:e}),signal:t});return{ok:!0,result:cn(n.result)}}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async executeNotebookCell(e,t,n){var o,i,l,a,d,c;const r=await j("/api/notebook/execute",{method:"POST",body:JSON.stringify({cell:{id:e.id,type:e.type,source:e.content,title:e.name,config:e.chartConfig},executionTarget:e.executionTarget,parameters:((o=e.blockBinding)==null?void 0:o.state)==="bound"?e.blockBinding.parameterValues:e.dqlParameterValues,executionContext:n}),signal:t});if(n!=null&&n.runId&&typeof((i=r==null?void 0:r.executionContext)==null?void 0:i.runId)=="string"&&r.executionContext.runId!==n.runId)throw new vt({message:"The notebook server returned a result for a different semantic cell run. The stale result was rejected.",status:409,code:"STALE_CELL_EXECUTION",details:{expected:n,received:r.executionContext}});return{cellType:String((r==null?void 0:r.cellType)??e.type),cellId:typeof((l=r==null?void 0:r.executionContext)==null?void 0:l.cellId)=="string"?r.executionContext.cellId:void 0,runId:typeof((a=r==null?void 0:r.executionContext)==null?void 0:a.runId)=="string"?r.executionContext.runId:void 0,title:typeof(r==null?void 0:r.title)=="string"?r.title:void 0,blockName:typeof(r==null?void 0:r.blockName)=="string"?r.blockName:void 0,blockPath:typeof(r==null?void 0:r.blockPath)=="string"?r.blockPath:void 0,chartConfig:r!=null&&r.chartConfig&&typeof r.chartConfig=="object"?r.chartConfig:void 0,tests:Array.isArray(r==null?void 0:r.tests)?r.tests:void 0,result:r!=null&&r.result?cn(r.result):null,executionTarget:((d=r==null?void 0:r.executionTarget)==null?void 0:d.target)==="local"?{target:"local"}:((c=r==null?void 0:r.executionTarget)==null?void 0:c.target)==="connection"?{target:"connection",...typeof r.executionTarget.connectionName=="string"?{connectionName:r.executionTarget.connectionName}:{}}:void 0,engine:(r==null?void 0:r.engine)==="native"||(r==null?void 0:r.engine)==="metricflow-cli"||(r==null?void 0:r.engine)==="dbt-cloud"?r.engine:void 0,semanticTrace:r!=null&&r.semanticTrace&&typeof r.semanticTrace=="object"?r.semanticTrace:void 0,compiledSql:typeof(r==null?void 0:r.compiledSql)=="string"?r.compiledSql:void 0,executedSql:typeof(r==null?void 0:r.executedSql)=="string"?r.executedSql:void 0,targetBinding:r!=null&&r.targetBinding&&typeof r.targetBinding=="object"?r.targetBinding:void 0,executionReceipt:r!=null&&r.executionReceipt&&typeof r.executionReceipt=="object"?r.executionReceipt:void 0}},async getDatasets(){return j("/api/datasets")},async importDataset(e){if(e.file){const t=new FormData;t.set("file",e.file,e.file.name);for(const[r,o]of Object.entries(e))r==="file"||o===void 0||t.set(r,Array.isArray(o)?o.join(","):String(o));const n=await fetch(`${On}/api/datasets/import`,{method:"POST",headers:$n(),body:t});if(!n.ok){const r=await n.text().catch(()=>"");throw Xo(n,r)}return n.json()}return j("/api/datasets/import",{method:"POST",body:JSON.stringify(e)})},async refreshDataset(e){return j(`/api/datasets/${encodeURIComponent(e)}/refresh`,{method:"POST"})},async updateDatasetSchema(e,t){return j(`/api/datasets/${encodeURIComponent(e)}/schema`,{method:"POST",body:JSON.stringify({overrides:t})})},async renameDataset(e,t,n){return j(`/api/datasets/${encodeURIComponent(e)}/rename`,{method:"POST",body:JSON.stringify({name:t,alias:n})})},async pinDataset(e,t=!0){return j(`/api/datasets/${encodeURIComponent(e)}/pin`,{method:"POST",body:JSON.stringify({pinned:t})})},async removeDataset(e){await j(`/api/datasets/${encodeURIComponent(e)}`,{method:"DELETE"})},async stageDataset(e){return j("/api/datasets/stage",{method:"POST",body:JSON.stringify(e)})},async listNotebookResearch(e){var o,i,l,a,d,c,f,p,h,g,S,x,b,k,C,E,v,w,A,R;const t=new URLSearchParams;typeof e=="string"?e&&t.set("path",e):e&&(e.path&&t.set("path",e.path),e.sourceCellId&&t.set("sourceCellId",e.sourceCellId),e.domain&&t.set("domain",e.domain),e.owner&&t.set("owner",e.owner),e.intent&&t.set("intent",e.intent),e.search&&t.set("q",e.search),e.status&&t.set("status",e.status),e.reviewStatus&&t.set("reviewStatus",e.reviewStatus),e.promotionAction&&t.set("promotionAction",e.promotionAction),e.readiness&&t.set("readiness",e.readiness),e.age&&t.set("age",e.age),e.nextAction&&t.set("nextAction",e.nextAction),e.activeOnly&&t.set("activeOnly","true"),e.sort&&t.set("sort",e.sort),typeof e.limit=="number"&&t.set("limit",String(e.limit)),typeof e.offset=="number"&&t.set("offset",String(e.offset)));const n=t.toString()?`?${t.toString()}`:"",r=await j(`/api/notebook/research${n}`);return{runs:r.runs.map(wt),total:typeof r.total=="number"?r.total:r.runs.length,domains:Array.isArray(r.domains)?r.domains.map(y=>({domain:typeof y.domain=="string"&&y.domain.trim()?y.domain:"uncategorized",total:typeof y.total=="number"?y.total:0,draftReady:typeof y.draftReady=="number"?y.draftReady:0,certificationReady:typeof y.certificationReady=="number"?y.certificationReady:0,blocked:typeof y.blocked=="number"?y.blocked:0,staleOpen:typeof y.staleOpen=="number"?y.staleOpen:0,expiredOpen:typeof y.expiredOpen=="number"?y.expiredOpen:0,nextAction:xr(y.nextAction),nextActionCount:typeof y.nextActionCount=="number"&&Number.isFinite(y.nextActionCount)?Math.max(0,Math.floor(y.nextActionCount)):void 0})):[],owners:Array.isArray(r.owners)?r.owners.map(y=>({owner:typeof y.owner=="string"&&y.owner.trim()?y.owner:"unassigned",total:typeof y.total=="number"?y.total:0,draftReady:typeof y.draftReady=="number"?y.draftReady:0,certificationReady:typeof y.certificationReady=="number"?y.certificationReady:0,blocked:typeof y.blocked=="number"?y.blocked:0,staleOpen:typeof y.staleOpen=="number"?y.staleOpen:0,expiredOpen:typeof y.expiredOpen=="number"?y.expiredOpen:0,nextAction:xr(y.nextAction),nextActionCount:typeof y.nextActionCount=="number"&&Number.isFinite(y.nextActionCount)?Math.max(0,Math.floor(y.nextActionCount)):void 0})):[],intents:Array.isArray(r.intents)?r.intents.map(y=>({intent:eb(y.intent),total:typeof y.total=="number"?y.total:0,draftReady:typeof y.draftReady=="number"?y.draftReady:0,certificationReady:typeof y.certificationReady=="number"?y.certificationReady:0,blocked:typeof y.blocked=="number"?y.blocked:0,staleOpen:typeof y.staleOpen=="number"?y.staleOpen:0,expiredOpen:typeof y.expiredOpen=="number"?y.expiredOpen:0,nextAction:xr(y.nextAction),nextActionCount:typeof y.nextActionCount=="number"&&Number.isFinite(y.nextActionCount)?Math.max(0,Math.floor(y.nextActionCount)):void 0})):[],notebooks:Array.isArray(r.notebooks)?r.notebooks.map(y=>({path:typeof y.path=="string"&&y.path.trim()?y.path:"notebooks/untitled.dqlnb",title:typeof y.title=="string"&&y.title.trim()?y.title:tb(y.path),total:typeof y.total=="number"?y.total:0,draftReady:typeof y.draftReady=="number"?y.draftReady:0,certificationReady:typeof y.certificationReady=="number"?y.certificationReady:0,blocked:typeof y.blocked=="number"?y.blocked:0,staleOpen:typeof y.staleOpen=="number"?y.staleOpen:0,expiredOpen:typeof y.expiredOpen=="number"?y.expiredOpen:0,nextAction:xr(y.nextAction),nextActionCount:typeof y.nextActionCount=="number"&&Number.isFinite(y.nextActionCount)?Math.max(0,Math.floor(y.nextActionCount)):void 0})):[],counts:{total:typeof((o=r.counts)==null?void 0:o.total)=="number"?r.counts.total:r.runs.length,ready:typeof((i=r.counts)==null?void 0:i.ready)=="number"?r.counts.ready:0,needsReview:typeof((l=r.counts)==null?void 0:l.needsReview)=="number"?r.counts.needsReview:0,dqlDrafts:typeof((a=r.counts)==null?void 0:a.dqlDrafts)=="number"?r.counts.dqlDrafts:0,errors:typeof((d=r.counts)==null?void 0:d.errors)=="number"?r.counts.errors:0,reuseExisting:typeof((c=r.counts)==null?void 0:c.reuseExisting)=="number"?r.counts.reuseExisting:0,extendExisting:typeof((f=r.counts)==null?void 0:f.extendExisting)=="number"?r.counts.extendExisting:0,replacements:typeof((p=r.counts)==null?void 0:p.replacements)=="number"?r.counts.replacements:0,createNew:typeof((h=r.counts)==null?void 0:h.createNew)=="number"?r.counts.createNew:0,draftReady:typeof((g=r.counts)==null?void 0:g.draftReady)=="number"?r.counts.draftReady:0,certificationReady:typeof((S=r.counts)==null?void 0:S.certificationReady)=="number"?r.counts.certificationReady:0,blocked:typeof((x=r.counts)==null?void 0:x.blocked)=="number"?r.counts.blocked:0,staleOpen:typeof((b=r.counts)==null?void 0:b.staleOpen)=="number"?r.counts.staleOpen:0,expiredOpen:typeof((k=r.counts)==null?void 0:k.expiredOpen)=="number"?r.counts.expiredOpen:0,sourceLinked:typeof((C=r.counts)==null?void 0:C.sourceLinked)=="number"?r.counts.sourceLinked:0,nextActions:nb((E=r.counts)==null?void 0:E.nextActions)},groupCounts:{domains:typeof((v=r.groupCounts)==null?void 0:v.domains)=="number"&&Number.isFinite(r.groupCounts.domains)?Math.max(0,Math.floor(r.groupCounts.domains)):Array.isArray(r.domains)?r.domains.length:0,owners:typeof((w=r.groupCounts)==null?void 0:w.owners)=="number"&&Number.isFinite(r.groupCounts.owners)?Math.max(0,Math.floor(r.groupCounts.owners)):Array.isArray(r.owners)?r.owners.length:0,intents:typeof((A=r.groupCounts)==null?void 0:A.intents)=="number"&&Number.isFinite(r.groupCounts.intents)?Math.max(0,Math.floor(r.groupCounts.intents)):Array.isArray(r.intents)?r.intents.length:0,notebooks:typeof((R=r.groupCounts)==null?void 0:R.notebooks)=="number"&&Number.isFinite(r.groupCounts.notebooks)?Math.max(0,Math.floor(r.groupCounts.notebooks)):Array.isArray(r.notebooks)?r.notebooks.length:0},reviewMetrics:Xx(r.reviewMetrics),limit:r.limit,offset:typeof r.offset=="number"?r.offset:0}},async getNotebookResearchDiagnostics(){const e=await j("/api/notebook/research/diagnostics");return Zx(e)},async createNotebookResearch(e){const t=await j("/api/notebook/research",{method:"POST",body:JSON.stringify(e)});return wt(t.run)},async seedNotebookResearchFromCells(e){const t=await j("/api/notebook/research/seed-cells",{method:"POST",body:JSON.stringify(e)});return{created:Array.isArray(t.created)?t.created.map(wt):[],createdCount:typeof t.createdCount=="number"?t.createdCount:Array.isArray(t.created)?t.created.length:0,skippedCount:typeof t.skippedCount=="number"?t.skippedCount:0,limitApplied:t.limitApplied===!0}},async listNotebookResearchSourceCoverage(e){const t=await j("/api/notebook/research/source-coverage",{method:"POST",body:JSON.stringify({path:e.path,sourceCellIds:e.sourceCellIds,sourceCells:e.sourceCells,limit:e.limit})});return{runs:Array.isArray(t.runs)?t.runs.map(wt):[],requestedCount:typeof t.requestedCount=="number"?t.requestedCount:e.sourceCellIds.length,matchedCount:typeof t.matchedCount=="number"?t.matchedCount:Array.isArray(t.runs)?t.runs.length:0,limitApplied:t.limitApplied===!0}},async previewNotebookResearchContext(e){const t=await j("/api/notebook/research/context-preview",{method:"POST",body:JSON.stringify(e)});return ob(t)},async getNotebookResearch(e){const t=await j(`/api/notebook/research/${encodeURIComponent(e)}`);return wt(t.run)},async updateNotebookResearch(e,t){const n=await j(`/api/notebook/research/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)});return wt(n.run)},async runNotebookResearch(e,t){const n=await j(`/api/notebook/research/${encodeURIComponent(e)}/run`,{method:"POST",body:JSON.stringify(t??{})});return wt(n.run)},async checkNotebookResearchReuse(e,t){const n=await j(`/api/notebook/research/${encodeURIComponent(e)}/reuse-check`,{method:"POST",body:JSON.stringify(t??{})});return{...n,run:wt(n.run),promotion:Uc(n.promotion)??n.promotion}},async promoteNotebookResearchToDql(e,t){const n=await j(`/api/notebook/research/${encodeURIComponent(e)}/promote-dql`,{method:"POST",body:JSON.stringify(t??{})});return{...n,run:wt(n.run)}},async getSchema(){try{const e=await fetch(`${On}/api/schema`,{headers:$n()});if(e.ok)return await e.json();const t=await e.json().catch(()=>null);return t!=null&&t.error&&console.warn(`[dql] schema introspection failed: ${t.error}`),(t==null?void 0:t.fallback)??[]}catch(e){return console.warn("[dql] getSchema request failed",e),[]}},async getConnections(){try{return await j("/api/connections")}catch{return{default:"unknown",connections:{}}}},async previewDbtProfiles(e){return j("/api/connections/dbt-profiles/preview",{method:"POST",body:JSON.stringify({path:e})})},async saveConnections(e,t){return j("/api/connections",{method:"PUT",body:JSON.stringify({connections:e,defaultConnectionName:t})})},async previewConnectionMetadataScope(e,t={}){return j(`/api/connections/${encodeURIComponent(e)}/metadata-scope/preview`,{method:"POST",body:JSON.stringify(t)})},async discoverConnectionMetadataScopes(e){return j(`/api/connections/${encodeURIComponent(e)}/metadata-scope/discovery`,{method:"POST"})},async getConnectionMetadataScope(e){return j(`/api/connections/${encodeURIComponent(e)}/metadata-scope`)},async applyConnectionMetadataScope(e,t){return j(`/api/connections/${encodeURIComponent(e)}/metadata-scope`,{method:"PUT",body:JSON.stringify(t)})},async refreshConnectionMetadata(e){return j(`/api/connections/${encodeURIComponent(e)}/metadata-sync`,{method:"POST"})},async installConnector(e){return j("/api/connectors/install",{method:"POST",body:JSON.stringify({driver:e})})},async testConnection(){try{return await j("/api/test-connection",{method:"POST",body:JSON.stringify({})})}catch(e){return{ok:!1,message:e.message??"Connection failed"}}},async getSemanticRuntimeSettings(){return j("/api/semantic-runtime")},async getMetricFlowInstallerStatus(){return j("/api/semantic-runtime/metricflow/installer")},async installMetricFlow(e){return j("/api/semantic-runtime/metricflow/install",{method:"POST",body:JSON.stringify(e?{adapter:e}:{})})},async testDbtCloudSemanticRuntime(e){try{return await j("/api/semantic-runtime/dbt-cloud/test",{method:"POST",body:JSON.stringify(e)})}catch(t){return{ok:!1,error:(t==null?void 0:t.message)??"dbt Cloud Semantic Layer test failed."}}},async applyDbtCloudSemanticRuntime(e){return j("/api/semantic-runtime/dbt-cloud/apply",{method:"POST",body:JSON.stringify(e)})},async setSemanticRuntimePreference(e){return j("/api/semantic-runtime/preference",{method:"POST",body:JSON.stringify({preference:e})})},async getSemanticLayer(){try{return await j("/api/semantic-layer")}catch{return{available:!1,provider:null,metrics:[],measures:[],dimensions:[],timeDimensions:[],entities:[],hierarchies:[],semanticModels:[],savedQueries:[],domains:[],tags:[],favorites:[],recentlyUsed:[],lastSyncTime:null}}},async getSemanticTree(){return(await j("/api/semantic-layer/tree")).tree},async getSemanticObject(e){return j(`/api/semantic-layer/object/${encodeURIComponent(e)}`)},async getSetupLaunch(){return j("/api/onboarding/launch")},async acknowledgeSetupLaunch(){return j("/api/onboarding/acknowledge",{method:"POST",body:"{}"})},async getOnboardingStatus(){return j("/api/onboarding/status")},async previewDbtOnboarding(e){return j("/api/onboarding/dbt/preview",{method:"POST",body:JSON.stringify(e)})},async applyDbtOnboarding(e){return j("/api/onboarding/dbt/apply",{method:"POST",body:JSON.stringify({...e,fingerprint:e.expectedFingerprint})})},async refreshDbtOnboarding(e={}){return j("/api/onboarding/refresh",{method:"POST",body:JSON.stringify(e)})},async getOnboardingJob(e){return j(`/api/onboarding/jobs/${encodeURIComponent(e)}`)},async cancelOnboardingJob(e){return j(`/api/onboarding/jobs/${encodeURIComponent(e)}`,{method:"DELETE"})},async discoverOnboardingDomains(e={}){return j("/api/onboarding/domains/discover",{method:"POST",body:JSON.stringify(e)})},async applyOnboardingDomains(e){return j("/api/onboarding/domains/apply",{method:"POST",body:JSON.stringify(e)})},async importSemanticLayer(e){return j("/api/semantic-layer/import",{method:"POST",body:JSON.stringify(e)})},async syncSemanticLayer(){return j("/api/semantic-layer/sync",{method:"POST",body:JSON.stringify({})})},async previewSemanticImport(e){return j("/api/semantic-layer/import-preview",{method:"POST",body:JSON.stringify(e)})},async previewSyncDiff(){return j("/api/semantic-layer/sync-preview",{method:"POST",body:JSON.stringify({})})},async searchSemanticLayer(e){const t=new URLSearchParams;e.query&&t.set("q",e.query),e.domain&&t.set("domain",e.domain),e.tag&&t.set("tag",e.tag),e.type&&t.set("type",e.type);try{return await j(`/api/semantic-layer/search?${t.toString()}`)}catch{return{metrics:[],measures:[],dimensions:[],timeDimensions:[],entities:[],hierarchies:[],semanticModels:[],savedQueries:[]}}},async getFavorites(){try{return(await j("/api/user-prefs/favorites")).favorites}catch{return[]}},async toggleFavorite(e){return(await j("/api/user-prefs/favorites",{method:"POST",body:JSON.stringify({name:e})})).favorites},async getRecentlyUsed(){try{return(await j("/api/user-prefs/recent")).recentlyUsed}catch{return[]}},async trackUsage(e){try{return(await j("/api/user-prefs/recent",{method:"POST",body:JSON.stringify({name:e})})).recentlyUsed}catch{return[]}},async getCompatibleDimensions(e){const t=new URLSearchParams;e.length>0&&t.set("metrics",e.join(","));try{return(await j(`/api/semantic-layer/compatible-dims?${t.toString()}`)).dimensions}catch{return[]}},async getCompatibility(e){const t=new URLSearchParams;e.length>0&&t.set("metrics",e.join(","));const n=await j(`/api/semantic-layer/compatible-dims?${t.toString()}`);return{dimensions:n.dimensions??[],engine:n.engine??"native",incompatible:n.incompatible??[],degraded:n.degraded??null}},async composeQuery(e,t,n){try{return await j("/api/semantic-query",{method:"POST",body:JSON.stringify({metrics:e,dimensions:t,timeDimension:n})})}catch(r){return{error:r.message??"Failed to compose query"}}},async previewSemanticBuilder(e){try{return await j("/api/semantic-builder/preview",{method:"POST",body:JSON.stringify(e)})}catch(t){return t instanceof vt?{error:t.message,code:t.code,details:t.details}:{error:t instanceof Error?t.message:"Failed to preview semantic block"}}},async saveSemanticBuilder(e){return j("/api/semantic-builder/save",{method:"POST",body:JSON.stringify(e)})},async createMetric(e){try{return await j("/api/semantic-layer/metric",{method:"POST",body:JSON.stringify(e)})}catch(t){return{ok:!1,error:t.message??"Failed to create metric"}}},async describeTable(e){const t=e.split("."),n=t.length>1?t[t.length-1]:e,r=t.length>1?t.slice(0,-1).join("."):"",o=new URLSearchParams({table:n});r&&o.set("schema",r);try{return await j(`/api/describe-table?${o.toString()}`)}catch{return[]}},async fetchLineage(){try{return await j("/api/lineage")}catch{return{nodes:[],edges:[]}}},async searchLineage(e){try{return await j(`/api/lineage/search?q=${encodeURIComponent(e)}`)}catch{return{matches:[]}}},async queryLineage(e){var n;const t=new URLSearchParams;e.focus&&t.set("focus",e.focus),e.search&&t.set("search",e.search),(n=e.types)!=null&&n.length&&t.set("types",e.types.join(",")),e.domain&&t.set("domain",e.domain),e.upstreamDepth!==void 0&&t.set("upstreamDepth",String(e.upstreamDepth)),e.downstreamDepth!==void 0&&t.set("downstreamDepth",String(e.downstreamDepth));try{return await j(`/api/lineage/query?${t.toString()}`)}catch{return{graph:{nodes:[],edges:[]},matches:[]}}},async fetchLineageNode(e){try{return await j(`/api/lineage/node/${encodeURIComponent(e)}`)}catch{return null}},async fetchBusiness360(e){try{return await j(`/api/lineage/business-360/${encodeURIComponent(e)}`)}catch{return null}},async fetchBlockLineage(e){try{return await j(`/api/lineage/block/${encodeURIComponent(e)}`)}catch{return null}},async fetchImpactAnalysis(e){try{return await j(`/api/lineage/impact/${encodeURIComponent(e)}`)}catch{return null}},async fetchLineagePaths(e,t){try{const n=new URLSearchParams;t!=null&&t.maxDepth&&n.set("maxDepth",String(t.maxDepth)),t!=null&&t.maxPaths&&n.set("maxPaths",String(t.maxPaths));const r=n.toString(),o=`/api/lineage/paths/${encodeURIComponent(e)}${r?`?${r}`:""}`;return await j(o)}catch{return null}},async fetchGitStatus(){try{return await j("/api/git/status")}catch{return{inRepo:!1,branch:null,ahead:0,behind:0,changes:[]}}},async fetchGitLog(e=20){try{return await j(`/api/git/log?limit=${e}`)}catch{return{inRepo:!1,commits:[]}}},async fetchRunSnapshot(e){try{return await j(`/api/run-snapshot?path=${encodeURIComponent(e)}`)}catch{return{found:!1,snapshot:null}}},async saveRunSnapshot(e,t){await j("/api/run-snapshot",{method:"PUT",body:JSON.stringify({path:e,snapshot:t})})},async fetchGitDiff(e,t){try{const n=new URLSearchParams;e&&n.set("path",e),t&&n.set("staged","true");const r=n.toString();return await j(`/api/git/diff${r?`?${r}`:""}`)}catch{return{inRepo:!1,diff:"",before:null,after:null,diffReport:null}}},async fetchGitBranches(){try{return await j("/api/git/branches")}catch{return{inRepo:!1,current:null,branches:[]}}},async fetchGitRemote(){try{return await j("/api/git/remote")}catch{return{inRepo:!1,url:null,name:null}}},async fetchGitGovernedContext(){try{return await j("/api/git/governed-context")}catch{return{inRepo:!1,trackingReady:!1,legacyBroadIgnore:!1,domains:yr(),skills:yr(),artifacts:yr(),learning:yr()}}},async enableGitGovernedContextTracking(){try{return await j("/api/git/governed-context/enable",{method:"POST",body:"{}"})}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}},async gitStage(e){try{return await j("/api/git/stage",{method:"POST",body:JSON.stringify({paths:e})})}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}},async gitUnstage(e){try{return await j("/api/git/unstage",{method:"POST",body:JSON.stringify({paths:e})})}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}},async gitDiscard(e){try{return await j("/api/git/discard",{method:"POST",body:JSON.stringify({paths:e})})}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}},async gitCommit(e,t=!1){try{return await j("/api/git/commit",{method:"POST",body:JSON.stringify({message:e,stageAll:t})})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async gitPush(){try{return await j("/api/git/push",{method:"POST",body:"{}"})}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}},async gitPull(){try{return await j("/api/git/pull",{method:"POST",body:"{}"})}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}},async gitCreateBranch(e,t=!0){try{return await j("/api/git/branch",{method:"POST",body:JSON.stringify({name:e,checkout:t})})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async gitCreateReview(e){try{return await j("/api/git/review",{method:"POST",body:JSON.stringify(e)})}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}},async gitOpenReview(e){try{return await j("/api/git/review/open",{method:"POST",body:JSON.stringify(e)})}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}},async gitCheckout(e){try{return await j("/api/git/checkout",{method:"POST",body:JSON.stringify({name:e})})}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}},async listApps(){try{const{apps:e}=await j("/api/apps");return e}catch{return[]}},async listAppsStrict(){const{apps:e}=await j("/api/apps");return e},async recommendAppBlocks(e){try{const{blocks:t}=await j("/api/apps/recommend-blocks",{method:"POST",body:JSON.stringify(e)});return t}catch{return[]}},async createApp(e){return j("/api/apps",{method:"POST",body:JSON.stringify(e)})},async generateApp(e){try{return await j("/api/apps/generate",{method:"POST",body:JSON.stringify(e)})}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}},async createAppAiBuild(e){try{return await j("/api/apps/ai-builds",{method:"POST",body:JSON.stringify(e)})}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}},async getAppAiBuild(e){try{const{session:t}=await j(`/api/apps/ai-builds/${encodeURIComponent(e)}`);return t}catch{return null}},async proposeAppAiBuild(e){try{return await j("/api/apps/ai-builds/propose",{method:"POST",body:JSON.stringify(e)})}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}},async commitAppAiBuild(e,t={}){try{return await j(`/api/apps/ai-builds/${encodeURIComponent(e)}/commit`,{method:"POST",body:JSON.stringify(t)})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async getApp(e){try{return await j(`/api/apps/${encodeURIComponent(e)}`)}catch{return null}},async attachAppNotebook(e,t){try{return await j(`/api/apps/${encodeURIComponent(e)}/notebooks`,{method:"POST",body:JSON.stringify(t)})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async listAppNotebookCandidates(e){try{const{notebooks:t}=await j(`/api/apps/${encodeURIComponent(e)}/notebook-candidates`);return t}catch{return[]}},async createAppNotebook(e,t){try{return await j(`/api/apps/${encodeURIComponent(e)}/notebooks/create`,{method:"POST",body:JSON.stringify(t)})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async previewAppNotebook(e,t){try{return await j(`/api/apps/${encodeURIComponent(e)}/notebooks/preview?path=${encodeURIComponent(t)}`)}catch{return null}},async runAppNotebook(e,t){try{return await j(`/api/apps/${encodeURIComponent(e)}/notebooks/run`,{method:"POST",body:JSON.stringify({path:t})})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async listAppConversations(e){try{const{conversations:t}=await j(`/api/apps/${encodeURIComponent(e)}/conversations`);return t}catch{return[]}},async createAppConversation(e,t){try{return await j(`/api/apps/${encodeURIComponent(e)}/conversations`,{method:"POST",body:JSON.stringify(t)})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async getAppConversation(e,t){try{const{conversation:n}=await j(`/api/apps/${encodeURIComponent(e)}/conversations/${encodeURIComponent(t)}`);return n}catch{return null}},async updateAppConversation(e,t,n){try{return await j(`/api/apps/${encodeURIComponent(e)}/conversations/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(n)})}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}},async deleteAppConversation(e,t){try{return await j(`/api/apps/${encodeURIComponent(e)}/conversations/${encodeURIComponent(t)}`,{method:"DELETE"})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async listAppInvestigations(e,t){try{const n=new URLSearchParams;t&&n.set("dashboardId",t);const r=n.toString(),{investigations:o}=await j(`/api/apps/${encodeURIComponent(e)}/investigations${r?`?${r}`:""}`);return o}catch{return[]}},async createAppInvestigation(e,t){try{return await j(`/api/apps/${encodeURIComponent(e)}/investigations`,{method:"POST",body:JSON.stringify(t)})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async getAppInvestigation(e,t){try{const{investigation:n}=await j(`/api/apps/${encodeURIComponent(e)}/investigations/${encodeURIComponent(t)}`);return n}catch{return null}},async runAppInvestigation(e,t,n){try{return await j(`/api/apps/${encodeURIComponent(e)}/investigations/${encodeURIComponent(t)}/run`,{method:"POST",body:JSON.stringify(n??{})})}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}},async pinAppInvestigation(e,t,n){try{return await j(`/api/apps/${encodeURIComponent(e)}/investigations/${encodeURIComponent(t)}/pin`,{method:"POST",body:JSON.stringify(n??{})})}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}},async getDashboard(e,t){try{return await j(`/api/apps/${encodeURIComponent(e)}/dashboards/${encodeURIComponent(t)}`)}catch{return null}},async dashboardFilterOptions(e,t){try{const n=new URLSearchParams({block:e,column:t});return await j(`/api/dashboard/filter-options?${n.toString()}`)}catch{return null}},async getAppEditorCatalog(e,t){try{const n=new URLSearchParams;t!=null&&t.domain&&n.set("domain",t.domain),(t==null?void 0:t.certifiedOnly)===!1&&n.set("certifiedOnly","false");const r=n.toString();return await j(`/api/apps/${encodeURIComponent(e)}/editor/catalog${r?`?${r}`:""}`)}catch{return null}},async createAppDashboard(e,t){try{return await j(`/api/apps/${encodeURIComponent(e)}/dashboards`,{method:"POST",body:JSON.stringify(t)})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async patchDashboardLayout(e,t,n){try{return await j(`/api/apps/${encodeURIComponent(e)}/dashboards/${encodeURIComponent(t)}/layout`,{method:"PATCH",body:JSON.stringify({layout:n})})}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}},async askApp(e,t){try{return await j(`/api/apps/${encodeURIComponent(e)}/ask`,{method:"POST",body:JSON.stringify(t)})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async promoteApp(e,t){try{return await j(`/api/apps/${encodeURIComponent(e)}/promote`,{method:"POST",body:JSON.stringify(t??{})})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async recommendVisualization(e){try{return await j("/api/visualizations/recommend",{method:"POST",body:JSON.stringify(e)})}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}},async recommendDashboardTile(e,t,n){try{return await j(`/api/apps/${encodeURIComponent(e)}/dashboards/${encodeURIComponent(t)}/tiles/recommend`,{method:"POST",body:JSON.stringify(n)})}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}},async createAiPin(e,t){try{return await j(`/api/apps/${encodeURIComponent(e)}/ai-pins`,{method:"POST",body:JSON.stringify(t)})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async listAiPins(e,t){try{const n=new URLSearchParams;t&&n.set("dashboardId",t);const r=n.toString(),{pins:o}=await j(`/api/apps/${encodeURIComponent(e)}/ai-pins${r?`?${r}`:""}`);return o}catch{return[]}},async refreshAiPin(e,t){try{return await j(`/api/apps/${encodeURIComponent(e)}/ai-pins/${encodeURIComponent(t)}/refresh`,{method:"POST"})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async promoteAiPin(e,t){try{return await j(`/api/apps/${encodeURIComponent(e)}/ai-pins/${encodeURIComponent(t)}/promote`,{method:"POST"})}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}},async fetchScopedLineage(e){try{const t=new URLSearchParams;return e.domain&&t.set("domain",e.domain),e.appId&&t.set("appId",e.appId),e.dashboardId&&t.set("dashboardId",e.dashboardId),e.blockId&&t.set("blockId",e.blockId),await j(`/api/lineage/scope?${t.toString()}`)}catch{return null}},async runDashboard(e,t,n){try{return await j(`/api/apps/${encodeURIComponent(e)}/dashboards/${encodeURIComponent(t)}/run`,{method:"POST",body:JSON.stringify({variables:n??{}})})}catch{return null}},async getDashboardStory(e,t,n){try{return await j(`/api/apps/${encodeURIComponent(e)}/dashboards/${encodeURIComponent(t)}/story`,{method:"POST",body:JSON.stringify({runId:n})})}catch{return null}},async saveDashboard(e,t,n){try{return{ok:!!(await j(`/api/apps/${encodeURIComponent(e)}/dashboards/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify(n)})).ok}}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}},async getPersona(){try{const{persona:e}=await j("/api/persona");return e}catch{return null}},async setPersona(e,t){try{const{persona:n}=await j("/api/persona",{method:"POST",body:JSON.stringify({userId:e,appId:t})});return n}catch{return null}},async clearPersona(){try{await j("/api/persona",{method:"DELETE"})}catch{}},async getSkills(){return j("/api/skills")},async getSkillPathSettings(){return j("/api/skills/settings")},async updateSkillPath(e){return j("/api/skills/settings",{method:"PUT",body:JSON.stringify({path:e})})},async getSkillOptions(e=""){const t=e.trim()?`?q=${encodeURIComponent(e.trim())}`:"";return j(`/api/skills/options${t}`)},async createSkill(e){return j("/api/skills",{method:"POST",body:JSON.stringify({skill:e})})},async updateSkill(e,t){return j(`/api/skills/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify({skill:t})})},async getEmbeddingSettings(){return j("/api/settings/embeddings")},async saveEmbeddingSettings(e){return j("/api/settings/embeddings",{method:"PUT",body:JSON.stringify(e)})},async listEmbeddingModels(e){const t=e?`?endpoint=${encodeURIComponent(e)}`:"";return j(`/api/settings/embeddings/models${t}`)},async installEmbeddingModel(e,t){return j("/api/settings/embeddings/install",{method:"POST",body:JSON.stringify({model:e,endpoint:t})})},async testEmbeddingProvider(){return j("/api/settings/embeddings/test",{method:"POST"})},async reindexEmbeddings(){return j("/api/settings/embeddings/reindex",{method:"POST"})},async deleteSkill(e){return j(`/api/skills/${encodeURIComponent(e)}`,{method:"DELETE"})},async getDomains(){try{return await j("/api/domains")}catch{return{domains:[]}}},async createDomain(e){return j("/api/domains",{method:"POST",body:JSON.stringify({domain:e})})},async updateDomain(e,t){return j(`/api/domains/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify({domain:t})})},async deleteDomain(e){return j(`/api/domains/${encodeURIComponent(e)}`,{method:"DELETE"})},async startContextBootstrap(e={}){return j("/api/context-bootstrap",{method:"POST",body:JSON.stringify(e)})},async getContextBootstrap(e){return j(`/api/context-bootstrap/${encodeURIComponent(e)}`)},async getLatestContextBootstrap(){return(await j("/api/context-bootstrap/latest")).session??null},async saveContextBootstrapSelected(e,t){return j(`/api/context-bootstrap/${encodeURIComponent(e)}/save-selected`,{method:"POST",body:JSON.stringify({candidateIds:t})})}},ib={source_table:"#8a8d96",dbt_model:"#4a74c9",dbt_source:"#4a74c9",term:"#0a6b5e",block:"#b26b1f",business_view:"#c14545",metric:"#6b5dd3",dimension:"#0a6b5e",domain:"#7c5cff",chart:"#c14590",notebook:"#2e8b57",dashboard:"#2e8b57",app:"#2e8b57"},ab={source_table:"TBL",dbt_model:"DBT",dbt_source:"SRC",term:"TERM",block:"BLK",business_view:"VIEW",metric:"MET",dimension:"DIM",domain:"DOM",chart:"CHT",notebook:"NB",dashboard:"DASH",app:"APP"},Wc={source_table:"Source Table",dbt_model:"dbt Model",dbt_source:"dbt Source",term:"Business Term",block:"DQL Block",business_view:"Business View",metric:"Metric",dimension:"Dimension",domain:"Domain",chart:"Chart",notebook:"Notebook",dashboard:"Dashboard",app:"App"},L1={reads_from:"#8b949e",feeds_into:"#56d364",defines:"#39c5cf",composes:"#f2cc60",aggregates:"#388bfd",visualizes:"#f778ba",depends_on:"#ff7b72",contains:"#d2a8ff",crosses_domain:"#d2a8ff",certified_by:"#56d364"},N1={reads_from:"reads from",feeds_into:"feeds into",defines:"defines",composes:"composes into",aggregates:"aggregates into",visualizes:"visualizes",depends_on:"dbt depends on",contains:"contains",crosses_domain:"crosses domain",certified_by:"certified by"},lb={source:"#79c0ff",transform:"#ff7b72",answer:"#56d364",consumption:"#d2a8ff"},Ui={source:"Sources",transform:"Transform",answer:"Answer",consumption:"Consumption"},Wi=["source","transform","answer","consumption"],B1=["term","business_view","block","metric","dimension","domain","source_table","dbt_source","dbt_model","chart","notebook","dashboard","app"],F1=["source_table","dbt_source","dbt_model"],cb=["term","domain","business_view","metric","dimension","block"];[...cb];function db(e){if(e.layer)return e.layer;switch(e.type){case"source_table":case"dbt_source":return"source";case"dbt_model":return"transform";case"term":case"block":case"business_view":case"metric":case"dimension":case"domain":return"answer";case"chart":case"notebook":case"dashboard":case"app":return"consumption";default:return"answer"}}function ub(){const{state:e,dispatch:t}=ve(),n=e.inspectorContext;return s.jsxs("aside",{"aria-label":"Inspector",style:{width:320,borderLeft:`1px solid ${le("borderSubtle")}`,background:le("surfaceBase"),color:le("textPrimary"),display:"flex",flexDirection:"column",overflow:"hidden",flexShrink:0},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:`${he[3]}px ${he[4]}px`,borderBottom:`1px solid ${le("borderSubtle")}`},children:[s.jsx("div",{style:{fontSize:Fe.sm,fontWeight:ts.semibold},children:n?pb(n):"Inspector"}),s.jsx("button",{onClick:()=>t({type:"SET_INSPECTOR",open:!1}),"aria-label":"Close inspector",style:{background:"transparent",border:"none",color:le("textMuted"),cursor:"pointer",fontSize:Fe.md,padding:2,borderRadius:Lt.sm},children:"×"})]}),s.jsx("div",{style:{flex:1,overflow:"auto",padding:he[4]},children:n?s.jsx(fb,{context:n}):s.jsx(yb,{})})]})}function pb(e){switch(e.kind){case"cell":return"Cell";case"lineage-node":return"Lineage node";case"metric":return"Metric"}}function fb({context:e}){return e.kind==="cell"?s.jsx(hb,{cellId:e.cellId}):e.kind==="lineage-node"?s.jsx(mb,{nodeId:e.nodeId}):s.jsx(gb,{name:e.name})}function hb({cellId:e}){const{state:t}=ve(),n=t.cells.find(r=>r.id===e);return n?s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:he[3],fontSize:Fe.sm},children:[s.jsx(Ae,{label:"Type",children:n.type}),s.jsx(Ae,{label:"ID",children:s.jsx("code",{style:{fontFamily:"var(--dql-font-mono, monospace)"},children:n.id})}),s.jsxs(Ae,{label:"Length",children:[n.content.length," chars"]}),n.status&&s.jsx(Ae,{label:"Status",children:n.status})]}):s.jsx(Lr,{children:"No matching cell in the active notebook."})}function mb({nodeId:e}){const[t,n]=u.useState(null),[r,o]=u.useState(!0);if(u.useEffect(()=>{let a=!1;return o(!0),N.fetchLineageNode(e).then(d=>{a||(n(d),o(!1))}).catch(()=>{a||o(!1)}),()=>{a=!0}},[e]),r)return s.jsx(Lr,{children:"Loading node…"});if(!t||!t.node)return s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:he[3]},children:[s.jsx(Ae,{label:"Node ID",children:s.jsx("code",{style:{fontFamily:"var(--dql-font-mono, monospace)"},children:e})}),s.jsx(Lr,{children:"No metadata available for this node."})]});const i=t.node,l=i.metadata??{};return s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:he[3]},children:[s.jsx(Ae,{label:"Name",children:i.name??e}),s.jsx(Ae,{label:"Type",children:Wc[i.type]??i.type}),i.domain&&s.jsx(Ae,{label:"Domain",children:i.domain}),i.owner&&s.jsx(Ae,{label:"Owner",children:i.owner}),i.status&&s.jsx(Ae,{label:"Status",children:i.status}),typeof l.termType=="string"&&s.jsx(Ae,{label:"Term Type",children:l.termType}),typeof l.description=="string"&&s.jsx(Ae,{label:"Description",children:l.description}),Array.isArray(l.identifiers)&&l.identifiers.length>0&&s.jsx(Ae,{label:"Identifiers",children:l.identifiers.map(String).join(", ")}),Array.isArray(l.synonyms)&&l.synonyms.length>0&&s.jsx(Ae,{label:"Synonyms",children:l.synonyms.map(String).join(", ")}),typeof l.businessOutcome=="string"&&s.jsx(Ae,{label:"Business Outcome",children:l.businessOutcome}),i.layer&&s.jsx(Ae,{label:"Layer",children:i.layer}),s.jsx(Ae,{label:"Upstream",children:t.incoming.length}),s.jsx(Ae,{label:"Downstream",children:t.outgoing.length}),(i.path||l.filePath)&&s.jsx(Ae,{label:"Path",children:s.jsx("code",{style:{fontFamily:"var(--dql-font-mono, monospace)",fontSize:Fe.xs},children:i.path??l.filePath})})]})}function gb({name:e}){return s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:he[3]},children:[s.jsx(Ae,{label:"Metric",children:e}),s.jsx(Lr,{children:"Definition, dimensions, and governance surface will render here."})]})}function Ae({label:e,children:t}){return s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[s.jsx("div",{style:{fontSize:Fe.xs,color:le("textMuted"),textTransform:"uppercase",letterSpacing:.5,fontWeight:ts.medium},children:e}),s.jsx("div",{style:{fontSize:Fe.sm,color:le("textPrimary")},children:t})]})}function Lr({children:e}){return s.jsx("div",{style:{fontSize:Fe.sm,color:le("textSecondary"),lineHeight:1.5,background:le("surfaceSunken"),border:`1px solid ${le("borderSubtle")}`,borderRadius:Lt.md,padding:he[3]},children:e})}function yb(){return s.jsx("div",{style:{fontSize:Fe.sm,color:le("textMuted"),lineHeight:1.5},children:"Select a cell, lineage node, or metric to inspect its details here."})}const Pn={appBg:"--color-bg-primary",sidebarBg:"--color-bg-secondary",activityBarBg:"--color-bg-sunken",headerBg:"--color-bg-toolbar",headerBorder:"--color-border-primary",cellBg:"--color-bg-card",cellBorder:"--color-border-subtle",cellBorderActive:"--color-accent-blue",cellBorderRunning:"--color-status-success",textPrimary:"--color-text-primary",textSecondary:"--color-text-secondary",textMuted:"--color-text-tertiary",editorBg:"--color-bg-surface",editorBorder:"--color-border-subtle",tableBorder:"--color-border-subtle",tableHeaderBg:"--color-bg-secondary",tableRowHover:"--color-bg-hover",accent:"--color-accent-blue",accentHover:"--color-accent-blue",success:"--color-status-success",error:"--color-status-error",warning:"--color-status-warning",btnBg:"--color-bg-tertiary",btnBorder:"--color-border-primary",btnHover:"--color-bg-hover",sidebarItemHover:"--color-bg-hover",sidebarItemActive:"--color-bg-active",scrollbarThumb:"--color-border-secondary",modalBg:"--color-bg-secondary",modalOverlay:"--color-bg-overlay",inputBg:"--color-bg-sunken",inputBorder:"--color-border-subtle",pillBg:"--color-bg-tertiary",font:"--font-ui",fontMono:"--font-mono",fontSerif:"--font-ui"},Ki={appBg:"#fbfaf7",sidebarBg:"#fbfaf7",activityBarBg:"#ffffff",headerBg:"#ffffff",headerBorder:"#e9e6e0",cellBg:"#ffffff",cellBorder:"#e9e6e0",cellBorderActive:"#6b5dd3",cellBorderRunning:"#2e8b57",textPrimary:"#1a1a1a",textSecondary:"#4a4a52",textMuted:"#8a8d96",editorBg:"#fbfaf7",editorBorder:"#e9e6e0",tableBorder:"#f0eee9",tableHeaderBg:"#faf9f7",tableRowHover:"#f3f0ea",accent:"#6b5dd3",accentHover:"#5c4fc2",success:"#2e8b57",error:"#c14545",warning:"#b26b1f",btnBg:"#ffffff",btnBorder:"#e9e6e0",btnHover:"#f3f0ea",sidebarItemHover:"#f3f0ea",sidebarItemActive:"#f3f0fb",scrollbarThumb:"#d9d5cc",modalBg:"#ffffff",modalOverlay:"rgba(26,26,26,0.40)",inputBg:"#fbfaf7",inputBorder:"#e9e6e0",pillBg:"#f3f0ea",font:"'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",fontMono:"'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Monaco, Consolas, monospace",fontSerif:"'Inter', -apple-system, BlinkMacSystemFont, sans-serif"};function Vi(e){if(typeof document>"u")return Ki[e];const t=Pn[e];return getComputedStyle(document.documentElement).getPropertyValue(t).trim()||Ki[e]}function xb(){return new Proxy({},{get(e,t){if(typeof t=="string"&&t in Pn)return Vi(t)},has(e,t){return typeof t=="string"&&t in Pn},ownKeys(){return Object.keys(Pn)},getOwnPropertyDescriptor(e,t){if(!(typeof t!="string"||!(t in Pn)))return{enumerable:!0,configurable:!0,value:Vi(t)}}})}const Kt=xb(),ze={obsidian:Kt,paper:Kt,white:Kt,dark:Kt,light:Kt,midnight:Kt,arctic:Kt};function it(e,t="0 0 24 24"){return function({size:r=16,strokeWidth:o=1.75,...i}){return s.jsx("svg",{width:r,height:r,viewBox:t,fill:"none",stroke:"currentColor",strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round",...i,children:e})}}const bb=it(s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3",y:"3",width:"8",height:"8",rx:"1.5"}),s.jsx("rect",{x:"13",y:"3",width:"8",height:"8",rx:"1.5"}),s.jsx("rect",{x:"3",y:"13",width:"8",height:"8",rx:"1.5"}),s.jsx("rect",{x:"13",y:"13",width:"8",height:"8",rx:"1.5"})]}));it(s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 2l8 3v6c0 5-3.5 9-8 11-4.5-2-8-6-8-11V5l8-3z"}),s.jsx("path",{d:"M9 12l2 2 4-4"})]}));const vb=it(s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"5",cy:"12",r:"2"}),s.jsx("circle",{cx:"19",cy:"5",r:"2"}),s.jsx("circle",{cx:"19",cy:"19",r:"2"}),s.jsx("path",{d:"M7 12l10-6M7 12l10 6"})]})),z1=it(s.jsxs(s.Fragment,{children:[s.jsx("ellipse",{cx:"12",cy:"5",rx:"8",ry:"3"}),s.jsx("path",{d:"M4 5v6c0 1.66 3.58 3 8 3s8-1.34 8-3V5"}),s.jsx("path",{d:"M4 11v6c0 1.66 3.58 3 8 3s8-1.34 8-3v-6"})]}));it(s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M4 4h8a8 8 0 010 16H4z"}),s.jsx("path",{d:"M16 20l4 4"})]}));it(s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M3 3v18h18"}),s.jsx("path",{d:"M7 15l4-4 4 4 5-7"})]}));it(s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),s.jsx("path",{d:"M3 9h18M9 3v18"})]}));it(s.jsxs(s.Fragment,{children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),s.jsx("path",{d:"M8 12h8M12 8v8"})]}));const q1=it(s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M4 7h16M4 12h16M4 17h10"}),s.jsx("circle",{cx:"18",cy:"17",r:"2"})]}));it(s.jsx(s.Fragment,{children:s.jsx("path",{d:"M3 5h18l-7 9v5l-4-2v-3L3 5z"})}));it(s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M4 4h10l6 6v10H4z"}),s.jsx("path",{d:"M14 4v6h6"}),s.jsx("path",{d:"M8 14l3 3 5-5"})]}));it(s.jsx(s.Fragment,{children:s.jsx("path",{d:"M21 12a8 8 0 01-11.5 7.2L4 21l1.8-5.5A8 8 0 1121 12z"})}));const Kc=44,Vc=188,Hc="dql-activitybar-expanded";function Sb(){var e;if(typeof window>"u")return!1;try{return((e=window.localStorage)==null?void 0:e.getItem(Hc))==="1"}catch{return!1}}function kb(e){var t;try{(t=window.localStorage)==null||t.setItem(Hc,e?"1":"0")}catch{}}function Hi({title:e,icon:t,active:n,expanded:r,onClick:o,t:i}){const[l,a]=u.useState(!1),d=s.jsxs("button",{"aria-label":e,onClick:o,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:{width:r?Vc-12:Kc-8,height:32,display:"flex",alignItems:"center",justifyContent:r?"flex-start":"center",gap:10,padding:r?"0 10px":0,marginLeft:r?6:4,marginRight:r?6:4,background:n?i.accent+"1f":l?i.textPrimary+"0f":"transparent",border:"none",borderRadius:6,cursor:"pointer",color:n?i.accent:l?i.textPrimary:i.textSecondary,transition:"background 0.15s, color 0.15s",fontFamily:i.font,fontSize:13,fontWeight:n?500:400,textAlign:"left",overflow:"hidden",whiteSpace:"nowrap"},children:[s.jsx("span",{style:{display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,width:18,height:18},children:t}),r&&s.jsx("span",{style:{flex:1,textOverflow:"ellipsis",overflow:"hidden"},children:e})]});return r?d:s.jsx(gl,{content:e,side:"right",children:d})}function wb(){const{state:e,dispatch:t}=ve(),n=ze[e.themeMode],[r,o]=u.useState(Sb);u.useEffect(()=>{kb(r)},[r]);function i(d){if(d==="home"||d==="ask"||d==="modeling"){t({type:"SET_MAIN_VIEW",view:d});return}if(d==="lineage"){t({type:"SET_SIDEBAR_PANEL",panel:"lineage"});return}if(d==="connection"||d==="git"||d==="apps"||d==="readiness"||d==="skills"||d==="domains"||d==="settings"){t({type:"SET_SIDEBAR_PANEL",panel:d});return}e.sidebarPanel===d&&e.sidebarOpen?t({type:"TOGGLE_SIDEBAR"}):t({type:"SET_SIDEBAR_PANEL",panel:d})}const l=[{label:"Insights",items:[{key:"apps",title:"Apps",icon:s.jsx(Xy,{size:16,strokeWidth:1.75}),active:e.mainView==="apps"},{key:"ask",title:"Ask",icon:s.jsx(Wy,{size:16,strokeWidth:1.75}),active:e.mainView==="ask"}]},{label:"Build",items:[{key:"files",title:"Notebooks",icon:s.jsx(Ms,{size:16,strokeWidth:1.75}),active:e.sidebarPanel==="files"&&e.sidebarOpen},{key:"block_library",title:"Blocks",icon:s.jsx(bb,{size:16}),active:e.sidebarPanel==="block_library"&&e.sidebarOpen},{key:"lineage",title:"Lineage",icon:s.jsx(vb,{size:16}),active:e.mainView==="lineage"||e.mainView==="lineage_detail"}]},{label:"Govern",items:[{key:"domains",title:"Domains",icon:s.jsx(Jo,{size:16,strokeWidth:1.75}),active:e.mainView==="domains"||e.mainView==="modeling"||e.mainView==="skills"},{key:"git",title:"Source control",icon:s.jsx(Sn,{size:16,strokeWidth:1.75}),active:e.mainView==="git"},{key:"settings",title:"Settings",icon:s.jsx(px,{size:16,strokeWidth:1.75}),active:e.mainView==="settings"||e.mainView==="connection"}]}],a=[{key:"help",title:"Help",icon:s.jsx(ny,{size:16,strokeWidth:1.75}),active:e.mainView==="help",onClick:()=>t({type:"SET_MAIN_VIEW",view:"help"})}];return s.jsxs("div",{style:{width:r?Vc:Kc,flexShrink:0,background:n.activityBarBg,borderRight:`1px solid ${n.headerBorder}`,display:"flex",flexDirection:"column",paddingTop:6,paddingBottom:6,gap:2,userSelect:"none",transition:"width 0.18s ease",overflow:"hidden"},children:[s.jsx("div",{style:{display:"flex",justifyContent:r?"flex-end":"center",paddingLeft:r?6:0,paddingRight:r?6:0,marginBottom:4},children:s.jsx(gl,{content:r?"Collapse":"Expand",side:"right",children:s.jsx("button",{"aria-label":r?"Collapse sidebar rail":"Expand sidebar rail",onClick:()=>o(d=>!d),style:{width:28,height:26,display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",border:"none",borderRadius:5,cursor:"pointer",color:n.textMuted,padding:0},onMouseEnter:d=>{d.currentTarget.style.color=n.textPrimary,d.currentTarget.style.background=n.textPrimary+"0f"},onMouseLeave:d=>{d.currentTarget.style.color=n.textMuted,d.currentTarget.style.background="transparent"},children:r?s.jsx(Jg,{size:14,strokeWidth:2}):s.jsx(Yg,{size:14,strokeWidth:2})})})}),l.map((d,c)=>s.jsxs(De.Fragment,{children:[c>0?s.jsx("div",{style:{height:1,margin:r?"8px 10px 2px":"8px 12px",background:n.headerBorder}}):null,r?s.jsx("div",{style:{fontSize:10,fontWeight:600,color:n.textMuted,letterSpacing:"0.04em",padding:"4px 12px 2px"},children:d.label}):null,d.items.map(f=>s.jsx(Hi,{title:f.title,icon:f.icon,active:f.active,expanded:r,onClick:()=>i(f.key),t:n},f.key))]},d.label)),s.jsx("div",{style:{flex:1}}),a.map(d=>s.jsx(Hi,{title:d.title,icon:d.icon,active:d.active,expanded:r,onClick:d.onClick,t:n},d.key))]})}const jb=2e4,U1="application/dql-semantic-ref",Gi=new Map;let Vn=null;function Cb(e){N.trackUsage(e),window.dispatchEvent(new CustomEvent("dql:semantic-used",{detail:{name:e}}))}async function Ji(e,t){const n=`${e}:${t.toLowerCase()}`,r=Gi.get(n);if(r&&Date.now()<r.expiresAt)return r.items;const o=new URLSearchParams({kind:e,q:t,limit:"50"}),i=await fetch(`${window.location.origin}/api/editor/completions?${o.toString()}`);if(!i.ok)throw new Error(`Failed to load semantic completions: HTTP ${i.status}`);const l=await i.json(),a=Array.isArray(l.completions)?l.completions:[];return Gi.set(n,{items:a,expiresAt:Date.now()+jb}),a}function Gc(e,t,n){const r=n??e.state.selection.main.from;e.dispatch({changes:{from:r,to:n??e.state.selection.main.to,insert:t},selection:{anchor:r+t.length}}),e.focus()}function W1(e){Vn=e}function K1(e){Vn===e&&(Vn=null)}function Eb(e){return Vn?(Gc(Vn,e),!0):!1}function V1(e,t,n){const r=n?e.posAtCoords(n)??e.state.selection.main.from:e.state.selection.main.from;Gc(e,t,r)}function Qi(e,t,n){return{label:e.name,detail:e.type==="metric"?"@metric":"@dim",type:e.type==="metric"?"function":"variable",info:`${e.label}${e.description?`
406
406
  ${e.description}`:""}${e.sql?`
407
407
  ${e.sql}`:""}`,apply(r){const i=r.state.sliceDoc(n,n+1)===")"?e.name:`${e.name})`;r.dispatch({changes:{from:t,to:n,insert:i},selection:{anchor:t+i.length}}),Cb(e.name)}}}function Ab(e){return{from:e,options:[{label:"@metric(",detail:"semantic metric",type:"function",apply(t,n,r,o){t.dispatch({changes:{from:r,to:o,insert:"@metric("},selection:{anchor:r+8}})}},{label:"@dim(",detail:"semantic dimension",type:"function",apply(t,n,r,o){t.dispatch({changes:{from:r,to:o,insert:"@dim("},selection:{anchor:r+5}})}}]}}const H1=async e=>{const{state:t,pos:n}=e,r=t.sliceDoc(Math.max(0,n-120),n),o=/@metric\(([^)]*)$/i.exec(r);if(o){const a=o[1].trim().toLowerCase(),d=n-o[1].length,c=await Ji("metric",a);return{from:d,options:c.map(f=>Qi(f,d,n)),validFor:/^[\w-]*$/}}const i=/@dim\(([^)]*)$/i.exec(r);if(i){const a=i[1].trim().toLowerCase(),d=n-i[1].length,c=await Ji("dimension",a);return{from:d,options:c.map(f=>Qi(f,d,n)),validFor:/^[\w-]*$/}}const l=/@([md][a-z_]*)?$/i.exec(r);return l?Ab(n-l[0].length):(e.explicit,null)};function G1(e){if(!e)return null;try{const t=JSON.parse(e);return(t.type==="metric"||t.type==="dimension")&&t.name&&t.reference?{type:t.type,name:t.name,reference:t.reference}:null}catch{return null}}const Tb=6,Rb=999,_b={xs:{height:22,fontSize:10.5,paddingX:7,gap:4,icon:11},sm:{height:26,fontSize:11.5,paddingX:9,gap:5,icon:12},md:{height:32,fontSize:12.5,paddingX:12,gap:6,icon:14},lg:{height:54,fontSize:12.5,paddingX:17,gap:7,icon:15}};function we(e,t={}){const{variant:n="secondary",size:r="sm",active:o=!1,disabled:i=!1,pill:l=!1}=t,a=_b[r],d=n==="danger"?e.error:n==="success"?e.success:n==="accent"?e.accent:void 0,c={boxSizing:"border-box",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:a.gap,height:a.height,padding:`0 ${a.paddingX}px`,borderRadius:l?Rb:Tb,fontSize:a.fontSize,fontWeight:n==="primary"?700:600,fontFamily:e.font,lineHeight:1,whiteSpace:"nowrap",cursor:i?"not-allowed":"pointer",opacity:i?.55:1,transition:"background 0.15s, border-color 0.15s, color 0.15s"};return n==="primary"?{...c,background:e.accent,border:`1px solid ${e.accent}`,color:"#ffffff"}:n==="ghost"?{...c,background:o?`${e.accent}14`:"transparent",border:"1px solid transparent",color:o?e.accent:e.textMuted,fontWeight:550}:d?{...c,background:o?`${d}22`:`${d}12`,border:`1px solid ${d}${o?"66":"33"}`,color:d}:{...c,background:o?`${e.accent}14`:e.btnBg,border:`1px solid ${o?e.accent:e.btnBorder}`,color:o?e.accent:e.textSecondary}}function Jc(e){var r,o;if(e.objectType==="staged_dataset"||e.storageMode==="staged")return{kind:"staged",label:"snapshot",title:"Bounded warehouse snapshot in the local workspace",tone:"warning"};const t=(r=e.path.toLowerCase().match(/\.([a-z0-9]+)$/))==null?void 0:r[1],n=e.source==="file"||e.objectType==="dataset";return n&&t==="csv"?{kind:"csv",label:e.storageMode==="project"?"project csv":"csv",title:e.storageMode==="project"?"Project-controlled CSV dataset":"Local CSV dataset",tone:e.storageMode==="project"?"success":"accent"}:n&&(t==="json"||t==="jsonl"||t==="ndjson")?{kind:"json",label:"json",title:"Local JSON dataset",tone:"accent"}:n&&t==="parquet"?{kind:"parquet",label:"parquet",title:"Local Parquet dataset",tone:"accent"}:(o=e.objectType)!=null&&o.toLowerCase().includes("view")?{kind:"view",label:"view",title:"Warehouse view",tone:"muted"}:{kind:"table",label:"table",title:"Warehouse table",tone:"accent"}}function $b({table:e,colors:t,size:n=13}){const r=Jc(e),o=t[r.tone],i={size:n,color:o,strokeWidth:2,style:{flexShrink:0}},l=r.kind==="csv"?s.jsx(ky,{...i}):r.kind==="json"?s.jsx(fy,{...i}):r.kind==="parquet"||r.kind==="staged"?s.jsx(Is,{...i}):r.kind==="view"?s.jsx(Lc,{...i}):s.jsx(tr,{...i});return s.jsx("span",{"aria-label":r.title,title:r.title,style:{display:"inline-flex"},children:l})}const Ob=new Set(["metric","measure","dimension","time_dimension"]);function so(e){var r;if(typeof((r=e.meta)==null?void 0:r.reference)=="string"&&e.meta.reference.trim())return e.meta.reference;const t=`${e.kind}:`;if(e.id.startsWith(t))return e.id.slice(t.length);const n=e.id.lastIndexOf(":");return n>=0?e.id.slice(n+1):e.id}function Zo(e){const t=so(e);return e.kind==="metric"||e.kind==="measure"?`@metric(${t})`:`@dim(${t})`}function Qc(e){var r,o;const t=typeof((r=e.meta)==null?void 0:r.qualifiedName)=="string"?e.meta.qualifiedName.trim():"";return t||(typeof((o=e.meta)==null?void 0:o.localName)=="string"?e.meta.localName.trim():"")||so(e)}function Ls(e,t){return!t||e.label.toLowerCase().includes(t)||e.id.toLowerCase().includes(t)||so(e).toLowerCase().includes(t)||Qc(e).toLowerCase().includes(t)?!0:(e.children??[]).some(n=>Ls(n,t))}function Yc(e){var r;const t=[],n=new Map;for(const o of e){const i=(((r=o.children)==null?void 0:r.length)??0)>0,l=i?`group:${o.label.toLowerCase()}`:`leaf:${Zo(o).toLowerCase()}`,a=n.get(l);if(a){i&&a.children&&(a.children=a.children.concat(o.children??[]));continue}const d=o.children?{...o,children:[...o.children]}:o;n.set(l,d),t.push(d)}for(const o of t)o.children&&(o.children=Yc(o.children));return t}const ko={metric:{Icon:Py,tone:e=>e.accent},measure:{Icon:xx,tone:e=>e.accent},dimension:{Icon:wx,tone:e=>e.success},time_dimension:{Icon:oy,tone:e=>e.warning},entity:{Icon:Fg,tone:e=>e.textSecondary},segment:{Icon:$y,tone:e=>e.textMuted},hierarchy:{Icon:Sn,tone:e=>e.textMuted},pre_aggregation:{Icon:Is,tone:e=>e.textMuted},cube:{Icon:Jo,tone:e=>e.textSecondary},semantic_model:{Icon:Jo,tone:e=>e.textSecondary},saved_query:{Icon:Ng,tone:e=>e.textMuted},provider:{Icon:Bn,tone:e=>e.textMuted},domain:{Icon:Bn,tone:e=>e.textMuted},group:{Icon:Bn,tone:e=>e.textMuted}};function Pb(e){var t;if(e.kind==="group"){const n=typeof((t=e.meta)==null?void 0:t.objectKind)=="string"?e.meta.objectKind:"";return ko[n]??ko.group}return ko[e.kind]}function Db({tree:e,themeMode:t,search:n="",onInsert:r,selectionMode:o=!1,selected:i=new Set,onToggleSelection:l,canSelect:a=()=>({allowed:!0})}){const d=ze[t],c=n.trim().toLowerCase(),f=Yc(e.children??[]).filter(p=>Ls(p,c));return f.length===0?s.jsx("div",{style:{padding:"16px 12px",fontSize:11.5,color:d.textMuted,textAlign:"center"},children:c?"No matches.":"No semantic objects."}):s.jsx(s.Fragment,{children:f.map(p=>s.jsx(Xc,{node:p,t:d,q:c,onInsert:r,depth:0,selectionMode:o,selected:i,onToggleSelection:l,canSelect:a},p.id))})}function Xc({node:e,t,q:n,onInsert:r,depth:o,selectionMode:i,selected:l,onToggleSelection:a,canSelect:d}){var R;const c=(((R=e.children)==null?void 0:R.length)??0)>0,[f,p]=u.useState(o<1||!!n);u.useEffect(()=>{n&&p(!0)},[n]);const h=Ob.has(e.kind),g=Pb(e),S=g==null?void 0:g.Icon,x=10+o*13,b=e.kind==="metric"||e.kind==="measure"?"metric":e.kind==="dimension"||e.kind==="time_dimension"?"dimension":null,k=so(e),C=Qc(e),E=k!==C?` · DQL ${k}`:"",v=b?`${b}:${k}`:"",w=b?d(b,k):{allowed:!1};if(!c)return s.jsx("div",{style:{display:"flex",alignItems:"center",width:"100%",minWidth:0,borderBottom:`1px solid ${t.cellBorder}`},children:s.jsxs("button",{type:"button",onClick:()=>{i&&b&&w.allowed?a==null||a(b,k):!i&&h&&r(Zo(e))},disabled:i&&!!b&&!w.allowed,title:i&&b?w.allowed?`Select ${e.label} · dbt ${C}${E}`:w.reason||"Not compatible with the current selection":h?`Insert ${Zo(e)} · dbt ${C}${E}`:e.label,style:{display:"flex",alignItems:"center",gap:7,flex:1,minWidth:0,boxSizing:"border-box",padding:`5px 6px 5px ${x+15}px`,border:"none",background:"transparent",cursor:i&&b?w.allowed?"pointer":"not-allowed":h?"pointer":"default",textAlign:"left",fontFamily:t.font,color:w.allowed||!b?t.textPrimary:t.textMuted,opacity:i&&b&&!w.allowed?.55:1},children:[i&&b&&s.jsx("input",{type:"checkbox",readOnly:!0,checked:l.has(v),disabled:!w.allowed,style:{accentColor:t.accent,margin:0,flexShrink:0}}),S&&s.jsx(S,{size:13,color:g.tone(t),style:{flexShrink:0}}),s.jsxs("span",{style:{flex:1,minWidth:0,display:"grid",gap:1,overflow:"hidden"},children:[s.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:11.5},children:e.label}),C!==e.label?s.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:9.5,fontFamily:t.fontMono,color:t.textMuted},children:C}):null]})]})});const A=(e.children??[]).filter(y=>Ls(y,n));return s.jsxs("div",{children:[s.jsxs("button",{type:"button",onClick:()=>p(y=>!y),style:{display:"flex",alignItems:"center",gap:6,width:"100%",minWidth:0,boxSizing:"border-box",padding:`6px 10px 6px ${x}px`,border:"none",borderBottom:`1px solid ${t.cellBorder}`,background:"transparent",cursor:"pointer",textAlign:"left",fontFamily:t.font,color:t.textPrimary},children:[f?s.jsx(Ds,{size:13,color:t.textMuted,style:{flexShrink:0}}):s.jsx(oo,{size:13,color:t.textMuted,style:{flexShrink:0}}),S&&s.jsx(S,{size:13,color:g.tone(t),style:{flexShrink:0}}),s.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:12,fontWeight:600},children:e.label}),s.jsx("span",{style:{fontSize:10,color:t.textMuted,flexShrink:0},children:e.count??A.length})]}),f&&A.map(y=>s.jsx(Xc,{node:y,t,q:n,onInsert:r,depth:o+1,selectionMode:i,selected:l,onToggleSelection:a,canSelect:d},y.id))]})}function Mb(e){return[...new Set(e.map(t=>{var n;return((n=t.domain)==null?void 0:n.trim())||"uncategorized"}))].sort((t,n)=>t.localeCompare(n))}function Ib(e,t,n=""){const r=n.trim().toLowerCase();return Array.from(new Map(e.map(o=>[o.path,o])).values()).filter(o=>{var i;return t&&(((i=o.domain)==null?void 0:i.trim())||"uncategorized")!==t?!1:!r||o.name.toLowerCase().includes(r)||(o.description??"").toLowerCase().includes(r)})}var K;(function(e){e.Program="Program",e.Workbook="Workbook",e.Page="Page",e.Dashboard="Dashboard",e.ChartCall="ChartCall",e.FilterCall="FilterCall",e.VariableDecl="VariableDecl",e.ParamDecl="ParamDecl",e.ImportDecl="ImportDecl",e.UseDecl="UseDecl",e.LayoutBlock="LayoutBlock",e.LayoutRow="LayoutRow",e.Decorator="Decorator",e.SQLQuery="SQLQuery",e.NamedArg="NamedArg",e.StringLiteral="StringLiteral",e.NumberLiteral="NumberLiteral",e.BooleanLiteral="BooleanLiteral",e.ArrayLiteral="ArrayLiteral",e.Identifier="Identifier",e.BinaryExpr="BinaryExpr",e.IntervalExpr="IntervalExpr",e.FunctionCall="FunctionCall",e.TemplateString="TemplateString",e.BlockDecl="BlockDecl",e.DomainDecl="DomainDecl",e.TermDecl="TermDecl",e.BusinessViewDecl="BusinessViewDecl",e.BusinessViewInclude="BusinessViewInclude",e.BlockParams="BlockParams",e.BlockVisualization="BlockVisualization",e.BlockTest="BlockTest",e.Digest="Digest",e.Narrative="Narrative"})(K||(K={}));var dn;(function(e){e.Error="error",e.Warning="warning",e.Info="info"})(dn||(dn={}));class Lb{constructor(){Ee(this,"diagnostics",[])}report(t){this.diagnostics.push(t)}error(t,n,r){this.report({severity:dn.Error,message:t,span:n,hint:r})}warning(t,n,r){this.report({severity:dn.Warning,message:t,span:n,hint:r})}hasErrors(){return this.diagnostics.some(t=>t.severity===dn.Error)}getErrors(){return this.diagnostics.filter(t=>t.severity===dn.Error)}getAll(){return[...this.diagnostics]}clear(){this.diagnostics=[]}format(t){return this.diagnostics.map(n=>Nb(n,t)).join(`
408
408
 
@@ -616,7 +616,7 @@ ${t}`;return r.replace(/\n\}\s*$/,`${o}
616
616
  </div>
617
617
  <p class="exported-by">Built with DQL Workbench</p>
618
618
  </body>
619
- </html>`}function q0(e,t){const n=z0(e,t),r=new Blob([n],{type:"text/html;charset=utf-8"}),o=URL.createObjectURL(r),i=document.createElement("a");i.href=o,i.download=`${e.toLowerCase().replace(/[^a-z0-9]+/g,"-")}-dashboard.html`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(o)}function U0({t:e}){return s.jsx("div",{style:{width:28,height:28,borderRadius:6,background:"linear-gradient(135deg, #5b8cff 0%, #7c5cff 100%)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:s.jsx("span",{style:{color:"#ffffff",fontSize:10,fontWeight:700,fontFamily:e.fontMono,letterSpacing:"-0.5px"},children:"DQL"})})}function W0(){var ee;const{state:e,dispatch:t}=ve(),n=ze[e.themeMode],{executeAll:r}=Ed(),[o,i]=u.useState(!1),[l,a]=u.useState(""),[d,c]=u.useState(!1),[f,p]=u.useState(!1),[h,g]=u.useState(!1),[S,x]=u.useState(!1),[b,k]=u.useState(!1),C=u.useRef(null),[E,v]=u.useState(!1),[w,A]=u.useState(!1),R=u.useRef(null),y=u.useRef(null),M=e.mainView==="block_studio"?e.blockStudioDirty:e.notebookDirty,O=e.mainView==="notebook",T=e.mainView==="notebook"||e.mainView==="block_studio",L=T&&!!e.activeFile,I={home:"Home",business_artifact:((ee=e.activeFile)==null?void 0:ee.name.replace(/\.(dqlnb|dql)$/i,""))??"Business Definition",lineage:"Lineage",lineage_detail:"Lineage",connection:"Settings",apps:"Apps",git:"Source control",settings:"Settings",imports:"Import SQL",domains:"Domains",modeling:"Domains"},V=T?e.activeFile?e.notebookTitle||"Untitled":e.mainView==="block_studio"?"Blocks":"Notebooks":I[e.mainView]??"DQL Workbench";u.useEffect(()=>{o&&y.current&&(y.current.focus(),y.current.select())},[o]),u.useEffect(()=>{if(!w)return;function H(B){R.current&&!R.current.contains(B.target)&&A(!1)}return document.addEventListener("mousedown",H),()=>document.removeEventListener("mousedown",H)},[w]);const X=()=>{a(e.notebookTitle),i(!0)},J=()=>{i(!1),l.trim()&&l!==e.notebookTitle&&(e.mainView==="block_studio"&&e.blockStudioMetadata?(t({type:"SET_BLOCK_STUDIO_METADATA",metadata:{...e.blockStudioMetadata,name:l.trim()}}),t({type:"SET_BLOCK_STUDIO_DRAFT",draft:j0(e.blockStudioDraft,l.trim())})):t({type:"SET_NOTEBOOK_DIRTY",dirty:!0}))},W=u.useCallback(async()=>{var H;if(e.activeFile){t({type:"SET_SAVING",saving:!0});try{if(e.mainView==="block_studio"){if(!e.blockStudioMetadata)return;const B=await N.saveBlockStudio({path:e.activeBlockPath,source:e.blockStudioDraft,metadata:{name:e.blockStudioMetadata.name,domain:e.blockStudioMetadata.domain,folderPath:e.blockStudioMetadata.folderPath,description:e.blockStudioMetadata.description,owner:e.blockStudioMetadata.owner,tags:e.blockStudioMetadata.tags}});t({type:"OPEN_BLOCK_STUDIO",file:{name:`${B.metadata.name}.dql`,path:B.path,type:"block",folder:"blocks"},payload:B}),e.files.some(ne=>ne.path===B.path)||t({type:"FILE_ADDED",file:{name:`${B.metadata.name}.dql`,path:B.path,type:"block",folder:"blocks"}})}else{const B=e.activeFile.type==="block"?((H=e.cells[0])==null?void 0:H.content)??"":u0(e.notebookTitle,e.cells,e.notebookMetadata);await N.saveNotebook(e.activeFile.path,B),t({type:"SET_NOTEBOOK_DIRTY",dirty:!1})}c(!0),setTimeout(()=>c(!1),2e3)}catch(B){console.error("Save failed:",B)}finally{t({type:"SET_SAVING",saving:!1})}}},[e.activeFile,e.activeBlockPath,e.blockStudioDraft,e.blockStudioMetadata,e.files,e.mainView,e.notebookTitle,e.notebookMetadata,e.cells,t]);u.useEffect(()=>{const H=B=>{(B.metaKey||B.ctrlKey)&&B.key==="s"&&(B.preventDefault(),W())};return document.addEventListener("keydown",H),()=>document.removeEventListener("keydown",H)},[W]),u.useEffect(()=>{if(!e.autoSave||!M||!e.activeFile||e.mainView==="block_studio")return;const H=setTimeout(()=>{W()},750);return()=>clearTimeout(H)},[e.autoSave,M,e.activeFile,e.cells,e.blockStudioDraft,W]);const D=[{mode:"obsidian",label:"Obsidian",glyph:"●",swatch:"#0d0e11"},{mode:"paper",label:"Paper",glyph:"☼",swatch:"#f7f4ed"},{mode:"white",label:"White",glyph:"○",swatch:"#ffffff"}],$=e.themeMode==="dark"||e.themeMode==="midnight"?"obsidian":e.themeMode==="light"?"paper":e.themeMode==="arctic"?"white":e.themeMode,Q=D.find(H=>H.mode===$)??D[0];u.useEffect(()=>{if(!b)return;const H=ne=>{C.current&&!C.current.contains(ne.target)&&k(!1)},B=ne=>{ne.key==="Escape"&&k(!1)};return document.addEventListener("mousedown",H),document.addEventListener("keydown",B),()=>{document.removeEventListener("mousedown",H),document.removeEventListener("keydown",B)}},[b]);const q={height:28,padding:"0 10px",borderRadius:6,border:`1px solid ${n.btnBorder}`,cursor:"pointer",fontSize:12,fontWeight:500,fontFamily:n.font,display:"flex",alignItems:"center",gap:4,transition:"background 0.15s, color 0.15s",whiteSpace:"nowrap"};return s.jsxs("div",{style:{height:48,flexShrink:0,background:n.headerBg,borderBottom:`1px solid ${n.headerBorder}`,display:"flex",alignItems:"center",padding:"0 12px",gap:8,userSelect:"none"},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[s.jsx(U0,{t:n}),s.jsx("div",{style:{width:1,height:20,background:n.headerBorder,flexShrink:0}}),e.activeFile&&T&&s.jsx("span",{style:{fontSize:10,fontWeight:600,color:e.activeFile.type==="block"?"#e3b341":n.accent,background:`${e.activeFile.type==="block"?"#e3b341":n.accent}18`,borderRadius:4,padding:"2px 6px",fontFamily:n.font,textTransform:"uppercase",letterSpacing:"0.05em",flexShrink:0},children:e.activeFile.type}),e.activeFile&&T?o?s.jsx("input",{ref:y,value:l,onChange:H=>a(H.target.value),onBlur:J,onKeyDown:H=>{H.key==="Enter"&&J(),H.key==="Escape"&&i(!1)},style:{background:"transparent",border:`1px solid ${n.cellBorderActive}`,borderRadius:4,color:n.textPrimary,fontSize:13,fontWeight:500,fontFamily:n.font,padding:"2px 6px",outline:"none",minWidth:120,maxWidth:320}}):s.jsxs("span",{onClick:X,title:"Click to rename",style:{color:n.textPrimary,fontSize:13,fontWeight:500,fontFamily:n.font,cursor:"text",maxWidth:320,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",padding:"2px 4px",borderRadius:4,border:"1px solid transparent"},children:[V,M&&s.jsx("span",{style:{color:n.textMuted,marginLeft:4},children:"●"})]}):s.jsx("span",{style:{color:n.textSecondary,fontSize:13,fontFamily:n.font,padding:"2px 4px"},children:V||"DQL Workbench"})]}),s.jsx("div",{style:{flex:1}}),s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.appMode==="studio"&&L&&e.mainView!=="block_studio"&&s.jsx(s.Fragment,{children:s.jsxs("button",{onClick:O?r:void 0,disabled:!e.activeFile||!O,onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),style:{...q,height:30,padding:"0 14px",borderRadius:999,background:n.accent,color:"#ffffff",border:`1px solid ${n.accent}`,opacity:!e.activeFile||!O?.4:f?.9:1,boxShadow:"0 1px 2px rgba(107,93,211,0.25)",gap:6},children:[s.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",children:s.jsx("path",{d:"M1.5 1.5l7 3.5-7 3.5V1.5Z"})}),"Run all"]})}),s.jsxs("div",{ref:C,style:{position:"relative"},children:[s.jsxs("button",{onClick:()=>k(H=>!H),onMouseEnter:()=>x(!0),onMouseLeave:()=>x(!1),title:`Theme: ${Q.label}`,"aria-haspopup":"true","aria-expanded":b,style:{...q,background:S||b?n.btnHover:n.btnBg,color:n.textSecondary,padding:"0 10px",fontSize:12,display:"flex",alignItems:"center",gap:6},children:[s.jsx("span",{style:{width:12,height:12,borderRadius:3,background:Q.swatch,border:`1px solid ${n.headerBorder}`,flexShrink:0}}),s.jsx("span",{style:{fontFamily:n.fontMono,fontSize:10,letterSpacing:"0.04em"},children:Q.label}),s.jsx("span",{style:{fontSize:8,color:n.textMuted},children:"▾"})]}),b&&s.jsx("div",{role:"menu",style:{position:"absolute",top:"100%",right:0,marginTop:4,minWidth:160,background:n.headerBg,border:`1px solid ${n.headerBorder}`,borderRadius:6,boxShadow:"0 8px 24px rgba(0,0,0,0.32)",padding:4,zIndex:1e3,display:"flex",flexDirection:"column",gap:1},children:D.map(H=>{const B=H.mode===$;return s.jsxs("button",{role:"menuitemradio","aria-checked":B,onClick:()=>{t({type:"SET_THEME",mode:H.mode}),k(!1)},style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",border:"none",background:B?n.btnHover:"transparent",color:n.textPrimary,cursor:"pointer",borderRadius:4,fontSize:12,fontFamily:n.font,textAlign:"left"},onMouseEnter:ne=>{B||(ne.currentTarget.style.background=n.btnHover)},onMouseLeave:ne=>{B||(ne.currentTarget.style.background="transparent")},children:[s.jsx("span",{style:{width:14,height:14,borderRadius:3,background:H.swatch,border:`1px solid ${n.headerBorder}`,flexShrink:0}}),s.jsx("span",{style:{flex:1},children:H.label}),B&&s.jsx("span",{style:{color:n.accent,fontSize:11},children:"✓"})]},H.mode)})})]}),e.appMode==="studio"&&L&&e.mainView!=="block_studio"&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:W,disabled:!e.activeFile||e.savingFile,onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),title:"Save (Cmd+S)",style:{...q,background:h&&e.activeFile?n.btnHover:n.btnBg,color:d?n.success:n.textSecondary,opacity:e.activeFile?1:.4},children:e.savingFile?s.jsxs(s.Fragment,{children:[s.jsx(V0,{}),"Saving…"]}):d?s.jsx(s.Fragment,{children:"✓ Saved"}):s.jsx(s.Fragment,{children:"Save"})}),s.jsx("div",{style:{width:1,height:20,background:n.headerBorder}})]}),L&&e.mainView!=="block_studio"&&s.jsxs("div",{ref:R,style:{position:"relative"},children:[s.jsxs("button",{onClick:()=>{e.activeFile&&A(H=>!H)},disabled:!e.activeFile,onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1),title:"Share / export",style:{...q,height:30,padding:"0 14px",borderRadius:999,background:(E||w)&&e.activeFile?"#2a2a30":"#1a1a1a",color:"#ffffff",border:"1px solid #1a1a1a",opacity:e.activeFile?1:.4,gap:6},children:[s.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"currentColor",children:s.jsx("path",{d:"M5.5 10.75a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 0 1.5h-3.5a.75.75 0 0 1-.75-.75Zm0-3a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 0 1.5h-3.5a.75.75 0 0 1-.75-.75ZM3 3.75A1.75 1.75 0 0 1 4.75 2h6.586c.464 0 .909.184 1.237.513l1.914 1.914c.329.328.513.773.513 1.237v6.586A1.75 1.75 0 0 1 13.25 14h-8.5A1.75 1.75 0 0 1 3 12.25Z"})}),"Share",s.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"currentColor",style:{marginLeft:1,opacity:.7},children:s.jsx("path",{d:"M1 2.5l3 3 3-3",stroke:"currentColor",fill:"none",strokeWidth:"1.2",strokeLinecap:"round"})})]}),w&&s.jsx("div",{style:{position:"absolute",top:32,right:0,zIndex:200,background:n.modalBg,border:`1px solid ${n.cellBorder}`,borderRadius:8,boxShadow:"0 8px 24px rgba(0,0,0,0.3)",padding:4,minWidth:160,display:"flex",flexDirection:"column",gap:2},children:s.jsx(K0,{label:"Export HTML",description:"Standalone dashboard",t:n,onClick:()=>{q0(e.notebookTitle||"dashboard",e.cells),A(!1)}})})]})]})]})}function K0({label:e,description:t,t:n,onClick:r}){const[o,i]=u.useState(!1);return s.jsxs("button",{onClick:r,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{background:o?n.btnHover:"transparent",border:"none",borderRadius:5,cursor:"pointer",padding:"6px 10px",textAlign:"left",display:"flex",flexDirection:"column",gap:1,transition:"background 0.12s"},children:[s.jsx("span",{style:{fontSize:12,fontWeight:500,color:n.textPrimary,fontFamily:n.font},children:e}),s.jsx("span",{style:{fontSize:10,color:n.textMuted,fontFamily:n.font},children:t})]})}function V0(){return s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{animation:"spin 0.8s linear infinite"},children:[s.jsx("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"}),s.jsx("circle",{cx:"6",cy:"6",r:"4.5",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"14 7"})]})}function H0(e){return e.toTimeString().slice(0,8)}function G0(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(2)}s`}function J0(){const{state:e,dispatch:t}=ve(),n=ze[e.themeMode],[r,o]=u.useState(!1),i=e.queryLog.filter(a=>a.error),l=a=>t({type:"SET_DEV_PANEL_TAB",tab:a});return s.jsxs("div",{style:{height:e.devPanelOpen?180:0,flexShrink:0,background:n.sidebarBg,borderTop:`1px solid ${n.headerBorder}`,display:"flex",flexDirection:"column",overflow:"hidden",transition:"height 0.2s ease",position:"relative"},children:[e.devPanelOpen&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{style:{height:32,flexShrink:0,display:"flex",alignItems:"center",borderBottom:`1px solid ${n.headerBorder}`,padding:"0 8px",gap:2},children:[["logs","errors"].map(a=>s.jsx(Q0,{label:a==="errors"?`Errors${i.length>0?` (${i.length})`:""}`:`Logs (${e.queryLog.length})`,active:e.devPanelTab===a,onClick:()=>l(a),t:n},a)),s.jsx("div",{style:{flex:1}}),s.jsx("button",{onClick:()=>t({type:"SET_CELLS",cells:e.cells}),title:"Clear logs",style:{background:"transparent",borderTop:"none",borderLeft:"none",borderRight:"none",borderBottom:"none",cursor:"pointer",color:n.textMuted,fontSize:11,fontFamily:n.font,padding:"2px 6px",borderRadius:4},children:"Clear"})]}),s.jsxs("div",{style:{flex:1,overflow:"auto",padding:"4px 0"},children:[e.devPanelTab==="logs"&&(e.queryLog.length===0?s.jsx(Aa,{t:n,message:"No queries executed yet."}):[...e.queryLog].reverse().map(a=>s.jsx(Ta,{entry:a,t:n},a.id))),e.devPanelTab==="errors"&&(i.length===0?s.jsx(Aa,{t:n,message:"No errors."}):[...i].reverse().map(a=>s.jsx(Ta,{entry:a,t:n},a.id)))]})]}),s.jsxs("button",{onClick:()=>t({type:"TOGGLE_DEV_PANEL"}),onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),title:e.devPanelOpen?"Close panel":"Open dev panel",style:{position:"absolute",bottom:e.devPanelOpen?4:-28,right:8,height:22,padding:"0 8px",borderRadius:"4px 4px 0 0",borderTop:`1px solid ${n.headerBorder}`,borderLeft:`1px solid ${n.headerBorder}`,borderRight:`1px solid ${n.headerBorder}`,borderBottom:e.devPanelOpen?`1px solid ${n.sidebarBg}`:`1px solid ${n.headerBorder}`,background:r?n.btnHover:n.sidebarBg,color:n.textMuted,cursor:"pointer",fontSize:11,fontFamily:n.font,display:"flex",alignItems:"center",gap:4,transition:"background 0.15s, bottom 0.2s ease",zIndex:10},children:[s.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",children:s.jsx("path",{d:e.devPanelOpen?"M1 7l4-4 4 4":"M1 3l4 4 4-4",strokeWidth:"1.5",stroke:"currentColor",fill:"none"})}),"Dev"]})]})}function Q0({label:e,active:t,onClick:n,t:r}){const[o,i]=u.useState(!1);return s.jsx("button",{onClick:n,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{background:"transparent",borderTop:"none",borderLeft:"none",borderRight:"none",borderBottom:t?`2px solid ${r.accent}`:"2px solid transparent",cursor:"pointer",color:t?r.textPrimary:o?r.textSecondary:r.textMuted,fontSize:12,fontFamily:r.font,fontWeight:t?500:400,padding:"4px 8px",height:32,transition:"color 0.15s"},children:e})}function Aa({t:e,message:t}){return s.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.textMuted,fontSize:12,fontFamily:e.font,fontStyle:"italic"},children:t})}function Ta({entry:e,t}){return s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"3px 12px",fontSize:11,fontFamily:t.fontMono,color:e.error?t.error:t.textSecondary,borderLeft:e.error?`2px solid ${t.error}`:"2px solid transparent"},children:[s.jsx("span",{style:{color:t.textMuted,flexShrink:0},children:H0(e.ts)}),s.jsx("span",{style:{flexShrink:0,color:t.textPrimary,maxWidth:160,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.cellName}),e.error?s.jsx("span",{style:{color:t.error,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.error}):s.jsxs(s.Fragment,{children:[s.jsxs("span",{style:{color:t.textMuted},children:[e.rows.toLocaleString()," rows"]}),s.jsx("span",{style:{color:t.textMuted},children:G0(e.time)})]})]})}function Y0(){const{state:e,dispatch:t}=ve(),{executeAll:n}=Ed();u.useEffect(()=>{const r=o=>{const i=o.metaKey||o.ctrlKey;if(i&&o.key==="b"&&!o.shiftKey){o.preventDefault(),t({type:"TOGGLE_SIDEBAR"});return}if(i&&o.shiftKey&&o.key==="Enter"){o.preventDefault(),e.activeFile&&n();return}if(i&&o.key==="j"&&!o.shiftKey){o.preventDefault(),t({type:"TOGGLE_DEV_PANEL"});return}if(i&&o.key==="d"&&!o.shiftKey){o.preventDefault(),e.activeFile&&t({type:"TOGGLE_DASHBOARD_MODE"});return}if(o.key==="Escape"){if(e.dashboardMode){t({type:"TOGGLE_DASHBOARD_MODE"});return}if(e.newNotebookModalOpen){t({type:"CLOSE_NEW_NOTEBOOK_MODAL"});return}if(e.newBlockModalOpen){t({type:"CLOSE_NEW_BLOCK_MODAL"});return}}};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[t,n,e.activeFile,e.newNotebookModalOpen,e.newBlockModalOpen,e.dashboardMode])}const X0=600;function Z0(e,t){const n=t.filter(r=>r.result||r.error||(r.executionCount??0)>0).map(r=>{var o;return{cellId:r.id,status:r.status,result:r.result,error:r.error,executionCount:r.executionCount,executedAt:((o=r.execution)==null?void 0:o.completedAt)??new Date().toISOString(),execution:r.execution}});return{version:1,notebookPath:e,capturedAt:new Date().toISOString(),cells:n}}function Ra(e){return e.map(t=>{var n,r;return`${t.id}:${((n=t.execution)==null?void 0:n.runId)??""}:${t.executionCount??0}:${((r=t.result)==null?void 0:r.rowCount)??-1}:${t.error??""}`}).join("|")}function e1(){var o;const{state:e}=ve(),t=u.useRef(null),n=u.useRef(""),r=u.useRef(null);u.useEffect(()=>{var a;const i=((a=e.activeFile)==null?void 0:a.path)??null;if(!i)return;if(i!==r.current){r.current=i,n.current=Ra(e.cells);return}const l=Ra(e.cells);return l!==n.current&&(n.current=l,t.current&&clearTimeout(t.current),t.current=setTimeout(()=>{const d=Z0(i,e.cells);N.saveRunSnapshot(i,d).catch(()=>{})},X0)),()=>{t.current&&(clearTimeout(t.current),t.current=null)}},[e.cells,(o=e.activeFile)==null?void 0:o.path])}const t1=u.lazy(()=>Ce(()=>import("./HomePage-LDu8z_nW.js"),__vite__mapDeps([0,1,2,3,4,5,6])).then(e=>({default:e.HomePage}))),n1=u.lazy(()=>Ce(()=>import("./AnalyticsHome-D5I-Okbz.js"),__vite__mapDeps([7,8,9,10,11,1,12,13,3,14,15,16,17,18,2,19,20,6])).then(e=>({default:e.AnalyticsHome}))),r1=u.lazy(()=>Ce(()=>import("./GlobalAiRail-ZOHo4H6j.js"),__vite__mapDeps([21,9,10,11,1,12,13,3,14,15,16,17,18,2,19,22,23,24,6])).then(e=>({default:e.GlobalAiRail}))),o1=u.lazy(()=>Ce(()=>import("./NotebookEditor-BWMX6Xfi.js"),__vite__mapDeps([25,4,2,5,26,27,28,11,9,10,1,12,13,3,14,15,16,17,18,19,8,29,30,6,31,32,22,23,24])).then(e=>({default:e.NotebookEditor}))),s1=u.lazy(()=>Ce(()=>import("./NewNotebookModal-Bl78Nnjz.js"),__vite__mapDeps([33,4,15,6])).then(e=>({default:e.NewNotebookModal}))),i1=u.lazy(()=>Ce(()=>import("./NewBlockModal-oo3fU5OW.js"),__vite__mapDeps([34,6])).then(e=>({default:e.NewBlockModal}))),a1=u.lazy(()=>Ce(()=>import("./SetupOnboarding-Cqw2NuAn.js"),__vite__mapDeps([35,36,2,6])).then(e=>({default:e.SetupOnboarding}))),l1=u.lazy(()=>Ce(()=>import("./BlockStudio-BmNsIfNK.js"),__vite__mapDeps([37,26,27,11,29,30,6,31,9,10,1,12,13,3,14,15,16,17,18,2,19,22,23,24,38,39])).then(e=>({default:e.BlockStudio}))),c1=u.lazy(()=>Ce(()=>import("./BusinessArtifactView-Bvn5X8uW.js"),__vite__mapDeps([40,29,30,6,31])).then(e=>({default:e.BusinessArtifactView}))),d1=u.lazy(()=>Ce(()=>import("./LineageDetailView-CuGG_JDv.js"),__vite__mapDeps([41,29,30,6,31,42,36,17])).then(e=>({default:e.LineageDetailView}))),u1=u.lazy(()=>Ce(()=>import("./LineageDAG-VFSCvevO.js"),__vite__mapDeps([42,30,6,31])).then(e=>({default:e.LineageDAG}))),p1=u.lazy(()=>Ce(()=>import("./HelpDocsPage-6SmmBvJh.js"),__vite__mapDeps([43,6])).then(e=>({default:e.HelpDocsPage}))),f1=u.lazy(()=>Ce(()=>Promise.resolve().then(()=>DS),void 0).then(e=>({default:e.ConnectionPanel}))),h1=u.lazy(()=>Ce(()=>import("./GitPage-C_5u2aCj.js"),__vite__mapDeps([44,45,15,6])).then(e=>({default:e.GitPage}))),m1=u.lazy(()=>Ce(()=>import("./ReadinessPage-CL2EJLKo.js"),__vite__mapDeps([46,1,47,48,13,3,2,6])).then(e=>({default:e.ReadinessPage}))),g1=u.lazy(()=>Ce(()=>import("./AgentLogPage-DKvtW4Fq.js"),__vite__mapDeps([49,36,18,50,6])).then(e=>({default:e.AgentLogPage}))),y1=u.lazy(()=>Ce(()=>import("./GovernedContextPage-CUaYIqfd.js").then(e=>e.G),__vite__mapDeps([51,3,13,19,16,15])).then(e=>({default:e.GovernedContextPage}))),x1=u.lazy(()=>Ce(()=>import("./DbtFirstModelingPage-DnpVGZJv.js"),__vite__mapDeps([52,51,3,13,19,16,15,30,6,31,32,24,38,50,14])).then(e=>({default:e.DbtFirstModelingPage}))),b1=u.lazy(()=>Ce(()=>import("./AppsView-DLtjogVz.js"),__vite__mapDeps([53,22,23,24,15,11,28,48,39,54,3,36,5,16,20,4,6])).then(e=>({default:e.AppsView}))),v1=u.lazy(()=>Ce(()=>import("./LineageDrawer-B2SVsEw1.js"),__vite__mapDeps([55,29,30,6,31,38,15,23,14,54,45])).then(e=>({default:e.LineageDrawer}))),S1=u.lazy(()=>Ce(()=>import("./AiBuildDialog-apJ4HoK3.js"),__vite__mapDeps([56,47,12,13,3,14,15,6])).then(e=>({default:e.AiBuildDialog})));function k1(){const{state:e,dispatch:t}=ve(),n=ze[e.themeMode],r=u.useRef({}),o=e.mainView==="block_studio"||e.mainView==="imports",[i,l]=u.useState(!1),[a,d]=u.useState(null),[c,f]=u.useState(!1);u.useEffect(()=>{let g=!0;return N.getSetupLaunch().then(S=>{g&&(d(S),S.shouldOpen&&t({type:"OPEN_SETUP"}))}).catch(()=>{}).finally(()=>{g&&f(!0)}),()=>{g=!1}},[t]),Y0(),e1(),u.useEffect(()=>{const g=S=>{(S.metaKey||S.ctrlKey)&&S.key.toLowerCase()==="k"&&!S.shiftKey&&(S.preventDefault(),l(x=>!x)),(S.metaKey||S.ctrlKey)&&S.shiftKey&&S.key.toLowerCase()==="i"&&(S.preventDefault(),t({type:"TOGGLE_INSPECTOR"}))};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[t]);const p=u.useCallback(async g=>{try{if(g.type==="term"||g.type==="business_view"){e.sidebarPanel!=="files"&&t({type:"SET_SIDEBAR_PANEL",panel:"files"}),t({type:"OPEN_BUSINESS_ARTIFACT",file:g});return}if(g.type==="block"){const v=await N.openBlockStudio(g.path);t({type:"OPEN_BLOCK_STUDIO",file:g,payload:v});return}const{content:S}=await N.readNotebook(g.path),{title:x,cells:b,metadata:k}=p0(g.path,S),C=g.path.endsWith(".dqlnb")?await N.fetchRunSnapshot(g.path):null;let E=b;if(C!=null&&C.found&&C.snapshot){const v=new Map(C.snapshot.cells.map(w=>[w.cellId,w]));E=b.map(w=>{const A=v.get(w.id);return A?{...w,status:A.status??w.status,result:A.result??w.result,error:A.error??w.error,executionCount:A.executionCount??w.executionCount,execution:A.execution??w.execution,fromSnapshot:A.result!=null}:w})}t({type:"OPEN_FILE",file:g,cells:E,title:x,metadata:k}),e.sidebarPanel!=="files"&&t({type:"SET_SIDEBAR_PANEL",panel:"files"})}catch(S){if(console.error("Failed to open file:",S),g.type==="block")try{const{content:x}=await N.readNotebook(g.path);t({type:"OPEN_BLOCK_STUDIO",file:g,payload:{path:g.path,source:x,companionPath:null,metadata:{name:g.name.replace(/\.dql$/i,""),path:g.path,domain:g.path.split("/").slice(1,-1).join("/")||"uncategorized",description:"",owner:"",tags:[]},validation:{valid:!1,diagnostics:[{severity:"warning",message:"Opened block without studio metadata. Save once to normalize it."}],semanticRefs:{metrics:[],dimensions:[],segments:[]}}}});return}catch(x){console.error("Failed to open block fallback:",x)}else t({type:"OPEN_FILE",file:g,cells:[Os("sql")],title:g.name})}},[t,e.sidebarPanel]);u.useCallback(g=>{const S=r.current[g];S&&S.scrollIntoView({behavior:"smooth",block:"start"})},[]);const h=u.useCallback((g,S)=>{S?r.current[g]=S:delete r.current[g]},[]);return s.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100vh",width:"100vw",background:n.appBg,fontFamily:n.font,color:n.textPrimary,overflow:"hidden"},children:[s.jsx(W0,{}),s.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[e.appMode==="studio"&&s.jsx(wb,{}),e.appMode==="studio"&&e.sidebarOpen&&!o&&s.jsx(s0,{onOpenFile:p}),s.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minWidth:0},children:s.jsx(u.Suspense,{fallback:s.jsx(w1,{t:n}),children:e.mainView==="home"?s.jsx(t1,{}):e.mainView==="ask"?s.jsx(n1,{}):e.mainView==="business_artifact"?s.jsx(c1,{}):e.mainView==="lineage"?s.jsx("div",{style:{flex:1,minWidth:0,minHeight:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:s.jsx(u1,{})}):e.mainView==="lineage_detail"?s.jsx(d1,{}):e.mainView==="help"?s.jsx(p1,{}):e.mainView==="connection"||e.mainView==="settings"?s.jsx(j1,{children:s.jsx(f1,{variant:"page"})}):e.mainView==="git"?s.jsx(h1,{}):e.mainView==="readiness"?s.jsx(m1,{}):e.mainView==="skills"?s.jsx(y1,{initialTab:"skills"}):e.mainView==="domains"||e.mainView==="modeling"?s.jsx(x1,{}):e.mainView==="apps"?s.jsx(b1,{}):e.mainView==="agent_log"?s.jsx(C1,{title:"Agent steps",description:"What the agent did to answer this question, and where the time went — route, tools, checks, and per-step timing.",children:s.jsx(g1,{})}):s.jsx(s.Fragment,{children:e.mainView==="imports"||e.mainView==="block_studio"?s.jsx(l1,{},"block-editor"):s.jsxs(s.Fragment,{children:[s.jsx(o1,{onOpenFile:p,registerCellRef:h}),e.appMode==="studio"&&s.jsx(J0,{})]})})})}),e.appMode==="studio"&&e.lineageDrawerOpen&&!e.lineageFullscreen&&!e.dashboardMode&&s.jsx(u.Suspense,{fallback:null,children:s.jsx(v1,{})}),e.appMode==="studio"&&e.inspectorOpen&&!e.lineageFullscreen&&!e.lineageDrawerOpen&&!e.dashboardMode&&s.jsx(ub,{}),e.globalAi.open&&e.mainView==="apps"&&s.jsx(u.Suspense,{fallback:null,children:s.jsx(r1,{})})]}),e.newNotebookModalOpen&&s.jsx(u.Suspense,{fallback:null,children:s.jsx(s1,{onFileOpened:p})}),e.newBlockModalOpen&&s.jsx(u.Suspense,{fallback:null,children:s.jsx(i1,{onFileOpened:p})}),s.jsx(Rx,{open:i,onClose:()=>l(!1)}),s.jsx(u.Suspense,{fallback:null,children:s.jsx(S1,{})}),e.setupOpen&&s.jsx(u.Suspense,{fallback:s.jsx(_a,{t:n}),children:s.jsx(a1,{launch:a!=null&&a.shouldOpen?a:void 0,onAcknowledged:()=>d(g=>g&&{...g,shouldOpen:!1,reason:null})})}),!c&&s.jsx(_a,{t:n})]})}function w1({t:e}){return s.jsx("div",{role:"status","aria-live":"polite",style:{flex:1,minWidth:0,display:"grid",placeItems:"center",background:e.appBg,color:e.textSecondary,fontFamily:e.font},children:s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,fontSize:12.5},children:[s.jsx("span",{style:{width:8,height:8,borderRadius:999,background:e.accent}}),"Loading workspace…"]})})}function _a({t:e}){return s.jsx("div",{role:"status","aria-live":"polite",style:{position:"fixed",inset:0,zIndex:1100,display:"grid",placeItems:"center",background:e.appBg,color:e.textSecondary,fontFamily:e.font},children:s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,fontSize:12.5},children:[s.jsx("span",{style:{width:8,height:8,borderRadius:999,background:e.accent}}),"Checking workspace setup…"]})})}function j1({children:e}){return s.jsx("div",{style:{flex:1,minWidth:0,overflow:"auto"},children:s.jsx("div",{style:{maxWidth:1120,margin:"0 auto",padding:"18px 28px 32px"},children:e})})}function C1({title:e,description:t,children:n}){return s.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0,overflow:"hidden"},children:[s.jsxs("div",{style:{padding:"18px 24px 12px",borderBottom:"1px solid rgba(127, 127, 127, 0.16)"},children:[s.jsx("div",{style:{fontSize:22,fontWeight:700},children:e}),s.jsx("div",{style:{fontSize:13,opacity:.72,marginTop:6,maxWidth:760,lineHeight:1.5},children:t})]}),s.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto"},children:n})]})}function E1(){const{state:e,dispatch:t}=ve(),n=u.useRef(null),r=u.useRef(null);u.useEffect(()=>{var o;n.current=((o=e.activeFile)==null?void 0:o.path)??null},[e.activeFile]),u.useEffect(()=>{if(typeof EventSource>"u")return;const o=()=>{const i=new EventSource(`${window.location.origin}/api/watch`);r.current=i,i.addEventListener("change",l=>{try{const a=JSON.parse(l.data);(a.type==="file-added"||a.type==="file-deleted")&&N.listNotebooks().then(d=>{t({type:"SET_FILES",files:d})}),a.type==="file-changed"&&N.listNotebooks().then(d=>{t({type:"SET_FILES",files:d})}),a.type==="semantic-reload"&&(t({type:"SET_SEMANTIC_LOADING",loading:!0}),N.getSemanticLayer().then(d=>{t({type:"SET_SEMANTIC_LAYER",layer:d})}))}catch{}}),i.addEventListener("error",()=>{i.close(),setTimeout(o,5e3)})};return o(),()=>{var i;(i=r.current)==null||i.close(),r.current=null}},[t])}function A1(){const{state:e,dispatch:t}=ve(),n=ze[e.themeMode];u.useEffect(()=>{const o="dql-global-styles";let i=document.getElementById(o);i||(i=document.createElement("style"),i.id=o,document.head.appendChild(i)),i.textContent=`
619
+ </html>`}function q0(e,t){const n=z0(e,t),r=new Blob([n],{type:"text/html;charset=utf-8"}),o=URL.createObjectURL(r),i=document.createElement("a");i.href=o,i.download=`${e.toLowerCase().replace(/[^a-z0-9]+/g,"-")}-dashboard.html`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(o)}function U0({t:e}){return s.jsx("div",{style:{width:28,height:28,borderRadius:6,background:"linear-gradient(135deg, #5b8cff 0%, #7c5cff 100%)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:s.jsx("span",{style:{color:"#ffffff",fontSize:10,fontWeight:700,fontFamily:e.fontMono,letterSpacing:"-0.5px"},children:"DQL"})})}function W0(){var ee;const{state:e,dispatch:t}=ve(),n=ze[e.themeMode],{executeAll:r}=Ed(),[o,i]=u.useState(!1),[l,a]=u.useState(""),[d,c]=u.useState(!1),[f,p]=u.useState(!1),[h,g]=u.useState(!1),[S,x]=u.useState(!1),[b,k]=u.useState(!1),C=u.useRef(null),[E,v]=u.useState(!1),[w,A]=u.useState(!1),R=u.useRef(null),y=u.useRef(null),M=e.mainView==="block_studio"?e.blockStudioDirty:e.notebookDirty,O=e.mainView==="notebook",T=e.mainView==="notebook"||e.mainView==="block_studio",L=T&&!!e.activeFile,I={home:"Home",business_artifact:((ee=e.activeFile)==null?void 0:ee.name.replace(/\.(dqlnb|dql)$/i,""))??"Business Definition",lineage:"Lineage",lineage_detail:"Lineage",connection:"Settings",apps:"Apps",git:"Source control",settings:"Settings",imports:"Import SQL",domains:"Domains",modeling:"Domains"},V=T?e.activeFile?e.notebookTitle||"Untitled":e.mainView==="block_studio"?"Blocks":"Notebooks":I[e.mainView]??"DQL Workbench";u.useEffect(()=>{o&&y.current&&(y.current.focus(),y.current.select())},[o]),u.useEffect(()=>{if(!w)return;function H(B){R.current&&!R.current.contains(B.target)&&A(!1)}return document.addEventListener("mousedown",H),()=>document.removeEventListener("mousedown",H)},[w]);const X=()=>{a(e.notebookTitle),i(!0)},J=()=>{i(!1),l.trim()&&l!==e.notebookTitle&&(e.mainView==="block_studio"&&e.blockStudioMetadata?(t({type:"SET_BLOCK_STUDIO_METADATA",metadata:{...e.blockStudioMetadata,name:l.trim()}}),t({type:"SET_BLOCK_STUDIO_DRAFT",draft:j0(e.blockStudioDraft,l.trim())})):t({type:"SET_NOTEBOOK_DIRTY",dirty:!0}))},W=u.useCallback(async()=>{var H;if(e.activeFile){t({type:"SET_SAVING",saving:!0});try{if(e.mainView==="block_studio"){if(!e.blockStudioMetadata)return;const B=await N.saveBlockStudio({path:e.activeBlockPath,source:e.blockStudioDraft,metadata:{name:e.blockStudioMetadata.name,domain:e.blockStudioMetadata.domain,folderPath:e.blockStudioMetadata.folderPath,description:e.blockStudioMetadata.description,owner:e.blockStudioMetadata.owner,tags:e.blockStudioMetadata.tags}});t({type:"OPEN_BLOCK_STUDIO",file:{name:`${B.metadata.name}.dql`,path:B.path,type:"block",folder:"blocks"},payload:B}),e.files.some(ne=>ne.path===B.path)||t({type:"FILE_ADDED",file:{name:`${B.metadata.name}.dql`,path:B.path,type:"block",folder:"blocks"}})}else{const B=e.activeFile.type==="block"?((H=e.cells[0])==null?void 0:H.content)??"":u0(e.notebookTitle,e.cells,e.notebookMetadata);await N.saveNotebook(e.activeFile.path,B),t({type:"SET_NOTEBOOK_DIRTY",dirty:!1})}c(!0),setTimeout(()=>c(!1),2e3)}catch(B){console.error("Save failed:",B)}finally{t({type:"SET_SAVING",saving:!1})}}},[e.activeFile,e.activeBlockPath,e.blockStudioDraft,e.blockStudioMetadata,e.files,e.mainView,e.notebookTitle,e.notebookMetadata,e.cells,t]);u.useEffect(()=>{const H=B=>{(B.metaKey||B.ctrlKey)&&B.key==="s"&&(B.preventDefault(),W())};return document.addEventListener("keydown",H),()=>document.removeEventListener("keydown",H)},[W]),u.useEffect(()=>{if(!e.autoSave||!M||!e.activeFile||e.mainView==="block_studio")return;const H=setTimeout(()=>{W()},750);return()=>clearTimeout(H)},[e.autoSave,M,e.activeFile,e.cells,e.blockStudioDraft,W]);const D=[{mode:"obsidian",label:"Obsidian",glyph:"●",swatch:"#0d0e11"},{mode:"paper",label:"Paper",glyph:"☼",swatch:"#f7f4ed"},{mode:"white",label:"White",glyph:"○",swatch:"#ffffff"}],$=e.themeMode==="dark"||e.themeMode==="midnight"?"obsidian":e.themeMode==="light"?"paper":e.themeMode==="arctic"?"white":e.themeMode,Q=D.find(H=>H.mode===$)??D[0];u.useEffect(()=>{if(!b)return;const H=ne=>{C.current&&!C.current.contains(ne.target)&&k(!1)},B=ne=>{ne.key==="Escape"&&k(!1)};return document.addEventListener("mousedown",H),document.addEventListener("keydown",B),()=>{document.removeEventListener("mousedown",H),document.removeEventListener("keydown",B)}},[b]);const q={height:28,padding:"0 10px",borderRadius:6,border:`1px solid ${n.btnBorder}`,cursor:"pointer",fontSize:12,fontWeight:500,fontFamily:n.font,display:"flex",alignItems:"center",gap:4,transition:"background 0.15s, color 0.15s",whiteSpace:"nowrap"};return s.jsxs("div",{style:{height:48,flexShrink:0,background:n.headerBg,borderBottom:`1px solid ${n.headerBorder}`,display:"flex",alignItems:"center",padding:"0 12px",gap:8,userSelect:"none"},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[s.jsx(U0,{t:n}),s.jsx("div",{style:{width:1,height:20,background:n.headerBorder,flexShrink:0}}),e.activeFile&&T&&s.jsx("span",{style:{fontSize:10,fontWeight:600,color:e.activeFile.type==="block"?"#e3b341":n.accent,background:`${e.activeFile.type==="block"?"#e3b341":n.accent}18`,borderRadius:4,padding:"2px 6px",fontFamily:n.font,textTransform:"uppercase",letterSpacing:"0.05em",flexShrink:0},children:e.activeFile.type}),e.activeFile&&T?o?s.jsx("input",{ref:y,value:l,onChange:H=>a(H.target.value),onBlur:J,onKeyDown:H=>{H.key==="Enter"&&J(),H.key==="Escape"&&i(!1)},style:{background:"transparent",border:`1px solid ${n.cellBorderActive}`,borderRadius:4,color:n.textPrimary,fontSize:13,fontWeight:500,fontFamily:n.font,padding:"2px 6px",outline:"none",minWidth:120,maxWidth:320}}):s.jsxs("span",{onClick:X,title:"Click to rename",style:{color:n.textPrimary,fontSize:13,fontWeight:500,fontFamily:n.font,cursor:"text",maxWidth:320,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",padding:"2px 4px",borderRadius:4,border:"1px solid transparent"},children:[V,M&&s.jsx("span",{style:{color:n.textMuted,marginLeft:4},children:"●"})]}):s.jsx("span",{style:{color:n.textSecondary,fontSize:13,fontFamily:n.font,padding:"2px 4px"},children:V||"DQL Workbench"})]}),s.jsx("div",{style:{flex:1}}),s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.appMode==="studio"&&L&&e.mainView!=="block_studio"&&s.jsx(s.Fragment,{children:s.jsxs("button",{onClick:O?r:void 0,disabled:!e.activeFile||!O,onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),style:{...q,height:30,padding:"0 14px",borderRadius:999,background:n.accent,color:"#ffffff",border:`1px solid ${n.accent}`,opacity:!e.activeFile||!O?.4:f?.9:1,boxShadow:"0 1px 2px rgba(107,93,211,0.25)",gap:6},children:[s.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",children:s.jsx("path",{d:"M1.5 1.5l7 3.5-7 3.5V1.5Z"})}),"Run all"]})}),s.jsxs("div",{ref:C,style:{position:"relative"},children:[s.jsxs("button",{onClick:()=>k(H=>!H),onMouseEnter:()=>x(!0),onMouseLeave:()=>x(!1),title:`Theme: ${Q.label}`,"aria-haspopup":"true","aria-expanded":b,style:{...q,background:S||b?n.btnHover:n.btnBg,color:n.textSecondary,padding:"0 10px",fontSize:12,display:"flex",alignItems:"center",gap:6},children:[s.jsx("span",{style:{width:12,height:12,borderRadius:3,background:Q.swatch,border:`1px solid ${n.headerBorder}`,flexShrink:0}}),s.jsx("span",{style:{fontFamily:n.fontMono,fontSize:10,letterSpacing:"0.04em"},children:Q.label}),s.jsx("span",{style:{fontSize:8,color:n.textMuted},children:"▾"})]}),b&&s.jsx("div",{role:"menu",style:{position:"absolute",top:"100%",right:0,marginTop:4,minWidth:160,background:n.headerBg,border:`1px solid ${n.headerBorder}`,borderRadius:6,boxShadow:"0 8px 24px rgba(0,0,0,0.32)",padding:4,zIndex:1e3,display:"flex",flexDirection:"column",gap:1},children:D.map(H=>{const B=H.mode===$;return s.jsxs("button",{role:"menuitemradio","aria-checked":B,onClick:()=>{t({type:"SET_THEME",mode:H.mode}),k(!1)},style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",border:"none",background:B?n.btnHover:"transparent",color:n.textPrimary,cursor:"pointer",borderRadius:4,fontSize:12,fontFamily:n.font,textAlign:"left"},onMouseEnter:ne=>{B||(ne.currentTarget.style.background=n.btnHover)},onMouseLeave:ne=>{B||(ne.currentTarget.style.background="transparent")},children:[s.jsx("span",{style:{width:14,height:14,borderRadius:3,background:H.swatch,border:`1px solid ${n.headerBorder}`,flexShrink:0}}),s.jsx("span",{style:{flex:1},children:H.label}),B&&s.jsx("span",{style:{color:n.accent,fontSize:11},children:"✓"})]},H.mode)})})]}),e.appMode==="studio"&&L&&e.mainView!=="block_studio"&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:W,disabled:!e.activeFile||e.savingFile,onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),title:"Save (Cmd+S)",style:{...q,background:h&&e.activeFile?n.btnHover:n.btnBg,color:d?n.success:n.textSecondary,opacity:e.activeFile?1:.4},children:e.savingFile?s.jsxs(s.Fragment,{children:[s.jsx(V0,{}),"Saving…"]}):d?s.jsx(s.Fragment,{children:"✓ Saved"}):s.jsx(s.Fragment,{children:"Save"})}),s.jsx("div",{style:{width:1,height:20,background:n.headerBorder}})]}),L&&e.mainView!=="block_studio"&&s.jsxs("div",{ref:R,style:{position:"relative"},children:[s.jsxs("button",{onClick:()=>{e.activeFile&&A(H=>!H)},disabled:!e.activeFile,onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1),title:"Share / export",style:{...q,height:30,padding:"0 14px",borderRadius:999,background:(E||w)&&e.activeFile?"#2a2a30":"#1a1a1a",color:"#ffffff",border:"1px solid #1a1a1a",opacity:e.activeFile?1:.4,gap:6},children:[s.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"currentColor",children:s.jsx("path",{d:"M5.5 10.75a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 0 1.5h-3.5a.75.75 0 0 1-.75-.75Zm0-3a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 0 1.5h-3.5a.75.75 0 0 1-.75-.75ZM3 3.75A1.75 1.75 0 0 1 4.75 2h6.586c.464 0 .909.184 1.237.513l1.914 1.914c.329.328.513.773.513 1.237v6.586A1.75 1.75 0 0 1 13.25 14h-8.5A1.75 1.75 0 0 1 3 12.25Z"})}),"Share",s.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"currentColor",style:{marginLeft:1,opacity:.7},children:s.jsx("path",{d:"M1 2.5l3 3 3-3",stroke:"currentColor",fill:"none",strokeWidth:"1.2",strokeLinecap:"round"})})]}),w&&s.jsx("div",{style:{position:"absolute",top:32,right:0,zIndex:200,background:n.modalBg,border:`1px solid ${n.cellBorder}`,borderRadius:8,boxShadow:"0 8px 24px rgba(0,0,0,0.3)",padding:4,minWidth:160,display:"flex",flexDirection:"column",gap:2},children:s.jsx(K0,{label:"Export HTML",description:"Standalone dashboard",t:n,onClick:()=>{q0(e.notebookTitle||"dashboard",e.cells),A(!1)}})})]})]})]})}function K0({label:e,description:t,t:n,onClick:r}){const[o,i]=u.useState(!1);return s.jsxs("button",{onClick:r,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{background:o?n.btnHover:"transparent",border:"none",borderRadius:5,cursor:"pointer",padding:"6px 10px",textAlign:"left",display:"flex",flexDirection:"column",gap:1,transition:"background 0.12s"},children:[s.jsx("span",{style:{fontSize:12,fontWeight:500,color:n.textPrimary,fontFamily:n.font},children:e}),s.jsx("span",{style:{fontSize:10,color:n.textMuted,fontFamily:n.font},children:t})]})}function V0(){return s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{animation:"spin 0.8s linear infinite"},children:[s.jsx("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"}),s.jsx("circle",{cx:"6",cy:"6",r:"4.5",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"14 7"})]})}function H0(e){return e.toTimeString().slice(0,8)}function G0(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(2)}s`}function J0(){const{state:e,dispatch:t}=ve(),n=ze[e.themeMode],[r,o]=u.useState(!1),i=e.queryLog.filter(a=>a.error),l=a=>t({type:"SET_DEV_PANEL_TAB",tab:a});return s.jsxs("div",{style:{height:e.devPanelOpen?180:0,flexShrink:0,background:n.sidebarBg,borderTop:`1px solid ${n.headerBorder}`,display:"flex",flexDirection:"column",overflow:"hidden",transition:"height 0.2s ease",position:"relative"},children:[e.devPanelOpen&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{style:{height:32,flexShrink:0,display:"flex",alignItems:"center",borderBottom:`1px solid ${n.headerBorder}`,padding:"0 8px",gap:2},children:[["logs","errors"].map(a=>s.jsx(Q0,{label:a==="errors"?`Errors${i.length>0?` (${i.length})`:""}`:`Logs (${e.queryLog.length})`,active:e.devPanelTab===a,onClick:()=>l(a),t:n},a)),s.jsx("div",{style:{flex:1}}),s.jsx("button",{onClick:()=>t({type:"SET_CELLS",cells:e.cells}),title:"Clear logs",style:{background:"transparent",borderTop:"none",borderLeft:"none",borderRight:"none",borderBottom:"none",cursor:"pointer",color:n.textMuted,fontSize:11,fontFamily:n.font,padding:"2px 6px",borderRadius:4},children:"Clear"})]}),s.jsxs("div",{style:{flex:1,overflow:"auto",padding:"4px 0"},children:[e.devPanelTab==="logs"&&(e.queryLog.length===0?s.jsx(Aa,{t:n,message:"No queries executed yet."}):[...e.queryLog].reverse().map(a=>s.jsx(Ta,{entry:a,t:n},a.id))),e.devPanelTab==="errors"&&(i.length===0?s.jsx(Aa,{t:n,message:"No errors."}):[...i].reverse().map(a=>s.jsx(Ta,{entry:a,t:n},a.id)))]})]}),s.jsxs("button",{onClick:()=>t({type:"TOGGLE_DEV_PANEL"}),onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),title:e.devPanelOpen?"Close panel":"Open dev panel",style:{position:"absolute",bottom:e.devPanelOpen?4:-28,right:8,height:22,padding:"0 8px",borderRadius:"4px 4px 0 0",borderTop:`1px solid ${n.headerBorder}`,borderLeft:`1px solid ${n.headerBorder}`,borderRight:`1px solid ${n.headerBorder}`,borderBottom:e.devPanelOpen?`1px solid ${n.sidebarBg}`:`1px solid ${n.headerBorder}`,background:r?n.btnHover:n.sidebarBg,color:n.textMuted,cursor:"pointer",fontSize:11,fontFamily:n.font,display:"flex",alignItems:"center",gap:4,transition:"background 0.15s, bottom 0.2s ease",zIndex:10},children:[s.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",children:s.jsx("path",{d:e.devPanelOpen?"M1 7l4-4 4 4":"M1 3l4 4 4-4",strokeWidth:"1.5",stroke:"currentColor",fill:"none"})}),"Dev"]})]})}function Q0({label:e,active:t,onClick:n,t:r}){const[o,i]=u.useState(!1);return s.jsx("button",{onClick:n,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{background:"transparent",borderTop:"none",borderLeft:"none",borderRight:"none",borderBottom:t?`2px solid ${r.accent}`:"2px solid transparent",cursor:"pointer",color:t?r.textPrimary:o?r.textSecondary:r.textMuted,fontSize:12,fontFamily:r.font,fontWeight:t?500:400,padding:"4px 8px",height:32,transition:"color 0.15s"},children:e})}function Aa({t:e,message:t}){return s.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.textMuted,fontSize:12,fontFamily:e.font,fontStyle:"italic"},children:t})}function Ta({entry:e,t}){return s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"3px 12px",fontSize:11,fontFamily:t.fontMono,color:e.error?t.error:t.textSecondary,borderLeft:e.error?`2px solid ${t.error}`:"2px solid transparent"},children:[s.jsx("span",{style:{color:t.textMuted,flexShrink:0},children:H0(e.ts)}),s.jsx("span",{style:{flexShrink:0,color:t.textPrimary,maxWidth:160,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.cellName}),e.error?s.jsx("span",{style:{color:t.error,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.error}):s.jsxs(s.Fragment,{children:[s.jsxs("span",{style:{color:t.textMuted},children:[e.rows.toLocaleString()," rows"]}),s.jsx("span",{style:{color:t.textMuted},children:G0(e.time)})]})]})}function Y0(){const{state:e,dispatch:t}=ve(),{executeAll:n}=Ed();u.useEffect(()=>{const r=o=>{const i=o.metaKey||o.ctrlKey;if(i&&o.key==="b"&&!o.shiftKey){o.preventDefault(),t({type:"TOGGLE_SIDEBAR"});return}if(i&&o.shiftKey&&o.key==="Enter"){o.preventDefault(),e.activeFile&&n();return}if(i&&o.key==="j"&&!o.shiftKey){o.preventDefault(),t({type:"TOGGLE_DEV_PANEL"});return}if(i&&o.key==="d"&&!o.shiftKey){o.preventDefault(),e.activeFile&&t({type:"TOGGLE_DASHBOARD_MODE"});return}if(o.key==="Escape"){if(e.dashboardMode){t({type:"TOGGLE_DASHBOARD_MODE"});return}if(e.newNotebookModalOpen){t({type:"CLOSE_NEW_NOTEBOOK_MODAL"});return}if(e.newBlockModalOpen){t({type:"CLOSE_NEW_BLOCK_MODAL"});return}}};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[t,n,e.activeFile,e.newNotebookModalOpen,e.newBlockModalOpen,e.dashboardMode])}const X0=600;function Z0(e,t){const n=t.filter(r=>r.result||r.error||(r.executionCount??0)>0).map(r=>{var o;return{cellId:r.id,status:r.status,result:r.result,error:r.error,executionCount:r.executionCount,executedAt:((o=r.execution)==null?void 0:o.completedAt)??new Date().toISOString(),execution:r.execution}});return{version:1,notebookPath:e,capturedAt:new Date().toISOString(),cells:n}}function Ra(e){return e.map(t=>{var n,r;return`${t.id}:${((n=t.execution)==null?void 0:n.runId)??""}:${t.executionCount??0}:${((r=t.result)==null?void 0:r.rowCount)??-1}:${t.error??""}`}).join("|")}function e1(){var o;const{state:e}=ve(),t=u.useRef(null),n=u.useRef(""),r=u.useRef(null);u.useEffect(()=>{var a;const i=((a=e.activeFile)==null?void 0:a.path)??null;if(!i)return;if(i!==r.current){r.current=i,n.current=Ra(e.cells);return}const l=Ra(e.cells);return l!==n.current&&(n.current=l,t.current&&clearTimeout(t.current),t.current=setTimeout(()=>{const d=Z0(i,e.cells);N.saveRunSnapshot(i,d).catch(()=>{})},X0)),()=>{t.current&&(clearTimeout(t.current),t.current=null)}},[e.cells,(o=e.activeFile)==null?void 0:o.path])}const t1=u.lazy(()=>Ce(()=>import("./HomePage-DQSo-K4y.js"),__vite__mapDeps([0,1,2,3,4,5,6])).then(e=>({default:e.HomePage}))),n1=u.lazy(()=>Ce(()=>import("./AnalyticsHome-4TgtH6SB.js"),__vite__mapDeps([7,8,9,10,11,1,12,13,3,14,15,16,17,18,2,19,20,6])).then(e=>({default:e.AnalyticsHome}))),r1=u.lazy(()=>Ce(()=>import("./GlobalAiRail-B_MZsB0z.js"),__vite__mapDeps([21,9,10,11,1,12,13,3,14,15,16,17,18,2,19,22,23,24,6])).then(e=>({default:e.GlobalAiRail}))),o1=u.lazy(()=>Ce(()=>import("./NotebookEditor-D6RgLQw-.js"),__vite__mapDeps([25,4,2,5,26,27,28,11,9,10,1,12,13,3,14,15,16,17,18,19,8,29,30,6,31,32,22,23,24])).then(e=>({default:e.NotebookEditor}))),s1=u.lazy(()=>Ce(()=>import("./NewNotebookModal-xgaKB2kI.js"),__vite__mapDeps([33,4,15,6])).then(e=>({default:e.NewNotebookModal}))),i1=u.lazy(()=>Ce(()=>import("./NewBlockModal-BLtjuWGy.js"),__vite__mapDeps([34,6])).then(e=>({default:e.NewBlockModal}))),a1=u.lazy(()=>Ce(()=>import("./SetupOnboarding-DX2f53J2.js"),__vite__mapDeps([35,36,2,6])).then(e=>({default:e.SetupOnboarding}))),l1=u.lazy(()=>Ce(()=>import("./BlockStudio-DUXN3MKz.js"),__vite__mapDeps([37,26,27,11,29,30,6,31,9,10,1,12,13,3,14,15,16,17,18,2,19,22,23,24,38,39])).then(e=>({default:e.BlockStudio}))),c1=u.lazy(()=>Ce(()=>import("./BusinessArtifactView-D8FIgrkF.js"),__vite__mapDeps([40,29,30,6,31])).then(e=>({default:e.BusinessArtifactView}))),d1=u.lazy(()=>Ce(()=>import("./LineageDetailView-CZEx2r1H.js"),__vite__mapDeps([41,29,30,6,31,42,36,17])).then(e=>({default:e.LineageDetailView}))),u1=u.lazy(()=>Ce(()=>import("./LineageDAG-RdpWmGmR.js"),__vite__mapDeps([42,30,6,31])).then(e=>({default:e.LineageDAG}))),p1=u.lazy(()=>Ce(()=>import("./HelpDocsPage-Bc5pLakt.js"),__vite__mapDeps([43,6])).then(e=>({default:e.HelpDocsPage}))),f1=u.lazy(()=>Ce(()=>Promise.resolve().then(()=>DS),void 0).then(e=>({default:e.ConnectionPanel}))),h1=u.lazy(()=>Ce(()=>import("./GitPage-BS2sm9zh.js"),__vite__mapDeps([44,45,15,6])).then(e=>({default:e.GitPage}))),m1=u.lazy(()=>Ce(()=>import("./ReadinessPage-C8hATaT_.js"),__vite__mapDeps([46,1,47,48,13,3,2,6])).then(e=>({default:e.ReadinessPage}))),g1=u.lazy(()=>Ce(()=>import("./AgentLogPage-uvVs284-.js"),__vite__mapDeps([49,36,18,50,6])).then(e=>({default:e.AgentLogPage}))),y1=u.lazy(()=>Ce(()=>import("./GovernedContextPage-CNM5UCAH.js").then(e=>e.G),__vite__mapDeps([51,3,13,19,16,15])).then(e=>({default:e.GovernedContextPage}))),x1=u.lazy(()=>Ce(()=>import("./DbtFirstModelingPage-DR8hTZ95.js"),__vite__mapDeps([52,51,3,13,19,16,15,30,6,31,32,24,38,50,14])).then(e=>({default:e.DbtFirstModelingPage}))),b1=u.lazy(()=>Ce(()=>import("./AppsView-CnfNtk5W.js"),__vite__mapDeps([53,22,23,24,15,11,28,48,39,54,3,36,5,16,20,4,6])).then(e=>({default:e.AppsView}))),v1=u.lazy(()=>Ce(()=>import("./LineageDrawer-P7ZdOW8-.js"),__vite__mapDeps([55,29,30,6,31,38,15,23,14,54,45])).then(e=>({default:e.LineageDrawer}))),S1=u.lazy(()=>Ce(()=>import("./AiBuildDialog-DEUS19WF.js"),__vite__mapDeps([56,47,12,13,3,14,15,6])).then(e=>({default:e.AiBuildDialog})));function k1(){const{state:e,dispatch:t}=ve(),n=ze[e.themeMode],r=u.useRef({}),o=e.mainView==="block_studio"||e.mainView==="imports",[i,l]=u.useState(!1),[a,d]=u.useState(null),[c,f]=u.useState(!1);u.useEffect(()=>{let g=!0;return N.getSetupLaunch().then(S=>{g&&(d(S),S.shouldOpen&&t({type:"OPEN_SETUP"}))}).catch(()=>{}).finally(()=>{g&&f(!0)}),()=>{g=!1}},[t]),Y0(),e1(),u.useEffect(()=>{const g=S=>{(S.metaKey||S.ctrlKey)&&S.key.toLowerCase()==="k"&&!S.shiftKey&&(S.preventDefault(),l(x=>!x)),(S.metaKey||S.ctrlKey)&&S.shiftKey&&S.key.toLowerCase()==="i"&&(S.preventDefault(),t({type:"TOGGLE_INSPECTOR"}))};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[t]);const p=u.useCallback(async g=>{try{if(g.type==="term"||g.type==="business_view"){e.sidebarPanel!=="files"&&t({type:"SET_SIDEBAR_PANEL",panel:"files"}),t({type:"OPEN_BUSINESS_ARTIFACT",file:g});return}if(g.type==="block"){const v=await N.openBlockStudio(g.path);t({type:"OPEN_BLOCK_STUDIO",file:g,payload:v});return}const{content:S}=await N.readNotebook(g.path),{title:x,cells:b,metadata:k}=p0(g.path,S),C=g.path.endsWith(".dqlnb")?await N.fetchRunSnapshot(g.path):null;let E=b;if(C!=null&&C.found&&C.snapshot){const v=new Map(C.snapshot.cells.map(w=>[w.cellId,w]));E=b.map(w=>{const A=v.get(w.id);return A?{...w,status:A.status??w.status,result:A.result??w.result,error:A.error??w.error,executionCount:A.executionCount??w.executionCount,execution:A.execution??w.execution,fromSnapshot:A.result!=null}:w})}t({type:"OPEN_FILE",file:g,cells:E,title:x,metadata:k}),e.sidebarPanel!=="files"&&t({type:"SET_SIDEBAR_PANEL",panel:"files"})}catch(S){if(console.error("Failed to open file:",S),g.type==="block")try{const{content:x}=await N.readNotebook(g.path);t({type:"OPEN_BLOCK_STUDIO",file:g,payload:{path:g.path,source:x,companionPath:null,metadata:{name:g.name.replace(/\.dql$/i,""),path:g.path,domain:g.path.split("/").slice(1,-1).join("/")||"uncategorized",description:"",owner:"",tags:[]},validation:{valid:!1,diagnostics:[{severity:"warning",message:"Opened block without studio metadata. Save once to normalize it."}],semanticRefs:{metrics:[],dimensions:[],segments:[]}}}});return}catch(x){console.error("Failed to open block fallback:",x)}else t({type:"OPEN_FILE",file:g,cells:[Os("sql")],title:g.name})}},[t,e.sidebarPanel]);u.useCallback(g=>{const S=r.current[g];S&&S.scrollIntoView({behavior:"smooth",block:"start"})},[]);const h=u.useCallback((g,S)=>{S?r.current[g]=S:delete r.current[g]},[]);return s.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100vh",width:"100vw",background:n.appBg,fontFamily:n.font,color:n.textPrimary,overflow:"hidden"},children:[s.jsx(W0,{}),s.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[e.appMode==="studio"&&s.jsx(wb,{}),e.appMode==="studio"&&e.sidebarOpen&&!o&&s.jsx(s0,{onOpenFile:p}),s.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minWidth:0},children:s.jsx(u.Suspense,{fallback:s.jsx(w1,{t:n}),children:e.mainView==="home"?s.jsx(t1,{}):e.mainView==="ask"?s.jsx(n1,{}):e.mainView==="business_artifact"?s.jsx(c1,{}):e.mainView==="lineage"?s.jsx("div",{style:{flex:1,minWidth:0,minHeight:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:s.jsx(u1,{})}):e.mainView==="lineage_detail"?s.jsx(d1,{}):e.mainView==="help"?s.jsx(p1,{}):e.mainView==="connection"||e.mainView==="settings"?s.jsx(j1,{children:s.jsx(f1,{variant:"page"})}):e.mainView==="git"?s.jsx(h1,{}):e.mainView==="readiness"?s.jsx(m1,{}):e.mainView==="skills"?s.jsx(y1,{initialTab:"skills"}):e.mainView==="domains"||e.mainView==="modeling"?s.jsx(x1,{}):e.mainView==="apps"?s.jsx(b1,{}):e.mainView==="agent_log"?s.jsx(C1,{title:"Agent steps",description:"What the agent did to answer this question, and where the time went — route, tools, checks, and per-step timing.",children:s.jsx(g1,{})}):s.jsx(s.Fragment,{children:e.mainView==="imports"||e.mainView==="block_studio"?s.jsx(l1,{},"block-editor"):s.jsxs(s.Fragment,{children:[s.jsx(o1,{onOpenFile:p,registerCellRef:h}),e.appMode==="studio"&&s.jsx(J0,{})]})})})}),e.appMode==="studio"&&e.lineageDrawerOpen&&!e.lineageFullscreen&&!e.dashboardMode&&s.jsx(u.Suspense,{fallback:null,children:s.jsx(v1,{})}),e.appMode==="studio"&&e.inspectorOpen&&!e.lineageFullscreen&&!e.lineageDrawerOpen&&!e.dashboardMode&&s.jsx(ub,{}),e.globalAi.open&&e.mainView==="apps"&&s.jsx(u.Suspense,{fallback:null,children:s.jsx(r1,{})})]}),e.newNotebookModalOpen&&s.jsx(u.Suspense,{fallback:null,children:s.jsx(s1,{onFileOpened:p})}),e.newBlockModalOpen&&s.jsx(u.Suspense,{fallback:null,children:s.jsx(i1,{onFileOpened:p})}),s.jsx(Rx,{open:i,onClose:()=>l(!1)}),s.jsx(u.Suspense,{fallback:null,children:s.jsx(S1,{})}),e.setupOpen&&s.jsx(u.Suspense,{fallback:s.jsx(_a,{t:n}),children:s.jsx(a1,{launch:a!=null&&a.shouldOpen?a:void 0,onAcknowledged:()=>d(g=>g&&{...g,shouldOpen:!1,reason:null})})}),!c&&s.jsx(_a,{t:n})]})}function w1({t:e}){return s.jsx("div",{role:"status","aria-live":"polite",style:{flex:1,minWidth:0,display:"grid",placeItems:"center",background:e.appBg,color:e.textSecondary,fontFamily:e.font},children:s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,fontSize:12.5},children:[s.jsx("span",{style:{width:8,height:8,borderRadius:999,background:e.accent}}),"Loading workspace…"]})})}function _a({t:e}){return s.jsx("div",{role:"status","aria-live":"polite",style:{position:"fixed",inset:0,zIndex:1100,display:"grid",placeItems:"center",background:e.appBg,color:e.textSecondary,fontFamily:e.font},children:s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,fontSize:12.5},children:[s.jsx("span",{style:{width:8,height:8,borderRadius:999,background:e.accent}}),"Checking workspace setup…"]})})}function j1({children:e}){return s.jsx("div",{style:{flex:1,minWidth:0,overflow:"auto"},children:s.jsx("div",{style:{maxWidth:1120,margin:"0 auto",padding:"18px 28px 32px"},children:e})})}function C1({title:e,description:t,children:n}){return s.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0,overflow:"hidden"},children:[s.jsxs("div",{style:{padding:"18px 24px 12px",borderBottom:"1px solid rgba(127, 127, 127, 0.16)"},children:[s.jsx("div",{style:{fontSize:22,fontWeight:700},children:e}),s.jsx("div",{style:{fontSize:13,opacity:.72,marginTop:6,maxWidth:760,lineHeight:1.5},children:t})]}),s.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto"},children:n})]})}function E1(){const{state:e,dispatch:t}=ve(),n=u.useRef(null),r=u.useRef(null);u.useEffect(()=>{var o;n.current=((o=e.activeFile)==null?void 0:o.path)??null},[e.activeFile]),u.useEffect(()=>{if(typeof EventSource>"u")return;const o=()=>{const i=new EventSource(`${window.location.origin}/api/watch`);r.current=i,i.addEventListener("change",l=>{try{const a=JSON.parse(l.data);(a.type==="file-added"||a.type==="file-deleted")&&N.listNotebooks().then(d=>{t({type:"SET_FILES",files:d})}),a.type==="file-changed"&&N.listNotebooks().then(d=>{t({type:"SET_FILES",files:d})}),a.type==="semantic-reload"&&(t({type:"SET_SEMANTIC_LOADING",loading:!0}),N.getSemanticLayer().then(d=>{t({type:"SET_SEMANTIC_LAYER",layer:d})}))}catch{}}),i.addEventListener("error",()=>{i.close(),setTimeout(o,5e3)})};return o(),()=>{var i;(i=r.current)==null||i.close(),r.current=null}},[t])}function A1(){const{state:e,dispatch:t}=ve(),n=ze[e.themeMode];u.useEffect(()=>{const o="dql-global-styles";let i=document.getElementById(o);i||(i=document.createElement("style"),i.id=o,document.head.appendChild(i)),i.textContent=`
620
620
  * { margin: 0; padding: 0; box-sizing: border-box; }
621
621
  body {
622
622
  font-family: var(--font-ui, ${n.font});