@duckcodeailabs/dql-cli 0.1.8 → 0.1.9

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.
@@ -1,4 +1,4 @@
1
- import{r as ge,a as Me,g as Le}from"./react-CRB3T2We.js";import{k as Be,i as Te,d as Ae,E as V,o as $e,s as De,l as Re,h as Oe,a as _e}from"./codemirror-CHXCUnwU.js";(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))o(i);new MutationObserver(i=>{for(const l of i)if(l.type==="childList")for(const s of l.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&o(s)}).observe(document,{childList:!0,subtree:!0});function n(i){const l={};return i.integrity&&(l.integrity=i.integrity),i.referrerPolicy&&(l.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?l.credentials="include":i.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function o(i){if(i.ep)return;i.ep=!0;const l=n(i);fetch(i.href,l)}})();var K={exports:{}},z={};/**
1
+ import{r as ge,a as Me,g as Le}from"./react-CRB3T2We.js";import{k as Be,i as Te,d as Ae,E as V,o as $e,s as De,l as Re,h as Fe,a as Oe}from"./codemirror-CHXCUnwU.js";(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))o(i);new MutationObserver(i=>{for(const l of i)if(l.type==="childList")for(const s of l.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&o(s)}).observe(document,{childList:!0,subtree:!0});function n(i){const l={};return i.integrity&&(l.integrity=i.integrity),i.referrerPolicy&&(l.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?l.credentials="include":i.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function o(i){if(i.ep)return;i.ep=!0;const l=n(i);fetch(i.href,l)}})();var Q={exports:{}},P={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,29 +6,44 @@ import{r as ge,a as Me,g as Le}from"./react-CRB3T2We.js";import{k as Be,i as Te,
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var re;function Fe(){if(re)return z;re=1;var e=ge(),r=Symbol.for("react.element"),n=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function s(a,c,x){var d,u={},p=null,m=null;x!==void 0&&(p=""+x),c.key!==void 0&&(p=""+c.key),c.ref!==void 0&&(m=c.ref);for(d in c)o.call(c,d)&&!l.hasOwnProperty(d)&&(u[d]=c[d]);if(a&&a.defaultProps)for(d in c=a.defaultProps,c)u[d]===void 0&&(u[d]=c[d]);return{$$typeof:r,type:a,key:p,ref:m,props:u,_owner:i.current}}return z.Fragment=n,z.jsx=s,z.jsxs=s,z}var ie;function Ne(){return ie||(ie=1,K.exports=Fe()),K.exports}var t=Ne(),q={},le;function He(){if(le)return q;le=1;var e=Me();return q.createRoot=e.createRoot,q.hydrateRoot=e.hydrateRoot,q}var Ie=He(),f=ge();const U=Le(f),ze={themeMode:"dark",sidebarPanel:"files",sidebarOpen:!0,files:[],filesLoading:!1,activeFile:null,cells:[],notebookTitle:"",notebookDirty:!1,schemaTables:[],schemaLoading:!1,devPanelOpen:!1,devPanelTab:"logs",queryLog:[],newNotebookModalOpen:!1,executionCounter:0,savingFile:!1};function Pe(e,r){switch(r.type){case"SET_THEME":return{...e,themeMode:r.mode};case"SET_SIDEBAR_PANEL":return{...e,sidebarPanel:r.panel,sidebarOpen:r.panel!==null};case"TOGGLE_SIDEBAR":return{...e,sidebarOpen:!e.sidebarOpen};case"SET_FILES":return{...e,files:r.files};case"SET_FILES_LOADING":return{...e,filesLoading:r.loading};case"OPEN_FILE":return{...e,activeFile:r.file,cells:r.cells,notebookTitle:r.title,notebookDirty:!1};case"SET_CELLS":return{...e,cells:r.cells,notebookDirty:!0};case"ADD_CELL":{if(!r.afterId)return{...e,cells:[...e.cells,r.cell],notebookDirty:!0};const n=e.cells.findIndex(i=>i.id===r.afterId);if(n===-1)return{...e,cells:[...e.cells,r.cell],notebookDirty:!0};const o=[...e.cells];return o.splice(n+1,0,r.cell),{...e,cells:o,notebookDirty:!0}}case"UPDATE_CELL":{const n=e.cells.map(i=>i.id===r.id?{...i,...r.updates}:i),o=r.updates.executionCount!==void 0?e.executionCounter+1:e.executionCounter;return{...e,cells:n,notebookDirty:!0,executionCounter:o}}case"DELETE_CELL":return{...e,cells:e.cells.filter(n=>n.id!==r.id),notebookDirty:!0};case"MOVE_CELL":{const n=e.cells.findIndex(i=>i.id===r.id);if(n===-1)return e;const o=[...e.cells];return r.direction==="up"&&n>0?[o[n-1],o[n]]=[o[n],o[n-1]]:r.direction==="down"&&n<o.length-1&&([o[n],o[n+1]]=[o[n+1],o[n]]),{...e,cells:o,notebookDirty:!0}}case"SET_SCHEMA":return{...e,schemaTables:r.tables};case"SET_SCHEMA_LOADING":return{...e,schemaLoading:r.loading};case"TOGGLE_SCHEMA_TABLE":return{...e,schemaTables:e.schemaTables.map(n=>n.name===r.tableName?{...n,expanded:!n.expanded}:n)};case"TOGGLE_DEV_PANEL":return{...e,devPanelOpen:!e.devPanelOpen};case"SET_DEV_PANEL_TAB":return{...e,devPanelTab:r.tab};case"APPEND_QUERY_LOG":return{...e,queryLog:[...e.queryLog,r.entry]};case"OPEN_NEW_NOTEBOOK_MODAL":return{...e,newNotebookModalOpen:!0};case"CLOSE_NEW_NOTEBOOK_MODAL":return{...e,newNotebookModalOpen:!1};case"SET_NOTEBOOK_DIRTY":return{...e,notebookDirty:r.dirty};case"SET_SAVING":return{...e,savingFile:r.saving};case"FILE_ADDED":return{...e,files:[...e.files,r.file]};case"SET_TABLE_COLUMNS":return{...e,schemaTables:e.schemaTables.map(n=>n.name===r.tableName?{...n,columns:r.columns}:n)};case"SET_PARAM_VALUE":return{...e,cells:e.cells.map(n=>n.id===r.id?{...n,paramValue:r.value}:n),notebookDirty:!0};default:return e}}const me=f.createContext(null);function We({children:e}){const[r,n]=f.useReducer(Pe,ze);return t.jsx(me.Provider,{value:{state:r,dispatch:n},children:e})}function w(){const e=f.useContext(me);if(!e)throw new Error("useNotebook must be used within NotebookProvider");return e}function R(){return`cell_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function A(e,r=""){const n={id:R(),type:e,content:r,status:"idle"};return e==="param"&&(n.content="",n.paramConfig={paramType:"text",label:"Parameter",defaultValue:"",options:[]}),n}const Ze={appBg:"#0d1117",sidebarBg:"#161b22",activityBarBg:"#0d1117",headerBg:"#161b22",headerBorder:"#21262d",cellBg:"#161b22",cellBorder:"#30363d",cellBorderActive:"#388bfd",cellBorderRunning:"#56d364",textPrimary:"#e6edf3",textSecondary:"#8b949e",textMuted:"#484f58",editorBg:"#0d1117",editorBorder:"#30363d",tableBorder:"#30363d",tableHeaderBg:"#1c2128",tableRowHover:"#21262d",accent:"#388bfd",accentHover:"#58a6ff",success:"#56d364",error:"#f85149",warning:"#e3b341",btnBg:"#21262d",btnBorder:"#30363d",btnHover:"#30363d",sidebarItemHover:"#21262d",sidebarItemActive:"#1f2d3d",scrollbarThumb:"#30363d",modalBg:"#161b22",modalOverlay:"rgba(0,0,0,0.7)",inputBg:"#0d1117",inputBorder:"#30363d",pillBg:"#21262d",font:"Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",fontMono:"'JetBrains Mono', 'Fira Code', Consolas, monospace",fontSerif:"Georgia, 'Times New Roman', serif"},Ve={appBg:"#ffffff",sidebarBg:"#f6f8fa",activityBarBg:"#eff1f3",headerBg:"#ffffff",headerBorder:"#d0d7de",cellBg:"#ffffff",cellBorder:"#d0d7de",cellBorderActive:"#0969da",cellBorderRunning:"#1f883d",textPrimary:"#1f2328",textSecondary:"#57606a",textMuted:"#8c959f",editorBg:"#f6f8fa",editorBorder:"#d0d7de",tableBorder:"#d0d7de",tableHeaderBg:"#f6f8fa",tableRowHover:"#f6f8fa",accent:"#0969da",accentHover:"#0550ae",success:"#1f883d",error:"#cf222e",warning:"#9a6700",btnBg:"#f6f8fa",btnBorder:"#d0d7de",btnHover:"#eaeef2",sidebarItemHover:"#eaeef2",sidebarItemActive:"#dbeafe",scrollbarThumb:"#d0d7de",modalBg:"#ffffff",modalOverlay:"rgba(0,0,0,0.4)",inputBg:"#ffffff",inputBorder:"#d0d7de",pillBg:"#eaeef2",font:"Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",fontMono:"'JetBrains Mono', 'Fira Code', Consolas, monospace",fontSerif:"Georgia, 'Times New Roman', serif"},S={dark:Ze,light:Ve};function P({title:e,active:r,onClick:n,children:o,t:i}){const[l,s]=f.useState(!1);return t.jsx("button",{title:e,onClick:n,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",border:"none",borderLeft:r?`2px solid ${i.accent}`:"2px solid transparent",cursor:"pointer",color:r?i.textPrimary:l?i.textSecondary:i.textMuted,transition:"color 0.15s, border-color 0.15s",padding:0,flexShrink:0},children:o})}function qe(){return t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M1.75 1A1.75 1.75 0 0 0 0 2.75v10.5C0 14.216.784 15 1.75 15h12.5A1.75 1.75 0 0 0 16 13.25v-8.5A1.75 1.75 0 0 0 14.25 3H7.5a.25.25 0 0 1-.2-.1l-.9-1.2C6.07 1.26 5.55 1 5 1H1.75Z"})})}function Ue(){return t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M8 0C3.58 0 0 1.567 0 3.5v9C0 14.433 3.58 16 8 16s8-1.567 8-3.5v-9C16 1.567 12.42 0 8 0ZM1.5 7.784V5.716C3.05 6.51 5.404 7 8 7s4.95-.49 6.5-1.284v2.068C12.95 8.578 10.596 9 8 9s-4.95-.422-6.5-1.216ZM8 1.5c3.17 0 5.854 1.116 6.357 2.5H1.643C2.146 2.616 4.83 1.5 8 1.5Zm0 13c-3.17 0-5.854-1.116-6.357-2.5h12.714C13.854 13.384 11.17 14.5 8 14.5Zm6.5-3.284C12.95 11.01 10.596 11.5 8 11.5s-4.95-.49-6.5-1.284V8.216C3.05 9.01 5.404 9.5 8 9.5s4.95-.49 6.5-1.284v2.5Z"})})}function Ge(){return t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M2 2h12a1 1 0 0 1 0 2H2a1 1 0 0 1 0-2Zm0 4h8a1 1 0 0 1 0 2H2a1 1 0 0 1 0-2Zm0 4h10a1 1 0 0 1 0 2H2a1 1 0 0 1 0-2Z"})})}function Ke(){return t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.92 6.085h.001a.749.749 0 1 1-1.342-.67C6.03 4.26 6.88 3.75 8 3.75c1.463 0 2.5 1.008 2.5 2.25 0 1.133-.67 1.8-1.4 2.25-.487.3-.6.47-.6.75V9.5a.75.75 0 0 1-1.5 0v-.5c0-.833.585-1.33 1.1-1.65.387-.24.9-.597.9-1.35 0-.65-.53-1.25-1.5-1.25-.74 0-1.163.353-1.58.835ZM8 12a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"})})}function Qe(){return t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M8 0a8.2 8.2 0 0 1 .701.031C9.444.095 9.99.645 10.16 1.29l.288 1.107c.018.066.079.158.212.224.231.114.454.243.668.386.123.082.233.09.299.071l1.103-.303c.644-.176 1.392.021 1.82.63.27.385.506.792.704 1.218.315.675.111 1.422-.364 1.891l-.814.806c-.049.048-.098.147-.088.294.016.257.016.515 0 .772-.01.147.038.246.088.294l.814.806c.475.469.679 1.216.364 1.891a7.977 7.977 0 0 1-.704 1.217c-.428.61-1.176.807-1.82.63l-1.103-.303c-.066-.019-.176-.011-.299.071a5.909 5.909 0 0 1-.668.386c-.133.066-.194.158-.211.224l-.29 1.106c-.168.646-.715 1.196-1.458 1.26a8.006 8.006 0 0 1-1.402 0c-.743-.064-1.289-.614-1.458-1.26l-.289-1.106c-.018-.066-.079-.158-.212-.224a5.738 5.738 0 0 1-.668-.386c-.123-.082-.233-.09-.299-.071l-1.103.303c-.644.176-1.392-.021-1.82-.63a8.12 8.12 0 0 1-.704-1.218c-.315-.675-.111-1.422.363-1.891l.815-.806c.05-.048.098-.147.088-.294a6.214 6.214 0 0 1 0-.772c.01-.147-.038-.246-.088-.294l-.815-.806C.635 6.045.431 5.298.746 4.623a7.92 7.92 0 0 1 .704-1.217c.428-.61 1.176-.807 1.82-.63l1.103.303c.066.019.176.011.299-.071.214-.143.437-.272.668-.386.133-.066.194-.158.211-.224l.29-1.106C6.009.645 6.556.095 7.299.03 7.53.01 7.764 0 8 0Zm-.571 1.525c-.036.003-.108.036-.137.146l-.289 1.105c-.147.561-.549.967-.998 1.189-.173.086-.34.183-.5.29-.417.278-.97.423-1.529.27l-1.103-.303c-.109-.03-.175.016-.195.045-.22.312-.412.644-.573.99-.014.031-.021.11.059.19l.815.806c.411.406.562.957.53 1.456a4.709 4.709 0 0 0 0 .582c.032.499-.119 1.05-.53 1.456l-.815.806c-.081.08-.073.159-.059.19.162.346.353.677.573.989.02.03.085.076.195.046l1.102-.303c.56-.153 1.113-.008 1.53.27.161.107.328.204.501.29.447.222.85.629.997 1.189l.289 1.105c.029.109.101.143.137.146a6.6 6.6 0 0 0 1.142 0c.036-.003.108-.036.137-.146l.289-1.105c.147-.561.549-.967.998-1.189.173-.086.34-.183.5-.29.417-.278.97-.423 1.529-.27l1.103.303c.109.029.175-.016.195-.045.22-.313.411-.644.573-.99.014-.031.021-.11-.059-.19l-.815-.806c-.411-.406-.562-.957-.53-1.456a4.709 4.709 0 0 0 0-.582c-.032-.499.119-1.05.53-1.456l.815-.806c.081-.08.073-.159.059-.19a6.464 6.464 0 0 0-.573-.989c-.02-.03-.085-.076-.195-.046l-1.102.303c-.56.153-1.113.008-1.53-.27a4.44 4.44 0 0 0-.501-.29c-.447-.222-.85-.629-.997-1.189l-.289-1.105c-.029-.11-.101-.143-.137-.147a6.6 6.6 0 0 0-1.142 0ZM8 5.5a2.5 2.5 0 1 1 0 5 2.5 2.5 0 0 1 0-5ZM8 7a1 1 0 1 0 0 2 1 1 0 0 0 0-2Z"})})}function Ye(){const{state:e,dispatch:r}=w(),n=S[e.themeMode];function o(i){e.sidebarPanel===i&&e.sidebarOpen?r({type:"TOGGLE_SIDEBAR"}):r({type:"SET_SIDEBAR_PANEL",panel:i})}return t.jsxs("div",{style:{width:32,flexShrink:0,background:n.activityBarBg,borderRight:`1px solid ${n.headerBorder}`,display:"flex",flexDirection:"column",alignItems:"center",paddingTop:8,paddingBottom:8,gap:2,userSelect:"none"},children:[t.jsx(P,{title:"Files",active:e.sidebarPanel==="files"&&e.sidebarOpen,onClick:()=>o("files"),t:n,children:t.jsx(qe,{})}),t.jsx(P,{title:"Schema",active:e.sidebarPanel==="schema"&&e.sidebarOpen,onClick:()=>o("schema"),t:n,children:t.jsx(Ue,{})}),t.jsx(P,{title:"Outline",active:e.sidebarPanel==="outline"&&e.sidebarOpen,onClick:()=>o("outline"),t:n,children:t.jsx(Ge,{})}),t.jsx("div",{style:{flex:1}}),t.jsx(P,{title:"Help",active:!1,onClick:()=>{},t:n,children:t.jsx(Ke,{})}),t.jsx(P,{title:"Settings",active:!1,onClick:()=>{},t:n,children:t.jsx(Qe,{})})]})}const Q={notebooks:"Notebooks",workbooks:"Workbooks",blocks:"Blocks",dashboards:"Dashboards"};function Je({type:e}){switch(e){case"notebook":return t.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M0 1.75A.75.75 0 0 1 .75 1h4.253c1.227 0 2.317.59 3 1.501A3.743 3.743 0 0 1 11.006 1h4.245a.75.75 0 0 1 .75.75v10.5a.75.75 0 0 1-.75.75h-4.507a2.25 2.25 0 0 0-1.591.659l-.622.621a.75.75 0 0 1-1.063 0L7.597 13.66A2.25 2.25 0 0 0 6.007 13H.75a.75.75 0 0 1-.75-.75Zm7.251 10.324.004-5.073-.002-2.253A2.25 2.25 0 0 0 5.003 2.5H1.5v9h4.507c.656 0 1.287.169 1.744.324Zm1.499.004c.457-.155 1.088-.324 1.744-.324H15v-9h-3.495a2.25 2.25 0 0 0-2.252 2.247l-.002 9.077Z"})});case"workbook":return t.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M2 1.75C2 .784 2.784 0 3.75 0h8.5C13.216 0 14 .784 14 1.75v12.5A1.75 1.75 0 0 1 12.25 16h-8.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25Zm2 3.5a.75.75 0 0 1 .75-.75h3a.75.75 0 0 1 0 1.5h-3a.75.75 0 0 1-.75-.75ZM6.5 7.25a.75.75 0 0 0 0 1.5h3a.75.75 0 0 0 0-1.5Zm-.75 3.5a.75.75 0 0 1 .75-.75h3a.75.75 0 0 1 0 1.5h-3a.75.75 0 0 1-.75-.75Z"})});case"block":return t.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M10.5 0l5.25 4-5.25 4V6H9.25A1.75 1.75 0 0 0 7.5 7.75v2.5A1.75 1.75 0 0 0 9.25 12h1.25v8H9v-6.5A3.25 3.25 0 0 1 5.75 10h-2A3.25 3.25 0 0 1 .5 6.75v-2.5A3.25 3.25 0 0 1 3.75 1h2A3.25 3.25 0 0 1 9 4.5V6h1.5V0z"})});default:return t.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M.24 2.375C.24 1.064 1.225.001 2.409.001h6.451a1.17 1.17 0 0 1 .828.344l3.311 3.312a1.17 1.17 0 0 1 .344.828v9.14c0 1.31-.985 2.374-2.169 2.374H2.41C1.225 16 .24 14.937.24 13.625Zm2.169-1a.846.846 0 0 0-.844.86v11.39c0 .47.38.86.844.86h8.774a.847.847 0 0 0 .844-.86V5.157L8.688 1.373H2.41Z"})})}}function Xe({expanded:e}){return t.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"currentColor",children:e?t.jsx("path",{d:"M1.75 2.5a.25.25 0 0 0-.25.25v10.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V4.25a.25.25 0 0 0-.25-.25H7.5A1.75 1.75 0 0 1 5.75 2.5h-4ZM0 2.75C0 1.784.784 1 1.75 1h4c.966 0 1.75.784 1.75 1.75H14.25c.966 0 1.75.784 1.75 1.75v8.5A1.75 1.75 0 0 1 14.25 14H1.75A1.75 1.75 0 0 1 0 12.25Z"}):t.jsx("path",{d:"M1.75 2.5a.25.25 0 0 0-.25.25v10.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V4.25a.25.25 0 0 0-.25-.25H7.5A1.75 1.75 0 0 1 5.75 2.5h-4ZM0 2.75C0 1.784.784 1 1.75 1h4c.966 0 1.75.784 1.75 1.75H14.25c.966 0 1.75.784 1.75 1.75v8.5A1.75 1.75 0 0 1 14.25 14H1.75A1.75 1.75 0 0 1 0 12.25Z"})})}function et(e){return e.name.replace(/\.(dqlnb|dql)$/,"")}function tt({onOpenFile:e}){const{state:r,dispatch:n}=w(),o=S[r.themeMode],[i,l]=f.useState({notebooks:!0,workbooks:!0,blocks:!1,dashboards:!1}),[s,a]=f.useState(!1),c={notebooks:[],workbooks:[],blocks:[],dashboards:[]};for(const d of r.files){const u=d.folder.toLowerCase();u in c&&c[u].push(d)}const x=d=>{l(u=>({...u,[d]:!u[d]}))};return t.jsxs("div",{style:{flex:1,overflow:"auto",padding:"8px 0",display:"flex",flexDirection:"column",gap:0},children:[t.jsx("div",{style:{padding:"0 8px 8px"},children:t.jsxs("button",{onClick:()=>n({type:"OPEN_NEW_NOTEBOOK_MODAL"}),onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:{width:"100%",height:30,background:"transparent",border:`1px dashed ${s?o.accent:o.cellBorder}`,borderRadius:6,color:s?o.accent:o.textSecondary,cursor:"pointer",fontSize:12,fontFamily:o.font,fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",gap:6,transition:"border-color 0.15s, color 0.15s"},children:[t.jsx("span",{style:{fontSize:16,lineHeight:1},children:"+"}),"New Notebook"]})}),r.filesLoading&&t.jsx("div",{style:{padding:"8px 14px",color:o.textMuted,fontSize:12,fontFamily:o.font},children:"Loading files…"}),Object.keys(Q).map(d=>{const u=c[d],p=i[d];return t.jsxs("div",{children:[t.jsx(nt,{label:Q[d],count:u.length,expanded:p,onToggle:()=>x(d),t:o}),p&&t.jsx("div",{children:u.length===0?t.jsxs("div",{style:{padding:"4px 14px 4px 32px",fontSize:12,color:o.textMuted,fontFamily:o.font,fontStyle:"italic"},children:["No ",Q[d].toLowerCase()]}):u.map(m=>{var g;return t.jsx(ot,{file:m,active:((g=r.activeFile)==null?void 0:g.path)===m.path,onClick:()=>e(m),t:o},m.path)})})]},d)})]})}function nt({label:e,count:r,expanded:n,onToggle:o,t:i}){const[l,s]=f.useState(!1);return t.jsxs("button",{onClick:o,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{width:"100%",display:"flex",alignItems:"center",gap:6,padding:"3px 8px 3px 10px",background:l?i.sidebarItemHover:"transparent",border:"none",cursor:"pointer",color:i.textSecondary,fontSize:11,fontWeight:600,fontFamily:i.font,letterSpacing:"0.04em",textTransform:"uppercase",textAlign:"left",transition:"background 0.1s"},children:[t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",style:{transform:n?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.15s",flexShrink:0},children:t.jsx("path",{d:"M3 2l4 3-4 3V2Z"})}),t.jsx(Xe,{expanded:n}),t.jsx("span",{style:{flex:1},children:e}),r>0&&t.jsx("span",{style:{background:i.pillBg,color:i.textMuted,borderRadius:10,padding:"0 5px",fontSize:10,fontWeight:500},children:r})]})}function ot({file:e,active:r,onClick:n,t:o}){const[i,l]=f.useState(!1);return t.jsxs("button",{onClick:n,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{width:"100%",display:"flex",alignItems:"center",gap:6,padding:"4px 8px 4px 26px",background:r?o.sidebarItemActive:i?o.sidebarItemHover:"transparent",border:"none",borderLeft:r?`2px solid ${o.accent}`:"2px solid transparent",cursor:"pointer",color:r||i?o.textPrimary:o.textSecondary,fontSize:13,fontFamily:o.font,textAlign:"left",transition:"background 0.1s, color 0.1s",overflow:"hidden"},children:[t.jsx("span",{style:{flexShrink:0,color:r?o.accent:o.textMuted},children:t.jsx(Je,{type:e.type})}),t.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:et(e)}),e.isNew&&t.jsx("span",{style:{fontSize:9,fontWeight:600,color:o.accent,background:o.sidebarItemActive,borderRadius:4,padding:"1px 4px",flexShrink:0},children:"NEW"})]})}const rt=window.location.origin;async function H(e,r){const n=await fetch(`${rt}${e}`,{headers:{"Content-Type":"application/json"},...r});if(!n.ok){const o=await n.text().catch(()=>n.statusText);throw new Error(o||`HTTP ${n.status}`)}if(n.status!==204)return n.json()}const $={async listNotebooks(){try{return await H("/api/notebooks")}catch{return[]}},async readNotebook(e){return H(`/api/notebook-content?path=${encodeURIComponent(e)}`)},async createNotebook(e,r){return H("/api/notebooks",{method:"POST",body:JSON.stringify({name:e,template:r})})},async saveNotebook(e,r){return H("/api/notebook-content",{method:"PUT",body:JSON.stringify({path:e,content:r})})},async executeQuery(e){return H("/api/query",{method:"POST",body:JSON.stringify({sql:e})})},async getSchema(){try{return await H("/api/schema")}catch{return[]}},async describeTable(e){const n=`DESCRIBE SELECT * FROM read_csv_auto('${e.replace(/'/g,"''")}') LIMIT 0`;try{return(await H("/api/query",{method:"POST",body:JSON.stringify({sql:n})})).rows.map(i=>({name:String(i.column_name??i.Field??""),type:String(i.column_type??i.Type??"")}))}catch{return[]}}},it={varchar:"#388bfd",text:"#388bfd",string:"#388bfd",char:"#388bfd",integer:"#56d364",int:"#56d364",bigint:"#56d364",smallint:"#56d364",float:"#56d364",double:"#56d364",decimal:"#56d364",numeric:"#56d364",real:"#56d364",date:"#e3b341",timestamp:"#e3b341",datetime:"#e3b341",time:"#e3b341",boolean:"#f778ba",bool:"#f778ba",json:"#79c0ff",jsonb:"#79c0ff",uuid:"#d2a8ff",bytea:"#ffa657",binary:"#ffa657"};function se(e,r){const n=e.toLowerCase().split("(")[0].trim();return it[n]??r}function lt({t:e}){return t.jsxs("div",{style:{padding:"8px 12px",display:"flex",flexDirection:"column",gap:8},children:[[1,2,3].map(r=>t.jsx("div",{style:{height:28,borderRadius:4,background:e.pillBg,opacity:.6,animation:"pulse 1.5s ease-in-out infinite"}},r)),t.jsx("style",{children:"@keyframes pulse { 0%,100%{opacity:.6} 50%{opacity:.3} }"})]})}function st(){const{state:e,dispatch:r}=w(),n=S[e.themeMode],[o,i]=f.useState(!1),l=async()=>{r({type:"SET_SCHEMA_LOADING",loading:!0});try{const s=await $.getSchema();r({type:"SET_SCHEMA",tables:s})}catch(s){console.error("Schema refresh failed:",s)}finally{r({type:"SET_SCHEMA_LOADING",loading:!1})}};return t.jsxs("div",{style:{flex:1,overflow:"auto",display:"flex",flexDirection:"column"},children:[t.jsxs("div",{style:{padding:"8px 10px",display:"flex",alignItems:"center",gap:6,borderBottom:`1px solid ${n.headerBorder}`},children:[t.jsxs("span",{style:{flex:1,fontSize:11,color:n.textMuted,fontFamily:n.font},children:[e.schemaTables.length," tables"]}),t.jsxs("button",{onClick:l,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),title:"Refresh schema",style:{background:o?n.btnHover:"transparent",border:`1px solid ${o?n.btnBorder:"transparent"}`,borderRadius:4,cursor:"pointer",color:o?n.textSecondary:n.textMuted,fontSize:11,fontFamily:n.font,padding:"2px 6px",display:"flex",alignItems:"center",gap:4,transition:"all 0.15s"},children:[t.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M1.705 8.005a.75.75 0 0 1 .834.656 5.5 5.5 0 0 0 9.592 2.97l-1.204-1.204a.25.25 0 0 1 .177-.427h3.646a.25.25 0 0 1 .25.25v3.646a.25.25 0 0 1-.427.177l-1.38-1.38A7.002 7.002 0 0 1 1.05 8.84a.75.75 0 0 1 .656-.834ZM8 2.5a5.487 5.487 0 0 0-4.131 1.869l1.204 1.204A.25.25 0 0 1 4.896 6H1.25A.25.25 0 0 1 1 5.75V2.104a.25.25 0 0 1 .427-.177l1.38 1.38A7.002 7.002 0 0 1 14.95 7.16a.75.75 0 0 1-1.49.178A5.5 5.5 0 0 0 8 2.5Z"})}),"Refresh"]})]}),e.schemaLoading?t.jsx(lt,{t:n}):e.schemaTables.length===0?t.jsxs("div",{style:{padding:"24px 14px",color:n.textMuted,fontSize:12,fontFamily:n.font,textAlign:"center",fontStyle:"italic"},children:["No tables found.",t.jsx("br",{}),"Connect a data source to explore schema."]}):t.jsx("div",{style:{overflow:"auto",flex:1},children:e.schemaTables.map(s=>t.jsx(at,{table:s,t:n},s.name))})]})}function at({table:e,t:r}){const{dispatch:n}=w(),[o,i]=f.useState(!1),[l,s]=f.useState(!1),a=async()=>{if(n({type:"TOGGLE_SCHEMA_TABLE",tableName:e.name}),!e.expanded&&e.columns.length===0){s(!0);try{const c=await $.describeTable(e.path);c.length>0&&n({type:"SET_TABLE_COLUMNS",tableName:e.name,columns:c})}catch(c){console.error("describeTable failed:",c)}finally{s(!1)}}};return t.jsxs("div",{children:[t.jsxs("button",{onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),onClick:a,style:{width:"100%",display:"flex",alignItems:"center",gap:6,padding:"5px 10px",background:o?r.sidebarItemHover:"transparent",border:"none",cursor:"pointer",color:r.textPrimary,fontSize:12,fontFamily:r.font,fontWeight:500,textAlign:"left",transition:"background 0.1s"},children:[t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",style:{transform:e.expanded?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.15s",flexShrink:0,color:r.textMuted},children:t.jsx("path",{d:"M3 2l4 3-4 3V2Z"})}),t.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"currentColor",style:{color:r.accent,flexShrink:0},children:t.jsx("path",{d:"M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v1.5A1.75 1.75 0 0 1 14.25 5H1.75A1.75 1.75 0 0 1 0 3.25Zm1.75-.25a.25.25 0 0 0-.25.25v1.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25v-1.5a.25.25 0 0 0-.25-.25Zm-1.75 6C0 6.784.784 6 1.75 6h12.5c.966 0 1.75.784 1.75 1.75v1.5A1.75 1.75 0 0 1 14.25 11H1.75A1.75 1.75 0 0 1 0 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v1.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25v-1.5a.25.25 0 0 0-.25-.25Zm-1.75 6c0-.966.784-1.75 1.75-1.75h12.5c.966 0 1.75.784 1.75 1.75v1.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v1.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25v-1.5a.25.25 0 0 0-.25-.25Z"})}),t.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),e.columns.length>0&&t.jsx("span",{style:{fontSize:10,color:r.textMuted,background:r.pillBg,borderRadius:8,padding:"1px 5px",flexShrink:0},children:e.columns.length})]}),e.expanded&&t.jsx("div",{style:{paddingLeft:26},children:l?t.jsx("div",{style:{padding:"4px 10px",fontSize:11,color:r.textMuted,fontFamily:r.font,fontStyle:"italic"},children:"..."}):e.columns.length===0?t.jsx("div",{style:{padding:"4px 10px",fontSize:11,color:r.textMuted,fontFamily:r.font,fontStyle:"italic"},children:"No columns"}):e.columns.map(c=>t.jsx(dt,{col:c,t:r},c.name))})]})}function dt({col:e,t:r}){const[n,o]=f.useState(!1);return t.jsxs("div",{onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{display:"flex",alignItems:"center",gap:8,padding:"3px 10px 3px 8px",background:n?r.sidebarItemHover:"transparent",cursor:"default",transition:"background 0.1s"},children:[t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",style:{color:r.textMuted,flexShrink:0},children:t.jsx("path",{d:"M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm7-3.25v2.992l2.028.812a.75.75 0 0 1-.557 1.392l-2.5-1A.751.751 0 0 1 7 8.25v-3.5a.75.75 0 0 1 1.5 0Z"})}),t.jsx("span",{style:{flex:1,fontSize:11,fontFamily:r.fontMono,color:r.textSecondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),t.jsx("span",{style:{fontSize:10,fontFamily:r.fontMono,color:se(e.type,r.accent),background:`${se(e.type,r.accent)}18`,borderRadius:4,padding:"1px 5px",flexShrink:0},children:e.type.toLowerCase()})]})}function ct(e){if(e.type==="markdown"){const r=e.content.match(/^#{1,6}\s+(.+)$/m);if(r)return r[1];const n=e.content.split(`
10
- `).find(o=>o.trim());return(n==null?void 0:n.trim())||null}return e.name?e.name:null}function ye(e){if(e.type!=="markdown")return 0;const r=e.content.match(/^(#{1,6})\s/m);return r?r[1].length:0}function ut({cell:e,t:r}){if(e.type==="markdown")return t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",style:{color:r.textMuted,flexShrink:0},children:[t.jsx("path",{d:"M14.85 3H7.39L6.74.translateX(.5.25C6.45.11 6.23 0 6 0H1.75A1.75 1.75 0 0 0 0 1.75v12.5C0 15.216.784 16 1.75 16h12.5A1.75 1.75 0 0 0 16 14.25V4.75A1.75 1.75 0 0 0 14.25 3ZM1.5 1.75a.25.25 0 0 1 .25-.25H6l.5 1.5H1.5Z"}),t.jsx("path",{d:"M2 2h12v12H2z",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})]});const n=e.type==="sql"?r.accent:r.warning;return t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",style:{color:n,flexShrink:0},children:t.jsx("path",{d:"M0 5.75C0 4.784.784 4 1.75 4h12.5c.966 0 1.75.784 1.75 1.75v4.5A1.75 1.75 0 0 1 14.25 12H1.75A1.75 1.75 0 0 1 0 10.25Zm1.75-.25a.25.25 0 0 0-.25.25v4.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25v-4.5a.25.25 0 0 0-.25-.25Z"})})}function pt({onNavigate:e}){const{state:r}=w(),n=S[r.themeMode];if(!r.activeFile)return t.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:20,textAlign:"center"},children:t.jsxs("div",{children:[t.jsx("svg",{width:"32",height:"32",viewBox:"0 0 16 16",fill:"currentColor",style:{color:n.textMuted,marginBottom:8},children:t.jsx("path",{d:"M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25ZM1.75 1.5a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25ZM3.5 6.25a.75.75 0 0 1 .75-.75h7a.75.75 0 0 1 0 1.5h-7a.75.75 0 0 1-.75-.75Zm.75 2.25h4a.75.75 0 0 1 0 1.5h-4a.75.75 0 0 1 0-1.5Z"})}),t.jsx("div",{style:{fontSize:12,color:n.textMuted,fontFamily:n.font,lineHeight:1.5},children:"Open a notebook to see its outline."})]})});const o=r.cells.map(i=>({cell:i,label:ct(i)})).filter(i=>i.label!==null);return o.length===0?t.jsxs("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:20,color:n.textMuted,fontSize:12,fontFamily:n.font,fontStyle:"italic",textAlign:"center"},children:["No named cells or headings yet.",t.jsx("br",{}),"Name your cells or add markdown headings."]}):t.jsx("div",{style:{flex:1,overflow:"auto",padding:"6px 0"},children:o.map(({cell:i,label:l})=>{const s=ye(i),a=i.type==="markdown"?Math.max(0,(s-1)*12):0;return t.jsx(ft,{cell:i,label:l,indent:a,onClick:()=>e(i.id),t:n},i.id)})})}function ft({cell:e,label:r,indent:n,onClick:o,t:i}){const[l,s]=f.useState(!1);return t.jsxs("button",{onClick:o,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{width:"100%",display:"flex",alignItems:"center",gap:6,padding:`4px 10px 4px ${14+n}px`,background:l?i.sidebarItemHover:"transparent",border:"none",cursor:"pointer",color:l?i.textPrimary:i.textSecondary,fontSize:12,fontFamily:e.type==="markdown"?i.font:i.fontMono,textAlign:"left",transition:"background 0.1s, color 0.1s",overflow:"hidden"},children:[t.jsx(ut,{cell:e,t:i}),t.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,fontWeight:e.type==="markdown"&&ye(e)===1?600:400},children:r})]})}const xt={files:"Explorer",schema:"Schema",outline:"Outline"};function ht({onOpenFile:e,onNavigateToCell:r}){const{state:n,dispatch:o}=w(),i=S[n.themeMode],[l,s]=f.useState(!1),a=n.sidebarPanel;return t.jsxs("div",{style:{width:240,flexShrink:0,background:i.sidebarBg,borderRight:`1px solid ${i.headerBorder}`,display:"flex",flexDirection:"column",overflow:"hidden"},children:[t.jsxs("div",{style:{height:36,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 10px 0 14px",borderBottom:`1px solid ${i.headerBorder}`},children:[t.jsx("span",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:i.textSecondary,fontFamily:i.font},children:xt[a??""]??""}),t.jsx("button",{title:"Collapse sidebar",onClick:()=>o({type:"TOGGLE_SIDEBAR"}),onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{background:"transparent",border:"none",cursor:"pointer",color:l?i.textPrimary:i.textMuted,padding:"2px 4px",borderRadius:4,fontSize:14,lineHeight:1,transition:"color 0.15s",display:"flex",alignItems:"center"},children:"‹"})]}),t.jsxs("div",{style:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column"},children:[a==="files"&&t.jsx(tt,{onOpenFile:e}),a==="schema"&&t.jsx(st,{}),a==="outline"&&t.jsx(pt,{onNavigate:r})]})]})}function gt(e){try{const r=e.match(/workbook\s+"([^"]+)"/i),n=r?r[1]:"Untitled Workbook",o=[],i=/page\s+"([^"]+)"\s*\{([\s\S]*?)\}/gi;let l;for(;(l=i.exec(e))!==null;){const s=l[1],a=l[2].trim();o.push({id:R(),type:"markdown",content:`# ${s}`,status:"idle"}),a&&o.push({id:R(),type:"dql",name:s.toLowerCase().replace(/\s+/g,"_"),content:a,status:"idle"})}return o.length===0&&o.push({id:R(),type:"dql",content:e.trim(),status:"idle"}),{title:n,cells:o}}catch{return{title:"Untitled Workbook",cells:[{id:R(),type:"dql",content:e.trim(),status:"idle"}]}}}function mt(e){try{const r=JSON.parse(e),n=(r.cells||[]).map(o=>({id:o.id||R(),type:o.type||"sql",content:o.content||"",name:o.name,status:"idle",...o.paramConfig?{paramConfig:o.paramConfig}:{},...o.paramValue!==void 0?{paramValue:o.paramValue}:{}}));return{title:r.title||"Untitled",cells:n}}catch{return{title:"Untitled",cells:[{id:R(),type:"sql",content:e,status:"idle"}]}}}function yt(e,r){const n={version:1,title:e,cells:r.map(o=>({id:o.id,type:o.type,content:o.content,...o.name?{name:o.name}:{},...o.paramConfig?{paramConfig:o.paramConfig}:{},...o.paramValue!==void 0?{paramValue:o.paramValue}:{}}))};return JSON.stringify(n,null,2)}function bt(e,r){return e.endsWith(".dql")?gt(r):mt(r)}function vt(e,r){if(!r.columns.length||!r.rows.length)return`${e} AS (SELECT 1 WHERE 1=0)`;const n=r.columns,i=r.rows.slice(0,5e3).map(s=>`(${n.map(c=>{const x=s[c];return x==null?"NULL":typeof x=="number"?String(x):typeof x=="boolean"?x?"TRUE":"FALSE":`'${String(x).replace(/'/g,"''")}'`}).join(", ")})`).join(`,
9
+ */var re;function _e(){if(re)return P;re=1;var e=ge(),r=Symbol.for("react.element"),n=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function s(a,c,x){var d,u={},p=null,m=null;x!==void 0&&(p=""+x),c.key!==void 0&&(p=""+c.key),c.ref!==void 0&&(m=c.ref);for(d in c)o.call(c,d)&&!l.hasOwnProperty(d)&&(u[d]=c[d]);if(a&&a.defaultProps)for(d in c=a.defaultProps,c)u[d]===void 0&&(u[d]=c[d]);return{$$typeof:r,type:a,key:p,ref:m,props:u,_owner:i.current}}return P.Fragment=n,P.jsx=s,P.jsxs=s,P}var ie;function Ne(){return ie||(ie=1,Q.exports=_e()),Q.exports}var t=Ne(),q={},le;function Ie(){if(le)return q;le=1;var e=Me();return q.createRoot=e.createRoot,q.hydrateRoot=e.hydrateRoot,q}var He=Ie(),f=ge();const U=Le(f),ze={themeMode:"dark",sidebarPanel:"files",sidebarOpen:!0,files:[],filesLoading:!1,activeFile:null,cells:[],notebookTitle:"",notebookDirty:!1,schemaTables:[],schemaLoading:!1,devPanelOpen:!1,devPanelTab:"logs",queryLog:[],newNotebookModalOpen:!1,executionCounter:0,savingFile:!1};function Pe(e,r){switch(r.type){case"SET_THEME":return{...e,themeMode:r.mode};case"SET_SIDEBAR_PANEL":return{...e,sidebarPanel:r.panel,sidebarOpen:r.panel!==null};case"TOGGLE_SIDEBAR":return{...e,sidebarOpen:!e.sidebarOpen};case"SET_FILES":return{...e,files:r.files};case"SET_FILES_LOADING":return{...e,filesLoading:r.loading};case"OPEN_FILE":return{...e,activeFile:r.file,cells:r.cells,notebookTitle:r.title,notebookDirty:!1};case"SET_CELLS":return{...e,cells:r.cells,notebookDirty:!0};case"ADD_CELL":{if(!r.afterId)return{...e,cells:[...e.cells,r.cell],notebookDirty:!0};const n=e.cells.findIndex(i=>i.id===r.afterId);if(n===-1)return{...e,cells:[...e.cells,r.cell],notebookDirty:!0};const o=[...e.cells];return o.splice(n+1,0,r.cell),{...e,cells:o,notebookDirty:!0}}case"UPDATE_CELL":{const n=e.cells.map(i=>i.id===r.id?{...i,...r.updates}:i),o=r.updates.executionCount!==void 0?e.executionCounter+1:e.executionCounter;return{...e,cells:n,notebookDirty:!0,executionCounter:o}}case"DELETE_CELL":return{...e,cells:e.cells.filter(n=>n.id!==r.id),notebookDirty:!0};case"MOVE_CELL":{const n=e.cells.findIndex(i=>i.id===r.id);if(n===-1)return e;const o=[...e.cells];return r.direction==="up"&&n>0?[o[n-1],o[n]]=[o[n],o[n-1]]:r.direction==="down"&&n<o.length-1&&([o[n],o[n+1]]=[o[n+1],o[n]]),{...e,cells:o,notebookDirty:!0}}case"SET_SCHEMA":return{...e,schemaTables:r.tables};case"SET_SCHEMA_LOADING":return{...e,schemaLoading:r.loading};case"TOGGLE_SCHEMA_TABLE":return{...e,schemaTables:e.schemaTables.map(n=>n.name===r.tableName?{...n,expanded:!n.expanded}:n)};case"TOGGLE_DEV_PANEL":return{...e,devPanelOpen:!e.devPanelOpen};case"SET_DEV_PANEL_TAB":return{...e,devPanelTab:r.tab};case"APPEND_QUERY_LOG":return{...e,queryLog:[...e.queryLog,r.entry]};case"OPEN_NEW_NOTEBOOK_MODAL":return{...e,newNotebookModalOpen:!0};case"CLOSE_NEW_NOTEBOOK_MODAL":return{...e,newNotebookModalOpen:!1};case"SET_NOTEBOOK_DIRTY":return{...e,notebookDirty:r.dirty};case"SET_SAVING":return{...e,savingFile:r.saving};case"FILE_ADDED":return{...e,files:[...e.files,r.file]};case"SET_TABLE_COLUMNS":return{...e,schemaTables:e.schemaTables.map(n=>n.name===r.tableName?{...n,columns:r.columns}:n)};case"SET_PARAM_VALUE":return{...e,cells:e.cells.map(n=>n.id===r.id?{...n,paramValue:r.value}:n),notebookDirty:!0};default:return e}}const me=f.createContext(null);function We({children:e}){const[r,n]=f.useReducer(Pe,ze);return t.jsx(me.Provider,{value:{state:r,dispatch:n},children:e})}function w(){const e=f.useContext(me);if(!e)throw new Error("useNotebook must be used within NotebookProvider");return e}function F(){return`cell_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function $(e,r=""){const n={id:F(),type:e,content:r,status:"idle"};return e==="param"&&(n.content="",n.paramConfig={paramType:"text",label:"Parameter",defaultValue:"",options:[]}),n}const Ze={appBg:"#0d1117",sidebarBg:"#161b22",activityBarBg:"#0d1117",headerBg:"#161b22",headerBorder:"#21262d",cellBg:"#161b22",cellBorder:"#30363d",cellBorderActive:"#388bfd",cellBorderRunning:"#56d364",textPrimary:"#e6edf3",textSecondary:"#8b949e",textMuted:"#484f58",editorBg:"#0d1117",editorBorder:"#30363d",tableBorder:"#30363d",tableHeaderBg:"#1c2128",tableRowHover:"#21262d",accent:"#388bfd",accentHover:"#58a6ff",success:"#56d364",error:"#f85149",warning:"#e3b341",btnBg:"#21262d",btnBorder:"#30363d",btnHover:"#30363d",sidebarItemHover:"#21262d",sidebarItemActive:"#1f2d3d",scrollbarThumb:"#30363d",modalBg:"#161b22",modalOverlay:"rgba(0,0,0,0.7)",inputBg:"#0d1117",inputBorder:"#30363d",pillBg:"#21262d",font:"Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",fontMono:"'JetBrains Mono', 'Fira Code', Consolas, monospace",fontSerif:"Georgia, 'Times New Roman', serif"},Ve={appBg:"#ffffff",sidebarBg:"#f6f8fa",activityBarBg:"#eff1f3",headerBg:"#ffffff",headerBorder:"#d0d7de",cellBg:"#ffffff",cellBorder:"#d0d7de",cellBorderActive:"#0969da",cellBorderRunning:"#1f883d",textPrimary:"#1f2328",textSecondary:"#57606a",textMuted:"#8c959f",editorBg:"#f6f8fa",editorBorder:"#d0d7de",tableBorder:"#d0d7de",tableHeaderBg:"#f6f8fa",tableRowHover:"#f6f8fa",accent:"#0969da",accentHover:"#0550ae",success:"#1f883d",error:"#cf222e",warning:"#9a6700",btnBg:"#f6f8fa",btnBorder:"#d0d7de",btnHover:"#eaeef2",sidebarItemHover:"#eaeef2",sidebarItemActive:"#dbeafe",scrollbarThumb:"#d0d7de",modalBg:"#ffffff",modalOverlay:"rgba(0,0,0,0.4)",inputBg:"#ffffff",inputBorder:"#d0d7de",pillBg:"#eaeef2",font:"Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",fontMono:"'JetBrains Mono', 'Fira Code', Consolas, monospace",fontSerif:"Georgia, 'Times New Roman', serif"},j={dark:Ze,light:Ve};function H({title:e,active:r,onClick:n,children:o,t:i}){const[l,s]=f.useState(!1);return t.jsx("button",{title:e,onClick:n,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",border:"none",borderLeft:r?`2px solid ${i.accent}`:"2px solid transparent",cursor:"pointer",color:r?i.textPrimary:l?i.textSecondary:i.textMuted,transition:"color 0.15s, border-color 0.15s",padding:0,flexShrink:0},children:o})}function qe(){return t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M1.75 1A1.75 1.75 0 0 0 0 2.75v10.5C0 14.216.784 15 1.75 15h12.5A1.75 1.75 0 0 0 16 13.25v-8.5A1.75 1.75 0 0 0 14.25 3H7.5a.25.25 0 0 1-.2-.1l-.9-1.2C6.07 1.26 5.55 1 5 1H1.75Z"})})}function Ue(){return t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M8 0C3.58 0 0 1.567 0 3.5v9C0 14.433 3.58 16 8 16s8-1.567 8-3.5v-9C16 1.567 12.42 0 8 0ZM1.5 7.784V5.716C3.05 6.51 5.404 7 8 7s4.95-.49 6.5-1.284v2.068C12.95 8.578 10.596 9 8 9s-4.95-.422-6.5-1.216ZM8 1.5c3.17 0 5.854 1.116 6.357 2.5H1.643C2.146 2.616 4.83 1.5 8 1.5Zm0 13c-3.17 0-5.854-1.116-6.357-2.5h12.714C13.854 13.384 11.17 14.5 8 14.5Zm6.5-3.284C12.95 11.01 10.596 11.5 8 11.5s-4.95-.49-6.5-1.284V8.216C3.05 9.01 5.404 9.5 8 9.5s4.95-.49 6.5-1.284v2.5Z"})})}function Ge(){return t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M2 2h12a1 1 0 0 1 0 2H2a1 1 0 0 1 0-2Zm0 4h8a1 1 0 0 1 0 2H2a1 1 0 0 1 0-2Zm0 4h10a1 1 0 0 1 0 2H2a1 1 0 0 1 0-2Z"})})}function Qe(){return t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M1 2.75C1 1.784 1.784 1 2.75 1h2.5C6.216 1 7 1.784 7 2.75v2.5C7 6.216 6.216 7 5.25 7h-2.5C1.784 7 1 6.216 1 5.25Zm1.75-.25a.25.25 0 0 0-.25.25v2.5c0 .138.112.25.25.25h2.5A.25.25 0 0 0 6 5.25v-2.5A.25.25 0 0 0 5.25 2.5ZM9 2.75C9 1.784 9.784 1 10.75 1h2.5C14.216 1 15 1.784 15 2.75v2.5C15 6.216 14.216 7 13.25 7h-2.5C9.784 7 9 6.216 9 5.25Zm1.75-.25a.25.25 0 0 0-.25.25v2.5c0 .138.112.25.25.25h2.5a.25.25 0 0 0 .25-.25v-2.5a.25.25 0 0 0-.25-.25ZM1 10.75C1 9.784 1.784 9 2.75 9h2.5C6.216 9 7 9.784 7 10.75v2.5C7 14.216 6.216 15 5.25 15h-2.5C1.784 15 1 14.216 1 13.25Zm1.75-.25a.25.25 0 0 0-.25.25v2.5c0 .138.112.25.25.25h2.5a.25.25 0 0 0 .25-.25v-2.5a.25.25 0 0 0-.25-.25ZM13 9.75a.75.75 0 0 1 .75.75v1.75H15.5a.75.75 0 0 1 0 1.5h-1.75V15.5a.75.75 0 0 1-1.5 0v-1.75H10.5a.75.75 0 0 1 0-1.5h1.75V10.5A.75.75 0 0 1 13 9.75Z"})})}function Ke(){return t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.92 6.085h.001a.749.749 0 1 1-1.342-.67C6.03 4.26 6.88 3.75 8 3.75c1.463 0 2.5 1.008 2.5 2.25 0 1.133-.67 1.8-1.4 2.25-.487.3-.6.47-.6.75V9.5a.75.75 0 0 1-1.5 0v-.5c0-.833.585-1.33 1.1-1.65.387-.24.9-.597.9-1.35 0-.65-.53-1.25-1.5-1.25-.74 0-1.163.353-1.58.835ZM8 12a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"})})}function Ye(){return t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M8 0a8.2 8.2 0 0 1 .701.031C9.444.095 9.99.645 10.16 1.29l.288 1.107c.018.066.079.158.212.224.231.114.454.243.668.386.123.082.233.09.299.071l1.103-.303c.644-.176 1.392.021 1.82.63.27.385.506.792.704 1.218.315.675.111 1.422-.364 1.891l-.814.806c-.049.048-.098.147-.088.294.016.257.016.515 0 .772-.01.147.038.246.088.294l.814.806c.475.469.679 1.216.364 1.891a7.977 7.977 0 0 1-.704 1.217c-.428.61-1.176.807-1.82.63l-1.103-.303c-.066-.019-.176-.011-.299.071a5.909 5.909 0 0 1-.668.386c-.133.066-.194.158-.211.224l-.29 1.106c-.168.646-.715 1.196-1.458 1.26a8.006 8.006 0 0 1-1.402 0c-.743-.064-1.289-.614-1.458-1.26l-.289-1.106c-.018-.066-.079-.158-.212-.224a5.738 5.738 0 0 1-.668-.386c-.123-.082-.233-.09-.299-.071l-1.103.303c-.644.176-1.392-.021-1.82-.63a8.12 8.12 0 0 1-.704-1.218c-.315-.675-.111-1.422.363-1.891l.815-.806c.05-.048.098-.147.088-.294a6.214 6.214 0 0 1 0-.772c.01-.147-.038-.246-.088-.294l-.815-.806C.635 6.045.431 5.298.746 4.623a7.92 7.92 0 0 1 .704-1.217c.428-.61 1.176-.807 1.82-.63l1.103.303c.066.019.176.011.299-.071.214-.143.437-.272.668-.386.133-.066.194-.158.211-.224l.29-1.106C6.009.645 6.556.095 7.299.03 7.53.01 7.764 0 8 0Zm-.571 1.525c-.036.003-.108.036-.137.146l-.289 1.105c-.147.561-.549.967-.998 1.189-.173.086-.34.183-.5.29-.417.278-.97.423-1.529.27l-1.103-.303c-.109-.03-.175.016-.195.045-.22.312-.412.644-.573.99-.014.031-.021.11.059.19l.815.806c.411.406.562.957.53 1.456a4.709 4.709 0 0 0 0 .582c.032.499-.119 1.05-.53 1.456l-.815.806c-.081.08-.073.159-.059.19.162.346.353.677.573.989.02.03.085.076.195.046l1.102-.303c.56-.153 1.113-.008 1.53.27.161.107.328.204.501.29.447.222.85.629.997 1.189l.289 1.105c.029.109.101.143.137.146a6.6 6.6 0 0 0 1.142 0c.036-.003.108-.036.137-.146l.289-1.105c.147-.561.549-.967.998-1.189.173-.086.34-.183.5-.29.417-.278.97-.423 1.529-.27l1.103.303c.109.029.175-.016.195-.045.22-.313.411-.644.573-.99.014-.031.021-.11-.059-.19l-.815-.806c-.411-.406-.562-.957-.53-1.456a4.709 4.709 0 0 0 0-.582c-.032-.499.119-1.05.53-1.456l.815-.806c.081-.08.073-.159.059-.19a6.464 6.464 0 0 0-.573-.989c-.02-.03-.085-.076-.195-.046l-1.102.303c-.56.153-1.113.008-1.53-.27a4.44 4.44 0 0 0-.501-.29c-.447-.222-.85-.629-.997-1.189l-.289-1.105c-.029-.11-.101-.143-.137-.147a6.6 6.6 0 0 0-1.142 0ZM8 5.5a2.5 2.5 0 1 1 0 5 2.5 2.5 0 0 1 0-5ZM8 7a1 1 0 1 0 0 2 1 1 0 0 0 0-2Z"})})}function Je(){const{state:e,dispatch:r}=w(),n=j[e.themeMode];function o(i){e.sidebarPanel===i&&e.sidebarOpen?r({type:"TOGGLE_SIDEBAR"}):r({type:"SET_SIDEBAR_PANEL",panel:i})}return t.jsxs("div",{style:{width:32,flexShrink:0,background:n.activityBarBg,borderRight:`1px solid ${n.headerBorder}`,display:"flex",flexDirection:"column",alignItems:"center",paddingTop:8,paddingBottom:8,gap:2,userSelect:"none"},children:[t.jsx(H,{title:"Files",active:e.sidebarPanel==="files"&&e.sidebarOpen,onClick:()=>o("files"),t:n,children:t.jsx(qe,{})}),t.jsx(H,{title:"Schema",active:e.sidebarPanel==="schema"&&e.sidebarOpen,onClick:()=>o("schema"),t:n,children:t.jsx(Ue,{})}),t.jsx(H,{title:"Outline",active:e.sidebarPanel==="outline"&&e.sidebarOpen,onClick:()=>o("outline"),t:n,children:t.jsx(Ge,{})}),t.jsx(H,{title:"Connection",active:e.sidebarPanel==="connection"&&e.sidebarOpen,onClick:()=>o("connection"),t:n,children:t.jsx(Qe,{})}),t.jsx("div",{style:{flex:1}}),t.jsx(H,{title:"Help",active:!1,onClick:()=>{},t:n,children:t.jsx(Ke,{})}),t.jsx(H,{title:"Settings",active:!1,onClick:()=>{},t:n,children:t.jsx(Ye,{})})]})}const K={notebooks:"Notebooks",workbooks:"Workbooks",blocks:"Blocks",dashboards:"Dashboards"};function Xe({type:e}){switch(e){case"notebook":return t.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M0 1.75A.75.75 0 0 1 .75 1h4.253c1.227 0 2.317.59 3 1.501A3.743 3.743 0 0 1 11.006 1h4.245a.75.75 0 0 1 .75.75v10.5a.75.75 0 0 1-.75.75h-4.507a2.25 2.25 0 0 0-1.591.659l-.622.621a.75.75 0 0 1-1.063 0L7.597 13.66A2.25 2.25 0 0 0 6.007 13H.75a.75.75 0 0 1-.75-.75Zm7.251 10.324.004-5.073-.002-2.253A2.25 2.25 0 0 0 5.003 2.5H1.5v9h4.507c.656 0 1.287.169 1.744.324Zm1.499.004c.457-.155 1.088-.324 1.744-.324H15v-9h-3.495a2.25 2.25 0 0 0-2.252 2.247l-.002 9.077Z"})});case"workbook":return t.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M2 1.75C2 .784 2.784 0 3.75 0h8.5C13.216 0 14 .784 14 1.75v12.5A1.75 1.75 0 0 1 12.25 16h-8.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h8.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25Zm2 3.5a.75.75 0 0 1 .75-.75h3a.75.75 0 0 1 0 1.5h-3a.75.75 0 0 1-.75-.75ZM6.5 7.25a.75.75 0 0 0 0 1.5h3a.75.75 0 0 0 0-1.5Zm-.75 3.5a.75.75 0 0 1 .75-.75h3a.75.75 0 0 1 0 1.5h-3a.75.75 0 0 1-.75-.75Z"})});case"block":return t.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M10.5 0l5.25 4-5.25 4V6H9.25A1.75 1.75 0 0 0 7.5 7.75v2.5A1.75 1.75 0 0 0 9.25 12h1.25v8H9v-6.5A3.25 3.25 0 0 1 5.75 10h-2A3.25 3.25 0 0 1 .5 6.75v-2.5A3.25 3.25 0 0 1 3.75 1h2A3.25 3.25 0 0 1 9 4.5V6h1.5V0z"})});default:return t.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M.24 2.375C.24 1.064 1.225.001 2.409.001h6.451a1.17 1.17 0 0 1 .828.344l3.311 3.312a1.17 1.17 0 0 1 .344.828v9.14c0 1.31-.985 2.374-2.169 2.374H2.41C1.225 16 .24 14.937.24 13.625Zm2.169-1a.846.846 0 0 0-.844.86v11.39c0 .47.38.86.844.86h8.774a.847.847 0 0 0 .844-.86V5.157L8.688 1.373H2.41Z"})})}}function et({expanded:e}){return t.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"currentColor",children:e?t.jsx("path",{d:"M1.75 2.5a.25.25 0 0 0-.25.25v10.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V4.25a.25.25 0 0 0-.25-.25H7.5A1.75 1.75 0 0 1 5.75 2.5h-4ZM0 2.75C0 1.784.784 1 1.75 1h4c.966 0 1.75.784 1.75 1.75H14.25c.966 0 1.75.784 1.75 1.75v8.5A1.75 1.75 0 0 1 14.25 14H1.75A1.75 1.75 0 0 1 0 12.25Z"}):t.jsx("path",{d:"M1.75 2.5a.25.25 0 0 0-.25.25v10.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V4.25a.25.25 0 0 0-.25-.25H7.5A1.75 1.75 0 0 1 5.75 2.5h-4ZM0 2.75C0 1.784.784 1 1.75 1h4c.966 0 1.75.784 1.75 1.75H14.25c.966 0 1.75.784 1.75 1.75v8.5A1.75 1.75 0 0 1 14.25 14H1.75A1.75 1.75 0 0 1 0 12.25Z"})})}function tt(e){return e.name.replace(/\.(dqlnb|dql)$/,"")}function nt({onOpenFile:e}){const{state:r,dispatch:n}=w(),o=j[r.themeMode],[i,l]=f.useState({notebooks:!0,workbooks:!0,blocks:!1,dashboards:!1}),[s,a]=f.useState(!1),c={notebooks:[],workbooks:[],blocks:[],dashboards:[]};for(const d of r.files){const u=d.folder.toLowerCase();u in c&&c[u].push(d)}const x=d=>{l(u=>({...u,[d]:!u[d]}))};return t.jsxs("div",{style:{flex:1,overflow:"auto",padding:"8px 0",display:"flex",flexDirection:"column",gap:0},children:[t.jsx("div",{style:{padding:"0 8px 8px"},children:t.jsxs("button",{onClick:()=>n({type:"OPEN_NEW_NOTEBOOK_MODAL"}),onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:{width:"100%",height:30,background:"transparent",border:`1px dashed ${s?o.accent:o.cellBorder}`,borderRadius:6,color:s?o.accent:o.textSecondary,cursor:"pointer",fontSize:12,fontFamily:o.font,fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",gap:6,transition:"border-color 0.15s, color 0.15s"},children:[t.jsx("span",{style:{fontSize:16,lineHeight:1},children:"+"}),"New Notebook"]})}),r.filesLoading&&t.jsx("div",{style:{padding:"8px 14px",color:o.textMuted,fontSize:12,fontFamily:o.font},children:"Loading files…"}),Object.keys(K).map(d=>{const u=c[d],p=i[d];return t.jsxs("div",{children:[t.jsx(ot,{label:K[d],count:u.length,expanded:p,onToggle:()=>x(d),t:o}),p&&t.jsx("div",{children:u.length===0?t.jsxs("div",{style:{padding:"4px 14px 4px 32px",fontSize:12,color:o.textMuted,fontFamily:o.font,fontStyle:"italic"},children:["No ",K[d].toLowerCase()]}):u.map(m=>{var h;return t.jsx(rt,{file:m,active:((h=r.activeFile)==null?void 0:h.path)===m.path,onClick:()=>e(m),t:o},m.path)})})]},d)})]})}function ot({label:e,count:r,expanded:n,onToggle:o,t:i}){const[l,s]=f.useState(!1);return t.jsxs("button",{onClick:o,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{width:"100%",display:"flex",alignItems:"center",gap:6,padding:"3px 8px 3px 10px",background:l?i.sidebarItemHover:"transparent",border:"none",cursor:"pointer",color:i.textSecondary,fontSize:11,fontWeight:600,fontFamily:i.font,letterSpacing:"0.04em",textTransform:"uppercase",textAlign:"left",transition:"background 0.1s"},children:[t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",style:{transform:n?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.15s",flexShrink:0},children:t.jsx("path",{d:"M3 2l4 3-4 3V2Z"})}),t.jsx(et,{expanded:n}),t.jsx("span",{style:{flex:1},children:e}),r>0&&t.jsx("span",{style:{background:i.pillBg,color:i.textMuted,borderRadius:10,padding:"0 5px",fontSize:10,fontWeight:500},children:r})]})}function rt({file:e,active:r,onClick:n,t:o}){const[i,l]=f.useState(!1);return t.jsxs("button",{onClick:n,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{width:"100%",display:"flex",alignItems:"center",gap:6,padding:"4px 8px 4px 26px",background:r?o.sidebarItemActive:i?o.sidebarItemHover:"transparent",border:"none",borderLeft:r?`2px solid ${o.accent}`:"2px solid transparent",cursor:"pointer",color:r||i?o.textPrimary:o.textSecondary,fontSize:13,fontFamily:o.font,textAlign:"left",transition:"background 0.1s, color 0.1s",overflow:"hidden"},children:[t.jsx("span",{style:{flexShrink:0,color:r?o.accent:o.textMuted},children:t.jsx(Xe,{type:e.type})}),t.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:tt(e)}),e.isNew&&t.jsx("span",{style:{fontSize:9,fontWeight:600,color:o.accent,background:o.sidebarItemActive,borderRadius:4,padding:"1px 4px",flexShrink:0},children:"NEW"})]})}const it=window.location.origin;async function R(e,r){const n=await fetch(`${it}${e}`,{headers:{"Content-Type":"application/json"},...r});if(!n.ok){const o=await n.text().catch(()=>n.statusText);throw new Error(o||`HTTP ${n.status}`)}if(n.status!==204)return n.json()}const B={async listNotebooks(){try{return await R("/api/notebooks")}catch{return[]}},async readNotebook(e){return R(`/api/notebook-content?path=${encodeURIComponent(e)}`)},async createNotebook(e,r){return R("/api/notebooks",{method:"POST",body:JSON.stringify({name:e,template:r})})},async saveNotebook(e,r){return R("/api/notebook-content",{method:"PUT",body:JSON.stringify({path:e,content:r})})},async executeQuery(e){return R("/api/query",{method:"POST",body:JSON.stringify({sql:e})})},async getSchema(){try{return await R("/api/schema")}catch{return[]}},async getConnections(){try{return await R("/api/connections")}catch{return{default:"unknown",connections:{}}}},async testConnection(){try{return await R("/api/test-connection",{method:"POST",body:JSON.stringify({})})}catch(e){return{ok:!1,message:e.message??"Connection failed"}}},async describeTable(e){const n=`DESCRIBE SELECT * FROM read_csv_auto('${e.replace(/'/g,"''")}') LIMIT 0`;try{return(await R("/api/query",{method:"POST",body:JSON.stringify({sql:n})})).rows.map(i=>({name:String(i.column_name??i.Field??""),type:String(i.column_type??i.Type??"")}))}catch{return[]}}},lt={varchar:"#388bfd",text:"#388bfd",string:"#388bfd",char:"#388bfd",integer:"#56d364",int:"#56d364",bigint:"#56d364",smallint:"#56d364",float:"#56d364",double:"#56d364",decimal:"#56d364",numeric:"#56d364",real:"#56d364",date:"#e3b341",timestamp:"#e3b341",datetime:"#e3b341",time:"#e3b341",boolean:"#f778ba",bool:"#f778ba",json:"#79c0ff",jsonb:"#79c0ff",uuid:"#d2a8ff",bytea:"#ffa657",binary:"#ffa657"};function se(e,r){const n=e.toLowerCase().split("(")[0].trim();return lt[n]??r}function st({t:e}){return t.jsxs("div",{style:{padding:"8px 12px",display:"flex",flexDirection:"column",gap:8},children:[[1,2,3].map(r=>t.jsx("div",{style:{height:28,borderRadius:4,background:e.pillBg,opacity:.6,animation:"pulse 1.5s ease-in-out infinite"}},r)),t.jsx("style",{children:"@keyframes pulse { 0%,100%{opacity:.6} 50%{opacity:.3} }"})]})}function at(){const{state:e,dispatch:r}=w(),n=j[e.themeMode],[o,i]=f.useState(!1),l=async()=>{r({type:"SET_SCHEMA_LOADING",loading:!0});try{const s=await B.getSchema();r({type:"SET_SCHEMA",tables:s})}catch(s){console.error("Schema refresh failed:",s)}finally{r({type:"SET_SCHEMA_LOADING",loading:!1})}};return t.jsxs("div",{style:{flex:1,overflow:"auto",display:"flex",flexDirection:"column"},children:[t.jsxs("div",{style:{padding:"8px 10px",display:"flex",alignItems:"center",gap:6,borderBottom:`1px solid ${n.headerBorder}`},children:[t.jsxs("span",{style:{flex:1,fontSize:11,color:n.textMuted,fontFamily:n.font},children:[e.schemaTables.length," tables"]}),t.jsxs("button",{onClick:l,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),title:"Refresh schema",style:{background:o?n.btnHover:"transparent",border:`1px solid ${o?n.btnBorder:"transparent"}`,borderRadius:4,cursor:"pointer",color:o?n.textSecondary:n.textMuted,fontSize:11,fontFamily:n.font,padding:"2px 6px",display:"flex",alignItems:"center",gap:4,transition:"all 0.15s"},children:[t.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M1.705 8.005a.75.75 0 0 1 .834.656 5.5 5.5 0 0 0 9.592 2.97l-1.204-1.204a.25.25 0 0 1 .177-.427h3.646a.25.25 0 0 1 .25.25v3.646a.25.25 0 0 1-.427.177l-1.38-1.38A7.002 7.002 0 0 1 1.05 8.84a.75.75 0 0 1 .656-.834ZM8 2.5a5.487 5.487 0 0 0-4.131 1.869l1.204 1.204A.25.25 0 0 1 4.896 6H1.25A.25.25 0 0 1 1 5.75V2.104a.25.25 0 0 1 .427-.177l1.38 1.38A7.002 7.002 0 0 1 14.95 7.16a.75.75 0 0 1-1.49.178A5.5 5.5 0 0 0 8 2.5Z"})}),"Refresh"]})]}),e.schemaLoading?t.jsx(st,{t:n}):e.schemaTables.length===0?t.jsxs("div",{style:{padding:"24px 14px",color:n.textMuted,fontSize:12,fontFamily:n.font,textAlign:"center",fontStyle:"italic"},children:["No tables found.",t.jsx("br",{}),"Connect a data source to explore schema."]}):t.jsx("div",{style:{overflow:"auto",flex:1},children:e.schemaTables.map(s=>t.jsx(dt,{table:s,t:n},s.name))})]})}function dt({table:e,t:r}){const{dispatch:n}=w(),[o,i]=f.useState(!1),[l,s]=f.useState(!1),a=async()=>{if(n({type:"TOGGLE_SCHEMA_TABLE",tableName:e.name}),!e.expanded&&e.columns.length===0){s(!0);try{const c=await B.describeTable(e.path);c.length>0&&n({type:"SET_TABLE_COLUMNS",tableName:e.name,columns:c})}catch(c){console.error("describeTable failed:",c)}finally{s(!1)}}};return t.jsxs("div",{children:[t.jsxs("button",{onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),onClick:a,style:{width:"100%",display:"flex",alignItems:"center",gap:6,padding:"5px 10px",background:o?r.sidebarItemHover:"transparent",border:"none",cursor:"pointer",color:r.textPrimary,fontSize:12,fontFamily:r.font,fontWeight:500,textAlign:"left",transition:"background 0.1s"},children:[t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",style:{transform:e.expanded?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.15s",flexShrink:0,color:r.textMuted},children:t.jsx("path",{d:"M3 2l4 3-4 3V2Z"})}),t.jsx("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"currentColor",style:{color:r.accent,flexShrink:0},children:t.jsx("path",{d:"M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v1.5A1.75 1.75 0 0 1 14.25 5H1.75A1.75 1.75 0 0 1 0 3.25Zm1.75-.25a.25.25 0 0 0-.25.25v1.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25v-1.5a.25.25 0 0 0-.25-.25Zm-1.75 6C0 6.784.784 6 1.75 6h12.5c.966 0 1.75.784 1.75 1.75v1.5A1.75 1.75 0 0 1 14.25 11H1.75A1.75 1.75 0 0 1 0 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v1.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25v-1.5a.25.25 0 0 0-.25-.25Zm-1.75 6c0-.966.784-1.75 1.75-1.75h12.5c.966 0 1.75.784 1.75 1.75v1.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v1.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25v-1.5a.25.25 0 0 0-.25-.25Z"})}),t.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),e.columns.length>0&&t.jsx("span",{style:{fontSize:10,color:r.textMuted,background:r.pillBg,borderRadius:8,padding:"1px 5px",flexShrink:0},children:e.columns.length})]}),e.expanded&&t.jsx("div",{style:{paddingLeft:26},children:l?t.jsx("div",{style:{padding:"4px 10px",fontSize:11,color:r.textMuted,fontFamily:r.font,fontStyle:"italic"},children:"..."}):e.columns.length===0?t.jsx("div",{style:{padding:"4px 10px",fontSize:11,color:r.textMuted,fontFamily:r.font,fontStyle:"italic"},children:"No columns"}):e.columns.map(c=>t.jsx(ct,{col:c,t:r},c.name))})]})}function ct({col:e,t:r}){const[n,o]=f.useState(!1);return t.jsxs("div",{onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{display:"flex",alignItems:"center",gap:8,padding:"3px 10px 3px 8px",background:n?r.sidebarItemHover:"transparent",cursor:"default",transition:"background 0.1s"},children:[t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",style:{color:r.textMuted,flexShrink:0},children:t.jsx("path",{d:"M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm7-3.25v2.992l2.028.812a.75.75 0 0 1-.557 1.392l-2.5-1A.751.751 0 0 1 7 8.25v-3.5a.75.75 0 0 1 1.5 0Z"})}),t.jsx("span",{style:{flex:1,fontSize:11,fontFamily:r.fontMono,color:r.textSecondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),t.jsx("span",{style:{fontSize:10,fontFamily:r.fontMono,color:se(e.type,r.accent),background:`${se(e.type,r.accent)}18`,borderRadius:4,padding:"1px 5px",flexShrink:0},children:e.type.toLowerCase()})]})}function ut(e){if(e.type==="markdown"){const r=e.content.match(/^#{1,6}\s+(.+)$/m);if(r)return r[1];const n=e.content.split(`
10
+ `).find(o=>o.trim());return(n==null?void 0:n.trim())||null}return e.name?e.name:null}function ye(e){if(e.type!=="markdown")return 0;const r=e.content.match(/^(#{1,6})\s/m);return r?r[1].length:0}function pt({cell:e,t:r}){if(e.type==="markdown")return t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",style:{color:r.textMuted,flexShrink:0},children:[t.jsx("path",{d:"M14.85 3H7.39L6.74.translateX(.5.25C6.45.11 6.23 0 6 0H1.75A1.75 1.75 0 0 0 0 1.75v12.5C0 15.216.784 16 1.75 16h12.5A1.75 1.75 0 0 0 16 14.25V4.75A1.75 1.75 0 0 0 14.25 3ZM1.5 1.75a.25.25 0 0 1 .25-.25H6l.5 1.5H1.5Z"}),t.jsx("path",{d:"M2 2h12v12H2z",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})]});const n=e.type==="sql"?r.accent:r.warning;return t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",style:{color:n,flexShrink:0},children:t.jsx("path",{d:"M0 5.75C0 4.784.784 4 1.75 4h12.5c.966 0 1.75.784 1.75 1.75v4.5A1.75 1.75 0 0 1 14.25 12H1.75A1.75 1.75 0 0 1 0 10.25Zm1.75-.25a.25.25 0 0 0-.25.25v4.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25v-4.5a.25.25 0 0 0-.25-.25Z"})})}function ft({onNavigate:e}){const{state:r}=w(),n=j[r.themeMode];if(!r.activeFile)return t.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:20,textAlign:"center"},children:t.jsxs("div",{children:[t.jsx("svg",{width:"32",height:"32",viewBox:"0 0 16 16",fill:"currentColor",style:{color:n.textMuted,marginBottom:8},children:t.jsx("path",{d:"M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v12.5A1.75 1.75 0 0 1 14.25 16H1.75A1.75 1.75 0 0 1 0 14.25ZM1.75 1.5a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h12.5a.25.25 0 0 0 .25-.25V1.75a.25.25 0 0 0-.25-.25ZM3.5 6.25a.75.75 0 0 1 .75-.75h7a.75.75 0 0 1 0 1.5h-7a.75.75 0 0 1-.75-.75Zm.75 2.25h4a.75.75 0 0 1 0 1.5h-4a.75.75 0 0 1 0-1.5Z"})}),t.jsx("div",{style:{fontSize:12,color:n.textMuted,fontFamily:n.font,lineHeight:1.5},children:"Open a notebook to see its outline."})]})});const o=r.cells.map(i=>({cell:i,label:ut(i)})).filter(i=>i.label!==null);return o.length===0?t.jsxs("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:20,color:n.textMuted,fontSize:12,fontFamily:n.font,fontStyle:"italic",textAlign:"center"},children:["No named cells or headings yet.",t.jsx("br",{}),"Name your cells or add markdown headings."]}):t.jsx("div",{style:{flex:1,overflow:"auto",padding:"6px 0"},children:o.map(({cell:i,label:l})=>{const s=ye(i),a=i.type==="markdown"?Math.max(0,(s-1)*12):0;return t.jsx(xt,{cell:i,label:l,indent:a,onClick:()=>e(i.id),t:n},i.id)})})}function xt({cell:e,label:r,indent:n,onClick:o,t:i}){const[l,s]=f.useState(!1);return t.jsxs("button",{onClick:o,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{width:"100%",display:"flex",alignItems:"center",gap:6,padding:`4px 10px 4px ${14+n}px`,background:l?i.sidebarItemHover:"transparent",border:"none",cursor:"pointer",color:l?i.textPrimary:i.textSecondary,fontSize:12,fontFamily:e.type==="markdown"?i.font:i.fontMono,textAlign:"left",transition:"background 0.1s, color 0.1s",overflow:"hidden"},children:[t.jsx(pt,{cell:e,t:i}),t.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,fontWeight:e.type==="markdown"&&ye(e)===1?600:400},children:r})]})}const ht={duckdb:"DuckDB",file:"Local File / DuckDB",postgres:"PostgreSQL",bigquery:"BigQuery",snowflake:"Snowflake",sqlite:"SQLite"},gt={duckdb:"#f4bc00",file:"#f4bc00",postgres:"#336791",bigquery:"#4285f4",snowflake:"#29b5e8",sqlite:"#003b57"};function mt(){const{state:e}=w(),r=j[e.themeMode],[n,o]=f.useState(null),[i,l]=f.useState(!1),[s,a]=f.useState(null);f.useEffect(()=>{B.getConnections().then(o)},[]);const c=async()=>{l(!0),a(null);const m=await B.testConnection();a(m),l(!1)},x={fontSize:10,fontWeight:600,letterSpacing:"0.07em",textTransform:"uppercase",color:r.textMuted,fontFamily:r.font,marginBottom:6},d={background:r.cellBg,border:`1px solid ${r.cellBorder}`,borderRadius:7,padding:"10px 12px",marginBottom:10},u=(n==null?void 0:n.connections)??{},p=(n==null?void 0:n.default)??"";return t.jsxs("div",{style:{flex:1,overflow:"auto",padding:"12px 12px 20px"},children:[t.jsx("div",{style:x,children:"Active Connection"}),n===null?t.jsx("div",{style:{fontSize:12,color:r.textMuted,fontFamily:r.font},children:"Loading…"}):Object.entries(u).map(([m,h])=>{const g=(h==null?void 0:h.driver)??(h==null?void 0:h.type)??"unknown",y=m===p||Object.keys(u).length===1,k=gt[g]??r.accent;return t.jsxs("div",{style:{...d,borderLeft:y?`3px solid ${k}`:`1px solid ${r.cellBorder}`},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[t.jsx("span",{style:{fontSize:10,fontWeight:700,fontFamily:r.fontMono,color:k,background:`${k}18`,border:`1px solid ${k}40`,borderRadius:4,padding:"1px 6px",letterSpacing:"0.05em",textTransform:"uppercase"},children:ht[g]??g}),y&&t.jsx("span",{style:{fontSize:10,color:r.textMuted,fontFamily:r.font},children:"default"})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:3},children:Object.entries(h??{}).filter(([v])=>v!=="driver"&&v!=="type").map(([v,E])=>t.jsxs("div",{style:{display:"flex",gap:6,alignItems:"baseline"},children:[t.jsx("span",{style:{fontSize:11,color:r.textMuted,fontFamily:r.fontMono,minWidth:70,flexShrink:0},children:v}),t.jsx("span",{style:{fontSize:11,color:r.textSecondary,fontFamily:r.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:v.toLowerCase().includes("password")?"••••••••":String(E)})]},v))})]},m)}),t.jsx("button",{onClick:c,disabled:i,style:{width:"100%",padding:"7px 0",borderRadius:6,border:`1px solid ${r.btnBorder}`,background:r.btnBg,color:r.textSecondary,fontSize:12,fontFamily:r.font,fontWeight:500,cursor:i?"not-allowed":"pointer",marginBottom:8,opacity:i?.7:1,transition:"all 0.15s"},children:i?"Testing…":"Test Connection"}),s&&t.jsxs("div",{style:{fontSize:12,fontFamily:r.font,color:s.ok?r.success:r.error,background:s.ok?`${r.success}12`:`${r.error}12`,border:`1px solid ${s.ok?r.success:r.error}40`,borderRadius:6,padding:"7px 10px",marginBottom:12},children:[s.ok?"":"✗ ",s.message]}),t.jsx("div",{style:{...x,marginTop:4},children:"Change Connection"}),t.jsxs("div",{style:{...d,fontSize:12,fontFamily:r.font,color:r.textSecondary,lineHeight:1.6},children:["Edit ",t.jsx("code",{style:{fontFamily:r.fontMono,color:r.accent,fontSize:11},children:"dql.config.json"})," in your project root to add or switch connections. Supported drivers:",t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4,marginTop:8},children:[{driver:"duckdb / file",desc:"Local CSV, Parquet, DuckDB"},{driver:"postgres",desc:"PostgreSQL / Supabase / RDS"},{driver:"bigquery",desc:"Google BigQuery"},{driver:"snowflake",desc:"Snowflake"}].map(({driver:m,desc:h})=>t.jsxs("div",{style:{display:"flex",gap:8,alignItems:"baseline"},children:[t.jsx("code",{style:{fontSize:10,fontFamily:r.fontMono,color:r.textMuted,minWidth:80,flexShrink:0},children:m}),t.jsx("span",{style:{fontSize:11,color:r.textMuted},children:h})]},m))})]}),t.jsx("div",{style:{...x,marginTop:4},children:"Example Config"}),t.jsx("pre",{style:{background:r.cellBg,border:`1px solid ${r.cellBorder}`,borderRadius:7,padding:"10px 12px",fontSize:11,fontFamily:r.fontMono,color:r.textSecondary,overflow:"auto",lineHeight:1.6,margin:0},children:`{
11
+ "connections": {
12
+ "default": {
13
+ "driver": "duckdb",
14
+ "path": ":memory:"
15
+ },
16
+ "prod": {
17
+ "driver": "postgres",
18
+ "host": "localhost",
19
+ "port": 5432,
20
+ "database": "analytics",
21
+ "user": "analyst",
22
+ "password": "..."
23
+ }
24
+ }
25
+ }`})]})}const yt={files:"Explorer",schema:"Schema",outline:"Outline",connection:"Connection"};function bt({onOpenFile:e,onNavigateToCell:r}){const{state:n,dispatch:o}=w(),i=j[n.themeMode],[l,s]=f.useState(!1),a=n.sidebarPanel;return t.jsxs("div",{style:{width:240,flexShrink:0,background:i.sidebarBg,borderRight:`1px solid ${i.headerBorder}`,display:"flex",flexDirection:"column",overflow:"hidden"},children:[t.jsxs("div",{style:{height:36,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 10px 0 14px",borderBottom:`1px solid ${i.headerBorder}`},children:[t.jsx("span",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:i.textSecondary,fontFamily:i.font},children:yt[a??""]??""}),t.jsx("button",{title:"Collapse sidebar",onClick:()=>o({type:"TOGGLE_SIDEBAR"}),onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{background:"transparent",border:"none",cursor:"pointer",color:l?i.textPrimary:i.textMuted,padding:"2px 4px",borderRadius:4,fontSize:14,lineHeight:1,transition:"color 0.15s",display:"flex",alignItems:"center"},children:"‹"})]}),t.jsxs("div",{style:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column"},children:[a==="files"&&t.jsx(nt,{onOpenFile:e}),a==="schema"&&t.jsx(at,{}),a==="outline"&&t.jsx(ft,{onNavigate:r}),a==="connection"&&t.jsx(mt,{})]})]})}function vt(e){try{const r=e.match(/workbook\s+"([^"]+)"/i),n=r?r[1]:"Untitled Workbook",o=[],i=/page\s+"([^"]+)"\s*\{([\s\S]*?)\}/gi;let l;for(;(l=i.exec(e))!==null;){const s=l[1],a=l[2].trim();o.push({id:F(),type:"markdown",content:`# ${s}`,status:"idle"}),a&&o.push({id:F(),type:"dql",name:s.toLowerCase().replace(/\s+/g,"_"),content:a,status:"idle"})}return o.length===0&&o.push({id:F(),type:"dql",content:e.trim(),status:"idle"}),{title:n,cells:o}}catch{return{title:"Untitled Workbook",cells:[{id:F(),type:"dql",content:e.trim(),status:"idle"}]}}}function St(e){var r;try{const n=JSON.parse(e),o=n.title||((r=n.metadata)==null?void 0:r.title)||"Untitled",i=(n.cells||[]).map(l=>({id:l.id||F(),type:l.type||"sql",content:l.content??l.source??"",name:l.name||l.title,status:"idle",...l.paramConfig?{paramConfig:l.paramConfig}:{},...l.paramValue!==void 0?{paramValue:l.paramValue}:{}}));return{title:o,cells:i}}catch{return{title:"Untitled",cells:[{id:F(),type:"sql",content:e,status:"idle"}]}}}function jt(e,r){const n={version:1,title:e,cells:r.map(o=>({id:o.id,type:o.type,content:o.content,...o.name?{name:o.name}:{},...o.paramConfig?{paramConfig:o.paramConfig}:{},...o.paramValue!==void 0?{paramValue:o.paramValue}:{}}))};return JSON.stringify(n,null,2)}function wt(e,r){return e.endsWith(".dql")?vt(r):St(r)}function kt(e,r){if(!r.columns.length||!r.rows.length)return`${e} AS (SELECT 1 WHERE 1=0)`;const n=r.columns,i=r.rows.slice(0,5e3).map(s=>`(${n.map(c=>{const x=s[c];return x==null?"NULL":typeof x=="number"?String(x):typeof x=="boolean"?x?"TRUE":"FALSE":`'${String(x).replace(/'/g,"''")}'`}).join(", ")})`).join(`,
11
26
  `),l=n.map(s=>`"${s.replace(/"/g,'""')}"`).join(", ");return`${e} AS (
