@duckcodeailabs/dql-cli 1.12.2 → 1.12.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/dist/assets/dql-notebook/assets/AgentAnswerCard-BJAnjaLA.js +5 -0
  2. package/dist/assets/dql-notebook/assets/AgentLogPage-J72WR6hk.js +1 -0
  3. package/dist/assets/dql-notebook/assets/AiBuildDialog-CHJZfDmp.js +1 -0
  4. package/dist/assets/dql-notebook/assets/AiBuildResult-Da7_Cn12.js +33 -0
  5. package/dist/assets/dql-notebook/assets/AiSidePanel-BY6W_5aC.js +6 -0
  6. package/dist/assets/dql-notebook/assets/AnalyticsHome-u-buXgdv.js +6 -0
  7. package/dist/assets/dql-notebook/assets/AppsView-3k7ftDpd.js +4471 -0
  8. package/dist/assets/dql-notebook/assets/BlockStudio-CLX4EUyO.js +60 -0
  9. package/dist/assets/dql-notebook/assets/BusinessArtifactView-3THMNeyO.js +1 -0
  10. package/dist/assets/dql-notebook/assets/DbtFirstModelingPage-BwBPwtdA.js +22 -0
  11. package/dist/assets/dql-notebook/assets/GitPage-CvEki0pe.js +7 -0
  12. package/dist/assets/dql-notebook/assets/GlobalAiRail-NXdk9kNy.js +1 -0
  13. package/dist/assets/dql-notebook/assets/GovernedContextPage-DILbw-Vr.js +7 -0
  14. package/dist/assets/dql-notebook/assets/HelpDocsPage-DgCu4bvY.js +22 -0
  15. package/dist/assets/dql-notebook/assets/HomePage-CK3fXTQo.js +117 -0
  16. package/dist/assets/dql-notebook/assets/LineageDAG-DW_NO3P2.js +1 -0
  17. package/dist/assets/dql-notebook/assets/LineageDetailView-VT7DLJOB.js +1 -0
  18. package/dist/assets/dql-notebook/assets/LineageDrawer-DSTm8aXw.js +1 -0
  19. package/dist/assets/dql-notebook/assets/LineagePathBreadcrumb-DRlAYasJ.js +14 -0
  20. package/dist/assets/dql-notebook/assets/MiniLineageGraph-CR_nhwhZ.js +1 -0
  21. package/dist/assets/dql-notebook/assets/NewBlockModal-CJvjYiBF.js +1 -0
  22. package/dist/assets/dql-notebook/assets/NewNotebookModal-BEpPH93n.js +46 -0
  23. package/dist/assets/dql-notebook/assets/NotebookEditor-C7GDFwhF.js +202 -0
  24. package/dist/assets/dql-notebook/assets/ReadinessPage-rZiOp2xr.js +1 -0
  25. package/dist/assets/dql-notebook/assets/SetupOnboarding-BWjhTjPB.js +6 -0
  26. package/dist/assets/dql-notebook/assets/TrustBadge-RvZ9s6OQ.js +1 -0
  27. package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-CGPcpY1B.js +83 -0
  28. package/dist/assets/dql-notebook/assets/ai-build-bus-1BR770pY.js +1 -0
  29. package/dist/assets/dql-notebook/assets/answer-to-notebook-Di227Cd4.js +2 -0
  30. package/dist/assets/dql-notebook/assets/arrow-left-BZHDcWHR.js +6 -0
  31. package/dist/assets/dql-notebook/assets/arrow-right-DlM1pC3_.js +6 -0
  32. package/dist/assets/dql-notebook/assets/book-open-text-DBcXFQAu.js +6 -0
  33. package/dist/assets/dql-notebook/assets/bot-BAywbvPm.js +6 -0
  34. package/dist/assets/dql-notebook/assets/chevron-up-B_GfKE_F.js +6 -0
  35. package/dist/assets/dql-notebook/assets/circle-x-BcxtZ-ym.js +6 -0
  36. package/dist/assets/dql-notebook/assets/{codemirror-Co0dCEDr.js → codemirror-1_I9gm6Z.js} +1 -1
  37. package/dist/assets/dql-notebook/assets/dagre-BZV40eAE.css +1 -0
  38. package/dist/assets/dql-notebook/assets/dagre.esm-Bqs0lsEz.js +23 -0
  39. package/dist/assets/dql-notebook/assets/external-link-B24Dk9_t.js +6 -0
  40. package/dist/assets/dql-notebook/assets/grip-vertical-D9g31N3j.js +6 -0
  41. package/dist/assets/dql-notebook/assets/{index-DvLT6Kls.css → index-DKu4CZt3.css} +1 -1
  42. package/dist/assets/dql-notebook/assets/index-DU7j3Sqk.js +644 -0
  43. package/dist/assets/dql-notebook/assets/link-2-B36oR5Bj.js +6 -0
  44. package/dist/assets/dql-notebook/assets/list-tree-B9ZzGc4U.js +6 -0
  45. package/dist/assets/dql-notebook/assets/maximize-2-BrvQLPoj.js +6 -0
  46. package/dist/assets/dql-notebook/assets/minimize-2-BrpFmsxS.js +6 -0
  47. package/dist/assets/dql-notebook/assets/panel-right-open-B1g1qhh5.js +6 -0
  48. package/dist/assets/dql-notebook/assets/pencil-DwywbTqQ.js +6 -0
  49. package/dist/assets/dql-notebook/assets/{react-BRY8hXab.js → react-CRB3T2We.js} +2 -2
  50. package/dist/assets/dql-notebook/assets/rotate-ccw-Db_KVs3J.js +6 -0
  51. package/dist/assets/dql-notebook/assets/semantic-fields-BIVuvP2l.js +3 -0
  52. package/dist/assets/dql-notebook/assets/triangle-alert-Cne6C2aG.js +6 -0
  53. package/dist/assets/dql-notebook/assets/usePersistedAgentThreadId-D6mtrJ-_.js +18 -0
  54. package/dist/assets/dql-notebook/assets/user-round-DkzxN1xD.js +11 -0
  55. package/dist/assets/dql-notebook/assets/wand-sparkles-CJUvFtur.js +6 -0
  56. package/dist/assets/dql-notebook/assets/workflow-BOvVTg7R.js +6 -0
  57. package/dist/assets/dql-notebook/assets/wrench-YeSpzZRt.js +6 -0
  58. package/dist/assets/dql-notebook/assets/x-C6tsHUR7.js +6 -0
  59. package/dist/assets/dql-notebook/index.html +3 -4
  60. package/dist/block-invocation.js +4 -0
  61. package/dist/block-invocation.js.map +1 -1
  62. package/dist/llm/answer-loop-tools.d.ts +8 -2
  63. package/dist/llm/answer-loop-tools.d.ts.map +1 -1
  64. package/dist/llm/answer-loop-tools.js +29 -2
  65. package/dist/llm/answer-loop-tools.js.map +1 -1
  66. package/dist/llm/providers/dql-agent-provider.d.ts +27 -1
  67. package/dist/llm/providers/dql-agent-provider.d.ts.map +1 -1
  68. package/dist/llm/providers/dql-agent-provider.js +79 -15
  69. package/dist/llm/providers/dql-agent-provider.js.map +1 -1
  70. package/dist/llm/types.d.ts +8 -1
  71. package/dist/llm/types.d.ts.map +1 -1
  72. package/dist/local-runtime.d.ts +56 -2
  73. package/dist/local-runtime.d.ts.map +1 -1
  74. package/dist/local-runtime.js +735 -104
  75. package/dist/local-runtime.js.map +1 -1
  76. package/dist/package.json +10 -10
  77. package/dist/sql-result-filter.d.ts +39 -0
  78. package/dist/sql-result-filter.d.ts.map +1 -0
  79. package/dist/sql-result-filter.js +256 -0
  80. package/dist/sql-result-filter.js.map +1 -0
  81. package/dist/warehouse-metadata.d.ts +1 -1
  82. package/dist/warehouse-metadata.d.ts.map +1 -1
  83. package/dist/warehouse-metadata.js +2 -2
  84. package/dist/warehouse-metadata.js.map +1 -1
  85. package/package.json +10 -10
  86. package/dist/assets/dql-notebook/assets/index-BRCtmVPa.js +0 -5952
