@duckcodeailabs/dql-cli 1.3.5 → 1.3.6
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.
|
@@ -601,9 +601,9 @@ ${t}`;return r.replace(/\n\}\s*$/,`${o}
|
|
|
601
601
|
</html>`}function vE(e,t){const n=o0(e,t),r=new Blob([n],{type:"text/html;charset=utf-8"}),o=URL.createObjectURL(r),s=document.createElement("a");s.href=o,s.download=`${e.toLowerCase().replace(/[^a-z0-9]+/g,"-")}-dashboard.html`,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(o)}function s0({t:e}){return i.jsx("div",{style:{width:28,height:28,borderRadius:6,background:"linear-gradient(135deg, #5b8cff 0%, #7c5cff 100%)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:i.jsx("span",{style:{color:"#ffffff",fontSize:10,fontWeight:700,fontFamily:e.fontMono,letterSpacing:"-0.5px"},children:"DQL"})})}function i0(){const{state:e,dispatch:t}=fe(),n=ie[e.themeMode],{executeAll:r}=Hi(),[o,s]=S.useState(!1),[a,l]=S.useState(""),[c,d]=S.useState(!1),[E,u]=S.useState(!1),[T,f]=S.useState(!1),[h,A]=S.useState(!1),[R,p]=S.useState(!1),N=S.useRef(null),[I,O]=S.useState(!1),[C,m]=S.useState(!1),g=S.useRef(null),y=S.useRef(null),x=e.mainView==="block_studio"?e.blockStudioDirty:e.notebookDirty,w=e.mainView==="notebook",D=e.mainView==="connection"?"Connections":e.mainView==="reference"?"Quick Reference":e.notebookTitle||"Untitled";S.useEffect(()=>{o&&y.current&&(y.current.focus(),y.current.select())},[o]),S.useEffect(()=>{if(!C)return;function L(v){g.current&&!g.current.contains(v.target)&&m(!1)}return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[C]);const U=()=>{l(e.notebookTitle),s(!0)},F=()=>{s(!1),a.trim()&&a!==e.notebookTitle&&(e.mainView==="block_studio"&&e.blockStudioMetadata?(t({type:"SET_BLOCK_STUDIO_METADATA",metadata:{...e.blockStudioMetadata,name:a.trim()}}),t({type:"SET_BLOCK_STUDIO_DRAFT",draft:XR(e.blockStudioDraft,a.trim())})):t({type:"SET_NOTEBOOK_DIRTY",dirty:!0}))},_=S.useCallback(async()=>{var L;if(e.activeFile){t({type:"SET_SAVING",saving:!0});try{if(e.mainView==="block_studio"){if(!e.blockStudioMetadata)return;const v=await J.saveBlockStudio({path:e.activeBlockPath,source:e.blockStudioDraft,metadata:{name:e.blockStudioMetadata.name,domain:e.blockStudioMetadata.domain,description:e.blockStudioMetadata.description,owner:e.blockStudioMetadata.owner,tags:e.blockStudioMetadata.tags}});t({type:"OPEN_BLOCK_STUDIO",file:{name:`${v.metadata.name}.dql`,path:v.path,type:"block",folder:"blocks"},payload:v}),e.files.some(G=>G.path===v.path)||t({type:"FILE_ADDED",file:{name:`${v.metadata.name}.dql`,path:v.path,type:"block",folder:"blocks"}})}else{const v=e.activeFile.type==="block"?((L=e.cells[0])==null?void 0:L.content)??"":B_(e.notebookTitle,e.cells,e.notebookMetadata);await J.saveNotebook(e.activeFile.path,v),t({type:"SET_NOTEBOOK_DIRTY",dirty:!1})}d(!0),setTimeout(()=>d(!1),2e3)}catch(v){console.error("Save failed:",v)}finally{t({type:"SET_SAVING",saving:!1})}}},[e.activeFile,e.activeBlockPath,e.blockStudioDraft,e.blockStudioMetadata,e.files,e.mainView,e.notebookTitle,e.notebookMetadata,e.cells,t]);S.useEffect(()=>{const L=v=>{(v.metaKey||v.ctrlKey)&&v.key==="s"&&(v.preventDefault(),_())};return document.addEventListener("keydown",L),()=>document.removeEventListener("keydown",L)},[_]),S.useEffect(()=>{if(!e.autoSave||!x||!e.activeFile)return;const L=setTimeout(()=>{_()},2e3);return()=>clearTimeout(L)},[e.autoSave,x,e.activeFile,e.cells,e.blockStudioDraft,_]);const B=[{mode:"obsidian",label:"Obsidian",glyph:"●",swatch:"#0d0e11"},{mode:"paper",label:"Paper",glyph:"☼",swatch:"#f7f4ed"},{mode:"white",label:"White",glyph:"○",swatch:"#ffffff"}],b=e.themeMode==="dark"||e.themeMode==="midnight"?"obsidian":e.themeMode==="light"?"paper":e.themeMode==="arctic"?"white":e.themeMode,P=B.find(L=>L.mode===b)??B[0];S.useEffect(()=>{if(!R)return;const L=G=>{N.current&&!N.current.contains(G.target)&&p(!1)},v=G=>{G.key==="Escape"&&p(!1)};return document.addEventListener("mousedown",L),document.addEventListener("keydown",v),()=>{document.removeEventListener("mousedown",L),document.removeEventListener("keydown",v)}},[R]);const M={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 i.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:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[i.jsx(s0,{t:n}),i.jsx("div",{style:{width:1,height:20,background:n.headerBorder,flexShrink:0}}),e.activeFile&&i.jsx("span",{style:{fontSize:10,fontWeight:600,color:e.activeFile.type==="block"?"#e3b341":n.accent,background:`${e.activeFile.type==="block"?"#e3b341":n.accent}18`,borderRadius:4,padding:"2px 6px",fontFamily:n.font,textTransform:"uppercase",letterSpacing:"0.05em",flexShrink:0},children:e.activeFile.type}),e.activeFile&&e.mainView!=="connection"&&e.mainView!=="reference"?o?i.jsx("input",{ref:y,value:a,onChange:L=>l(L.target.value),onBlur:F,onKeyDown:L=>{L.key==="Enter"&&F(),L.key==="Escape"&&s(!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}}):i.jsxs("span",{onClick:U,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:[D,x&&i.jsx("span",{style:{color:n.textMuted,marginLeft:4},children:"●"})]}):i.jsx("span",{style:{color:n.textSecondary,fontSize:13,fontFamily:n.font,padding:"2px 4px"},children:D})]}),i.jsx("div",{style:{flex:1}}),i.jsx(Sx,{options:[{value:"studio",label:"Notebook"},{value:"app",label:"App"},{value:"reader",label:"Reader"}],value:e.appMode,onChange:L=>t({type:"SET_APP_MODE",mode:L}),size:"sm",ariaLabel:"View mode"}),i.jsx("div",{style:{flex:1}}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.appMode==="studio"&&i.jsx(i.Fragment,{children:i.jsxs("button",{onClick:w?r:void 0,disabled:!e.activeFile||!w,onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),style:{...M,height:30,padding:"0 14px",borderRadius:999,background:n.accent,color:"#ffffff",border:`1px solid ${n.accent}`,opacity:!e.activeFile||!w?.4:E?.9:1,boxShadow:"0 1px 2px rgba(107,93,211,0.25)",gap:6},children:[i.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",children:i.jsx("path",{d:"M1.5 1.5l7 3.5-7 3.5V1.5Z"})}),"Run all"]})}),e.appMode==="app"&&i.jsxs(i.Fragment,{children:[i.jsxs("button",{onClick:()=>vE(e.notebookTitle||"dashboard",e.cells),disabled:!e.activeFile,title:"Publish dashboard (standalone HTML)",style:{...M,background:n.accent,color:"#ffffff",border:`1px solid ${n.accent}`,opacity:e.activeFile?1:.4},children:[i.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"currentColor",children:[i.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"}),i.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"})]}),"Publish"]}),i.jsx("div",{style:{width:1,height:20,background:n.headerBorder}})]}),i.jsxs("div",{ref:N,style:{position:"relative"},children:[i.jsxs("button",{onClick:()=>p(L=>!L),onMouseEnter:()=>A(!0),onMouseLeave:()=>A(!1),title:`Theme: ${P.label}`,"aria-haspopup":"true","aria-expanded":R,style:{...M,background:h||R?n.btnHover:n.btnBg,color:n.textSecondary,padding:"0 10px",fontSize:12,display:"flex",alignItems:"center",gap:6},children:[i.jsx("span",{style:{width:12,height:12,borderRadius:3,background:P.swatch,border:`1px solid ${n.headerBorder}`,flexShrink:0}}),i.jsx("span",{style:{fontFamily:n.fontMono,fontSize:10,letterSpacing:"0.04em"},children:P.label}),i.jsx("span",{style:{fontSize:8,color:n.textMuted},children:"▾"})]}),R&&i.jsx("div",{role:"menu",style:{position:"absolute",top:"100%",right:0,marginTop:4,minWidth:160,background:n.headerBg,border:`1px solid ${n.headerBorder}`,borderRadius:6,boxShadow:"0 8px 24px rgba(0,0,0,0.32)",padding:4,zIndex:1e3,display:"flex",flexDirection:"column",gap:1},children:B.map(L=>{const v=L.mode===b;return i.jsxs("button",{role:"menuitemradio","aria-checked":v,onClick:()=>{t({type:"SET_THEME",mode:L.mode}),p(!1)},style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",border:"none",background:v?n.btnHover:"transparent",color:n.textPrimary,cursor:"pointer",borderRadius:4,fontSize:12,fontFamily:n.font,textAlign:"left"},onMouseEnter:G=>{v||(G.currentTarget.style.background=n.btnHover)},onMouseLeave:G=>{v||(G.currentTarget.style.background="transparent")},children:[i.jsx("span",{style:{width:14,height:14,borderRadius:3,background:L.swatch,border:`1px solid ${n.headerBorder}`,flexShrink:0}}),i.jsx("span",{style:{flex:1},children:L.label}),v&&i.jsx("span",{style:{color:n.accent,fontSize:11},children:"✓"})]},L.mode)})})]}),e.appMode==="studio"&&i.jsxs(i.Fragment,{children:[i.jsx("button",{onClick:_,disabled:!e.activeFile||e.savingFile,onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),title:"Save (Cmd+S)",style:{...M,background:T&&e.activeFile?n.btnHover:n.btnBg,color:c?n.success:n.textSecondary,opacity:e.activeFile?1:.4},children:e.savingFile?i.jsxs(i.Fragment,{children:[i.jsx(l0,{}),"Saving…"]}):c?i.jsx(i.Fragment,{children:"✓ Saved"}):i.jsx(i.Fragment,{children:"Save"})}),i.jsx("button",{onClick:()=>t({type:"SET_AUTO_SAVE",enabled:!e.autoSave}),title:e.autoSave?"Auto-save on":"Auto-save off",style:{...M,background:e.autoSave?`${n.accent}20`:n.btnBg,color:e.autoSave?n.accent:n.textMuted,padding:"0 6px",fontSize:10,fontWeight:600,letterSpacing:"0.03em",border:`1px solid ${e.autoSave?n.accent:n.btnBorder}`},children:"AUTO"}),i.jsxs("button",{onClick:()=>t({type:"TOGGLE_DASHBOARD_MODE"}),disabled:!e.activeFile,title:e.dashboardMode?"Switch to editor mode":"Switch to dashboard mode",style:{...M,background:e.dashboardMode?`${n.accent}20`:n.btnBg,color:e.dashboardMode?n.accent:n.textSecondary,border:`1px solid ${e.dashboardMode?n.accent:n.btnBorder}`,opacity:e.activeFile?1:.4,padding:"0 8px"},children:[i.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"currentColor",children:e.dashboardMode?i.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.5Z"}):i.jsx("path",{d:"M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v3.585a.746.746 0 0 1 0 .83v8.085A1.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.25V5h13V1.75a.25.25 0 0 0-.25-.25ZM1.5 6.5v7.75c0 .138.112.25.25.25H7v-8Zm7 8h5.75a.25.25 0 0 0 .25-.25V6.5h-6Z"})}),e.dashboardMode?"Editor":"Dashboard"]}),i.jsx("div",{style:{width:1,height:20,background:n.headerBorder}})]}),i.jsxs("div",{ref:g,style:{position:"relative"},children:[i.jsxs("button",{onClick:()=>{e.activeFile&&m(L=>!L)},disabled:!e.activeFile,onMouseEnter:()=>O(!0),onMouseLeave:()=>O(!1),title:"Share / export",style:{...M,height:30,padding:"0 14px",borderRadius:999,background:(I||C)&&e.activeFile?"#2a2a30":"#1a1a1a",color:"#ffffff",border:"1px solid #1a1a1a",opacity:e.activeFile?1:.4,gap:6},children:[i.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"currentColor",children:i.jsx("path",{d:"M5.5 10.75a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 0 1.5h-3.5a.75.75 0 0 1-.75-.75Zm0-3a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 0 1.5h-3.5a.75.75 0 0 1-.75-.75ZM3 3.75A1.75 1.75 0 0 1 4.75 2h6.586c.464 0 .909.184 1.237.513l1.914 1.914c.329.328.513.773.513 1.237v6.586A1.75 1.75 0 0 1 13.25 14h-8.5A1.75 1.75 0 0 1 3 12.25Z"})}),"Share",i.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"currentColor",style:{marginLeft:1,opacity:.7},children:i.jsx("path",{d:"M1 2.5l3 3 3-3",stroke:"currentColor",fill:"none",strokeWidth:"1.2",strokeLinecap:"round"})})]}),C&&i.jsx("div",{style:{position:"absolute",top:32,right:0,zIndex:200,background:n.modalBg,border:`1px solid ${n.cellBorder}`,borderRadius:8,boxShadow:"0 8px 24px rgba(0,0,0,0.3)",padding:4,minWidth:160,display:"flex",flexDirection:"column",gap:2},children:i.jsx(a0,{label:"Export HTML",description:"Standalone dashboard",t:n,onClick:()=>{vE(e.notebookTitle||"dashboard",e.cells),m(!1)}})})]})]})]})}function a0({label:e,description:t,t:n,onClick:r}){const[o,s]=S.useState(!1);return i.jsxs("button",{onClick:r,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{background:o?n.btnHover:"transparent",border:"none",borderRadius:5,cursor:"pointer",padding:"6px 10px",textAlign:"left",display:"flex",flexDirection:"column",gap:1,transition:"background 0.12s"},children:[i.jsx("span",{style:{fontSize:12,fontWeight:500,color:n.textPrimary,fontFamily:n.font},children:e}),i.jsx("span",{style:{fontSize:10,color:n.textMuted,fontFamily:n.font},children:t})]})}function l0(){return i.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",style:{animation:"spin 0.8s linear infinite"},children:[i.jsx("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"}),i.jsx("circle",{cx:"6",cy:"6",r:"4.5",stroke:"currentColor",strokeWidth:"1.5",strokeDasharray:"14 7"})]})}function c0(e){return e.toTimeString().slice(0,8)}function d0(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(2)}s`}function E0(){const{state:e,dispatch:t}=fe(),n=ie[e.themeMode],[r,o]=S.useState(!1),s=e.queryLog.filter(l=>l.error),a=l=>t({type:"SET_DEV_PANEL_TAB",tab:l});return i.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&&i.jsxs(i.Fragment,{children:[i.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(l=>i.jsx(u0,{label:l==="errors"?`Errors${s.length>0?` (${s.length})`:""}`:`Logs (${e.queryLog.length})`,active:e.devPanelTab===l,onClick:()=>a(l),t:n},l)),i.jsx("div",{style:{flex:1}}),i.jsx("button",{onClick:()=>t({type:"SET_CELLS",cells:e.cells}),title:"Clear logs",style:{background:"transparent",borderTop:"none",borderLeft:"none",borderRight:"none",borderBottom:"none",cursor:"pointer",color:n.textMuted,fontSize:11,fontFamily:n.font,padding:"2px 6px",borderRadius:4},children:"Clear"})]}),i.jsxs("div",{style:{flex:1,overflow:"auto",padding:"4px 0"},children:[e.devPanelTab==="logs"&&(e.queryLog.length===0?i.jsx(UE,{t:n,message:"No queries executed yet."}):[...e.queryLog].reverse().map(l=>i.jsx(wE,{entry:l,t:n},l.id))),e.devPanelTab==="errors"&&(s.length===0?i.jsx(UE,{t:n,message:"No errors."}):[...s].reverse().map(l=>i.jsx(wE,{entry:l,t:n},l.id)))]})]}),i.jsxs("button",{onClick:()=>t({type:"TOGGLE_DEV_PANEL"}),onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),title:e.devPanelOpen?"Close panel":"Open dev panel",style:{position:"absolute",bottom:e.devPanelOpen?4:-28,right:8,height:22,padding:"0 8px",borderRadius:"4px 4px 0 0",borderTop:`1px solid ${n.headerBorder}`,borderLeft:`1px solid ${n.headerBorder}`,borderRight:`1px solid ${n.headerBorder}`,borderBottom:e.devPanelOpen?`1px solid ${n.sidebarBg}`:`1px solid ${n.headerBorder}`,background:r?n.btnHover:n.sidebarBg,color:n.textMuted,cursor:"pointer",fontSize:11,fontFamily:n.font,display:"flex",alignItems:"center",gap:4,transition:"background 0.15s, bottom 0.2s ease",zIndex:10},children:[i.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",children:i.jsx("path",{d:e.devPanelOpen?"M1 7l4-4 4 4":"M1 3l4 4 4-4",strokeWidth:"1.5",stroke:"currentColor",fill:"none"})}),"Dev"]})]})}function u0({label:e,active:t,onClick:n,t:r}){const[o,s]=S.useState(!1);return i.jsx("button",{onClick:n,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{background:"transparent",borderTop:"none",borderLeft:"none",borderRight:"none",borderBottom:t?`2px solid ${r.accent}`:"2px solid transparent",cursor:"pointer",color:t?r.textPrimary:o?r.textSecondary:r.textMuted,fontSize:12,fontFamily:r.font,fontWeight:t?500:400,padding:"4px 8px",height:32,transition:"color 0.15s"},children:e})}function UE({t:e,message:t}){return i.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:e.textMuted,fontSize:12,fontFamily:e.font,fontStyle:"italic"},children:t})}function wE({entry:e,t}){return i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"3px 12px",fontSize:11,fontFamily:t.fontMono,color:e.error?t.error:t.textSecondary,borderLeft:e.error?`2px solid ${t.error}`:"2px solid transparent"},children:[i.jsx("span",{style:{color:t.textMuted,flexShrink:0},children:c0(e.ts)}),i.jsx("span",{style:{flexShrink:0,color:t.textPrimary,maxWidth:160,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.cellName}),e.error?i.jsx("span",{style:{color:t.error,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.error}):i.jsxs(i.Fragment,{children:[i.jsxs("span",{style:{color:t.textMuted},children:[e.rows.toLocaleString()," rows"]}),i.jsx("span",{style:{color:t.textMuted},children:d0(e.time)})]})]})}function T0({onOpenFile:e}){const{state:t,dispatch:n}=fe(),r=ie[t.themeMode],o=t.files.slice(0,3);return i.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",background:r.appBg,padding:40,overflow:"auto"},children:i.jsxs("div",{style:{maxWidth:720,width:"100%",display:"flex",flexDirection:"column",alignItems:"center",gap:48},children:[i.jsxs("div",{style:{textAlign:"center",display:"flex",flexDirection:"column",alignItems:"center",gap:16},children:[i.jsx("div",{style:{width:72,height:72,borderRadius:16,background:"linear-gradient(135deg, #5b8cff 0%, #7c5cff 60%, #4a34a8 100%)",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 8px 32px rgba(91,140,255,0.28)"},children:i.jsx("span",{style:{color:"#fff",fontSize:26,fontWeight:800,fontFamily:r.fontMono,letterSpacing:"-1px"},children:"DQL"})}),i.jsxs("div",{children:[i.jsx("h1",{style:{fontSize:32,fontWeight:700,color:r.textPrimary,fontFamily:r.font,marginBottom:8,letterSpacing:"-0.5px"},children:"DQL Notebook"}),i.jsx("p",{style:{fontSize:15,color:r.textSecondary,fontFamily:r.font,letterSpacing:"0.02em"},children:"Analytics as Code"})]})]}),i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:16,width:"100%"},children:[i.jsx(BE,{title:"New Notebook",description:"Start a fresh analysis with an empty notebook.",icon:i.jsx(R0,{}),accent:r.accent,onClick:()=>n({type:"OPEN_NEW_NOTEBOOK_MODAL"}),t:r}),i.jsx(f0,{recentFiles:o,onOpenFile:e,t:r}),i.jsx(BE,{title:"New Block",description:"Create a reusable SQL block file.",icon:i.jsx(A0,{}),accent:"#ffc857",onClick:()=>n({type:"OPEN_NEW_BLOCK_MODAL"}),t:r})]}),i.jsxs("div",{style:{width:"100%",borderRadius:10,border:`1px solid ${r.cellBorder}`,padding:"16px 20px",background:r.cellBg},children:[i.jsx("div",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:r.textMuted,fontFamily:r.font,marginBottom:12},children:"Quick Tips"}),i.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:8},children:[["Shift + Enter","Run cell"],["⌘ + S","Save notebook"],["⌘ + B","Toggle sidebar"],["⌘ + D","Dashboard mode"],["⌘ + Shift + Enter","Run all cells"],["⌘ + J","Toggle dev panel"],["Click +","Add a new cell"],["Drag handle","Reorder cells"]].map(([s,a])=>i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[i.jsx("kbd",{style:{background:r.pillBg,border:`1px solid ${r.cellBorder}`,borderRadius:4,padding:"2px 6px",fontSize:11,fontFamily:r.fontMono,color:r.textSecondary,whiteSpace:"nowrap"},children:s}),i.jsx("span",{style:{fontSize:12,color:r.textMuted,fontFamily:r.font},children:a})]},s))})]})]})})}function BE({title:e,description:t,icon:n,accent:r,onClick:o,t:s}){const[a,l]=S.useState(!1);return i.jsxs("button",{onClick:o,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{background:a?s.cellBg:"transparent",border:`1px solid ${a?r:s.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:a?`0 0 0 1px ${r}30, 0 4px 16px rgba(0,0,0,0.15)`:"none"},children:[i.jsx("div",{style:{width:36,height:36,borderRadius:8,background:`${r}18`,display:"flex",alignItems:"center",justifyContent:"center",color:r},children:n}),i.jsxs("div",{children:[i.jsx("div",{style:{fontSize:13,fontWeight:600,color:s.textPrimary,fontFamily:s.font,marginBottom:4},children:e}),i.jsx("div",{style:{fontSize:12,color:s.textSecondary,fontFamily:s.font,lineHeight:1.5},children:t})]})]})}function f0({recentFiles:e,onOpenFile:t,t:n}){const[r,o]=S.useState(!1);return i.jsxs("div",{onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{background:r?n.cellBg:"transparent",border:`1px solid ${r?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:[i.jsx("div",{style:{width:36,height:36,borderRadius:8,background:`${n.warning}18`,display:"flex",alignItems:"center",justifyContent:"center",color:n.warning},children:i.jsx(p0,{})}),i.jsxs("div",{children:[i.jsx("div",{style:{fontSize:13,fontWeight:600,color:n.textPrimary,fontFamily:n.font,marginBottom:8},children:"Open Recent"}),e.length===0?i.jsx("div",{style:{fontSize:12,color:n.textMuted,fontFamily:n.font,fontStyle:"italic"},children:"No recent files."}):i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:e.map(s=>i.jsx(S0,{file:s,onClick:()=>t(s),t:n},s.path))})]})]})}function S0({file:e,onClick:t,t:n}){const[r,o]=S.useState(!1);return i.jsx("button",{onClick:t,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{background:"transparent",border:"none",cursor:"pointer",color:r?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 R0(){return i.jsx("svg",{width:"18",height:"18",viewBox:"0 0 16 16",fill:"currentColor",children:i.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 p0(){return i.jsx("svg",{width:"18",height:"18",viewBox:"0 0 16 16",fill:"currentColor",children:i.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 A0(){return i.jsx("svg",{width:"18",height:"18",viewBox:"0 0 16 16",fill:"currentColor",children:i.jsx("path",{d:"M8.75 1.75a.75.75 0 0 0-1.5 0V6.5H2.75a.75.75 0 0 0 0 1.5H7.25v4.75a.75.75 0 0 0 1.5 0V8H13.25a.75.75 0 0 0 0-1.5H8.75V1.75Z"})})}const FE=typeof String.prototype.normalize=="function"?e=>e.normalize("NFKD"):e=>e;class ro{constructor(t,n,r=0,o=t.length,s,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=t.iterRange(r,o),this.bufferStart=r,this.normalize=s?l=>s(FE(l)):FE,this.query=this.normalize(n)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return NI(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let t=this.peek();if(t<0)return this.done=!0,this;let n=LI(t),r=this.bufferStart+this.bufferPos;this.bufferPos+=OI(t);let o=this.normalize(n);if(o.length)for(let s=0,a=r;;s++){let l=o.charCodeAt(s),c=this.match(l,a,this.bufferPos+this.bufferStart);if(s==o.length-1){if(c)return this.value=c,this;break}a==r&&s<n.length&&n.charCodeAt(s)==l&&a++}}}match(t,n,r){let o=null;for(let s=0;s<this.matches.length;s+=2){let a=this.matches[s],l=!1;this.query.charCodeAt(a)==t&&(a==this.query.length-1?o={from:this.matches[s+1],to:r}:(this.matches[s]++,l=!0)),l||(this.matches.splice(s,2),s-=2)}return this.query.charCodeAt(0)==t&&(this.query.length==1?o={from:n,to:r}:this.matches.push(1,n)),o&&this.test&&!this.test(o.from,o.to,this.buffer,this.bufferStart)&&(o=null),o}}typeof Symbol<"u"&&(ro.prototype[Symbol.iterator]=function(){return this});const KR={from:-1,to:-1,match:/.*/.exec("")},Zc="gm"+(/x/.unicode==null?"":"u");class zR{constructor(t,n,r,o=0,s=t.length){if(this.text=t,this.to=s,this.curLine="",this.done=!1,this.value=KR,/\\[sWDnr]|\n|\r|\[\^/.test(n))return new JR(t,n,r,o,s);this.re=new RegExp(n,Zc+(r!=null&&r.ignoreCase?"i":"")),this.test=r==null?void 0:r.test,this.iter=t.iter();let a=t.lineAt(o);this.curLineStart=a.from,this.matchPos=Zs(t,o),this.getLine(this.curLineStart)}getLine(t){this.iter.next(t),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let t=this.matchPos-this.curLineStart;;){this.re.lastIndex=t;let n=this.matchPos<=this.to&&this.re.exec(this.curLine);if(n){let r=this.curLineStart+n.index,o=r+n[0].length;if(this.matchPos=Zs(this.text,o+(r==o?1:0)),r==this.curLineStart+this.curLine.length&&this.nextLine(),(r<o||r>this.value.to)&&(!this.test||this.test(r,o,n)))return this.value={from:r,to:o,match:n},this;t=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),t=0;else return this.done=!0,this}}}const ka=new WeakMap;class sr{constructor(t,n){this.from=t,this.text=n}get to(){return this.from+this.text.length}static get(t,n,r){let o=ka.get(t);if(!o||o.from>=r||o.to<=n){let l=new sr(n,t.sliceString(n,r));return ka.set(t,l),l}if(o.from==n&&o.to==r)return o;let{text:s,from:a}=o;return a>n&&(s=t.sliceString(n,a)+s,a=n),o.to<r&&(s+=t.sliceString(o.to,r)),ka.set(t,new sr(a,s)),new sr(n,s.slice(n-a,r-a))}}class JR{constructor(t,n,r,o,s){this.text=t,this.to=s,this.done=!1,this.value=KR,this.matchPos=Zs(t,o),this.re=new RegExp(n,Zc+(r!=null&&r.ignoreCase?"i":"")),this.test=r==null?void 0:r.test,this.flat=sr.get(t,o,this.chunkEnd(o+5e3))}chunkEnd(t){return t>=this.to?this.to:this.text.lineAt(t).to}next(){for(;;){let t=this.re.lastIndex=this.matchPos-this.flat.from,n=this.re.exec(this.flat.text);if(n&&!n[0]&&n.index==t&&(this.re.lastIndex=t+1,n=this.re.exec(this.flat.text)),n){let r=this.flat.from+n.index,o=r+n[0].length;if((this.flat.to>=this.to||n.index+n[0].length<=this.flat.text.length-10)&&(!this.test||this.test(r,o,n)))return this.value={from:r,to:o,match:n},this.matchPos=Zs(this.text,o+(r==o?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=sr.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(zR.prototype[Symbol.iterator]=JR.prototype[Symbol.iterator]=function(){return this});function h0(e){try{return new RegExp(e,Zc),!0}catch{return!1}}function Zs(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}const I0=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:o}=AI(e,{label:t.phrase("Go to line"),input:{type:"text",name:"line",value:n},focus:!0,submitLabel:t.phrase("go")});return o.then(s=>{let a=s&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(s.elements.line.value);if(!a){e.dispatch({effects:r});return}let l=t.doc.lineAt(t.selection.main.head),[,c,d,E,u]=a,T=E?+E.slice(1):0,f=d?+d:l.number;if(d&&u){let R=f/100;c&&(R=R*(c=="-"?-1:1)+l.number/t.doc.lines),f=Math.round(t.doc.lines*R)}else d&&c&&(f=f*(c=="-"?-1:1)+l.number);let h=t.doc.line(Math.max(1,Math.min(t.doc.lines,f))),A=ut.cursor(h.from+Math.max(0,Math.min(T,h.length)));e.dispatch({effects:[r,Ge.scrollIntoView(A.from,{y:"center"})],selection:A})}),!0},N0=({state:e,dispatch:t})=>{let{selection:n}=e,r=ut.create(n.ranges.map(o=>e.wordAt(o.head)||ut.cursor(o.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function O0(e,t){let{main:n,ranges:r}=e.selection,o=e.wordAt(n.head),s=o&&o.from==n.from&&o.to==n.to;for(let a=!1,l=new ro(e.doc,t,r[r.length-1].to);;)if(l.next(),l.done){if(a)return null;l=new ro(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),a=!0}else{if(a&&r.some(c=>c.from==l.value.from))continue;if(s){let c=e.wordAt(l.value.from);if(!c||c.from!=l.value.from||c.to!=l.value.to)continue}return l.value}}const m0=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(s=>s.from===s.to))return N0({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(s=>e.sliceDoc(s.from,s.to)!=r))return!1;let o=O0(e,r);return o?(t(e.update({selection:e.selection.addRange(ut.range(o.from,o.to),!1),effects:Ge.scrollIntoView(o.to)})),!0):!1},Bn=mI.define({combine(e){return gI(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:t=>new F0(t),scrollToMatch:t=>Ge.scrollIntoView(t)})}});function g0(e){return e?[Bn.of(e),Jl]:Jl}class qR{constructor(t){this.search=t.search,this.caseSensitive=!!t.caseSensitive,this.literal=!!t.literal,this.regexp=!!t.regexp,this.replace=t.replace||"",this.valid=!!this.search&&(!this.regexp||h0(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!t.wholeWord,this.test=t.test}unquote(t){return this.literal?t:t.replace(/\\([nrt\\])/g,(n,r)=>r=="n"?`
|
|
602
602
|
`:r=="r"?"\r":r=="t"?" ":"\\")}eq(t){return this.search==t.search&&this.replace==t.replace&&this.caseSensitive==t.caseSensitive&&this.regexp==t.regexp&&this.wholeWord==t.wholeWord&&this.test==t.test}create(){return this.regexp?new D0(this):new L0(this)}getCursor(t,n=0,r){let o=t.doc?t:Of.create({doc:t});return r==null&&(r=o.doc.length),this.regexp?er(this,o,n,r):Zn(this,o,n,r)}}class QR{constructor(t){this.spec=t}}function C0(e,t,n){return(r,o,s,a)=>{if(n&&!n(r,o,s,a))return!1;let l=r>=a&&o<=a+s.length?s.slice(r-a,o-a):t.doc.sliceString(r,o);return e(l,t,r,o)}}function Zn(e,t,n,r){let o;return e.wholeWord&&(o=x0(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(o=C0(e.test,t,o)),new ro(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:s=>s.toLowerCase(),o)}function x0(e,t){return(n,r,o,s)=>((s>n||s+o.length<r)&&(s=Math.max(0,n-2),o=e.sliceString(s,Math.min(e.length,r+2))),(t(ei(o,n-s))!=en.Word||t(ti(o,n-s))!=en.Word)&&(t(ti(o,r-s))!=en.Word||t(ei(o,r-s))!=en.Word))}class L0 extends QR{constructor(t){super(t)}nextMatch(t,n,r){let o=Zn(this.spec,t,r,t.doc.length).nextOverlapping();if(o.done){let s=Math.min(t.doc.length,n+this.spec.unquoted.length);o=Zn(this.spec,t,0,s).nextOverlapping()}return o.done||o.value.from==n&&o.value.to==r?null:o.value}prevMatchInRange(t,n,r){for(let o=r;;){let s=Math.max(n,o-1e4-this.spec.unquoted.length),a=Zn(this.spec,t,s,o),l=null;for(;!a.nextOverlapping().done;)l=a.value;if(l)return l;if(s==n)return null;o-=1e4}}prevMatch(t,n,r){let o=this.prevMatchInRange(t,0,n);return o||(o=this.prevMatchInRange(t,Math.max(0,r-this.spec.unquoted.length),t.doc.length)),o&&(o.from!=n||o.to!=r)?o:null}getReplacement(t){return this.spec.unquote(this.spec.replace)}matchAll(t,n){let r=Zn(this.spec,t,0,t.doc.length),o=[];for(;!r.next().done;){if(o.length>=n)return null;o.push(r.value)}return o}highlight(t,n,r,o){let s=Zn(this.spec,t,Math.max(0,n-this.spec.unquoted.length),Math.min(r+this.spec.unquoted.length,t.doc.length));for(;!s.next().done;)o(s.value.from,s.value.to)}}function y0(e,t,n){return(r,o,s)=>(!n||n(r,o,s))&&e(s[0],t,r,o)}function er(e,t,n,r){let o;return e.wholeWord&&(o=_0(t.charCategorizer(t.selection.main.head))),e.test&&(o=y0(e.test,t,o)),new zR(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:o},n,r)}function ei(e,t){return e.slice(mf(e,t,!1),t)}function ti(e,t){return e.slice(t,mf(e,t))}function _0(e){return(t,n,r)=>!r[0].length||(e(ei(r.input,r.index))!=en.Word||e(ti(r.input,r.index))!=en.Word)&&(e(ti(r.input,r.index+r[0].length))!=en.Word||e(ei(r.input,r.index+r[0].length))!=en.Word)}class D0 extends QR{nextMatch(t,n,r){let o=er(this.spec,t,r,t.doc.length).next();return o.done&&(o=er(this.spec,t,0,n).next()),o.done?null:o.value}prevMatchInRange(t,n,r){for(let o=1;;o++){let s=Math.max(n,r-o*1e4),a=er(this.spec,t,s,r),l=null;for(;!a.next().done;)l=a.value;if(l&&(s==n||l.from>s+10))return l;if(s==n)return null}}prevMatch(t,n,r){return this.prevMatchInRange(t,0,n)||this.prevMatchInRange(t,r,t.doc.length)}getReplacement(t){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(n,r)=>{if(r=="&")return t.match[0];if(r=="$")return"$";for(let o=r.length;o>0;o--){let s=+r.slice(0,o);if(s>0&&s<t.match.length)return t.match[s]+r.slice(o)}return n})}matchAll(t,n){let r=er(this.spec,t,0,t.doc.length),o=[];for(;!r.next().done;){if(o.length>=n)return null;o.push(r.value)}return o}highlight(t,n,r,o){let s=er(this.spec,t,Math.max(0,n-250),Math.min(r+250,t.doc.length));for(;!s.next().done;)o(s.value.from,s.value.to)}}const oo=Oi.define(),ed=Oi.define(),tn=Nf.define({create(e){return new ja(zl(e).create(),null)},update(e,t){for(let n of t.effects)n.is(oo)?e=new ja(n.value.create(),e.panel):n.is(ed)&&(e=new ja(e.query,n.value?td:null));return e},provide:e=>hI.from(e,t=>t.panel)});class ja{constructor(t,n){this.query=t,this.panel=n}}const M0=mn.mark({class:"cm-searchMatch"}),b0=mn.mark({class:"cm-searchMatch cm-searchMatch-selected"}),P0=CI.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(tn))}update(e){let t=e.state.field(tn);(t!=e.startState.field(tn)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return mn.none;let{view:n}=this,r=new xI;for(let o=0,s=n.visibleRanges,a=s.length;o<a;o++){let{from:l,to:c}=s[o];for(;o<a-1&&c>s[o+1].from-500;)c=s[++o].to;e.highlight(n.state,l,c,(d,E)=>{let u=n.state.selection.ranges.some(T=>T.from==d&&T.to==E);r.add(d,E,u?b0:M0)})}return r.finish()}},{decorations:e=>e.decorations});function Lo(e){return t=>{let n=t.state.field(tn,!1);return n&&n.query.spec.valid?e(t,n):tp(t)}}const ni=Lo((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let o=ut.single(r.from,r.to),s=e.state.facet(Bn);return e.dispatch({selection:o,effects:[nd(e,r),s.scrollToMatch(o.main,e)],userEvent:"select.search"}),ep(e),!0}),ri=Lo((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,o=t.prevMatch(n,r,r);if(!o)return!1;let s=ut.single(o.from,o.to),a=e.state.facet(Bn);return e.dispatch({selection:s,effects:[nd(e,o),a.scrollToMatch(s.main,e)],userEvent:"select.search"}),ep(e),!0}),v0=Lo((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:ut.create(n.map(r=>ut.range(r.from,r.to))),userEvent:"select.search.matches"}),!0)}),U0=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:o}=n.main,s=[],a=0;for(let l=new ro(e.doc,e.sliceDoc(r,o));!l.next().done;){if(s.length>1e3)return!1;l.value.from==r&&(a=s.length),s.push(ut.range(l.value.from,l.value.to))}return t(e.update({selection:ut.create(s,a),userEvent:"select.search.matches"})),!0},GE=Lo((e,{query:t})=>{let{state:n}=e,{from:r,to:o}=n.selection.main;if(n.readOnly)return!1;let s=t.nextMatch(n,r,r);if(!s)return!1;let a=s,l=[],c,d,E=[];a.from==r&&a.to==o&&(d=n.toText(t.getReplacement(a)),l.push({from:a.from,to:a.to,insert:d}),a=t.nextMatch(n,a.from,a.to),E.push(Ge.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+".")));let u=e.state.changes(l);return a&&(c=ut.single(a.from,a.to).map(u),E.push(nd(e,a)),E.push(n.facet(Bn).scrollToMatch(c.main,e))),e.dispatch({changes:u,selection:c,effects:E,userEvent:"input.replace"}),!0}),w0=Lo((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map(o=>{let{from:s,to:a}=o;return{from:s,to:a,insert:t.getReplacement(o)}});if(!n.length)return!1;let r=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:Ge.announce.of(r),userEvent:"input.replace.all"}),!0});function td(e){return e.state.facet(Bn).createPanel(e)}function zl(e,t){var n,r,o,s,a;let l=e.selection.main,c=l.empty||l.to>l.from+100?"":e.sliceDoc(l.from,l.to);if(t&&!c)return t;let d=e.facet(Bn);return new qR({search:((n=t==null?void 0:t.literal)!==null&&n!==void 0?n:d.literal)?c:c.replace(/\n/g,"\\n"),caseSensitive:(r=t==null?void 0:t.caseSensitive)!==null&&r!==void 0?r:d.caseSensitive,literal:(o=t==null?void 0:t.literal)!==null&&o!==void 0?o:d.literal,regexp:(s=t==null?void 0:t.regexp)!==null&&s!==void 0?s:d.regexp,wholeWord:(a=t==null?void 0:t.wholeWord)!==null&&a!==void 0?a:d.wholeWord})}function ZR(e){let t=If(e,td);return t&&t.dom.querySelector("[main-field]")}function ep(e){let t=ZR(e);t&&t==e.root.activeElement&&t.select()}const tp=e=>{let t=e.state.field(tn,!1);if(t&&t.panel){let n=ZR(e);if(n&&n!=e.root.activeElement){let r=zl(e.state,t.query.spec);r.valid&&e.dispatch({effects:oo.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[ed.of(!0),t?oo.of(zl(e.state,t.query.spec)):Oi.appendConfig.of(Jl)]});return!0},np=e=>{let t=e.state.field(tn,!1);if(!t||!t.panel)return!1;let n=If(e,td);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:ed.of(!1)}),!0},B0=[{key:"Mod-f",run:tp,scope:"editor search-panel"},{key:"F3",run:ni,shift:ri,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:ni,shift:ri,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:np,scope:"editor search-panel"},{key:"Mod-Shift-l",run:U0},{key:"Mod-Alt-g",run:I0},{key:"Mod-d",run:m0,preventDefault:!0}];class F0{constructor(t){this.view=t;let n=this.query=t.state.field(tn).query.spec;this.commit=this.commit.bind(this),this.searchField=Ze("input",{value:n.search,placeholder:Ve(t,"Find"),"aria-label":Ve(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Ze("input",{value:n.replace,placeholder:Ve(t,"Replace"),"aria-label":Ve(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Ze("input",{type:"checkbox",name:"case",form:"",checked:n.caseSensitive,onchange:this.commit}),this.reField=Ze("input",{type:"checkbox",name:"re",form:"",checked:n.regexp,onchange:this.commit}),this.wordField=Ze("input",{type:"checkbox",name:"word",form:"",checked:n.wholeWord,onchange:this.commit});function r(o,s,a){return Ze("button",{class:"cm-button",name:o,onclick:s,type:"button"},a)}this.dom=Ze("div",{onkeydown:o=>this.keydown(o),class:"cm-search"},[this.searchField,r("next",()=>ni(t),[Ve(t,"next")]),r("prev",()=>ri(t),[Ve(t,"previous")]),r("select",()=>v0(t),[Ve(t,"all")]),Ze("label",null,[this.caseField,Ve(t,"match case")]),Ze("label",null,[this.reField,Ve(t,"regexp")]),Ze("label",null,[this.wordField,Ve(t,"by word")]),...t.state.readOnly?[]:[Ze("br"),this.replaceField,r("replace",()=>GE(t),[Ve(t,"replace")]),r("replaceAll",()=>w0(t),[Ve(t,"replace all")])],Ze("button",{name:"close",onclick:()=>np(t),"aria-label":Ve(t,"close"),type:"button"},["×"])])}commit(){let t=new qR({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});t.eq(this.query)||(this.query=t,this.view.dispatch({effects:oo.of(t)}))}keydown(t){yI(this.view,t,"search-panel")?t.preventDefault():t.keyCode==13&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?ri:ni)(this.view)):t.keyCode==13&&t.target==this.replaceField&&(t.preventDefault(),GE(this.view))}update(t){for(let n of t.transactions)for(let r of n.effects)r.is(oo)&&!r.value.eq(this.query)&&this.setQuery(r.value)}setQuery(t){this.query=t,this.searchField.value=t.search,this.replaceField.value=t.replace,this.caseField.checked=t.caseSensitive,this.reField.checked=t.regexp,this.wordField.checked=t.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Bn).top}}function Ve(e,t){return e.state.phrase(t)}const Es=30,us=/[\s\.,:;?!]/;function nd(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),o=e.state.doc.lineAt(n).to,s=Math.max(r.from,t-Es),a=Math.min(o,n+Es),l=e.state.sliceDoc(s,a);if(s!=r.from){for(let c=0;c<Es;c++)if(!us.test(l[c+1])&&us.test(l[c])){l=l.slice(c);break}}if(a!=o){for(let c=l.length-1;c>l.length-Es;c--)if(!us.test(l[c-1])&&us.test(l[c])){l=l.slice(0,c);break}}return Ge.announce.of(`${e.state.phrase("current match")}. ${l} ${e.state.phrase("on line")} ${r.number}.`)}const G0=Ge.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),Jl=[tn,II.low(P0),G0],H0=3e4,oi="application/dql-semantic-ref";let Ts=[],HE=0,so=null;function k0(e){J.trackUsage(e),window.dispatchEvent(new CustomEvent("dql:semantic-used",{detail:{name:e}}))}async function kE(){if(Date.now()<HE&&Ts.length>0)return Ts;const e=await fetch(`${window.location.origin}/api/semantic-completions`);if(!e.ok)throw new Error(`Failed to load semantic completions: HTTP ${e.status}`);const t=await e.json();return Ts=Array.isArray(t.completions)?t.completions:[],HE=Date.now()+H0,Ts}function rp(e,t,n){const r=n??e.state.selection.main.from;e.dispatch({changes:{from:r,to:n??e.state.selection.main.to,insert:t},selection:{anchor:r+t.length}}),e.focus()}function j0(e){so=e}function Y0(e){so===e&&(so=null)}function W0(e){return so?(rp(so,e),!0):!1}function V0(e,t,n){const r=n?e.posAtCoords(n)??e.state.selection.main.from:e.state.selection.main.from;rp(e,t,r)}function jE(e,t,n){return{label:e.name,detail:e.type==="metric"?"@metric":"@dim",type:e.type==="metric"?"function":"variable",info:`${e.label}${e.description?`
|
|
603
603
|
${e.description}`:""}${e.sql?`
|
|
604
|
-
${e.sql}`:""}`,apply(r){const s=r.state.sliceDoc(n,n+1)===")"?e.name:`${e.name})`;r.dispatch({changes:{from:t,to:n,insert:s},selection:{anchor:t+s.length}}),k0(e.name)}}}function $0(e){return{from:e,options:[{label:"@metric(",detail:"semantic metric",type:"function",apply(t,n,r,o){t.dispatch({changes:{from:r,to:o,insert:"@metric("},selection:{anchor:r+8}})}},{label:"@dim(",detail:"semantic dimension",type:"function",apply(t,n,r,o){t.dispatch({changes:{from:r,to:o,insert:"@dim("},selection:{anchor:r+5}})}}]}}const X0=async e=>{const{state:t,pos:n}=e,r=t.sliceDoc(Math.max(0,n-120),n),o=/@metric\(([^)]*)$/i.exec(r);if(o){const l=o[1].trim().toLowerCase(),c=n-o[1].length,d=(await kE()).filter(E=>E.type==="metric").filter(E=>!l||E.name.toLowerCase().includes(l)||E.label.toLowerCase().includes(l)||(E.domain??"").toLowerCase().includes(l)||E.tags.some(u=>u.toLowerCase().includes(l))).slice(0,50);return{from:c,options:d.map(E=>jE(E,c,n)),validFor:/^[\w-]*$/}}const s=/@dim\(([^)]*)$/i.exec(r);if(s){const l=s[1].trim().toLowerCase(),c=n-s[1].length,d=(await kE()).filter(E=>E.type==="dimension").filter(E=>!l||E.name.toLowerCase().includes(l)||E.label.toLowerCase().includes(l)||(E.domain??"").toLowerCase().includes(l)||E.tags.some(u=>u.toLowerCase().includes(l))).slice(0,50);return{from:c,options:d.map(E=>jE(E,c,n)),validFor:/^[\w-]*$/}}const a=/@([md][a-z_]*)?$/i.exec(r);return a?$0(n-a[0].length):(e.explicit,null)};function op(e){if(!e)return null;try{const t=JSON.parse(e);return(t.type==="metric"||t.type==="dimension")&&t.name&&t.reference?{type:t.type,name:t.name,reference:t.reference}:null}catch{return null}}function K0(e){const t=e.match(/LINE\s+(\d+)/i);if(t){const o=parseInt(t[1],10),s=e.match(/\n(\s*)\^/),a=s?s[1].length+1:1;return{line:o,col:a}}const n=e.match(/at line\s+(\d+),?\s*column\s+(\d+)/i);if(n)return{line:parseInt(n[1],10),col:parseInt(n[2],10)};const r=e.match(/line\s+(\d+)/i);return r?{line:parseInt(r[1],10),col:1}:null}const Ps=Oi.define(),z0=Nf.define({create(){return mn.none},update(e,t){for(const n of t.effects)if(n.is(Ps)){if(!n.value)return mn.none;const{from:r,to:o,message:s}=n.value;return mn.set([mn.mark({class:"cm-sql-error",attributes:{title:s}}).range(r,o)])}return e},provide:e=>Ge.decorations.from(e)}),J0=_I.define([{tag:me.keyword,color:"var(--sql-keyword)",fontWeight:"600"},{tag:[me.controlKeyword,me.moduleKeyword],color:"var(--sql-keyword)",fontWeight:"600"},{tag:[me.string,me.special(me.string)],color:"var(--sql-string)"},{tag:me.number,color:"var(--sql-number)"},{tag:me.bool,color:"var(--sql-number)",fontWeight:"600"},{tag:me.null,color:"var(--sql-number)",fontWeight:"600"},{tag:[me.comment,me.lineComment,me.blockComment,me.docComment],color:"var(--sql-comment)",fontStyle:"italic"},{tag:[me.function(me.variableName),me.function(me.propertyName)],color:"var(--sql-function)"},{tag:[me.typeName,me.className],color:"var(--sql-type)"},{tag:me.operator,color:"var(--sql-punctuation)"},{tag:me.punctuation,color:"var(--sql-punctuation)"},{tag:me.bracket,color:"var(--sql-punctuation)"},{tag:[me.variableName,me.name,me.propertyName,me.attributeName],color:"var(--sql-ident)"},{tag:me.invalid,color:"var(--color-status-error)"}]),q0=Ge.baseTheme({".cm-sql-error":{textDecoration:"underline wavy var(--color-status-error)",textUnderlineOffset:"3px",background:"color-mix(in srgb, var(--color-status-error) 10%, transparent)"}});function sp(e){return Ge.theme({"&":{background:"var(--color-bg-sunken)",color:"var(--color-text-primary)"},".cm-content":{caretColor:"var(--color-text-primary)"},".cm-cursor":{borderLeftColor:"var(--color-text-primary)"},".cm-selectionBackground":{background:"color-mix(in srgb, var(--color-accent-blue) 30%, transparent)"},"&.cm-focused .cm-selectionBackground":{background:"color-mix(in srgb, var(--color-accent-blue) 30%, transparent)"},".cm-gutters":{background:"var(--color-bg-sunken)",color:"var(--color-text-tertiary)",border:"none",borderRight:"1px solid var(--color-border-subtle)"},".cm-activeLineGutter":{background:"var(--color-bg-hover)"},".cm-activeLine":{background:"var(--color-bg-hover)"},".cm-matchingBracket":{background:"color-mix(in srgb, var(--color-accent-blue) 18%, transparent)",outline:"1px solid var(--color-accent-blue)"},".cm-foldPlaceholder":{background:"var(--color-bg-tertiary)",border:"1px solid var(--color-border-subtle)",color:"var(--color-text-secondary)",borderRadius:3,padding:"0 4px"},".cm-tooltip":{background:"var(--color-bg-card)",border:"1px solid var(--color-border-primary)",color:"var(--color-text-primary)",borderRadius:6,boxShadow:"0 4px 12px color-mix(in srgb, var(--color-bg-primary) 40%, transparent)"},".cm-tooltip.cm-tooltip-autocomplete":{"& > ul > li":{padding:"3px 8px"},"& > ul > li[aria-selected]":{background:"color-mix(in srgb, var(--color-accent-blue) 20%, transparent)",color:"var(--color-accent-blue)"}},".cm-searchMatch":{background:"color-mix(in srgb, var(--color-status-warning) 25%, transparent)",outline:"1px solid var(--color-status-warning)"},".cm-searchMatch.cm-searchMatch-selected":{background:"color-mix(in srgb, var(--color-status-warning) 50%, transparent)"},".cm-panels":{background:"var(--color-bg-secondary)",borderTop:"1px solid var(--color-border-subtle)"},".cm-panel":{padding:"6px 8px"},".cm-panel input":{background:"var(--color-bg-sunken)",border:"1px solid var(--color-border-subtle)",color:"var(--color-text-primary)",borderRadius:4,padding:"2px 6px",fontSize:12},".cm-panel button":{background:"var(--color-bg-tertiary)",border:"1px solid var(--color-border-subtle)",color:"var(--color-text-primary)",borderRadius:4,padding:"2px 8px",cursor:"pointer",fontSize:12,marginLeft:4}},{dark:e})}const Q0=sp(!0),Z0=sp(!1);function eD(e){return e==="midnight"||e==="obsidian"||e==="dark"}function rd({value:e,onChange:t,onRun:n,themeMode:r,autoFocus:o,schema:s,errorMessage:a,editorRef:l,wrap:c=!0}){const d=ie[r],E=S.useRef(null),u=S.useRef(null),[T,f]=S.useState(!1),h=S.useRef(n),A=S.useRef(t),R=S.useRef(new DI);return h.current=n,A.current=t,S.useEffect(()=>{l&&(l.current={undo:()=>{u.current&&bI(u.current)},redo:()=>{u.current&&MI(u.current)},resetTo:p=>{const N=u.current;N&&N.dispatch({changes:{from:0,to:N.state.doc.length,insert:p}})}})}),S.useEffect(()=>{if(!E.current)return;const p=PI.of([{key:"Shift-Enter",run:()=>(h.current(),!0)},{key:"Ctrl-Enter",mac:"Cmd-Enter",run:()=>(h.current(),!0)},{key:"Ctrl-/",mac:"Cmd-/",run:vI},UI,...wI,...BI,...FI,...B0,...GI,...HI]),N=Ge.updateListener.of(x=>{x.docChanged&&A.current(x.state.doc.toString())}),I=Ge.domEventHandlers({focus:(x,w)=>{j0(w)},blur:(x,w)=>{Y0(w)}}),O=Ge.theme({"&":{background:
|
|
605
|
-
`),r=[];let o=0;for(;o<n.length;){const s=n[o],a=s.match(/^(#{1,6})\s+(.+)$/);if(a){const l=a[1].length,c=a[2],E=[28,22,18,16,14,13][l-1];r.push(i.jsx("div",{style:{fontSize:E,fontWeight:l<=2?700:600,color:t.textPrimary,fontFamily:t.font,lineHeight:1.3,marginBottom:l===1?12:8,marginTop:o>0?l===1?16:10:0,borderBottom:l===1?`1px solid ${t.cellBorder}`:void 0,paddingBottom:l===1?8:void 0},children:Gr(c,t)},o)),o++;continue}if(/^[-*_]{3,}$/.test(s.trim())){r.push(i.jsx("hr",{style:{border:"none",borderTop:`1px solid ${t.cellBorder}`,margin:"12px 0"}},o)),o++;continue}if(s.startsWith("> ")){r.push(i.jsx("div",{style:{borderLeft:`3px solid ${t.textMuted}`,paddingLeft:12,marginLeft:4,color:t.textSecondary,fontStyle:"italic",fontFamily:t.fontSerif,fontSize:14},children:Gr(s.slice(2),t)},o)),o++;continue}if(s.startsWith("```")){const l=[];for(o++;o<n.length&&!n[o].startsWith("```");)l.push(n[o]),o++;r.push(i.jsx("pre",{style:{background:
|
|
606
|
-
`)},o)),o++;continue}if(/^[-*+]\s/.test(s)){const l=o,c=[];for(;o<n.length&&/^[-*+]\s/.test(n[o]);)c.push(n[o].replace(/^[-*+]\s/,"")),o++;r.push(i.jsx("ul",{style:{paddingLeft:20,marginBottom:8,color:t.textSecondary},children:c.map((d,E)=>i.jsx("li",{style:{fontSize:14,fontFamily:t.font,lineHeight:1.6,marginBottom:2},children:Gr(d,t)},E))},`ul-${l}`));continue}if(/^\d+\.\s/.test(s)){const l=o,c=[];for(;o<n.length&&/^\d+\.\s/.test(n[o]);)c.push(n[o].replace(/^\d+\.\s/,"")),o++;r.push(i.jsx("ol",{style:{paddingLeft:20,marginBottom:8,color:t.textSecondary},children:c.map((d,E)=>i.jsx("li",{style:{fontSize:14,fontFamily:t.font,lineHeight:1.6,marginBottom:2},children:Gr(d,t)},E))},`ol-${l}`));continue}if(!s.trim()){r.push(i.jsx("div",{style:{height:8}},o)),o++;continue}r.push(i.jsx("p",{style:{fontSize:14,lineHeight:1.7,fontFamily:t.fontSerif,color:t.textSecondary,marginBottom:6},children:Gr(s,t)},o)),o++}return r}function Gr(e,t){const n=[];let r=e,o=0;for(;r.length>0;){const s=r.match(/\*{3}(.+?)\*{3}/),a=r.match(/\*{2}(.+?)\*{2}/),l=r.match(/\*(.+?)\*/),c=r.match(/`(.+?)`/),d=r.match(/\[(.+?)\]\((.+?)\)/),E=[s?{match:s,type:"boldItalic"}:null,a?{match:a,type:"bold"}:null,l?{match:l,type:"italic"}:null,c?{match:c,type:"code"}:null,d?{match:d,type:"link"}:null].filter(Boolean);if(E.length===0){n.push(i.jsx(ye.Fragment,{children:r},o++));break}const u=E.reduce((f,h)=>(f.match.index??0)<(h.match.index??0)?f:h),T=u.match.index??0;switch(T>0&&n.push(i.jsx(ye.Fragment,{children:r.slice(0,T)},o++)),u.type){case"boldItalic":n.push(i.jsx("strong",{style:{fontStyle:"italic"},children:u.match[1]},o++));break;case"bold":n.push(i.jsx("strong",{children:u.match[1]},o++));break;case"italic":n.push(i.jsx("em",{children:u.match[1]},o++));break;case"code":n.push(i.jsx("code",{style:{background:
|
|
604
|
+
${e.sql}`:""}`,apply(r){const s=r.state.sliceDoc(n,n+1)===")"?e.name:`${e.name})`;r.dispatch({changes:{from:t,to:n,insert:s},selection:{anchor:t+s.length}}),k0(e.name)}}}function $0(e){return{from:e,options:[{label:"@metric(",detail:"semantic metric",type:"function",apply(t,n,r,o){t.dispatch({changes:{from:r,to:o,insert:"@metric("},selection:{anchor:r+8}})}},{label:"@dim(",detail:"semantic dimension",type:"function",apply(t,n,r,o){t.dispatch({changes:{from:r,to:o,insert:"@dim("},selection:{anchor:r+5}})}}]}}const X0=async e=>{const{state:t,pos:n}=e,r=t.sliceDoc(Math.max(0,n-120),n),o=/@metric\(([^)]*)$/i.exec(r);if(o){const l=o[1].trim().toLowerCase(),c=n-o[1].length,d=(await kE()).filter(E=>E.type==="metric").filter(E=>!l||E.name.toLowerCase().includes(l)||E.label.toLowerCase().includes(l)||(E.domain??"").toLowerCase().includes(l)||E.tags.some(u=>u.toLowerCase().includes(l))).slice(0,50);return{from:c,options:d.map(E=>jE(E,c,n)),validFor:/^[\w-]*$/}}const s=/@dim\(([^)]*)$/i.exec(r);if(s){const l=s[1].trim().toLowerCase(),c=n-s[1].length,d=(await kE()).filter(E=>E.type==="dimension").filter(E=>!l||E.name.toLowerCase().includes(l)||E.label.toLowerCase().includes(l)||(E.domain??"").toLowerCase().includes(l)||E.tags.some(u=>u.toLowerCase().includes(l))).slice(0,50);return{from:c,options:d.map(E=>jE(E,c,n)),validFor:/^[\w-]*$/}}const a=/@([md][a-z_]*)?$/i.exec(r);return a?$0(n-a[0].length):(e.explicit,null)};function op(e){if(!e)return null;try{const t=JSON.parse(e);return(t.type==="metric"||t.type==="dimension")&&t.name&&t.reference?{type:t.type,name:t.name,reference:t.reference}:null}catch{return null}}function K0(e){const t=e.match(/LINE\s+(\d+)/i);if(t){const o=parseInt(t[1],10),s=e.match(/\n(\s*)\^/),a=s?s[1].length+1:1;return{line:o,col:a}}const n=e.match(/at line\s+(\d+),?\s*column\s+(\d+)/i);if(n)return{line:parseInt(n[1],10),col:parseInt(n[2],10)};const r=e.match(/line\s+(\d+)/i);return r?{line:parseInt(r[1],10),col:1}:null}const Ps=Oi.define(),z0=Nf.define({create(){return mn.none},update(e,t){for(const n of t.effects)if(n.is(Ps)){if(!n.value)return mn.none;const{from:r,to:o,message:s}=n.value;return mn.set([mn.mark({class:"cm-sql-error",attributes:{title:s}}).range(r,o)])}return e},provide:e=>Ge.decorations.from(e)}),J0=_I.define([{tag:me.keyword,color:"var(--sql-keyword)",fontWeight:"600"},{tag:[me.controlKeyword,me.moduleKeyword],color:"var(--sql-keyword)",fontWeight:"600"},{tag:[me.string,me.special(me.string)],color:"var(--sql-string)"},{tag:me.number,color:"var(--sql-number)"},{tag:me.bool,color:"var(--sql-number)",fontWeight:"600"},{tag:me.null,color:"var(--sql-number)",fontWeight:"600"},{tag:[me.comment,me.lineComment,me.blockComment,me.docComment],color:"var(--sql-comment)",fontStyle:"italic"},{tag:[me.function(me.variableName),me.function(me.propertyName)],color:"var(--sql-function)"},{tag:[me.typeName,me.className],color:"var(--sql-type)"},{tag:me.operator,color:"var(--sql-punctuation)"},{tag:me.punctuation,color:"var(--sql-punctuation)"},{tag:me.bracket,color:"var(--sql-punctuation)"},{tag:[me.variableName,me.name,me.propertyName,me.attributeName],color:"var(--sql-ident)"},{tag:me.invalid,color:"var(--color-status-error)"}]),q0=Ge.baseTheme({".cm-sql-error":{textDecoration:"underline wavy var(--color-status-error)",textUnderlineOffset:"3px",background:"color-mix(in srgb, var(--color-status-error) 10%, transparent)"}});function sp(e){return Ge.theme({"&":{background:"var(--color-bg-sunken)",color:"var(--color-text-primary)"},".cm-content":{caretColor:"var(--color-text-primary)"},".cm-cursor":{borderLeftColor:"var(--color-text-primary)"},".cm-selectionBackground":{background:"color-mix(in srgb, var(--color-accent-blue) 30%, transparent)"},"&.cm-focused .cm-selectionBackground":{background:"color-mix(in srgb, var(--color-accent-blue) 30%, transparent)"},".cm-gutters":{background:"var(--color-bg-sunken)",color:"var(--color-text-tertiary)",border:"none",borderRight:"1px solid var(--color-border-subtle)"},".cm-activeLineGutter":{background:"var(--color-bg-hover)"},".cm-activeLine":{background:"var(--color-bg-hover)"},".cm-matchingBracket":{background:"color-mix(in srgb, var(--color-accent-blue) 18%, transparent)",outline:"1px solid var(--color-accent-blue)"},".cm-foldPlaceholder":{background:"var(--color-bg-tertiary)",border:"1px solid var(--color-border-subtle)",color:"var(--color-text-secondary)",borderRadius:3,padding:"0 4px"},".cm-tooltip":{background:"var(--color-bg-card)",border:"1px solid var(--color-border-primary)",color:"var(--color-text-primary)",borderRadius:6,boxShadow:"0 4px 12px color-mix(in srgb, var(--color-bg-primary) 40%, transparent)"},".cm-tooltip.cm-tooltip-autocomplete":{"& > ul > li":{padding:"3px 8px"},"& > ul > li[aria-selected]":{background:"color-mix(in srgb, var(--color-accent-blue) 20%, transparent)",color:"var(--color-accent-blue)"}},".cm-searchMatch":{background:"color-mix(in srgb, var(--color-status-warning) 25%, transparent)",outline:"1px solid var(--color-status-warning)"},".cm-searchMatch.cm-searchMatch-selected":{background:"color-mix(in srgb, var(--color-status-warning) 50%, transparent)"},".cm-panels":{background:"var(--color-bg-secondary)",borderTop:"1px solid var(--color-border-subtle)"},".cm-panel":{padding:"6px 8px"},".cm-panel input":{background:"var(--color-bg-sunken)",border:"1px solid var(--color-border-subtle)",color:"var(--color-text-primary)",borderRadius:4,padding:"2px 6px",fontSize:12},".cm-panel button":{background:"var(--color-bg-tertiary)",border:"1px solid var(--color-border-subtle)",color:"var(--color-text-primary)",borderRadius:4,padding:"2px 8px",cursor:"pointer",fontSize:12,marginLeft:4}},{dark:e})}const Q0=sp(!0),Z0=sp(!1);function eD(e){return e==="midnight"||e==="obsidian"||e==="dark"}function rd({value:e,onChange:t,onRun:n,themeMode:r,autoFocus:o,schema:s,errorMessage:a,editorRef:l,wrap:c=!0}){const d=ie[r],E=S.useRef(null),u=S.useRef(null),[T,f]=S.useState(!1),h=S.useRef(n),A=S.useRef(t),R=S.useRef(new DI);return h.current=n,A.current=t,S.useEffect(()=>{l&&(l.current={undo:()=>{u.current&&bI(u.current)},redo:()=>{u.current&&MI(u.current)},resetTo:p=>{const N=u.current;N&&N.dispatch({changes:{from:0,to:N.state.doc.length,insert:p}})}})}),S.useEffect(()=>{if(!E.current)return;const p=PI.of([{key:"Shift-Enter",run:()=>(h.current(),!0)},{key:"Ctrl-Enter",mac:"Cmd-Enter",run:()=>(h.current(),!0)},{key:"Ctrl-/",mac:"Cmd-/",run:vI},UI,...wI,...BI,...FI,...B0,...GI,...HI]),N=Ge.updateListener.of(x=>{x.docChanged&&A.current(x.state.doc.toString())}),I=Ge.domEventHandlers({focus:(x,w)=>{j0(w)},blur:(x,w)=>{Y0(w)}}),O=Ge.theme({"&":{background:"var(--color-bg-surface)",color:"var(--color-text-primary)",fontFamily:"var(--font-mono)",fontSize:"13px",minHeight:"80px",maxHeight:"480px"},".cm-scroller":{overflow:"auto",fontFamily:"inherit"},".cm-content":{padding:"10px 0",minHeight:"80px",color:"var(--color-text-primary)"},".cm-focused":{outline:"none"},".cm-editor":{border:"none"},".cm-gutters":{minWidth:40},".cm-foldGutter":{cursor:"pointer"}}),C=s?ns({schema:s,upperCaseKeywords:!1}):ns({upperCaseKeywords:!1}),m=[p,N,I,O,R.current.of(C),kI({closeOnBlur:!1,override:[X0]}),jI(),YI(),WI(),VI(),$I(),XI(),KI(),zI(),...c?[Ge.lineWrapping]:[],g0({top:!0}),z0,q0,JI(J0),eD(r)?Q0:Z0],g=Of.create({doc:e,extensions:m}),y=new Ge({state:g,parent:E.current});return u.current=y,o&&y.focus(),()=>{y.destroy(),u.current=null}},[r]),S.useEffect(()=>{const p=u.current;if(!p)return;const N=s?ns({schema:s,upperCaseKeywords:!1}):ns({upperCaseKeywords:!1});p.dispatch({effects:R.current.reconfigure(N)})},[s]),S.useEffect(()=>{const p=u.current;if(!p)return;const N=p.state.doc.toString();N!==e&&p.dispatch({changes:{from:0,to:N.length,insert:e}})},[e]),S.useEffect(()=>{const p=u.current;if(!p)return;if(!a){p.dispatch({effects:Ps.of(null)});return}const N=K0(a),I=p.state.doc;if(N&&N.line>=1&&N.line<=I.lines){const O=I.line(N.line),C=O.from+Math.max(0,N.col-1),m=Math.max(C+1,O.to);p.dispatch({effects:Ps.of({from:Math.min(C,I.length),to:Math.min(m,I.length),message:a})})}else if(I.lines>=1){const O=I.line(1);p.dispatch({effects:Ps.of({from:O.from,to:Math.max(O.from+1,O.to),message:a})})}},[a]),i.jsx("div",{onDragOver:p=>{p.dataTransfer.types.includes(oi)&&(p.preventDefault(),f(!0))},onDragLeave:()=>f(!1),onDrop:p=>{const N=u.current;if(!N)return;const I=op(p.dataTransfer.getData(oi));I&&(p.preventDefault(),f(!1),V0(N,I.reference,{x:p.clientX,y:p.clientY}),J.trackUsage(I.name),window.dispatchEvent(new CustomEvent("dql:semantic-used",{detail:{name:I.name}})))},style:{background:"var(--color-bg-surface)",minHeight:80,border:T?`1px solid ${d.accent}`:"1px solid transparent",borderRadius:6,transition:"border-color 0.15s"},children:i.jsx("div",{ref:E,style:{minHeight:80}})})}rd.displayName="SQLCellEditor";function tD(e,t){const n=e.split(`
|
|
605
|
+
`),r=[];let o=0;for(;o<n.length;){const s=n[o],a=s.match(/^(#{1,6})\s+(.+)$/);if(a){const l=a[1].length,c=a[2],E=[28,22,18,16,14,13][l-1];r.push(i.jsx("div",{style:{fontSize:E,fontWeight:l<=2?700:600,color:t.textPrimary,fontFamily:t.font,lineHeight:1.3,marginBottom:l===1?12:8,marginTop:o>0?l===1?16:10:0,borderBottom:l===1?`1px solid ${t.cellBorder}`:void 0,paddingBottom:l===1?8:void 0},children:Gr(c,t)},o)),o++;continue}if(/^[-*_]{3,}$/.test(s.trim())){r.push(i.jsx("hr",{style:{border:"none",borderTop:`1px solid ${t.cellBorder}`,margin:"12px 0"}},o)),o++;continue}if(s.startsWith("> ")){r.push(i.jsx("div",{style:{borderLeft:`3px solid ${t.textMuted}`,paddingLeft:12,marginLeft:4,color:t.textSecondary,fontStyle:"italic",fontFamily:t.fontSerif,fontSize:14},children:Gr(s.slice(2),t)},o)),o++;continue}if(s.startsWith("```")){const l=[];for(o++;o<n.length&&!n[o].startsWith("```");)l.push(n[o]),o++;r.push(i.jsx("pre",{style:{background:"var(--color-bg-surface)",border:"1px solid var(--color-border-subtle)",borderRadius:6,padding:"10px 12px",fontSize:12,fontFamily:"var(--font-mono)",color:"var(--color-text-primary)",overflow:"auto",margin:"8px 0",lineHeight:1.6},children:l.join(`
|
|
606
|
+
`)},o)),o++;continue}if(/^[-*+]\s/.test(s)){const l=o,c=[];for(;o<n.length&&/^[-*+]\s/.test(n[o]);)c.push(n[o].replace(/^[-*+]\s/,"")),o++;r.push(i.jsx("ul",{style:{paddingLeft:20,marginBottom:8,color:t.textSecondary},children:c.map((d,E)=>i.jsx("li",{style:{fontSize:14,fontFamily:t.font,lineHeight:1.6,marginBottom:2},children:Gr(d,t)},E))},`ul-${l}`));continue}if(/^\d+\.\s/.test(s)){const l=o,c=[];for(;o<n.length&&/^\d+\.\s/.test(n[o]);)c.push(n[o].replace(/^\d+\.\s/,"")),o++;r.push(i.jsx("ol",{style:{paddingLeft:20,marginBottom:8,color:t.textSecondary},children:c.map((d,E)=>i.jsx("li",{style:{fontSize:14,fontFamily:t.font,lineHeight:1.6,marginBottom:2},children:Gr(d,t)},E))},`ol-${l}`));continue}if(!s.trim()){r.push(i.jsx("div",{style:{height:8}},o)),o++;continue}r.push(i.jsx("p",{style:{fontSize:14,lineHeight:1.7,fontFamily:t.fontSerif,color:t.textSecondary,marginBottom:6},children:Gr(s,t)},o)),o++}return r}function Gr(e,t){const n=[];let r=e,o=0;for(;r.length>0;){const s=r.match(/\*{3}(.+?)\*{3}/),a=r.match(/\*{2}(.+?)\*{2}/),l=r.match(/\*(.+?)\*/),c=r.match(/`(.+?)`/),d=r.match(/\[(.+?)\]\((.+?)\)/),E=[s?{match:s,type:"boldItalic"}:null,a?{match:a,type:"bold"}:null,l?{match:l,type:"italic"}:null,c?{match:c,type:"code"}:null,d?{match:d,type:"link"}:null].filter(Boolean);if(E.length===0){n.push(i.jsx(ye.Fragment,{children:r},o++));break}const u=E.reduce((f,h)=>(f.match.index??0)<(h.match.index??0)?f:h),T=u.match.index??0;switch(T>0&&n.push(i.jsx(ye.Fragment,{children:r.slice(0,T)},o++)),u.type){case"boldItalic":n.push(i.jsx("strong",{style:{fontStyle:"italic"},children:u.match[1]},o++));break;case"bold":n.push(i.jsx("strong",{children:u.match[1]},o++));break;case"italic":n.push(i.jsx("em",{children:u.match[1]},o++));break;case"code":n.push(i.jsx("code",{style:{background:"var(--color-bg-surface)",border:"1px solid var(--color-border-subtle)",borderRadius:4,padding:"1px 5px",fontSize:"0.9em",fontFamily:"var(--font-mono)",color:"var(--color-accent-blue)"},children:u.match[1]},o++));break;case"link":n.push(i.jsx("a",{href:u.match[2],target:"_blank",rel:"noopener noreferrer",style:{color:t.accent,textDecoration:"underline"},children:u.match[1]},o++));break}r=r.slice(T+u.match[0].length)}return i.jsx(i.Fragment,{children:n})}function nD({value:e,onChange:t,onRun:n,themeMode:r}){const o=ie[r],[s,a]=S.useState(!1),l=S.useRef(null);S.useEffect(()=>{if(s&&l.current){l.current.focus();const u=l.current;u.style.height="auto",u.style.height=`${Math.max(u.scrollHeight,80)}px`}},[s]);const c=()=>{a(!1)},d=u=>{if(u.key==="Escape"&&a(!1),u.key==="Enter"&&u.shiftKey&&(u.preventDefault(),a(!1),n==null||n()),u.key==="Tab"){u.preventDefault();const T=u.currentTarget,f=T.selectionStart,h=T.selectionEnd,A=e.slice(0,f)+" "+e.slice(h);t(A),requestAnimationFrame(()=>{T.selectionStart=T.selectionEnd=f+2})}},E=u=>{t(u.target.value);const T=u.target;T.style.height="auto",T.style.height=`${Math.max(T.scrollHeight,80)}px`};return s?i.jsx("textarea",{ref:l,value:e,onChange:E,onBlur:c,onKeyDown:d,placeholder:"Write markdown here...",spellCheck:!1,style:{display:"block",width:"100%",minHeight:80,padding:"12px 16px",background:o.editorBg,color:o.textPrimary,border:"none",outline:"none",resize:"none",fontFamily:o.fontMono,fontSize:13,lineHeight:"20px",borderRadius:0,caretColor:o.accent}}):e.trim()?i.jsx("div",{onDoubleClick:()=>a(!0),title:"Double-click to edit",style:{padding:"12px 16px",cursor:"text",minHeight:48},children:tD(e,o)}):i.jsx("div",{onDoubleClick:()=>a(!0),style:{padding:"12px 16px",color:o.textMuted,fontFamily:o.font,fontSize:13,fontStyle:"italic",cursor:"text",minHeight:48,display:"flex",alignItems:"center"},children:"Double-click to add markdown..."})}function rD({cell:e,themeMode:t,onApplyParam:n}){const{dispatch:r}=fe(),o=ie[t],[s,a]=S.useState(!1),l=e.paramConfig??{paramType:"text",label:"Parameter",defaultValue:"",options:[]},c=e.paramValue??l.defaultValue,d=f=>{r({type:"UPDATE_CELL",id:e.id,updates:{paramConfig:{...l,...f}}})},E=f=>{r({type:"SET_PARAM_VALUE",id:e.id,value:f})},u=(l.options??[]).map(f=>f.trim()).filter(Boolean),T=e.name?`{{${e.name}}}`:null;return i.jsxs("div",{style:{background:o.cellBg,border:`1px solid ${o.cellBorder}`,borderLeft:`3px solid ${o.warning}`,borderRadius:8,overflow:"hidden"},children:[s&&i.jsxs("div",{style:{background:o.tableHeaderBg,borderBottom:`1px solid ${o.cellBorder}`,padding:"12px 14px",display:"flex",flexDirection:"column",gap:10},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:2},children:[i.jsx("span",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.06em",color:o.warning,fontFamily:o.fontMono,textTransform:"uppercase"},children:"Configure Parameter"}),i.jsx("button",{onClick:()=>a(!1),title:"Done",style:{background:o.warning,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"})]}),i.jsxs("div",{style:{display:"flex",gap:10,flexWrap:"wrap"},children:[i.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:3,flex:"1 1 120px"},children:[i.jsx("span",{style:{fontSize:10,color:o.textMuted,fontFamily:o.font},children:"Variable name"}),i.jsx("input",{value:e.name??"",onChange:f=>r({type:"UPDATE_CELL",id:e.id,updates:{name:f.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"}})]}),i.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:3,flex:"1 1 120px"},children:[i.jsx("span",{style:{fontSize:10,color:o.textMuted,fontFamily:o.font},children:"Display label"}),i.jsx("input",{value:l.label,onChange:f=>d({label:f.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"}})]}),i.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:3,flex:"1 1 100px"},children:[i.jsx("span",{style:{fontSize:10,color:o.textMuted,fontFamily:o.font},children:"Type"}),i.jsxs("select",{value:l.paramType,onChange:f=>d({paramType:f.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:[i.jsx("option",{value:"text",children:"Text"}),i.jsx("option",{value:"number",children:"Number"}),i.jsx("option",{value:"date",children:"Date"}),i.jsx("option",{value:"select",children:"Select"})]})]}),i.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:3,flex:"1 1 120px"},children:[i.jsx("span",{style:{fontSize:10,color:o.textMuted,fontFamily:o.font},children:"Default value"}),i.jsx("input",{type:l.paramType==="number"?"number":l.paramType==="date"?"date":"text",value:l.defaultValue,onChange:f=>d({defaultValue:f.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"}})]})]}),l.paramType==="select"&&i.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:3},children:[i.jsx("span",{style:{fontSize:10,color:o.textMuted,fontFamily:o.font},children:"Options (one per line)"}),i.jsx("textarea",{value:(l.options??[]).join(`
|
|
607
607
|
`),onChange:f=>d({options:f.target.value.split(`
|
|
608
608
|
`)}),rows:4,placeholder:`Option A
|
|
609
609
|
Option B
|
|
@@ -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;800&family=JetBrains+Mono:wght@400;500;600;700&family=Kalam:wght@400;700&family=Caveat:wght@400;600;700&display=swap" rel="stylesheet" />
|
|
10
|
-
<script type="module" crossorigin src="/assets/index-
|
|
10
|
+
<script type="module" crossorigin src="/assets/index-jwFfZgBm.js"></script>
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/assets/react-CRB3T2We.js">
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/codemirror-DJYUkPr1.js">
|
|
13
13
|
<link rel="stylesheet" crossorigin href="/assets/index-DrhoZmtv.css">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duckcodeailabs/dql-cli",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.6",
|
|
4
4
|
"description": "Public CLI for parsing, formatting, testing, and certifying DQL blocks",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
"directory": "apps/cli"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@duckcodeailabs/dql-compiler": "^1.3.
|
|
23
|
-
"@duckcodeailabs/dql-connectors": "^1.3.
|
|
24
|
-
"@duckcodeailabs/dql-core": "^1.3.
|
|
25
|
-
"@duckcodeailabs/dql-governance": "^1.3.
|
|
26
|
-
"@duckcodeailabs/dql-mcp": "^1.3.
|
|
27
|
-
"@duckcodeailabs/dql-notebook": "^1.3.
|
|
28
|
-
"@duckcodeailabs/dql-project": "^1.3.
|
|
22
|
+
"@duckcodeailabs/dql-compiler": "^1.3.6",
|
|
23
|
+
"@duckcodeailabs/dql-connectors": "^1.3.6",
|
|
24
|
+
"@duckcodeailabs/dql-core": "^1.3.6",
|
|
25
|
+
"@duckcodeailabs/dql-governance": "^1.3.6",
|
|
26
|
+
"@duckcodeailabs/dql-mcp": "^1.3.6",
|
|
27
|
+
"@duckcodeailabs/dql-notebook": "^1.3.6",
|
|
28
|
+
"@duckcodeailabs/dql-project": "^1.3.6",
|
|
29
29
|
"isomorphic-git": "^1.27.0",
|
|
30
30
|
"js-yaml": "^4.1.0",
|
|
31
31
|
"node-cron": "^3.0.3",
|