12
27
  SELECT * FROM (VALUES
13
28
  ${i}
14
29
  ) AS _t(${l})
15
- )`}function St(e,r){if(r==="number"){const n=Number(e);return isNaN(n)?`'${e.replace(/'/g,"''")}'`:String(n)}return`'${e.replace(/'/g,"''")}'`}function jt(){const{state:e}=w();return{substituteVariables:f.useCallback(n=>{var d;const o=/\{\{([a-zA-Z_][a-zA-Z0-9_]*)\}\}/g,i=[...n.matchAll(o)];if(i.length===0)return{sql:n,substituted:[]};const l=[],s=[];let a=n;const c=new Map,x=new Map;for(const u of e.cells){const p=(d=u.name)==null?void 0:d.trim();p&&(u.type==="param"?c.set(p,u):u.status==="success"&&u.result&&x.set(p,u.result))}for(const u of i){const p=u[1];if(c.has(p)){const m=c.get(p),g=m.paramConfig,h=m.paramValue??(g==null?void 0:g.defaultValue)??"",y=(g==null?void 0:g.paramType)??"text",C=St(h,y);a=a.replace(u[0],C),l.push(p)}else x.has(p)&&(s.push(vt(p,x.get(p))),a=a.replace(u[0],`"${p}"`),l.push(p))}if(s.length===0&&l.length===0)return{sql:n,substituted:[]};if(s.length>0){const u=a.trimStart();/^WITH\s+/i.test(u)?a=a.replace(/^(\s*WITH\s+)/i,`$1${s.join(`,
30
+ )`}function Ct(e,r){if(r==="number"){const n=Number(e);return isNaN(n)?`'${e.replace(/'/g,"''")}'`:String(n)}return`'${e.replace(/'/g,"''")}'`}function Et(){const{state:e}=w();return{substituteVariables:f.useCallback(n=>{var d;const o=/\{\{([a-zA-Z_][a-zA-Z0-9_]*)\}\}/g,i=[...n.matchAll(o)];if(i.length===0)return{sql:n,substituted:[]};const l=[],s=[];let a=n;const c=new Map,x=new Map;for(const u of e.cells){const p=(d=u.name)==null?void 0:d.trim();p&&(u.type==="param"?c.set(p,u):u.status==="success"&&u.result&&x.set(p,u.result))}for(const u of i){const p=u[1];if(c.has(p)){const m=c.get(p),h=m.paramConfig,g=m.paramValue??(h==null?void 0:h.defaultValue)??"",y=(h==null?void 0:h.paramType)??"text",k=Ct(g,y);a=a.replace(u[0],k),l.push(p)}else x.has(p)&&(s.push(kt(p,x.get(p))),a=a.replace(u[0],`"${p}"`),l.push(p))}if(s.length===0&&l.length===0)return{sql:n,substituted:[]};if(s.length>0){const u=a.trimStart();/^WITH\s+/i.test(u)?a=a.replace(/^(\s*WITH\s+)/i,`$1${s.join(`,
16
31
  `)},
17
32
  `):a=`WITH ${s.join(`,
18
33
  `)}
19
- ${a}`}return{sql:a,substituted:l}},[e.cells])}}function wt(e){if(e.type==="markdown")return null;if(e.type==="sql")return e.content.trim()||null;const r=e.content.trim();if(!r)return null;const n=r.match(/\b(SELECT|WITH|INSERT|UPDATE|DELETE|CREATE|DROP|ALTER|SHOW|DESCRIBE|EXPLAIN)\b[\s\S]*/i);return n?n[0].trim():r}function oe(){const{state:e,dispatch:r}=w(),{substituteVariables:n}=jt(),o=f.useCallback(async l=>{const s=e.cells.find(d=>d.id===l);if(!s)return;const a=wt(s);if(!a)return;const{sql:c}=n(a),x=Date.now();r({type:"UPDATE_CELL",id:l,updates:{status:"running",error:void 0,result:void 0}});try{const d=await $.executeQuery(c),u=Date.now()-x,p=(s.executionCount??0)+1;r({type:"UPDATE_CELL",id:l,updates:{status:"success",result:{...d,executionTime:d.executionTime??u,rowCount:d.rowCount??d.rows.length},executionCount:p}}),r({type:"APPEND_QUERY_LOG",entry:{id:R(),cellName:s.name??s.id,rows:d.rowCount??d.rows.length,time:d.executionTime??u,ts:new Date}}),setTimeout(()=>{r({type:"UPDATE_CELL",id:l,updates:{status:"idle"}})},2e3)}catch(d){const u=Date.now()-x,p=d instanceof Error?d.message:String(d);r({type:"UPDATE_CELL",id:l,updates:{status:"error",error:p,executionCount:(s.executionCount??0)+1}}),r({type:"APPEND_QUERY_LOG",entry:{id:R(),cellName:s.name??s.id,rows:0,time:u,ts:new Date,error:p}})}},[e.cells,r]),i=f.useCallback(async()=>{for(const l of e.cells)l.type!=="markdown"&&await o(l.id)},[e.cells,o]);return{executeCell:o,executeAll:i}}function L(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function kt(e){return typeof e=="number"?Math.abs(e)>=1e6?`${(e/1e6).toFixed(1)}M`:Math.abs(e)>=1e3?`${(e/1e3).toFixed(1)}K`:Number.isInteger(e)?String(e):e.toFixed(2):""}function Et(e){const r=e.split(`
34
+ ${a}`}return{sql:a,substituted:l}},[e.cells])}}function Mt(e){if(e.type==="markdown")return null;if(e.type==="sql")return e.content.trim()||null;const r=e.content.trim();if(!r)return null;const n=r.match(/\b(SELECT|WITH|INSERT|UPDATE|DELETE|CREATE|DROP|ALTER|SHOW|DESCRIBE|EXPLAIN)\b[\s\S]*/i);return n?n[0].trim():r}function oe(){const{state:e,dispatch:r}=w(),{substituteVariables:n}=Et(),o=f.useCallback(async l=>{const s=e.cells.find(d=>d.id===l);if(!s)return;const a=Mt(s);if(!a)return;const{sql:c}=n(a),x=Date.now();r({type:"UPDATE_CELL",id:l,updates:{status:"running",error:void 0,result:void 0}});try{const d=await B.executeQuery(c),u=Date.now()-x,p=(s.executionCount??0)+1;r({type:"UPDATE_CELL",id:l,updates:{status:"success",result:{...d,executionTime:d.executionTime??u,rowCount:d.rowCount??d.rows.length},executionCount:p}}),r({type:"APPEND_QUERY_LOG",entry:{id:F(),cellName:s.name??s.id,rows:d.rowCount??d.rows.length,time:d.executionTime??u,ts:new Date}}),setTimeout(()=>{r({type:"UPDATE_CELL",id:l,updates:{status:"idle"}})},2e3)}catch(d){const u=Date.now()-x,p=d instanceof Error?d.message:String(d);r({type:"UPDATE_CELL",id:l,updates:{status:"error",error:p,executionCount:(s.executionCount??0)+1}}),r({type:"APPEND_QUERY_LOG",entry:{id:F(),cellName:s.name??s.id,rows:0,time:u,ts:new Date,error:p}})}},[e.cells,r]),i=f.useCallback(async()=>{for(const l of e.cells)l.type!=="markdown"&&await o(l.id)},[e.cells,o]);return{executeCell:o,executeAll:i}}function L(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Lt(e){return typeof e=="number"?Math.abs(e)>=1e6?`${(e/1e6).toFixed(1)}M`:Math.abs(e)>=1e3?`${(e/1e3).toFixed(1)}K`:Number.isInteger(e)?String(e):e.toFixed(2):""}function Bt(e){const r=e.split(`
20
35
  `),n=[];let o=!1,i=!1;for(const l of r){const s=l;if(s.startsWith("```")){i&&(n.push("</ul>"),i=!1),o?(n.push("</code></pre>"),o=!1):(n.push("<pre><code>"),o=!0);continue}if(o){n.push(L(s));continue}if(s.startsWith("### ")){i&&(n.push("</ul>"),i=!1),n.push(`<h3>${L(s.slice(4))}</h3>`);continue}if(s.startsWith("## ")){i&&(n.push("</ul>"),i=!1),n.push(`<h2>${L(s.slice(3))}</h2>`);continue}if(s.startsWith("# ")){i&&(n.push("</ul>"),i=!1),n.push(`<h1>${L(s.slice(2))}</h1>`);continue}if(s.startsWith("> ")){i&&(n.push("</ul>"),i=!1),n.push(`<blockquote><p>${L(s.slice(2))}</p></blockquote>`);continue}if(s.startsWith("- ")||s.startsWith("* ")){i||(n.push("<ul>"),i=!0),n.push(`<li>${ae(s.slice(2))}</li>`);continue}if(i&&(n.push("</ul>"),i=!1),s.trim()===""){n.push("<br>");continue}n.push(`<p>${ae(s)}</p>`)}return i&&n.push("</ul>"),o&&n.push("</code></pre>"),n.join(`
21
- `)}function ae(e){return L(e).replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/`(.+?)`/g,"<code>$1</code>")}function Ct(e){const{columns:r,rows:n}=e,o=n.slice(0,200),i=n.length>200,l=r.map(a=>`<th>${L(a)}</th>`).join(""),s=o.map(a=>`<tr>${r.map(x=>{const d=a[x],u=typeof d=="number",p=d==null?"—":String(d);return`<td${u?' class="num"':""}>${L(p)}</td>`}).join("")}</tr>`).join("");return`
36
+ `)}function ae(e){return L(e).replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/`(.+?)`/g,"<code>$1</code>")}function Tt(e){const{columns:r,rows:n}=e,o=n.slice(0,200),i=n.length>200,l=r.map(a=>`<th>${L(a)}</th>`).join(""),s=o.map(a=>`<tr>${r.map(x=>{const d=a[x],u=typeof d=="number",p=d==null?"—":String(d);return`<td${u?' class="num"':""}>${L(p)}</td>`}).join("")}</tr>`).join("");return`
22
37
  <div class="table-wrap">
23
38
  <table>
24
39
  <thead><tr>${l}</tr></thead>
25
40
  <tbody>${s}</tbody>
26
41
  </table>
27
42
  ${i?`<p class="truncated">Showing first 200 of ${n.length.toLocaleString()} rows</p>`:""}
28
- </div>`}function Mt(e){const{columns:r,rows:n}=e;if(r.length<2||n.length===0)return null;const o=r.find(l=>typeof n[0][l]=="number"),i=r.find(l=>l!==o);return!o||!i?null:{labelCol:i,valueCol:o}}function Lt(e){const r=Mt(e);if(!r)return null;const n=e.rows.slice(0,20).map(d=>({label:String(d[r.labelCol]??""),value:Number(d[r.valueCol]??0)})),o=Math.max(...n.map(d=>d.value),1),i=28,l=6,s=140,a=440,c=n.length*(i+l)+40,x=n.map((d,u)=>{const p=u*(i+l)+20,m=Math.max(d.value/o*a,2);return`
43
+ </div>`}function At(e){const{columns:r,rows:n}=e;if(r.length<2||n.length===0)return null;const o=r.find(l=>typeof n[0][l]=="number"),i=r.find(l=>l!==o);return!o||!i?null:{labelCol:i,valueCol:o}}function $t(e){const r=At(e);if(!r)return null;const n=e.rows.slice(0,20).map(d=>({label:String(d[r.labelCol]??""),value:Number(d[r.valueCol]??0)})),o=Math.max(...n.map(d=>d.value),1),i=28,l=6,s=140,a=440,c=n.length*(i+l)+40,x=n.map((d,u)=>{const p=u*(i+l)+20,m=Math.max(d.value/o*a,2);return`
29
44
  <text x="${s-6}" y="${p+i/2+4}" text-anchor="end" font-size="11" fill="#8b949e">${L(d.label.slice(0,20))}</text>
30
45
  <rect x="${s}" y="${p}" width="${m}" height="${i}" rx="3" fill="#388bfd" />
31
- <text x="${s+m+5}" y="${p+i/2+4}" font-size="11" fill="#e6edf3">${kt(d.value)}</text>`}).join("");return`<svg xmlns="http://www.w3.org/2000/svg" width="${s+a+80}" height="${c}" style="max-width:100%">${x}</svg>`}function Bt(e,r){const n=r.map(o=>{if(o.type==="markdown")return`<section class="cell md-cell">${Et(o.content)}</section>`;const i=o.name?`<div class="cell-header"><span class="cell-type">${o.type.toUpperCase()}</span><span class="cell-name">${L(o.name)}</span></div>`:`<div class="cell-header"><span class="cell-type">${o.type.toUpperCase()}</span></div>`,l=`<pre class="cell-code"><code>${L(o.content)}</code></pre>`;let s="";if(o.result&&o.result.rows.length>0){const a=Lt(o.result),c=Ct(o.result);s=`<div class="cell-output">${`<div class="output-meta">${o.result.rows.length.toLocaleString()} rows${o.result.executionTime?` · ${o.result.executionTime}ms`:""}</div>`}${a??""}${a?"":c}</div>`}else o.error&&(s=`<div class="cell-error">⚠ ${L(o.error)}</div>`);return`<section class="cell sql-cell">${i}${l}${s}</section>`}).join(`
46
+ <text x="${s+m+5}" y="${p+i/2+4}" font-size="11" fill="#e6edf3">${Lt(d.value)}</text>`}).join("");return`<svg xmlns="http://www.w3.org/2000/svg" width="${s+a+80}" height="${c}" style="max-width:100%">${x}</svg>`}function Dt(e,r){const n=r.map(o=>{if(o.type==="markdown")return`<section class="cell md-cell">${Bt(o.content)}</section>`;const i=o.name?`<div class="cell-header"><span class="cell-type">${o.type.toUpperCase()}</span><span class="cell-name">${L(o.name)}</span></div>`:`<div class="cell-header"><span class="cell-type">${o.type.toUpperCase()}</span></div>`,l=`<pre class="cell-code"><code>${L(o.content)}</code></pre>`;let s="";if(o.result&&o.result.rows.length>0){const a=$t(o.result),c=Tt(o.result);s=`<div class="cell-output">${`<div class="output-meta">${o.result.rows.length.toLocaleString()} rows${o.result.executionTime?` · ${o.result.executionTime}ms`:""}</div>`}${a??""}${a?"":c}</div>`}else o.error&&(s=`<div class="cell-error">⚠ ${L(o.error)}</div>`);return`<section class="cell sql-cell">${i}${l}${s}</section>`}).join(`
32
47
  `);return`<!DOCTYPE html>
33
48
  <html lang="en">
34
49
  <head>
@@ -96,45 +111,45 @@ ${a}`}return{sql:a,substituted:l}},[e.cells])}}function wt(e){if(e.type==="markd
96
111
  </div>
97
112
  <p class="exported-by">Built with DQL Notebook</p>
98
113
  </body>
99
- </html>`}function Tt(e,r){const n=Bt(e,r),o=new Blob([n],{type:"text/html;charset=utf-8"}),i=URL.createObjectURL(o),l=document.createElement("a");l.href=i,l.download=`${e.toLowerCase().replace(/[^a-z0-9]+/g,"-")}-dashboard.html`,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(i)}function At(e,r){var l,s;const n=[];n.push(`workbook "${e}" {`);let o=0,i=0;for(const a of r)if(a.type!=="param"){if(a.type==="markdown"){i++;const c=`Markdown ${i}`;n.push(""),n.push(` page "${c}" {`);const x=a.content.split(`
114
+ </html>`}function Rt(e,r){const n=Dt(e,r),o=new Blob([n],{type:"text/html;charset=utf-8"}),i=URL.createObjectURL(o),l=document.createElement("a");l.href=i,l.download=`${e.toLowerCase().replace(/[^a-z0-9]+/g,"-")}-dashboard.html`,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(i)}function Ft(e,r){var l,s;const n=[];n.push(`workbook "${e}" {`);let o=0,i=0;for(const a of r)if(a.type!=="param"){if(a.type==="markdown"){i++;const c=`Markdown ${i}`;n.push(""),n.push(` page "${c}" {`);const x=a.content.split(`
100
115
  `);for(const d of x)n.push(` // ${d}`);n.push(" }")}else if(a.type==="sql"){o++;const c=((l=a.name)==null?void 0:l.trim())||`Query ${o}`;n.push(""),n.push(` page "${c}" {`);const d=a.content.trim().split(`
101
116
  `).map(u=>` ${u}`).join(`
102
117
  `);n.push(" chart.table("),n.push(d+","),n.push(` title = "${c}"`),n.push(" )"),n.push(" }")}else if(a.type==="dql"){o++;const c=((s=a.name)==null?void 0:s.trim())||`Query ${o}`;n.push(""),n.push(` page "${c}" {`);const x=a.content.trim().split(`
103
118
  `);for(const d of x)n.push(` ${d}`);n.push(" }")}}return n.push("}"),n.join(`
104
- `)}function $t(e,r){const n=At(e,r),o=new Blob([n],{type:"text/plain;charset=utf-8"}),i=URL.createObjectURL(o),l=document.createElement("a"),s=e.replace(/[^a-zA-Z0-9_-]/g,"_")+".dql";l.href=i,l.download=s,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(i)}function Dt({t:e}){return t.jsx("div",{style:{width:28,height:28,borderRadius:6,background:"linear-gradient(135deg, #388bfd 0%, #1f6feb 100%)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx("span",{style:{color:"#ffffff",fontSize:10,fontWeight:700,fontFamily:e.fontMono,letterSpacing:"-0.5px"},children:"DQL"})})}function Rt(){const{state:e,dispatch:r}=w(),n=S[e.themeMode],{executeAll:o}=oe(),[i,l]=f.useState(!1),[s,a]=f.useState(""),[c,x]=f.useState(!1),[d,u]=f.useState(!1),[p,m]=f.useState(!1),[g,h]=f.useState(!1),[y,C]=f.useState(!1),[E,k]=f.useState(!1),B=f.useRef(null),T=f.useRef(null);f.useEffect(()=>{i&&T.current&&(T.current.focus(),T.current.select())},[i]),f.useEffect(()=>{if(!E)return;function M(G){B.current&&!B.current.contains(G.target)&&k(!1)}return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[E]);const D=()=>{a(e.notebookTitle),l(!0)},O=()=>{l(!1),s.trim()&&s!==e.notebookTitle&&r({type:"SET_NOTEBOOK_DIRTY",dirty:!0})},I=f.useCallback(async()=>{if(e.activeFile){r({type:"SET_SAVING",saving:!0});try{const M=yt(e.notebookTitle,e.cells);await $.saveNotebook(e.activeFile.path,M),r({type:"SET_NOTEBOOK_DIRTY",dirty:!1}),x(!0),setTimeout(()=>x(!1),2e3)}catch(M){console.error("Save failed:",M)}finally{r({type:"SET_SAVING",saving:!1})}}},[e.activeFile,e.notebookTitle,e.cells,r]),_=()=>{r({type:"SET_THEME",mode:e.themeMode==="dark"?"light":"dark"})},v={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 t.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:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[t.jsx(Dt,{t:n}),t.jsx("div",{style:{width:1,height:20,background:n.headerBorder,flexShrink:0}}),e.activeFile?i?t.jsx("input",{ref:T,value:s,onChange:M=>a(M.target.value),onBlur:O,onKeyDown:M=>{M.key==="Enter"&&O(),M.key==="Escape"&&l(!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}}):t.jsxs("span",{onClick:D,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:[e.notebookTitle||"Untitled",e.notebookDirty&&t.jsx("span",{style:{color:n.textMuted,marginLeft:4},children:"●"})]}):t.jsx("span",{style:{color:n.textSecondary,fontSize:13,fontFamily:n.font,padding:"2px 4px"},children:"DQL Notebook"})]}),t.jsx("div",{style:{flex:1}}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t.jsxs("button",{onClick:o,disabled:!e.activeFile,onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),style:{...v,background:(d&&e.activeFile,n.accent),color:"#ffffff",border:`1px solid ${n.accent}`,opacity:e.activeFile?d?.9:1:.4},children:[t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",children:t.jsx("path",{d:"M1.5 1.5l7 3.5-7 3.5V1.5Z"})}),"Run All"]}),t.jsx("div",{style:{width:1,height:20,background:n.headerBorder}}),t.jsx("button",{onClick:_,onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),title:e.themeMode==="dark"?"Switch to light mode":"Switch to dark mode",style:{...v,background:g?n.btnHover:n.btnBg,color:n.textSecondary,padding:"0 8px",fontSize:14},children:e.themeMode==="dark"?"☀":"☾"}),t.jsx("button",{onClick:I,disabled:!e.activeFile||e.savingFile,onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),style:{...v,background:p&&e.activeFile?n.btnHover:n.btnBg,color:c?n.success:n.textSecondary,opacity:e.activeFile?1:.4},children:e.savingFile?t.jsxs(t.Fragment,{children:[t.jsx(Ot,{}),"Saving…"]}):c?t.jsx(t.Fragment,{children:"✓ Saved"}):t.jsx(t.Fragment,{children:"Save"})}),t.jsx("div",{style:{width:1,height:20,background:n.headerBorder}}),t.jsxs("div",{ref:B,style:{position:"relative"},children:[t.jsxs("button",{onClick:()=>{e.activeFile&&k(M=>!M)},disabled:!e.activeFile,onMouseEnter:()=>C(!0),onMouseLeave:()=>C(!1),title:"Export options",style:{...v,background:(y||E)&&e.activeFile?n.btnHover:n.btnBg,color:n.textSecondary,opacity:e.activeFile?1:.4},children:[t.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"currentColor",children:[t.jsx("path",{d:"M2.75 14A1.75 1.75 0 0 1 1 12.25v-2.5a.75.75 0 0 1 1.5 0v2.5c0 .138.112.25.25.25h10.5a.25.25 0 0 0 .25-.25v-2.5a.75.75 0 0 1 1.5 0v2.5A1.75 1.75 0 0 1 13.25 14Z"}),t.jsx("path",{d:"M7.25 7.689V2a.75.75 0 0 1 1.5 0v5.689l1.97-1.97a.749.749 0 1 1 1.06 1.06l-3.25 3.25a.749.749 0 0 1-1.06 0L4.22 6.779a.749.749 0 1 1 1.06-1.06l1.97 1.97Z"})]}),"Export",t.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"currentColor",style:{marginLeft:1},children:t.jsx("path",{d:"M1 2.5l3 3 3-3",stroke:"currentColor",fill:"none",strokeWidth:"1.2",strokeLinecap:"round"})})]}),E&&t.jsxs("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:[t.jsx(de,{label:"Export HTML",description:"Standalone dashboard",t:n,onClick:()=>{Tt(e.notebookTitle||"dashboard",e.cells),k(!1)}}),t.jsx(de,{label:"Export .dql",description:"DQL workbook file",t:n,onClick:()=>{$t(e.notebookTitle||"notebook",e.cells),k(!1)}})]})]})]})]})}function de({label:e,description:r,t:n,onClick:o}){const[i,l]=f.useState(!1);return t.jsxs("button",{onClick:o,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{background:i?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:[t.jsx("span",{style:{fontSize:12,fontWeight:500,color:n.textPrimary,fontFamily:n.font},children:e}),t.jsx("span",{style:{fontSize:10,color:n.textMuted,fontFamily:n.font},children:r})]})}function Ot(){return t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{animation:"spin 0.8s linear infinite"},children:[t.jsx("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"}),t.jsx("circle",{cx:"6",cy:"6",r:"4.5",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"14 7"})]})}function _t(e){return e.toTimeString().slice(0,8)}function Ft(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(2)}s`}function Nt(){const{state:e,dispatch:r}=w(),n=S[e.themeMode],[o,i]=f.useState(!1),l=e.queryLog.filter(a=>a.error),s=a=>r({type:"SET_DEV_PANEL_TAB",tab:a});return t.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&&t.jsxs(t.Fragment,{children:[t.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=>t.jsx(Ht,{label:a==="errors"?`Errors${l.length>0?` (${l.length})`:""}`:`Logs (${e.queryLog.length})`,active:e.devPanelTab===a,onClick:()=>s(a),t:n},a)),t.jsx("div",{style:{flex:1}}),t.jsx("button",{onClick:()=>r({type:"SET_CELLS",cells:e.cells}),title:"Clear logs",style:{background:"transparent",border:"none",cursor:"pointer",color:n.textMuted,fontSize:11,fontFamily:n.font,padding:"2px 6px",borderRadius:4},children:"Clear"})]}),t.jsxs("div",{style:{flex:1,overflow:"auto",padding:"4px 0"},children:[e.devPanelTab==="logs"&&(e.queryLog.length===0?t.jsx(ce,{t:n,message:"No queries executed yet."}):[...e.queryLog].reverse().map(a=>t.jsx(ue,{entry:a,t:n},a.id))),e.devPanelTab==="errors"&&(l.length===0?t.jsx(ce,{t:n,message:"No errors."}):[...l].reverse().map(a=>t.jsx(ue,{entry:a,t:n},a.id)))]})]}),t.jsxs("button",{onClick:()=>r({type:"TOGGLE_DEV_PANEL"}),onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!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",border:`1px solid ${n.headerBorder}`,borderBottom:e.devPanelOpen?`1px solid ${n.sidebarBg}`:void 0,background:o?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:[t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",children:t.jsx("path",{d:e.devPanelOpen?"M1 7l4-4 4 4":"M1 3l4 4 4-4",strokeWidth:"1.5",stroke:"currentColor",fill:"none"})}),"Dev"]})]})}function Ht({label:e,active:r,onClick:n,t:o}){const[i,l]=f.useState(!1);return t.jsx("button",{onClick:n,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{background:"transparent",border:"none",borderBottom:r?`2px solid ${o.accent}`:"2px solid transparent",cursor:"pointer",color:r?o.textPrimary:i?o.textSecondary:o.textMuted,fontSize:12,fontFamily:o.font,fontWeight:r?500:400,padding:"4px 8px",height:32,transition:"color 0.15s"},children:e})}function ce({t:e,message:r}){return t.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.textMuted,fontSize:12,fontFamily:e.font,fontStyle:"italic"},children:r})}function ue({entry:e,t:r}){return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"3px 12px",fontSize:11,fontFamily:r.fontMono,color:e.error?r.error:r.textSecondary,borderLeft:e.error?`2px solid ${r.error}`:"2px solid transparent"},children:[t.jsx("span",{style:{color:r.textMuted,flexShrink:0},children:_t(e.ts)}),t.jsx("span",{style:{flexShrink:0,color:r.textPrimary,maxWidth:160,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.cellName}),e.error?t.jsx("span",{style:{color:r.error,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.error}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{style:{color:r.textMuted},children:[e.rows.toLocaleString()," rows"]}),t.jsx("span",{style:{color:r.textMuted},children:Ft(e.time)})]})]})}function It({onOpenFile:e}){const{state:r,dispatch:n}=w(),o=S[r.themeMode],i=r.files.slice(0,3);return t.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",background:o.appBg,padding:40,overflow:"auto"},children:t.jsxs("div",{style:{maxWidth:720,width:"100%",display:"flex",flexDirection:"column",alignItems:"center",gap:48},children:[t.jsxs("div",{style:{textAlign:"center",display:"flex",flexDirection:"column",alignItems:"center",gap:16},children:[t.jsx("div",{style:{width:72,height:72,borderRadius:16,background:"linear-gradient(135deg, #388bfd 0%, #1f6feb 60%, #0d419d 100%)",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 8px 32px rgba(56,139,253,0.3)"},children:t.jsx("span",{style:{color:"#fff",fontSize:26,fontWeight:800,fontFamily:o.fontMono,letterSpacing:"-1px"},children:"DQL"})}),t.jsxs("div",{children:[t.jsx("h1",{style:{fontSize:32,fontWeight:700,color:o.textPrimary,fontFamily:o.font,marginBottom:8,letterSpacing:"-0.5px"},children:"DQL Notebook"}),t.jsx("p",{style:{fontSize:15,color:o.textSecondary,fontFamily:o.font,letterSpacing:"0.02em"},children:"Analytics as Code"})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:16,width:"100%"},children:[t.jsx(pe,{title:"New Notebook",description:"Start a fresh analysis with an empty notebook.",icon:t.jsx(Wt,{}),accent:o.accent,onClick:()=>n({type:"OPEN_NEW_NOTEBOOK_MODAL"}),t:o}),t.jsx(zt,{recentFiles:i,onOpenFile:e,t:o}),t.jsx(pe,{title:"Browse Examples",description:"Explore sample notebooks and DQL workbooks.",icon:t.jsx(Vt,{}),accent:o.success,onClick:()=>{const l=r.files.find(s=>s.folder.toLowerCase()==="notebooks");l&&e(l)},t:o})]}),t.jsxs("div",{style:{width:"100%",borderRadius:10,border:`1px solid ${o.cellBorder}`,padding:"16px 20px",background:o.cellBg},children:[t.jsx("div",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:o.textMuted,fontFamily:o.font,marginBottom:12},children:"Quick Tips"}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:8},children:[["Shift + Enter","Run cell"],["Click +","Add a new cell"],["Double-click MD cell","Edit markdown"],["Header title","Click to rename notebook"]].map(([l,s])=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("kbd",{style:{background:o.pillBg,border:`1px solid ${o.cellBorder}`,borderRadius:4,padding:"2px 6px",fontSize:11,fontFamily:o.fontMono,color:o.textSecondary,whiteSpace:"nowrap"},children:l}),t.jsx("span",{style:{fontSize:12,color:o.textMuted,fontFamily:o.font},children:s})]},l))})]})]})})}function pe({title:e,description:r,icon:n,accent:o,onClick:i,t:l}){const[s,a]=f.useState(!1);return t.jsxs("button",{onClick:i,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:{background:s?l.cellBg:"transparent",border:`1px solid ${s?o:l.cellBorder}`,borderRadius:10,padding:"20px 16px",cursor:"pointer",textAlign:"left",display:"flex",flexDirection:"column",gap:10,transition:"border-color 0.2s, background 0.2s, box-shadow 0.2s",boxShadow:s?`0 0 0 1px ${o}30, 0 4px 16px rgba(0,0,0,0.15)`:"none"},children:[t.jsx("div",{style:{width:36,height:36,borderRadius:8,background:`${o}18`,display:"flex",alignItems:"center",justifyContent:"center",color:o},children:n}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:13,fontWeight:600,color:l.textPrimary,fontFamily:l.font,marginBottom:4},children:e}),t.jsx("div",{style:{fontSize:12,color:l.textSecondary,fontFamily:l.font,lineHeight:1.5},children:r})]})]})}function zt({recentFiles:e,onOpenFile:r,t:n}){const[o,i]=f.useState(!1);return t.jsxs("div",{onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{background:o?n.cellBg:"transparent",border:`1px solid ${o?n.textMuted:n.cellBorder}`,borderRadius:10,padding:"20px 16px",textAlign:"left",display:"flex",flexDirection:"column",gap:10,transition:"border-color 0.2s, background 0.2s"},children:[t.jsx("div",{style:{width:36,height:36,borderRadius:8,background:`${n.warning}18`,display:"flex",alignItems:"center",justifyContent:"center",color:n.warning},children:t.jsx(Zt,{})}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:13,fontWeight:600,color:n.textPrimary,fontFamily:n.font,marginBottom:8},children:"Open Recent"}),e.length===0?t.jsx("div",{style:{fontSize:12,color:n.textMuted,fontFamily:n.font,fontStyle:"italic"},children:"No recent files."}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:e.map(l=>t.jsx(Pt,{file:l,onClick:()=>r(l),t:n},l.path))})]})]})}function Pt({file:e,onClick:r,t:n}){const[o,i]=f.useState(!1);return t.jsx("button",{onClick:r,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{background:"transparent",border:"none",cursor:"pointer",color:o?n.accent:n.textSecondary,fontSize:12,fontFamily:n.font,textAlign:"left",padding:"2px 0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",transition:"color 0.15s"},children:e.name.replace(/\.(dqlnb|dql)$/,"")})}function Wt(){return t.jsx("svg",{width:"18",height:"18",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 8.75 4.25V1.5ZM8.75 5.5h2.836L10.25 3.664V4.25c0 .138.112.25.25.25H8.75Zm.5 3.25a.75.75 0 0 1 .75.75v.75h.75a.75.75 0 0 1 0 1.5H10v.75a.75.75 0 0 1-1.5 0V11.5H7.75a.75.75 0 0 1 0-1.5H8.5V9.5a.75.75 0 0 1 .75-.75Z"})})}function Zt(){return t.jsx("svg",{width:"18",height:"18",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm7-3.25v2.992l2.028.812a.75.75 0 0 1-.557 1.392l-2.5-1A.751.751 0 0 1 7 8.25v-3.5a.75.75 0 0 1 1.5 0Z"})})}function Vt(){return t.jsx("svg",{width:"18",height:"18",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M.24 2.375C.24 1.064 1.225.001 2.409.001h6.451a1.17 1.17 0 0 1 .828.344l3.311 3.312a1.17 1.17 0 0 1 .344.828v9.14c0 1.31-.985 2.374-2.169 2.374H2.41C1.225 16 .24 14.937.24 13.625ZM2.41 1.376a.846.846 0 0 0-.844.86v11.39c0 .47.38.86.844.86h8.774a.847.847 0 0 0 .844-.86V5.157L8.688 1.373H2.41Z"})})}function be({value:e,onChange:r,onRun:n,themeMode:o,autoFocus:i}){const l=S[o],s=f.useRef(null),a=f.useRef(null),c=f.useRef(n),x=f.useRef(r);return c.current=n,x.current=r,f.useEffect(()=>{if(!s.current)return;const d=Be.of([{key:"Shift-Enter",run:()=>(c.current(),!0)},{key:"Ctrl-Enter",mac:"Cmd-Enter",run:()=>(c.current(),!0)},Te,...Ae]),u=V.updateListener.of(y=>{y.docChanged&&x.current(y.state.doc.toString())}),p=V.theme({"&":{background:l.editorBg,fontFamily:l.fontMono,fontSize:"13px",minHeight:"80px",maxHeight:"400px"},".cm-scroller":{overflow:"auto",fontFamily:"inherit"},".cm-content":{padding:"10px 0",minHeight:"80px"},".cm-focused":{outline:"none"},".cm-editor":{border:"none"}}),m=[d,u,p,De(),Re(),Oe(),V.lineWrapping,...o==="dark"?[$e]:[]],g=_e.create({doc:e,extensions:m}),h=new V({state:g,parent:s.current});return a.current=h,i&&h.focus(),()=>{h.destroy(),a.current=null}},[o]),f.useEffect(()=>{const d=a.current;if(!d)return;const u=d.state.doc.toString();u!==e&&d.dispatch({changes:{from:0,to:u.length,insert:e}})},[e]),t.jsx("div",{ref:s,style:{background:l.editorBg,minHeight:80}})}be.displayName="SQLCellEditor";function qt(e,r){const n=e.split(`
119
+ `)}function Ot(e,r){const n=Ft(e,r),o=new Blob([n],{type:"text/plain;charset=utf-8"}),i=URL.createObjectURL(o),l=document.createElement("a"),s=e.replace(/[^a-zA-Z0-9_-]/g,"_")+".dql";l.href=i,l.download=s,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(i)}function _t({t:e}){return t.jsx("div",{style:{width:28,height:28,borderRadius:6,background:"linear-gradient(135deg, #388bfd 0%, #1f6feb 100%)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx("span",{style:{color:"#ffffff",fontSize:10,fontWeight:700,fontFamily:e.fontMono,letterSpacing:"-0.5px"},children:"DQL"})})}function Nt(){const{state:e,dispatch:r}=w(),n=j[e.themeMode],{executeAll:o}=oe(),[i,l]=f.useState(!1),[s,a]=f.useState(""),[c,x]=f.useState(!1),[d,u]=f.useState(!1),[p,m]=f.useState(!1),[h,g]=f.useState(!1),[y,k]=f.useState(!1),[v,E]=f.useState(!1),T=f.useRef(null),A=f.useRef(null);f.useEffect(()=>{i&&A.current&&(A.current.focus(),A.current.select())},[i]),f.useEffect(()=>{if(!v)return;function M(G){T.current&&!T.current.contains(G.target)&&E(!1)}return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[v]);const D=()=>{a(e.notebookTitle),l(!0)},O=()=>{l(!1),s.trim()&&s!==e.notebookTitle&&r({type:"SET_NOTEBOOK_DIRTY",dirty:!0})},z=f.useCallback(async()=>{if(e.activeFile){r({type:"SET_SAVING",saving:!0});try{const M=jt(e.notebookTitle,e.cells);await B.saveNotebook(e.activeFile.path,M),r({type:"SET_NOTEBOOK_DIRTY",dirty:!1}),x(!0),setTimeout(()=>x(!1),2e3)}catch(M){console.error("Save failed:",M)}finally{r({type:"SET_SAVING",saving:!1})}}},[e.activeFile,e.notebookTitle,e.cells,r]),_=()=>{r({type:"SET_THEME",mode:e.themeMode==="dark"?"light":"dark"})},S={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 t.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:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[t.jsx(_t,{t:n}),t.jsx("div",{style:{width:1,height:20,background:n.headerBorder,flexShrink:0}}),e.activeFile?i?t.jsx("input",{ref:A,value:s,onChange:M=>a(M.target.value),onBlur:O,onKeyDown:M=>{M.key==="Enter"&&O(),M.key==="Escape"&&l(!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}}):t.jsxs("span",{onClick:D,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:[e.notebookTitle||"Untitled",e.notebookDirty&&t.jsx("span",{style:{color:n.textMuted,marginLeft:4},children:"●"})]}):t.jsx("span",{style:{color:n.textSecondary,fontSize:13,fontFamily:n.font,padding:"2px 4px"},children:"DQL Notebook"})]}),t.jsx("div",{style:{flex:1}}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t.jsxs("button",{onClick:o,disabled:!e.activeFile,onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),style:{...S,background:(d&&e.activeFile,n.accent),color:"#ffffff",border:`1px solid ${n.accent}`,opacity:e.activeFile?d?.9:1:.4},children:[t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",children:t.jsx("path",{d:"M1.5 1.5l7 3.5-7 3.5V1.5Z"})}),"Run All"]}),t.jsx("div",{style:{width:1,height:20,background:n.headerBorder}}),t.jsx("button",{onClick:_,onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),title:e.themeMode==="dark"?"Switch to light mode":"Switch to dark mode",style:{...S,background:h?n.btnHover:n.btnBg,color:n.textSecondary,padding:"0 8px",fontSize:14},children:e.themeMode==="dark"?"☀":"☾"}),t.jsx("button",{onClick:z,disabled:!e.activeFile||e.savingFile,onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),style:{...S,background:p&&e.activeFile?n.btnHover:n.btnBg,color:c?n.success:n.textSecondary,opacity:e.activeFile?1:.4},children:e.savingFile?t.jsxs(t.Fragment,{children:[t.jsx(It,{}),"Saving…"]}):c?t.jsx(t.Fragment,{children:"✓ Saved"}):t.jsx(t.Fragment,{children:"Save"})}),t.jsx("div",{style:{width:1,height:20,background:n.headerBorder}}),t.jsxs("div",{ref:T,style:{position:"relative"},children:[t.jsxs("button",{onClick:()=>{e.activeFile&&E(M=>!M)},disabled:!e.activeFile,onMouseEnter:()=>k(!0),onMouseLeave:()=>k(!1),title:"Export options",style:{...S,background:(y||v)&&e.activeFile?n.btnHover:n.btnBg,color:n.textSecondary,opacity:e.activeFile?1:.4},children:[t.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"currentColor",children:[t.jsx("path",{d:"M2.75 14A1.75 1.75 0 0 1 1 12.25v-2.5a.75.75 0 0 1 1.5 0v2.5c0 .138.112.25.25.25h10.5a.25.25 0 0 0 .25-.25v-2.5a.75.75 0 0 1 1.5 0v2.5A1.75 1.75 0 0 1 13.25 14Z"}),t.jsx("path",{d:"M7.25 7.689V2a.75.75 0 0 1 1.5 0v5.689l1.97-1.97a.749.749 0 1 1 1.06 1.06l-3.25 3.25a.749.749 0 0 1-1.06 0L4.22 6.779a.749.749 0 1 1 1.06-1.06l1.97 1.97Z"})]}),"Export",t.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"currentColor",style:{marginLeft:1},children:t.jsx("path",{d:"M1 2.5l3 3 3-3",stroke:"currentColor",fill:"none",strokeWidth:"1.2",strokeLinecap:"round"})})]}),v&&t.jsxs("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:[t.jsx(de,{label:"Export HTML",description:"Standalone dashboard",t:n,onClick:()=>{Rt(e.notebookTitle||"dashboard",e.cells),E(!1)}}),t.jsx(de,{label:"Export .dql",description:"DQL workbook file",t:n,onClick:()=>{Ot(e.notebookTitle||"notebook",e.cells),E(!1)}})]})]})]})]})}function de({label:e,description:r,t:n,onClick:o}){const[i,l]=f.useState(!1);return t.jsxs("button",{onClick:o,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{background:i?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:[t.jsx("span",{style:{fontSize:12,fontWeight:500,color:n.textPrimary,fontFamily:n.font},children:e}),t.jsx("span",{style:{fontSize:10,color:n.textMuted,fontFamily:n.font},children:r})]})}function It(){return t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{animation:"spin 0.8s linear infinite"},children:[t.jsx("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"}),t.jsx("circle",{cx:"6",cy:"6",r:"4.5",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"14 7"})]})}function Ht(e){return e.toTimeString().slice(0,8)}function zt(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(2)}s`}function Pt(){const{state:e,dispatch:r}=w(),n=j[e.themeMode],[o,i]=f.useState(!1),l=e.queryLog.filter(a=>a.error),s=a=>r({type:"SET_DEV_PANEL_TAB",tab:a});return t.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&&t.jsxs(t.Fragment,{children:[t.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=>t.jsx(Wt,{label:a==="errors"?`Errors${l.length>0?` (${l.length})`:""}`:`Logs (${e.queryLog.length})`,active:e.devPanelTab===a,onClick:()=>s(a),t:n},a)),t.jsx("div",{style:{flex:1}}),t.jsx("button",{onClick:()=>r({type:"SET_CELLS",cells:e.cells}),title:"Clear logs",style:{background:"transparent",border:"none",cursor:"pointer",color:n.textMuted,fontSize:11,fontFamily:n.font,padding:"2px 6px",borderRadius:4},children:"Clear"})]}),t.jsxs("div",{style:{flex:1,overflow:"auto",padding:"4px 0"},children:[e.devPanelTab==="logs"&&(e.queryLog.length===0?t.jsx(ce,{t:n,message:"No queries executed yet."}):[...e.queryLog].reverse().map(a=>t.jsx(ue,{entry:a,t:n},a.id))),e.devPanelTab==="errors"&&(l.length===0?t.jsx(ce,{t:n,message:"No errors."}):[...l].reverse().map(a=>t.jsx(ue,{entry:a,t:n},a.id)))]})]}),t.jsxs("button",{onClick:()=>r({type:"TOGGLE_DEV_PANEL"}),onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!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",border:`1px solid ${n.headerBorder}`,borderBottom:e.devPanelOpen?`1px solid ${n.sidebarBg}`:void 0,background:o?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:[t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",children:t.jsx("path",{d:e.devPanelOpen?"M1 7l4-4 4 4":"M1 3l4 4 4-4",strokeWidth:"1.5",stroke:"currentColor",fill:"none"})}),"Dev"]})]})}function Wt({label:e,active:r,onClick:n,t:o}){const[i,l]=f.useState(!1);return t.jsx("button",{onClick:n,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{background:"transparent",border:"none",borderBottom:r?`2px solid ${o.accent}`:"2px solid transparent",cursor:"pointer",color:r?o.textPrimary:i?o.textSecondary:o.textMuted,fontSize:12,fontFamily:o.font,fontWeight:r?500:400,padding:"4px 8px",height:32,transition:"color 0.15s"},children:e})}function ce({t:e,message:r}){return t.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.textMuted,fontSize:12,fontFamily:e.font,fontStyle:"italic"},children:r})}function ue({entry:e,t:r}){return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"3px 12px",fontSize:11,fontFamily:r.fontMono,color:e.error?r.error:r.textSecondary,borderLeft:e.error?`2px solid ${r.error}`:"2px solid transparent"},children:[t.jsx("span",{style:{color:r.textMuted,flexShrink:0},children:Ht(e.ts)}),t.jsx("span",{style:{flexShrink:0,color:r.textPrimary,maxWidth:160,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.cellName}),e.error?t.jsx("span",{style:{color:r.error,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.error}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{style:{color:r.textMuted},children:[e.rows.toLocaleString()," rows"]}),t.jsx("span",{style:{color:r.textMuted},children:zt(e.time)})]})]})}function Zt({onOpenFile:e}){const{state:r,dispatch:n}=w(),o=j[r.themeMode],i=r.files.slice(0,3);return t.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",background:o.appBg,padding:40,overflow:"auto"},children:t.jsxs("div",{style:{maxWidth:720,width:"100%",display:"flex",flexDirection:"column",alignItems:"center",gap:48},children:[t.jsxs("div",{style:{textAlign:"center",display:"flex",flexDirection:"column",alignItems:"center",gap:16},children:[t.jsx("div",{style:{width:72,height:72,borderRadius:16,background:"linear-gradient(135deg, #388bfd 0%, #1f6feb 60%, #0d419d 100%)",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 8px 32px rgba(56,139,253,0.3)"},children:t.jsx("span",{style:{color:"#fff",fontSize:26,fontWeight:800,fontFamily:o.fontMono,letterSpacing:"-1px"},children:"DQL"})}),t.jsxs("div",{children:[t.jsx("h1",{style:{fontSize:32,fontWeight:700,color:o.textPrimary,fontFamily:o.font,marginBottom:8,letterSpacing:"-0.5px"},children:"DQL Notebook"}),t.jsx("p",{style:{fontSize:15,color:o.textSecondary,fontFamily:o.font,letterSpacing:"0.02em"},children:"Analytics as Code"})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:16,width:"100%"},children:[t.jsx(pe,{title:"New Notebook",description:"Start a fresh analysis with an empty notebook.",icon:t.jsx(Ut,{}),accent:o.accent,onClick:()=>n({type:"OPEN_NEW_NOTEBOOK_MODAL"}),t:o}),t.jsx(Vt,{recentFiles:i,onOpenFile:e,t:o}),t.jsx(pe,{title:"Browse Examples",description:"Explore sample notebooks and DQL workbooks.",icon:t.jsx(Qt,{}),accent:o.success,onClick:()=>{const l=r.files.find(s=>s.folder.toLowerCase()==="notebooks");l&&e(l)},t:o})]}),t.jsxs("div",{style:{width:"100%",borderRadius:10,border:`1px solid ${o.cellBorder}`,padding:"16px 20px",background:o.cellBg},children:[t.jsx("div",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:o.textMuted,fontFamily:o.font,marginBottom:12},children:"Quick Tips"}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:8},children:[["Shift + Enter","Run cell"],["Click +","Add a new cell"],["Double-click MD cell","Edit markdown"],["Header title","Click to rename notebook"]].map(([l,s])=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("kbd",{style:{background:o.pillBg,border:`1px solid ${o.cellBorder}`,borderRadius:4,padding:"2px 6px",fontSize:11,fontFamily:o.fontMono,color:o.textSecondary,whiteSpace:"nowrap"},children:l}),t.jsx("span",{style:{fontSize:12,color:o.textMuted,fontFamily:o.font},children:s})]},l))})]})]})})}function pe({title:e,description:r,icon:n,accent:o,onClick:i,t:l}){const[s,a]=f.useState(!1);return t.jsxs("button",{onClick:i,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:{background:s?l.cellBg:"transparent",border:`1px solid ${s?o:l.cellBorder}`,borderRadius:10,padding:"20px 16px",cursor:"pointer",textAlign:"left",display:"flex",flexDirection:"column",gap:10,transition:"border-color 0.2s, background 0.2s, box-shadow 0.2s",boxShadow:s?`0 0 0 1px ${o}30, 0 4px 16px rgba(0,0,0,0.15)`:"none"},children:[t.jsx("div",{style:{width:36,height:36,borderRadius:8,background:`${o}18`,display:"flex",alignItems:"center",justifyContent:"center",color:o},children:n}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:13,fontWeight:600,color:l.textPrimary,fontFamily:l.font,marginBottom:4},children:e}),t.jsx("div",{style:{fontSize:12,color:l.textSecondary,fontFamily:l.font,lineHeight:1.5},children:r})]})]})}function Vt({recentFiles:e,onOpenFile:r,t:n}){const[o,i]=f.useState(!1);return t.jsxs("div",{onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{background:o?n.cellBg:"transparent",border:`1px solid ${o?n.textMuted:n.cellBorder}`,borderRadius:10,padding:"20px 16px",textAlign:"left",display:"flex",flexDirection:"column",gap:10,transition:"border-color 0.2s, background 0.2s"},children:[t.jsx("div",{style:{width:36,height:36,borderRadius:8,background:`${n.warning}18`,display:"flex",alignItems:"center",justifyContent:"center",color:n.warning},children:t.jsx(Gt,{})}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:13,fontWeight:600,color:n.textPrimary,fontFamily:n.font,marginBottom:8},children:"Open Recent"}),e.length===0?t.jsx("div",{style:{fontSize:12,color:n.textMuted,fontFamily:n.font,fontStyle:"italic"},children:"No recent files."}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:e.map(l=>t.jsx(qt,{file:l,onClick:()=>r(l),t:n},l.path))})]})]})}function qt({file:e,onClick:r,t:n}){const[o,i]=f.useState(!1);return t.jsx("button",{onClick:r,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{background:"transparent",border:"none",cursor:"pointer",color:o?n.accent:n.textSecondary,fontSize:12,fontFamily:n.font,textAlign:"left",padding:"2px 0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",transition:"color 0.15s"},children:e.name.replace(/\.(dqlnb|dql)$/,"")})}function Ut(){return t.jsx("svg",{width:"18",height:"18",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 8.75 4.25V1.5ZM8.75 5.5h2.836L10.25 3.664V4.25c0 .138.112.25.25.25H8.75Zm.5 3.25a.75.75 0 0 1 .75.75v.75h.75a.75.75 0 0 1 0 1.5H10v.75a.75.75 0 0 1-1.5 0V11.5H7.75a.75.75 0 0 1 0-1.5H8.5V9.5a.75.75 0 0 1 .75-.75Z"})})}function Gt(){return t.jsx("svg",{width:"18",height:"18",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm7-3.25v2.992l2.028.812a.75.75 0 0 1-.557 1.392l-2.5-1A.751.751 0 0 1 7 8.25v-3.5a.75.75 0 0 1 1.5 0Z"})})}function Qt(){return t.jsx("svg",{width:"18",height:"18",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M.24 2.375C.24 1.064 1.225.001 2.409.001h6.451a1.17 1.17 0 0 1 .828.344l3.311 3.312a1.17 1.17 0 0 1 .344.828v9.14c0 1.31-.985 2.374-2.169 2.374H2.41C1.225 16 .24 14.937.24 13.625ZM2.41 1.376a.846.846 0 0 0-.844.86v11.39c0 .47.38.86.844.86h8.774a.847.847 0 0 0 .844-.86V5.157L8.688 1.373H2.41Z"})})}function be({value:e,onChange:r,onRun:n,themeMode:o,autoFocus:i}){const l=j[o],s=f.useRef(null),a=f.useRef(null),c=f.useRef(n),x=f.useRef(r);return c.current=n,x.current=r,f.useEffect(()=>{if(!s.current)return;const d=Be.of([{key:"Shift-Enter",run:()=>(c.current(),!0)},{key:"Ctrl-Enter",mac:"Cmd-Enter",run:()=>(c.current(),!0)},Te,...Ae]),u=V.updateListener.of(y=>{y.docChanged&&x.current(y.state.doc.toString())}),p=V.theme({"&":{background:l.editorBg,fontFamily:l.fontMono,fontSize:"13px",minHeight:"80px",maxHeight:"400px"},".cm-scroller":{overflow:"auto",fontFamily:"inherit"},".cm-content":{padding:"10px 0",minHeight:"80px"},".cm-focused":{outline:"none"},".cm-editor":{border:"none"}}),m=[d,u,p,De(),Re(),Fe(),V.lineWrapping,...o==="dark"?[$e]:[]],h=Oe.create({doc:e,extensions:m}),g=new V({state:h,parent:s.current});return a.current=g,i&&g.focus(),()=>{g.destroy(),a.current=null}},[o]),f.useEffect(()=>{const d=a.current;if(!d)return;const u=d.state.doc.toString();u!==e&&d.dispatch({changes:{from:0,to:u.length,insert:e}})},[e]),t.jsx("div",{ref:s,style:{background:l.editorBg,minHeight:80}})}be.displayName="SQLCellEditor";function Kt(e,r){const n=e.split(`
105
120
  `),o=[];let i=0;for(;i<n.length;){const l=n[i],s=l.match(/^(#{1,6})\s+(.+)$/);if(s){const a=s[1].length,c=s[2],d=[28,22,18,16,14,13][a-1];o.push(t.jsx("div",{style:{fontSize:d,fontWeight:a<=2?700:600,color:r.textPrimary,fontFamily:r.font,lineHeight:1.3,marginBottom:a===1?12:8,marginTop:i>0?a===1?16:10:0,borderBottom:a===1?`1px solid ${r.cellBorder}`:void 0,paddingBottom:a===1?8:void 0},children:W(c,r)},i)),i++;continue}if(/^[-*_]{3,}$/.test(l.trim())){o.push(t.jsx("hr",{style:{border:"none",borderTop:`1px solid ${r.cellBorder}`,margin:"12px 0"}},i)),i++;continue}if(l.startsWith("> ")){o.push(t.jsx("div",{style:{borderLeft:`3px solid ${r.textMuted}`,paddingLeft:12,marginLeft:4,color:r.textSecondary,fontStyle:"italic",fontFamily:r.fontSerif,fontSize:14},children:W(l.slice(2),r)},i)),i++;continue}if(l.startsWith("```")){const a=[];for(i++;i<n.length&&!n[i].startsWith("```");)a.push(n[i]),i++;o.push(t.jsx("pre",{style:{background:r.editorBg,border:`1px solid ${r.cellBorder}`,borderRadius:6,padding:"10px 12px",fontSize:12,fontFamily:r.fontMono,color:r.textPrimary,overflow:"auto",margin:"8px 0",lineHeight:1.6},children:a.join(`
106
- `)},i)),i++;continue}if(/^[-*+]\s/.test(l)){const a=[];for(;i<n.length&&/^[-*+]\s/.test(n[i]);)a.push(n[i].replace(/^[-*+]\s/,"")),i++;o.push(t.jsx("ul",{style:{paddingLeft:20,marginBottom:8,color:r.textSecondary},children:a.map((c,x)=>t.jsx("li",{style:{fontSize:14,fontFamily:r.font,lineHeight:1.6,marginBottom:2},children:W(c,r)},x))},i));continue}if(/^\d+\.\s/.test(l)){const a=[];for(;i<n.length&&/^\d+\.\s/.test(n[i]);)a.push(n[i].replace(/^\d+\.\s/,"")),i++;o.push(t.jsx("ol",{style:{paddingLeft:20,marginBottom:8,color:r.textSecondary},children:a.map((c,x)=>t.jsx("li",{style:{fontSize:14,fontFamily:r.font,lineHeight:1.6,marginBottom:2},children:W(c,r)},x))},i));continue}if(!l.trim()){o.push(t.jsx("div",{style:{height:8}},i)),i++;continue}o.push(t.jsx("p",{style:{fontSize:14,lineHeight:1.7,fontFamily:r.fontSerif,color:r.textSecondary,marginBottom:6},children:W(l,r)},i)),i++}return o}function W(e,r){const n=[];let o=e,i=0;for(;o.length>0;){const l=o.match(/\*{3}(.+?)\*{3}/),s=o.match(/\*{2}(.+?)\*{2}/),a=o.match(/\*(.+?)\*/),c=o.match(/`(.+?)`/),x=o.match(/\[(.+?)\]\((.+?)\)/),d=[l?{match:l,type:"boldItalic"}:null,s?{match:s,type:"bold"}:null,a?{match:a,type:"italic"}:null,c?{match:c,type:"code"}:null,x?{match:x,type:"link"}:null].filter(Boolean);if(d.length===0){n.push(t.jsx(U.Fragment,{children:o},i++));break}const u=d.reduce((m,g)=>(m.match.index??0)<(g.match.index??0)?m:g),p=u.match.index??0;switch(p>0&&n.push(t.jsx(U.Fragment,{children:o.slice(0,p)},i++)),u.type){case"boldItalic":n.push(t.jsx("strong",{style:{fontStyle:"italic"},children:u.match[1]},i++));break;case"bold":n.push(t.jsx("strong",{children:u.match[1]},i++));break;case"italic":n.push(t.jsx("em",{children:u.match[1]},i++));break;case"code":n.push(t.jsx("code",{style:{background:r.editorBg,border:`1px solid ${r.cellBorder}`,borderRadius:4,padding:"1px 5px",fontSize:"0.9em",fontFamily:r.fontMono,color:r.accent},children:u.match[1]},i++));break;case"link":n.push(t.jsx("a",{href:u.match[2],target:"_blank",rel:"noopener noreferrer",style:{color:r.accent,textDecoration:"underline"},children:u.match[1]},i++));break}o=o.slice(p+u.match[0].length)}return t.jsx(t.Fragment,{children:n})}function Ut({value:e,onChange:r,onRun:n,themeMode:o}){const i=S[o],[l,s]=f.useState(!1),a=f.useRef(null);f.useEffect(()=>{if(l&&a.current){a.current.focus();const u=a.current;u.style.height="auto",u.style.height=`${Math.max(u.scrollHeight,80)}px`}},[l]);const c=()=>{s(!1)},x=u=>{if(u.key==="Escape"&&s(!1),u.key==="Enter"&&u.shiftKey&&(u.preventDefault(),s(!1),n==null||n()),u.key==="Tab"){u.preventDefault();const p=u.currentTarget,m=p.selectionStart,g=p.selectionEnd,h=e.slice(0,m)+" "+e.slice(g);r(h),requestAnimationFrame(()=>{p.selectionStart=p.selectionEnd=m+2})}},d=u=>{r(u.target.value);const p=u.target;p.style.height="auto",p.style.height=`${Math.max(p.scrollHeight,80)}px`};return l?t.jsx("textarea",{ref:a,value:e,onChange:d,onBlur:c,onKeyDown:x,placeholder:"Write markdown here...",spellCheck:!1,style:{display:"block",width:"100%",minHeight:80,padding:"12px 16px",background:i.editorBg,color:i.textPrimary,border:"none",outline:"none",resize:"none",fontFamily:i.fontMono,fontSize:13,lineHeight:"20px",borderRadius:0,caretColor:i.accent}}):e.trim()?t.jsx("div",{onDoubleClick:()=>s(!0),title:"Double-click to edit",style:{padding:"12px 16px",cursor:"text",minHeight:48},children:qt(e,i)}):t.jsx("div",{onDoubleClick:()=>s(!0),style:{padding:"12px 16px",color:i.textMuted,fontFamily:i.font,fontSize:13,fontStyle:"italic",cursor:"text",minHeight:48,display:"flex",alignItems:"center"},children:"Double-click to add markdown..."})}function Gt({cell:e,themeMode:r}){const{dispatch:n}=w(),o=S[r],[i,l]=f.useState(!1),s=e.paramConfig??{paramType:"text",label:"Parameter",defaultValue:"",options:[]},a=e.paramValue??s.defaultValue,c=p=>{n({type:"UPDATE_CELL",id:e.id,updates:{paramConfig:{...s,...p}}})},x=p=>{n({type:"SET_PARAM_VALUE",id:e.id,value:p})},d=(s.options??[]).map(p=>p.trim()).filter(Boolean),u=e.name?`{{${e.name}}}`:null;return t.jsxs("div",{style:{background:o.cellBg,border:`1px solid ${o.cellBorder}`,borderLeft:"3px solid #e3b341",borderRadius:8,overflow:"hidden"},children:[i&&t.jsxs("div",{style:{background:o.tableHeaderBg,borderBottom:`1px solid ${o.cellBorder}`,padding:"12px 14px",display:"flex",flexDirection:"column",gap:10},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:2},children:[t.jsx("span",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.06em",color:"#e3b341",fontFamily:o.fontMono,textTransform:"uppercase"},children:"Configure Parameter"}),t.jsx("button",{onClick:()=>l(!1),title:"Done",style:{background:"#e3b341",border:"none",borderRadius:5,cursor:"pointer",color:"#000",fontSize:11,fontWeight:700,fontFamily:o.font,padding:"3px 10px",display:"flex",alignItems:"center",gap:4},children:"✓ Done"})]}),t.jsxs("div",{style:{display:"flex",gap:10,flexWrap:"wrap"},children:[t.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:3,flex:"1 1 120px"},children:[t.jsx("span",{style:{fontSize:10,color:o.textMuted,fontFamily:o.font},children:"Variable name"}),t.jsx("input",{value:e.name??"",onChange:p=>n({type:"UPDATE_CELL",id:e.id,updates:{name:p.target.value||void 0}}),placeholder:"e.g. start_date",style:{background:o.inputBg,border:`1px solid ${o.inputBorder}`,borderRadius:4,color:o.textPrimary,fontSize:12,fontFamily:o.fontMono,padding:"4px 7px",outline:"none"}})]}),t.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:3,flex:"1 1 120px"},children:[t.jsx("span",{style:{fontSize:10,color:o.textMuted,fontFamily:o.font},children:"Display label"}),t.jsx("input",{value:s.label,onChange:p=>c({label:p.target.value}),placeholder:"e.g. Start Date",style:{background:o.inputBg,border:`1px solid ${o.inputBorder}`,borderRadius:4,color:o.textPrimary,fontSize:12,fontFamily:o.font,padding:"4px 7px",outline:"none"}})]}),t.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:3,flex:"1 1 100px"},children:[t.jsx("span",{style:{fontSize:10,color:o.textMuted,fontFamily:o.font},children:"Type"}),t.jsxs("select",{value:s.paramType,onChange:p=>c({paramType:p.target.value}),style:{background:o.inputBg,border:`1px solid ${o.inputBorder}`,borderRadius:4,color:o.textPrimary,fontSize:12,fontFamily:o.font,padding:"4px 7px",outline:"none"},children:[t.jsx("option",{value:"text",children:"Text"}),t.jsx("option",{value:"number",children:"Number"}),t.jsx("option",{value:"date",children:"Date"}),t.jsx("option",{value:"select",children:"Select"})]})]}),t.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:3,flex:"1 1 120px"},children:[t.jsx("span",{style:{fontSize:10,color:o.textMuted,fontFamily:o.font},children:"Default value"}),t.jsx("input",{type:s.paramType==="number"?"number":s.paramType==="date"?"date":"text",value:s.defaultValue,onChange:p=>c({defaultValue:p.target.value}),style:{background:o.inputBg,border:`1px solid ${o.inputBorder}`,borderRadius:4,color:o.textPrimary,fontSize:12,fontFamily:o.font,padding:"4px 7px",outline:"none"}})]})]}),s.paramType==="select"&&t.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:3},children:[t.jsx("span",{style:{fontSize:10,color:o.textMuted,fontFamily:o.font},children:"Options (one per line)"}),t.jsx("textarea",{value:(s.options??[]).join(`
121
+ `)},i)),i++;continue}if(/^[-*+]\s/.test(l)){const a=[];for(;i<n.length&&/^[-*+]\s/.test(n[i]);)a.push(n[i].replace(/^[-*+]\s/,"")),i++;o.push(t.jsx("ul",{style:{paddingLeft:20,marginBottom:8,color:r.textSecondary},children:a.map((c,x)=>t.jsx("li",{style:{fontSize:14,fontFamily:r.font,lineHeight:1.6,marginBottom:2},children:W(c,r)},x))},i));continue}if(/^\d+\.\s/.test(l)){const a=[];for(;i<n.length&&/^\d+\.\s/.test(n[i]);)a.push(n[i].replace(/^\d+\.\s/,"")),i++;o.push(t.jsx("ol",{style:{paddingLeft:20,marginBottom:8,color:r.textSecondary},children:a.map((c,x)=>t.jsx("li",{style:{fontSize:14,fontFamily:r.font,lineHeight:1.6,marginBottom:2},children:W(c,r)},x))},i));continue}if(!l.trim()){o.push(t.jsx("div",{style:{height:8}},i)),i++;continue}o.push(t.jsx("p",{style:{fontSize:14,lineHeight:1.7,fontFamily:r.fontSerif,color:r.textSecondary,marginBottom:6},children:W(l,r)},i)),i++}return o}function W(e,r){const n=[];let o=e,i=0;for(;o.length>0;){const l=o.match(/\*{3}(.+?)\*{3}/),s=o.match(/\*{2}(.+?)\*{2}/),a=o.match(/\*(.+?)\*/),c=o.match(/`(.+?)`/),x=o.match(/\[(.+?)\]\((.+?)\)/),d=[l?{match:l,type:"boldItalic"}:null,s?{match:s,type:"bold"}:null,a?{match:a,type:"italic"}:null,c?{match:c,type:"code"}:null,x?{match:x,type:"link"}:null].filter(Boolean);if(d.length===0){n.push(t.jsx(U.Fragment,{children:o},i++));break}const u=d.reduce((m,h)=>(m.match.index??0)<(h.match.index??0)?m:h),p=u.match.index??0;switch(p>0&&n.push(t.jsx(U.Fragment,{children:o.slice(0,p)},i++)),u.type){case"boldItalic":n.push(t.jsx("strong",{style:{fontStyle:"italic"},children:u.match[1]},i++));break;case"bold":n.push(t.jsx("strong",{children:u.match[1]},i++));break;case"italic":n.push(t.jsx("em",{children:u.match[1]},i++));break;case"code":n.push(t.jsx("code",{style:{background:r.editorBg,border:`1px solid ${r.cellBorder}`,borderRadius:4,padding:"1px 5px",fontSize:"0.9em",fontFamily:r.fontMono,color:r.accent},children:u.match[1]},i++));break;case"link":n.push(t.jsx("a",{href:u.match[2],target:"_blank",rel:"noopener noreferrer",style:{color:r.accent,textDecoration:"underline"},children:u.match[1]},i++));break}o=o.slice(p+u.match[0].length)}return t.jsx(t.Fragment,{children:n})}function Yt({value:e,onChange:r,onRun:n,themeMode:o}){const i=j[o],[l,s]=f.useState(!1),a=f.useRef(null);f.useEffect(()=>{if(l&&a.current){a.current.focus();const u=a.current;u.style.height="auto",u.style.height=`${Math.max(u.scrollHeight,80)}px`}},[l]);const c=()=>{s(!1)},x=u=>{if(u.key==="Escape"&&s(!1),u.key==="Enter"&&u.shiftKey&&(u.preventDefault(),s(!1),n==null||n()),u.key==="Tab"){u.preventDefault();const p=u.currentTarget,m=p.selectionStart,h=p.selectionEnd,g=e.slice(0,m)+" "+e.slice(h);r(g),requestAnimationFrame(()=>{p.selectionStart=p.selectionEnd=m+2})}},d=u=>{r(u.target.value);const p=u.target;p.style.height="auto",p.style.height=`${Math.max(p.scrollHeight,80)}px`};return l?t.jsx("textarea",{ref:a,value:e,onChange:d,onBlur:c,onKeyDown:x,placeholder:"Write markdown here...",spellCheck:!1,style:{display:"block",width:"100%",minHeight:80,padding:"12px 16px",background:i.editorBg,color:i.textPrimary,border:"none",outline:"none",resize:"none",fontFamily:i.fontMono,fontSize:13,lineHeight:"20px",borderRadius:0,caretColor:i.accent}}):e.trim()?t.jsx("div",{onDoubleClick:()=>s(!0),title:"Double-click to edit",style:{padding:"12px 16px",cursor:"text",minHeight:48},children:Kt(e,i)}):t.jsx("div",{onDoubleClick:()=>s(!0),style:{padding:"12px 16px",color:i.textMuted,fontFamily:i.font,fontSize:13,fontStyle:"italic",cursor:"text",minHeight:48,display:"flex",alignItems:"center"},children:"Double-click to add markdown..."})}function Jt({cell:e,themeMode:r}){const{dispatch:n}=w(),o=j[r],[i,l]=f.useState(!1),s=e.paramConfig??{paramType:"text",label:"Parameter",defaultValue:"",options:[]},a=e.paramValue??s.defaultValue,c=p=>{n({type:"UPDATE_CELL",id:e.id,updates:{paramConfig:{...s,...p}}})},x=p=>{n({type:"SET_PARAM_VALUE",id:e.id,value:p})},d=(s.options??[]).map(p=>p.trim()).filter(Boolean),u=e.name?`{{${e.name}}}`:null;return t.jsxs("div",{style:{background:o.cellBg,border:`1px solid ${o.cellBorder}`,borderLeft:"3px solid #e3b341",borderRadius:8,overflow:"hidden"},children:[i&&t.jsxs("div",{style:{background:o.tableHeaderBg,borderBottom:`1px solid ${o.cellBorder}`,padding:"12px 14px",display:"flex",flexDirection:"column",gap:10},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:2},children:[t.jsx("span",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.06em",color:"#e3b341",fontFamily:o.fontMono,textTransform:"uppercase"},children:"Configure Parameter"}),t.jsx("button",{onClick:()=>l(!1),title:"Done",style:{background:"#e3b341",border:"none",borderRadius:5,cursor:"pointer",color:"#000",fontSize:11,fontWeight:700,fontFamily:o.font,padding:"3px 10px",display:"flex",alignItems:"center",gap:4},children:"✓ Done"})]}),t.jsxs("div",{style:{display:"flex",gap:10,flexWrap:"wrap"},children:[t.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:3,flex:"1 1 120px"},children:[t.jsx("span",{style:{fontSize:10,color:o.textMuted,fontFamily:o.font},children:"Variable name"}),t.jsx("input",{value:e.name??"",onChange:p=>n({type:"UPDATE_CELL",id:e.id,updates:{name:p.target.value||void 0}}),placeholder:"e.g. start_date",style:{background:o.inputBg,border:`1px solid ${o.inputBorder}`,borderRadius:4,color:o.textPrimary,fontSize:12,fontFamily:o.fontMono,padding:"4px 7px",outline:"none"}})]}),t.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:3,flex:"1 1 120px"},children:[t.jsx("span",{style:{fontSize:10,color:o.textMuted,fontFamily:o.font},children:"Display label"}),t.jsx("input",{value:s.label,onChange:p=>c({label:p.target.value}),placeholder:"e.g. Start Date",style:{background:o.inputBg,border:`1px solid ${o.inputBorder}`,borderRadius:4,color:o.textPrimary,fontSize:12,fontFamily:o.font,padding:"4px 7px",outline:"none"}})]}),t.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:3,flex:"1 1 100px"},children:[t.jsx("span",{style:{fontSize:10,color:o.textMuted,fontFamily:o.font},children:"Type"}),t.jsxs("select",{value:s.paramType,onChange:p=>c({paramType:p.target.value}),style:{background:o.inputBg,border:`1px solid ${o.inputBorder}`,borderRadius:4,color:o.textPrimary,fontSize:12,fontFamily:o.font,padding:"4px 7px",outline:"none"},children:[t.jsx("option",{value:"text",children:"Text"}),t.jsx("option",{value:"number",children:"Number"}),t.jsx("option",{value:"date",children:"Date"}),t.jsx("option",{value:"select",children:"Select"})]})]}),t.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:3,flex:"1 1 120px"},children:[t.jsx("span",{style:{fontSize:10,color:o.textMuted,fontFamily:o.font},children:"Default value"}),t.jsx("input",{type:s.paramType==="number"?"number":s.paramType==="date"?"date":"text",value:s.defaultValue,onChange:p=>c({defaultValue:p.target.value}),style:{background:o.inputBg,border:`1px solid ${o.inputBorder}`,borderRadius:4,color:o.textPrimary,fontSize:12,fontFamily:o.font,padding:"4px 7px",outline:"none"}})]})]}),s.paramType==="select"&&t.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:3},children:[t.jsx("span",{style:{fontSize:10,color:o.textMuted,fontFamily:o.font},children:"Options (one per line)"}),t.jsx("textarea",{value:(s.options??[]).join(`
107
122
  `),onChange:p=>c({options:p.target.value.split(`
108
123
  `)}),rows:4,placeholder:`Option A
109
124
  Option B
110
- Option C`,style:{background:o.inputBg,border:`1px solid ${o.inputBorder}`,borderRadius:4,color:o.textPrimary,fontSize:12,fontFamily:o.fontMono,padding:"5px 7px",outline:"none",resize:"vertical"}})]})]}),t.jsxs("div",{style:{padding:"12px 14px",display:"flex",alignItems:"center",gap:12,flexWrap:"wrap"},children:[t.jsx("button",{onClick:()=>l(p=>!p),title:i?"Close config":"Configure parameter",style:{background:i?"#e3b34118":"transparent",border:`1px solid ${i?"#e3b341":o.cellBorder}`,borderRadius:5,cursor:"pointer",color:i?"#e3b341":o.textMuted,width:26,height:26,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"all 0.15s"},children:i?t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.749.749 0 1 1 1.06-1.06L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"})}):t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M8 0a8.2 8.2 0 0 1 .701.031C9.444.095 9.99.645 10.16 1.29l.288 1.107c.018.066.079.158.212.224.231.114.454.243.668.386.123.082.233.09.299.071l1.103-.303c.644-.176 1.392.021 1.82.63.27.385.506.792.704 1.218.315.675.111 1.422-.364 1.891l-.814.806c-.049.048-.098.147-.088.294.016.257.016.515 0 .772-.01.147.038.246.088.294l.814.806c.475.469.679 1.216.364 1.891a7.977 7.977 0 0 1-.704 1.217c-.428.61-1.176.807-1.82.63l-1.102-.302c-.067-.019-.177-.011-.3.071a5.909 5.909 0 0 1-.668.386c-.133.066-.194.158-.211.224l-.29 1.106c-.168.646-.715 1.196-1.458 1.26a8.006 8.006 0 0 1-1.402 0c-.743-.064-1.289-.614-1.458-1.26l-.289-1.106c-.018-.066-.079-.158-.212-.224a5.738 5.738 0 0 1-.668-.386c-.123-.082-.233-.09-.299-.071l-1.103.303c-.644.176-1.392-.021-1.82-.63a8.12 8.12 0 0 1-.704-1.218c-.315-.675-.111-1.422.363-1.891l.815-.806c.05-.048.098-.147.088-.294a6.214 6.214 0 0 1 0-.772c.01-.147-.038-.246-.088-.294l-.815-.806C.635 6.045.431 5.298.746 4.623a7.92 7.92 0 0 1 .704-1.217c.428-.61 1.176-.807 1.82-.63l1.102.302c.067.019.177.011.3-.071.214-.143.437-.272.668-.386.133-.066.194-.158.211-.224l.29-1.106C6.009.645 6.556.095 7.299.03 7.53.01 7.764 0 8 0Zm-.571 1.525c-.036.003-.108.036-.137.146l-.289 1.105c-.147.561-.549.967-.998 1.189-.173.086-.34.183-.5.29-.417.278-.97.423-1.529.27l-1.103-.303c-.109-.03-.175.016-.195.045-.22.312-.412.644-.573.99-.014.031-.021.11.059.19l.815.806c.411.406.562.957.53 1.456a4.709 4.709 0 0 0 0 .582c.032.499-.119 1.05-.53 1.456l-.815.806c-.081.08-.073.159-.059.19.162.346.353.677.573.989.02.03.085.076.195.046l1.102-.303c.56-.153 1.113-.008 1.53.27.161.107.328.204.501.29.447.222.85.629.997 1.189l.289 1.105c.029.109.101.143.137.146a6.6 6.6 0 0 0 1.142 0c.036-.003.108-.036.137-.146l.289-1.105c.147-.561.549-.967.998-1.189.173-.086.34-.183.5-.29.417-.278.97-.423 1.529-.27l1.103.303c.109.029.175-.016.195-.045.22-.313.411-.644.573-.99.014-.031.021-.11-.059-.19l-.815-.806c-.411-.406-.562-.957-.53-1.456a4.709 4.709 0 0 0 0-.582c-.032-.499.119-1.05.53-1.456l.815-.806c.081-.08.073-.159.059-.19a6.464 6.464 0 0 0-.573-.989c-.02-.03-.085-.076-.195-.046l-1.102.303c-.56.153-1.113.008-1.53-.27a4.44 4.44 0 0 0-.501-.29c-.447-.222-.85-.629-.997-1.189l-.289-1.105c-.029-.11-.101-.143-.137-.146a6.6 6.6 0 0 0-1.142 0ZM8 5.5a2.5 2.5 0 1 1 0 5 2.5 2.5 0 0 1 0-5ZM8 7a1 1 0 1 0 0 2 1 1 0 0 0 0-2Z"})})}),t.jsx("span",{style:{fontSize:13,fontWeight:500,fontFamily:o.font,color:o.textSecondary,flexShrink:0},children:s.label}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:3},children:[s.paramType==="select"?t.jsx("select",{value:a,onChange:p=>x(p.target.value),style:{background:o.inputBg,border:`1px solid ${o.inputBorder}`,borderRadius:5,color:o.textPrimary,fontSize:13,fontFamily:o.font,padding:"5px 10px",outline:"none",minWidth:160},children:d.length===0?t.jsx("option",{value:"",children:"— no options configured —"}):d.map(p=>t.jsx("option",{value:p,children:p},p))}):t.jsx("input",{type:s.paramType,value:a,onChange:p=>x(p.target.value),style:{background:o.inputBg,border:`1px solid ${o.inputBorder}`,borderRadius:5,color:o.textPrimary,fontSize:13,fontFamily:s.paramType==="number"?o.fontMono:o.font,padding:"5px 10px",outline:"none",minWidth:160}}),u&&t.jsx("span",{style:{fontSize:10,fontFamily:o.fontMono,color:"#e3b341",opacity:.8},children:u})]}),a&&t.jsx("span",{style:{fontSize:12,fontFamily:o.fontMono,color:o.textPrimary,background:"#e3b34118",border:"1px solid #e3b34140",borderRadius:4,padding:"2px 8px",flexShrink:0},children:a})]})]})}const Y=500;function Kt(e){return typeof e=="number"?!0:typeof e=="string"?!isNaN(Number(e))&&e.trim()!=="":!1}function Qt(e){return e==null?"":typeof e=="object"?JSON.stringify(e):String(e)}function ve({result:e,themeMode:r}){const n=S[r],[o,i]=f.useState(null),l=e.rows.slice(0,Y),s=e.rows.length>Y;return e.columns.length===0?t.jsx("div",{style:{padding:"12px 16px",color:n.textMuted,fontSize:12,fontFamily:n.font,fontStyle:"italic"},children:"Query executed successfully. No columns to display."}):t.jsxs("div",{style:{maxHeight:400,overflow:"auto",position:"relative"},children:[t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",tableLayout:"auto",fontSize:12,fontFamily:n.fontMono},children:[t.jsx("thead",{children:t.jsx("tr",{children:e.columns.map(a=>t.jsx("th",{style:{background:n.tableHeaderBg,color:n.textSecondary,fontWeight:600,fontSize:11,textAlign:"left",padding:"6px 12px",borderBottom:`1px solid ${n.tableBorder}`,borderRight:`1px solid ${n.tableBorder}`,minWidth:80,maxWidth:300,whiteSpace:"nowrap",position:"sticky",top:0,zIndex:1,fontFamily:n.font,letterSpacing:"0.03em",overflow:"hidden",textOverflow:"ellipsis"},children:a},a))})}),t.jsx("tbody",{children:l.map((a,c)=>t.jsx("tr",{onMouseEnter:()=>i(c),onMouseLeave:()=>i(null),style:{background:o===c?n.tableRowHover:"transparent",transition:"background 0.1s"},children:e.columns.map(x=>{const d=a[x],u=d==null,p=Kt(d);return t.jsx("td",{style:{padding:"5px 12px",borderBottom:`1px solid ${n.tableBorder}`,borderRight:`1px solid ${n.tableBorder}`,color:u?n.textMuted:n.textPrimary,fontStyle:u?"italic":"normal",textAlign:p?"right":"left",whiteSpace:"nowrap",maxWidth:300,overflow:"hidden",textOverflow:"ellipsis"},children:u?"—":Qt(d)},x)})},c))})]}),s&&t.jsxs("div",{style:{padding:"8px 12px",color:n.textMuted,fontSize:11,fontFamily:n.font,borderTop:`1px solid ${n.tableBorder}`,background:n.tableHeaderBg,fontStyle:"italic"},children:["Showing ",Y.toLocaleString()," of ",e.rows.length.toLocaleString()," rows"]})]})}const Yt=/date|time|at|day|month|year/i,Se=/^(label|name|category)$/i,je=/^(value|count|total|revenue|amount)$/i;function fe(e){return typeof e=="number"?!0:typeof e=="string"?e.trim()!==""&&!isNaN(Number(e)):!1}function Jt(e){return typeof e=="string"||typeof e=="number"}function te(e){const{columns:r,rows:n}=e;if(r.length<2||n.length===0)return"table";const o=r[0],i=r[1],l=n.slice(0,5),s=l.every(d=>fe(d[i])),a=l.every(d=>Jt(d[o]));if(Yt.test(o)&&s&&a)return"line";const c=r.find(d=>Se.test(d)),x=r.find(d=>je.test(d));return c&&x&&l.every(u=>fe(u[x]))||r.length===2&&a&&s?"bar":"table"}function ne(e){return Math.abs(e)>=1e6?`${(e/1e6).toFixed(1)}M`:Math.abs(e)>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString(void 0,{maximumFractionDigits:2})}const J=20;function Xt({result:e,themeMode:r}){const n=S[r],[o,i]=f.useState(null),l=e.columns.find(y=>Se.test(y))??e.columns[0],s=e.columns.find(y=>je.test(y))??e.columns[1],a=e.rows.slice(0,J).map(y=>({label:String(y[l]??""),value:Number(y[s]??0)})),c=e.rows.length>J,x=Math.max(...a.map(y=>y.value),1),d=28,u=120,p=60,m=6,g=12,h=a.length*(d+m)+g*2;return t.jsxs("div",{style:{padding:"8px 0"},children:[t.jsx("svg",{width:"100%",height:h,style:{display:"block",overflow:"visible"},viewBox:`0 0 600 ${h}`,preserveAspectRatio:"xMidYMid meet",children:a.map((y,C)=>{const E=g+C*(d+m),k=600-u-p-24,B=Math.max(y.value/x*k,2),T=o===C;return t.jsxs("g",{onMouseEnter:()=>i(C),onMouseLeave:()=>i(null),style:{cursor:"default"},children:[t.jsx("text",{x:u-8,y:E+d/2+4,textAnchor:"end",fontSize:11,fontFamily:n.font,fill:n.textSecondary,children:y.label.length>16?y.label.slice(0,15)+"…":y.label}),t.jsx("rect",{x:u,y:E,width:B,height:d,rx:3,fill:T?n.accentHover:n.accent,style:{transition:"fill 0.15s"}}),t.jsx("text",{x:u+B+6,y:E+d/2+4,textAnchor:"start",fontSize:11,fontFamily:n.fontMono,fill:n.textMuted,children:ne(y.value)})]},C)})}),c&&t.jsxs("div",{style:{fontSize:11,color:n.textMuted,fontFamily:n.font,fontStyle:"italic",padding:"4px 12px"},children:["Showing ",J," of ",e.rows.length," rows"]})]})}function en(e){const r=new Date(e);if(!isNaN(r.getTime())){if(/^\d{4}-\d{2}-\d{2}/.test(e))return r.toLocaleDateString("en-US",{month:"short",day:"numeric"});if(/^\d{4}-\d{2}$/.test(e))return r.toLocaleDateString("en-US",{year:"numeric",month:"short"})}return String(e).length>8?String(e).slice(0,8):String(e)}function tn({result:e,themeMode:r}){const n=S[r],[o,i]=f.useState(null),l=e.columns[0],s=e.columns[1],a=e.rows.map(b=>({label:String(b[l]??""),value:Number(b[s]??0)}));if(a.length<2)return null;const c=560,x=200,d=52,u=16,p=16,m=36,g=c-d-u,h=x-p-m,y=Math.min(...a.map(b=>b.value)),E=Math.max(...a.map(b=>b.value))-y||1,k=g/(a.length-1),B=b=>d+b*k,T=b=>p+h-(b-y)/E*h,D=a.map((b,j)=>({x:B(j),y:T(b.value)})),O=D.reduce((b,j,F)=>{if(F===0)return`M ${j.x},${j.y}`;const N=D[F-1],we=N.x+(j.x-N.x)/2,ke=N.y,Ee=N.x+(j.x-N.x)/2,Ce=j.y;return`${b} C ${we},${ke} ${Ee},${Ce} ${j.x},${j.y}`},""),I=`${O} L ${D[D.length-1].x},${p+h} L ${d},${p+h} Z`,_=5,v=Array.from({length:_+1},(b,j)=>{const F=y+E*j/_,N=T(F);return{val:F,y:N}}),M=Math.ceil(a.length/8),G=a.filter((b,j)=>j%M===0||j===a.length-1);return t.jsx("div",{style:{position:"relative",padding:"8px 0"},children:t.jsxs("svg",{width:"100%",height:x,viewBox:`0 0 ${c} ${x}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",overflow:"visible"},onMouseLeave:()=>i(null),children:[v.map((b,j)=>t.jsxs("g",{children:[t.jsx("line",{x1:d,y1:b.y,x2:d+g,y2:b.y,stroke:n.tableBorder,strokeWidth:.5}),t.jsx("text",{x:d-6,y:b.y+4,textAnchor:"end",fontSize:10,fontFamily:n.fontMono,fill:n.textMuted,children:ne(b.val)})]},j)),t.jsx("path",{d:I,fill:n.accent,opacity:.15}),t.jsx("path",{d:O,fill:"none",stroke:n.accent,strokeWidth:2,strokeLinejoin:"round"}),D.map((b,j)=>t.jsx("circle",{cx:b.x,cy:b.y,r:3,fill:n.accent,style:{cursor:"crosshair"},onMouseEnter:()=>i({x:b.x,y:b.y,label:a[j].label,value:a[j].value})},j)),G.map((b,j)=>{const F=a.indexOf(b);return t.jsx("text",{x:B(F),y:p+h+16,textAnchor:"middle",fontSize:10,fontFamily:n.font,fill:n.textMuted,children:en(b.label)},j)}),t.jsx("line",{x1:d,y1:p,x2:d,y2:p+h,stroke:n.tableBorder,strokeWidth:1}),t.jsx("line",{x1:d,y1:p+h,x2:d+g,y2:p+h,stroke:n.tableBorder,strokeWidth:1}),o&&t.jsxs("g",{children:[t.jsx("rect",{x:o.x+8,y:o.y-20,width:90,height:32,rx:4,fill:n.cellBg,stroke:n.cellBorder,strokeWidth:1}),t.jsx("text",{x:o.x+13,y:o.y-8,fontSize:10,fontFamily:n.font,fill:n.textSecondary,children:o.label.length>10?o.label.slice(0,10)+"…":o.label}),t.jsx("text",{x:o.x+13,y:o.y+6,fontSize:11,fontFamily:n.fontMono,fill:n.textPrimary,fontWeight:600,children:ne(o.value)})]})]})})}function nn({result:e,themeMode:r}){const n=S[r],o=te(e),[i,l]=f.useState(o!=="table"?"chart":"table"),s=o!=="table";return t.jsxs("div",{children:[s&&t.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center",padding:"4px 12px",gap:4,borderBottom:`1px solid ${n.cellBorder}`,background:`${n.tableHeaderBg}60`},children:[t.jsx("span",{style:{fontSize:10,color:n.textMuted,fontFamily:n.font,marginRight:4},children:"View:"}),["chart","table"].map(a=>t.jsx("button",{onClick:()=>l(a),style:{padding:"2px 8px",fontSize:10,fontFamily:n.font,borderRadius:4,border:`1px solid ${i===a?n.accent:n.btnBorder}`,background:i===a?`${n.accent}20`:"transparent",color:i===a?n.accent:n.textMuted,cursor:"pointer",transition:"all 0.15s",textTransform:"capitalize"},children:a==="chart"?o==="line"?"Line":"Chart":"Table"},a))]}),i==="table"||!s?t.jsx(ve,{result:e,themeMode:r}):o==="line"?t.jsx(tn,{result:e,themeMode:r}):t.jsx(Xt,{result:e,themeMode:r})]})}function on({message:e,themeMode:r}){const n=S[r];return t.jsxs("div",{style:{padding:"10px 14px",background:`${n.error}10`,borderLeft:`3px solid ${n.error}`,display:"flex",alignItems:"flex-start",gap:10},children:[t.jsx("div",{style:{flexShrink:0,marginTop:1,color:n.error},children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M4.47.22A.749.749 0 0 1 5 0h6c.199 0 .389.079.53.22l4.25 4.25c.141.14.22.331.22.53v6a.749.749 0 0 1-.22.53l-4.25 4.25A.749.749 0 0 1 11 16H5a.749.749 0 0 1-.53-.22L.22 11.53A.749.749 0 0 1 0 11V5c0-.199.079-.389.22-.53Zm.84 1.28L1.5 5.31v5.38l3.81 3.81h5.38l3.81-3.81V5.31L10.69 1.5ZM8 4a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 4Zm0 8a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"})})}),t.jsx("pre",{style:{flex:1,margin:0,fontFamily:n.fontMono,fontSize:12,color:n.error,lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:e})]})}const rn={sql:"SQL",markdown:"MD",dql:"DQL",param:"PARAM"},X={sql:"#388bfd",markdown:"#56d364",dql:"#e3b341",param:"#e3b341"};function ln(e,r){switch(e.status){case"running":return r.cellBorderRunning;case"success":return r.success;case"error":return r.error;default:return r.cellBorder}}function sn({cell:e,t:r}){let n="",o=r.textMuted;return e.status==="running"?(n="[*]",o=r.cellBorderRunning):e.status==="error"?(n="[!]",o=r.error):e.executionCount!==void 0?(n=`[${e.executionCount}]`,o=r.textMuted):(n="[ ]",o=r.textMuted),t.jsx("div",{style:{width:40,display:"flex",alignItems:"flex-start",justifyContent:"center",paddingTop:12,flexShrink:0},children:t.jsx("span",{style:{fontFamily:r.fontMono,fontSize:11,color:o,lineHeight:1.4,userSelect:"none",transition:"color 0.2s"},children:n})})}function an({cell:e,index:r}){const{state:n,dispatch:o}=w(),i=S[n.themeMode],{executeCell:l}=oe(),[s,a]=f.useState(!1),[c,x]=f.useState(!1),[d,u]=f.useState(e.name??""),[p,m]=f.useState(!0),[g,h]=f.useState("table"),y=ln(e,i),C=e.type!=="markdown"&&e.type!=="param";if(e.type==="param")return t.jsxs("div",{onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:{display:"flex",gap:0,marginBottom:2},children:[t.jsx("div",{style:{width:40,flexShrink:0}}),t.jsx("div",{style:{flex:1,minWidth:0},children:t.jsx(Gt,{cell:e,themeMode:n.themeMode})})]});f.useEffect(()=>{if(e.status==="success"&&e.result){const v=te(e.result);h(v!=="table"?"chart":"table")}},[e.status,e.result]);const E=f.useCallback(()=>{C&&l(e.id)},[e.id,l,C]),k=f.useCallback(v=>{o({type:"UPDATE_CELL",id:e.id,updates:{content:v}})},[e.id,o]),B=()=>{o({type:"DELETE_CELL",id:e.id})},T=()=>{o({type:"MOVE_CELL",id:e.id,direction:"up"})},D=()=>{o({type:"MOVE_CELL",id:e.id,direction:"down"})},O=()=>{x(!1),o({type:"UPDATE_CELL",id:e.id,updates:{name:d.trim()||void 0}})},I=(e.result||e.error)&&e.type!=="markdown",_=e.result?te(e.result)!=="table":!1;return t.jsxs("div",{onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:{display:"flex",gap:0,marginBottom:2},children:[t.jsx(sn,{cell:e,t:i}),t.jsxs("div",{style:{flex:1,minWidth:0,borderRadius:8,border:`1px solid ${s||e.status!=="idle"?y:i.cellBorder}`,borderLeft:`2px solid ${y}`,background:i.cellBg,overflow:"hidden",transition:"border-color 0.2s"},children:[t.jsxs("div",{style:{height:32,display:"flex",alignItems:"center",padding:"0 8px 0 10px",gap:8,borderBottom:`1px solid ${i.cellBorder}`,background:`${i.tableHeaderBg}80`},children:[t.jsx("span",{style:{fontSize:10,fontWeight:700,fontFamily:i.fontMono,letterSpacing:"0.08em",color:X[e.type]??i.accent,background:`${X[e.type]??i.accent}18`,border:`1px solid ${X[e.type]??i.accent}40`,borderRadius:4,padding:"1px 6px",flexShrink:0,textTransform:"uppercase"},children:rn[e.type]}),c?t.jsx("input",{autoFocus:!0,value:d,onChange:v=>u(v.target.value),onBlur:O,onKeyDown:v=>{v.key==="Enter"&&O(),v.key==="Escape"&&x(!1)},style:{background:"transparent",border:`1px solid ${i.cellBorderActive}`,borderRadius:4,color:i.textSecondary,fontSize:12,fontFamily:i.fontMono,padding:"1px 6px",outline:"none",width:140}}):e.name&&t.jsx("span",{onClick:()=>{u(e.name??""),x(!0)},title:"Click to rename",style:{color:i.textSecondary,fontSize:12,fontFamily:i.fontMono,cursor:"text",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:200},children:e.name}),t.jsx("div",{style:{flex:1}}),s&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:2},children:[!e.name&&!c&&t.jsx(Z,{title:"Name this cell",onClick:()=>{u(""),x(!0)},t:i,children:t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M11.013 1.427a1.75 1.75 0 0 1 2.474 0l1.086 1.086a1.75 1.75 0 0 1 0 2.474l-8.61 8.61c-.21.21-.47.364-.756.445l-3.251.93a.75.75 0 0 1-.927-.928l.929-3.25c.081-.286.235-.547.445-.758l8.61-8.61Zm.176 4.823L9.75 4.81l-6.286 6.287a.253.253 0 0 0-.064.108l-.558 1.953 1.953-.558a.253.253 0 0 0 .108-.064Zm1.238-3.763a.25.25 0 0 0-.354 0L10.811 3.75l1.439 1.44 1.263-1.263a.25.25 0 0 0 0-.354Z"})})}),C&&t.jsx(Z,{title:"Run cell (Shift+Enter)",onClick:E,t:i,accent:!0,children:t.jsx("svg",{width:"11",height:"11",viewBox:"0 0 10 10",fill:"currentColor",children:t.jsx("path",{d:"M1.5 1.5l7 3.5-7 3.5V1.5Z"})})}),t.jsx(Z,{title:"Move up",onClick:T,t:i,children:t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M3.47 7.78a.75.75 0 0 1 0-1.06l4.25-4.25a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1-1.06 1.06L8.75 4.81v7.44a.75.75 0 0 1-1.5 0V4.81L4.53 7.78a.75.75 0 0 1-1.06 0Z"})})}),t.jsx(Z,{title:"Move down",onClick:D,t:i,children:t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M12.53 8.22a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L2.97 9.28a.75.75 0 0 1 1.06-1.06l2.72 2.97V3.75a.75.75 0 0 1 1.5 0v7.44l2.72-2.97a.75.75 0 0 1 1.06 0Z"})})}),t.jsx(Z,{title:"Delete cell",onClick:B,t:i,danger:!0,children:t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M11 1.75V3h2.25a.75.75 0 0 1 0 1.5H2.75a.75.75 0 0 1 0-1.5H5V1.75C5 .784 5.784 0 6.75 0h2.5C10.216 0 11 .784 11 1.75ZM4.496 6.675l.66 6.6a.25.25 0 0 0 .249.225h5.19a.25.25 0 0 0 .249-.225l.66-6.6a.75.75 0 0 1 1.492.149l-.66 6.6A1.748 1.748 0 0 1 10.595 15h-5.19a1.75 1.75 0 0 1-1.741-1.575l-.66-6.6a.75.75 0 1 1 1.492-.15ZM6.5 1.75V3h3V1.75a.25.25 0 0 0-.25-.25h-2.5a.25.25 0 0 0-.25.25Z"})})})]})]}),e.type==="markdown"?t.jsx(Ut,{value:e.content,onChange:k,themeMode:n.themeMode}):t.jsx(be,{value:e.content,onChange:k,onRun:E,themeMode:n.themeMode}),I&&t.jsxs("div",{style:{borderTop:`1px solid ${i.cellBorder}`},children:[t.jsxs("div",{style:{height:28,display:"flex",alignItems:"center",padding:"0 12px",gap:10,borderBottom:e.result&&p?`1px solid ${i.cellBorder}`:"none",background:`${i.tableHeaderBg}60`},children:[e.result&&t.jsxs("span",{style:{fontSize:11,fontFamily:i.font,color:i.textMuted},children:[(e.result.rowCount??e.result.rows.length).toLocaleString()," rows",e.result.executionTime!==void 0&&t.jsxs(t.Fragment,{children:[" · ",e.result.executionTime<1e3?`${e.result.executionTime}ms`:`${(e.result.executionTime/1e3).toFixed(2)}s`]})]}),e.error&&t.jsx("span",{style:{fontSize:11,fontFamily:i.font,color:i.error},children:"Error"}),t.jsx("div",{style:{flex:1}}),e.result&&_&&p&&t.jsx("div",{style:{display:"flex",alignItems:"center",gap:3},children:["chart","table"].map(v=>t.jsx("button",{onClick:()=>h(v),style:{padding:"1px 7px",fontSize:10,fontFamily:i.font,borderRadius:3,border:`1px solid ${g===v?i.accent:i.btnBorder}`,background:g===v?`${i.accent}20`:"transparent",color:g===v?i.accent:i.textMuted,cursor:"pointer",transition:"all 0.15s",textTransform:"capitalize"},children:v==="chart"?"Chart":"Table"},v))}),t.jsxs("button",{onClick:()=>m(v=>!v),style:{background:"transparent",border:"none",cursor:"pointer",color:i.textMuted,fontSize:11,fontFamily:i.font,padding:"2px 4px",display:"flex",alignItems:"center",gap:4},children:[t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",style:{transform:p?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.15s"},children:t.jsx("path",{d:"M1 3l4 4 4-4",stroke:"currentColor",fill:"none",strokeWidth:"1.5"})}),p?"Hide":"Show"]})]}),p&&t.jsxs(t.Fragment,{children:[e.error&&t.jsx(on,{message:e.error,themeMode:n.themeMode}),e.result&&!e.error&&(g==="chart"&&_?t.jsx(nn,{result:e.result,themeMode:n.themeMode}):t.jsx(ve,{result:e.result,themeMode:n.themeMode}))]})]})]})]})}function Z({title:e,onClick:r,children:n,t:o,accent:i,danger:l}){const[s,a]=f.useState(!1);return t.jsx("button",{title:e,onClick:r,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",background:s?l?`${o.error}18`:i?`${o.accent}18`:o.btnHover:"transparent",border:"none",borderRadius:4,cursor:"pointer",color:s?l?o.error:i?o.accent:o.textSecondary:o.textMuted,transition:"all 0.15s",padding:0},children:n})}const dn=[{type:"sql",label:"SQL",color:"#388bfd"},{type:"markdown",label:"Markdown",color:"#56d364"},{type:"dql",label:"DQL",color:"#e3b341"},{type:"param",label:"Param",color:"#e3b341"}];function ee({afterId:e}){const{state:r,dispatch:n}=w(),o=S[r.themeMode],[i,l]=f.useState(!1),[s,a]=f.useState(!1),c=f.useRef(null);f.useEffect(()=>{if(!s)return;function d(u){c.current&&!c.current.contains(u.target)&&a(!1)}return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[s]);const x=d=>{const u=A(d);n({type:"ADD_CELL",cell:u,afterId:e}),a(!1)};return t.jsxs("div",{ref:c,onMouseEnter:()=>l(!0),onMouseLeave:()=>{l(!1)},style:{position:"relative",height:28,display:"flex",alignItems:"center",justifyContent:"center",cursor:"default"},children:[t.jsx("div",{style:{position:"absolute",left:0,right:0,height:1,background:i||s?o.cellBorderActive:"transparent",transition:"background 0.15s"}}),(i||s)&&t.jsxs("button",{onClick:()=>a(d=>!d),style:{position:"relative",zIndex:2,height:22,padding:"0 10px",borderRadius:11,border:`1px solid ${o.cellBorderActive}`,background:`${o.accent}18`,color:o.accent,cursor:"pointer",fontSize:12,fontFamily:o.font,fontWeight:500,display:"flex",alignItems:"center",gap:4,transition:"background 0.15s"},children:[t.jsx("span",{style:{fontSize:14,lineHeight:1,marginTop:-1},children:"+"}),"Add cell"]}),s&&t.jsx("div",{style:{position:"absolute",top:26,left:"50%",transform:"translateX(-50%)",zIndex:100,background:o.modalBg,border:`1px solid ${o.cellBorder}`,borderRadius:8,boxShadow:"0 8px 24px rgba(0,0,0,0.3)",padding:4,display:"flex",gap:4},children:dn.map(({type:d,label:u,color:p})=>t.jsx(cn,{label:u,color:p,onClick:()=>x(d),t:o},d))})]})}function cn({label:e,color:r,onClick:n,t:o}){const[i,l]=f.useState(!1);return t.jsx("button",{onClick:n,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{background:i?`${r}18`:"transparent",border:`1px solid ${i?r:o.cellBorder}`,borderRadius:6,cursor:"pointer",color:i?r:o.textSecondary,fontSize:11,fontFamily:o.fontMono,fontWeight:600,padding:"4px 10px",letterSpacing:"0.04em",transition:"all 0.15s",whiteSpace:"nowrap"},children:e})}function un({registerCellRef:e}){const{state:r,dispatch:n}=w(),{executeCell:o}=oe(),i=S[r.themeMode],[l,s]=f.useState(null),a=f.useRef(0);return f.useCallback(c=>{s(c)},[]),f.useEffect(()=>{function c(x){var m;if(!l)return;const d=x.target;if(d.tagName==="TEXTAREA"||d.tagName==="INPUT"||d.isContentEditable||d.closest(".cm-editor")){s(null);return}const u=r.cells,p=u.findIndex(g=>g.id===l);if(p!==-1)switch(x.key){case"a":{x.preventDefault();const g=A("sql");if(p===0)n({type:"ADD_CELL",cell:g,afterId:u[0].id}),n({type:"MOVE_CELL",id:g.id,direction:"up"});else{const h=u[p-1].id;n({type:"ADD_CELL",cell:g,afterId:h})}s(g.id);break}case"b":{x.preventDefault();const g=A("sql");n({type:"ADD_CELL",cell:g,afterId:l}),s(g.id);break}case"d":{x.preventDefault();const g=Date.now();if(g-a.current<=500){if(n({type:"DELETE_CELL",id:l}),u.length>1){const h=p>0?p-1:1;s(((m=u[h])==null?void 0:m.id)??null)}else s(null);a.current=0}else a.current=g;break}case"Enter":{if(x.shiftKey){x.preventDefault();const g=u[p];g&&g.type!=="markdown"&&o(g.id)}break}}}return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[l,r.cells,n,o]),f.useEffect(()=>{function c(x){x.target.closest("[data-cell-id]")||s(null)}return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[]),r.cells.length===0?t.jsxs("div",{style:{maxWidth:860,margin:"0 auto",padding:"0 24px",display:"flex",flexDirection:"column"},children:[t.jsx(ee,{}),t.jsx(pn,{t:i})]}):t.jsxs("div",{style:{maxWidth:860,margin:"0 auto",padding:"0 24px",display:"flex",flexDirection:"column"},children:[t.jsx(ee,{afterId:void 0}),r.cells.map((c,x)=>t.jsxs(U.Fragment,{children:[t.jsx("div",{ref:d=>e(c.id,d),"data-cell-id":c.id,onClick:d=>{const u=d.target;!u.closest(".cm-editor")&&!u.closest("textarea")&&!u.closest("input")&&s(c.id)},style:{outline:l===c.id?`2px solid ${i.accent}40`:"none",outlineOffset:2,borderRadius:10,transition:"outline 0.1s"},children:t.jsx(an,{cell:c,index:x})}),t.jsx(ee,{afterId:c.id})]},c.id))]})}function pn({t:e}){return t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"48px 0",gap:12,color:e.textMuted},children:[t.jsx("svg",{width:"40",height:"40",viewBox:"0 0 16 16",fill:"currentColor",style:{opacity:.3},children:t.jsx("path",{d:"M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 8.75 4.25V1.5ZM8.75 5.5h2.836L10.25 3.664V4.25c0 .138.112.25.25.25H8.75Z"})}),t.jsx("span",{style:{fontSize:13,fontFamily:e.font},children:"Empty notebook. Click + to add your first cell."})]})}function fn({onOpenFile:e,registerCellRef:r}){const{state:n}=w(),o=S[n.themeMode];return n.activeFile?t.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",background:o.appBg},children:[t.jsx(xn,{t:o}),t.jsx("div",{style:{flex:1,overflow:"auto",padding:"24px 0 40px"},children:t.jsx(un,{registerCellRef:r})})]}):t.jsx(It,{onOpenFile:e})}function xn({t:e}){const{state:r}=w(),n=r.cells.length;return t.jsxs("div",{style:{height:32,flexShrink:0,borderBottom:`1px solid ${e.headerBorder}`,background:e.cellBg,display:"flex",alignItems:"center",padding:"0 16px",gap:12},children:[t.jsx(hn,{t:e}),t.jsx("div",{style:{flex:1}}),t.jsxs("span",{style:{fontSize:11,color:e.textMuted,fontFamily:e.font,display:"flex",alignItems:"center",gap:12},children:[t.jsxs("span",{children:[n," ",n===1?"cell":"cells"]}),r.notebookDirty&&t.jsx("span",{style:{color:e.warning},children:"● unsaved"})]})]})}function hn({t:e}){const{state:r}=w();if(!r.activeFile)return null;const n=r.activeFile.path.split("/").filter(Boolean);return t.jsx("div",{style:{display:"flex",alignItems:"center",gap:4,fontSize:12,fontFamily:e.fontMono,color:e.textMuted,overflow:"hidden"},children:n.map((o,i)=>t.jsxs(U.Fragment,{children:[i>0&&t.jsx("span",{style:{color:e.textMuted,opacity:.5},children:"/"}),t.jsx("span",{style:{color:i===n.length-1?e.textSecondary:e.textMuted,fontWeight:i===n.length-1?500:400,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:i===n.length-1?200:100},children:o})]},i))})}const xe={blank:"Blank",revenue:"Revenue Analysis",pipeline:"Pipeline Health"},gn={blank:"Start with an empty notebook.",revenue:"Pre-built queries for revenue metrics and trends.",pipeline:"Templates for data pipeline health monitoring."};function he(e){return e.toLowerCase().replace(/[^a-z0-9\-_\s]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").slice(0,64)}function mn(e){return e.trim()?/^[a-zA-Z0-9\-_ ]+$/.test(e)?null:"Only letters, numbers, hyphens, underscores, and spaces allowed.":"Name is required."}function yn(e){switch(e){case"revenue":return[A("markdown",`# Revenue Analysis
125
+ Option C`,style:{background:o.inputBg,border:`1px solid ${o.inputBorder}`,borderRadius:4,color:o.textPrimary,fontSize:12,fontFamily:o.fontMono,padding:"5px 7px",outline:"none",resize:"vertical"}})]})]}),t.jsxs("div",{style:{padding:"12px 14px",display:"flex",alignItems:"center",gap:12,flexWrap:"wrap"},children:[t.jsx("button",{onClick:()=>l(p=>!p),title:i?"Close config":"Configure parameter",style:{background:i?"#e3b34118":"transparent",border:`1px solid ${i?"#e3b341":o.cellBorder}`,borderRadius:5,cursor:"pointer",color:i?"#e3b341":o.textMuted,width:26,height:26,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"all 0.15s"},children:i?t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.749.749 0 1 1 1.06-1.06L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"})}):t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M8 0a8.2 8.2 0 0 1 .701.031C9.444.095 9.99.645 10.16 1.29l.288 1.107c.018.066.079.158.212.224.231.114.454.243.668.386.123.082.233.09.299.071l1.103-.303c.644-.176 1.392.021 1.82.63.27.385.506.792.704 1.218.315.675.111 1.422-.364 1.891l-.814.806c-.049.048-.098.147-.088.294.016.257.016.515 0 .772-.01.147.038.246.088.294l.814.806c.475.469.679 1.216.364 1.891a7.977 7.977 0 0 1-.704 1.217c-.428.61-1.176.807-1.82.63l-1.102-.302c-.067-.019-.177-.011-.3.071a5.909 5.909 0 0 1-.668.386c-.133.066-.194.158-.211.224l-.29 1.106c-.168.646-.715 1.196-1.458 1.26a8.006 8.006 0 0 1-1.402 0c-.743-.064-1.289-.614-1.458-1.26l-.289-1.106c-.018-.066-.079-.158-.212-.224a5.738 5.738 0 0 1-.668-.386c-.123-.082-.233-.09-.299-.071l-1.103.303c-.644.176-1.392-.021-1.82-.63a8.12 8.12 0 0 1-.704-1.218c-.315-.675-.111-1.422.363-1.891l.815-.806c.05-.048.098-.147.088-.294a6.214 6.214 0 0 1 0-.772c.01-.147-.038-.246-.088-.294l-.815-.806C.635 6.045.431 5.298.746 4.623a7.92 7.92 0 0 1 .704-1.217c.428-.61 1.176-.807 1.82-.63l1.102.302c.067.019.177.011.3-.071.214-.143.437-.272.668-.386.133-.066.194-.158.211-.224l.29-1.106C6.009.645 6.556.095 7.299.03 7.53.01 7.764 0 8 0Zm-.571 1.525c-.036.003-.108.036-.137.146l-.289 1.105c-.147.561-.549.967-.998 1.189-.173.086-.34.183-.5.29-.417.278-.97.423-1.529.27l-1.103-.303c-.109-.03-.175.016-.195.045-.22.312-.412.644-.573.99-.014.031-.021.11.059.19l.815.806c.411.406.562.957.53 1.456a4.709 4.709 0 0 0 0 .582c.032.499-.119 1.05-.53 1.456l-.815.806c-.081.08-.073.159-.059.19.162.346.353.677.573.989.02.03.085.076.195.046l1.102-.303c.56-.153 1.113-.008 1.53.27.161.107.328.204.501.29.447.222.85.629.997 1.189l.289 1.105c.029.109.101.143.137.146a6.6 6.6 0 0 0 1.142 0c.036-.003.108-.036.137-.146l.289-1.105c.147-.561.549-.967.998-1.189.173-.086.34-.183.5-.29.417-.278.97-.423 1.529-.27l1.103.303c.109.029.175-.016.195-.045.22-.313.411-.644.573-.99.014-.031.021-.11-.059-.19l-.815-.806c-.411-.406-.562-.957-.53-1.456a4.709 4.709 0 0 0 0-.582c-.032-.499.119-1.05.53-1.456l.815-.806c.081-.08.073-.159.059-.19a6.464 6.464 0 0 0-.573-.989c-.02-.03-.085-.076-.195-.046l-1.102.303c-.56.153-1.113.008-1.53-.27a4.44 4.44 0 0 0-.501-.29c-.447-.222-.85-.629-.997-1.189l-.289-1.105c-.029-.11-.101-.143-.137-.146a6.6 6.6 0 0 0-1.142 0ZM8 5.5a2.5 2.5 0 1 1 0 5 2.5 2.5 0 0 1 0-5ZM8 7a1 1 0 1 0 0 2 1 1 0 0 0 0-2Z"})})}),t.jsx("span",{style:{fontSize:13,fontWeight:500,fontFamily:o.font,color:o.textSecondary,flexShrink:0},children:s.label}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:3},children:[s.paramType==="select"?t.jsx("select",{value:a,onChange:p=>x(p.target.value),style:{background:o.inputBg,border:`1px solid ${o.inputBorder}`,borderRadius:5,color:o.textPrimary,fontSize:13,fontFamily:o.font,padding:"5px 10px",outline:"none",minWidth:160},children:d.length===0?t.jsx("option",{value:"",children:"— no options configured —"}):d.map(p=>t.jsx("option",{value:p,children:p},p))}):t.jsx("input",{type:s.paramType,value:a,onChange:p=>x(p.target.value),style:{background:o.inputBg,border:`1px solid ${o.inputBorder}`,borderRadius:5,color:o.textPrimary,fontSize:13,fontFamily:s.paramType==="number"?o.fontMono:o.font,padding:"5px 10px",outline:"none",minWidth:160}}),u&&t.jsx("span",{style:{fontSize:10,fontFamily:o.fontMono,color:"#e3b341",opacity:.8},children:u})]}),a&&t.jsx("span",{style:{fontSize:12,fontFamily:o.fontMono,color:o.textPrimary,background:"#e3b34118",border:"1px solid #e3b34140",borderRadius:4,padding:"2px 8px",flexShrink:0},children:a})]})]})}const Y=500;function Xt(e){return typeof e=="number"?!0:typeof e=="string"?!isNaN(Number(e))&&e.trim()!=="":!1}function en(e){return e==null?"":typeof e=="object"?JSON.stringify(e):String(e)}function ve({result:e,themeMode:r}){const n=j[r],[o,i]=f.useState(null),l=e.rows.slice(0,Y),s=e.rows.length>Y;return e.columns.length===0?t.jsx("div",{style:{padding:"12px 16px",color:n.textMuted,fontSize:12,fontFamily:n.font,fontStyle:"italic"},children:"Query executed successfully. No columns to display."}):t.jsxs("div",{style:{maxHeight:400,overflow:"auto",position:"relative"},children:[t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",tableLayout:"auto",fontSize:12,fontFamily:n.fontMono},children:[t.jsx("thead",{children:t.jsx("tr",{children:e.columns.map(a=>t.jsx("th",{style:{background:n.tableHeaderBg,color:n.textSecondary,fontWeight:600,fontSize:11,textAlign:"left",padding:"6px 12px",borderBottom:`1px solid ${n.tableBorder}`,borderRight:`1px solid ${n.tableBorder}`,minWidth:80,maxWidth:300,whiteSpace:"nowrap",position:"sticky",top:0,zIndex:1,fontFamily:n.font,letterSpacing:"0.03em",overflow:"hidden",textOverflow:"ellipsis"},children:a},a))})}),t.jsx("tbody",{children:l.map((a,c)=>t.jsx("tr",{onMouseEnter:()=>i(c),onMouseLeave:()=>i(null),style:{background:o===c?n.tableRowHover:"transparent",transition:"background 0.1s"},children:e.columns.map(x=>{const d=a[x],u=d==null,p=Xt(d);return t.jsx("td",{style:{padding:"5px 12px",borderBottom:`1px solid ${n.tableBorder}`,borderRight:`1px solid ${n.tableBorder}`,color:u?n.textMuted:n.textPrimary,fontStyle:u?"italic":"normal",textAlign:p?"right":"left",whiteSpace:"nowrap",maxWidth:300,overflow:"hidden",textOverflow:"ellipsis"},children:u?"—":en(d)},x)})},c))})]}),s&&t.jsxs("div",{style:{padding:"8px 12px",color:n.textMuted,fontSize:11,fontFamily:n.font,borderTop:`1px solid ${n.tableBorder}`,background:n.tableHeaderBg,fontStyle:"italic"},children:["Showing ",Y.toLocaleString()," of ",e.rows.length.toLocaleString()," rows"]})]})}const tn=/date|time|at|day|month|year/i,Se=/^(label|name|category)$/i,je=/^(value|count|total|revenue|amount)$/i;function fe(e){return typeof e=="number"?!0:typeof e=="string"?e.trim()!==""&&!isNaN(Number(e)):!1}function nn(e){return typeof e=="string"||typeof e=="number"}function te(e){const{columns:r,rows:n}=e;if(r.length<2||n.length===0)return"table";const o=r[0],i=r[1],l=n.slice(0,5),s=l.every(d=>fe(d[i])),a=l.every(d=>nn(d[o]));if(tn.test(o)&&s&&a)return"line";const c=r.find(d=>Se.test(d)),x=r.find(d=>je.test(d));return c&&x&&l.every(u=>fe(u[x]))||r.length===2&&a&&s?"bar":"table"}function ne(e){return Math.abs(e)>=1e6?`${(e/1e6).toFixed(1)}M`:Math.abs(e)>=1e3?`${(e/1e3).toFixed(1)}K`:e.toLocaleString(void 0,{maximumFractionDigits:2})}const J=20;function on({result:e,themeMode:r}){const n=j[r],[o,i]=f.useState(null),l=e.columns.find(y=>Se.test(y))??e.columns[0],s=e.columns.find(y=>je.test(y))??e.columns[1],a=e.rows.slice(0,J).map(y=>({label:String(y[l]??""),value:Number(y[s]??0)})),c=e.rows.length>J,x=Math.max(...a.map(y=>y.value),1),d=28,u=120,p=60,m=6,h=12,g=a.length*(d+m)+h*2;return t.jsxs("div",{style:{padding:"8px 0"},children:[t.jsx("svg",{width:"100%",height:g,style:{display:"block",overflow:"visible"},viewBox:`0 0 600 ${g}`,preserveAspectRatio:"xMidYMid meet",children:a.map((y,k)=>{const v=h+k*(d+m),E=600-u-p-24,T=Math.max(y.value/x*E,2),A=o===k;return t.jsxs("g",{onMouseEnter:()=>i(k),onMouseLeave:()=>i(null),style:{cursor:"default"},children:[t.jsx("text",{x:u-8,y:v+d/2+4,textAnchor:"end",fontSize:11,fontFamily:n.font,fill:n.textSecondary,children:y.label.length>16?y.label.slice(0,15)+"…":y.label}),t.jsx("rect",{x:u,y:v,width:T,height:d,rx:3,fill:A?n.accentHover:n.accent,style:{transition:"fill 0.15s"}}),t.jsx("text",{x:u+T+6,y:v+d/2+4,textAnchor:"start",fontSize:11,fontFamily:n.fontMono,fill:n.textMuted,children:ne(y.value)})]},k)})}),c&&t.jsxs("div",{style:{fontSize:11,color:n.textMuted,fontFamily:n.font,fontStyle:"italic",padding:"4px 12px"},children:["Showing ",J," of ",e.rows.length," rows"]})]})}function rn(e){const r=new Date(e);if(!isNaN(r.getTime())){if(/^\d{4}-\d{2}-\d{2}/.test(e))return r.toLocaleDateString("en-US",{month:"short",day:"numeric"});if(/^\d{4}-\d{2}$/.test(e))return r.toLocaleDateString("en-US",{year:"numeric",month:"short"})}return String(e).length>8?String(e).slice(0,8):String(e)}function ln({result:e,themeMode:r}){const n=j[r],[o,i]=f.useState(null),l=e.columns[0],s=e.columns[1],a=e.rows.map(b=>({label:String(b[l]??""),value:Number(b[s]??0)}));if(a.length<2)return null;const c=560,x=200,d=52,u=16,p=16,m=36,h=c-d-u,g=x-p-m,y=Math.min(...a.map(b=>b.value)),v=Math.max(...a.map(b=>b.value))-y||1,E=h/(a.length-1),T=b=>d+b*E,A=b=>p+g-(b-y)/v*g,D=a.map((b,C)=>({x:T(C),y:A(b.value)})),O=D.reduce((b,C,N)=>{if(N===0)return`M ${C.x},${C.y}`;const I=D[N-1],we=I.x+(C.x-I.x)/2,ke=I.y,Ce=I.x+(C.x-I.x)/2,Ee=C.y;return`${b} C ${we},${ke} ${Ce},${Ee} ${C.x},${C.y}`},""),z=`${O} L ${D[D.length-1].x},${p+g} L ${d},${p+g} Z`,_=5,S=Array.from({length:_+1},(b,C)=>{const N=y+v*C/_,I=A(N);return{val:N,y:I}}),M=Math.ceil(a.length/8),G=a.filter((b,C)=>C%M===0||C===a.length-1);return t.jsx("div",{style:{position:"relative",padding:"8px 0"},children:t.jsxs("svg",{width:"100%",height:x,viewBox:`0 0 ${c} ${x}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",overflow:"visible"},onMouseLeave:()=>i(null),children:[S.map((b,C)=>t.jsxs("g",{children:[t.jsx("line",{x1:d,y1:b.y,x2:d+h,y2:b.y,stroke:n.tableBorder,strokeWidth:.5}),t.jsx("text",{x:d-6,y:b.y+4,textAnchor:"end",fontSize:10,fontFamily:n.fontMono,fill:n.textMuted,children:ne(b.val)})]},C)),t.jsx("path",{d:z,fill:n.accent,opacity:.15}),t.jsx("path",{d:O,fill:"none",stroke:n.accent,strokeWidth:2,strokeLinejoin:"round"}),D.map((b,C)=>t.jsx("circle",{cx:b.x,cy:b.y,r:3,fill:n.accent,style:{cursor:"crosshair"},onMouseEnter:()=>i({x:b.x,y:b.y,label:a[C].label,value:a[C].value})},C)),G.map((b,C)=>{const N=a.indexOf(b);return t.jsx("text",{x:T(N),y:p+g+16,textAnchor:"middle",fontSize:10,fontFamily:n.font,fill:n.textMuted,children:rn(b.label)},C)}),t.jsx("line",{x1:d,y1:p,x2:d,y2:p+g,stroke:n.tableBorder,strokeWidth:1}),t.jsx("line",{x1:d,y1:p+g,x2:d+h,y2:p+g,stroke:n.tableBorder,strokeWidth:1}),o&&t.jsxs("g",{children:[t.jsx("rect",{x:o.x+8,y:o.y-20,width:90,height:32,rx:4,fill:n.cellBg,stroke:n.cellBorder,strokeWidth:1}),t.jsx("text",{x:o.x+13,y:o.y-8,fontSize:10,fontFamily:n.font,fill:n.textSecondary,children:o.label.length>10?o.label.slice(0,10)+"…":o.label}),t.jsx("text",{x:o.x+13,y:o.y+6,fontSize:11,fontFamily:n.fontMono,fill:n.textPrimary,fontWeight:600,children:ne(o.value)})]})]})})}function sn({result:e,themeMode:r}){const n=j[r],o=te(e),[i,l]=f.useState(o!=="table"?"chart":"table"),s=o!=="table";return t.jsxs("div",{children:[s&&t.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center",padding:"4px 12px",gap:4,borderBottom:`1px solid ${n.cellBorder}`,background:`${n.tableHeaderBg}60`},children:[t.jsx("span",{style:{fontSize:10,color:n.textMuted,fontFamily:n.font,marginRight:4},children:"View:"}),["chart","table"].map(a=>t.jsx("button",{onClick:()=>l(a),style:{padding:"2px 8px",fontSize:10,fontFamily:n.font,borderRadius:4,border:`1px solid ${i===a?n.accent:n.btnBorder}`,background:i===a?`${n.accent}20`:"transparent",color:i===a?n.accent:n.textMuted,cursor:"pointer",transition:"all 0.15s",textTransform:"capitalize"},children:a==="chart"?o==="line"?"Line":"Chart":"Table"},a))]}),i==="table"||!s?t.jsx(ve,{result:e,themeMode:r}):o==="line"?t.jsx(ln,{result:e,themeMode:r}):t.jsx(on,{result:e,themeMode:r})]})}function an({message:e,themeMode:r}){const n=j[r];return t.jsxs("div",{style:{padding:"10px 14px",background:`${n.error}10`,borderLeft:`3px solid ${n.error}`,display:"flex",alignItems:"flex-start",gap:10},children:[t.jsx("div",{style:{flexShrink:0,marginTop:1,color:n.error},children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M4.47.22A.749.749 0 0 1 5 0h6c.199 0 .389.079.53.22l4.25 4.25c.141.14.22.331.22.53v6a.749.749 0 0 1-.22.53l-4.25 4.25A.749.749 0 0 1 11 16H5a.749.749 0 0 1-.53-.22L.22 11.53A.749.749 0 0 1 0 11V5c0-.199.079-.389.22-.53Zm.84 1.28L1.5 5.31v5.38l3.81 3.81h5.38l3.81-3.81V5.31L10.69 1.5ZM8 4a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 4Zm0 8a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"})})}),t.jsx("pre",{style:{flex:1,margin:0,fontFamily:n.fontMono,fontSize:12,color:n.error,lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:e})]})}const dn={sql:"SQL",markdown:"MD",dql:"DQL",param:"PARAM"},X={sql:"#388bfd",markdown:"#56d364",dql:"#e3b341",param:"#e3b341"};function cn(e,r){switch(e.status){case"running":return r.cellBorderRunning;case"success":return r.success;case"error":return r.error;default:return r.cellBorder}}function un({cell:e,t:r}){let n="",o=r.textMuted;return e.status==="running"?(n="[*]",o=r.cellBorderRunning):e.status==="error"?(n="[!]",o=r.error):e.executionCount!==void 0?(n=`[${e.executionCount}]`,o=r.textMuted):(n="[ ]",o=r.textMuted),t.jsx("div",{style:{width:40,display:"flex",alignItems:"flex-start",justifyContent:"center",paddingTop:12,flexShrink:0},children:t.jsx("span",{style:{fontFamily:r.fontMono,fontSize:11,color:o,lineHeight:1.4,userSelect:"none",transition:"color 0.2s"},children:n})})}function pn({cell:e,index:r}){const{state:n,dispatch:o}=w(),i=j[n.themeMode],{executeCell:l}=oe(),[s,a]=f.useState(!1),[c,x]=f.useState(!1),[d,u]=f.useState(e.name??""),[p,m]=f.useState(!0),[h,g]=f.useState("table"),y=cn(e,i),k=e.type!=="markdown"&&e.type!=="param";if(e.type==="param")return t.jsxs("div",{onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:{display:"flex",gap:0,marginBottom:2},children:[t.jsx("div",{style:{width:40,flexShrink:0}}),t.jsx("div",{style:{flex:1,minWidth:0},children:t.jsx(Jt,{cell:e,themeMode:n.themeMode})})]});f.useEffect(()=>{if(e.status==="success"&&e.result){const S=te(e.result);g(S!=="table"?"chart":"table")}},[e.status,e.result]);const v=f.useCallback(()=>{k&&l(e.id)},[e.id,l,k]),E=f.useCallback(S=>{o({type:"UPDATE_CELL",id:e.id,updates:{content:S}})},[e.id,o]),T=()=>{o({type:"DELETE_CELL",id:e.id})},A=()=>{o({type:"MOVE_CELL",id:e.id,direction:"up"})},D=()=>{o({type:"MOVE_CELL",id:e.id,direction:"down"})},O=()=>{x(!1),o({type:"UPDATE_CELL",id:e.id,updates:{name:d.trim()||void 0}})},z=(e.result||e.error)&&e.type!=="markdown",_=e.result?te(e.result)!=="table":!1;return t.jsxs("div",{onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:{display:"flex",gap:0,marginBottom:2},children:[t.jsx(un,{cell:e,t:i}),t.jsxs("div",{style:{flex:1,minWidth:0,borderRadius:8,border:`1px solid ${s||e.status!=="idle"?y:i.cellBorder}`,borderLeft:`2px solid ${y}`,background:i.cellBg,overflow:"hidden",transition:"border-color 0.2s"},children:[t.jsxs("div",{style:{height:32,display:"flex",alignItems:"center",padding:"0 8px 0 10px",gap:8,borderBottom:`1px solid ${i.cellBorder}`,background:`${i.tableHeaderBg}80`},children:[t.jsx("span",{style:{fontSize:10,fontWeight:700,fontFamily:i.fontMono,letterSpacing:"0.08em",color:X[e.type]??i.accent,background:`${X[e.type]??i.accent}18`,border:`1px solid ${X[e.type]??i.accent}40`,borderRadius:4,padding:"1px 6px",flexShrink:0,textTransform:"uppercase"},children:dn[e.type]}),c?t.jsx("input",{autoFocus:!0,value:d,onChange:S=>u(S.target.value),onBlur:O,onKeyDown:S=>{S.key==="Enter"&&O(),S.key==="Escape"&&x(!1)},style:{background:"transparent",border:`1px solid ${i.cellBorderActive}`,borderRadius:4,color:i.textSecondary,fontSize:12,fontFamily:i.fontMono,padding:"1px 6px",outline:"none",width:140}}):e.name&&t.jsx("span",{onClick:()=>{u(e.name??""),x(!0)},title:"Click to rename",style:{color:i.textSecondary,fontSize:12,fontFamily:i.fontMono,cursor:"text",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:200},children:e.name}),t.jsx("div",{style:{flex:1}}),s&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:2},children:[!e.name&&!c&&t.jsx(Z,{title:"Name this cell",onClick:()=>{u(""),x(!0)},t:i,children:t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M11.013 1.427a1.75 1.75 0 0 1 2.474 0l1.086 1.086a1.75 1.75 0 0 1 0 2.474l-8.61 8.61c-.21.21-.47.364-.756.445l-3.251.93a.75.75 0 0 1-.927-.928l.929-3.25c.081-.286.235-.547.445-.758l8.61-8.61Zm.176 4.823L9.75 4.81l-6.286 6.287a.253.253 0 0 0-.064.108l-.558 1.953 1.953-.558a.253.253 0 0 0 .108-.064Zm1.238-3.763a.25.25 0 0 0-.354 0L10.811 3.75l1.439 1.44 1.263-1.263a.25.25 0 0 0 0-.354Z"})})}),k&&t.jsx(Z,{title:"Run cell (Shift+Enter)",onClick:v,t:i,accent:!0,children:t.jsx("svg",{width:"11",height:"11",viewBox:"0 0 10 10",fill:"currentColor",children:t.jsx("path",{d:"M1.5 1.5l7 3.5-7 3.5V1.5Z"})})}),t.jsx(Z,{title:"Move up",onClick:A,t:i,children:t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M3.47 7.78a.75.75 0 0 1 0-1.06l4.25-4.25a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1-1.06 1.06L8.75 4.81v7.44a.75.75 0 0 1-1.5 0V4.81L4.53 7.78a.75.75 0 0 1-1.06 0Z"})})}),t.jsx(Z,{title:"Move down",onClick:D,t:i,children:t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M12.53 8.22a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L2.97 9.28a.75.75 0 0 1 1.06-1.06l2.72 2.97V3.75a.75.75 0 0 1 1.5 0v7.44l2.72-2.97a.75.75 0 0 1 1.06 0Z"})})}),t.jsx(Z,{title:"Delete cell",onClick:T,t:i,danger:!0,children:t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:t.jsx("path",{d:"M11 1.75V3h2.25a.75.75 0 0 1 0 1.5H2.75a.75.75 0 0 1 0-1.5H5V1.75C5 .784 5.784 0 6.75 0h2.5C10.216 0 11 .784 11 1.75ZM4.496 6.675l.66 6.6a.25.25 0 0 0 .249.225h5.19a.25.25 0 0 0 .249-.225l.66-6.6a.75.75 0 0 1 1.492.149l-.66 6.6A1.748 1.748 0 0 1 10.595 15h-5.19a1.75 1.75 0 0 1-1.741-1.575l-.66-6.6a.75.75 0 1 1 1.492-.15ZM6.5 1.75V3h3V1.75a.25.25 0 0 0-.25-.25h-2.5a.25.25 0 0 0-.25.25Z"})})})]})]}),e.type==="markdown"?t.jsx(Yt,{value:e.content,onChange:E,themeMode:n.themeMode}):t.jsx(be,{value:e.content,onChange:E,onRun:v,themeMode:n.themeMode}),z&&t.jsxs("div",{style:{borderTop:`1px solid ${i.cellBorder}`},children:[t.jsxs("div",{style:{height:28,display:"flex",alignItems:"center",padding:"0 12px",gap:10,borderBottom:e.result&&p?`1px solid ${i.cellBorder}`:"none",background:`${i.tableHeaderBg}60`},children:[e.result&&t.jsxs("span",{style:{fontSize:11,fontFamily:i.font,color:i.textMuted},children:[(e.result.rowCount??e.result.rows.length).toLocaleString()," rows",e.result.executionTime!==void 0&&t.jsxs(t.Fragment,{children:[" · ",e.result.executionTime<1e3?`${e.result.executionTime}ms`:`${(e.result.executionTime/1e3).toFixed(2)}s`]})]}),e.error&&t.jsx("span",{style:{fontSize:11,fontFamily:i.font,color:i.error},children:"Error"}),t.jsx("div",{style:{flex:1}}),e.result&&_&&p&&t.jsx("div",{style:{display:"flex",alignItems:"center",gap:3},children:["chart","table"].map(S=>t.jsx("button",{onClick:()=>g(S),style:{padding:"1px 7px",fontSize:10,fontFamily:i.font,borderRadius:3,border:`1px solid ${h===S?i.accent:i.btnBorder}`,background:h===S?`${i.accent}20`:"transparent",color:h===S?i.accent:i.textMuted,cursor:"pointer",transition:"all 0.15s",textTransform:"capitalize"},children:S==="chart"?"Chart":"Table"},S))}),t.jsxs("button",{onClick:()=>m(S=>!S),style:{background:"transparent",border:"none",cursor:"pointer",color:i.textMuted,fontSize:11,fontFamily:i.font,padding:"2px 4px",display:"flex",alignItems:"center",gap:4},children:[t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",style:{transform:p?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.15s"},children:t.jsx("path",{d:"M1 3l4 4 4-4",stroke:"currentColor",fill:"none",strokeWidth:"1.5"})}),p?"Hide":"Show"]})]}),p&&t.jsxs(t.Fragment,{children:[e.error&&t.jsx(an,{message:e.error,themeMode:n.themeMode}),e.result&&!e.error&&(h==="chart"&&_?t.jsx(sn,{result:e.result,themeMode:n.themeMode}):t.jsx(ve,{result:e.result,themeMode:n.themeMode}))]})]})]})]})}function Z({title:e,onClick:r,children:n,t:o,accent:i,danger:l}){const[s,a]=f.useState(!1);return t.jsx("button",{title:e,onClick:r,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",background:s?l?`${o.error}18`:i?`${o.accent}18`:o.btnHover:"transparent",border:"none",borderRadius:4,cursor:"pointer",color:s?l?o.error:i?o.accent:o.textSecondary:o.textMuted,transition:"all 0.15s",padding:0},children:n})}const fn=[{type:"sql",label:"SQL",color:"#388bfd"},{type:"markdown",label:"Markdown",color:"#56d364"},{type:"dql",label:"DQL",color:"#e3b341"},{type:"param",label:"Param",color:"#e3b341"}];function ee({afterId:e}){const{state:r,dispatch:n}=w(),o=j[r.themeMode],[i,l]=f.useState(!1),[s,a]=f.useState(!1),c=f.useRef(null);f.useEffect(()=>{if(!s)return;function d(u){c.current&&!c.current.contains(u.target)&&a(!1)}return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[s]);const x=d=>{const u=$(d);n({type:"ADD_CELL",cell:u,afterId:e}),a(!1)};return t.jsxs("div",{ref:c,onMouseEnter:()=>l(!0),onMouseLeave:()=>{l(!1)},style:{position:"relative",height:28,display:"flex",alignItems:"center",justifyContent:"center",cursor:"default"},children:[t.jsx("div",{style:{position:"absolute",left:0,right:0,height:1,background:i||s?o.cellBorderActive:"transparent",transition:"background 0.15s"}}),(i||s)&&t.jsxs("button",{onClick:()=>a(d=>!d),style:{position:"relative",zIndex:2,height:22,padding:"0 10px",borderRadius:11,border:`1px solid ${o.cellBorderActive}`,background:`${o.accent}18`,color:o.accent,cursor:"pointer",fontSize:12,fontFamily:o.font,fontWeight:500,display:"flex",alignItems:"center",gap:4,transition:"background 0.15s"},children:[t.jsx("span",{style:{fontSize:14,lineHeight:1,marginTop:-1},children:"+"}),"Add cell"]}),s&&t.jsx("div",{style:{position:"absolute",top:26,left:"50%",transform:"translateX(-50%)",zIndex:100,background:o.modalBg,border:`1px solid ${o.cellBorder}`,borderRadius:8,boxShadow:"0 8px 24px rgba(0,0,0,0.3)",padding:4,display:"flex",gap:4},children:fn.map(({type:d,label:u,color:p})=>t.jsx(xn,{label:u,color:p,onClick:()=>x(d),t:o},d))})]})}function xn({label:e,color:r,onClick:n,t:o}){const[i,l]=f.useState(!1);return t.jsx("button",{onClick:n,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{background:i?`${r}18`:"transparent",border:`1px solid ${i?r:o.cellBorder}`,borderRadius:6,cursor:"pointer",color:i?r:o.textSecondary,fontSize:11,fontFamily:o.fontMono,fontWeight:600,padding:"4px 10px",letterSpacing:"0.04em",transition:"all 0.15s",whiteSpace:"nowrap"},children:e})}function hn({registerCellRef:e}){const{state:r,dispatch:n}=w(),{executeCell:o}=oe(),i=j[r.themeMode],[l,s]=f.useState(null),a=f.useRef(0);return f.useCallback(c=>{s(c)},[]),f.useEffect(()=>{function c(x){var m;if(!l)return;const d=x.target;if(d.tagName==="TEXTAREA"||d.tagName==="INPUT"||d.isContentEditable||d.closest(".cm-editor")){s(null);return}const u=r.cells,p=u.findIndex(h=>h.id===l);if(p!==-1)switch(x.key){case"a":{x.preventDefault();const h=$("sql");if(p===0)n({type:"ADD_CELL",cell:h,afterId:u[0].id}),n({type:"MOVE_CELL",id:h.id,direction:"up"});else{const g=u[p-1].id;n({type:"ADD_CELL",cell:h,afterId:g})}s(h.id);break}case"b":{x.preventDefault();const h=$("sql");n({type:"ADD_CELL",cell:h,afterId:l}),s(h.id);break}case"d":{x.preventDefault();const h=Date.now();if(h-a.current<=500){if(n({type:"DELETE_CELL",id:l}),u.length>1){const g=p>0?p-1:1;s(((m=u[g])==null?void 0:m.id)??null)}else s(null);a.current=0}else a.current=h;break}case"Enter":{if(x.shiftKey){x.preventDefault();const h=u[p];h&&h.type!=="markdown"&&o(h.id)}break}}}return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[l,r.cells,n,o]),f.useEffect(()=>{function c(x){x.target.closest("[data-cell-id]")||s(null)}return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[]),r.cells.length===0?t.jsxs("div",{style:{maxWidth:1200,margin:"0 auto",padding:"0 24px",display:"flex",flexDirection:"column"},children:[t.jsx(ee,{}),t.jsx(gn,{t:i})]}):t.jsxs("div",{style:{maxWidth:1200,margin:"0 auto",padding:"0 24px",display:"flex",flexDirection:"column"},children:[t.jsx(ee,{afterId:void 0}),r.cells.map((c,x)=>t.jsxs(U.Fragment,{children:[t.jsx("div",{ref:d=>e(c.id,d),"data-cell-id":c.id,onClick:d=>{const u=d.target;!u.closest(".cm-editor")&&!u.closest("textarea")&&!u.closest("input")&&s(c.id)},style:{outline:l===c.id?`2px solid ${i.accent}40`:"none",outlineOffset:2,borderRadius:10,transition:"outline 0.1s"},children:t.jsx(pn,{cell:c,index:x})}),t.jsx(ee,{afterId:c.id})]},c.id))]})}function gn({t:e}){return t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"48px 0",gap:12,color:e.textMuted},children:[t.jsx("svg",{width:"40",height:"40",viewBox:"0 0 16 16",fill:"currentColor",style:{opacity:.3},children:t.jsx("path",{d:"M2 1.75C2 .784 2.784 0 3.75 0h6.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0 1 13.25 16h-9.5A1.75 1.75 0 0 1 2 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v12.5c0 .138.112.25.25.25h9.5a.25.25 0 0 0 .25-.25V6h-2.75A1.75 1.75 0 0 1 8.75 4.25V1.5ZM8.75 5.5h2.836L10.25 3.664V4.25c0 .138.112.25.25.25H8.75Z"})}),t.jsx("span",{style:{fontSize:13,fontFamily:e.font},children:"Empty notebook. Click + to add your first cell."})]})}function mn({onOpenFile:e,registerCellRef:r}){const{state:n}=w(),o=j[n.themeMode];return n.activeFile?t.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",background:o.appBg},children:[t.jsx(yn,{t:o}),t.jsx("div",{style:{flex:1,overflow:"auto",padding:"24px 0 40px"},children:t.jsx(hn,{registerCellRef:r})})]}):t.jsx(Zt,{onOpenFile:e})}function yn({t:e}){const{state:r}=w(),n=r.cells.length;return t.jsxs("div",{style:{height:32,flexShrink:0,borderBottom:`1px solid ${e.headerBorder}`,background:e.cellBg,display:"flex",alignItems:"center",padding:"0 16px",gap:12},children:[t.jsx(bn,{t:e}),t.jsx("div",{style:{flex:1}}),t.jsxs("span",{style:{fontSize:11,color:e.textMuted,fontFamily:e.font,display:"flex",alignItems:"center",gap:12},children:[t.jsxs("span",{children:[n," ",n===1?"cell":"cells"]}),r.notebookDirty&&t.jsx("span",{style:{color:e.warning},children:"● unsaved"})]})]})}function bn({t:e}){const{state:r}=w();if(!r.activeFile)return null;const n=r.activeFile.path.split("/").filter(Boolean);return t.jsx("div",{style:{display:"flex",alignItems:"center",gap:4,fontSize:12,fontFamily:e.fontMono,color:e.textMuted,overflow:"hidden"},children:n.map((o,i)=>t.jsxs(U.Fragment,{children:[i>0&&t.jsx("span",{style:{color:e.textMuted,opacity:.5},children:"/"}),t.jsx("span",{style:{color:i===n.length-1?e.textSecondary:e.textMuted,fontWeight:i===n.length-1?500:400,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:i===n.length-1?200:100},children:o})]},i))})}const xe={blank:"Blank",revenue:"Revenue Analysis",pipeline:"Pipeline Health"},vn={blank:"Start with an empty notebook.",revenue:"Pre-built queries for revenue metrics and trends.",pipeline:"Templates for data pipeline health monitoring."};function he(e){return e.toLowerCase().replace(/[^a-z0-9\-_\s]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").slice(0,64)}function Sn(e){return e.trim()?/^[a-zA-Z0-9\-_ ]+$/.test(e)?null:"Only letters, numbers, hyphens, underscores, and spaces allowed.":"Name is required."}function jn(e){switch(e){case"revenue":return[$("markdown",`# Revenue Analysis
111
126
 
112
- This notebook analyzes revenue metrics and trends over time.`),{...A("sql",`SELECT
127
+ This notebook analyzes revenue metrics and trends over time.`),{...$("sql",`SELECT
113
128
  DATE_TRUNC('month', order_date) AS month,
114
129
  SUM(amount) AS revenue
115
130
  FROM orders
116
131
  GROUP BY 1
117
- ORDER BY 1`),name:"monthly_revenue"},{...A("sql",`SELECT
132
+ ORDER BY 1`),name:"monthly_revenue"},{...$("sql",`SELECT
118
133
  product_category,
119
134
  SUM(amount) AS total_revenue,
120
135
  COUNT(*) AS orders
121
136
  FROM orders
122
137
  GROUP BY 1
123
- ORDER BY 2 DESC`),name:"revenue_by_category"}];case"pipeline":return[A("markdown",`# Pipeline Health
138
+ ORDER BY 2 DESC`),name:"revenue_by_category"}];case"pipeline":return[$("markdown",`# Pipeline Health
124
139
 
125
- Monitor data pipeline performance, SLA compliance, and error rates.`),{...A("sql",`SELECT
140
+ Monitor data pipeline performance, SLA compliance, and error rates.`),{...$("sql",`SELECT
126
141
  pipeline_name,
127
142
  COUNT(*) AS runs,
128
143
  AVG(duration_seconds) AS avg_duration,
129
144
  SUM(CASE WHEN status = 'failed' THEN 1 ELSE 0 END) AS failures
130
145
  FROM pipeline_runs
131
146
  GROUP BY 1
132
- ORDER BY 4 DESC`),name:"pipeline_summary"},{...A("sql",`SELECT
147
+ ORDER BY 4 DESC`),name:"pipeline_summary"},{...$("sql",`SELECT
133
148
  *
134
149
  FROM pipeline_runs
135
150
  WHERE status = 'failed'
136
151
  AND run_date >= CURRENT_DATE - INTERVAL '7 days'
137
- ORDER BY run_date DESC`),name:"recent_failures"}];default:return[A("sql")]}}function bn({onFileOpened:e}){const{state:r,dispatch:n}=w(),o=S[r.themeMode],[i,l]=f.useState(""),[s,a]=f.useState("blank"),[c,x]=f.useState(null),[d,u]=f.useState(!1),p=f.useRef(null);f.useEffect(()=>{var h;(h=p.current)==null||h.focus()},[]),f.useEffect(()=>{const h=y=>{y.key==="Escape"&&n({type:"CLOSE_NEW_NOTEBOOK_MODAL"})};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[n]);const m=async()=>{const h=mn(i);if(h){x(h);return}u(!0),x(null);const y=he(i),C=yn(s);try{const E=await $.createNotebook(y,s),k={name:`${y}.dqlnb`,path:E.path,type:"notebook",folder:"notebooks",isNew:!0};n({type:"FILE_ADDED",file:k}),n({type:"OPEN_FILE",file:k,cells:C,title:i.trim()}),n({type:"CLOSE_NEW_NOTEBOOK_MODAL"}),e(k)}catch{const E=`notebooks/${y}.dqlnb`,k={name:`${y}.dqlnb`,path:E,type:"notebook",folder:"notebooks",isNew:!0};n({type:"FILE_ADDED",file:k}),n({type:"OPEN_FILE",file:k,cells:C,title:i.trim()}),n({type:"CLOSE_NEW_NOTEBOOK_MODAL"}),e(k)}finally{u(!1)}},g=h=>{h.target===h.currentTarget&&n({type:"CLOSE_NEW_NOTEBOOK_MODAL"})};return t.jsx("div",{onClick:g,style:{position:"fixed",inset:0,background:o.modalOverlay,display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,backdropFilter:"blur(4px)"},children:t.jsxs("div",{style:{background:o.modalBg,border:`1px solid ${o.cellBorder}`,borderRadius:12,width:480,maxWidth:"calc(100vw - 48px)",boxShadow:"0 20px 60px rgba(0,0,0,0.5)",overflow:"hidden"},children:[t.jsxs("div",{style:{padding:"20px 24px 0",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx("h2",{style:{fontSize:16,fontWeight:600,color:o.textPrimary,fontFamily:o.font,margin:0},children:"New Notebook"}),t.jsx("button",{onClick:()=>n({type:"CLOSE_NEW_NOTEBOOK_MODAL"}),style:{background:"transparent",border:"none",cursor:"pointer",color:o.textMuted,fontSize:18,lineHeight:1,padding:"2px 4px",borderRadius:4},children:"×"})]}),t.jsxs("div",{style:{padding:"20px 24px 24px",display:"flex",flexDirection:"column",gap:20},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsx("label",{style:{fontSize:12,fontWeight:500,color:o.textSecondary,fontFamily:o.font},children:"Name"}),t.jsx("input",{ref:p,value:i,onChange:h=>{l(h.target.value),x(null)},onKeyDown:h=>{h.key==="Enter"&&m()},placeholder:"my-analysis",style:{background:o.inputBg,border:`1px solid ${c?o.error:o.inputBorder}`,borderRadius:6,color:o.textPrimary,fontSize:13,fontFamily:o.font,padding:"8px 12px",outline:"none",transition:"border-color 0.15s"}}),c&&t.jsx("span",{style:{fontSize:11,color:o.error,fontFamily:o.font},children:c}),i&&!c&&t.jsxs("span",{style:{fontSize:11,color:o.textMuted,fontFamily:o.fontMono},children:["File: ",he(i),".dqlnb"]})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsx("label",{style:{fontSize:12,fontWeight:500,color:o.textSecondary,fontFamily:o.font},children:"Template"}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:Object.keys(xe).map(h=>t.jsx(vn,{value:h,selected:s===h,onSelect:()=>a(h),label:xe[h],description:gn[h],t:o},h))})]})]}),t.jsxs("div",{style:{padding:"14px 24px",borderTop:`1px solid ${o.cellBorder}`,display:"flex",justifyContent:"flex-end",gap:10},children:[t.jsx("button",{onClick:()=>n({type:"CLOSE_NEW_NOTEBOOK_MODAL"}),style:{background:o.btnBg,border:`1px solid ${o.btnBorder}`,borderRadius:6,color:o.textSecondary,cursor:"pointer",fontSize:13,fontFamily:o.font,fontWeight:500,padding:"7px 16px"},children:"Cancel"}),t.jsx("button",{onClick:m,disabled:d||!i.trim(),style:{background:o.accent,border:`1px solid ${o.accent}`,borderRadius:6,color:"#ffffff",cursor:d||!i.trim()?"not-allowed":"pointer",fontSize:13,fontFamily:o.font,fontWeight:500,padding:"7px 20px",opacity:d||!i.trim()?.6:1,display:"flex",alignItems:"center",gap:6},children:d?"Creating…":"Create Notebook"})]})]})})}function vn({value:e,selected:r,onSelect:n,label:o,description:i,t:l}){const[s,a]=f.useState(!1);return t.jsxs("div",{onClick:n,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:{display:"flex",alignItems:"flex-start",gap:10,padding:"10px 12px",borderRadius:8,border:`1px solid ${r?l.cellBorderActive:s?l.textMuted:l.inputBorder}`,background:r?`${l.cellBorderActive}10`:s?l.sidebarItemHover:"transparent",cursor:"pointer",transition:"all 0.15s"},children:[t.jsx("div",{style:{width:16,height:16,borderRadius:8,border:`2px solid ${r?l.accent:l.textMuted}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginTop:1,transition:"border-color 0.15s"},children:r&&t.jsx("div",{style:{width:8,height:8,borderRadius:4,background:l.accent}})}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:13,fontWeight:500,color:l.textPrimary,fontFamily:l.font,marginBottom:2},children:o}),t.jsx("div",{style:{fontSize:12,color:l.textSecondary,fontFamily:l.font},children:i})]})]})}function Sn(){const{state:e,dispatch:r}=w(),n=S[e.themeMode],o=f.useRef({}),i=f.useCallback(async a=>{try{const{content:c}=await $.readNotebook(a.path),{title:x,cells:d}=bt(a.path,c);r({type:"OPEN_FILE",file:a,cells:d,title:x}),e.sidebarPanel!=="files"&&r({type:"SET_SIDEBAR_PANEL",panel:"files"})}catch(c){console.error("Failed to open file:",c),r({type:"OPEN_FILE",file:a,cells:[A("sql")],title:a.name})}},[r,e.sidebarPanel]),l=f.useCallback(a=>{const c=o.current[a];c&&c.scrollIntoView({behavior:"smooth",block:"start"})},[]),s=f.useCallback((a,c)=>{c?o.current[a]=c:delete o.current[a]},[]);return t.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100vh",width:"100vw",background:n.appBg,fontFamily:n.font,color:n.textPrimary,overflow:"hidden"},children:[t.jsx(Rt,{}),t.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[t.jsx(Ye,{}),e.sidebarOpen&&t.jsx(ht,{onOpenFile:i,onNavigateToCell:l}),t.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minWidth:0},children:[t.jsx(fn,{onOpenFile:i,registerCellRef:s}),t.jsx(Nt,{})]})]}),e.newNotebookModalOpen&&t.jsx(bn,{onFileOpened:i})]})}function jn(){const{state:e,dispatch:r}=w(),n=f.useRef(null),o=f.useRef(null);f.useEffect(()=>{var i;n.current=((i=e.activeFile)==null?void 0:i.path)??null},[e.activeFile]),f.useEffect(()=>{if(typeof EventSource>"u")return;const i=()=>{const l=new EventSource(`${window.location.origin}/api/watch`);o.current=l,l.addEventListener("change",s=>{try{const a=JSON.parse(s.data);(a.type==="file-added"||a.type==="file-deleted")&&$.listNotebooks().then(c=>{r({type:"SET_FILES",files:c})}),a.type==="file-changed"&&$.listNotebooks().then(c=>{r({type:"SET_FILES",files:c})})}catch{}}),l.addEventListener("error",()=>{l.close(),setTimeout(i,5e3)})};return i(),()=>{var l;(l=o.current)==null||l.close(),o.current=null}},[r])}function wn(){const{state:e,dispatch:r}=w(),n=S[e.themeMode];return f.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=`
152
+ ORDER BY run_date DESC`),name:"recent_failures"}];default:return[$("sql")]}}function wn({onFileOpened:e}){const{state:r,dispatch:n}=w(),o=j[r.themeMode],[i,l]=f.useState(""),[s,a]=f.useState("blank"),[c,x]=f.useState(null),[d,u]=f.useState(!1),p=f.useRef(null);f.useEffect(()=>{var g;(g=p.current)==null||g.focus()},[]),f.useEffect(()=>{const g=y=>{y.key==="Escape"&&n({type:"CLOSE_NEW_NOTEBOOK_MODAL"})};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[n]);const m=async()=>{const g=Sn(i);if(g){x(g);return}u(!0),x(null);const y=he(i),k=jn(s);try{const v=await B.createNotebook(y,s),E={name:`${y}.dqlnb`,path:v.path,type:"notebook",folder:"notebooks",isNew:!0};n({type:"FILE_ADDED",file:E}),n({type:"OPEN_FILE",file:E,cells:k,title:i.trim()}),n({type:"CLOSE_NEW_NOTEBOOK_MODAL"}),e(E)}catch{const v=`notebooks/${y}.dqlnb`,E={name:`${y}.dqlnb`,path:v,type:"notebook",folder:"notebooks",isNew:!0};n({type:"FILE_ADDED",file:E}),n({type:"OPEN_FILE",file:E,cells:k,title:i.trim()}),n({type:"CLOSE_NEW_NOTEBOOK_MODAL"}),e(E)}finally{u(!1)}},h=g=>{g.target===g.currentTarget&&n({type:"CLOSE_NEW_NOTEBOOK_MODAL"})};return t.jsx("div",{onClick:h,style:{position:"fixed",inset:0,background:o.modalOverlay,display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,backdropFilter:"blur(4px)"},children:t.jsxs("div",{style:{background:o.modalBg,border:`1px solid ${o.cellBorder}`,borderRadius:12,width:480,maxWidth:"calc(100vw - 48px)",boxShadow:"0 20px 60px rgba(0,0,0,0.5)",overflow:"hidden"},children:[t.jsxs("div",{style:{padding:"20px 24px 0",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx("h2",{style:{fontSize:16,fontWeight:600,color:o.textPrimary,fontFamily:o.font,margin:0},children:"New Notebook"}),t.jsx("button",{onClick:()=>n({type:"CLOSE_NEW_NOTEBOOK_MODAL"}),style:{background:"transparent",border:"none",cursor:"pointer",color:o.textMuted,fontSize:18,lineHeight:1,padding:"2px 4px",borderRadius:4},children:"×"})]}),t.jsxs("div",{style:{padding:"20px 24px 24px",display:"flex",flexDirection:"column",gap:20},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsx("label",{style:{fontSize:12,fontWeight:500,color:o.textSecondary,fontFamily:o.font},children:"Name"}),t.jsx("input",{ref:p,value:i,onChange:g=>{l(g.target.value),x(null)},onKeyDown:g=>{g.key==="Enter"&&m()},placeholder:"my-analysis",style:{background:o.inputBg,border:`1px solid ${c?o.error:o.inputBorder}`,borderRadius:6,color:o.textPrimary,fontSize:13,fontFamily:o.font,padding:"8px 12px",outline:"none",transition:"border-color 0.15s"}}),c&&t.jsx("span",{style:{fontSize:11,color:o.error,fontFamily:o.font},children:c}),i&&!c&&t.jsxs("span",{style:{fontSize:11,color:o.textMuted,fontFamily:o.fontMono},children:["File: ",he(i),".dqlnb"]})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsx("label",{style:{fontSize:12,fontWeight:500,color:o.textSecondary,fontFamily:o.font},children:"Template"}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:Object.keys(xe).map(g=>t.jsx(kn,{value:g,selected:s===g,onSelect:()=>a(g),label:xe[g],description:vn[g],t:o},g))})]})]}),t.jsxs("div",{style:{padding:"14px 24px",borderTop:`1px solid ${o.cellBorder}`,display:"flex",justifyContent:"flex-end",gap:10},children:[t.jsx("button",{onClick:()=>n({type:"CLOSE_NEW_NOTEBOOK_MODAL"}),style:{background:o.btnBg,border:`1px solid ${o.btnBorder}`,borderRadius:6,color:o.textSecondary,cursor:"pointer",fontSize:13,fontFamily:o.font,fontWeight:500,padding:"7px 16px"},children:"Cancel"}),t.jsx("button",{onClick:m,disabled:d||!i.trim(),style:{background:o.accent,border:`1px solid ${o.accent}`,borderRadius:6,color:"#ffffff",cursor:d||!i.trim()?"not-allowed":"pointer",fontSize:13,fontFamily:o.font,fontWeight:500,padding:"7px 20px",opacity:d||!i.trim()?.6:1,display:"flex",alignItems:"center",gap:6},children:d?"Creating…":"Create Notebook"})]})]})})}function kn({value:e,selected:r,onSelect:n,label:o,description:i,t:l}){const[s,a]=f.useState(!1);return t.jsxs("div",{onClick:n,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:{display:"flex",alignItems:"flex-start",gap:10,padding:"10px 12px",borderRadius:8,border:`1px solid ${r?l.cellBorderActive:s?l.textMuted:l.inputBorder}`,background:r?`${l.cellBorderActive}10`:s?l.sidebarItemHover:"transparent",cursor:"pointer",transition:"all 0.15s"},children:[t.jsx("div",{style:{width:16,height:16,borderRadius:8,border:`2px solid ${r?l.accent:l.textMuted}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginTop:1,transition:"border-color 0.15s"},children:r&&t.jsx("div",{style:{width:8,height:8,borderRadius:4,background:l.accent}})}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:13,fontWeight:500,color:l.textPrimary,fontFamily:l.font,marginBottom:2},children:o}),t.jsx("div",{style:{fontSize:12,color:l.textSecondary,fontFamily:l.font},children:i})]})]})}function Cn(){const{state:e,dispatch:r}=w(),n=j[e.themeMode],o=f.useRef({}),i=f.useCallback(async a=>{try{const{content:c}=await B.readNotebook(a.path),{title:x,cells:d}=wt(a.path,c);r({type:"OPEN_FILE",file:a,cells:d,title:x}),e.sidebarPanel!=="files"&&r({type:"SET_SIDEBAR_PANEL",panel:"files"})}catch(c){console.error("Failed to open file:",c),r({type:"OPEN_FILE",file:a,cells:[$("sql")],title:a.name})}},[r,e.sidebarPanel]),l=f.useCallback(a=>{const c=o.current[a];c&&c.scrollIntoView({behavior:"smooth",block:"start"})},[]),s=f.useCallback((a,c)=>{c?o.current[a]=c:delete o.current[a]},[]);return t.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100vh",width:"100vw",background:n.appBg,fontFamily:n.font,color:n.textPrimary,overflow:"hidden"},children:[t.jsx(Nt,{}),t.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[t.jsx(Je,{}),e.sidebarOpen&&t.jsx(bt,{onOpenFile:i,onNavigateToCell:l}),t.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minWidth:0},children:[t.jsx(mn,{onOpenFile:i,registerCellRef:s}),t.jsx(Pt,{})]})]}),e.newNotebookModalOpen&&t.jsx(wn,{onFileOpened:i})]})}function En(){const{state:e,dispatch:r}=w(),n=f.useRef(null),o=f.useRef(null);f.useEffect(()=>{var i;n.current=((i=e.activeFile)==null?void 0:i.path)??null},[e.activeFile]),f.useEffect(()=>{if(typeof EventSource>"u")return;const i=()=>{const l=new EventSource(`${window.location.origin}/api/watch`);o.current=l,l.addEventListener("change",s=>{try{const a=JSON.parse(s.data);(a.type==="file-added"||a.type==="file-deleted")&&B.listNotebooks().then(c=>{r({type:"SET_FILES",files:c})}),a.type==="file-changed"&&B.listNotebooks().then(c=>{r({type:"SET_FILES",files:c})})}catch{}}),l.addEventListener("error",()=>{l.close(),setTimeout(i,5e3)})};return i(),()=>{var l;(l=o.current)==null||l.close(),o.current=null}},[r])}function Mn(){const{state:e,dispatch:r}=w(),n=j[e.themeMode];return f.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=`
138
153
  * { margin: 0; padding: 0; box-sizing: border-box; }
139
154
  body {
140
155
  font-family: ${n.font};
@@ -155,4 +170,4 @@ ORDER BY run_date DESC`),name:"recent_failures"}];default:return[A("sql")]}}func
155
170
  background: ${n.accent}40;
156
171
  color: ${n.textPrimary};
157
172
  }
158
- `},[n]),f.useEffect(()=>{r({type:"SET_FILES_LOADING",loading:!0}),$.listNotebooks().then(o=>{r({type:"SET_FILES",files:o}),r({type:"SET_FILES_LOADING",loading:!1})})},[r]),f.useEffect(()=>{r({type:"SET_SCHEMA_LOADING",loading:!0}),$.getSchema().then(o=>{r({type:"SET_SCHEMA",tables:o}),r({type:"SET_SCHEMA_LOADING",loading:!1})})},[r]),jn(),t.jsx(Sn,{})}function kn(){return t.jsx(We,{children:t.jsx(wn,{})})}Ie.createRoot(document.getElementById("root")).render(t.jsx(kn,{}));
173
+ `},[n]),f.useEffect(()=>{r({type:"SET_FILES_LOADING",loading:!0}),B.listNotebooks().then(o=>{r({type:"SET_FILES",files:o}),r({type:"SET_FILES_LOADING",loading:!1})})},[r]),f.useEffect(()=>{r({type:"SET_SCHEMA_LOADING",loading:!0}),B.getSchema().then(o=>{r({type:"SET_SCHEMA",tables:o}),r({type:"SET_SCHEMA_LOADING",loading:!1})})},[r]),En(),t.jsx(Cn,{})}function Ln(){return t.jsx(We,{children:t.jsx(Mn,{})})}He.createRoot(document.getElementById("root")).render(t.jsx(Ln,{}));
@@ -7,7 +7,7 @@
7
7
  <link rel="preconnect" href="https://fonts.googleapis.com" />
8
8
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
9
9
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet" />
10
- <script type="module" crossorigin src="/assets/index-BqahXnjO.js"></script>
10
+ <script type="module" crossorigin src="/assets/index-EE_LNEYl.js"></script>
11
11
  <link rel="modulepreload" crossorigin href="/assets/react-CRB3T2We.js">
12
12
  <link rel="modulepreload" crossorigin href="/assets/codemirror-CHXCUnwU.js">
13
13
  </head>
@@ -1 +1 @@
1
- {"version":3,"file":"local-runtime.d.ts","sourceRoot":"","sources":["../src/local-runtime.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,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AAED,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,aAAa,CAOpE;AAED,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,gBAAgB,EAC5B,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,aAAa,GAC3B;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,gBAAgB,CAAA;CAAE,CAQ/C;AAED,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,GAAG,gBAAgB,CAY9G;AAED,wBAAgB,8BAA8B,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAezG"}
@@ -151,6 +151,21 @@ export async function startLocalServer(opts) {
151
151
  res.end(serializeJSON(scanDataFiles(projectRoot)));
152
152
  return;
153
153
  }
154
+ if (req.method === 'GET' && path === '/api/connections') {
155
+ const cfg = loadProjectConfig(projectRoot);
156
+ const raw = cfg;
157
+ const connections = raw.connections ?? {};
158
+ // If no explicit connections map, surface the defaultConnection as "default"
159
+ if (Object.keys(connections).length === 0 && cfg.defaultConnection) {
160
+ connections['default'] = cfg.defaultConnection;
161
+ }
162
+ const defaultKey = raw.defaultConnection
163
+ ? 'default'
164
+ : Object.keys(connections)[0] ?? 'default';
165
+ res.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8' });
166
+ res.end(serializeJSON({ default: defaultKey, connections }));
167
+ return;
168
+ }
154
169
  // ── end dql-notebook API ──────────────────────────────────────────────────
155
170
  if (req.method === 'POST' && path === '/api/query') {
156
171
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"local-runtime.js","sourceRoot":"","sources":["../src/local-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,Q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AC,CAAC;AAC/D,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duckcodeailabs/dql-cli",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Public CLI for parsing, formatting, testing, and certifying DQL blocks",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -19,11 +19,11 @@
19
19
  "directory": "apps/cli"
20
20
  },
21
21
  "dependencies": {
22
- "@duckcodeailabs/dql-connectors": "0.1.4",
23
22
  "@duckcodeailabs/dql-core": "0.1.4",
24
- "@duckcodeailabs/dql-compiler": "0.1.5",
25
- "@duckcodeailabs/dql-project": "0.1.5",
23
+ "@duckcodeailabs/dql-connectors": "0.1.4",
26
24
  "@duckcodeailabs/dql-governance": "0.1.5",
25
+ "@duckcodeailabs/dql-project": "0.1.5",
26
+ "@duckcodeailabs/dql-compiler": "0.1.5",
27
27
  "@duckcodeailabs/dql-notebook": "0.1.5"
28
28
  },
29
29
  "devDependencies": {