@@ -0,0 +1,117 @@
1
+ import{r as c,a as q,j as e,u as Be,t as Ye,S as Ie,B as ue,C as ot,c as Je,b as rt,d as st,L as at,e as lt,G as Ne,D as be,N as dt,F as ct,f as pt}from"./index-DU7j3Sqk.js";import{T as xt}from"./TrustBadge-RvZ9s6OQ.js";import{A as he}from"./arrow-right-DlM1pC3_.js";import{T as Ke}from"./triangle-alert-Cne6C2aG.js";import{B as Ee}from"./book-open-text-DBcXFQAu.js";import{W as ut}from"./workflow-BOvVTg7R.js";import"./react-CRB3T2We.js";function ht(t){var d,n,a,u,p,S;if(!t)return"connect";const o=(d=t.dbt)==null?void 0:d.artifactState,i=(n=t.modeling)==null?void 0:n.snapshotState;return(((a=t.domains)==null?void 0:a.count)??0)>0?"domain-model":i==="ready"||i==="stale"?"domains":i==="building"||o==="building"?"building":(u=t.modeling)!=null&&u.enabled&&((p=t.dbt)!=null&&p.manifestFound)?"domains":(S=t.dbt)!=null&&S.manifestFound||o==="ready"||o==="stale"?"inspect":"connect"}function ft(t){return t.job?t.job:{id:t.id??"onboarding-job",kind:t.kind,status:t.status??"running",stage:t.stage,progress:t.progress,message:t.message,diagnostics:t.diagnostics,result:t.result,error:t.error}}function mt(t){const o=t;return{code:typeof(o==null?void 0:o.code)=="string"?o.code:void 0,message:t instanceof Error?t.message:String(t??"Onboarding failed."),nextActions:Array.isArray(o==null?void 0:o.nextActions)?o.nextActions:[]}}function gt(t,o,i="target/manifest.json"){const r=mt(t),d=o.trim()||".";switch(r.code){case"DBT_PROJECT_NOT_FOUND":return{code:r.code,title:"dbt project not found",message:"Choose the folder that contains dbt_project.yml. DQL will read that project; it will not copy its schema.",nextActions:r.nextActions.length>0?r.nextActions:["Check the project path and retry."],optional:!1};case"DBT_MANIFEST_MISSING":return{code:r.code,title:"dbt manifest.json is missing",message:`DQL needs ${i||"target/manifest.json"} to inspect dbt-owned models. Build the artifact, then retry without importing or copying dbt semantics.`,command:`cd ${JSON.stringify(d)} && dbt parse`,nextActions:r.nextActions.length>0?r.nextActions:["Run the command locally, or ask DQL to build artifacts when dbt is available.","Retry inspection."],optional:!1};case"DBT_ARTIFACT_INVALID":return{code:r.code,title:"dbt artifact is invalid",message:"The manifest could not be read safely. Rebuild it with the project’s installed dbt version, then inspect again.",command:`cd ${JSON.stringify(d)} && dbt parse`,nextActions:r.nextActions.length>0?r.nextActions:["Rebuild manifest.json and retry."],optional:!1};case"DBT_PARSE_FAILED":return{code:r.code,title:"dbt parse failed",message:r.message,command:`cd ${JSON.stringify(d)} && dbt parse`,nextActions:r.nextActions.length>0?r.nextActions:["Review the redacted dbt output, repair the project, and retry."],optional:!1};case"SOURCE_CHANGED":return{code:r.code,title:"dbt source changed during review",message:"The reviewed artifact fingerprint is no longer current. Inspect the latest source before applying.",nextActions:r.nextActions.length>0?r.nextActions:["Refresh the preview and review the new diff."],optional:!1};case"AI_PROVIDER_UNAVAILABLE":return{code:r.code,title:"AI assistance is unavailable",message:"AI summaries are optional. Continue with deterministic, evidence-based domain discovery and review every draft manually.",nextActions:r.nextActions.length>0?r.nextActions:["Continue without AI."],optional:!0};case"WAREHOUSE_UNAVAILABLE":return{code:r.code,title:"Warehouse validation is unavailable",message:"You can finish metadata setup now. Relationship validation and certification will remain incomplete until a warehouse is connected.",nextActions:r.nextActions.length>0?r.nextActions:["Continue metadata setup.","Connect a warehouse before certification."],optional:!0};default:return{code:r.code,title:"Onboarding needs attention",message:r.message,nextActions:r.nextActions.length>0?r.nextActions:["Retry, or close and resume later."],optional:!1}}}const Xe=[{id:"connect",label:"Connect"},{id:"inspect",label:"Artifacts"},{id:"domains",label:"Domains"},{id:"domain-model",label:"Model"},{id:"knowledge",label:"Knowledge"},{id:"ready",label:"Start"}];function yt(t){return t==="building"?1:Math.max(0,Xe.findIndex(o=>o.id===t))}function bt(t){return typeof t=="number"?`${Math.round(t*(t<=1?100:1))}%`:t}function je(t){return t||"Optional · not available"}function jt(t){var i;return(t.confidence==="high"||typeof t.confidence=="number"&&t.confidence>=.8)&&!t.requiresHumanDecision&&(((i=t.conflicts)==null?void 0:i.length)??0)===0}function vt(t){const o=[],i=t==null?void 0:t.ai,r=t==null?void 0:t.warehouse;return(i===!1||typeof i=="object"&&!i.available)&&o.push(typeof i=="object"&&i.message?i.message:"AI assistance is unavailable; deterministic discovery remains available."),(r===!1||typeof r=="object"&&!r.available)&&o.push(typeof r=="object"&&r.message?r.message:"Warehouse validation can be connected later; certification remains incomplete until then."),o}function kt({t,initialProjectDir:o="",onBack:i,onClose:r,onComplete:d,onOpen:n}){var Re,Te,$e,Me,Pe,We;const[a,u]=c.useState("connect"),[p,S]=c.useState(null),[f,D]=c.useState(o||"."),[b,E]=c.useState("target/manifest.json"),[W,$]=c.useState(""),[B,T]=c.useState("local"),[U,V]=c.useState(""),[L,_]=c.useState(""),[O,G]=c.useState(""),[j,K]=c.useState(null),[v,X]=c.useState(null),[m,Z]=c.useState(null),[C,N]=c.useState(null),[M,ee]=c.useState(new Set),[x,A]=c.useState(!0),[I,F]=c.useState(!1),[te,ge]=c.useState(!0),[re,Q]=c.useState(null),[de,ne]=c.useState(!1),[k,l]=c.useState(!0);c.useEffect(()=>{a!=="connect"&&l(!1)},[a]);const h=c.useRef(!0),R={background:t.inputBg,border:`1px solid ${t.inputBorder}`,borderRadius:7,color:t.textPrimary,fontSize:13,fontFamily:t.font,padding:"9px 11px",outline:"none",width:"100%",boxSizing:"border-box"},et=(m==null?void 0:m.capabilities)??(j==null?void 0:j.capabilities)??(p==null?void 0:p.capabilities),tt=vt(et),P=re?gt(re,f,b):null,qe=yt(a);c.useEffect(()=>(h.current=!0,q.getOnboardingStatus().then(s=>{var g,y,w,z;h.current&&(S(s),(g=s.dbt)!=null&&g.projectDir&&D(s.dbt.projectDir),(y=s.dbt)!=null&&y.manifestPath&&E(s.dbt.manifestPath),(w=s.dbt)!=null&&w.profilesDir&&$(s.dbt.profilesDir),(z=s.dbt)!=null&&z.repoUrl&&(T("repo"),V(s.dbt.repoUrl),_(s.dbt.branch??""),G(s.dbt.subPath??"")),u(ht(s)))}).catch(()=>{}).finally(()=>{h.current&&ge(!1)}),()=>{h.current=!1}),[]);const nt=c.useCallback(async()=>{F(!0),Q(null);try{const s=await q.previewDbtOnboarding(B==="repo"?{repoUrl:U,branch:L||void 0,subPath:O||void 0,manifestPath:b,profilesDir:W||void 0}:{projectDir:f||".",manifestPath:b,profilesDir:W||void 0});if(!h.current)return;K(s),D(s.projectDir||f||"."),E(s.manifestPath||b),$(s.profilesDir||W),s.repoUrl&&(T("repo"),V(s.repoUrl),_(s.branch??""),G(s.subPath??"")),u("inspect")}catch(s){h.current&&Q(s)}finally{h.current&&F(!1)}},[L,b,W,f,U,B,O]),ie=c.useCallback(async(s=x)=>{F(!0),Q(null);try{let g;try{g=await q.discoverOnboardingDomains({snapshotId:p==null?void 0:p.snapshotId,useAi:s})}catch(z){const se=z==null?void 0:z.code;if(s&&se==="AI_PROVIDER_UNAVAILABLE")A(!1),g=await q.discoverOnboardingDomains({snapshotId:p==null?void 0:p.snapshotId,useAi:!1});else throw z}if(!h.current)return;const y=(g.proposals??[]).map(z=>({...z,lifecycle:"draft"})),w={...g,proposals:y};Z(w),ee(new Set(y.filter(jt).map(z=>z.id))),u("domains")}catch(g){h.current&&Q(g)}finally{h.current&&F(!1)}},[p==null?void 0:p.snapshotId,x]),ze=c.useCallback(async s=>{for(;;){const g=await q.getOnboardingJob(s),y=ft(g);if(!h.current)return;if(X(y),y.status==="completed"){await ie(x);return}if(y.status==="failed"||y.status==="cancelled")throw new Error(y.error||y.message||`Onboarding ${y.status}.`);await new Promise(w=>window.setTimeout(w,700))}},[ie,x]),De=c.useCallback(async s=>{F(!0),Q(null),u("building");try{const g=await q.applyDbtOnboarding({...B==="repo"?{repoUrl:U,branch:L||void 0,subPath:O||void 0}:{projectDir:f||"."},manifestPath:b,profilesDir:W||void 0,expectedFingerprint:j==null?void 0:j.fingerprint,buildArtifacts:s}),y=g.jobId??g.id,w=y?null:await q.refreshDbtOnboarding({expectedFingerprint:g.fingerprint??(j==null?void 0:j.fingerprint),buildArtifacts:s}),z=y??(w==null?void 0:w.jobId)??(w==null?void 0:w.id);z?(X({id:z,status:g.status??(w==null?void 0:w.status)??"queued"}),await ze(z)):await ie(x)}catch(g){h.current&&(Q(g),u(j?"inspect":"connect"))}finally{h.current&&F(!1)}},[L,ie,b,ze,j,W,f,U,B,O,x]);c.useEffect(()=>{a==="domains"&&!m&&!I&&!te&&!re&&ie(x)},[ie,m,re,I,a,te,x]);const Le=c.useCallback(async s=>{if(!m)return;const g=m.proposals.filter(y=>M.has(y.id)).map(y=>({...y,lifecycle:"draft"}));if(g.length===0){ne(!0),u("domain-model");return}F(!0),Q(null);try{const y=await q.applyOnboardingDomains({proposals:g,expectedSourceFingerprint:m.sourceFingerprint,mode:s});if(!h.current)return;N(y),(s==="apply"||y.applied)&&u("domain-model")}catch(y){h.current&&Q(y)}finally{h.current&&F(!1)}},[m,M]),it=c.useCallback(async()=>{if(v)try{await q.cancelOnboardingJob(v.id)}finally{X(s=>s&&{...s,status:"cancelled"}),u("inspect"),F(!1)}},[v]),ye=M.size,fe=c.useMemo(()=>{var s;return((s=C==null?void 0:C.domains)==null?void 0:s.map(g=>g.id))??(m==null?void 0:m.proposals.filter(g=>M.has(g.id)).map(g=>g.name))??[]},[m,C,M]),ce=s=>{d(),n(s)};return e.jsxs("div",{style:{background:t.appBg,width:"100vw",height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},role:"dialog","aria-modal":"true","aria-labelledby":"dbt-onboarding-title",children:[e.jsx("style",{children:`
2
+ @keyframes dql-setup-fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
3
+ @keyframes dql-setup-stage { from { opacity: 0; transform: translateY(10px) scale(0.97); } to { opacity: 1; transform: none; } }
4
+ @keyframes dql-setup-arrow { 0%, 100% { opacity: 0.35; transform: translateX(0); } 50% { opacity: 1; transform: translateX(3px); } }
5
+ @keyframes dql-setup-flowrail { 0% { background-position: 0% 0; } 100% { background-position: 200% 0; } }
6
+ @keyframes dql-setup-gitdash { 0% { background-position: 0 0; } 100% { background-position: 40px 0; } }
7
+ @keyframes dql-setup-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
8
+ `}),e.jsxs("div",{style:{height:52,flexShrink:0,background:t.cellBg,borderBottom:`1px solid ${t.cellBorder}`,display:"flex",alignItems:"center",padding:"0 18px",gap:10,userSelect:"none"},children:[e.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:e.jsx("span",{style:{color:"#fff",fontSize:10,fontWeight:700,fontFamily:t.fontMono,letterSpacing:"-0.5px"},children:"DQL"})}),e.jsx("h2",{id:"dbt-onboarding-title",style:{margin:0,fontSize:13.5,fontWeight:650,color:t.textPrimary,fontFamily:t.font,whiteSpace:"nowrap"},children:"Set up your workspace"}),e.jsx("div",{style:{flex:1}}),e.jsxs("div",{"aria-label":"dbt onboarding progress",style:{display:"flex",alignItems:"center",gap:4,overflowX:"auto"},children:[e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 10px",borderRadius:999,border:`1px solid ${k?t.accent:"var(--status-success-border)"}`,background:k?"var(--accent-dim)":"var(--status-success-bg)",fontFamily:t.font,whiteSpace:"nowrap"},children:[e.jsx("span",{style:{width:16,height:16,borderRadius:999,display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:9,fontWeight:700,background:k?t.accent:"var(--status-success)",color:"#fff"},children:k?"0":"✓"}),e.jsx("span",{style:{fontSize:11,fontWeight:650,color:k?t.accent:"var(--status-success)"},children:"Welcome"})]}),Xe.map((s,g)=>{const y=!k&&g<qe,w=!k&&g===qe;return e.jsxs("span",{"aria-current":w?"step":void 0,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"5px 10px",borderRadius:999,border:`1px solid ${w?t.accent:y?"var(--status-success-border)":t.cellBorder}`,background:w?"var(--accent-dim)":y?"var(--status-success-bg)":"transparent",fontFamily:t.font,whiteSpace:"nowrap"},children:[e.jsx("span",{style:{width:16,height:16,borderRadius:999,display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:9,fontWeight:700,background:w?t.accent:y?"var(--status-success)":t.cellBorder,color:w||y?"#fff":t.textMuted},children:y?"✓":g+1}),e.jsx("span",{style:{fontSize:11,fontWeight:650,color:w?t.accent:y?"var(--status-success)":t.textMuted},children:s.label})]},s.id)})]}),e.jsx("div",{style:{flex:1}}),e.jsx("button",{"aria-label":"Close setup",onClick:r,style:{height:28,padding:"0 11px",borderRadius:7,border:"none",background:"none",color:t.textMuted,fontSize:12,fontWeight:600,cursor:"pointer",fontFamily:t.font,whiteSpace:"nowrap"},children:"Skip for now"})]}),e.jsx("div",{style:{flex:1,minHeight:0,overflowY:"auto"},children:e.jsx("div",{style:{width:"min(860px, 100% - 48px)",margin:"0 auto",padding:"26px 0 60px"},children:k?e.jsx(wt,{t}):e.jsxs(e.Fragment,{children:[null,te&&e.jsx(J,{t,title:"Checking existing setup…",body:"You can resume from the first incomplete step."}),a==="connect"&&!te&&e.jsxs(oe,{title:"1. Connect the dbt project",description:"Point DQL at the existing dbt project and artifact. DQL reads these files in place; it does not create a second semantic copy.",t,children:[e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{type:"button",onClick:()=>T("local"),style:B==="local"?H(t):Y(t),children:"Local path"}),e.jsx("button",{type:"button",onClick:()=>T("repo"),style:B==="repo"?H(t):Y(t),children:"Git repository"})]}),B==="local"?e.jsx(ae,{label:"dbt project directory",hint:"Folder containing dbt_project.yml",t,children:e.jsx("input",{"aria-label":"dbt project directory",value:f,onChange:s=>D(s.target.value),placeholder:".",style:R})}):e.jsxs(e.Fragment,{children:[e.jsx(ae,{label:"Repository URL",hint:"HTTPS, SSH, or file URL for a dbt Git repository",t,children:e.jsx("input",{"aria-label":"dbt repository URL",value:U,onChange:s=>V(s.target.value),placeholder:"https://github.com/org/dbt-project.git",style:R})}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10},children:[e.jsx(ae,{label:"Branch",hint:"Defaults to main",t,children:e.jsx("input",{"aria-label":"dbt repository branch",value:L,onChange:s=>_(s.target.value),placeholder:"main",style:R})}),e.jsx(ae,{label:"Sub-path",hint:"Optional dbt project folder",t,children:e.jsx("input",{"aria-label":"dbt repository sub-path",value:O,onChange:s=>G(s.target.value),placeholder:"analytics/dbt",style:R})})]})]}),e.jsx(ae,{label:"Manifest path",hint:"Relative to the dbt project directory",t,children:e.jsx("input",{"aria-label":"dbt manifest path",value:b,onChange:s=>E(s.target.value),placeholder:"target/manifest.json",style:R})}),e.jsx(ae,{label:"dbt profiles directory",hint:"Optional; auto-detected from the dbt project, DQL project, DBT_PROFILES_DIR, or ~/.dbt",t,children:e.jsx("input",{"aria-label":"dbt profiles directory",value:W,onChange:s=>$(s.target.value),placeholder:"Auto-detect",style:R})}),e.jsx(St,{t})]}),a==="inspect"&&j&&e.jsxs(oe,{title:"2. Review dbt artifacts",description:"DQL will enable Manifest v3 and dbt-first modeling, then build an immutable snapshot from these sources.",t,children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gap:10},children:Object.entries(j.counts).map(([s,g])=>e.jsx(Ct,{label:s,value:g,t},s))}),e.jsxs("div",{style:{border:`1px solid ${t.cellBorder}`,borderRadius:8,overflow:"hidden"},children:[e.jsx(me,{label:"manifest.json",value:je(j.artifacts.manifest),required:!0,t}),e.jsx(me,{label:"catalog.json",value:je(j.artifacts.catalog),t}),e.jsx(me,{label:"semantic_manifest.json",value:je(j.artifacts.semanticManifest),t}),e.jsx(me,{label:"profiles directory",value:j.profilesDir||"Optional · not detected",t})]}),e.jsx(J,{t,title:"What changes",body:"DQL writes project configuration and a rebuildable snapshot. dbt SQL/YAML and MetricFlow formulas remain the source of truth and are never copied into Domain Packages."}),(Re=j.warnings)==null?void 0:Re.map(s=>e.jsx(J,{t,title:"Repository note",body:s},s))]}),a==="building"&&e.jsx(oe,{title:"Building the dbt-first snapshot",description:"Artifact generation, validation, compile, and indexing are handled as one resumable job. The previous active snapshot remains usable until this completes.",t,children:e.jsxs("div",{style:{border:`1px solid ${t.cellBorder}`,borderRadius:10,padding:16},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",color:t.textPrimary,font:`600 13px ${t.font}`},children:[e.jsx("span",{children:(v==null?void 0:v.stage)??"Preparing project"}),e.jsx("span",{children:typeof(v==null?void 0:v.progress)=="number"?`${v.progress}%`:(v==null?void 0:v.status)??"running"})]}),e.jsx("div",{style:{height:7,borderRadius:8,background:t.cellBorder,marginTop:12,overflow:"hidden"},children:e.jsx("div",{style:{width:`${Math.max(8,(v==null?void 0:v.progress)??15)}%`,height:"100%",background:t.accent,transition:"width .2s"}})}),(v==null?void 0:v.message)&&e.jsx("div",{style:{marginTop:10,color:t.textSecondary,font:`12px/1.5 ${t.font}`},children:v.message})]})}),a==="domains"&&e.jsxs(oe,{title:"3. Review discovered domains",description:"Proposals use dbt groups, tags, paths, owners, exposures, packages, and MetricFlow evidence. Nothing is certified automatically.",t,children:[e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:9,color:t.textSecondary,font:`12px/1.45 ${t.font}`},children:[e.jsx("input",{type:"checkbox",checked:x,onChange:s=>{A(s.target.checked),Z(null),Q(null)}}),e.jsxs("span",{children:[e.jsx("strong",{style:{color:t.textPrimary},children:"Use AI to summarize repository evidence"}),e.jsx("br",{}),"Optional and review-only. AI cannot invent membership or set certified lifecycle."]})]}),(Te=m==null?void 0:m.warnings)==null?void 0:Te.map(s=>e.jsx(J,{t,title:"Discovery note",body:s},s)),m&&m.proposals.length===0&&e.jsx(J,{t,title:"No confident domains found",body:"Continue to create domains manually in Domain Studio. Ask remains available in limited-context, review-required mode."}),m==null?void 0:m.proposals.map(s=>{var y,w;const g=M.has(s.id);return e.jsx("label",{style:{display:"block",border:`1px solid ${g?t.accent:t.cellBorder}`,background:g?`${t.accent}0d`:t.inputBg,borderRadius:9,padding:13,cursor:"pointer"},children:e.jsxs("div",{style:{display:"flex",gap:10,alignItems:"flex-start"},children:[e.jsx("input",{type:"checkbox",checked:g,onChange:()=>{N(null),ee(z=>{const se=new Set(z);return se.has(s.id)?se.delete(s.id):se.add(s.id),se})},"aria-label":`Select ${s.name}`}),e.jsxs("div",{style:{minWidth:0,flex:1},children:[e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:7,alignItems:"center"},children:[e.jsx("strong",{style:{color:t.textPrimary,font:`600 13px ${t.font}`},children:s.name}),e.jsx(ve,{text:`${bt(s.confidence)} confidence`,t}),e.jsx(ve,{text:"Draft only",t,tone:"warning"}),s.requiresHumanDecision&&e.jsx(ve,{text:"Decision required",t,tone:"warning"})]}),s.description&&e.jsx("p",{style:{margin:"6px 0 0",color:t.textSecondary,font:`12px/1.45 ${t.font}`},children:s.description}),e.jsxs("div",{style:{marginTop:8,color:t.textMuted,font:`11px/1.45 ${t.font}`},children:["Evidence: ",s.evidence.length>0?s.evidence.slice(0,4).map(z=>`${z.kind}: ${z.value}`).join(" · "):"No evidence supplied — manual review required"]}),(((y=s.conflicts)==null?void 0:y.length)??0)>0&&e.jsxs("div",{style:{marginTop:6,color:t.warning,font:`11px/1.45 ${t.font}`},children:["Conflicts: ",(w=s.conflicts)==null?void 0:w.join(" · ")]})]})]})},s.id)}),((($e=C==null?void 0:C.preview)==null?void 0:$e.length)??0)>0&&e.jsxs("div",{style:{border:`1px solid ${t.accent}55`,background:`${t.accent}09`,borderRadius:9,padding:12},children:[e.jsx("div",{style:{color:t.textPrimary,font:`600 12px ${t.font}`},children:"Review Domain Package source changes"}),e.jsx("div",{style:{marginTop:4,color:t.textMuted,font:`11px/1.45 ${t.font}`},children:"Only sparse DQL domain declarations and bindings will be written. Confirm after reviewing these target files."}),e.jsx("div",{style:{display:"grid",gap:6,marginTop:9},children:(Me=C==null?void 0:C.preview)==null?void 0:Me.map(s=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"60px 1fr",gap:8,color:t.textSecondary,font:`11px ${t.font}`},children:[e.jsx("strong",{children:s.operation}),e.jsx("code",{style:{color:t.textPrimary},children:s.path}),s.summary&&e.jsx("span",{style:{gridColumn:"2",color:t.textMuted},children:s.summary})]},`${s.operation}:${s.path}`))})]})]}),a==="domain-model"&&e.jsxs(oe,{title:"4. Build the Domain Model",description:"The unified canvas adds analytical meaning over dbt provenance. Start small: bind high-value entities and prove only the joins agents may use.",t,children:[fe.length>0&&e.jsx(J,{t,title:`${fe.length} draft domain${fe.length===1?"":"s"} created`,body:fe.join(" · ")}),de&&e.jsx(J,{t,title:"Domain setup skipped",body:"You can continue, but Ask is limited-context and all generated output requires review until governed paths exist."}),e.jsx(Oe,{t,items:[["Bind business entities","Reference dbt unique IDs; do not duplicate columns or descriptions."],["Declare analytical grain","Add grain only where dbt metadata is insufficient."],["Prove relationships","Cardinality, fanout, key mapping, evidence, and lifecycle control agent joins."],["Export cross-domain paths","Provider exports and consumer imports are required in addition to relationship proof."]]}),e.jsx("button",{onClick:()=>ce("modeling"),style:Y(t),children:"Open Domain Model now"})]}),a==="knowledge"&&e.jsxs(oe,{title:"5. Add domain knowledge",description:"Skills and terms teach agents vocabulary, policies, examples, exclusions, and when to ask for clarification.",t,children:[e.jsx(Oe,{t,items:[["Terms","Define business vocabulary and map synonyms to domain-qualified concepts."],["Domain skills","Add policies, examples, exclusions, and required clarifications for this domain."],["Evaluations","Test retrieval, metric selection, safe joins, refusal, and clarification behavior."],["Review lifecycle","AI may draft from repository evidence, but a person reviews and certifies."]]}),e.jsx("button",{onClick:()=>ce("skills"),style:Y(t),children:"Open Skills now"})]}),a==="ready"&&e.jsx(oe,{title:"Your dbt-first workspace is ready to continue",description:"Choose the next task. Setup is resumable, and trust improves as relationships, skills, evaluations, and certified assets are completed.",t,children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gap:10},children:[e.jsx(ke,{title:"Ask AI",body:de?"Limited-context and review-required until domains are governed.":"Use the governed cascade; unsafe paths clarify or refuse.",action:"Open Ask",onClick:()=>ce("ask"),t}),e.jsx(ke,{title:"Build a Block",body:"Turn reviewed analysis into a reusable domain asset and evaluate it.",action:"New Block",onClick:()=>ce("block"),t}),e.jsx(ke,{title:"Domain Studio",body:"Continue bindings, relationships, knowledge, readiness, and dbt scope.",action:"Open Studio",onClick:()=>ce("modeling"),t})]})}),tt.map(s=>e.jsx(J,{t,title:"Optional capability",body:s},s)),P&&e.jsxs("div",{role:"alert",style:{border:`1px solid ${P.optional?t.warning:t.error}`,background:P.optional?`${t.warning}0d`:`${t.error}0d`,borderRadius:9,padding:13,marginTop:14},children:[e.jsx("div",{style:{color:P.optional?t.warning:t.error,font:`600 13px ${t.font}`},children:P.title}),e.jsx("div",{style:{color:t.textSecondary,font:`12px/1.5 ${t.font}`,marginTop:5},children:P.message}),P.command&&e.jsx("code",{style:{display:"block",marginTop:9,padding:"8px 10px",borderRadius:6,background:t.inputBg,color:t.textPrimary,fontSize:11,overflowX:"auto"},children:P.command}),e.jsx("ul",{style:{margin:"8px 0 0",paddingLeft:18,color:t.textMuted,font:`11px/1.5 ${t.font}`},children:P.nextActions.map(s=>e.jsx("li",{children:s},s))})]})]})})}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:10,padding:"13px 22px",borderTop:`1px solid ${t.cellBorder}`,background:t.cellBg,flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",gap:8},children:[k&&e.jsx("button",{onClick:i,style:Y(t),children:"Back"}),!k&&a==="connect"&&e.jsx("button",{onClick:()=>l(!0),style:Y(t),children:"Back"}),!k&&a!=="building"&&a!=="connect"&&e.jsx("button",{onClick:r,style:Y(t),children:"Save & close"}),!k&&a==="building"&&v&&e.jsx("button",{onClick:()=>void it(),style:Y(t),children:"Cancel job"})]}),e.jsx("span",{style:{flex:1,textAlign:"center",fontSize:11,color:t.textMuted,fontFamily:t.font},children:k?"~2 minute read — or skip straight to setup":"Setup is resumable — you can save and come back any time."}),e.jsxs("div",{style:{display:"flex",gap:8},children:[k&&e.jsx("button",{onClick:()=>l(!1),style:H(t),children:"Next — connect your dbt project"}),!k&&a==="connect"&&(P==null?void 0:P.code)==="DBT_MANIFEST_MISSING"&&e.jsx("button",{disabled:I,onClick:()=>void De(!0),style:Y(t),children:"Build artifacts with DQL"}),!k&&a==="connect"&&e.jsx("button",{disabled:I||(B==="repo"?!U.trim():!f.trim()),onClick:()=>void nt(),style:H(t,I||(B==="repo"?!U.trim():!f.trim())),children:I?"Inspecting…":(P==null?void 0:P.code)==="DBT_MANIFEST_MISSING"?"I ran dbt parse — retry":"Inspect artifacts"}),!k&&a==="inspect"&&e.jsx("button",{disabled:I,onClick:()=>void De(!1),style:H(t,I),children:I?"Building…":"Apply & build snapshot"}),!k&&a==="domains"&&!m&&e.jsx("button",{disabled:I,onClick:()=>{Q(null),ie(x)},style:H(t,I),children:I?"Discovering…":"Retry discovery"}),!k&&a==="domains"&&m&&(((Pe=C==null?void 0:C.preview)==null?void 0:Pe.length)??0)===0&&e.jsx("button",{disabled:I,onClick:()=>void Le("preview"),style:H(t,I),children:I?"Preparing preview…":ye>0?`Review ${ye} draft domain${ye===1?"":"s"}`:"Continue without domains"}),!k&&a==="domains"&&m&&(((We=C==null?void 0:C.preview)==null?void 0:We.length)??0)>0&&e.jsx("button",{disabled:I,onClick:()=>void Le("apply"),style:H(t,I),children:I?"Applying…":"Apply reviewed drafts"}),!k&&a==="domain-model"&&e.jsx("button",{onClick:()=>u("knowledge"),style:H(t),children:"Continue to knowledge"}),!k&&a==="knowledge"&&e.jsx("button",{onClick:()=>u("ready"),style:H(t),children:"Continue"}),!k&&a==="ready"&&e.jsx("button",{onClick:r,style:{...H(t),background:"var(--status-success)",borderColor:"var(--status-success)"},children:"Finish setup"})]})]})]})}function wt({t}){const o=(p,S,f)=>e.jsxs("div",{style:{border:`1.5px solid ${S.border}`,borderRadius:10,background:S.bg,padding:"11px 10px",textAlign:"center",animation:"dql-setup-stage 0.5s ease-out both",animationDelay:`${p}s`,boxShadow:S.glow?"0 4px 18px rgba(107,93,211,0.12)":"none"},children:[e.jsx("div",{style:{width:26,height:26,borderRadius:7,background:S.iconBg,color:S.iconColor,display:"inline-flex",alignItems:"center",justifyContent:"center"},children:f}),e.jsx("div",{style:{fontSize:12,fontWeight:700,color:t.textPrimary,marginTop:6},children:S.title}),e.jsx("div",{style:{fontSize:10,color:t.textMuted,lineHeight:1.45,marginTop:3},children:S.body})]}),i=e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",color:t.accent},children:e.jsxs("svg",{style:{animation:"dql-setup-arrow 1.6s ease-in-out infinite"},width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M5 12h14"}),e.jsx("path",{d:"m12 5 7 7-7 7"})]})}),r=(p,S,f)=>e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,border:`1px solid ${(f==null?void 0:f.border)??t.cellBorder}`,background:(f==null?void 0:f.bg)??t.cellBg,borderRadius:999,padding:"4px 12px",fontSize:11.5,fontWeight:650,color:(f==null?void 0:f.color)??t.textSecondary},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:999,background:S}}),p]}),d=e.jsxs("svg",{style:{color:"var(--border-strong)"},width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M5 12h14"}),e.jsx("path",{d:"m12 5 7 7-7 7"})]}),n=p=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:7,padding:"14px 0 10px"},children:[e.jsx("span",{style:{width:1.5,height:26,background:"linear-gradient(to bottom, transparent, var(--border-strong))"}}),e.jsx("span",{style:{fontSize:11.5,color:t.textMuted,fontStyle:"italic"},children:p}),e.jsx("span",{style:{width:1.5,height:26,background:"linear-gradient(to bottom, var(--border-strong), transparent)"}})]}),a=(p,S,f)=>e.jsxs("div",{style:{border:"1px solid var(--border-subtle)",borderRadius:11,background:t.cellBg,padding:"12px 14px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,fontSize:12.5,fontWeight:700,color:t.textPrimary},children:[f,p]}),e.jsx("div",{style:{fontSize:11,color:t.textMuted,lineHeight:1.5,marginTop:4},children:S})]}),u=p=>e.jsxs("div",{style:{display:"flex",gap:9,alignItems:"flex-start"},children:[e.jsx("svg",{style:{flexShrink:0,marginTop:3},width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"var(--status-success)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6 9 17l-5-5"})}),e.jsx("span",{style:{fontSize:13,color:t.textSecondary,lineHeight:1.55},children:p})]});return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:20,animation:"dql-setup-fadein 0.25s ease-out",fontFamily:t.font},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1.1fr 0.9fr",gap:28,alignItems:"center"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{display:"inline-flex",alignItems:"center",gap:7,border:"1px solid var(--status-info-border)",background:"var(--accent-dim)",borderRadius:999,padding:"4px 13px",fontSize:11,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",color:t.accent},children:"Welcome to DQL"}),e.jsxs("h1",{style:{margin:"12px 0 0",fontSize:27,fontWeight:700,letterSpacing:"-0.02em",color:t.textPrimary,lineHeight:1.25},children:["Analytics your AI",e.jsx("br",{}),"can't hallucinate"]}),e.jsxs("div",{style:{marginTop:14,display:"flex",flexDirection:"column",gap:9},children:[u("Sits on your dbt project — models and tests stay yours"),u(e.jsxs(e.Fragment,{children:["Questions route through ",e.jsx("strong",{children:"certified blocks"})," before AI writes SQL"]})),u("Every answer carries a trust label your stakeholders can read")]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8,animation:"dql-setup-float 4s ease-in-out infinite"},children:[e.jsxs("div",{style:{border:"1px solid var(--border-subtle)",borderRadius:12,background:t.cellBg,padding:"12px 14px",boxShadow:"0 8px 28px rgba(26,26,26,0.06)"},children:[e.jsx("div",{style:{background:"var(--bg-0)",borderRadius:"12px 12px 3px 12px",padding:"7px 11px",fontSize:11.5,color:t.textPrimary,width:"fit-content",marginLeft:"auto"},children:"What was revenue last quarter?"}),e.jsxs("div",{style:{marginTop:9,display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{fontSize:10,fontWeight:700,color:"var(--status-success)",background:"var(--status-success-bg)",border:"1px solid var(--status-success-border)",borderRadius:999,padding:"1.5px 8px"},children:"Certified"}),e.jsx("span",{style:{fontSize:10,color:t.textMuted},children:"from total_revenue · 0.3s"})]}),e.jsxs("div",{style:{marginTop:6,fontSize:13,color:t.textPrimary},children:["Q2 revenue was ",e.jsx("strong",{children:"$4.82M"}),", up 6.4% from Q1."]})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:7,justifyContent:"flex-end",fontSize:10.5,color:t.textMuted,paddingRight:4},children:"Traceable from source table to this answer"})]})]}),e.jsxs("div",{style:{marginTop:14,display:"flex",alignItems:"baseline",gap:10},children:[e.jsx("span",{style:{fontSize:13,fontWeight:700,color:t.textMuted,fontFamily:t.fontMono},children:"01"}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:16,fontWeight:700,color:t.textPrimary,letterSpacing:"-0.01em"},children:"How a question becomes a trusted answer"}),e.jsx("div",{style:{fontSize:12,color:t.textMuted,marginTop:2},children:"Five stages, one direction — watch the flow."})]})]}),e.jsxs("div",{style:{border:"1px solid var(--border-subtle)",borderRadius:14,background:t.cellBg,padding:"22px 20px 16px"},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 26px 1fr 26px 1fr 26px 1fr 26px 1fr",alignItems:"stretch"},children:[o(.1,{border:t.cellBorder,bg:t.appBg,iconBg:"rgba(74,116,201,0.12)",iconColor:"#4a74c9",title:"Sources & dbt",body:"Your warehouse and models — dbt keeps ownership"},e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),e.jsx("path",{d:"M3 5v14a9 3 0 0 0 18 0V5"}),e.jsx("path",{d:"M3 12a9 3 0 0 0 18 0"})]})),i,o(.35,{border:"rgba(10,107,94,0.3)",bg:"rgba(10,107,94,0.05)",iconBg:"rgba(10,107,94,0.12)",iconColor:"#0a6b5e",title:"Domains & modeling",body:"Business entities, proven joins, skills"},e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0z"}),e.jsx("path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3z"}),e.jsx("path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5z"})]})),i,o(.6,{border:"rgba(107,93,211,0.35)",bg:"var(--accent-dim)",iconBg:"rgba(107,93,211,0.14)",iconColor:t.accent,title:"Certified blocks",body:"Reusable governed answers — reviewed & certified",glow:!0},e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"8",height:"8",rx:"1.5"}),e.jsx("rect",{x:"13",y:"3",width:"8",height:"8",rx:"1.5"}),e.jsx("rect",{x:"3",y:"13",width:"8",height:"8",rx:"1.5"}),e.jsx("rect",{x:"13",y:"13",width:"8",height:"8",rx:"1.5"})]})),i,o(.85,{border:t.cellBorder,bg:t.appBg,iconBg:"rgba(178,107,31,0.12)",iconColor:"#b26b1f",title:"Ask & research",body:"Ask AI answers + SQL notebooks for deep dives"},e.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z"})})),i,o(1.1,{border:"rgba(46,139,87,0.3)",bg:"rgba(46,139,87,0.05)",iconBg:"var(--status-success-bg)",iconColor:"var(--status-success)",title:"Generative apps",body:"Stakeholder apps built from certified blocks"},e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"}),e.jsx("path",{d:"m3.3 7 8.7 5 8.7-5"}),e.jsx("path",{d:"M12 22V12"})]}))]}),e.jsxs("div",{style:{marginTop:14,display:"flex",flexDirection:"column",gap:6},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("div",{style:{flex:1,height:5,borderRadius:999,background:"linear-gradient(90deg, rgba(74,116,201,0.35), rgba(10,107,94,0.4), rgba(107,93,211,0.5), rgba(178,107,31,0.4), rgba(46,139,87,0.45), rgba(74,116,201,0.35))",backgroundSize:"200% 100%",animation:"dql-setup-flowrail 5s linear infinite"}}),e.jsx("span",{style:{fontSize:10,color:t.textMuted,whiteSpace:"nowrap"},children:"Lineage — trace any number from source to app, across domains"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("div",{style:{flex:1,height:5,borderRadius:999,background:"repeating-linear-gradient(90deg, var(--border-strong) 0 14px, transparent 14px 20px)",animation:"dql-setup-gitdash 1.6s linear infinite"}}),e.jsx("span",{style:{fontSize:10,color:t.textMuted,whiteSpace:"nowrap"},children:"Everything Git-versioned — branch, review, approve like code"})]})]})]}),n("…and every good answer feeds the loop that makes the next one cheaper."),e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:10,justifyContent:"flex-end",textAlign:"right"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:16,fontWeight:700,color:t.textPrimary,letterSpacing:"-0.01em"},children:"Certify once, everyone reuses"}),e.jsx("div",{style:{fontSize:12,color:t.textMuted,marginTop:2},children:"The loop that grows trust — and cuts AI cost with every pass."})]}),e.jsx("span",{style:{fontSize:13,fontWeight:700,color:t.textMuted,fontFamily:t.fontMono},children:"02"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8,flexWrap:"wrap",animation:"dql-setup-fadein 0.5s ease-out both",animationDelay:"1.3s"},children:[r("Research freely","#b26b1f",{color:"#b26b1f"}),d,r("Review together","var(--accent)",{color:"var(--accent)"}),d,r("Certify once","var(--status-success)",{border:"var(--status-success-border)",bg:"var(--status-success-bg)",color:"var(--status-success)"}),d,r("Everyone reuses — instantly","#4a74c9"),e.jsx("span",{style:{width:"100%",textAlign:"right",fontSize:11,color:t.textMuted,marginTop:2},children:"A certified block answers the same question forever — no regenerated SQL, no second review, no token bill."})]}),n("Which is why the numbers survive the hardest room in the company."),e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:10},children:[e.jsx("span",{style:{fontSize:13,fontWeight:700,color:t.textMuted,fontFamily:t.fontMono},children:"03"}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:16,fontWeight:700,color:t.textPrimary,letterSpacing:"-0.01em"},children:"Why it holds up in the boardroom"}),e.jsx("div",{style:{fontSize:12,color:t.textMuted,marginTop:2},children:"Four guarantees behind every number."})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(190px, 1fr))",gap:10,animation:"dql-setup-fadein 0.5s ease-out both",animationDelay:"1.5s"},children:[a("High confidence","Certified answers at stakeholder precision — every answer carries its trust label.",e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"var(--status-success)",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1 1 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"}),e.jsx("path",{d:"m9 12 2 2 4-4"})]})),a("Lower AI cost","Reusable blocks answer repeat questions instantly — no regenerated SQL, no wasted tokens.",e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"8",height:"8",rx:"1.5"}),e.jsx("rect",{x:"13",y:"13",width:"8",height:"8",rx:"1.5"}),e.jsx("rect",{x:"3",y:"13",width:"8",height:"8",rx:"1.5"}),e.jsx("rect",{x:"13",y:"3",width:"8",height:"8",rx:"1.5"})]})),a("Git-versioned","Blocks, domains, and apps are files — branch, review, and approve like code.",e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"#b26b1f",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"6",x2:"6",y1:"3",y2:"15"}),e.jsx("circle",{cx:"18",cy:"6",r:"3"}),e.jsx("circle",{cx:"6",cy:"18",r:"3"}),e.jsx("path",{d:"M18 9a9 9 0 0 1-9 9"})]})),a("Full lineage","Trace any number from source table to app — including across domains.",e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"#4a74c9",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"5",cy:"12",r:"2"}),e.jsx("circle",{cx:"19",cy:"5",r:"2"}),e.jsx("circle",{cx:"19",cy:"19",r:"2"}),e.jsx("path",{d:"M7 12l10-6M7 12l10 6"})]}))]})]})}function oe({title:t,description:o,t:i,children:r}){return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[e.jsxs("div",{children:[e.jsx("h3",{style:{margin:0,color:i.textPrimary,font:`600 15px ${i.font}`},children:t}),e.jsx("p",{style:{margin:"5px 0 0",color:i.textSecondary,font:`12px/1.5 ${i.font}`},children:o})]}),r]})}function ae({label:t,hint:o,t:i,children:r}){return e.jsxs("label",{style:{display:"block"},children:[e.jsx("span",{style:{display:"block",marginBottom:5,color:i.textSecondary,font:`600 11px ${i.font}`},children:t}),r,e.jsx("span",{style:{display:"block",marginTop:5,color:i.textMuted,font:`10px ${i.font}`},children:o})]})}function St({t}){return e.jsx(J,{t,title:"Read-only dbt ownership",body:"Models, columns, descriptions, tests, lineage, catalog types, and MetricFlow formulas stay in dbt. DQL stores sparse domains, bindings, relationship safety, contracts, skills, blocks, and evaluations."})}function J({title:t,body:o,t:i}){return e.jsxs("div",{style:{border:`1px solid ${i.cellBorder}`,background:i.inputBg,borderRadius:8,padding:"10px 12px",marginTop:10},children:[e.jsx("div",{style:{color:i.textPrimary,font:`600 11px ${i.font}`},children:t}),e.jsx("div",{style:{marginTop:3,color:i.textMuted,font:`11px/1.5 ${i.font}`},children:o})]})}function Ct({label:t,value:o,t:i}){return e.jsxs("div",{style:{border:`1px solid ${i.cellBorder}`,background:i.inputBg,borderRadius:8,padding:12},children:[e.jsx("div",{style:{color:i.textPrimary,font:`700 20px ${i.font}`},children:o}),e.jsx("div",{style:{color:i.textMuted,font:`11px ${i.font}`,textTransform:"capitalize"},children:t})]})}function me({label:t,value:o,required:i=!1,t:r}){return e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"160px 1fr auto",gap:10,padding:"10px 12px",borderBottom:`1px solid ${r.cellBorder}`,color:r.textSecondary,font:`11px ${r.font}`},children:[e.jsx("strong",{style:{color:r.textPrimary},children:t}),e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:o}),e.jsx("span",{children:i?"Required":"Optional"})]})}function ve({text:t,t:o,tone:i}){const r=i==="warning"?o.warning:o.accent;return e.jsx("span",{style:{border:`1px solid ${r}55`,color:r,background:`${r}0d`,borderRadius:20,padding:"2px 7px",font:`600 9px ${o.font}`},children:t})}function Oe({items:t,t:o}){return e.jsx("div",{style:{display:"grid",gap:8},children:t.map(([i,r],d)=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"24px 1fr",gap:10,border:`1px solid ${o.cellBorder}`,borderRadius:8,padding:11},children:[e.jsx("span",{style:{width:22,height:22,display:"grid",placeItems:"center",borderRadius:"50%",background:`${o.accent}18`,color:o.accent,font:`600 10px ${o.font}`},children:d+1}),e.jsxs("div",{children:[e.jsx("strong",{style:{color:o.textPrimary,font:`600 12px ${o.font}`},children:i}),e.jsx("div",{style:{marginTop:2,color:o.textMuted,font:`11px/1.45 ${o.font}`},children:r})]})]},i))})}function ke({title:t,body:o,action:i,onClick:r,t:d}){return e.jsxs("div",{style:{display:"flex",flexDirection:"column",minHeight:145,border:`1px solid ${d.cellBorder}`,borderRadius:9,padding:13},children:[e.jsx("strong",{style:{color:d.textPrimary,font:`600 13px ${d.font}`},children:t}),e.jsx("div",{style:{flex:1,marginTop:6,color:d.textMuted,font:`11px/1.5 ${d.font}`},children:o}),e.jsx("button",{onClick:r,style:{...H(d),width:"100%",marginTop:12},children:i})]})}function H(t,o=!1){return{border:`1px solid ${t.accent}`,background:t.accent,color:"#fff",borderRadius:7,padding:"8px 14px",cursor:o?"not-allowed":"pointer",opacity:o?.55:1,font:`600 12px ${t.font}`}}function Y(t){return{border:`1px solid ${t.cellBorder}`,background:t.btnBg,color:t.textSecondary,borderRadius:7,padding:"8px 13px",cursor:"pointer",font:`500 12px ${t.font}`}}const It=[{id:"dbt",label:"dbt",description:"Connect a dbt project as the read-only source for models, schema, lineage, tests, catalog types, and MetricFlow.",icon:"dbt",color:"#ff694a"},{id:"cubejs",label:"Cube.js",description:"Import cubes, measures, dimensions, joins, and pre-aggregations from Cube.js.",icon:"cube",color:"#7a77ff"},{id:"snowflake",label:"Snowflake",description:"Introspect Snowflake semantic views and import metrics and dimensions.",icon:"snow",color:"#29b5e8"}];function At({detectedProvider:t,onClose:o,onImported:i}){const{state:r,dispatch:d}=Be(),n=Ye[r.themeMode],[a,u]=c.useState("provider"),[p,S]=c.useState(null),[f,D]=c.useState(""),[b,E]=c.useState(""),[W,$]=c.useState(""),[B,T]=c.useState(""),[U,V]=c.useState(""),[L,_]=c.useState("local"),[O,G]=c.useState([]),[j,K]=c.useState(null),[v,X]=c.useState(!1),[m,Z]=c.useState(null),[C,N]=c.useState(null),[M,ee]=c.useState(null),[x,A]=c.useState(null),[I,F]=c.useState(null);c.useEffect(()=>{q.getConnections().then(l=>{l!=null&&l.connections&&G(Object.keys(l.connections))}).catch(()=>{})},[]);const te=()=>p?p==="snowflake"?{provider:p,connection:U||void 0}:L==="repo"?{provider:p,repoUrl:b,branch:W||void 0,subPath:B||void 0}:{provider:p,projectPath:f||void 0}:null,ge=async()=>{const l=te();if(l){X(!0),Z(null),N(null);try{const h=await q.previewSemanticImport(l);K(h),u("preview")}catch(h){let R={};try{R=JSON.parse(h.message)}catch{R={error:h.message}}Z(R.error??h.message??"Preview failed"),N(R.hint??null)}finally{X(!1)}}},re=async()=>{const l=te();if(l){u("importing"),A(null),F(null);try{const h=await q.importSemanticLayer(l);ee(h),u("done")}catch(h){let R={};try{R=JSON.parse(h.message)}catch{R={error:h.message}}A(R.error??h.message??"Import failed"),F(R.hint??null),u("preview")}}},Q=()=>{i(),o()},de=l=>{l.target===l.currentTarget&&o()};c.useEffect(()=>{const l=h=>{h.key==="Escape"&&o()};return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[o]);const ne={background:n.inputBg,border:`1px solid ${n.inputBorder}`,borderRadius:6,color:n.textPrimary,fontSize:13,fontFamily:n.font,padding:"8px 12px",outline:"none",width:"100%",boxSizing:"border-box"},k={fontSize:12,fontWeight:500,color:n.textSecondary,fontFamily:n.font,marginBottom:4,display:"block"};return p==="dbt"&&a!=="provider"?e.jsx("div",{onClick:de,style:{position:"fixed",inset:0,background:n.modalOverlay,display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,backdropFilter:"blur(4px)"},children:e.jsx(kt,{t:n,initialProjectDir:f,onBack:()=>u("provider"),onClose:o,onComplete:i,onOpen:l=>{if(o(),l==="block"){d({type:"SET_MAIN_VIEW",view:"block_studio"}),d({type:"OPEN_NEW_BLOCK_MODAL"});return}d({type:"SET_MAIN_VIEW",view:l})}})}):e.jsx("div",{onClick:de,style:{position:"fixed",inset:0,background:n.modalOverlay,display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,backdropFilter:"blur(4px)"},children:e.jsxs("div",{style:{background:n.modalBg,border:`1px solid ${n.cellBorder}`,borderRadius:12,width:560,maxWidth:"calc(100vw - 48px)",maxHeight:"calc(100vh - 80px)",display:"flex",flexDirection:"column",boxShadow:"0 20px 60px rgba(0,0,0,0.5)",overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"20px 24px 0",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("h2",{style:{fontSize:16,fontWeight:600,color:n.textPrimary,fontFamily:n.font,margin:0},children:a==="done"?"Import Complete":"Set Up Semantic Layer"}),e.jsx("button",{onClick:o,style:{background:"transparent",border:"none",cursor:"pointer",color:n.textMuted,fontSize:18,lineHeight:1,padding:"2px 4px",borderRadius:4},children:"×"})]}),a!=="done"&&e.jsx("div",{style:{padding:"12px 24px 0",display:"flex",gap:4},children:["provider","configure","preview","importing"].map((l,h)=>e.jsx("div",{style:{flex:1,height:3,borderRadius:2,background:["provider","configure","preview","importing"].indexOf(a)>=h?n.accent:n.cellBorder,transition:"background 0.2s"}},l))}),e.jsxs("div",{style:{padding:"20px 24px 24px",flex:1,overflowY:"auto"},children:[a==="provider"&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsx("div",{style:{fontSize:13,color:n.textSecondary,fontFamily:n.font,lineHeight:1.5},children:"Connect dbt for the governed DQL 2.0 path, or import a supported external semantic provider."}),It.map(l=>{const h=t===l.id,R=p===l.id;return e.jsxs("button",{onClick:()=>S(l.id),style:{background:R?`${l.color}11`:n.inputBg,border:`2px solid ${R?l.color:n.cellBorder}`,borderRadius:10,padding:"14px 16px",cursor:"pointer",textAlign:"left",display:"flex",flexDirection:"column",gap:4,transition:"border-color 0.15s, background 0.15s"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{display:"inline-block",width:10,height:10,borderRadius:"50%",background:l.color,flexShrink:0}}),e.jsx("span",{style:{fontSize:14,fontWeight:600,color:n.textPrimary,fontFamily:n.font},children:l.label}),h&&e.jsx("span",{style:{fontSize:10,fontWeight:600,color:l.color,fontFamily:n.font,background:`${l.color}18`,padding:"2px 8px",borderRadius:8,marginLeft:4},children:"Detected"})]}),e.jsx("span",{style:{fontSize:12,color:n.textMuted,fontFamily:n.font,lineHeight:1.4},children:l.description})]},l.id)})]}),a==="configure"&&p&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsx("div",{style:{fontSize:13,color:n.textSecondary,fontFamily:n.font,lineHeight:1.5},children:p==="snowflake"?"Select the Snowflake connection to introspect semantic views.":`Configure the source for your ${p==="dbt"?"dbt":"Cube.js"} project.`}),p==="snowflake"?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx("label",{style:k,children:"Connection"}),e.jsxs("select",{value:U,onChange:l=>V(l.target.value),style:ne,children:[e.jsx("option",{value:"",children:"Select a connection..."}),O.map(l=>e.jsx("option",{value:l,children:l},l))]}),O.length===0&&e.jsx("span",{style:{fontSize:11,color:n.warning??"#f0ad4e",fontFamily:n.font},children:"No connections configured. Set up a Snowflake connection first."})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:()=>_("local"),style:{background:L==="local"?n.accent:"transparent",color:L==="local"?"#fff":n.textSecondary,border:`1px solid ${L==="local"?n.accent:n.cellBorder}`,borderRadius:6,padding:"5px 14px",cursor:"pointer",fontSize:12,fontFamily:n.font,fontWeight:500},children:"Local Path"}),e.jsx("button",{onClick:()=>_("repo"),style:{background:L==="repo"?n.accent:"transparent",color:L==="repo"?"#fff":n.textSecondary,border:`1px solid ${L==="repo"?n.accent:n.cellBorder}`,borderRadius:6,padding:"5px 14px",cursor:"pointer",fontSize:12,fontFamily:n.font,fontWeight:500},children:"Git Repository"})]}),L==="local"?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx("label",{style:k,children:"Project Path"}),e.jsx("input",{value:f,onChange:l=>D(l.target.value),placeholder:p==="dbt"?"../my-dbt-project":"../my-cube-project",style:ne}),e.jsx("span",{style:{fontSize:11,color:n.textMuted,fontFamily:n.font},children:p==="dbt"?"Path to the directory containing dbt_project.yml":"Path to the directory containing model/ or schema/"})]}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx("label",{style:k,children:"Repository URL"}),e.jsx("input",{value:b,onChange:l=>E(l.target.value),placeholder:"https://github.com/org/repo",style:ne})]}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6},children:[e.jsx("label",{style:k,children:"Branch"}),e.jsx("input",{value:W,onChange:l=>$(l.target.value),placeholder:"main",style:ne})]}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6},children:[e.jsx("label",{style:k,children:"Sub-path"}),e.jsx("input",{value:B,onChange:l=>T(l.target.value),placeholder:"optional/sub/dir",style:ne})]})]})]})]}),m&&e.jsxs("div",{style:{background:`${n.error}12`,border:`1px solid ${n.error}40`,borderRadius:8,padding:"10px 14px"},children:[e.jsx("div",{style:{fontSize:12,color:n.error,fontFamily:n.font,fontWeight:600,marginBottom:4},children:"Validation Failed"}),e.jsx("div",{style:{fontSize:12,color:n.textSecondary,fontFamily:n.font,lineHeight:1.4},children:m}),C&&e.jsx("div",{style:{fontSize:11,color:n.textMuted,fontFamily:n.font,marginTop:6,fontStyle:"italic"},children:C})]})]}),a==="preview"&&j&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsx("div",{style:{fontSize:13,color:n.textSecondary,fontFamily:n.font,lineHeight:1.5},children:"Review what will be imported into your project."}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:10},children:Object.entries(j.counts).filter(([,l])=>l>0).map(([l,h])=>e.jsxs("div",{style:{background:n.inputBg,borderRadius:8,padding:"12px 14px",border:`1px solid ${n.cellBorder}`,textAlign:"center"},children:[e.jsx("div",{style:{fontSize:22,fontWeight:700,color:n.accent,fontFamily:n.font},children:h}),e.jsxs("div",{style:{fontSize:11,color:n.textMuted,fontFamily:n.font,textTransform:"capitalize"},children:[l.replace("_","-"),"s"]})]},l))}),j.domains.length>0&&e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:n.textSecondary,fontFamily:n.font,marginBottom:6},children:"Domains"}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:j.domains.map(l=>e.jsx("span",{style:{fontSize:11,fontFamily:n.font,background:n.pillBg,padding:"3px 10px",borderRadius:8,color:n.textSecondary},children:l},l))})]}),j.warnings.length>0&&e.jsxs("div",{style:{background:`${n.warning??"#f0ad4e"}12`,border:`1px solid ${n.warning??"#f0ad4e"}40`,borderRadius:8,padding:"10px 14px"},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:n.warning??"#f0ad4e",fontFamily:n.font,marginBottom:4},children:"Warnings"}),j.warnings.map((l,h)=>e.jsx("div",{style:{fontSize:12,color:n.textSecondary,fontFamily:n.font,lineHeight:1.4},children:l},h))]}),x&&e.jsxs("div",{style:{background:`${n.error}12`,border:`1px solid ${n.error}40`,borderRadius:8,padding:"10px 14px"},children:[e.jsx("div",{style:{fontSize:12,color:n.error,fontFamily:n.font,fontWeight:600,marginBottom:4},children:"Import Failed"}),e.jsx("div",{style:{fontSize:12,color:n.textSecondary,fontFamily:n.font,lineHeight:1.4},children:x}),I&&e.jsx("div",{style:{fontSize:11,color:n.textMuted,fontFamily:n.font,marginTop:6,fontStyle:"italic"},children:I})]})]}),a==="importing"&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:16,padding:"32px 0"},children:[e.jsx("div",{style:{width:40,height:40,borderRadius:"50%",border:`3px solid ${n.cellBorder}`,borderTopColor:n.accent,animation:"spin 0.8s linear infinite"}}),e.jsx("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"}),e.jsxs("div",{style:{fontSize:14,color:n.textSecondary,fontFamily:n.font},children:["Importing ",p," semantic layer..."]}),e.jsx("div",{style:{fontSize:12,color:n.textMuted,fontFamily:n.font},children:"Parsing models, writing YAML files, refreshing state"})]}),a==="done"&&M&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"12px 0"},children:[e.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:36,height:36,borderRadius:"50%",background:`${n.success??"#28a745"}20`,color:n.success??"#28a745",fontSize:20,fontWeight:700},children:"✓"}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:600,color:n.textPrimary,fontFamily:n.font},children:"Semantic layer imported successfully"}),e.jsx("div",{style:{fontSize:12,color:n.textMuted,fontFamily:n.font},children:Object.entries(M.counts).filter(([,l])=>l>0).map(([l,h])=>`${h} ${l.replace("_","-")}${h!==1?"s":""}`).join(", ")})]})]}),M.manifest.warnings.length>0&&e.jsx("div",{style:{background:`${n.warning??"#f0ad4e"}12`,border:`1px solid ${n.warning??"#f0ad4e"}40`,borderRadius:8,padding:"10px 14px"},children:M.manifest.warnings.map((l,h)=>e.jsx("div",{style:{fontSize:12,color:n.textSecondary,fontFamily:n.font},children:l},h))}),e.jsx("div",{style:{background:n.inputBg,borderRadius:8,padding:"12px 14px",border:`1px solid ${n.cellBorder}`,fontSize:12,color:n.textMuted,fontFamily:n.font,lineHeight:1.5},children:"Your semantic definitions are now available in the Semantic Layer browser. Use the Guided Builder or drag metrics into your editor to start creating blocks."})]})]}),e.jsxs("div",{style:{padding:"14px 24px",borderTop:`1px solid ${n.cellBorder}`,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("div",{children:a!=="provider"&&a!=="importing"&&a!=="done"&&e.jsx("button",{onClick:()=>{a==="configure"?u("provider"):a==="preview"&&u("configure")},style:{background:"transparent",border:`1px solid ${n.cellBorder}`,borderRadius:6,color:n.textSecondary,cursor:"pointer",fontSize:13,fontFamily:n.font,fontWeight:500,padding:"7px 16px"},children:"Back"})}),e.jsxs("div",{style:{display:"flex",gap:10},children:[a!=="importing"&&e.jsx("button",{onClick:o,style:{background:n.btnBg,border:`1px solid ${n.btnBorder}`,borderRadius:6,color:n.textSecondary,cursor:"pointer",fontSize:13,fontFamily:n.font,fontWeight:500,padding:"7px 16px"},children:"Cancel"}),a==="provider"&&e.jsx("button",{onClick:()=>p&&u("configure"),disabled:!p,style:{background:n.accent,border:`1px solid ${n.accent}`,borderRadius:6,color:"#fff",cursor:p?"pointer":"not-allowed",fontSize:13,fontFamily:n.font,fontWeight:500,padding:"7px 20px",opacity:p?1:.5},children:p==="dbt"?"Connect dbt":"Next"}),a==="configure"&&e.jsx("button",{onClick:ge,disabled:v,style:{background:n.accent,border:`1px solid ${n.accent}`,borderRadius:6,color:"#fff",cursor:v?"not-allowed":"pointer",fontSize:13,fontFamily:n.font,fontWeight:500,padding:"7px 20px",opacity:v?.6:1,display:"flex",alignItems:"center",gap:6},children:v?"Validating...":"Validate & Preview"}),a==="preview"&&e.jsx("button",{onClick:re,style:{background:n.accent,border:`1px solid ${n.accent}`,borderRadius:6,color:"#fff",cursor:"pointer",fontSize:13,fontFamily:n.font,fontWeight:500,padding:"7px 20px"},children:"Import"}),a==="done"&&e.jsx("button",{onClick:Q,style:{background:n.accent,border:`1px solid ${n.accent}`,borderRadius:6,color:"#fff",cursor:"pointer",fontSize:13,fontFamily:n.font,fontWeight:500,padding:"7px 20px"},children:"Open Semantic Browser"})]})]})]})})}const we=3;function Bt({t,aiReady:o=!0,onSetupAi:i}){const{dispatch:r}=Be(),[d,n]=c.useState(null),[a,u]=c.useState(!0);c.useEffect(()=>{if(!o){u(!1);return}let D=!1;return u(!0),q.getProposeReadiness({limit:we}).then(b=>{D||n(b)}).catch(()=>{D||n(null)}).finally(()=>{D||u(!1)}),()=>{D=!0}},[o]);const p=c.useMemo(()=>d!=null&&d.ready?[...d.plan.domains.flatMap(b=>b.candidates)].sort((b,E)=>(E.score??0)-(b.score??0)).slice(0,we):[],[d]),S=c.useCallback(()=>{r({type:"SET_MAIN_VIEW",view:"readiness"})},[r]),f=c.useCallback(()=>{r({type:"SET_MAIN_VIEW",view:"block_studio"})},[r]);return o?e.jsxs("div",{style:_e(t),children:[e.jsx("style",{children:Ve}),e.jsxs("div",{style:Fe,children:[e.jsx("span",{style:Qe(t),children:e.jsx(Ie,{size:16,strokeWidth:2,"aria-hidden":"true"})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{style:{fontSize:14,fontWeight:760,color:t.textPrimary},children:"New here? Start with blocks DQL built for you"}),e.jsxs("p",{style:{margin:"3px 0 0",fontSize:12.5,lineHeight:1.5,color:t.textSecondary},children:["A ",e.jsx("strong",{children:"block"})," is a reusable piece of analytics — one trusted metric or query your whole team can reuse across answers and Apps. Here are a few important ones DQL drafted from your dbt models. Open ",e.jsx("em",{children:"See details"})," on each to understand exactly what it measures and the SQL behind it — then build your own."]})]})]}),a?e.jsx("div",{style:Et,children:Array.from({length:we}).map((D,b)=>e.jsx("div",{className:"dql-starter-skel",style:Ot(t)},b))}):p.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:Dt,children:p.map((D,b)=>e.jsx(qt,{candidate:D,index:b,t},D.slug))}),e.jsxs("div",{style:He(t),children:[e.jsx("span",{style:{fontSize:12,color:t.textMuted},children:"Open a suggested block to edit it, or build one from scratch."}),e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsxs("button",{type:"button",onClick:S,style:Ue(t),children:["Open block suggestions",e.jsx(he,{size:14,strokeWidth:2.2,"aria-hidden":"true"})]}),e.jsxs("button",{type:"button",onClick:f,style:Se(t),children:[e.jsx(ue,{size:14,strokeWidth:2,"aria-hidden":"true"}),"Build my own"]})]})]})]}):e.jsxs("div",{style:_t(t),children:[e.jsx(ot,{size:16,strokeWidth:2,"aria-hidden":"true",style:{flexShrink:0,marginTop:1,color:t.textMuted}}),e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsx("span",{style:{fontSize:12.5,color:t.textSecondary,lineHeight:1.5},children:d&&!d.ready&&d.reason?d.reason:"No starter blocks to suggest yet — connect a dbt project so DQL can read your models, or build your first block by hand to see how it works."}),e.jsxs("button",{type:"button",onClick:f,style:Se(t),children:[e.jsx(ue,{size:14,strokeWidth:2,"aria-hidden":"true"}),"Build a block in Block Studio"]})]})]})]}):e.jsxs("div",{style:_e(t),children:[e.jsx("style",{children:Ve}),e.jsxs("div",{style:Fe,children:[e.jsx("span",{style:Qe(t),children:e.jsx(Ie,{size:16,strokeWidth:2,"aria-hidden":"true"})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{style:{fontSize:14,fontWeight:760,color:t.textPrimary},children:"Turn on AI to generate starter blocks"}),e.jsxs("p",{style:{margin:"3px 0 0",fontSize:12.5,lineHeight:1.5,color:t.textSecondary},children:["Block suggestions are drafted by ",e.jsx("strong",{children:"your AI provider"})," from your dbt models and data — that's where the value is. Connect a provider (OpenAI, Anthropic, Gemini, or a local Ollama) and DQL will propose a few important blocks you can learn from and certify."]})]})]}),e.jsxs("div",{style:He(t),children:[e.jsx("span",{style:{fontSize:12,color:t.textMuted},children:"AI also powers governed answers and research — it's the heart of DQL."}),e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[i?e.jsxs("button",{type:"button",onClick:i,style:Ue(t),children:["Connect an AI provider",e.jsx(he,{size:14,strokeWidth:2.2,"aria-hidden":"true"})]}):null,e.jsxs("button",{type:"button",onClick:f,style:Se(t),children:[e.jsx(ue,{size:14,strokeWidth:2,"aria-hidden":"true"}),"Build one by hand"]})]})]})]})}function qt({candidate:t,index:o,t:i}){const[r,d]=c.useState(!1),[n,a]=c.useState(null),[u,p]=c.useState(!1),[S,f]=c.useState(null),D=c.useCallback(()=>{d($=>{const B=!$;return B&&!n&&!u&&(p(!0),f(null),q.proposePreview(t.slug).then(T=>a(T.candidate)).catch(T=>f(T instanceof Error?T.message:"Could not load the details.")).finally(()=>p(!1))),B})},[t.slug,n,u]),b=n??t,E=t.evidence.slice(0,2).join(" · "),W=t.description||E||"A governed metric drafted from your dbt model.";return e.jsxs("div",{className:"dql-starter-card",style:{...Lt(i),animationDelay:`${o*70}ms`},children:[e.jsxs("button",{type:"button",onClick:D,"aria-expanded":r,style:Rt,children:[e.jsx("span",{style:Tt(i),children:o+1}),e.jsxs("span",{style:{display:"grid",gap:4,minWidth:0,flex:1,textAlign:"left"},children:[e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:7,flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:13.5,fontWeight:720,color:i.textPrimary},children:t.model}),e.jsx(xt,{state:"ai_generated"}),t.pattern?e.jsx("span",{style:Pt(i),children:t.pattern}):null,t.grain?e.jsxs("span",{style:{fontSize:11,color:i.textMuted},children:["grain ",t.grain]}):null]}),e.jsx("span",{style:{fontSize:12,color:i.textSecondary,lineHeight:1.45},children:W})]}),e.jsxs("span",{style:$t(i),children:[r?e.jsx(rt,{size:13,strokeWidth:2.2}):e.jsx(st,{size:13,strokeWidth:2.2}),r?"Hide":"See details"]})]}),r?e.jsx("div",{style:Mt(i),children:u?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12,color:i.textMuted},children:[e.jsx(at,{size:13,className:"dql-starter-spin"})," Loading the SQL and what it measures…"]}):S?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12,color:i.warning},children:[e.jsx(Ke,{size:14})," ",S]}):e.jsxs(e.Fragment,{children:[b.description?e.jsx(xe,{label:"What it is",t:i,children:e.jsx("span",{style:{fontSize:12.5,color:i.textSecondary,lineHeight:1.5},children:b.description})}):null,(b.outputs??[]).length>0?e.jsx(xe,{label:"What it measures",t:i,children:e.jsx("span",{style:{display:"flex",flexWrap:"wrap",gap:5},children:b.outputs.map($=>e.jsx("span",{style:Wt(i),children:$},$))})}):null,(b.examples??[]).length>0?e.jsx(xe,{label:"Answers questions like",t:i,children:e.jsx("ul",{style:{margin:0,padding:"0 0 0 16px",display:"grid",gap:3},children:b.examples.slice(0,3).map($=>e.jsx("li",{style:{fontSize:12,color:i.textSecondary,lineHeight:1.45},children:$},$))})}):null,e.jsx(xe,{label:"The SQL behind it",t:i,children:b.sqlPreview?e.jsx("pre",{style:Nt(i),children:e.jsx("code",{style:{fontFamily:i.fontMono,fontSize:11.5,whiteSpace:"pre-wrap",wordBreak:"break-word",color:i.textPrimary},children:b.sqlPreview.trim()})}):e.jsx("span",{style:{fontSize:11.5,color:i.textMuted},children:"SQL preview is not available for this model yet."})}),e.jsx(zt,{verdict:b.certifierVerdict,t:i})]})}):null]})}function xe({label:t,children:o,t:i}){return e.jsxs("div",{style:{display:"grid",gap:5},children:[e.jsx("span",{style:{fontSize:9.5,fontWeight:800,letterSpacing:"0.05em",textTransform:"uppercase",color:i.textMuted},children:t}),o]})}function zt({verdict:t,t:o}){const i=!!(t!=null&&t.ready&&t.blocking.length===0);return e.jsx(xe,{label:"Can you trust it",t:o,children:i?e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:12,color:o.success},children:[e.jsx(lt,{size:14})," Grain, outputs, and context are set — ready to certify."]}):e.jsxs("span",{style:{display:"inline-flex",alignItems:"flex-start",gap:6,fontSize:12,color:o.warning,lineHeight:1.45},children:[e.jsx(Ke,{size:14,style:{flexShrink:0,marginTop:1}}),"An AI draft — a person reviews and certifies it before your team relies on it. That review step is what makes a block trustworthy."]})})}const _e=t=>({border:`1px solid ${t.cellBorder}`,borderRadius:12,background:t.cellBg,padding:16,display:"grid",gap:14}),Fe={display:"flex",gap:11,alignItems:"flex-start"},Qe=t=>({flex:"none",width:32,height:32,borderRadius:9,display:"inline-flex",alignItems:"center",justifyContent:"center",background:`${t.accent}18`,color:t.accent}),Dt={display:"grid",gap:8},Lt=t=>({border:`1px solid ${t.cellBorder}`,borderLeft:`3px solid ${t.accent}`,borderRadius:9,background:t.appBg,overflow:"hidden"}),Rt={width:"100%",display:"flex",gap:11,alignItems:"flex-start",padding:11,border:"none",background:"transparent",cursor:"pointer",textAlign:"left"},Tt=t=>({flex:"none",width:20,height:20,borderRadius:6,display:"inline-flex",alignItems:"center",justifyContent:"center",background:`${t.accent}18`,color:t.accent,fontSize:11,fontWeight:800,marginTop:1}),$t=t=>({display:"inline-flex",alignItems:"center",gap:4,flexShrink:0,padding:"5px 9px",borderRadius:6,border:`1px solid ${t.cellBorder}`,background:t.cellBg,color:t.textSecondary,fontSize:11,fontWeight:650,whiteSpace:"nowrap",alignSelf:"flex-start"}),Mt=t=>({borderTop:`1px solid ${t.cellBorder}`,padding:"11px 11px 12px 42px",display:"grid",gap:11}),Pt=t=>({fontSize:10,padding:"2px 7px",borderRadius:4,background:`${t.textMuted}1f`,color:t.textSecondary,fontWeight:600}),Wt=t=>({fontSize:11,fontWeight:600,padding:"3px 8px",borderRadius:6,border:`1px solid ${t.cellBorder}`,background:t.cellBg,color:t.textSecondary,fontFamily:t.fontMono}),Nt=t=>({margin:0,border:`1px solid ${t.cellBorder}`,borderRadius:8,background:t.inputBg,padding:"9px 11px",overflow:"auto",maxHeight:240}),He=t=>({display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,flexWrap:"wrap",borderTop:`1px solid ${t.cellBorder}`,paddingTop:12}),Ue=t=>Je(t,{variant:"primary",size:"md"}),Se=t=>Je(t,{variant:"ghost",size:"md"}),Et={display:"grid",gap:8},Ot=t=>({height:56,borderRadius:9,border:`1px solid ${t.cellBorder}`,background:t.appBg}),_t=t=>({display:"flex",gap:10,alignItems:"flex-start",border:`1px dashed ${t.cellBorder}`,borderRadius:9,padding:14,background:t.appBg}),Ve=`
9
+ @keyframes dql-starter-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
10
+ .dql-starter-card { animation: dql-starter-rise 360ms cubic-bezier(0.2,0.7,0.2,1) both; }
11
+ .dql-starter-card:hover { border-color: var(--color-accent-blue, #2563eb); }
12
+ @keyframes dql-starter-pulse { 0%,100% { opacity: 0.5; } 50% { opacity: 0.85; } }
13
+ .dql-starter-skel { animation: dql-starter-pulse 1.3s ease-in-out infinite; }
14
+ @keyframes dql-starter-spin { to { transform: rotate(360deg); } }
15
+ .dql-starter-spin { animation: dql-starter-spin 0.8s linear infinite; }
16
+ @media (prefers-reduced-motion: reduce) {
17
+ .dql-starter-card, .dql-starter-skel, .dql-starter-spin { animation: none !important; }
18
+ }
19
+ `,Ft=[["dql-manifest.json","Compiled project graph for lineage, trust, Apps, and AI context."],["semantic-layer/","Imported or authored metrics, dimensions, models, and saved queries."],["connections","Warehouse credentials and schema status for executing blocks."],["blocks/","Reusable DQL blocks built from dbt objects, SQL, tables, or semantic metrics."],["notebooks/","Analysis workspaces where users explore, edit, and assemble blocks."],["apps/","Published consumption surfaces for stakeholders."]];function sn(){var ee;const{state:t,dispatch:o}=Be(),i=Ye[t.themeMode],r=Gt(t.files),d=Yt(t.semanticLayer),n=t.blockStudioDbtStatus,a={models:Math.max(d.models,(n==null?void 0:n.counts.semanticModels)??0,(n==null?void 0:n.counts.models)??0),metrics:Math.max(d.metrics,(n==null?void 0:n.counts.metrics)??0),dimensions:d.dimensions,savedQueries:Math.max(d.savedQueries,(n==null?void 0:n.counts.savedQueries)??0)},u=Jt(t.schemaTables),[p,S]=c.useState(null),[f,D]=c.useState(!1),[b,E]=c.useState(!1),[W,$]=c.useState(null);c.useEffect(()=>{let x=!1;return q.getConnections().then(A=>{x||S(A)}),q.getProviderSettings().then(A=>{x||D(A.providers.some(I=>I.enabled&&I.configured))}).catch(()=>{}),q.getBlockStudioDbtStatus().then(A=>{x||o({type:"SET_BLOCK_STUDIO_DBT_STATUS",status:A})}).catch(()=>{x||o({type:"SET_BLOCK_STUDIO_DBT_STATUS",status:null})}),o({type:"SET_SEMANTIC_LOADING",loading:!0}),q.getSemanticLayer().then(A=>{x||o({type:"SET_SEMANTIC_LAYER",layer:A})}).finally(()=>{x||o({type:"SET_SEMANTIC_LOADING",loading:!1})}),o({type:"SET_APPS_LOADING",loading:!0}),q.listApps().then(A=>{x||o({type:"SET_APPS",apps:A})}).catch(()=>{x||o({type:"SET_APPS",apps:[]})}).finally(()=>{x||o({type:"SET_APPS_LOADING",loading:!1})}),()=>{x=!0}},[o]);const B=Object.keys((p==null?void 0:p.connections)??{}).length,T=((ee=p==null?void 0:p.dbtProfiles)==null?void 0:ee.length)??0,V=!!(n!=null&&n.artifacts.manifest.exists||n!=null&&n.artifacts.semanticManifest.exists)||t.semanticLayer.available||d.total>0||r.blocks>0,L=B>0||t.schemaTables.length>0,_=r.blocks>0,O=r.notebooks>0,G=t.apps.length>0,j=V?L?_?"notebook":"build":"connection":"source",K=x=>{o({type:"SET_SIDEBAR_PANEL",panel:x})},v=x=>{o({type:"SET_SETTINGS_TAB",tab:x}),o({type:"SET_MAIN_VIEW",view:"settings"})},X=async()=>{o({type:"SET_SEMANTIC_LOADING",loading:!0});try{const[x,A]=await Promise.all([q.getSemanticLayer(),q.listNotebooks()]);o({type:"SET_SEMANTIC_LAYER",layer:x}),o({type:"SET_FILES",files:A})}finally{o({type:"SET_SEMANTIC_LOADING",loading:!1})}},m=c.useMemo(()=>[{id:"source",number:"1",title:"Connect dbt and compile context",body:"Start with the dbt repo or semantic source. Import models, metrics, dimensions, and compile the local manifest context that DQL uses for lineage and AI.",state:V?"ready":j==="source"?"active":"waiting",Icon:Ne,primaryLabel:V?"Refresh semantic import":"Connect dbt repo",onPrimary:()=>E(!0),secondaryLabel:"Browse lineage",onSecondary:()=>K("lineage"),evidence:[`${a.models} semantic models`,`${a.metrics} metrics`,`${a.dimensions} dimensions`,`${r.blocks+r.businessViews} DQL artifacts`]},{id:"connection",number:"2",title:"Connect database and test access",body:"Use dbt profiles.yml where your runtime already resolves it, or enter warehouse credentials directly. Test the connection and refresh schema before building blocks.",state:L?"ready":j==="connection"?"active":"waiting",Icon:be,primaryLabel:L?"Manage connections":"Add database connection",onPrimary:()=>v("database"),secondaryLabel:"Open connections",onSecondary:()=>v("database"),evidence:[`${B} connection${B===1?"":"s"}`,`${T} dbt profile target${T===1?"":"s"}`,`${u.tables} tables`,`${u.columns} columns`]},{id:"ai",number:"3",title:"Connect an AI provider (optional)",body:"AI powers governed Ask and assisted authoring. Without it, SQL execution, dbt metadata, lineage, deterministic helpers, and other non-AI paths remain available.",state:f?"ready":"optional",Icon:Ie,primaryLabel:f?"Manage AI providers":"Connect AI provider",onPrimary:()=>v("ai"),secondaryLabel:"Open settings",onSecondary:()=>v("ai"),evidence:[f?"Provider configured — test in Settings to verify":"Optional · limited-AI mode"]},{id:"build",number:"4",title:"Build governed blocks",body:"Build reviewed reusable DQL blocks from dbt and semantic context. Use AI suggestions when configured, or work deterministically in Block Studio.",state:_?"ready":j==="build"?"active":"waiting",Icon:ue,primaryLabel:_?"Open block suggestions":"Suggest blocks with AI",onPrimary:()=>o({type:"SET_MAIN_VIEW",view:"readiness"}),secondaryLabel:"Open Block Studio",onSecondary:()=>o({type:"SET_MAIN_VIEW",view:"block_studio"}),evidence:[`${r.blocks} blocks`,`${r.terms} business terms`,`${r.businessViews} business views`]},{id:"notebook",number:"5",title:"Analyze in notebooks and publish to Apps",body:"Search, add, and edit notebooks around reviewed blocks. When the answer is ready, promote it into an App for stakeholder consumption.",state:O||G?"ready":j==="notebook"?"active":"waiting",Icon:Ee,primaryLabel:O?"Open notebooks":"Create notebook",onPrimary:()=>{O?K("files"):o({type:"OPEN_NEW_NOTEBOOK_MODAL"})},secondaryLabel:G?"Open Apps":"Build App",onSecondary:()=>K("apps"),evidence:[`${r.notebooks} notebooks`,`${t.apps.length} apps`,`${t.apps.reduce((x,A)=>x+A.dashboards.length,0)} dashboards`]}],[f,G,B,L,r.blocks,r.businessViews,r.notebooks,r.terms,j,_,T,O,u.columns,u.tables,a.dimensions,a.metrics,V,t.apps]),Z=m.filter(x=>x.state==="ready"||x.state==="optional").length,C=m.find(x=>x.id===j)??m[0],N=m.find(x=>x.id===W)??C,M=m.every(x=>x.state==="ready"||x.state==="optional");return e.jsxs("div",{style:{flex:1,minWidth:0,overflow:"auto",background:i.appBg},children:[e.jsx("style",{children:Kt}),e.jsxs("main",{className:"dql-home-page",children:[e.jsxs("section",{className:"dql-home-hero dql-home-fade",style:{animationDelay:"0ms"},children:[e.jsxs("div",{className:"dql-home-hero-copy",children:[e.jsxs("div",{className:"dql-home-brand-row",children:[e.jsx("span",{className:"dql-home-logo",children:"DQL"}),e.jsx("span",{style:{color:i.textMuted},children:"Guided setup"})]}),e.jsx("h1",{style:{color:i.textPrimary},children:M?"Your workspace is ready":"Set up your analytics workspace"}),e.jsx("p",{className:"dql-home-lead",style:{color:i.textSecondary},children:M?"Source, database, blocks, notebooks and Apps are all connected. Jump back into building.":"Connect your data, build reviewed DQL blocks, then deliver with notebooks and Apps."}),e.jsx("div",{className:"dql-home-cta-row",children:e.jsxs("button",{className:"dql-home-primary-btn",onClick:C.onPrimary,children:[e.jsx(C.Icon,{size:15,strokeWidth:2.2,"aria-hidden":"true"}),C.primaryLabel,e.jsx(he,{size:15,strokeWidth:2.2,"aria-hidden":"true"})]})})]}),e.jsxs("div",{className:"dql-home-progress-badge",style:{borderColor:i.cellBorder,background:i.inputBg},children:[e.jsx(Ut,{ready:Z,total:m.length,t:i}),e.jsxs("div",{children:[e.jsxs("strong",{style:{color:i.textPrimary},children:[Z," of ",m.length," satisfied"]}),e.jsx("span",{style:{color:i.textMuted},children:M?"All set up":Vt(j)})]})]})]}),e.jsx("section",{className:"dql-home-stepper dql-home-fade","aria-label":"DQL setup steps",style:{animationDelay:"60ms"},children:m.map((x,A)=>e.jsx(Qt,{step:x,index:A,total:m.length,selected:(N==null?void 0:N.id)===x.id,t:i,onSelect:()=>$(x.id)},x.id))}),N&&e.jsx("section",{className:"dql-home-fade",style:{animationDelay:"120ms"},children:e.jsx(Ht,{step:N,t:i})}),(N==null?void 0:N.id)==="build"&&!_&&e.jsx("section",{className:"dql-home-fade",style:{animationDelay:"150ms"},children:e.jsx(Bt,{t:i,aiReady:f,onSetupAi:()=>v("ai")})}),e.jsxs("section",{className:"dql-home-metrics dql-home-fade",style:{animationDelay:"180ms"},children:[e.jsx(pe,{label:"Blocks",value:r.blocks,Icon:ue,t:i}),e.jsx(pe,{label:"Notebooks",value:r.notebooks,Icon:Ee,t:i}),e.jsx(pe,{label:"Apps",value:t.apps.length,Icon:ut,t:i}),e.jsx(pe,{label:"Tables",value:u.tables,Icon:be,t:i}),e.jsx(pe,{label:"Metrics",value:a.metrics,Icon:dt,t:i})]}),e.jsxs("details",{className:"dql-home-details dql-home-fade",style:{animationDelay:"240ms",borderColor:i.cellBorder,background:i.cellBg},children:[e.jsxs("summary",{style:{color:i.textSecondary},children:[e.jsx("span",{children:"Project details"}),e.jsx("span",{className:"dql-home-details-hint",style:{color:i.textMuted},children:"catalog, schema, and artifacts"})]}),e.jsxs("div",{className:"dql-home-details-body",children:[e.jsxs("div",{className:"dql-home-context-grid",children:[e.jsx(Ce,{title:"Source objects",description:"Trusted inputs from dbt and semantic imports.",Icon:Ne,t:i,rows:[["dbt project",(n==null?void 0:n.projectName)??(n!=null&&n.configured?"Configured":"Not detected")],["manifest.json",Ge(n==null?void 0:n.artifacts.manifest)],["semantic_manifest.json",Ge(n==null?void 0:n.artifacts.semanticManifest)],["Semantic models",String(a.models)],["Metrics",String(a.metrics)],["Dimensions",String(a.dimensions)]],actionLabel:"Connect or refresh",onAction:()=>E(!0)}),e.jsx(Ce,{title:"Database catalog",description:"Connection and schema determine whether blocks run.",Icon:be,t:i,rows:[["Default connection",(p==null?void 0:p.default)??"Unknown"],["Connection profiles",String(B)],["dbt profile targets",String(T)],["Schemas",String(u.schemas)],["Tables",String(u.tables)],["Columns",String(u.columns)]],actionLabel:"Open connections",onAction:()=>K("connection")}),e.jsx(Ce,{title:"Authoring inventory",description:"Versioned files that move into notebooks and Apps.",Icon:ct,t:i,rows:[["Blocks",String(r.blocks)],["Business terms",String(r.terms)],["Business views",String(r.businessViews)],["Notebooks",String(r.notebooks)],["Apps",String(t.apps.length)]],actionLabel:"Open Block Studio",onAction:()=>o({type:"SET_MAIN_VIEW",view:"block_studio"})})]}),e.jsx("div",{className:"dql-home-artifact-list",children:Ft.map(([x,A])=>e.jsxs("div",{className:"dql-home-artifact-row",style:{borderColor:i.cellBorder},children:[e.jsx("code",{style:{color:i.textPrimary},children:x}),e.jsx("span",{style:{color:i.textSecondary},children:A})]},x))})]})]})]}),b&&e.jsx(At,{detectedProvider:t.semanticLayer.provider,onClose:()=>E(!1),onImported:()=>void X()})]})}const le="var(--color-accent-green, #16a34a)";function Ae(t,o){return t==="ready"?le:t==="active"?o.warning:t==="optional"?o.accent:o.textMuted}function Qt({step:t,index:o,total:i,selected:r,t:d,onSelect:n}){const a=t.Icon,u=t.state==="ready"?{background:le,borderColor:le,color:"#fff"}:t.state==="active"?{background:d.cellBg,borderColor:d.warning,color:d.warning}:{background:d.cellBg,borderColor:d.cellBorder,color:d.textMuted};return e.jsxs("button",{type:"button",className:`dql-home-node is-${t.state} ${r?"is-selected":""}`,onClick:n,style:{color:d.textSecondary,background:r?d.cellBg:"transparent"},children:[o<i-1?e.jsx("span",{className:"dql-home-node-track","aria-hidden":"true",style:{background:t.state==="ready"?le:d.cellBorder}}):null,e.jsx("span",{className:"dql-home-node-badge","aria-hidden":"true",style:u,children:t.state==="ready"?e.jsx(pt,{size:18,strokeWidth:3}):e.jsx(a,{size:18,strokeWidth:2})}),e.jsxs("span",{className:"dql-home-node-meta",children:[e.jsx("span",{className:"dql-home-node-title",style:{color:d.textPrimary},children:t.title.split(" ").slice(0,3).join(" ")}),e.jsx("span",{className:"dql-home-node-status",style:{color:Ae(t.state,d)},children:Ze(t.state)})]})]})}function Ht({step:t,t:o}){const i=t.Icon;return e.jsxs("article",{className:`dql-home-focus is-${t.state}`,style:{borderColor:t.state==="active"?o.warning:t.state==="ready"?`${le}`:o.cellBorder,background:o.cellBg},children:[e.jsx("div",{className:"dql-home-focus-icon",style:{background:`${o.accent}16`,color:o.accent},children:e.jsx(i,{size:20,strokeWidth:2,"aria-hidden":"true"})}),e.jsxs("div",{className:"dql-home-focus-body",children:[e.jsxs("div",{className:"dql-home-focus-head",children:[e.jsx("h2",{style:{color:o.textPrimary},children:t.title}),e.jsx("span",{className:"dql-home-status",style:{color:Ae(t.state,o),background:`${Ae(t.state,o)}1f`},children:Ze(t.state)})]}),e.jsx("p",{style:{color:o.textSecondary},children:t.body}),e.jsx("div",{className:"dql-home-evidence",children:t.evidence.map(r=>e.jsx("span",{style:{borderColor:o.cellBorder,color:o.textMuted},children:r},r))}),e.jsxs("div",{className:"dql-home-card-actions",children:[e.jsxs("button",{className:"dql-home-primary-btn dql-home-card-btn",onClick:t.onPrimary,children:[t.primaryLabel,e.jsx(he,{size:15,strokeWidth:2.2,"aria-hidden":"true"})]}),t.secondaryLabel&&t.onSecondary&&e.jsx("button",{className:"dql-home-secondary-btn dql-home-card-btn",onClick:t.onSecondary,children:t.secondaryLabel})]})]})]})}function pe({label:t,value:o,Icon:i,t:r}){return e.jsxs("div",{className:"dql-home-metric",style:{borderColor:r.cellBorder,background:r.cellBg},children:[e.jsx("span",{className:"dql-home-metric-icon",style:{color:r.accent},children:e.jsx(i,{size:15,strokeWidth:2,"aria-hidden":"true"})}),e.jsx("strong",{style:{color:r.textPrimary},children:o.toLocaleString()}),e.jsx("span",{style:{color:r.textMuted},children:t})]})}function Ut({ready:t,total:o,t:i}){const r=o>0?t/o:0,d=16,n=2*Math.PI*d;return e.jsxs("svg",{className:"dql-home-ring",width:44,height:44,viewBox:"0 0 44 44","aria-hidden":"true",children:[e.jsx("circle",{cx:"22",cy:"22",r:d,fill:"none",stroke:i.cellBorder,strokeWidth:"4"}),e.jsx("circle",{cx:"22",cy:"22",r:d,fill:"none",stroke:le,strokeWidth:"4",strokeLinecap:"round",strokeDasharray:n,strokeDashoffset:n*(1-r),transform:"rotate(-90 22 22)",style:{transition:"stroke-dashoffset 700ms ease"}}),e.jsx("text",{x:"22",y:"26",textAnchor:"middle",fontSize:"12",fontWeight:"800",fill:i.textPrimary,children:t})]})}function Vt(t){return t==="source"?"Connect a dbt or semantic source":t==="connection"?"Add and test a database":t==="ai"?"Connect an AI provider":t==="build"?"Build your first DQL block":"Open notebooks and publish an App"}function Ce({title:t,description:o,Icon:i,rows:r,actionLabel:d,onAction:n,t:a}){return e.jsxs("section",{className:"dql-home-context-panel",style:{borderColor:a.cellBorder,background:a.cellBg},children:[e.jsxs("div",{className:"dql-home-context-head",children:[e.jsx("div",{className:"dql-home-context-icon",style:{background:`${a.accent}18`,color:a.accent},children:e.jsx(i,{size:18,strokeWidth:2,"aria-hidden":"true"})}),e.jsxs("div",{children:[e.jsx("h2",{style:{color:a.textPrimary},children:t}),e.jsx("p",{style:{color:a.textSecondary},children:o})]})]}),e.jsx("div",{className:"dql-home-context-rows",children:r.map(([u,p])=>e.jsxs("div",{className:"dql-home-context-row",style:{borderColor:a.cellBorder},children:[e.jsx("span",{style:{color:a.textMuted},children:u}),e.jsx("strong",{style:{color:a.textPrimary},children:p})]},u))}),e.jsxs("button",{className:"dql-home-link-btn",onClick:n,children:[d,e.jsx(he,{size:15,strokeWidth:2,"aria-hidden":"true"})]})]})}function Ze(t){return t==="ready"?"Ready":t==="active"?"Next":t==="optional"?"Optional":"Waiting"}function Ge(t){return t?t.exists?typeof t.count=="number"?`Ready (${t.count})`:"Ready":"Missing":"Unknown"}function Gt(t){return t.reduce((o,i)=>(i.type==="block"?o.blocks+=1:i.type==="term"?o.terms+=1:i.type==="business_view"?o.businessViews+=1:(i.type==="notebook"||i.type==="workbook")&&(o.notebooks+=1),o),{notebooks:0,blocks:0,terms:0,businessViews:0})}function Yt(t){const o=t.metrics.length,i=t.measures.length,r=t.dimensions.length+t.timeDimensions.length,d=t.semanticModels.length,n=t.savedQueries.length;return{metrics:o,measures:i,dimensions:r,models:d,savedQueries:n,total:o+i+r+d+n+t.entities.length+t.hierarchies.length}}function Jt(t){const o=new Set;let i=0;for(const r of t){const[d,...n]=r.name.split(".");o.add(n.length>0?d:"default"),i+=r.columns.length}return{schemas:o.size,tables:t.length,columns:i}}const Kt=`
20
+ .dql-home-page {
21
+ width: min(1080px, calc(100% - 48px));
22
+ margin: 0 auto;
23
+ padding: 28px 0 56px;
24
+ display: flex;
25
+ flex-direction: column;
26
+ gap: 18px;
27
+ }
28
+
29
+ @keyframes dql-home-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
30
+ .dql-home-fade { animation: dql-home-rise 480ms cubic-bezier(0.2,0.7,0.2,1) both; }
31
+
32
+ .dql-home-hero { display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
33
+ .dql-home-hero-copy { display: flex; flex-direction: column; gap: 12px; min-width: 0; flex: 1 1 420px; }
34
+ .dql-home-brand-row { display: inline-flex; align-items: center; gap: 10px; font: 800 11px var(--font-mono, ui-monospace, monospace); letter-spacing: 0.08em; text-transform: uppercase; }
35
+ .dql-home-logo { display: inline-flex; align-items: center; justify-content: center; height: 24px; padding: 0 9px; border-radius: 7px; background: var(--color-accent-blue, #2563eb); color: var(--accent-on, #fff); }
36
+ .dql-home-hero h1 { margin: 0; font-size: 30px; line-height: 1.1; font-weight: 820; letter-spacing: -0.01em; }
37
+ .dql-home-lead { margin: 0; font-size: 14px; line-height: 1.5; max-width: 48ch; }
38
+ .dql-home-cta-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
39
+
40
+ .dql-home-primary-btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--color-accent-blue, #2563eb); border-radius: 9px; background: var(--color-accent-blue, #2563eb); color: var(--accent-on, #fff); padding: 9px 15px; font: 750 13px var(--font-ui, inherit); cursor: pointer; transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease; }
41
+ .dql-home-primary-btn:hover { filter: brightness(1.06); box-shadow: 0 8px 22px rgba(37,99,235,0.26); transform: translateY(-1px); }
42
+ .dql-home-secondary-btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border-color, rgba(0,0,0,0.16)); border-radius: 9px; background: transparent; color: inherit; padding: 9px 14px; font: 700 13px var(--font-ui, inherit); cursor: pointer; transition: border-color 120ms ease, background 120ms ease; }
43
+ .dql-home-secondary-btn:hover { border-color: var(--color-accent-blue, #2563eb); }
44
+
45
+ .dql-home-progress-badge { display: inline-flex; align-items: center; gap: 12px; border: 1px solid; border-radius: 12px; padding: 12px 16px; flex: none; }
46
+ .dql-home-progress-badge > div { display: flex; flex-direction: column; }
47
+ .dql-home-progress-badge strong { font-size: 14px; }
48
+ .dql-home-progress-badge span { font-size: 12px; margin-top: 2px; }
49
+
50
+ .dql-home-stepper { display: grid; grid-template-columns: repeat(4, 1fr); }
51
+ .dql-home-node { position: relative; display: flex; flex-direction: column; align-items: center; gap: 9px; border: 0; cursor: pointer; padding: 8px 8px 10px; border-radius: 12px; transition: background 140ms ease; }
52
+ .dql-home-node-track { position: absolute; top: 30px; left: 50%; width: 100%; height: 3px; z-index: 0; border-radius: 2px; transition: background 500ms ease; }
53
+ .dql-home-node-badge { position: relative; z-index: 1; width: 46px; height: 46px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; border: 2px solid; transition: transform 200ms ease; }
54
+ .dql-home-node.is-ready .dql-home-node-badge { animation: dql-home-pop 380ms cubic-bezier(0.2,1.5,0.4,1) both; }
55
+ .dql-home-node.is-active .dql-home-node-badge { animation: dql-home-pulse 1.8s ease-in-out infinite; }
56
+ @keyframes dql-home-pop { 0% { transform: scale(0.5); } 60% { transform: scale(1.14); } 100% { transform: scale(1); } }
57
+ @keyframes dql-home-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(217,119,6,0.40); } 50% { box-shadow: 0 0 0 8px rgba(217,119,6,0); } }
58
+ .dql-home-node-meta { display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center; }
59
+ .dql-home-node-title { font: 750 12.5px var(--font-ui, inherit); }
60
+ .dql-home-node-status { font: 700 9.5px var(--font-mono, ui-monospace, monospace); text-transform: uppercase; letter-spacing: 0.05em; }
61
+
62
+ .dql-home-focus { display: flex; gap: 14px; border: 1px solid; border-radius: 12px; padding: 16px 18px; }
63
+ .dql-home-focus-icon { flex: none; width: 40px; height: 40px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; }
64
+ .dql-home-focus-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 9px; }
65
+ .dql-home-focus-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
66
+ .dql-home-focus-head h2 { margin: 0; font-size: 16px; font-weight: 780; }
67
+ .dql-home-focus-body p { margin: 0; font-size: 13px; line-height: 1.5; }
68
+ .dql-home-status { font: 700 9.5px var(--font-mono, ui-monospace, monospace); text-transform: uppercase; letter-spacing: 0.05em; padding: 3px 9px; border-radius: 999px; }
69
+ .dql-home-evidence { display: flex; flex-wrap: wrap; gap: 6px; }
70
+ .dql-home-evidence span { font: 650 11px var(--font-mono, ui-monospace, monospace); border: 1px solid; border-radius: 999px; padding: 3px 9px; }
71
+ .dql-home-card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
72
+ .dql-home-card-btn { font-size: 12.5px; }
73
+
74
+ .dql-home-metrics { display: flex; flex-wrap: wrap; gap: 10px; }
75
+ .dql-home-metric { display: inline-flex; align-items: center; gap: 8px; border: 1px solid; border-radius: 10px; padding: 8px 13px; }
76
+ .dql-home-metric strong { font-size: 16px; font-weight: 800; }
77
+ .dql-home-metric span { font-size: 12px; }
78
+ .dql-home-metric-icon { display: inline-flex; }
79
+
80
+ .dql-home-details { border: 1px solid; border-radius: 12px; overflow: hidden; }
81
+ .dql-home-details > summary { list-style: none; cursor: pointer; padding: 13px 16px; display: flex; align-items: center; gap: 10px; font: 750 13px var(--font-ui, inherit); }
82
+ .dql-home-details > summary::-webkit-details-marker { display: none; }
83
+ .dql-home-details > summary::after { content: "\\2304"; margin-left: auto; font-size: 14px; transition: transform 200ms ease; }
84
+ .dql-home-details[open] > summary::after { transform: rotate(180deg); }
85
+ .dql-home-details-hint { font: 600 11.5px var(--font-ui, inherit); }
86
+ .dql-home-details-body { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 14px; }
87
+
88
+ .dql-home-context-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
89
+ .dql-home-context-panel { display: flex; flex-direction: column; gap: 10px; border: 1px solid; border-radius: 10px; padding: 14px; }
90
+ .dql-home-context-head { display: flex; gap: 10px; align-items: flex-start; }
91
+ .dql-home-context-icon { flex: none; width: 34px; height: 34px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; }
92
+ .dql-home-context-head h2 { margin: 0; font-size: 13.5px; font-weight: 760; line-height: 1.25; }
93
+ .dql-home-context-head p { margin: 3px 0 0; font-size: 12px; line-height: 1.4; }
94
+ .dql-home-context-rows { display: flex; flex-direction: column; }
95
+ .dql-home-context-row { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid; font-size: 12.5px; }
96
+ .dql-home-context-row:last-child { border-bottom: 0; }
97
+ .dql-home-link-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--color-accent-blue, #2563eb); cursor: pointer; font: 750 12.5px var(--font-ui, inherit); padding: 2px 0; margin-top: auto; }
98
+ .dql-home-artifact-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
99
+ .dql-home-artifact-row { display: flex; gap: 10px; align-items: baseline; border: 1px solid; border-radius: 8px; padding: 8px 11px; }
100
+ .dql-home-artifact-row code { font: 700 12px var(--font-mono, ui-monospace, monospace); flex: none; }
101
+ .dql-home-artifact-row span { font-size: 12px; line-height: 1.4; }
102
+
103
+ @media (max-width: 880px) {
104
+ .dql-home-stepper { grid-template-columns: repeat(2, 1fr); }
105
+ .dql-home-node-track { display: none; }
106
+ .dql-home-context-grid, .dql-home-artifact-list { grid-template-columns: 1fr; }
107
+ .dql-home-hero { flex-direction: column; align-items: flex-start; }
108
+ .dql-home-focus { flex-direction: column; }
109
+ }
110
+
111
+ @media (prefers-reduced-motion: reduce) {
112
+ .dql-home-fade,
113
+ .dql-home-node.is-ready .dql-home-node-badge,
114
+ .dql-home-node.is-active .dql-home-node-badge { animation: none !important; }
115
+ .dql-home-node-track, .dql-home-primary-btn { transition: none; }
116
+ }
117
+ `;export{sn as HomePage};
@@ -0,0 +1 @@
1
+ import{u as je,t as Se,r as a,ap as O,a as pe,aq as Ce,ar as Re,as as Ee,at as Le,j as e,n as E,an as H,au as Te,h as ge}from"./index-DU7j3Sqk.js";import{u as Be,a as Ie,M as ze,i as We,B as Pe,C as Me,b as Fe,P as Ne,T as he,c as N,H as xe}from"./dagre.esm-Bqs0lsEz.js";import"./react-CRB3T2We.js";const G=[{key:"technical",label:"Technical",title:"Physical sources and dbt transformations",types:Ce},{key:"domain",label:"Domain",title:"Business terms, governed domains, semantic metrics, and certified blocks",types:Re},{key:"end-to-end",label:"End-to-end",title:"Complete path from physical sources through governed meaning to consumption",types:O}],Y=[{type:"block",label:"Blocks"},{type:"app",label:"Apps"},{type:"notebook",label:"Notebooks"},{type:"dashboard",label:"Dashboards"}];function Oe(n,h,o="flow",g="LR"){var v;const p=new he.graphlib.Graph().setDefaultEdgeLabel(()=>({})),b=g==="LR";p.setGraph({rankdir:g,ranksep:o==="layered"?120:b?80:60,nodesep:b?40:50,marginx:32,marginy:32});for(const d of n){const y={width:190,height:58};if(o==="layered"&&((v=d.data)!=null&&v.layer)){const x=Te.indexOf(d.data.layer);x>=0&&(y.rank=x)}p.setNode(d.id,y)}for(const d of h)p.setEdge(d.source,d.target);return he.layout(p),n.map(d=>{const y=p.node(d.id);return{...d,position:{x:y.x-95,y:y.y-29},data:{...d.data,direction:g}}})}function $e({data:n,selected:h}){const o=n.nodeType,g=E[o]??"var(--color-text-tertiary)",p=n.direction??"LR",b=p==="LR"?N.Left:N.Top,v=p==="LR"?N.Right:N.Bottom,d=!!n.dimmed,y=n.status==="certified";return e.jsxs("div",{style:{width:196,display:"flex",alignItems:"center",gap:8,background:"var(--color-bg-card)",border:`1.5px solid ${h?"var(--accent)":"var(--border-default)"}`,borderRadius:9,padding:"9px 11px",boxShadow:h?"0 1px 6px rgba(107,93,211,0.16)":"0 1px 4px rgba(26,26,26,0.05)",opacity:d?.3:1,transition:"opacity 0.15s ease"},children:[e.jsx(xe,{type:"target",position:b,style:{width:7,height:7,background:g,border:"none"}}),e.jsx("span",{style:{width:8,height:8,borderRadius:999,background:g,flexShrink:0}}),e.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:1},children:[e.jsx("span",{title:n.label,style:{fontSize:11.5,fontWeight:650,color:"var(--color-text-primary)",fontFamily:"'JetBrains Mono', monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n.label}),e.jsx("span",{style:{fontSize:9.5,fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",color:g},children:H[o]??o})]}),y?e.jsx(ge,{size:12,color:"var(--status-success)",strokeWidth:2,style:{flexShrink:0}}):null,e.jsx(xe,{type:"source",position:v,style:{width:7,height:7,background:g,border:"none"}})]})}const De={dagNode:$e};function He(){var ae,le,de;const{state:n,dispatch:h}=je(),o=Se[n.themeMode],[g,p]=a.useState(!0),[b,v]=a.useState({nodes:[],edges:[]}),[d,y]=a.useState({nodes:[],edges:[]}),[x,w]=a.useState(null),[c,L]=a.useState(null),[W,T]=a.useState(!1),[l,s]=a.useState(null),[f,S]=a.useState(Object.fromEntries(O.map(t=>[t,!0]))),[k,Q]=a.useState("flow"),[C,J]=a.useState("LR"),[B,P]=a.useState(null),[$,M]=a.useState(!1),[q,V]=a.useState("block"),[U,K]=a.useState(""),[X,F]=a.useState(!1),[Z,ee]=a.useState(""),[ye,te,fe]=Be([]),[be,oe,me]=Ie([]),re=a.useCallback(async()=>{p(!0);const t=await pe.fetchLineage();v({nodes:t.nodes??[],edges:t.edges??[]}),p(!1)},[]);a.useEffect(()=>{re()},[re]);const R=a.useMemo(()=>b.nodes.filter(t=>Y.some(r=>r.type===t.type)).sort((t,r)=>t.name.localeCompare(r.name)),[b.nodes]),I=a.useCallback(async t=>{L(t),M(!1),P(null),s(null),T(!0);const r=await pe.queryLineage({focus:t,upstreamDepth:12,downstreamDepth:12});y(r.graph??{nodes:[],edges:[]}),w(r.focalNode??null),T(!1)},[]);a.useCallback(()=>{L(null),y({nodes:[],edges:[]}),w(null),s(null),P(null),M(!1),h({type:"SET_LINEAGE_FOCUS",nodeId:null})},[h]),a.useEffect(()=>{n.lineageFocusNodeId&&n.lineageFocusNodeId!==c&&I(n.lineageFocusNodeId)},[n.lineageFocusNodeId]);const m=a.useMemo(()=>{const t=new Set(d.nodes.filter(r=>f[r.type]??!0).map(r=>r.id));return{nodes:d.nodes.filter(r=>t.has(r.id)),edges:d.edges.filter(r=>t.has(r.source)&&t.has(r.target))}},[d,f]),z=a.useMemo(()=>{for(const t of G){const r=new Set(t.types);if(O.every(u=>(f[u]??!0)===r.has(u)))return t.key}return"custom"},[f]),ve=a.useCallback(t=>{const r=new Set(t);S(Object.fromEntries(O.map(i=>[i,r.has(i)])))},[]),j=a.useMemo(()=>{if(!B)return null;const t=new Set([B]),r=new Set([B]);let i=!0;for(;i;){i=!1;for(const u of m.edges)t.has(u.target)&&!t.has(u.source)&&(t.add(u.source),i=!0),r.has(u.source)&&!r.has(u.target)&&(r.add(u.target),i=!0)}return new Set([...t,...r])},[B,m.edges]);a.useEffect(()=>{const t=m.nodes.map(i=>({id:i.id,type:"dagNode",selected:i.id===c,position:{x:0,y:0},data:{label:i.name,nodeType:i.type,domain:i.domain,status:i.status,layer:Ee(i),dimmed:j?!j.has(i.id):!1}})),r=m.edges.map((i,u)=>{const A=j?j.has(i.source)&&j.has(i.target):!1,ce=A?"var(--accent)":Le[i.type]??"var(--color-text-tertiary)";return{id:`edge-${u}-${i.source}-${i.target}-${i.type}`,source:i.source,target:i.target,style:{stroke:ce,strokeWidth:A?2:1.5,opacity:j&&!A?.25:1},markerEnd:{type:ze.ArrowClosed,color:ce,width:12,height:12}}});te(Oe(t,r,k,C)),oe(r)},[m,k,C,j,c,oe,te]);const ke=a.useCallback((t,r)=>{P(r.id);const i=m.nodes.find(u=>u.id===r.id)??null;s(i)},[m.nodes]),D=a.useCallback(()=>{P(null),s(null)},[]),_=a.useMemo(()=>{if(!l)return null;const t=d.edges.filter(i=>i.target===l.id).length,r=d.edges.filter(i=>i.source===l.id).length;return{incoming:t,outgoing:r}},[d.edges,l]),ne=(x==null?void 0:x.name)??((ae=R.find(t=>t.id===c))==null?void 0:ae.name)??c??"",we=(x==null?void 0:x.type)??((le=R.find(t=>t.id===c))==null?void 0:le.type)??"block",ie=Z.trim().toLowerCase(),se=(ie?R.filter(t=>t.name.toLowerCase().includes(ie)):R).slice(0,40);return g?e.jsx("div",{style:{padding:16,color:o.textMuted,fontSize:12},children:"Loading lineage graph..."}):b.nodes.length===0?e.jsx("div",{style:{padding:16,color:o.textMuted,fontSize:12},children:"No lineage graph available yet."}):c?e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"var(--color-bg-primary)"},children:[e.jsx("div",{style:{padding:8,borderBottom:`1px solid ${o.headerBorder}`,background:o.sidebarBg},children:e.jsxs("div",{style:{display:"flex",gap:6,marginBottom:8,flexWrap:"wrap",alignItems:"center"},children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsxs("button",{onClick:()=>M(t=>!t),title:"Change the traced entity",style:{display:"inline-flex",alignItems:"center",gap:7,height:30,padding:"0 11px",borderRadius:8,border:`1px solid ${$?o.accent:o.headerBorder}`,background:$?"var(--accent-dim)":o.cellBg,color:o.textPrimary,cursor:"pointer",fontFamily:o.font,maxWidth:320},children:[e.jsx("span",{style:{fontSize:10.5,fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",color:o.textMuted},children:"Tracing"}),e.jsx("span",{style:{width:8,height:8,borderRadius:999,background:E[we]??"var(--color-text-tertiary)",flexShrink:0}}),e.jsx("span",{style:{fontSize:12.5,fontWeight:650,fontFamily:"'JetBrains Mono', monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:ne}),e.jsx("span",{style:{fontSize:9,color:o.textMuted},children:"▾"})]}),$&&e.jsxs(e.Fragment,{children:[e.jsx("div",{onClick:()=>M(!1),style:{position:"fixed",inset:0,zIndex:30}}),e.jsx("div",{style:{position:"absolute",top:"calc(100% + 6px)",left:0,zIndex:31,width:340,background:o.cellBg,border:`1px solid ${o.headerBorder}`,borderRadius:11,boxShadow:"0 10px 30px rgba(26,26,26,0.14)",padding:12},children:e.jsx(ue,{t:o,entities:R,activeType:q,onTypeChange:V,query:U,onQueryChange:K,onSelect:t=>void I(t),focalId:c,listHeight:240})})]})]}),e.jsxs("div",{style:{position:"relative",flex:"0 1 300px",minWidth:160},children:[e.jsxs("svg",{style:{position:"absolute",left:9,top:"50%",transform:"translateY(-50%)",color:o.textMuted,pointerEvents:"none"},width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"m21 21-4.3-4.3"})]}),e.jsx("input",{value:Z,onChange:t=>{ee(t.target.value),F(!0)},onFocus:()=>F(!0),placeholder:"Search another block, app, or notebook…",style:{width:"100%",boxSizing:"border-box",height:30,padding:"0 10px 0 28px",borderRadius:8,border:`1px solid ${X?o.accent:o.headerBorder}`,background:"var(--color-bg-sunken)",color:o.textPrimary,fontSize:12,fontFamily:o.font,outline:"none"}}),X&&e.jsxs(e.Fragment,{children:[e.jsx("div",{onClick:()=>F(!1),style:{position:"fixed",inset:0,zIndex:30}}),e.jsx("div",{style:{position:"absolute",top:"calc(100% + 6px)",left:0,zIndex:31,width:"min(340px, 90vw)",maxHeight:300,overflow:"auto",background:o.cellBg,border:`1px solid ${o.headerBorder}`,borderRadius:11,boxShadow:"0 10px 30px rgba(26,26,26,0.14)",padding:4},children:se.length===0?e.jsx("div",{style:{padding:"12px 11px",fontSize:12,color:o.textMuted,fontFamily:o.font},children:"No matching block, app, or notebook."}):se.map(t=>e.jsxs("button",{onClick:()=>{I(t.id),ee(""),F(!1)},style:{width:"100%",display:"flex",alignItems:"center",gap:9,textAlign:"left",padding:"8px 10px",border:"none",borderRadius:7,background:t.id===c?"var(--accent-dim)":"transparent",cursor:"pointer",fontFamily:o.font},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:999,background:E[t.type]??"var(--color-text-tertiary)",flexShrink:0}}),e.jsx("span",{style:{flex:1,minWidth:0,fontSize:12.5,fontWeight:550,color:o.textPrimary,fontFamily:"'JetBrains Mono', monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.name}),e.jsx("span",{style:{fontSize:9.5,fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",color:o.textMuted,flexShrink:0},children:H[t.type]??t.type})]},t.id))})]})]}),e.jsx("div",{style:{width:1,height:20,background:o.headerBorder,margin:"0 2px"}}),e.jsxs("div",{style:{display:"flex",borderRadius:6,border:`1px solid ${o.headerBorder}`,overflow:"hidden"},children:[e.jsx("button",{onClick:()=>Q("flow"),style:{padding:"4px 8px",fontSize:10,fontWeight:700,border:"none",cursor:"pointer",background:k==="flow"?"var(--color-bg-tertiary)":"transparent",color:k==="flow"?"var(--color-text-primary)":"var(--color-text-tertiary)"},children:"Flow"}),e.jsx("button",{onClick:()=>Q("layered"),style:{padding:"4px 8px",fontSize:10,fontWeight:700,border:"none",borderLeft:`1px solid ${o.headerBorder}`,cursor:"pointer",background:k==="layered"?"var(--color-bg-tertiary)":"transparent",color:k==="layered"?"var(--color-text-primary)":"var(--color-text-tertiary)"},children:"Layered"})]}),e.jsxs("div",{style:{display:"flex",borderRadius:6,border:`1px solid ${o.headerBorder}`,overflow:"hidden",marginRight:4},children:[e.jsxs("button",{title:"Horizontal layout (left → right)",onClick:()=>J("LR"),style:{padding:"4px 8px",fontSize:10,fontWeight:700,border:"none",cursor:"pointer",background:C==="LR"?"var(--color-bg-tertiary)":"transparent",color:C==="LR"?"var(--color-text-primary)":"var(--color-text-tertiary)",display:"flex",alignItems:"center",gap:3},children:[e.jsxs("svg",{width:"14",height:"10",viewBox:"0 0 14 10",fill:"none",children:[e.jsx("rect",{x:"0",y:"2",width:"4",height:"6",rx:"1",fill:"currentColor",opacity:"0.7"}),e.jsx("line",{x1:"4",y1:"5",x2:"10",y2:"5",stroke:"currentColor",strokeWidth:"1.2"}),e.jsx("path",{d:"M9 3l2 2-2 2",stroke:"currentColor",strokeWidth:"1.2",fill:"none"}),e.jsx("rect",{x:"10",y:"2",width:"4",height:"6",rx:"1",fill:"currentColor"})]}),"LR"]}),e.jsxs("button",{title:"Vertical layout (top → bottom)",onClick:()=>J("TB"),style:{padding:"4px 8px",fontSize:10,fontWeight:700,border:"none",borderLeft:`1px solid ${o.headerBorder}`,cursor:"pointer",background:C==="TB"?"var(--color-bg-tertiary)":"transparent",color:C==="TB"?"var(--color-text-primary)":"var(--color-text-tertiary)",display:"flex",alignItems:"center",gap:3},children:[e.jsxs("svg",{width:"10",height:"14",viewBox:"0 0 10 14",fill:"none",children:[e.jsx("rect",{x:"2",y:"0",width:"6",height:"4",rx:"1",fill:"currentColor",opacity:"0.7"}),e.jsx("line",{x1:"5",y1:"4",x2:"5",y2:"10",stroke:"currentColor",strokeWidth:"1.2"}),e.jsx("path",{d:"M3 9l2 2 2-2",stroke:"currentColor",strokeWidth:"1.2",fill:"none"}),e.jsx("rect",{x:"2",y:"10",width:"6",height:"4",rx:"1",fill:"currentColor"})]}),"TB"]})]}),e.jsx("div",{role:"group","aria-label":"Lineage view",style:{display:"inline-flex",alignItems:"center",gap:2,padding:2,border:`1px solid ${o.headerBorder}`,borderRadius:7,background:o.appBg,marginRight:4},children:G.map(t=>e.jsx("button",{onClick:()=>ve(t.types),title:t.title,"aria-pressed":z===t.key,style:{padding:"4px 11px",fontSize:11.5,fontWeight:600,border:"none",borderRadius:5,cursor:"pointer",fontFamily:o.font,whiteSpace:"nowrap",background:z===t.key?"var(--accent-dim)":"transparent",color:z===t.key?o.accent:o.textMuted},children:t.label},t.key))}),B&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{flex:1}}),e.jsx("button",{onClick:D,style:{borderRadius:7,border:`1px solid ${o.accent}`,background:"var(--accent-dim)",color:o.accent,cursor:"pointer",fontSize:11.5,fontWeight:650,padding:"5px 11px",whiteSpace:"nowrap"},children:"Show all"})]})]})}),e.jsx("div",{style:{flex:1,position:"relative"},children:e.jsxs(We,{nodes:ye,edges:be,onNodesChange:fe,onEdgesChange:me,onNodeClick:ke,onPaneClick:D,nodeTypes:De,fitView:!0,fitViewOptions:{padding:.18},proOptions:{hideAttribution:!0},style:{background:"var(--bg-canvas)"},children:[e.jsx(Pe,{color:"var(--border-strong)",gap:22,size:1}),e.jsx(Me,{showInteractive:!1}),e.jsx(Fe,{nodeColor:t=>{var r;return E[((r=t.data)==null?void 0:r.nodeType)??"source_table"]??"var(--color-text-tertiary)"},maskColor:"color-mix(in srgb, var(--color-bg-primary) 55%, transparent)",style:{background:"var(--color-bg-sunken)",border:"1px solid var(--color-border-primary)"}}),e.jsx(Ne,{position:"bottom-left",children:l?e.jsxs("div",{style:{width:264,background:"var(--color-bg-card)",border:"1px solid var(--color-border-primary)",borderRadius:11,boxShadow:"0 8px 26px rgba(26,26,26,0.13)",padding:"12px 14px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:999,background:E[l.type]??"var(--color-text-tertiary)",flexShrink:0}}),e.jsx("span",{style:{flex:1,minWidth:0,fontSize:12.5,fontWeight:700,color:"var(--color-text-primary)",fontFamily:"'JetBrains Mono', monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l.name}),e.jsx("button",{onClick:D,title:"Clear focus",style:{width:20,height:20,borderRadius:5,border:"none",background:"none",color:"var(--color-text-tertiary)",display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0,flexShrink:0},children:"×"})]}),e.jsxs("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",marginTop:3},children:[H[l.type]??l.type,_?` · ${_.incoming} upstream · ${_.outgoing} downstream`:""]}),l.domain?e.jsxs("div",{style:{fontSize:11.5,color:"var(--color-text-secondary)",lineHeight:1.5,marginTop:7},children:["Domain: ",l.domain]}):null,e.jsxs("div",{style:{display:"flex",gap:8,marginTop:10},children:[e.jsx("button",{onClick:()=>{l&&l.id!==c&&I(l.id)},disabled:!l||l.id===c,title:(l==null?void 0:l.id)===c?"Already the traced entity":"Re-scope lineage to this node",style:{display:"inline-flex",alignItems:"center",gap:5,height:26,padding:"0 10px",borderRadius:6,border:"none",background:"var(--accent)",color:"#fff",fontSize:11,fontWeight:650,cursor:(l==null?void 0:l.id)===c?"default":"pointer",opacity:(l==null?void 0:l.id)===c?.5:1},children:"Trace from here"}),e.jsx("button",{onClick:()=>h({type:"OPEN_GLOBAL_AI",autoRun:{text:`Explain the lineage of ${l.name} — where does it come from and what consumes it?`}}),style:{display:"inline-flex",alignItems:"center",gap:5,height:26,padding:"0 10px",borderRadius:6,border:"1px solid var(--color-border-primary)",background:"var(--color-bg-card)",color:"var(--color-text-secondary)",fontSize:11,fontWeight:600,cursor:"pointer"},children:"Ask about this"})]})]}):null})]})}),e.jsxs("div",{style:{height:28,flexShrink:0,borderTop:"1px solid var(--border-subtle)",background:"var(--color-bg-card)",display:"flex",alignItems:"center",gap:14,padding:"0 14px",fontSize:10.5,color:"var(--color-text-tertiary)"},children:[e.jsxs("span",{children:[z==="custom"?"Custom":(de=G.find(t=>t.key===z))==null?void 0:de.label," lineage of ",ne," · ",m.nodes.length," nodes · ",m.edges.length," edges",W?" · loading…":""]}),e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:999,background:"var(--status-success)"}}),"Compiled from the dbt manifest"]}),e.jsx("div",{style:{flex:1}}),e.jsx("span",{children:"Click a node to focus its path · click the canvas to clear"})]})]}):e.jsx("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"var(--color-bg-primary)",alignItems:"center",justifyContent:"center",padding:24,overflow:"auto"},children:e.jsxs("div",{style:{width:"min(560px, 100%)",border:`1px solid ${o.headerBorder}`,borderRadius:14,background:o.cellBg,padding:"22px 22px 18px",boxShadow:"0 1px 4px rgba(26,26,26,0.05)"},children:[e.jsx("div",{style:{fontSize:16,fontWeight:700,color:o.textPrimary,fontFamily:o.font},children:"Trace lineage"}),e.jsx("div",{style:{fontSize:12.5,color:o.textMuted,marginTop:3,lineHeight:1.5,fontFamily:o.font},children:"Pick a block, app, or notebook to see its upstream sources and downstream consumers — no project-wide noise."}),e.jsx("div",{style:{marginTop:16},children:e.jsx(ue,{t:o,entities:R,activeType:q,onTypeChange:V,query:U,onQueryChange:K,onSelect:t=>void I(t),focalId:c,listHeight:300})})]})})}function ue({t:n,entities:h,activeType:o,onTypeChange:g,query:p,onQueryChange:b,onSelect:v,focalId:d,listHeight:y}){var T,l;const x=Y.filter(s=>h.some(f=>f.type===s.type)),w=x.some(s=>s.type===o)?o:((T=x[0])==null?void 0:T.type)??o,c=p.trim().toLowerCase(),L=h.filter(s=>s.type===w).filter(s=>!c||s.name.toLowerCase().includes(c)),W=((l=Y.find(s=>s.type===w))==null?void 0:l.label)??"items";return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:9,minWidth:0},children:[e.jsx("div",{style:{display:"inline-flex",alignItems:"center",gap:2,padding:2,border:`1px solid ${n.headerBorder}`,borderRadius:8,background:n.appBg,alignSelf:"flex-start",flexWrap:"wrap"},children:x.map(s=>{const f=s.type===w,S=h.filter(k=>k.type===s.type).length;return e.jsxs("button",{onClick:()=>g(s.type),style:{display:"inline-flex",alignItems:"center",gap:6,border:"none",borderRadius:6,padding:"5px 11px",fontSize:12,fontWeight:600,cursor:"pointer",fontFamily:n.font,background:f?"var(--accent-dim)":"transparent",color:f?n.accent:n.textMuted},children:[s.label,e.jsx("span",{style:{fontSize:10.5,color:f?n.accent:n.textMuted,opacity:.8},children:S})]},s.type)})}),e.jsx("input",{value:p,onChange:s=>b(s.target.value),placeholder:`Search ${W.toLowerCase()}…`,style:{padding:"8px 10px",borderRadius:8,border:`1px solid ${n.headerBorder}`,background:"var(--color-bg-sunken)",color:n.textPrimary,fontSize:12,fontFamily:n.font,outline:"none"}}),e.jsx("div",{style:{maxHeight:y,overflow:"auto",border:`1px solid ${n.headerBorder}`,borderRadius:8},children:L.length===0?e.jsx("div",{style:{padding:"14px 12px",fontSize:12,color:n.textMuted,fontFamily:n.font},children:h.some(s=>s.type===w)?"No matches.":`No ${W.toLowerCase()} in this project yet.`}):L.map((s,f)=>{const S=s.id===d;return e.jsxs("button",{onClick:()=>v(s.id),style:{width:"100%",display:"flex",alignItems:"center",gap:9,textAlign:"left",padding:"9px 11px",border:"none",borderTop:f===0?"none":`1px solid ${n.headerBorder}`,background:S?"var(--accent-dim)":"transparent",cursor:"pointer",fontFamily:n.font},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:999,background:E[s.type]??"var(--color-text-tertiary)",flexShrink:0}}),e.jsx("span",{style:{flex:1,minWidth:0,fontSize:12.5,fontWeight:S?650:500,color:n.textPrimary,fontFamily:"'JetBrains Mono', monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s.name}),s.status==="certified"?e.jsx(ge,{size:12,color:"var(--status-success)",strokeWidth:2,style:{flexShrink:0}}):null]},s.id)})})]})}export{He as LineageDAG};
@@ -0,0 +1 @@
1
+ import{u as O,t as N,r as u,a as A,j as t,n as C,o as E,an as W,ao as R}from"./index-DU7j3Sqk.js";import{M as _}from"./MiniLineageGraph-CR_nhwhZ.js";import{LineageDAG as H}from"./LineageDAG-DW_NO3P2.js";import{A as F}from"./arrow-left-BZHDcWHR.js";import{L as G}from"./list-tree-B9ZzGc4U.js";import"./react-CRB3T2We.js";import"./dagre.esm-Bqs0lsEz.js";function U(i){return i.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function q(i){if(i==null)return null;if(typeof i=="string")return i.trim()||null;if(typeof i=="number"||typeof i=="boolean")return String(i);if(Array.isArray(i)){const n=i.map(e=>e==null?null:typeof e=="string"||typeof e=="number"||typeof e=="boolean"?String(e):null).filter(e=>!!e);return n.length>0?n.join(", "):null}return null}function V(i){return i?i.type==="term"?"Business definition used by blocks, views, dashboards, and AI agents.":i.type==="business_view"?"Business composition built from trusted terms, DQL blocks, and other business views.":i.type==="block"?"Reusable DQL block with its technical inputs and business consumption paths.":i.type==="dbt_model"||i.type==="dbt_source"||i.type==="source_table"?"Technical data asset connected to semantic, business, and consumption lineage.":i.type==="dashboard"||i.type==="notebook"||i.type==="app"||i.type==="chart"?"Consumption surface showing which trusted blocks and business concepts feed the experience.":"Focused technical and business lineage for the selected item.":"Focused technical and business lineage for the selected item."}function se(){var z;const{state:i,dispatch:n}=O(),e=N[i.themeMode],s=i.lineageFocusNodeId,[o,l]=u.useState({nodes:[],edges:[],focalNode:null}),[d,h]=u.useState(!1),[c,x]=u.useState("details"),[w,S]=u.useState(!1);u.useEffect(()=>{if(!s)return;let r=!1;return h(!0),A.queryLineage({focus:s,upstreamDepth:3,downstreamDepth:3}).then(v=>{var I,L;r||(l({nodes:((I=v.graph)==null?void 0:I.nodes)??[],edges:((L=v.graph)==null?void 0:L.edges)??[],focalNode:v.focalNode??null}),h(!1))}).catch(()=>{r||h(!1)}),()=>{r=!0}},[s]);const a=o.focalNode,m=u.useMemo(()=>new Map(o.nodes.map(r=>[r.id,r])),[o.nodes]),b=u.useMemo(()=>a?o.edges.filter(r=>r.target===a.id).map(r=>({edge:r,node:m.get(r.source)})).filter(r=>!!r.node):[],[a,o.edges,m]),j=u.useMemo(()=>a?o.edges.filter(r=>r.source===a.id).map(r=>({edge:r,node:m.get(r.target)})).filter(r=>!!r.node):[],[a,o.edges,m]);if(!s||w)return t.jsxs("div",{style:{flex:1,minWidth:0,minHeight:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[w&&s?t.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 14px",borderBottom:`1px solid ${e.headerBorder}`,background:e.cellBg},children:t.jsx("button",{type:"button",onClick:()=>S(!1),style:{border:`1px solid ${e.headerBorder}`,background:e.cellBg,color:e.textSecondary,borderRadius:7,padding:"5px 11px",fontSize:11.5,fontWeight:600,cursor:"pointer",fontFamily:e.font},children:"← Back to focused view"})}):null,t.jsx(H,{})]});const f=(a==null?void 0:a.type)??s.split(":")[0]??"node",D=C[f]??e.accent,P=E[f]??f.slice(0,4).toUpperCase(),B=(a==null?void 0:a.metadata)??{},k=B.path??B.filePath,$=(a==null?void 0:a.name)??s,g=i.sidebarOpen&&i.sidebarPanel==="lineage",p=((z=i.lineageReturnTarget)==null?void 0:z.view)==="apps"?i.lineageReturnTarget:null,T=p!=null&&p.label?`Back to ${p.label}`:"Back to app";return t.jsxs("div",{style:{flex:1,minWidth:0,overflow:"auto",background:"var(--color-bg-primary)"},children:[t.jsx("div",{style:{padding:"22px 28px 18px",borderBottom:`1px solid ${e.headerBorder}`,background:e.appBg},children:t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:16},children:[t.jsxs("div",{style:{minWidth:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:8},children:[t.jsx("span",{style:{color:e.appBg,background:D,borderRadius:5,padding:"3px 7px",fontSize:10,fontWeight:800,letterSpacing:0},title:W[f]??f,children:P}),t.jsxs("span",{style:{color:e.textMuted,fontSize:12},children:["Focused lineage · ↑ ",b.length," · ↓ ",j.length]})]}),t.jsx("h1",{style:{margin:0,fontSize:26,lineHeight:1.15,color:e.textPrimary},children:$}),t.jsx("div",{style:{marginTop:7,color:e.textMuted,fontSize:13,maxWidth:760,lineHeight:1.45},children:V(a)})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[t.jsx("button",{type:"button",onClick:()=>S(!0),title:"Open the full lineage graph",style:{display:"inline-flex",alignItems:"center",gap:6,border:`1px solid ${e.headerBorder}`,background:e.cellBg,color:e.textSecondary,borderRadius:7,padding:"6px 11px",fontSize:12,fontWeight:600,cursor:"pointer",fontFamily:e.font,whiteSpace:"nowrap"},children:"Full graph"}),p?t.jsxs("button",{type:"button",onClick:()=>{n({type:"OPEN_APP",appId:p.appId,dashboardId:p.dashboardId??null,experience:p.experience,section:p.section})},title:T,style:{display:"inline-flex",alignItems:"center",gap:7,border:`1px solid ${e.headerBorder}`,background:e.sidebarBg,color:e.textPrimary,borderRadius:6,padding:"7px 10px",fontSize:12,fontWeight:800,cursor:"pointer",whiteSpace:"nowrap",maxWidth:220,overflow:"hidden",textOverflow:"ellipsis"},children:[t.jsx(F,{size:14}),t.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:T})]}):null,t.jsxs("button",{type:"button",onClick:()=>{n(g?{type:"TOGGLE_SIDEBAR"}:{type:"SET_SIDEBAR_PANEL",panel:"lineage"})},style:{display:"inline-flex",alignItems:"center",gap:7,border:`1px solid ${g?e.accent:e.headerBorder}`,background:g?`${e.accent}1a`:e.sidebarBg,color:g?e.textPrimary:e.textSecondary,borderRadius:6,padding:"7px 10px",fontSize:12,fontWeight:800,cursor:"pointer",whiteSpace:"nowrap"},children:[t.jsx(G,{size:14}),g?"Hide list":"Browse lineage"]})]})]})}),t.jsxs("div",{style:{padding:16,display:"grid",gridTemplateColumns:"minmax(0, 1fr) clamp(190px, 26%, 280px)",gap:14,minHeight:"calc(100vh - 160px)",minWidth:0},children:[t.jsxs("section",{style:{border:`1px solid ${e.headerBorder}`,borderRadius:8,background:e.sidebarBg,overflow:"hidden",display:"flex",flexDirection:"column",minWidth:0,minHeight:560},children:[t.jsxs("div",{style:{padding:"10px 12px",borderBottom:`1px solid ${e.headerBorder}`,flexShrink:0},children:[t.jsx("div",{style:{fontWeight:800,color:e.textPrimary,fontSize:14},children:"Focused lineage"}),t.jsx("div",{style:{color:e.textMuted,fontSize:12,marginTop:3},children:"Technical chain, business concepts, and consumption endpoints for this item."})]}),t.jsx("div",{style:{flex:1,minHeight:490,padding:12},children:d?t.jsx("div",{style:{color:e.textMuted,fontSize:12},children:"Loading lineage..."}):o.nodes.length===0?t.jsx("div",{style:{color:e.textMuted,fontSize:12},children:"No lineage available."}):t.jsx(_,{nodes:o.nodes,edges:o.edges,focalNodeId:s,height:"100%",fitViewPadding:.04,onNodeClick:r=>{n({type:"OPEN_LINEAGE_DETAIL",nodeId:r})},interactive:!0})})]}),t.jsxs("aside",{"aria-label":"Lineage details",style:{border:`1px solid ${e.headerBorder}`,borderRadius:8,background:e.sidebarBg,minWidth:0,maxHeight:"calc(100vh - 160px)",overflow:"hidden",display:"flex",flexDirection:"column"},children:[t.jsxs("div",{style:{padding:8,borderBottom:`1px solid ${e.headerBorder}`,display:"grid",gridTemplateColumns:"1fr 1fr",gap:4},children:[t.jsx(y,{label:"Details",active:c==="details",onClick:()=>x("details"),t:e}),t.jsx(y,{label:`Up ${b.length}`,active:c==="upstream",onClick:()=>x("upstream"),t:e}),t.jsx(y,{label:`Down ${j.length}`,active:c==="downstream",onClick:()=>x("downstream"),t:e}),t.jsx(y,{label:"Source",active:c==="source",onClick:()=>x("source"),t:e})]}),t.jsxs("div",{style:{padding:12,overflow:"auto",flex:1,minHeight:0},children:[c==="details"&&(a?t.jsx(Q,{node:a,t:e}):t.jsx(Y,{t:e,label:"No metadata available."})),c==="upstream"&&t.jsx(M,{title:"Upstream",connections:b,t:e}),c==="downstream"&&t.jsx(M,{title:"Downstream",connections:j,t:e}),c==="source"&&t.jsx(K,{filePath:typeof k=="string"?k:null,t:e})]})]})]})]})}function y({label:i,active:n,onClick:e,t:s}){return t.jsx("button",{onClick:e,style:{border:`1px solid ${n?s.accent:s.headerBorder}`,background:n?`${s.accent}1c`:"transparent",color:n?s.textPrimary:s.textMuted,borderRadius:5,padding:"5px 6px",fontSize:10,fontWeight:800,cursor:"pointer",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:i})}function Y({t:i,label:n}){return t.jsx("div",{style:{color:i.textMuted,fontSize:12,lineHeight:1.45},children:n})}function Q({node:i,t:n}){const e=i.metadata??{},s=new Set,o=[],l=(d,h,c=d)=>{const x=q(h);!x||s.has(c)||(s.add(c),o.push({label:d,value:x}))};l("Type",W[i.type]??i.type,"type"),l("Domain",i.domain,"domain"),l("Owner",i.owner,"owner"),l("Status",i.status,"status"),l("Term Type",e.termType,"termType"),l("Block Type",e.blockType,"blockType"),l("Materialized As",e.materializedAs,"materializedAs"),l("Identifiers",e.identifiers,"identifiers"),l("Synonyms",e.synonyms,"synonyms"),l("Description",e.description,"description"),l("Business Outcome",e.businessOutcome,"businessOutcome"),l("Decision Use",e.decisionUse,"decisionUse"),l("Review Cadence",e.reviewCadence,"reviewCadence");for(const[d,h]of Object.entries(e))d==="path"||d==="filePath"||d==="sql"||d==="compiledSql"||l(U(d),h,d);return t.jsxs("div",{children:[t.jsx("div",{style:{fontWeight:800,color:n.textPrimary,marginBottom:10},children:"Lineage metadata"}),o.length===0?t.jsx("div",{style:{color:n.textMuted,fontSize:12},children:"No metadata available for this node."}):t.jsx("div",{style:{display:"grid",gap:8},children:o.map(d=>t.jsxs("div",{style:{display:"grid",gap:3},children:[t.jsx("div",{style:{color:n.textMuted,fontSize:10,fontWeight:800,textTransform:"uppercase"},children:d.label}),t.jsx("div",{style:{color:n.textSecondary,fontSize:12,lineHeight:1.45},children:d.value})]},d.label))})]})}function M({title:i,connections:n,t:e}){return t.jsxs("div",{children:[t.jsx("div",{style:{fontWeight:800,color:e.textPrimary,marginBottom:10},children:i}),n.length===0?t.jsxs("div",{style:{color:e.textMuted,fontSize:12},children:["No ",i.toLowerCase()," connections in this focused window."]}):t.jsxs("div",{style:{display:"grid",gap:7},children:[n.slice(0,10).map(({edge:s,node:o})=>{const l=C[o.type]??e.textMuted;return t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"92px 1fr",gap:8,minWidth:0,fontSize:12},children:[t.jsx("span",{style:{color:e.textMuted},children:R[s.type]??s.type}),t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,minWidth:0},children:[t.jsx("span",{style:{color:e.appBg,background:l,borderRadius:3,padding:"1px 4px",fontSize:9,fontWeight:800,flexShrink:0},children:E[o.type]??o.type.slice(0,4).toUpperCase()}),t.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:o.name,children:o.name})]})]},`${s.source}-${s.target}-${s.type}`)}),n.length>10&&t.jsxs("div",{style:{color:e.textMuted,fontSize:12},children:[n.length-10," more connection",n.length-10===1?"":"s"," in the graph"]})]})]})}function K({filePath:i,t:n}){const e=i==null?void 0:i.trim();return t.jsxs("div",{children:[t.jsx("div",{style:{fontWeight:800,color:n.textPrimary,marginBottom:10},children:"Source file"}),e?t.jsx("div",{style:{color:n.textMuted,fontSize:12,lineHeight:1.5,overflowWrap:"anywhere"},children:e}):t.jsx("div",{style:{color:n.textMuted,fontSize:12},children:"No source file path available for this node."})]})}export{se as LineageDetailView};
@@ -0,0 +1 @@
1
+ import{u as F,t as J,r as l,a as K,n as R,o as I,j as t,an as Q,ao as Z}from"./index-DU7j3Sqk.js";import{M as ee}from"./MiniLineageGraph-CR_nhwhZ.js";import{P as te}from"./panel-right-open-B1g1qhh5.js";import{X as B}from"./x-C6tsHUR7.js";import{M as re}from"./minimize-2-BrpFmsxS.js";import{R as ie}from"./rotate-ccw-Db_KVs3J.js";import{G as ne}from"./grip-vertical-D9g31N3j.js";import{E as se}from"./external-link-B24Dk9_t.js";import"./react-CRB3T2We.js";import"./dagre.esm-Bqs0lsEz.js";const O=320,oe=48;function T(){return typeof window>"u"?380:Math.min(420,Math.max(O,Math.round(window.innerWidth*.42)))}function ae(){return typeof window>"u"?760:Math.max(420,Math.min(880,Math.round(window.innerWidth*.72)))}function le(o){return Math.min(ae(),Math.max(O,o))}function be(){var E,D;const{state:o,dispatch:a}=F(),e=J[o.themeMode],n=o.lineageDrawerNodeId,[s,m]=l.useState({nodes:[],edges:[],focalNode:null}),[N,y]=l.useState(!1),j=l.useRef(null),[A,P]=l.useState(360),[w,S]=l.useState(()=>T()),[k,f]=l.useState(!1),[p,M]=l.useState(!1),b=l.useRef(w);l.useEffect(()=>{const r=j.current;if(!r)return;const d=new ResizeObserver(u=>{for(const c of u){const x=Math.max(160,c.contentRect.height);P(x)}});return d.observe(r),()=>d.disconnect()},[]),l.useEffect(()=>{if(!n)return;let r=!1;return y(!0),K.queryLineage({focus:n,upstreamDepth:2,downstreamDepth:2}).then(d=>{var u,c;r||(m({nodes:((u=d.graph)==null?void 0:u.nodes)??[],edges:((c=d.graph)==null?void 0:c.edges)??[],focalNode:d.focalNode??null}),y(!1))}).catch(()=>{r||y(!1)}),()=>{r=!0}},[n]);const i=s.focalNode,$=i?s.edges.filter(r=>r.target===i.id).length:0,_=i?s.edges.filter(r=>r.source===i.id).length:0,H=i?R[i.type]??e.textSecondary:e.textSecondary,G=i?I[i.type]??i.type.toUpperCase():"",g=l.useMemo(()=>new Map(s.nodes.map(r=>[r.id,r])),[s.nodes]),U=l.useMemo(()=>i?s.edges.filter(r=>r.target===i.id).map(r=>({edge:r,node:g.get(r.source)})).filter(r=>!!r.node):[],[i,s.edges,g]),X=l.useMemo(()=>i?s.edges.filter(r=>r.source===i.id).map(r=>({edge:r,node:g.get(r.target)})).filter(r=>!!r.node):[],[i,s.edges,g]),v=((E=i==null?void 0:i.metadata)==null?void 0:E.path)??((D=i==null?void 0:i.metadata)==null?void 0:D.filePath);if(!n)return null;const Y=r=>{r!==n&&a({type:"OPEN_LINEAGE_DRAWER",nodeId:r})},q=r=>{r.preventDefault(),r.stopPropagation(),k&&f(!1);const d=r.clientX,u=b.current;M(!0);const c=V=>{const L=le(u+(d-V.clientX));b.current=L,S(L)},x=()=>{M(!1),document.body.style.cursor="",document.body.style.userSelect="",window.removeEventListener("mousemove",c),window.removeEventListener("mouseup",x)};document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("mousemove",c),window.addEventListener("mouseup",x)},z=()=>{const r=T();b.current=r,S(r),f(!1)},W=()=>a({type:"CLOSE_LINEAGE_DRAWER"});return k?t.jsxs("aside",{"aria-label":"Collapsed lineage drawer",style:{width:oe,flexShrink:0,borderLeft:`1px solid ${e.headerBorder}`,background:e.appBg,color:e.textPrimary,display:"flex",flexDirection:"column",alignItems:"center",gap:8,padding:"10px 6px",overflow:"hidden"},children:[t.jsx(h,{title:"Show lineage details",onClick:()=>f(!1),t:e,children:t.jsx(te,{size:15,strokeWidth:1.9})}),t.jsx(h,{title:"Hide lineage drawer",onClick:W,t:e,children:t.jsx(B,{size:15,strokeWidth:2})}),t.jsx("div",{title:(i==null?void 0:i.name)??n,style:{writingMode:"vertical-rl",transform:"rotate(180deg)",color:e.textMuted,fontSize:11,fontWeight:700,lineHeight:1,marginTop:4,maxHeight:260,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(i==null?void 0:i.name)??"Lineage"})]}):t.jsxs("aside",{"aria-label":"Lineage drawer",style:{width:w,flexShrink:0,borderLeft:`1px solid ${e.headerBorder}`,background:e.appBg,color:e.textPrimary,display:"flex",flexDirection:"column",overflow:"hidden",position:"relative",animation:"dql-drawer-slide-in 180ms cubic-bezier(0.22, 0.61, 0.36, 1)"},children:[t.jsx("div",{onMouseDown:q,onDoubleClick:z,title:"Drag to resize. Double-click to reset width.",style:{position:"absolute",top:0,left:0,width:8,height:"100%",cursor:"col-resize",zIndex:20,display:"flex",alignItems:"center",justifyContent:"center",background:p?`${e.accent}1f`:"transparent",transition:p?"none":"background 0.15s"},onMouseEnter:r=>{p||(r.currentTarget.style.background=`${e.accent}14`)},onMouseLeave:r=>{p||(r.currentTarget.style.background="transparent")},children:t.jsx("div",{style:{width:3,height:44,borderRadius:999,background:p?e.accent:e.headerBorder,boxShadow:p?`0 0 0 3px ${e.accent}1f`:"none"}})}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 14px 11px",borderBottom:`1px solid ${e.headerBorder}`,background:e.appBg,flexShrink:0},children:[t.jsx("div",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",minWidth:38,padding:"2px 6px",background:H,color:e.appBg,fontSize:10,fontWeight:700,letterSpacing:0,borderRadius:4},title:i?Q[i.type]??i.type:"",children:G||"NODE"}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{color:e.textMuted,fontSize:10,fontWeight:800,marginBottom:3},children:"Lineage Inspector"}),t.jsx("div",{style:{fontSize:14,fontWeight:700,color:e.textPrimary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:(i==null?void 0:i.name)??n,children:(i==null?void 0:i.name)??n}),t.jsxs("div",{style:{fontSize:11,color:e.textMuted,marginTop:2},children:["Lineage · ↑ ",$," · ↓ ",_]})]}),t.jsx(h,{title:"Collapse drawer",onClick:()=>f(!0),t:e,children:t.jsx(re,{size:14,strokeWidth:1.8})}),t.jsx(h,{title:"Reset width",onClick:z,t:e,children:t.jsx(ie,{size:14,strokeWidth:1.8})}),t.jsx(h,{title:"Hide lineage drawer",onClick:W,t:e,children:t.jsx(B,{size:14,strokeWidth:2})})]}),t.jsxs("div",{style:{height:30,padding:"0 14px",borderBottom:`1px solid ${e.headerBorder}`,display:"flex",alignItems:"center",gap:8,color:e.textMuted,fontSize:11,flexShrink:0,background:e.sidebarBg},children:[t.jsx(ne,{size:13,strokeWidth:1.8}),t.jsx("span",{children:"Drag the left edge to resize"}),t.jsxs("span",{style:{marginLeft:"auto",color:e.textMuted},children:[w,"px"]})]}),i&&t.jsx(de,{node:i,t:e}),t.jsx("div",{ref:j,style:{flex:1,minHeight:220,padding:12,overflow:"hidden",display:"flex",background:e.appBg},children:N?t.jsx("div",{style:{color:e.textMuted,fontSize:12,padding:8},children:"Loading lineage…"}):s.nodes.length===0?t.jsx("div",{style:{color:e.textMuted,fontSize:12,padding:8},children:"No lineage available for this node."}):t.jsx("div",{style:{flex:1,minWidth:0},children:t.jsx(ee,{nodes:s.nodes,edges:s.edges,focalNodeId:n,height:Math.max(0,A-24),onNodeClick:Y,interactive:!0})})}),i&&t.jsxs("div",{style:{borderTop:`1px solid ${e.headerBorder}`,padding:"10px 12px",display:"grid",gap:10,maxHeight:280,overflow:"auto",background:e.sidebarBg,flexShrink:0},children:[t.jsx(C,{title:"Upstream",connections:U,t:e}),t.jsx(C,{title:"Downstream",connections:X,t:e})]}),typeof v=="string"&&t.jsxs("div",{style:{padding:"8px 14px",borderTop:`1px solid ${e.headerBorder}`,fontSize:11,color:e.textMuted,display:"flex",alignItems:"center",gap:6},children:[t.jsx(se,{size:11,strokeWidth:1.75}),t.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:v,children:v})]})]})}function de({node:o,t:a}){const e=o.metadata??{},n=[];return o.domain&&n.push({label:"Domain",value:o.domain}),o.owner&&n.push({label:"Owner",value:o.owner}),o.status&&n.push({label:"Status",value:o.status}),o.type==="term"&&typeof e.termType=="string"&&n.push({label:"Term Type",value:e.termType}),o.type==="block"&&typeof e.blockType=="string"&&n.push({label:"Block Type",value:e.blockType}),typeof e.materializedAs=="string"&&n.push({label:"Materialized As",value:e.materializedAs}),Array.isArray(e.identifiers)&&e.identifiers.length>0&&n.push({label:"Identifiers",value:e.identifiers.map(String).join(", ")}),Array.isArray(e.synonyms)&&e.synonyms.length>0&&n.push({label:"Synonyms",value:e.synonyms.map(String).join(", ")}),typeof e.description=="string"&&e.description.trim()&&n.push({label:"Description",value:e.description}),typeof e.businessOutcome=="string"&&e.businessOutcome.trim()&&n.push({label:"Business Outcome",value:e.businessOutcome}),n.length===0?null:t.jsx("div",{style:{padding:"10px 14px",borderBottom:`1px solid ${a.headerBorder}`,display:"grid",gap:6,background:a.sidebarBg},children:n.slice(0,6).map(s=>t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"92px 1fr",gap:8,minWidth:0},children:[t.jsx("span",{style:{color:a.textMuted,fontSize:10,fontWeight:700,textTransform:"uppercase"},children:s.label}),t.jsx("span",{style:{color:a.textSecondary,fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:s.value.length>90?"normal":"nowrap"},title:s.value,children:s.value})]},s.label))})}function C({title:o,connections:a,t:e}){return a.length===0?t.jsxs("div",{style:{color:e.textMuted,fontSize:11},children:[o,": none in this focused window"]}):t.jsxs("div",{children:[t.jsx("div",{style:{color:e.textMuted,fontSize:10,fontWeight:700,textTransform:"uppercase",marginBottom:5},children:o}),t.jsxs("div",{style:{display:"grid",gap:4},children:[a.slice(0,5).map(({edge:n,node:s})=>{const m=R[s.type]??e.textMuted;return t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"76px 1fr",gap:8,alignItems:"center",fontSize:11,minWidth:0},children:[t.jsx("span",{style:{color:e.textMuted},children:Z[n.type]??n.type}),t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,minWidth:0},children:[t.jsx("span",{style:{color:e.appBg,background:m,borderRadius:3,padding:"1px 4px",fontSize:8,fontWeight:700,flexShrink:0},children:I[s.type]??s.type.slice(0,4).toUpperCase()}),t.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:s.name,children:s.name})]})]},`${n.source}-${n.target}-${n.type}`)}),a.length>5&&t.jsxs("div",{style:{color:e.textMuted,fontSize:11},children:[a.length-5," more connection",a.length-5===1?"":"s"," in the graph"]})]})]})}function h({title:o,onClick:a,children:e,t:n}){return t.jsx("button",{"aria-label":o,title:o,onClick:a,style:{width:26,height:26,display:"inline-flex",alignItems:"center",justifyContent:"center",background:"transparent",border:`1px solid ${n.headerBorder}`,borderRadius:5,color:n.textSecondary,cursor:"pointer"},onMouseEnter:s=>{s.currentTarget.style.color=n.textPrimary,s.currentTarget.style.background=n.textPrimary+"0f"},onMouseLeave:s=>{s.currentTarget.style.color=n.textSecondary,s.currentTarget.style.background="transparent"},children:e})}export{be as LineageDrawer};
@@ -0,0 +1,14 @@
1
+ import{r as v,j as d,t as Pe,V as De,W as ue,aj as _e,a as je,ak as Be,al as Ie,am as Te,R as be,n as ze,o as Oe}from"./index-DU7j3Sqk.js";import{S as Z,g as ye,E as S,s as Ne,a as g,b as ve,c as Ke,P as Qe,d as Ge,e as Ue,F as Ze,f as Ve,h as Se,V as He,D as R,R as Ye,i as Je,C as M,j as we,k as y,r as Xe,l as et,m as tt,u as rt,n as nt,t as st,o as at,p as it,q as ot,v as lt,w as ct,x as ut,y as ht,z as dt,A as ft,B as pt,G as mt,H as gt,I as xt,J as bt,K as yt,L as vt,M as he,N as St,O as u}from"./codemirror-1_I9gm6Z.js";const de=typeof String.prototype.normalize=="function"?t=>t.normalize("NFKD"):t=>t;class P{constructor(e,r,n=0,s=e.length,a,i){this.test=i,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,s),this.bufferStart=n,this.normalize=a?o=>a(de(o)):de,this.query=this.normalize(r)}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 Ge(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let r=Je(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=Ue(e);let s=this.normalize(r);if(s.length)for(let a=0,i=n;;a++){let o=s.charCodeAt(a),l=this.match(o,i,this.bufferPos+this.bufferStart);if(a==s.length-1){if(l)return this.value=l,this;break}i==n&&a<r.length&&r.charCodeAt(a)==o&&i++}}}match(e,r,n){let s=null;for(let a=0;a<this.matches.length;a+=2){let i=this.matches[a],o=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?s={from:this.matches[a+1],to:n}:(this.matches[a]++,o=!0)),o||(this.matches.splice(a,2),a-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?s={from:r,to:n}:this.matches.push(1,r)),s&&this.test&&!this.test(s.from,s.to,this.buffer,this.bufferStart)&&(s=null),s}}typeof Symbol<"u"&&(P.prototype[Symbol.iterator]=function(){return this});const ke={from:-1,to:-1,match:/.*/.exec("")},se="gm"+(/x/.unicode==null?"":"u");class Ce{constructor(e,r,n,s=0,a=e.length){if(this.text=e,this.to=a,this.curLine="",this.done=!1,this.value=ke,/\\[sWDnr]|\n|\r|\[\^/.test(r))return new Me(e,r,n,s,a);this.re=new RegExp(r,se+(n!=null&&n.ignoreCase?"i":"")),this.test=n==null?void 0:n.test,this.iter=e.iter();let i=e.lineAt(s);this.curLineStart=i.from,this.matchPos=N(e,s),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),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 e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let r=this.matchPos<=this.to&&this.re.exec(this.curLine);if(r){let n=this.curLineStart+r.index,s=n+r[0].length;if(this.matchPos=N(this.text,s+(n==s?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<s||n>this.value.to)&&(!this.test||this.test(n,s,r)))return this.value={from:n,to:s,match:r},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}const J=new WeakMap;class W{constructor(e,r){this.from=e,this.text=r}get to(){return this.from+this.text.length}static get(e,r,n){let s=J.get(e);if(!s||s.from>=n||s.to<=r){let o=new W(r,e.sliceString(r,n));return J.set(e,o),o}if(s.from==r&&s.to==n)return s;let{text:a,from:i}=s;return i>r&&(a=e.sliceString(r,i)+a,i=r),s.to<n&&(a+=e.sliceString(s.to,n)),J.set(e,new W(i,a)),new W(r,a.slice(r-i,n-i))}}class Me{constructor(e,r,n,s,a){this.text=e,this.to=a,this.done=!1,this.value=ke,this.matchPos=N(e,s),this.re=new RegExp(r,se+(n!=null&&n.ignoreCase?"i":"")),this.test=n==null?void 0:n.test,this.flat=W.get(e,s,this.chunkEnd(s+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,r=this.re.exec(this.flat.text);if(r&&!r[0]&&r.index==e&&(this.re.lastIndex=e+1,r=this.re.exec(this.flat.text)),r){let n=this.flat.from+r.index,s=n+r[0].length;if((this.flat.to>=this.to||r.index+r[0].length<=this.flat.text.length-10)&&(!this.test||this.test(n,s,r)))return this.value={from:n,to:s,match:r},this.matchPos=N(this.text,s+(n==s?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=W.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(Ce.prototype[Symbol.iterator]=Me.prototype[Symbol.iterator]=function(){return this});function wt(t){try{return new RegExp(t,se),!0}catch{return!1}}function N(t,e){if(e>=t.length)return e;let r=t.lineAt(e),n;for(;e<r.to&&(n=r.text.charCodeAt(e-r.from))>=56320&&n<57344;)e++;return e}const kt=t=>{let{state:e}=t,r=String(e.doc.lineAt(t.state.selection.main.head).number),{close:n,result:s}=Ne(t,{label:e.phrase("Go to line"),input:{type:"text",name:"line",value:r},focus:!0,submitLabel:e.phrase("go")});return s.then(a=>{let i=a&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(a.elements.line.value);if(!i){t.dispatch({effects:n});return}let o=e.doc.lineAt(e.selection.main.head),[,l,c,m,w]=i,k=m?+m.slice(1):0,f=c?+c:o.number;if(c&&w){let E=f/100;l&&(E=E*(l=="-"?-1:1)+o.number/e.doc.lines),f=Math.round(e.doc.lines*E)}else c&&l&&(f=f*(l=="-"?-1:1)+o.number);let j=e.doc.line(Math.max(1,Math.min(e.doc.lines,f))),A=S.cursor(j.from+Math.max(0,Math.min(k,j.length)));t.dispatch({effects:[n,g.scrollIntoView(A.from,{y:"center"})],selection:A})}),!0},Ct=({state:t,dispatch:e})=>{let{selection:r}=t,n=S.create(r.ranges.map(s=>t.wordAt(s.head)||S.cursor(s.head)),r.mainIndex);return n.eq(r)?!1:(e(t.update({selection:n})),!0)};function Mt(t,e){let{main:r,ranges:n}=t.selection,s=t.wordAt(r.head),a=s&&s.from==r.from&&s.to==r.to;for(let i=!1,o=new P(t.doc,e,n[n.length-1].to);;)if(o.next(),o.done){if(i)return null;o=new P(t.doc,e,0,Math.max(0,n[n.length-1].from-1)),i=!0}else{if(i&&n.some(l=>l.from==o.value.from))continue;if(a){let l=t.wordAt(o.value.from);if(!l||l.from!=o.value.from||l.to!=o.value.to)continue}return o.value}}const Lt=({state:t,dispatch:e})=>{let{ranges:r}=t.selection;if(r.some(a=>a.from===a.to))return Ct({state:t,dispatch:e});let n=t.sliceDoc(r[0].from,r[0].to);if(t.selection.ranges.some(a=>t.sliceDoc(a.from,a.to)!=n))return!1;let s=Mt(t,n);return s?(e(t.update({selection:t.selection.addRange(S.range(s.from,s.to),!1),effects:g.scrollIntoView(s.to)})),!0):!1},q=Ze.define({combine(t){return Ve(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new zt(e),scrollToMatch:e=>g.scrollIntoView(e)})}});function Et(t){return t?[q.of(t),ne]:ne}class Le{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||wt(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(r,n)=>n=="n"?`
2
+ `:n=="r"?"\r":n=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new Wt(this):new At(this)}getCursor(e,r=0,n){let s=e.doc?e:Se.create({doc:e});return n==null&&(n=s.doc.length),this.regexp?F(this,s,r,n):$(this,s,r,n)}}class Ee{constructor(e){this.spec=e}}function Rt(t,e,r){return(n,s,a,i)=>{if(r&&!r(n,s,a,i))return!1;let o=n>=i&&s<=i+a.length?a.slice(n-i,s-i):e.doc.sliceString(n,s);return t(o,e,n,s)}}function $(t,e,r,n){let s;return t.wholeWord&&(s=qt(e.doc,e.charCategorizer(e.selection.main.head))),t.test&&(s=Rt(t.test,e,s)),new P(e.doc,t.unquoted,r,n,t.caseSensitive?void 0:a=>a.toLowerCase(),s)}function qt(t,e){return(r,n,s,a)=>((a>r||a+s.length<n)&&(a=Math.max(0,r-2),s=t.sliceString(a,Math.min(t.length,n+2))),(e(K(s,r-a))!=M.Word||e(Q(s,r-a))!=M.Word)&&(e(Q(s,n-a))!=M.Word||e(K(s,n-a))!=M.Word))}class At extends Ee{constructor(e){super(e)}nextMatch(e,r,n){let s=$(this.spec,e,n,e.doc.length).nextOverlapping();if(s.done){let a=Math.min(e.doc.length,r+this.spec.unquoted.length);s=$(this.spec,e,0,a).nextOverlapping()}return s.done||s.value.from==r&&s.value.to==n?null:s.value}prevMatchInRange(e,r,n){for(let s=n;;){let a=Math.max(r,s-1e4-this.spec.unquoted.length),i=$(this.spec,e,a,s),o=null;for(;!i.nextOverlapping().done;)o=i.value;if(o)return o;if(a==r)return null;s-=1e4}}prevMatch(e,r,n){let s=this.prevMatchInRange(e,0,r);return s||(s=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length)),s&&(s.from!=r||s.to!=n)?s:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,r){let n=$(this.spec,e,0,e.doc.length),s=[];for(;!n.next().done;){if(s.length>=r)return null;s.push(n.value)}return s}highlight(e,r,n,s){let a=$(this.spec,e,Math.max(0,r-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!a.next().done;)s(a.value.from,a.value.to)}}function $t(t,e,r){return(n,s,a)=>(!r||r(n,s,a))&&t(a[0],e,n,s)}function F(t,e,r,n){let s;return t.wholeWord&&(s=Ft(e.charCategorizer(e.selection.main.head))),t.test&&(s=$t(t.test,e,s)),new Ce(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:s},r,n)}function K(t,e){return t.slice(we(t,e,!1),e)}function Q(t,e){return t.slice(e,we(t,e))}function Ft(t){return(e,r,n)=>!n[0].length||(t(K(n.input,n.index))!=M.Word||t(Q(n.input,n.index))!=M.Word)&&(t(Q(n.input,n.index+n[0].length))!=M.Word||t(K(n.input,n.index+n[0].length))!=M.Word)}class Wt extends Ee{nextMatch(e,r,n){let s=F(this.spec,e,n,e.doc.length).next();return s.done&&(s=F(this.spec,e,0,r).next()),s.done?null:s.value}prevMatchInRange(e,r,n){for(let s=1;;s++){let a=Math.max(r,n-s*1e4),i=F(this.spec,e,a,n),o=null;for(;!i.next().done;)o=i.value;if(o&&(a==r||o.from>a+10))return o;if(a==r)return null}}prevMatch(e,r,n){return this.prevMatchInRange(e,0,r)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(r,n)=>{if(n=="&")return e.match[0];if(n=="$")return"$";for(let s=n.length;s>0;s--){let a=+n.slice(0,s);if(a>0&&a<e.match.length)return e.match[a]+n.slice(s)}return r})}matchAll(e,r){let n=F(this.spec,e,0,e.doc.length),s=[];for(;!n.next().done;){if(s.length>=r)return null;s.push(n.value)}return s}highlight(e,r,n,s){let a=F(this.spec,e,Math.max(0,r-250),Math.min(n+250,e.doc.length));for(;!a.next().done;)s(a.value.from,a.value.to)}}const D=Z.define(),ae=Z.define(),L=ve.define({create(t){return new X(re(t).create(),null)},update(t,e){for(let r of e.effects)r.is(D)?t=new X(r.value.create(),t.panel):r.is(ae)&&(t=new X(t.query,r.value?ie:null));return t},provide:t=>Ke.from(t,e=>e.panel)});class X{constructor(e,r){this.query=e,this.panel=r}}const Pt=R.mark({class:"cm-searchMatch"}),Dt=R.mark({class:"cm-searchMatch cm-searchMatch-selected"}),_t=He.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(L))}update(t){let e=t.state.field(L);(e!=t.startState.field(L)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return R.none;let{view:r}=this,n=new Ye;for(let s=0,a=r.visibleRanges,i=a.length;s<i;s++){let{from:o,to:l}=a[s];for(;s<i-1&&l>a[s+1].from-500;)l=a[++s].to;t.highlight(r.state,o,l,(c,m)=>{let w=r.state.selection.ranges.some(k=>k.from==c&&k.to==m);n.add(c,m,w?Dt:Pt)})}return n.finish()}},{decorations:t=>t.decorations});function _(t){return e=>{let r=e.state.field(L,!1);return r&&r.query.spec.valid?t(e,r):Ae(e)}}const G=_((t,{query:e})=>{let{to:r}=t.state.selection.main,n=e.nextMatch(t.state,r,r);if(!n)return!1;let s=S.single(n.from,n.to),a=t.state.facet(q);return t.dispatch({selection:s,effects:[oe(t,n),a.scrollToMatch(s.main,t)],userEvent:"select.search"}),qe(t),!0}),U=_((t,{query:e})=>{let{state:r}=t,{from:n}=r.selection.main,s=e.prevMatch(r,n,n);if(!s)return!1;let a=S.single(s.from,s.to),i=t.state.facet(q);return t.dispatch({selection:a,effects:[oe(t,s),i.scrollToMatch(a.main,t)],userEvent:"select.search"}),qe(t),!0}),jt=_((t,{query:e})=>{let r=e.matchAll(t.state,1e3);return!r||!r.length?!1:(t.dispatch({selection:S.create(r.map(n=>S.range(n.from,n.to))),userEvent:"select.search.matches"}),!0)}),Bt=({state:t,dispatch:e})=>{let r=t.selection;if(r.ranges.length>1||r.main.empty)return!1;let{from:n,to:s}=r.main,a=[],i=0;for(let o=new P(t.doc,t.sliceDoc(n,s));!o.next().done;){if(a.length>1e3)return!1;o.value.from==n&&(i=a.length),a.push(S.range(o.value.from,o.value.to))}return e(t.update({selection:S.create(a,i),userEvent:"select.search.matches"})),!0},fe=_((t,{query:e})=>{let{state:r}=t,{from:n,to:s}=r.selection.main;if(r.readOnly)return!1;let a=e.nextMatch(r,n,n);if(!a)return!1;let i=a,o=[],l,c,m=[];i.from==n&&i.to==s&&(c=r.toText(e.getReplacement(i)),o.push({from:i.from,to:i.to,insert:c}),i=e.nextMatch(r,i.from,i.to),m.push(g.announce.of(r.phrase("replaced match on line $",r.doc.lineAt(n).number)+".")));let w=t.state.changes(o);return i&&(l=S.single(i.from,i.to).map(w),m.push(oe(t,i)),m.push(r.facet(q).scrollToMatch(l.main,t))),t.dispatch({changes:w,selection:l,effects:m,userEvent:"input.replace"}),!0}),It=_((t,{query:e})=>{if(t.state.readOnly)return!1;let r=e.matchAll(t.state,1e9).map(s=>{let{from:a,to:i}=s;return{from:a,to:i,insert:e.getReplacement(s)}});if(!r.length)return!1;let n=t.state.phrase("replaced $ matches",r.length)+".";return t.dispatch({changes:r,effects:g.announce.of(n),userEvent:"input.replace.all"}),!0});function ie(t){return t.state.facet(q).createPanel(t)}function re(t,e){var r,n,s,a,i;let o=t.selection.main,l=o.empty||o.to>o.from+100?"":t.sliceDoc(o.from,o.to);if(e&&!l)return e;let c=t.facet(q);return new Le({search:((r=e==null?void 0:e.literal)!==null&&r!==void 0?r:c.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:(n=e==null?void 0:e.caseSensitive)!==null&&n!==void 0?n:c.caseSensitive,literal:(s=e==null?void 0:e.literal)!==null&&s!==void 0?s:c.literal,regexp:(a=e==null?void 0:e.regexp)!==null&&a!==void 0?a:c.regexp,wholeWord:(i=e==null?void 0:e.wholeWord)!==null&&i!==void 0?i:c.wholeWord})}function Re(t){let e=ye(t,ie);return e&&e.dom.querySelector("[main-field]")}function qe(t){let e=Re(t);e&&e==t.root.activeElement&&e.select()}const Ae=t=>{let e=t.state.field(L,!1);if(e&&e.panel){let r=Re(t);if(r&&r!=t.root.activeElement){let n=re(t.state,e.query.spec);n.valid&&t.dispatch({effects:D.of(n)}),r.focus(),r.select()}}else t.dispatch({effects:[ae.of(!0),e?D.of(re(t.state,e.query.spec)):Z.appendConfig.of(ne)]});return!0},$e=t=>{let e=t.state.field(L,!1);if(!e||!e.panel)return!1;let r=ye(t,ie);return r&&r.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:ae.of(!1)}),!0},Tt=[{key:"Mod-f",run:Ae,scope:"editor search-panel"},{key:"F3",run:G,shift:U,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:G,shift:U,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:$e,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Bt},{key:"Mod-Alt-g",run:kt},{key:"Mod-d",run:Lt,preventDefault:!0}];class zt{constructor(e){this.view=e;let r=this.query=e.state.field(L).query.spec;this.commit=this.commit.bind(this),this.searchField=y("input",{value:r.search,placeholder:b(e,"Find"),"aria-label":b(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=y("input",{value:r.replace,placeholder:b(e,"Replace"),"aria-label":b(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=y("input",{type:"checkbox",name:"case",form:"",checked:r.caseSensitive,onchange:this.commit}),this.reField=y("input",{type:"checkbox",name:"re",form:"",checked:r.regexp,onchange:this.commit}),this.wordField=y("input",{type:"checkbox",name:"word",form:"",checked:r.wholeWord,onchange:this.commit});function n(s,a,i){return y("button",{class:"cm-button",name:s,onclick:a,type:"button"},i)}this.dom=y("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,n("next",()=>G(e),[b(e,"next")]),n("prev",()=>U(e),[b(e,"previous")]),n("select",()=>jt(e),[b(e,"all")]),y("label",null,[this.caseField,b(e,"match case")]),y("label",null,[this.reField,b(e,"regexp")]),y("label",null,[this.wordField,b(e,"by word")]),...e.state.readOnly?[]:[y("br"),this.replaceField,n("replace",()=>fe(e),[b(e,"replace")]),n("replaceAll",()=>It(e),[b(e,"replace all")])],y("button",{name:"close",onclick:()=>$e(e),"aria-label":b(e,"close"),type:"button"},["×"])])}commit(){let e=new Le({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:D.of(e)}))}keydown(e){Xe(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?U:G)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),fe(this.view))}update(e){for(let r of e.transactions)for(let n of r.effects)n.is(D)&&!n.value.eq(this.query)&&this.setQuery(n.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(q).top}}function b(t,e){return t.state.phrase(e)}const T=30,z=/[\s\.,:;?!]/;function oe(t,{from:e,to:r}){let n=t.state.doc.lineAt(e),s=t.state.doc.lineAt(r).to,a=Math.max(n.from,e-T),i=Math.min(s,r+T),o=t.state.sliceDoc(a,i);if(a!=n.from){for(let l=0;l<T;l++)if(!z.test(o[l+1])&&z.test(o[l])){o=o.slice(l);break}}if(i!=s){for(let l=o.length-1;l>o.length-T;l--)if(!z.test(o[l-1])&&z.test(o[l])){o=o.slice(0,l);break}}return g.announce.of(`${t.state.phrase("current match")}. ${o} ${t.state.phrase("on line")} ${n.number}.`)}const Ot=g.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"}}),ne=[L,Qe.low(_t),Ot],pe=[{name:"domain",detail:"business domain (namespace)"},{name:"owner",detail:"accountable owner — required to certify"},{name:"description",detail:"business-facing description"},{name:"status",detail:"draft | certified"},{name:"pattern",detail:"reusable block pattern"},{name:"grain",detail:'row grain, e.g. "one row per customer"'},{name:"outputs",detail:"declared output column names"},{name:"entities",detail:'business entities, e.g. ["order"]'},{name:"tags",detail:"discoverability tags"},{name:"llmContext",detail:"when an agent should use this block"},{name:"reviewCadence",detail:"how often to re-review"},{name:"sourceSystems",detail:"upstream source systems"},{name:"dimensions",detail:"queryable dimensions"},{name:"allowedFilters",detail:"filters an app may bind"},{name:"filterBindings",detail:"filter → column map (app-ready)",snippet:`filterBindings {
3
+ $0
4
+ }`},{name:"parameterPolicy",detail:"per-parameter reuse policy",snippet:`parameterPolicy {
5
+ $0
6
+ }`},{name:"identifiers",detail:"identifier columns"},{name:"synonyms",detail:"alternate names"},{name:"primaryTerms",detail:"governed terms this block defines"},{name:"replacementFor",detail:"block this supersedes"},{name:"boundedContext",detail:"bounded context"},{name:"businessOwner",detail:"business (non-technical) owner"},{name:"businessOutcome",detail:"outcome this supports"},{name:"businessRules",detail:"business rules / caveats"},{name:"decisionUse",detail:"decision this informs"},{name:"caveats",detail:"known caveats"},{name:"invariants",detail:"assertions that must hold"},{name:"chart",detail:"default visualization",snippet:'chart = "bar"'},{name:"examples",detail:"example questions block",snippet:`examples = [
7
+ { question = "$0" }
8
+ ]`},{name:"parameters",detail:"parameters block",snippet:`parameters {
9
+ $0
10
+ }`},{name:"tests",detail:"test assertions block",snippet:`tests {
11
+ assert $0
12
+ }`},{name:"query",detail:"the SQL body",snippet:`query = """
13
+ $0
14
+ """`}],Nt={chart:["bar","line","area","column","combo","pie","donut","scatter","histogram","heatmap","number","single_value","table"],viz:["bar","line","area","column","combo","pie","donut","scatter","histogram","heatmap","number","single_value","table"],type:["bar","line","area","column","combo","pie","donut","scatter","histogram","heatmap","number","single_value","table"],pattern:["metric_wrapper","entity_profile","entity_rollup","ranking","trend","bridge","drilldown","replacement","custom"],reviewCadence:["daily","weekly","monthly","quarterly","annually"],status:["draft","certified"],type_block:["custom","semantic"]};function Kt(t){return(t.match(/"""/g)??[]).length%2===1}function me(t){return{label:t.name,type:"property",detail:t.detail,apply:t.snippet?Qt(t.snippet):`${t.name} = `}}function Qt(t){return(e,r,n,s)=>{const a=t.indexOf("$0"),i=t.replace("$0",""),o=a>=0?n+a:n+i.length;e.dispatch({changes:{from:n,to:s,insert:i},selection:{anchor:o}})}}const Gt=t=>{const e=t.state.doc.lineAt(t.pos),r=t.state.sliceDoc(0,t.pos),n=r.slice(e.from);if(Kt(r))return null;const s=/([a-zA-Z_]+)\s*=\s*"([^"]*)$/.exec(n);if(s){const i=Nt[s[1]];if(i){const o=t.pos-s[2].length,l=s[2].toLowerCase();return{from:o,options:i.filter(c=>!l||c.toLowerCase().includes(l)).map(c=>({label:c,type:"enum"})),validFor:/^[\w-]*$/}}return null}const a=t.matchBefore(/[a-zA-Z_]+/);if(a&&/^\s*[a-zA-Z_]+$/.test(n)){const i=a.text.toLowerCase();return{from:a.from,options:pe.filter(o=>o.name.toLowerCase().startsWith(i)||o.name.toLowerCase().includes(i)).map(me),validFor:/^[a-zA-Z_]*$/}}return t.explicit&&/^\s*$/.test(n)?{from:t.pos,options:pe.map(me)}:null},ge=new Map;async function ee(t,e,r){const n=`${t}:${r??""}:${e}`.toLowerCase(),s=ge.get(n);if(s&&s.expiresAt>Date.now())return s.items;const a=new URLSearchParams({kind:t,q:e,limit:"60"});r&&a.set("relation",r);const i=await fetch(`${window.location.origin}/api/editor/completions?${a}`);if(!i.ok)return[];const o=await i.json(),l=Array.isArray(o.completions)?o.completions:[];return ge.set(n,{items:l,expiresAt:Date.now()+2e4}),l}const Ut=async t=>{const e=t.state.sliceDoc(0,t.pos),r=/\b(?:from|join)\s+([\w."-]*)$/i.exec(e);if(r){const a=r[1].replace(/^"/,""),i=await ee("relation",a);return te(t.pos-r[1].length,i)}const n=/([A-Za-z_][\w]*)\.([A-Za-z_][\w]*)?$/.exec(e);if(n){const a=n[1],i=n[2]??"",o=Zt(e,a)??a,l=await ee("column",i,o.replace(/^"|"$/g,""));return te(t.pos-i.length,l)}const s=t.matchBefore(/[A-Za-z_][\w]*$/);if(t.explicit&&s){const a=await ee("column",s.text);return te(s.from,a)}return null};function te(t,e){return{from:t,options:e.map(r=>({label:r.label||r.name,apply:r.apply??r.name,detail:[r.detail,r.relation,r.governance].filter(Boolean).join(" · "),info:r.description,type:r.type==="column"?"property":r.type==="dataset"?"class":"variable",boost:r.governance==="semantic"||r.governance==="project_controlled"?20:0})),validFor:/^[\w."-]*$/}}function Zt(t,e){var n;return(n=new RegExp(`\\b(?:from|join)\\s+([\\w."-]+)(?:\\s+(?:as\\s+)?${Vt(e)})\\b`,"i").exec(t))==null?void 0:n[1]}function Vt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function xe(t,e){const r=t?he({schema:t,upperCaseKeywords:!1}):he({upperCaseKeywords:!1}),n=[r,r.language.data.of({autocomplete:Be}),r.language.data.of({autocomplete:Ut})];return e&&n.push(r.language.data.of({autocomplete:Gt})),n}function Ht(t){const e=t.match(/LINE\s+(\d+)/i);if(e){const s=parseInt(e[1],10),a=t.match(/\n(\s*)\^/),i=a?a[1].length+1:1;return{line:s,col:i}}const r=t.match(/at line\s+(\d+),?\s*column\s+(\d+)/i);if(r)return{line:parseInt(r[1],10),col:parseInt(r[2],10)};const n=t.match(/line\s+(\d+)/i);return n?{line:parseInt(n[1],10),col:1}:null}const O=Z.define(),Yt=ve.define({create(){return R.none},update(t,e){for(const r of e.effects)if(r.is(O)){if(!r.value)return R.none;const{from:n,to:s,message:a}=r.value;return R.set([R.mark({class:"cm-sql-error",attributes:{title:a}}).range(n,s)])}return t},provide:t=>g.decorations.from(t)}),Jt=St.define([{tag:u.keyword,color:"var(--sql-keyword)",fontWeight:"600"},{tag:[u.controlKeyword,u.moduleKeyword],color:"var(--sql-keyword)",fontWeight:"600"},{tag:[u.string,u.special(u.string)],color:"var(--sql-string)"},{tag:u.number,color:"var(--sql-number)"},{tag:u.bool,color:"var(--sql-number)",fontWeight:"600"},{tag:u.null,color:"var(--sql-number)",fontWeight:"600"},{tag:[u.comment,u.lineComment,u.blockComment,u.docComment],color:"var(--sql-comment)",fontStyle:"italic"},{tag:[u.function(u.variableName),u.function(u.propertyName)],color:"var(--sql-function)"},{tag:[u.typeName,u.className],color:"var(--sql-type)"},{tag:u.operator,color:"var(--sql-punctuation)"},{tag:u.punctuation,color:"var(--sql-punctuation)"},{tag:u.bracket,color:"var(--sql-punctuation)"},{tag:[u.variableName,u.name,u.propertyName,u.attributeName],color:"var(--sql-ident)"},{tag:u.invalid,color:"var(--color-status-error)"}]),Xt=g.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 Fe(t){return g.theme({"&":{background:"transparent",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:"transparent",color:"var(--color-text-tertiary)",border:"none",borderRight:"1px solid var(--color-border-subtle)"},".cm-activeLineGutter":{background:"transparent"},".cm-activeLine":{background:"transparent"},"&.cm-focused .cm-activeLineGutter":{background:"var(--color-bg-hover)"},"&.cm-focused .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:t})}const er=Fe(!0),tr=Fe(!1);function rr(t){return t==="midnight"||t==="obsidian"||t==="dark"}function nr({value:t,onChange:e,onRun:r,themeMode:n,autoFocus:s,schema:a,errorMessage:i,editorRef:o,wrap:l=!0,fillHeight:c=!1,dqlMode:m=!1}){const w=Pe[n],k=v.useRef(null),f=v.useRef(null),[j,A]=v.useState(!1),E=v.useRef(r),le=v.useRef(e),ce=v.useRef(new et);return E.current=r,le.current=e,v.useEffect(()=>{o&&(o.current={undo:()=>{f.current&&rt(f.current)},redo:()=>{f.current&&tt(f.current)},resetTo:h=>{const p=f.current;p&&p.dispatch({changes:{from:0,to:p.state.doc.length,insert:h}})}})}),v.useEffect(()=>{if(!k.current)return;const h=nt.of([{key:"Shift-Enter",run:()=>(E.current(),!0)},{key:"Ctrl-Enter",mac:"Cmd-Enter",run:()=>(E.current(),!0)},{key:"Ctrl-/",mac:"Cmd-/",run:st},at,...it,...ot,...lt,...Tt,...ct,...ut]),p=g.updateListener.of(I=>{I.docChanged&&le.current(I.state.doc.toString())}),x=g.domEventHandlers({focus:(I,Y)=>{Te(Y)},blur:(I,Y)=>{Ie(Y)}}),C=g.theme({"&":{background:"var(--color-bg-surface)",color:"var(--color-text-primary)",fontFamily:"var(--font-mono)",fontSize:"13px",minHeight:c?"100%":"80px",maxHeight:c?"none":"480px",...c?{height:"100%"}:{}},".cm-scroller":{overflow:"auto",fontFamily:"inherit",...c?{height:"100%"}:{}},".cm-content":{padding:"10px 0",minHeight:c?"100%":"80px",color:"var(--color-text-primary)"},"&.cm-focused":{outline:"none"},".cm-editor":{border:"none"},".cm-gutters":{minWidth:40},".cm-foldGutter":{cursor:"pointer"}}),B=xe(a,m),V=[h,p,x,C,ce.current.of(B),ht({closeOnBlur:!1}),dt(),ft(),pt(),mt(),gt(),xt(),bt(),yt(),...l?[g.lineWrapping]:[],Et({top:!0}),Yt,Xt,vt(Jt),rr(n)?er:tr],We=Se.create({doc:t,extensions:V}),H=new g({state:We,parent:k.current});return f.current=H,s&&H.focus(),()=>{H.destroy(),f.current=null}},[n]),v.useEffect(()=>{const h=f.current;h&&h.dispatch({effects:ce.current.reconfigure(xe(a,m))})},[a,m]),v.useEffect(()=>{const h=f.current;if(!h)return;const p=h.state.doc.toString();p!==t&&h.dispatch({changes:{from:0,to:p.length,insert:t}})},[t]),v.useEffect(()=>{const h=f.current;if(!h)return;if(!i){h.dispatch({effects:O.of(null)});return}const p=Ht(i),x=h.state.doc;if(p&&p.line>=1&&p.line<=x.lines){const C=x.line(p.line),B=C.from+Math.max(0,p.col-1),V=Math.max(B+1,C.to);h.dispatch({effects:O.of({from:Math.min(B,x.length),to:Math.min(V,x.length),message:i})})}else if(x.lines>=1){const C=x.line(1);h.dispatch({effects:O.of({from:C.from,to:Math.max(C.from+1,C.to),message:i})})}},[i]),d.jsx("div",{onDragOver:h=>{h.dataTransfer.types.includes(ue)&&(h.preventDefault(),A(!0))},onDragLeave:()=>A(!1),onDrop:h=>{const p=f.current;if(!p)return;const x=De(h.dataTransfer.getData(ue));x&&(h.preventDefault(),A(!1),_e(p,x.reference,{x:h.clientX,y:h.clientY}),je.trackUsage(x.name),window.dispatchEvent(new CustomEvent("dql:semantic-used",{detail:{name:x.name}})))},style:{background:"var(--color-bg-surface)",height:c?"100%":void 0,minHeight:c?0:80,border:j?`1px solid ${w.accent}`:"1px solid transparent",borderRadius:c?0:6,transition:"border-color 0.15s",overflow:"hidden"},children:d.jsx("div",{ref:k,style:{height:c?"100%":void 0,minHeight:c?0:80}})})}nr.displayName="SQLCellEditor";function sr({path:t,onNodeClick:e,focalNodeId:r,t:n}){return t.nodes.length===0?null:d.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,alignItems:"center"},children:t.nodes.map((s,a)=>d.jsxs(be.Fragment,{children:[d.jsx(ar,{node:s,isFocal:s.id===r,onClick:e?()=>e(s.id):void 0,t:n}),a<t.nodes.length-1&&d.jsx("span",{style:{color:n.textMuted,fontSize:10,lineHeight:1},children:"→"})]},s.id))})}function lr({title:t,paths:e,onNodeClick:r,focalNodeId:n,maxVisible:s=4,t:a}){const[i,o]=be.useState(!1),l=i?e:e.slice(0,s),c=e.length>s;return e.length===0?null:d.jsxs("div",{style:{border:`1px solid ${a.cellBorder}`,borderRadius:10,overflow:"hidden",background:a.inputBg},children:[d.jsxs("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${a.cellBorder}`,fontSize:11,fontWeight:700,color:a.textMuted,fontFamily:a.font,textTransform:"uppercase",letterSpacing:"0.04em",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[d.jsx("span",{children:t}),d.jsxs("span",{style:{fontWeight:400,fontSize:10},children:[e.length," path",e.length!==1?"s":""]})]}),d.jsxs("div",{style:{display:"grid",gap:8,padding:10},children:[l.map((m,w)=>d.jsx(sr,{path:m,onNodeClick:r,focalNodeId:n,t:a},`path-${w}`)),c&&!i&&d.jsxs("button",{onClick:()=>o(!0),style:{background:"none",border:"none",color:a.accent,cursor:"pointer",fontSize:11,fontFamily:a.font,padding:"2px 0",textAlign:"left"},children:["Show ",e.length-s," more path",e.length-s!==1?"s":"","..."]})]})]})}function ar({node:t,isFocal:e,onClick:r,t:n}){const s=ze[t.type]??"#8b949e",a=Oe[t.type]??t.type.slice(0,3).toUpperCase();return d.jsxs("button",{onClick:r,disabled:!r,style:{display:"inline-flex",alignItems:"center",gap:4,background:e?`${s}18`:n.pillBg??`${n.cellBg}`,border:`1px solid ${e?s:n.cellBorder}`,borderRadius:999,color:n.textPrimary,cursor:r?"pointer":"default",fontSize:10,fontFamily:n.font,padding:"3px 8px",transition:"border-color 0.15s",whiteSpace:"nowrap",maxWidth:180},title:`${t.type}: ${t.name}${t.domain?` (${t.domain})`:""}`,children:[d.jsx("span",{style:{fontSize:8,fontWeight:700,color:"#0d1117",background:s,borderRadius:3,padding:"1px 3px",flexShrink:0},children:a}),d.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.name})]})}function cr({layerSummary:t,t:e}){const r=["source","transform","answer","consumption"];if(Object.values(t).reduce((i,o)=>i+o,0)===0)return null;const s={source:"#79c0ff",transform:"#ff7b72",answer:"#56d364",consumption:"#d2a8ff"},a={source:"Sources",transform:"Transform",answer:"Answer",consumption:"Consumption"};return d.jsx("div",{style:{display:"flex",gap:10,fontSize:10,color:e.textMuted,fontFamily:e.font},children:r.map(i=>{const o=t[i]??0;return o===0?null:d.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3},children:[d.jsx("span",{style:{width:8,height:8,borderRadius:2,background:s[i],display:"inline-block"}}),a[i],": ",o]},i)})})}export{sr as L,nr as S,cr as a,lr as b};