@duckcodeailabs/dql-cli 1.12.11 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apps-api.d.ts +151 -3
- package/dist/apps-api.d.ts.map +1 -1
- package/dist/apps-api.js +675 -97
- package/dist/apps-api.js.map +1 -1
- package/dist/assets/dql-notebook/assets/AgentAnswerCard-Cp0eh6zU.js +5 -0
- package/dist/assets/dql-notebook/assets/{AgentLogPage-hzHqpD3-.js → AgentLogPage-CBGEoGmU.js} +1 -1
- package/dist/assets/dql-notebook/assets/{AiBuildDialog-BQRWoxp9.js → AiBuildDialog-CwAD3tXE.js} +1 -1
- package/dist/assets/dql-notebook/assets/{AiBuildResult-D9t_4sQl.js → AiBuildResult-CyqTuQe5.js} +1 -1
- package/dist/assets/dql-notebook/assets/AiSidePanel-DjB8PWHG.js +6 -0
- package/dist/assets/dql-notebook/assets/AnalyticsHome-B7BkvA-R.js +6 -0
- package/dist/assets/dql-notebook/assets/AppsView-CUrqtEGC.js +4583 -0
- package/dist/assets/dql-notebook/assets/BlockStudio-Bl0aGQJR.js +60 -0
- package/dist/assets/dql-notebook/assets/{BusinessArtifactView-CnTbFVGT.js → BusinessArtifactView-C4SZVNW-.js} +1 -1
- package/dist/assets/dql-notebook/assets/DbtFirstModelingPage-B0uxitnx.js +22 -0
- package/dist/assets/dql-notebook/assets/GitPage-BfVD4tVq.js +7 -0
- package/dist/assets/dql-notebook/assets/GlobalAiRail-DUwdy3fB.js +1 -0
- package/dist/assets/dql-notebook/assets/GovernedContextPage-D9f26ZFb.js +7 -0
- package/dist/assets/dql-notebook/assets/{HelpDocsPage-CL0vbSER.js → HelpDocsPage-BDPNVot1.js} +1 -1
- package/dist/assets/dql-notebook/assets/{HomePage-DzAucwBW.js → HomePage-DiOnRhEG.js} +1 -1
- package/dist/assets/dql-notebook/assets/LineageDAG-BiUFX2KL.js +1 -0
- package/dist/assets/dql-notebook/assets/{LineageDetailView-DdVH-nz6.js → LineageDetailView-CfbSvlPJ.js} +1 -1
- package/dist/assets/dql-notebook/assets/{LineageDrawer-BvrVZNKY.js → LineageDrawer-CgTScaGB.js} +1 -1
- package/dist/assets/dql-notebook/assets/{LineagePathBreadcrumb-CSut-zvm.js → LineagePathBreadcrumb-D7ZA7k68.js} +3 -3
- package/dist/assets/dql-notebook/assets/{MiniLineageGraph-zg_1wW3M.js → MiniLineageGraph-GkD4y17x.js} +1 -1
- package/dist/assets/dql-notebook/assets/{NewBlockModal-9cDletl-.js → NewBlockModal-B9TfRjt7.js} +1 -1
- package/dist/assets/dql-notebook/assets/{NewNotebookModal-V6de8L4d.js → NewNotebookModal-BbO9NKUl.js} +2 -2
- package/dist/assets/dql-notebook/assets/NotebookEditor-CuMpvXR9.js +200 -0
- package/dist/assets/dql-notebook/assets/ReadinessPage-BROJ9YBM.js +1 -0
- package/dist/assets/dql-notebook/assets/{SetupOnboarding-Bg-MjbC9.js → SetupOnboarding-BCcZlpuQ.js} +2 -2
- package/dist/assets/dql-notebook/assets/{TrustBadge-DGuHB8kP.js → TrustBadge-vQQh8d0D.js} +1 -1
- package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-Dj4AXAhT.js +83 -0
- package/dist/assets/dql-notebook/assets/{answer-to-notebook-BDzY4MuQ.js → answer-to-notebook-DuqCcDDl.js} +1 -1
- package/dist/assets/dql-notebook/assets/{arrow-left-IjlnAihE.js → arrow-left-CMe1kkOL.js} +1 -1
- package/dist/assets/dql-notebook/assets/{arrow-right-BI4cXgOY.js → arrow-right-DvB_DONr.js} +1 -1
- package/dist/assets/dql-notebook/assets/{book-open-text-i6xhxu_I.js → book-open-text-CJ3NAvrs.js} +1 -1
- package/dist/assets/dql-notebook/assets/{bot-C6DE7Q6m.js → bot-CV8DYRrt.js} +1 -1
- package/dist/assets/dql-notebook/assets/{chevron-up-DSEILnDs.js → chevron-up-HxU1l85K.js} +1 -1
- package/dist/assets/dql-notebook/assets/{circle-x-BoAorVSm.js → circle-x-BCgtha1W.js} +1 -1
- package/dist/assets/dql-notebook/assets/{dagre.esm-CycymVj6.js → dagre.esm-GKp7qoUL.js} +1 -1
- package/dist/assets/dql-notebook/assets/{external-link-ZwE5iHsX.js → external-link-C-PXokWV.js} +1 -1
- package/dist/assets/dql-notebook/assets/{grip-vertical-Dnp2st8l.js → grip-vertical-B4EHbGXW.js} +1 -1
- package/dist/assets/dql-notebook/assets/index-1mIC_XX4.js +634 -0
- package/dist/assets/dql-notebook/assets/{link-2-CTKe6Snr.js → link-2-BLx-goet.js} +1 -1
- package/dist/assets/dql-notebook/assets/{list-tree-Ced8e_S1.js → list-tree-BRFpEmvV.js} +1 -1
- package/dist/assets/dql-notebook/assets/{maximize-2-Cojc6867.js → maximize-2-CCd5uRIZ.js} +1 -1
- package/dist/assets/dql-notebook/assets/{minimize-2-CBIAE0XH.js → minimize-2-CDwSCGlO.js} +1 -1
- package/dist/assets/dql-notebook/assets/{panel-right-open-po3bWSeL.js → panel-right-open-CunA1xO7.js} +1 -1
- package/dist/assets/dql-notebook/assets/{pencil-Cb45c6WU.js → pencil-D_I14Wyk.js} +1 -1
- package/dist/assets/dql-notebook/assets/{rotate-ccw-B9v1LTJ0.js → rotate-ccw-DOrfTZk8.js} +1 -1
- package/dist/assets/dql-notebook/assets/{semantic-fields-B6ii0an0.js → semantic-fields-AfQvjt5R.js} +1 -1
- package/dist/assets/dql-notebook/assets/{star-CO4tfaDq.js → star-DDhv4e8M.js} +1 -1
- package/dist/assets/dql-notebook/assets/{triangle-alert-BSdIu2El.js → triangle-alert-2ZXx8wAu.js} +1 -1
- package/dist/assets/dql-notebook/assets/usePersistedAgentThreadId-3rzkZrqc.js +18 -0
- package/dist/assets/dql-notebook/assets/{user-round-BfrV8U-W.js → user-round-BA074kiQ.js} +1 -1
- package/dist/assets/dql-notebook/assets/{wand-sparkles-BgTxZNBc.js → wand-sparkles-CEYHLt9b.js} +1 -1
- package/dist/assets/dql-notebook/assets/{workflow--2ycp0yy.js → workflow-CZtyrcR-.js} +1 -1
- package/dist/assets/dql-notebook/assets/{wrench-LMCrpa9_.js → wrench-Ong23-wu.js} +1 -1
- package/dist/assets/dql-notebook/assets/{x-CeNgQwGm.js → x-CSo1M3tu.js} +1 -1
- package/dist/assets/dql-notebook/index.html +1 -1
- package/dist/llm/providers/dql-agent-provider.d.ts +4 -3
- package/dist/llm/providers/dql-agent-provider.d.ts.map +1 -1
- package/dist/llm/providers/dql-agent-provider.js +13 -10
- package/dist/llm/providers/dql-agent-provider.js.map +1 -1
- package/dist/local-operation-coordinator.d.ts +59 -0
- package/dist/local-operation-coordinator.d.ts.map +1 -0
- package/dist/local-operation-coordinator.js +256 -0
- package/dist/local-operation-coordinator.js.map +1 -0
- package/dist/local-runtime.d.ts +49 -1
- package/dist/local-runtime.d.ts.map +1 -1
- package/dist/local-runtime.js +1590 -323
- package/dist/local-runtime.js.map +1 -1
- package/dist/package.json +12 -11
- package/dist/project-refresh-coordinator.d.ts +19 -0
- package/dist/project-refresh-coordinator.d.ts.map +1 -0
- package/dist/project-refresh-coordinator.js +134 -0
- package/dist/project-refresh-coordinator.js.map +1 -0
- package/dist/project-refresh-worker.d.ts +13 -0
- package/dist/project-refresh-worker.d.ts.map +1 -0
- package/dist/project-refresh-worker.js +58 -0
- package/dist/project-refresh-worker.js.map +1 -0
- package/package.json +13 -11
- package/dist/assets/dql-notebook/assets/AgentAnswerCard-CpL2kDCV.js +0 -5
- package/dist/assets/dql-notebook/assets/AiSidePanel-BCQB9rVF.js +0 -6
- package/dist/assets/dql-notebook/assets/AnalyticsHome-Ba4Ve_Gd.js +0 -6
- package/dist/assets/dql-notebook/assets/AppsView-CdAT9BOq.js +0 -4466
- package/dist/assets/dql-notebook/assets/BlockStudio-Brg4fwn5.js +0 -60
- package/dist/assets/dql-notebook/assets/DbtFirstModelingPage-CQe2FUZq.js +0 -22
- package/dist/assets/dql-notebook/assets/GitPage-DHyDBChc.js +0 -7
- package/dist/assets/dql-notebook/assets/GlobalAiRail-Cys4n_rq.js +0 -1
- package/dist/assets/dql-notebook/assets/GovernedContextPage-DyKoDSZ2.js +0 -7
- package/dist/assets/dql-notebook/assets/LineageDAG-QHqd_AM5.js +0 -1
- package/dist/assets/dql-notebook/assets/NotebookEditor-EZ0pfWVs.js +0 -200
- package/dist/assets/dql-notebook/assets/ReadinessPage-BaGvjyfd.js +0 -1
- package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-BlWAVEwO.js +0 -83
- package/dist/assets/dql-notebook/assets/index-BTuliKhK.js +0 -634
- package/dist/assets/dql-notebook/assets/usePersistedAgentThreadId-CkVFrrjk.js +0 -18
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{c as Ve,u as fe,t as we,r as d,a as D,j as e,a4 as se,a0 as ye,L as _,S as ne,P as J,B as Ye,d as Oe,T as ie,$ as We,a5 as Je,Q as de,N as Ie,l as Xe,aU as Le,f as Ze}from"./index-1mIC_XX4.js";import{T as Ne}from"./triangle-alert-2ZXx8wAu.js";import{U as Te,G as re}from"./user-round-BA074kiQ.js";import{C as He}from"./chevron-up-HxU1l85K.js";import{P as _e}from"./pencil-D_I14Wyk.js";import{X as me}from"./x-CSo1M3tu.js";/**
|
|
2
|
+
* @license lucide-react v0.563.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const et=[["path",{d:"M13.172 2a2 2 0 0 1 1.414.586l6.71 6.71a2.4 2.4 0 0 1 0 3.408l-4.592 4.592a2.4 2.4 0 0 1-3.408 0l-6.71-6.71A2 2 0 0 1 6 9.172V3a1 1 0 0 1 1-1z",key:"16rjxf"}],["path",{d:"M2 7v6.172a2 2 0 0 0 .586 1.414l6.71 6.71a2.4 2.4 0 0 0 3.191.193",key:"178nd4"}],["circle",{cx:"10.5",cy:"6.5",r:".5",fill:"currentColor",key:"12ikhr"}]],tt=Ve("tags",et),le="dql-context-bootstrap-session",ae="dql-context-bootstrap-selection";function nt(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").slice(0,64)}function $e(t){return t.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64)}function it(){return{id:"",name:"",owner:"",boundedContext:"",sourceSystems:[],description:""}}function st({embedded:t=!1}={}){const{state:n,dispatch:r}=fe(),i=we[n.themeMode],[l,a]=d.useState([]),[o,s]=d.useState(!0),[x,S]=d.useState(null),[v,c]=d.useState(null),[I,b]=d.useState(null),[h,u]=d.useState(!1),[R,T]=d.useState(null),[j,M]=d.useState(null),[y,k]=d.useState(!1),[E,L]=d.useState(!1),[O,A]=d.useState(null),[m,p]=d.useState([]),B=d.useCallback(()=>{let g=!1;return s(!0),S(null),D.getDomains().then(C=>{if(g)return;const W=Array.isArray(C==null?void 0:C.domains)?C.domains:[];a(W),r({type:"SET_AUTHORED_DOMAINS",domains:W})}).catch(C=>{g||(a([]),S(C instanceof Error&&C.message?C.message:"Could not load domains. Is the local DQL server running?"))}).finally(()=>{g||s(!1)}),()=>{g=!0}},[r]);d.useEffect(()=>B(),[B]),d.useEffect(()=>{const g=window.sessionStorage.getItem(le);let C=!1;const W=$=>{if($&&!C){M($);try{const f=JSON.parse(window.sessionStorage.getItem(ae)??"[]");p(Array.isArray(f)?f.filter(w=>typeof w=="string"):$.candidates.filter(w=>w.action!=="unchanged").map(w=>w.id))}catch{p($.candidates.filter(f=>f.action!=="unchanged").map(f=>f.id))}}};return(g?D.getContextBootstrap(g):D.getLatestContextBootstrap()).then(W).catch(async()=>{window.sessionStorage.removeItem(le),window.sessionStorage.removeItem(ae),g&&W(await D.getLatestContextBootstrap().catch(()=>null))}),()=>{C=!0}},[]),d.useEffect(()=>{j&&(window.sessionStorage.setItem(le,j.id),window.sessionStorage.setItem(ae,JSON.stringify(m)))},[j==null?void 0:j.id,m]);const N=d.useMemo(()=>[...l].sort((g,C)=>g.name.localeCompare(C.name)),[l]),z=d.useCallback(g=>{a(C=>{const W=C.findIndex($=>$.id===g.id),P=W===-1?[...C,g]:[...C];return W!==-1&&(P[W]=g),r({type:"SET_AUTHORED_DOMAINS",domains:P}),P}),c(null)},[r]),Z=d.useCallback(async()=>{if(I){u(!0),T(null);try{await D.deleteDomain(I.id),a(g=>{const C=g.filter(W=>W.id!==I.id);return r({type:"SET_AUTHORED_DOMAINS",domains:C}),C}),b(null)}catch(g){T(g instanceof Error&&g.message?g.message:"Could not delete this domain.")}finally{u(!1)}}},[r,I]),G=d.useCallback(async()=>{k(!0),A(null);try{const g=await D.startContextBootstrap({ai:!0});M(g);const C=g.candidates.filter(W=>W.action!=="unchanged").map(W=>W.id);p(C),window.sessionStorage.setItem(le,g.id),window.sessionStorage.setItem(ae,JSON.stringify(C))}catch(g){A(g instanceof Error?g.message:"Could not draft repository context.")}finally{k(!1)}},[]);d.useEffect(()=>{if(!t)return;const g=()=>{G()};return window.addEventListener("dql:context-build",g),()=>window.removeEventListener("dql:context-build",g)},[t,G]),d.useEffect(()=>{if(!j||["ready","needs_attention"].includes(j.status))return;let g=!1;const C=async()=>{try{const P=await D.getContextBootstrap(j.id);g||M(P)}catch(P){g||A(P instanceof Error?P.message:"Could not update AI draft progress.")}};C();const W=window.setInterval(()=>void C(),750);return()=>{g=!0,window.clearInterval(W)}},[j==null?void 0:j.id,j==null?void 0:j.status]);const F=d.useCallback(async()=>{if(!(!j||m.length===0)){L(!0),A(null);try{await D.saveContextBootstrapSelected(j.id,m),M(null),p([]),window.sessionStorage.removeItem(le),window.sessionStorage.removeItem(ae),B()}catch(g){A(g instanceof Error?g.message:"Could not save selected drafts.")}finally{L(!1)}}},[j,m,B]);return e.jsxs("div",{style:{flex:1,minWidth:0,overflow:"auto",background:i.appBg},children:[e.jsxs("div",{style:{maxWidth:980,margin:"0 auto",padding:"22px 28px 40px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-end",justifyContent:"space-between",gap:18,marginBottom:18},children:[e.jsxs("div",{style:{minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9},children:[e.jsx(se,{size:20,strokeWidth:1.9,color:i.accent}),e.jsx("div",{style:{fontSize:22,fontWeight:700,color:i.textPrimary},children:"Domains"})]}),e.jsx("div",{style:{fontSize:13,color:i.textMuted,marginTop:6,maxWidth:680,lineHeight:1.5},children:"Domains are the top of your business model — each one owns the terms, skills, and blocks beneath it. Name the business area, who owns it, the bounded context, and the source systems it draws from."})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[e.jsxs("button",{type:"button",onClick:()=>B(),title:"Refresh",style:X(i),children:[e.jsx(ye,{size:13,strokeWidth:2})," Refresh"]}),e.jsxs("button",{type:"button",onClick:()=>void G(),disabled:y,style:X(i),children:[y?e.jsx(_,{size:13,strokeWidth:2}):e.jsx(ne,{size:13,strokeWidth:2})," Draft with AI"]}),e.jsxs("button",{type:"button",onClick:()=>c({kind:"create"}),style:ue(i),children:[e.jsx(J,{size:14,strokeWidth:2.2})," Add domain"]})]})]}),o?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:i.textMuted,fontSize:13,padding:"40px 0"},children:[e.jsx(_,{size:15,strokeWidth:2})," Loading domains…"]}):x?e.jsx(at,{t:i,message:x,onRetry:()=>B()}):N.length===0?e.jsx(lt,{t:i,onAdd:()=>c({kind:"create"})}):e.jsx("div",{style:{display:"grid",gap:10},children:N.map(g=>e.jsx(rt,{domain:g,t:i,onEdit:()=>c({kind:"edit",domain:g}),onDelete:()=>{T(null),b(g)}},g.id))}),O?e.jsx("div",{style:{marginTop:12},children:e.jsx(pe,{t:i,tone:"error",children:O})}):null,j?e.jsxs("section",{style:{marginTop:18,border:`1px solid ${i.cellBorder}`,borderRadius:10,background:i.cellBg,padding:14},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,alignItems:"center",flexWrap:"wrap"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13,fontWeight:750,color:i.textPrimary},children:"Repository-guided AI draft"}),e.jsx("div",{style:{fontSize:12,color:i.textMuted,marginTop:3},children:"Inventory is deterministic; AI may enrich only grounded prose and guidance. Nothing is written to Git until you save."})]}),e.jsxs("button",{type:"button",disabled:E||m.length===0||!["ready","needs_attention"].includes(j.status),onClick:()=>void F(),style:{...ue(i),opacity:E||m.length===0||!["ready","needs_attention"].includes(j.status)?.55:1},children:[E?e.jsx(_,{size:13,strokeWidth:2}):e.jsx(J,{size:13,strokeWidth:2})," Save selected drafts"]})]}),e.jsx(dt,{t:i,session:j}),e.jsx("div",{style:{display:"grid",gap:9,marginTop:12},children:j.candidates.map(g=>{const C=g.action!=="unchanged",W=m.includes(g.id);return e.jsx(ct,{candidate:g,selected:W,selectable:C,disabled:E,t:i,onToggle:()=>p(P=>W?P.filter($=>$!==g.id):[...P,g.id])},g.id)})})]}):null]}),v?e.jsx(ot,{mode:v,existingIds:l.map(g=>g.id),domains:l,t:i,onClose:()=>c(null),onSaved:z}):null,I?e.jsx(pt,{domain:I,t:i,deleting:h,error:R,onCancel:()=>{h||b(null)},onConfirm:Z}):null]})}function rt({domain:t,t:n,onEdit:r,onDelete:i}){const l=t.sourceSystems??[],[a,o]=d.useState(!1);return e.jsxs("section",{style:{border:`1px solid ${n.cellBorder}`,borderRadius:10,background:n.cellBg,padding:"13px 15px",display:"flex",alignItems:"flex-start",gap:14},children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:13.5,fontWeight:750,color:n.textPrimary},children:t.name}),t.parent?e.jsxs("span",{style:Se(n),children:["↳ ",t.parent]}):null,t.owner?e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,color:n.textMuted},children:[e.jsx(Te,{size:11,strokeWidth:2})," ",t.owner]}):null,t.businessOwner?e.jsxs("span",{style:Se(n),children:[e.jsx(Te,{size:10,strokeWidth:2.2})," Business owner: ",t.businessOwner]}):null]}),t.description?e.jsx("div",{style:{fontSize:12.5,color:n.textSecondary,marginTop:5,lineHeight:1.5},children:t.description}):e.jsx("div",{style:{fontSize:12,color:n.textMuted,marginTop:5,fontStyle:"italic"},children:"No description yet."}),l.length>0?e.jsx("div",{style:{display:"flex",gap:5,marginTop:9,flexWrap:"wrap"},children:l.map(s=>e.jsx("span",{style:Ce(n),children:s},s))}):null,e.jsxs("div",{style:{display:"flex",gap:7,marginTop:9,flexWrap:"wrap"},children:[e.jsx(je,{t:n,icon:e.jsx(Ye,{size:11,strokeWidth:2}),label:"blocks",count:t.blockCount??0}),e.jsx(je,{t:n,icon:e.jsx(re,{size:11,strokeWidth:2}),label:"skills",count:t.skillCount??0}),e.jsx(je,{t:n,icon:e.jsx(tt,{size:11,strokeWidth:2}),label:"terms",count:t.termCount??0})]}),a?e.jsxs("div",{style:{display:"grid",gap:9,marginTop:12,paddingTop:11,borderTop:`1px solid ${n.btnBorder}`},children:[t.boundedContext?e.jsx(De,{t:n,label:"Business boundary",children:t.boundedContext}):null,t.businessOutcome?e.jsx(De,{t:n,label:"Decision outcome",children:t.businessOutcome}):null,e.jsx(ce,{t:n,label:"In scope",values:t.inScope,empty:"Not defined yet"}),e.jsx(ce,{t:n,label:"Out of scope",values:t.outOfScope,empty:"Not defined yet"}),e.jsx(ce,{t:n,label:"Primary terms",values:t.primaryTerms,empty:"No terms linked yet"}),e.jsx(ce,{t:n,label:"Tags",values:t.tags,empty:"No tags"})]}):null]}),e.jsxs("div",{style:{display:"flex",gap:6,flexShrink:0},children:[e.jsxs("button",{type:"button",onClick:()=>o(s=>!s),style:{...X(n),padding:"5px 7px",fontSize:11.5},title:a?"Hide domain details":"Show domain details",children:[a?e.jsx(He,{size:13}):e.jsx(Oe,{size:13}),a?"Less":"Details"]}),e.jsx("button",{type:"button",onClick:r,style:ke(n),title:"Edit domain",children:e.jsx(_e,{size:13,strokeWidth:2})}),e.jsx("button",{type:"button",onClick:i,style:ke(n),title:"Delete domain",children:e.jsx(ie,{size:13,strokeWidth:2})})]})]})}function ot({mode:t,existingIds:n,domains:r,t:i,onClose:l,onSaved:a}){const o=t.kind==="edit",[s,x]=d.useState(()=>t.kind==="edit"?{...t.domain}:it()),[S,v]=d.useState(o),[c,I]=d.useState(!1),[b,h]=d.useState(null),u=d.useCallback((y,k)=>{x(E=>({...E,[y]:k}))},[]),R=y=>{x(k=>({...k,name:y,...!o&&!S?{id:$e(y)}:{}}))},T=!o&&s.id.length>0&&n.includes(s.id),j=s.id.trim().length>0&&s.name.trim().length>0&&!T&&!c,M=d.useCallback(async()=>{var k,E,L,O,A;const y={...s,id:s.id.trim(),name:s.name.trim(),owner:(k=s.owner)!=null&&k.trim()?s.owner.trim():void 0,businessOwner:(E=s.businessOwner)!=null&&E.trim()?s.businessOwner.trim():void 0,parent:(L=s.parent)!=null&&L.trim()?s.parent.trim():void 0,boundedContext:(O=s.boundedContext)!=null&&O.trim()?s.boundedContext.trim():void 0,description:(A=s.description)!=null&&A.trim()?s.description.trim():void 0,sourceSystems:(s.sourceSystems??[]).map(m=>m.trim()).filter(Boolean),primaryTerms:(s.primaryTerms??[]).map(m=>m.trim()).filter(Boolean),tags:(s.tags??[]).map(m=>m.trim()).filter(Boolean),inScope:(s.inScope??[]).map(m=>m.trim()).filter(Boolean),outOfScope:(s.outOfScope??[]).map(m=>m.trim()).filter(Boolean),dbtGroups:(s.dbtGroups??[]).map(m=>m.trim()).filter(Boolean),dbtPaths:(s.dbtPaths??[]).map(m=>m.trim()).filter(Boolean),dbtTags:(s.dbtTags??[]).map(m=>m.trim()).filter(Boolean),semanticDomains:(s.semanticDomains??[]).map(m=>m.trim()).filter(Boolean),semanticTags:(s.semanticTags??[]).map(m=>m.trim()).filter(Boolean)};I(!0),h(null);try{const m=o?await D.updateDomain(y.id,y):await D.createDomain(y);a(m.domain??y)}catch(m){h(m instanceof Error&&m.message?m.message:"Could not save this domain. Try again.")}finally{I(!1)}},[s,o,a]);return e.jsx("div",{style:ft,onClick:()=>!c&&l(),children:e.jsxs("div",{style:yt(i),onClick:y=>y.stopPropagation(),children:[e.jsxs("div",{style:mt(i),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(se,{size:16,strokeWidth:2,color:i.accent}),e.jsx("div",{style:{fontSize:15,fontWeight:700,color:i.textPrimary},children:o?"Edit domain":"New domain"})]}),e.jsx("button",{type:"button",onClick:()=>!c&&l(),style:ke(i),title:"Close",children:e.jsx(me,{size:15,strokeWidth:2})})]}),e.jsxs("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:"16px 18px",display:"grid",gap:16},children:[e.jsx(K,{label:"Name",t:i,hint:o?void 0:"A short, human label for this business area.",children:e.jsx("input",{type:"text",value:s.name,onChange:y=>R(y.target.value),placeholder:"Revenue",style:Q(i)})}),e.jsxs(K,{label:"ID (slug)",t:i,hint:"Used as the on-disk identifier. Letters, numbers, and dashes.",children:[e.jsx("input",{type:"text",value:s.id,disabled:o,onChange:y=>{v(!0),u("id",nt(y.target.value))},onBlur:()=>u("id",$e(s.id)),placeholder:"revenue",style:{...Q(i),fontFamily:i.fontMono,opacity:o?.7:1}}),T?e.jsx(pe,{t:i,tone:"error",children:"A domain with this id already exists."}):null]}),e.jsx(K,{label:"Parent domain",t:i,hint:"Optional. Depth becomes Domain, Subdomain, Microdomain, and beyond.",children:e.jsxs("select",{value:s.parent??"",onChange:y=>u("parent",y.target.value||void 0),style:Q(i),children:[e.jsx("option",{value:"",children:"Top-level domain"}),r.filter(y=>y.id!==s.id).map(y=>e.jsx("option",{value:y.id,children:y.name},y.id))]})}),e.jsx(K,{label:"Owner",t:i,hint:"The team or person accountable for this domain.",children:e.jsx("input",{type:"text",value:s.owner??"",onChange:y=>u("owner",y.target.value),placeholder:"finance-analytics",style:Q(i)})}),e.jsx(K,{label:"Business owner",t:i,hint:"The stakeholder accountable for business use and definitions.",children:e.jsx("input",{type:"text",value:s.businessOwner??"",onChange:y=>u("businessOwner",y.target.value),placeholder:"Revenue Operations",style:Q(i)})}),e.jsx(K,{label:"Bounded context",t:i,hint:"The conceptual boundary this domain owns, e.g. 'recognized revenue and invoicing'.",children:e.jsx("input",{type:"text",value:s.boundedContext??"",onChange:y=>u("boundedContext",y.target.value),placeholder:"Recognized revenue and invoicing",style:Q(i)})}),e.jsx(K,{label:"Source systems",t:i,hint:"The upstream systems this domain draws from — type a name and press Enter.",children:e.jsx(be,{t:i,values:s.sourceSystems??[],onChange:y=>u("sourceSystems",y),placeholder:"Add a source system…"})}),e.jsx(K,{label:"Primary terms",t:i,hint:"Business concepts the agent should use to recognize this domain.",children:e.jsx(be,{t:i,values:s.primaryTerms??[],onChange:y=>u("primaryTerms",y),placeholder:"Add a term…"})}),e.jsx(K,{label:"Scope tags",t:i,hint:"Short labels used for routing and discovery.",children:e.jsx(be,{t:i,values:s.tags??[],onChange:y=>u("tags",y),placeholder:"Add a tag…"})}),e.jsx(K,{label:"Description",t:i,hint:"What this domain covers and how it's used.",children:e.jsx("textarea",{value:s.description??"",onChange:y=>u("description",y.target.value),rows:5,placeholder:"All recognized-revenue metrics and the blocks that report them, sourced from the billing warehouse.",style:xt(i)})}),b?e.jsx(pe,{t:i,tone:"error",children:b}):null]}),e.jsxs("div",{style:bt(i),children:[e.jsx("button",{type:"button",onClick:()=>!c&&l(),style:X(i),children:"Cancel"}),e.jsxs("button",{type:"button",onClick:M,disabled:!j,style:{...ue(i),opacity:j?1:.55},children:[c?e.jsx(_,{size:13,strokeWidth:2}):null,c?"Saving…":o?"Save changes":"Create domain"]})]})]})})}function be({t,values:n,onChange:r,placeholder:i}){const[l,a]=d.useState(""),o=s=>{const x=s.trim();!x||n.includes(x)||(r([...n,x]),a(""))};return e.jsxs("div",{style:{display:"grid",gap:7},children:[n.length>0?e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:5},children:n.map(s=>e.jsxs("span",{style:gt(t),children:[s,e.jsx("button",{type:"button",onClick:()=>r(n.filter(x=>x!==s)),style:ht(t),title:"Remove",children:e.jsx(me,{size:11,strokeWidth:2.4})})]},s))}):null,e.jsx("input",{type:"text",value:l,onChange:s=>a(s.target.value),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),o(l))},placeholder:i,style:Q(t)})]})}function lt({t,onAdd:n}){return e.jsxs("div",{style:{border:`1px dashed ${t.cellBorder}`,borderRadius:12,background:t.cellBg,padding:"34px 28px",textAlign:"center",display:"grid",gap:12,justifyItems:"center"},children:[e.jsx("div",{style:{width:44,height:44,borderRadius:10,background:`${t.accent}18`,color:t.accent,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(se,{size:22,strokeWidth:1.9})}),e.jsx("div",{style:{fontSize:15,fontWeight:700,color:t.textPrimary},children:"Name your business domains"}),e.jsx("div",{style:{fontSize:13,color:t.textMuted,maxWidth:460,lineHeight:1.55},children:`Domains organize everything below them — terms, skills, and blocks. Add your first one, like "Revenue" or "Customer", and you'll be able to pick it when authoring blocks and skills.`}),e.jsxs("button",{type:"button",onClick:n,style:{...ue(t),marginTop:4},children:[e.jsx(J,{size:14,strokeWidth:2.2})," Add your first domain"]})]})}function at({t,message:n,onRetry:r}){return e.jsxs("div",{style:{border:`1px solid ${t.warning}55`,borderRadius:10,background:`${t.warning}12`,padding:"16px 18px",display:"flex",alignItems:"flex-start",gap:11},children:[e.jsx(Ne,{size:16,strokeWidth:2,color:t.warning,style:{marginTop:1,flexShrink:0}}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:13,fontWeight:650,color:t.textPrimary},children:"Domains are not available right now"}),e.jsx("div",{style:{fontSize:12.5,color:t.textSecondary,marginTop:4,lineHeight:1.5},children:n}),e.jsxs("button",{type:"button",onClick:r,style:{...X(t),marginTop:10},children:[e.jsx(ye,{size:13,strokeWidth:2})," Retry"]})]})]})}function dt({t,session:n}){var l;const r=!["ready","needs_attention"].includes(n.status),i=n.ai.mode==="evidence_only"?"Evidence-only":n.ai.provider?`${n.ai.provider} grounded`:"Preparing AI";return e.jsxs("div",{style:{marginTop:14,padding:"10px 11px",borderRadius:8,background:t.appBg,border:`1px solid ${t.btnBorder}`},children:[e.jsxs("div",{style:{display:"flex",gap:9,alignItems:"center",flexWrap:"wrap",fontSize:12,color:t.textSecondary},children:[r?e.jsx(_,{size:14,strokeWidth:2,color:t.accent}):e.jsx(ne,{size:14,strokeWidth:2,color:t.accent}),e.jsx("strong",{style:{color:t.textPrimary,textTransform:"capitalize"},children:n.status.replace("_"," ")}),e.jsx("span",{children:i}),e.jsxs("span",{children:[n.progress.domains.ready,"/",n.progress.domains.total," domains"]}),e.jsxs("span",{children:[n.progress.skills.ready,"/",n.progress.skills.total," skills"]})]}),e.jsx("div",{style:{height:5,borderRadius:999,background:t.btnBg,overflow:"hidden",marginTop:9},children:e.jsx("div",{style:{width:`${Math.max(3,Math.min(100,n.progress.percent))}%`,height:"100%",background:t.accent,transition:"width 260ms ease"}})}),e.jsx("div",{style:{marginTop:7,fontSize:11.5,color:t.textMuted,lineHeight:1.45},children:n.progress.message}),(l=n.warnings)!=null&&l.length?e.jsx("div",{style:{marginTop:7,fontSize:11.5,color:t.warning,lineHeight:1.45},children:n.warnings.slice(-2).join(" ")}):null]})}function ct({candidate:t,selected:n,selectable:r,disabled:i,t:l,onToggle:a}){var I,b,h,u,R,T,j,M,y,k,E,L,O,A,m,p,B,N,z,Z,G,F,g,C,W,P;const[o,s]=d.useState(!1),x=t.kind==="domain",S=((I=t.domain)==null?void 0:I.name)??((b=t.skill)==null?void 0:b.id)??t.id.replace(/^(domain|skill):/,""),v=x?((h=t.domain)==null?void 0:h.description)??((u=t.domain)==null?void 0:u.boundedContext):((R=t.skill)==null?void 0:R.description)??((j=(T=t.skill)==null?void 0:T.body)==null?void 0:j.split(`
|
|
7
|
+
`).find(Boolean)),c=x?[["Business outcome",(M=t.domain)==null?void 0:M.businessOutcome],["In scope",(k=(y=t.domain)==null?void 0:y.inScope)==null?void 0:k.join(" · ")],["Out of scope",(L=(E=t.domain)==null?void 0:E.outOfScope)==null?void 0:L.join(" · ")],["Primary terms",(A=(O=t.domain)==null?void 0:O.primaryTerms)==null?void 0:A.join(" · ")]]:[["Applies when",(p=(m=t.skill)==null?void 0:m.triggers)==null?void 0:p.join(" · ")],["Ask first when",(N=(B=t.skill)==null?void 0:B.clarifyWhen)==null?void 0:N.join(" · ")],["Avoid when",(Z=(z=t.skill)==null?void 0:z.exclusions)==null?void 0:Z.join(" · ")],["Preferred metrics",(F=(G=t.skill)==null?void 0:G.preferredMetrics)==null?void 0:F.join(" · ")],["Preferred blocks",(C=(g=t.skill)==null?void 0:g.preferredBlocks)==null?void 0:C.join(" · ")]];return e.jsx("article",{style:{border:`1px solid ${n?`${l.accent}66`:l.btnBorder}`,background:n?`${l.accent}08`:l.appBg,borderRadius:8,padding:"10px 11px",opacity:r?1:.72},children:e.jsxs("div",{style:{display:"flex",gap:9,alignItems:"flex-start"},children:[e.jsx("input",{"aria-label":`Select ${x?"domain":"skill"} ${S}`,type:"checkbox",disabled:!r||i,checked:n,onChange:a,style:{marginTop:3}}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",gap:7,alignItems:"center",flexWrap:"wrap"},children:[e.jsxs("strong",{style:{color:l.textPrimary,fontSize:12.5},children:[x?"Domain":"Skill"," · ",S]}),e.jsx("span",{style:Se(l),children:t.action.replace("_"," ")}),e.jsxs("span",{style:{fontSize:11,color:l.textMuted},children:[Math.round(t.confidence*100),"% evidence confidence"]})]}),v?e.jsx("p",{style:{marginTop:5,color:l.textSecondary,fontSize:12,lineHeight:1.45},children:v}):e.jsx("p",{style:{marginTop:5,color:l.textMuted,fontSize:12,fontStyle:"italic"},children:"Waiting for grounded guidance…"}),e.jsx("div",{style:{display:"flex",gap:5,marginTop:7,flexWrap:"wrap"},children:t.evidence.map($=>e.jsx("span",{style:Ce(l),children:$},$))}),o?e.jsxs("div",{style:{marginTop:9,display:"grid",gap:6,borderTop:`1px solid ${l.btnBorder}`,paddingTop:9},children:[c.filter(([,$])=>!!$).map(([$,f])=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"116px minmax(0, 1fr)",gap:8,fontSize:11.5,lineHeight:1.45},children:[e.jsx("strong",{style:{color:l.textMuted},children:$}),e.jsx("span",{style:{color:l.textSecondary},children:f})]},$)),!x&&((W=t.skill)!=null&&W.body)?e.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap",fontFamily:l.font,fontSize:11.5,color:l.textSecondary,background:l.cellBg,padding:9,borderRadius:6,maxHeight:180,overflow:"auto"},children:t.skill.body}):null,(P=t.notes)!=null&&P.length?e.jsx("div",{style:{fontSize:11.5,color:l.accent},children:t.notes.join(" ")}):null]}):null]}),e.jsxs("button",{type:"button",onClick:()=>s($=>!$),style:{...X(l),padding:"4px 6px",fontSize:11.5},"aria-expanded":o,children:[o?e.jsx(He,{size:13}):e.jsx(Oe,{size:13}),o?"Less":"Review"]})]})})}function pt({domain:t,t:n,deleting:r,error:i,onCancel:l,onConfirm:a}){return e.jsx("div",{style:jt,onClick:l,children:e.jsxs("div",{style:vt(n),onClick:o=>o.stopPropagation(),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9},children:[e.jsx(ie,{size:16,strokeWidth:2,color:n.error}),e.jsx("div",{style:{fontSize:15,fontWeight:700,color:n.textPrimary},children:"Delete this domain?"})]}),e.jsxs("div",{style:{fontSize:13,color:n.textSecondary,lineHeight:1.55},children:[e.jsx("span",{style:{fontWeight:700,color:n.textPrimary},children:t.name})," will be removed. Blocks, skills, and terms that referenced it will become unassigned. This can't be undone."]}),i?e.jsx(pe,{t:n,tone:"error",children:i}):null,e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[e.jsx("button",{type:"button",onClick:l,disabled:r,style:X(n),children:"Cancel"}),e.jsxs("button",{type:"button",onClick:a,disabled:r,style:{...ut(n),opacity:r?.6:1},children:[r?e.jsx(_,{size:13,strokeWidth:2}):e.jsx(ie,{size:13,strokeWidth:2}),r?"Deleting…":"Delete"]})]})]})})}function je({t,icon:n,label:r,count:i}){return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:11,fontWeight:600,color:i>0?t.textSecondary:t.textMuted,background:t.btnBg,border:`1px solid ${t.btnBorder}`,borderRadius:6,padding:"3px 8px"},children:[n,i," ",r]})}function De({t,label:n,children:r}){return e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"118px minmax(0, 1fr)",gap:10,fontSize:12,lineHeight:1.5},children:[e.jsx("strong",{style:{color:t.textMuted},children:n}),e.jsx("span",{style:{color:t.textSecondary},children:r})]})}function ce({t,label:n,values:r,empty:i}){return e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"118px minmax(0, 1fr)",gap:10,fontSize:12,lineHeight:1.5},children:[e.jsx("strong",{style:{color:t.textMuted},children:n}),e.jsx("div",{style:{display:"flex",gap:5,flexWrap:"wrap"},children:r!=null&&r.length?r.map(l=>e.jsx("span",{style:Ce(t),children:l},l)):e.jsx("span",{style:{color:t.textMuted,fontStyle:"italic"},children:i})})]})}function K({label:t,hint:n,t:r,children:i}){return e.jsxs("div",{style:{display:"grid",gap:6},children:[e.jsx("label",{style:{fontSize:12,fontWeight:700,color:r.textPrimary},children:t}),n?e.jsx("div",{style:{fontSize:11.5,color:r.textMuted,lineHeight:1.45,marginTop:-2},children:n}):null,i]})}function pe({t,tone:n,children:r}){const i=n==="error"?t.error:t.textMuted;return e.jsx("div",{style:{fontSize:11.5,color:i,lineHeight:1.45},children:r})}function ue(t){return{display:"inline-flex",alignItems:"center",gap:6,padding:"7px 13px",borderRadius:7,border:`1px solid ${t.accent}`,background:t.accent,color:"#ffffff",fontSize:12.5,fontWeight:700,fontFamily:t.font,cursor:"pointer"}}function X(t){return{display:"inline-flex",alignItems:"center",gap:5,padding:"7px 11px",borderRadius:7,border:`1px solid ${t.btnBorder}`,background:t.btnBg,color:t.textSecondary,fontSize:12,fontWeight:600,fontFamily:t.font,cursor:"pointer"}}function ut(t){return{display:"inline-flex",alignItems:"center",gap:6,padding:"7px 13px",borderRadius:7,border:`1px solid ${t.error}`,background:t.error,color:"#ffffff",fontSize:12.5,fontWeight:700,fontFamily:t.font,cursor:"pointer"}}function ke(t){return{display:"inline-flex",alignItems:"center",justifyContent:"center",width:30,height:30,borderRadius:7,border:`1px solid ${t.btnBorder}`,background:t.btnBg,color:t.textSecondary,cursor:"pointer",flexShrink:0}}function Q(t){return{width:"100%",border:`1px solid ${t.btnBorder}`,borderRadius:7,background:t.cellBg,color:t.textPrimary,fontSize:12.5,fontFamily:t.font,padding:"8px 10px",boxSizing:"border-box"}}function xt(t){return{...Q(t),resize:"vertical",lineHeight:1.5,padding:"9px 11px"}}function Se(t){return{display:"inline-flex",alignItems:"center",gap:4,fontSize:10.5,fontWeight:700,color:t.accent,background:`${t.accent}14`,border:`1px solid ${t.accent}38`,borderRadius:999,padding:"2px 8px"}}function Ce(t){return{fontSize:11,fontWeight:600,color:t.textSecondary,background:t.btnBg,border:`1px solid ${t.btnBorder}`,borderRadius:6,padding:"3px 8px",fontFamily:t.fontMono}}function gt(t){return{display:"inline-flex",alignItems:"center",gap:4,fontSize:11.5,fontWeight:600,color:t.textPrimary,background:`${t.accent}14`,border:`1px solid ${t.accent}38`,borderRadius:6,padding:"3px 4px 3px 9px",fontFamily:t.fontMono}}function ht(t){return{display:"inline-flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",color:t.textMuted,cursor:"pointer",padding:2,borderRadius:4}}const ft={position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.42)",display:"flex",justifyContent:"flex-end",zIndex:60};function yt(t){return{width:"min(560px, 100%)",height:"100%",background:t.appBg,borderLeft:`1px solid ${t.headerBorder}`,display:"flex",flexDirection:"column",boxShadow:"-8px 0 28px rgba(0,0,0,0.18)"}}function mt(t){return{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 18px",borderBottom:`1px solid ${t.headerBorder}`,flexShrink:0}}function bt(t){return{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8,padding:"13px 18px",borderTop:`1px solid ${t.headerBorder}`,flexShrink:0}}const jt={position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.42)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:70,padding:20};function vt(t){return{width:"min(420px, 100%)",background:t.cellBg,border:`1px solid ${t.cellBorder}`,borderRadius:12,padding:20,display:"grid",gap:13,boxShadow:"0 18px 48px rgba(0,0,0,0.3)"}}function kt(t,n,r){var a,o;if(n&&t.domain!==n&&!((a=t.domains)!=null&&a.includes(n)))return!1;const i=(o=r==null?void 0:r.split("::").at(-1))==null?void 0:o.toLowerCase();if(!i)return!0;const l=(t.modelAreaRefs??[]).map(s=>{var x;return(x=s.split("::").at(-1))==null?void 0:x.toLowerCase()});return l.length===0||l.includes(i)}function Re(t){return t.replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/+$/,"")}function St(t,n){if(!n)return!0;const r=Re(t.sourcePath);return n.some(i=>{const l=Re(i);return r===l||r.endsWith(`/${l}`)})}function wt(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").slice(0,64)}function Me(t){return t.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64)}function Ct(){return{id:"",scope:"project",description:"",body:"",preferredMetrics:[],preferredBlocks:[],vocabulary:{},sourcePath:""}}function zt({embedded:t=!1,domainFilter:n=null,modelAreaFilter:r=null,sourcePathFilter:i}={}){var $;const{state:l}=fe(),a=we[l.themeMode],[o,s]=d.useState([]),[x,S]=d.useState(!0),[v,c]=d.useState(null),[I,b]=d.useState({metrics:[],blocks:[]}),h=l.authoredDomains,[u,R]=d.useState(null),[T,j]=d.useState(!1),[M,y]=d.useState("skills"),[k,E]=d.useState(!1),[L,O]=d.useState(null),[A,m]=d.useState(null),[p,B]=d.useState(null),[N,z]=d.useState(!1),[Z,G]=d.useState(null),F=d.useCallback(()=>{let f=!1;return S(!0),c(null),D.getSkills().then(w=>{f||s(Array.isArray(w==null?void 0:w.skills)?w.skills:[])}).catch(w=>{f||(s([]),c(w instanceof Error&&w.message?w.message:"Could not load skills. Is the local DQL server running?"))}).finally(()=>{f||S(!1)}),D.getSkillOptions().then(w=>{f||b({metrics:Array.isArray(w==null?void 0:w.metrics)?w.metrics:[],blocks:Array.isArray(w==null?void 0:w.blocks)?w.blocks:[]})}).catch(()=>{f||b({metrics:[],blocks:[]})}),D.getSkillPathSettings().then(w=>{f||(R(w),y(w.path))}).catch(()=>{f||R(null)}),()=>{f=!0}},[]);d.useEffect(()=>F(),[F]);const g=d.useMemo(()=>o.filter(f=>kt(f,n,r)).filter(f=>St(f,i)).sort((f,w)=>f.id.localeCompare(w.id)),[o,n,r,i]),C=d.useCallback(f=>{s(w=>{const oe=w.findIndex(Be=>(Be.qualifiedId??Be.id)===(f.qualifiedId??f.id));if(oe===-1)return[...w,f];const ze=[...w];return ze[oe]=f,ze}),m(null)},[]),W=d.useCallback(async()=>{if(p){z(!0),G(null);try{const f=p.qualifiedId??p.id;await D.deleteSkill(f),s(w=>w.filter(oe=>(oe.qualifiedId??oe.id)!==f)),B(null)}catch(f){G(f instanceof Error&&f.message?f.message:"Could not delete this skill.")}finally{z(!1)}}},[p]),P=d.useCallback(async()=>{E(!0),O(null);try{const f=await D.updateSkillPath(M);R(f),y(f.path),j(!1),F()}catch(f){O(f instanceof Error&&f.message?f.message:"Could not use this Skills folder.")}finally{E(!1)}},[F,M]);return e.jsxs("div",{style:{flex:1,minWidth:0,overflow:"auto",background:a.appBg},children:[e.jsxs("div",{style:{maxWidth:980,margin:"0 auto",padding:t?"18px 20px 40px":"22px 28px 40px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-end",justifyContent:"space-between",gap:18,marginBottom:18},children:[e.jsxs("div",{style:{minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9},children:[e.jsx(re,{size:20,strokeWidth:1.9,color:a.accent}),e.jsx("div",{style:{fontSize:t?18:22,fontWeight:700,color:a.textPrimary},children:r?`${($=r.split("::").at(-1))==null?void 0:$.replace(/_/g," ")} skills`:n?`${n} skills`:i?"Authored domain skills":"Skills"})]}),e.jsxs("div",{style:{fontSize:13,color:a.textMuted,marginTop:6,maxWidth:680,lineHeight:1.5},children:["Definitions, vocabulary, and instructions the AI follows when answering",r?" in this model area":n?" in this domain":i?" from authored domains":"",". Applied only when their triggers match — drafts never guide answers."]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginTop:7,color:a.textMuted,fontSize:10.5,minWidth:0},children:[e.jsx(We,{size:12,strokeWidth:1.8}),e.jsx("span",{children:"Skill folder"}),e.jsx("code",{style:{color:a.textSecondary,fontFamily:a.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(u==null?void 0:u.path)??"skills"}),u?e.jsxs("span",{children:["· ",u.exists?`${u.skillCount} loaded${i?` · ${g.length} shown here`:""}`:"not found"]}):null]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[e.jsxs("button",{type:"button",onClick:()=>F(),title:"Refresh",style:V(a),children:[e.jsx(ye,{size:13,strokeWidth:2})," Refresh"]}),e.jsxs("button",{type:"button",onClick:()=>{O(null),j(f=>!f)},style:V(a),children:[e.jsx(We,{size:13,strokeWidth:2})," Skill folder"]}),e.jsxs("button",{type:"button",onClick:()=>m({kind:"create"}),style:ge(a),children:[e.jsx(J,{size:14,strokeWidth:2.2})," Add skill"]})]})]}),T?e.jsxs("div",{style:{border:"1px solid var(--border-subtle)",borderRadius:10,background:a.cellBg,padding:"12px 14px",marginBottom:16,display:"grid",gap:8},children:[e.jsx("div",{style:{fontSize:12.5,fontWeight:700,color:a.textPrimary},children:"Use an existing Skills folder"}),e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[e.jsx("input",{"aria-label":"Existing Skills folder",value:M,onChange:f=>y(f.target.value),onKeyDown:f=>{f.key==="Enter"&&M.trim()&&!k&&P()},placeholder:"skills or ../skills",style:{...H(a),flex:1,fontFamily:a.fontMono}}),e.jsx("button",{type:"button",onClick:()=>j(!1),disabled:k,style:V(a),children:"Cancel"}),e.jsxs("button",{type:"button",onClick:()=>void P(),disabled:!M.trim()||k,style:{...ge(a),opacity:M.trim()&&!k?1:.55},children:[k?e.jsx(_,{size:13,strokeWidth:2}):null,k?"Connecting…":"Use folder"]})]}),e.jsxs("div",{style:{fontSize:10.5,lineHeight:1.45,color:a.textMuted},children:["Relative paths start from the DQL project. If DQL is in a ",e.jsx("code",{style:{fontFamily:a.fontMono},children:"/dql"})," folder inside your dbt repo, use ",e.jsx("code",{style:{fontFamily:a.fontMono},children:"../skills"}),". Existing ",e.jsx("code",{style:{fontFamily:a.fontMono},children:".skill.md"})," and Markdown skill files are loaded in place and stay Git-owned by that repo."]}),u!=null&&u.resolvedPath?e.jsxs("div",{style:{fontSize:10.5,color:a.textMuted,fontFamily:a.fontMono,overflowWrap:"anywhere"},children:["Resolved: ",u.resolvedPath]}):null,L?e.jsx(xe,{t:a,tone:"error",children:L}):null]}):null,x?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:a.textMuted,fontSize:13,padding:"40px 0"},children:[e.jsx(_,{size:15,strokeWidth:2})," Loading skills…"]}):v?e.jsx(Dt,{t:a,message:v,onRetry:()=>F()}):g.length===0?e.jsx($t,{t:a,onAdd:()=>m({kind:"create"})}):e.jsx("div",{style:{display:"grid",gap:10},children:g.map(f=>e.jsx(Bt,{skill:f,t:a,onEdit:()=>m({kind:"edit",skill:f}),onDelete:()=>{G(null),B(f)}},f.qualifiedId??f.id))})]}),A?e.jsx(Wt,{mode:A,options:I,domains:h,defaultDomain:n,defaultModelArea:r,existingIds:o.map(f=>f.id),t:a,onClose:()=>m(null),onSaved:C}):null,p?e.jsx(Rt,{skill:p,t:a,deleting:N,error:Z,onCancel:()=>{N||B(null)},onConfirm:W}):null]})}function Bt({skill:t,t:n,onEdit:r,onDelete:i}){var s,x,S;const[l,a]=d.useState(!1),o=(s=t.domains)!=null&&s.length?t.domains:t.domain?[t.domain]:[];return e.jsxs("section",{style:{border:"1px solid var(--border-subtle)",borderRadius:11,background:n.cellBg,overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,padding:"12px 14px"},children:[e.jsx("span",{style:{width:28,height:28,borderRadius:7,background:"var(--accent-dim)",color:n.accent,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(re,{size:14,strokeWidth:1.75})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:13,fontWeight:650,color:n.textPrimary,fontFamily:n.fontMono},children:t.id}),t.status==="draft"?e.jsx("span",{style:Ee(n),children:"draft — inactive"}):null,t.status==="active"||!t.status?e.jsx("span",{style:Mt(n),children:"active"}):null,o.map(v=>e.jsx("span",{style:Pt(n),children:v},v)),t.isStarter?e.jsxs("span",{style:Ee(n),title:"A dbt-seeded starter — edit it to make it yours",children:[e.jsx(ne,{size:10,strokeWidth:2.2})," starter — edit me"]}):null]}),e.jsx("div",{style:{fontSize:12,color:t.description?n.textSecondary:n.textMuted,fontStyle:t.description?void 0:"italic",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.description||"No description yet."}),e.jsx("div",{title:t.sourcePath,style:{marginTop:3,color:n.textMuted,fontSize:10,fontFamily:n.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.sourcePath})]}),e.jsx("button",{type:"button",onClick:()=>a(v=>!v),style:{...V(n),height:26,padding:"0 10px",fontSize:11},title:l?"Hide skill details":"Show skill details",children:l?"Hide details":"Details"}),e.jsx("button",{type:"button",onClick:r,style:{...he(n),width:26,height:26},title:"Edit skill",children:e.jsx(_e,{size:12,strokeWidth:1.75})}),e.jsx("button",{type:"button",onClick:i,style:{...he(n),width:26,height:26},title:"Delete skill",children:e.jsx(ie,{size:12,strokeWidth:1.75})})]}),l?e.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle)",padding:"12px 14px",display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px 20px"},children:[e.jsx(ee,{t:n,label:"Apply when",values:t.triggers,empty:"No trigger phrases defined"}),e.jsx(ee,{t:n,label:"Prefer these metrics",values:t.preferredMetrics,empty:"No preferred metrics",accent:!0,mono:!0}),e.jsx(ee,{t:n,label:"Reuse these blocks",values:t.preferredBlocks,empty:"No preferred blocks",accent:!0,mono:!0}),e.jsx(ee,{t:n,label:"Ask first when",values:t.clarifyWhen,empty:"No clarification rule defined"}),(x=t.exclusions)!=null&&x.length?e.jsx(ee,{t:n,label:"Avoid when",values:t.exclusions,empty:""}):null,(S=t.modelAreaRefs)!=null&&S.length?e.jsx(ee,{t:n,label:"Focus on model areas",values:t.modelAreaRefs,empty:"",mono:!0}):null,t.body?e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("div",{style:te(n),children:"Guidance"}),e.jsx("div",{style:{fontSize:12,lineHeight:1.6,color:n.textSecondary,background:"var(--bg-1)",border:"1px solid var(--border-subtle)",borderRadius:8,padding:"10px 12px",whiteSpace:"pre-wrap",maxHeight:220,overflow:"auto"},children:t.body})]}):null]}):null]})}function Wt({mode:t,options:n,domains:r,defaultDomain:i=null,defaultModelArea:l=null,existingIds:a,t:o,onClose:s,onSaved:x}){const{dispatch:S}=fe(),v=t.kind==="edit",[c,I]=d.useState(()=>t.kind==="edit"?{...t.skill}:{...Ct(),domain:i??void 0,domains:i?[i]:[],modelAreaRefs:l?[l]:[]}),[b,h]=d.useState(v),[u,R]=d.useState(()=>t.kind==="edit"?t.skill.id:""),[T,j]=d.useState(!1),[M,y]=d.useState(null),k=d.useCallback((p,B)=>{I(N=>({...N,[p]:B}))},[]),E=p=>{R(p),!v&&!b&&k("id",Me(p))},L=!v&&c.id.length>0&&a.includes(c.id),O=c.id.trim().length>0&&c.body.trim().length>0&&!L&&!T,A=Je(c.domain,r),m=d.useCallback(async()=>{var B,N;const p={...c,id:c.id.trim(),description:(B=c.description)!=null&&B.trim()?c.description.trim():void 0,body:c.body,domain:(N=c.domain)!=null&&N.trim()?c.domain.trim():void 0,domains:(c.domains??(c.domain?[c.domain]:[])).map(z=>z.trim()).filter(Boolean),modelAreaRefs:(c.modelAreaRefs??[]).map(z=>z.trim()).filter(Boolean),triggers:(c.triggers??[]).map(z=>z.trim()).filter(Boolean),exclusions:(c.exclusions??[]).map(z=>z.trim()).filter(Boolean),preferredDimensions:(c.preferredDimensions??[]).map(z=>z.trim()).filter(Boolean),requiredFilters:(c.requiredFilters??[]).map(z=>z.trim()).filter(Boolean),clarifyWhen:(c.clarifyWhen??[]).map(z=>z.trim()).filter(Boolean),examples:(c.examples??[]).map(z=>z.trim()).filter(Boolean)};j(!0),y(null);try{const z=v?await D.updateSkill(p.id,p):await D.createSkill(p);x(z.skill??p)}catch(z){y(z instanceof Error&&z.message?z.message:"Could not save this skill. Try again.")}finally{j(!1)}},[c,v,x]);return e.jsx("div",{style:Lt,onClick:()=>!T&&s(),children:e.jsxs("div",{style:Nt(o),onClick:p=>p.stopPropagation(),children:[e.jsxs("div",{style:Ht(),children:[e.jsx("span",{style:{width:30,height:30,borderRadius:8,background:"var(--accent-dim)",color:o.accent,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(re,{size:15,strokeWidth:1.75})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:14,fontWeight:700,color:o.textPrimary},children:v?"Edit skill":"New skill"}),e.jsx("div",{style:{fontSize:11,color:o.textMuted,marginTop:1},children:"Git-backed guidance · applied only when triggers match"})]}),e.jsx("button",{type:"button",onClick:()=>!T&&s(),style:{...he(o),width:26,height:26,border:"none",background:"none"},title:"Close",children:e.jsx(me,{size:14,strokeWidth:2})})]}),e.jsxs("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:"18px 22px",display:"grid",gridTemplateColumns:"1fr 1fr",gap:"20px 28px",alignContent:"start"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[e.jsx("div",{style:te(o),children:"Identity"}),e.jsxs("label",{style:U,children:[e.jsx("span",{style:q(o),children:"Name"}),e.jsx("input",{type:"text",value:u,onChange:p=>E(p.target.value),placeholder:"e.g. Revenue definition",style:H(o)}),e.jsxs("span",{style:{fontSize:10.5,color:o.textMuted},children:["Saved as"," ",e.jsx("input",{type:"text",value:`skills/${c.id}.skill.md`,disabled:v,onChange:p=>{h(!0),k("id",wt(p.target.value.replace(/^skills\//,"").replace(/\.skill\.md$/,"")))},onBlur:()=>k("id",Me(c.id)),title:"File name — letters, numbers, and dashes",style:{border:"none",background:"none",outline:"none",padding:0,fontFamily:o.fontMono,fontSize:10.5,color:o.textSecondary,width:`${Math.max(20,c.id.length+15)}ch`,borderBottom:v?"none":`1px dashed ${o.btnBorder}`}})]}),L?e.jsx(xe,{t:o,tone:"error",children:"A skill with this id already exists."}):null]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10},children:[e.jsxs("label",{style:U,children:[e.jsx("span",{style:q(o),children:"Domain"}),e.jsxs("select",{value:c.domain??"",onChange:p=>{const B=p.target.value||void 0;k("domain",B),k("domains",B?[B]:[])},style:{...H(o),cursor:"pointer",color:c.domain?o.textPrimary:o.textMuted},children:[e.jsx("option",{value:"",children:r.length===0?"No domains yet":"No domain"}),A.map(p=>e.jsx("option",{value:p.value,disabled:p.disabled,children:p.label},p.value))]})]}),e.jsxs("label",{style:U,children:[e.jsx("span",{style:q(o),children:"Type"}),e.jsxs("select",{value:c.kind??"custom",onChange:p=>k("kind",p.target.value),style:{...H(o),cursor:"pointer"},children:[e.jsx("option",{value:"custom",children:"Custom guidance"}),e.jsx("option",{value:"domain_reference",children:"Domain reference — broad context"}),e.jsx("option",{value:"metric_policy",children:"Policy — focused rule"}),e.jsx("option",{value:"glossary",children:"Glossary"}),e.jsx("option",{value:"analysis_pattern",children:"Analysis pattern"}),e.jsx("option",{value:"sql_policy",children:"SQL policy"})]})]})]}),e.jsx("button",{type:"button",onClick:()=>S({type:"SET_MAIN_VIEW",view:"domains"}),style:{border:"none",background:"none",padding:0,fontSize:10.5,color:o.accent,cursor:"pointer",fontFamily:o.font,alignSelf:"flex-start"},title:"Create a new domain on the Domains page",children:"+ New domain"}),e.jsxs("div",{children:[e.jsx("span",{style:{...q(o),display:"block",marginBottom:5},children:"Lifecycle"}),e.jsx("div",{style:{display:"inline-flex",alignItems:"center",gap:2,padding:2,border:`1px solid ${o.btnBorder}`,borderRadius:7,background:"var(--bg-1)"},children:["active","draft","deprecated"].map(p=>{const B=(c.status??"active")===p;return e.jsx("button",{type:"button",onClick:()=>k("status",p),style:{border:"none",borderRadius:5,padding:"4px 12px",fontSize:11.5,fontWeight:600,cursor:"pointer",fontFamily:o.font,background:B?o.cellBg:"transparent",color:B?o.textPrimary:o.textMuted,boxShadow:B?"0 1px 3px rgba(26,26,26,0.1)":"none",textTransform:"capitalize"},children:p},p)})}),e.jsx("span",{style:{fontSize:10.5,color:o.textMuted,marginLeft:8},children:(c.status??"active")==="active"?"Guides matching answers.":c.status==="draft"?"Drafts never guide answers.":"Kept in Git for history only."})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[e.jsx("div",{style:te(o),children:"When to apply"}),e.jsxs("label",{style:U,children:[e.jsx("span",{style:q(o),children:"Apply when the question mentions"}),e.jsx(It,{t:o,values:c.triggers??[],onChange:p=>k("triggers",p),placeholder:"Add phrase, press Enter"})]}),e.jsxs("label",{style:U,children:[e.jsx("span",{style:q(o),children:"Ask first when"}),e.jsx(de,{values:c.clarifyWhen??[],onChange:p=>k("clarifyWhen",p),placeholder:"e.g. 'sales' could mean revenue or order count",style:H(o)})]}),e.jsxs("label",{style:U,children:[e.jsx("span",{style:q(o),children:"Avoid when"}),e.jsx(de,{values:c.exclusions??[],onChange:p=>k("exclusions",p),placeholder:"e.g. question is about pipeline or bookings",style:H(o)})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,gridRow:"span 2"},children:[e.jsx("div",{style:te(o),children:"Guidance"}),e.jsxs("label",{style:U,children:[e.jsx("span",{style:q(o),children:"One-line summary"}),e.jsx("input",{type:"text",value:c.description??"",onChange:p=>k("description",p.target.value),placeholder:"What rule does this skill encode?",style:H(o)})]}),e.jsxs("label",{style:U,children:[e.jsx("span",{style:q(o),children:"Full guidance"}),e.jsx("textarea",{value:c.body,onChange:p=>k("body",p.target.value),rows:9,placeholder:"Definitions, exclusions, edge cases — written for the agent.",style:At(o)})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[e.jsx("div",{style:te(o),children:"Prefer these assets"}),e.jsxs("label",{style:U,children:[e.jsx("span",{style:q(o),children:"Metrics"}),e.jsx(Pe,{t:o,options:n.metrics,optionKind:"metrics",selected:c.preferredMetrics,onChange:p=>k("preferredMetrics",p),placeholder:"Search metrics…",emptyOptionsHint:"No metrics available from the project yet."})]}),e.jsxs("label",{style:U,children:[e.jsx("span",{style:q(o),children:"Blocks"}),e.jsx(Pe,{t:o,options:n.blocks,optionKind:"blocks",selected:c.preferredBlocks,onChange:p=>k("preferredBlocks",p),placeholder:"Search blocks…",emptyOptionsHint:"No blocks available from the project yet."})]})]}),e.jsxs("details",{style:{gridColumn:"1 / -1"},children:[e.jsx("summary",{style:{fontSize:11.5,fontWeight:650,color:o.accent,cursor:"pointer"},children:"Advanced — model areas, dimensions, and vocabulary"}),e.jsxs("div",{style:{display:"grid",gap:14,marginTop:12},children:[e.jsx(ve,{label:"Focused model areas (optional)",t:o,hint:"Comma-separated area ids from the Model workspace. This boosts the skill only inside its selected domain; it never expands access.",children:e.jsx(de,{values:c.modelAreaRefs??[],onChange:p=>k("modelAreaRefs",p),placeholder:"customer_lifecycle, revenue_reporting",style:H(o)})}),e.jsx(ve,{label:"Preferred dimensions",t:o,hint:"Business-safe dimensions the agent should prefer when they are compatible.",children:e.jsx(de,{values:c.preferredDimensions??[],onChange:p=>k("preferredDimensions",p),placeholder:"region, month",style:H(o)})}),e.jsx(ve,{label:"Vocabulary",t:o,hint:"Map your terms to a target, e.g. arr → metric:arr or revenue → block:revenue_by_region.",children:e.jsx(Tt,{t:o,value:c.vocabulary,onChange:p=>k("vocabulary",p)})})]})]}),M?e.jsx("div",{style:{gridColumn:"1 / -1"},children:e.jsx(xe,{t:o,tone:"error",children:M})}):null]}),e.jsxs("div",{style:_t(),children:[e.jsx("span",{style:{fontSize:10.5,color:o.textMuted,flex:1,textAlign:"left"},children:"Saved to Git — review in source control before merging."}),e.jsx("button",{type:"button",onClick:()=>!T&&s(),style:V(o),children:"Cancel"}),e.jsxs("button",{type:"button",onClick:m,disabled:!O,style:{...ge(o),opacity:O?1:.55},children:[T?e.jsx(_,{size:13,strokeWidth:2}):null,T?"Saving…":v?"Save changes":"Create skill"]})]})]})})}function It({t,values:n,onChange:r,placeholder:i}){const[l,a]=d.useState(""),o=s=>{const x=s.trim().replace(/,$/,"");!x||n.includes(x)||(r([...n,x]),a(""))};return e.jsxs("div",{style:Fe(t),children:[n.map(s=>e.jsxs("span",{style:Ge(t),children:[s,e.jsx("button",{type:"button",onClick:()=>r(n.filter(x=>x!==s)),style:Ke(t),title:"Remove",children:"×"})]},s)),e.jsx("input",{type:"text",value:l,onChange:s=>a(s.target.value),onKeyDown:s=>{s.key==="Enter"||s.key===","?(s.preventDefault(),o(l)):s.key==="Backspace"&&!l&&n.length&&r(n.slice(0,-1))},onBlur:()=>o(l),placeholder:n.length?"":i,style:qe(t)})]})}function Pe({t,options:n,optionKind:r,selected:i,onChange:l,placeholder:a,emptyOptionsHint:o}){const[s,x]=d.useState(""),[S,v]=d.useState(n);d.useEffect(()=>{let b=!1;const h=window.setTimeout(()=>{D.getSkillOptions(s).then(u=>{b||v(r==="metrics"?u.metrics:u.blocks)}).catch(()=>{b||v(n)})},160);return()=>{b=!0,window.clearTimeout(h)}},[r,n,s]);const c=d.useMemo(()=>S.filter(b=>!i.includes(b)).filter(b=>s?b.toLowerCase().includes(s.toLowerCase()):!0).slice(0,8),[S,i,s]),I=b=>{const h=b.trim();!h||i.includes(h)||(l([...i,h]),x(""))};return e.jsxs("div",{style:{display:"grid",gap:6},children:[e.jsxs("div",{style:Fe(t),children:[i.map(b=>e.jsxs("span",{style:{...Ge(t),fontFamily:t.fontMono},children:[b,e.jsx("button",{type:"button",onClick:()=>l(i.filter(h=>h!==b)),style:Ke(t),title:"Remove",children:"×"})]},b)),e.jsx("input",{type:"text",value:s,onChange:b=>x(b.target.value),onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),I(s))},placeholder:i.length?"":a,style:qe(t)})]}),c.length>0?e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:5},children:c.map(b=>e.jsxs("button",{type:"button",onClick:()=>I(b),style:Ot(t),children:[e.jsx(J,{size:10,strokeWidth:2.4})," ",b]},b))}):S.length===0?e.jsxs("div",{style:{fontSize:11,color:t.textMuted},children:[o," You can still type a value and press Enter."]}):null]})}function Tt({t,value:n,onChange:r}){const[i,l]=d.useState(()=>Object.entries(n??{}).map(([s,x])=>({term:s,target:x}))),a=s=>{l(s);const x={};for(const S of s){const v=S.term.trim();v&&(x[v]=S.target.trim())}r(x)},o=(s,x)=>{a(i.map((S,v)=>v===s?{...S,...x}:S))};return e.jsxs("div",{style:{display:"grid",gap:7},children:[i.map((s,x)=>e.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[e.jsx("input",{type:"text",value:s.term,onChange:S=>o(x,{term:S.target.value}),placeholder:"arr",style:{...H(t),flex:1}}),e.jsx("span",{style:{color:t.textMuted,fontSize:13},children:"→"}),e.jsx("input",{type:"text",value:s.target,onChange:S=>o(x,{target:S.target.value}),placeholder:"metric:arr",style:{...H(t),flex:1.3,fontFamily:t.fontMono}}),e.jsx("button",{type:"button",onClick:()=>a(i.filter((S,v)=>v!==x)),style:he(t),title:"Remove row",children:e.jsx(me,{size:13,strokeWidth:2})})]},x)),e.jsxs("button",{type:"button",onClick:()=>l([...i,{term:"",target:""}]),style:{...V(t),justifySelf:"start"},children:[e.jsx(J,{size:12,strokeWidth:2.2})," Add term"]})]})}function $t({t,onAdd:n}){return e.jsxs("div",{style:{border:`1px dashed ${t.cellBorder}`,borderRadius:12,background:t.cellBg,padding:"34px 28px",textAlign:"center",display:"grid",gap:12,justifyItems:"center"},children:[e.jsx("div",{style:{width:44,height:44,borderRadius:10,background:`${t.accent}18`,color:t.accent,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(re,{size:22,strokeWidth:1.9})}),e.jsx("div",{style:{fontSize:15,fontWeight:700,color:t.textPrimary},children:"Teach the AI your business rules"}),e.jsx("div",{style:{fontSize:13,color:t.textMuted,maxWidth:460,lineHeight:1.55},children:'Skills are the definitions, rules, and vocabulary the AI follows when it answers — like "revenue = recognized, not bookings" or "always exclude test accounts." Add your first one to start guiding every answer.'}),e.jsxs("button",{type:"button",onClick:n,style:{...ge(t),marginTop:4},children:[e.jsx(J,{size:14,strokeWidth:2.2})," Add your first skill"]})]})}function Dt({t,message:n,onRetry:r}){return e.jsxs("div",{style:{border:`1px solid ${t.warning}55`,borderRadius:10,background:`${t.warning}12`,padding:"16px 18px",display:"flex",alignItems:"flex-start",gap:11},children:[e.jsx(Ne,{size:16,strokeWidth:2,color:t.warning,style:{marginTop:1,flexShrink:0}}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:13,fontWeight:650,color:t.textPrimary},children:"Skills are not available right now"}),e.jsx("div",{style:{fontSize:12.5,color:t.textSecondary,marginTop:4,lineHeight:1.5},children:n}),e.jsxs("button",{type:"button",onClick:r,style:{...V(t),marginTop:10},children:[e.jsx(ye,{size:13,strokeWidth:2})," Retry"]})]})]})}function Rt({skill:t,t:n,deleting:r,error:i,onCancel:l,onConfirm:a}){return e.jsx("div",{style:Ft,onClick:l,children:e.jsxs("div",{style:qt(n),onClick:o=>o.stopPropagation(),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9},children:[e.jsx(ie,{size:16,strokeWidth:2,color:n.error}),e.jsx("div",{style:{fontSize:15,fontWeight:700,color:n.textPrimary},children:"Delete this skill?"})]}),e.jsxs("div",{style:{fontSize:13,color:n.textSecondary,lineHeight:1.55},children:[e.jsx("span",{style:{fontFamily:n.fontMono,color:n.textPrimary},children:t.id})," will be removed and the AI will stop following it. This can't be undone."]}),i?e.jsx(xe,{t:n,tone:"error",children:i}):null,e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[e.jsx("button",{type:"button",onClick:l,disabled:r,style:V(n),children:"Cancel"}),e.jsxs("button",{type:"button",onClick:a,disabled:r,style:{...Et(n),opacity:r?.6:1},children:[r?e.jsx(_,{size:13,strokeWidth:2}):e.jsx(ie,{size:13,strokeWidth:2}),r?"Deleting…":"Delete"]})]})]})})}function te(t){return{fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",color:t.textMuted,marginBottom:5}}function ee({t,label:n,values:r,empty:i,accent:l=!1,mono:a=!1}){return e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{style:te(t),children:n}),e.jsx("div",{style:{display:"flex",gap:5,flexWrap:"wrap"},children:r!=null&&r.length?r.map(o=>e.jsx("span",{style:{fontSize:11,padding:"3px 9px",borderRadius:999,background:l?"var(--accent-dim)":"var(--bg-1)",color:l?t.accent:t.textSecondary,border:l?`1px solid ${t.accent}33`:"1px solid var(--border-subtle)",fontFamily:a?t.fontMono:void 0},children:o},o)):e.jsx("span",{style:{fontSize:11.5,color:t.textMuted,fontStyle:"italic"},children:i})})]})}function ve({label:t,hint:n,t:r,children:i}){return e.jsxs("div",{style:{display:"grid",gap:6},children:[e.jsx("label",{style:{fontSize:12,fontWeight:700,color:r.textPrimary},children:t}),n?e.jsx("div",{style:{fontSize:11.5,color:r.textMuted,lineHeight:1.45,marginTop:-2},children:n}):null,i]})}function xe({t,tone:n,children:r}){const i=n==="error"?t.error:t.textMuted;return e.jsx("div",{style:{fontSize:11.5,color:i,lineHeight:1.45},children:r})}function Mt(t){return{display:"inline-flex",alignItems:"center",fontSize:10.5,fontWeight:700,color:t.success,background:`${t.success}14`,border:`1px solid ${t.success}38`,borderRadius:999,padding:"2px 7px"}}function Pt(t){return{display:"inline-flex",alignItems:"center",fontSize:10.5,fontWeight:700,color:t.accent,background:`${t.accent}14`,border:`1px solid ${t.accent}38`,borderRadius:999,padding:"2px 7px"}}function ge(t){return{display:"inline-flex",alignItems:"center",gap:6,padding:"7px 13px",borderRadius:7,border:`1px solid ${t.accent}`,background:t.accent,color:"#ffffff",fontSize:12.5,fontWeight:700,fontFamily:t.font,cursor:"pointer"}}function V(t){return{display:"inline-flex",alignItems:"center",gap:5,padding:"7px 11px",borderRadius:7,border:`1px solid ${t.btnBorder}`,background:t.btnBg,color:t.textSecondary,fontSize:12,fontWeight:600,fontFamily:t.font,cursor:"pointer"}}function Et(t){return{display:"inline-flex",alignItems:"center",gap:6,padding:"7px 13px",borderRadius:7,border:`1px solid ${t.error}`,background:t.error,color:"#ffffff",fontSize:12.5,fontWeight:700,fontFamily:t.font,cursor:"pointer"}}function he(t){return{display:"inline-flex",alignItems:"center",justifyContent:"center",width:30,height:30,borderRadius:7,border:`1px solid ${t.btnBorder}`,background:t.btnBg,color:t.textSecondary,cursor:"pointer",flexShrink:0}}function H(t){return{width:"100%",border:`1px solid ${t.btnBorder}`,borderRadius:7,background:t.cellBg,color:t.textPrimary,fontSize:12.5,fontFamily:t.font,padding:"8px 10px",boxSizing:"border-box"}}function At(t){return{...H(t),resize:"vertical",lineHeight:1.5,padding:"9px 11px"}}function Ee(t){return{display:"inline-flex",alignItems:"center",gap:4,fontSize:10,fontWeight:700,letterSpacing:"0.02em",color:t.warning,background:`${t.warning}16`,border:`1px solid ${t.warning}40`,borderRadius:999,padding:"2px 8px"}}function Fe(t){return{display:"flex",alignItems:"center",gap:5,flexWrap:"wrap",border:`1px solid ${t.btnBorder}`,background:t.cellBg,borderRadius:7,padding:"6px 8px"}}function qe(t){return{flex:1,minWidth:110,border:"none",background:"none",outline:"none",fontSize:11.5,fontFamily:t.font,color:t.textPrimary,padding:2}}function Ge(t){return{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,padding:"2.5px 8px",borderRadius:999,background:"var(--accent-dim)",color:t.accent,border:`1px solid ${t.accent}33`}}function Ke(t){return{border:"none",background:"none",color:t.accent,cursor:"pointer",padding:0,fontSize:12,lineHeight:1,fontFamily:t.font}}const U={display:"flex",flexDirection:"column",gap:4};function q(t){return{fontSize:11,fontWeight:650,color:t.textSecondary}}function Ot(t){return{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,fontWeight:600,color:t.textSecondary,background:t.btnBg,border:`1px solid ${t.btnBorder}`,borderRadius:6,padding:"3px 8px",cursor:"pointer",fontFamily:t.fontMono}}const Lt={position:"fixed",inset:0,background:"rgba(26, 26, 26, 0.22)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:60};function Nt(t){return{width:"min(860px, 94vw)",height:"min(640px, 90vh)",background:t.cellBg,border:`1px solid ${t.headerBorder}`,borderRadius:14,display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"0 24px 70px rgba(26,26,26,0.22)"}}function Ht(t){return{display:"flex",alignItems:"center",gap:10,padding:"14px 18px",borderBottom:"1px solid var(--border-subtle)",flexShrink:0}}function _t(t){return{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8,padding:"12px 18px",borderTop:"1px solid var(--border-subtle)",background:"var(--bg-1)",flexShrink:0}}const Ft={position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.42)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:70,padding:20};function qt(t){return{width:"min(420px, 100%)",background:t.cellBg,border:`1px solid ${t.cellBorder}`,borderRadius:12,padding:20,display:"grid",gap:13,boxShadow:"0 18px 48px rgba(0,0,0,0.3)"}}function Gt({initialTab:t="overview"}){const{state:n}=fe(),r=we[n.themeMode],[i,l]=d.useState(t),[a,o]=d.useState([]),[s,x]=d.useState([]),[S,v]=d.useState(!0);d.useEffect(()=>l(t),[t]);const c=d.useCallback(()=>{let u=!1;return v(!0),Promise.all([D.getDomains(),D.getSkills()]).then(([R,T])=>{u||(o(Array.isArray(R.domains)?R.domains:[]),x(Array.isArray(T.skills)?T.skills:[]))}).catch(()=>{u||(o([]),x([]))}).finally(()=>{u||v(!1)}),()=>{u=!0}},[]);d.useEffect(()=>c(),[c]);const I=d.useMemo(()=>{const u=a.filter(j=>!!(j.businessOwner||j.owner)).length,R=s.filter(j=>!j.status||j.status==="active").length,T=s.filter(j=>j.status==="draft").length;return{ownedDomains:u,activeSkills:R,draftSkills:T}},[a,s]),b=d.useCallback(()=>{l("domains"),window.setTimeout(()=>window.dispatchEvent(new Event("dql:context-build")),50)},[]),h=[{id:"overview",label:"Overview"},{id:"domains",label:"Domains",count:a.length},{id:"skills",label:"Skills",count:s.length},{id:"knowledge",label:"Knowledge 360"}];return e.jsx("div",{style:{flex:1,minWidth:0,overflow:"auto",background:r.appBg},children:e.jsxs("div",{style:{maxWidth:1040,margin:"0 auto",padding:"22px 28px 40px"},children:[e.jsxs("header",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-end",gap:18,marginBottom:15},children:[e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",gap:9,alignItems:"center"},children:[e.jsx(se,{size:20,color:r.accent}),e.jsx("h1",{style:{fontSize:22,color:r.textPrimary},children:"Governed context"})]}),e.jsx("p",{style:{marginTop:6,fontSize:13,lineHeight:1.5,color:r.textMuted,maxWidth:700},children:"Domains define business boundaries. Skills teach the agent approved vocabulary, reuse rules, and when to ask for clarification."})]}),e.jsxs("button",{type:"button",onClick:b,style:Qe(r),children:[e.jsx(ne,{size:14})," Build with AI"]})]}),e.jsx("nav",{"aria-label":"Governed context sections",style:{display:"flex",gap:3,borderBottom:`1px solid ${r.headerBorder}`,marginBottom:18},children:h.map(u=>e.jsxs("button",{type:"button",onClick:()=>l(u.id),style:{border:"none",borderBottom:`2px solid ${i===u.id?r.accent:"transparent"}`,background:"transparent",padding:"9px 12px",color:i===u.id?r.textPrimary:r.textMuted,fontWeight:i===u.id?700:600,cursor:"pointer",fontFamily:r.font,fontSize:12.5},children:[u.label,u.count!==void 0?` · ${u.count}`:""]},u.id))}),i==="overview"?e.jsx(Kt,{t:r,loading:S,domains:a,skills:s,status:I,onBuild:b,onTab:l}):null,i==="domains"?e.jsx(st,{embedded:!0}):null,i==="skills"?e.jsx(zt,{embedded:!0}):null,i==="knowledge"?e.jsx(Ue,{t:r,domains:a}):null]})})}function Ue({t,domains:n,initialDomainId:r}){var I,b;const[i,l]=d.useState(r??((I=n[0])==null?void 0:I.id)??""),[a,o]=d.useState(null),[s,x]=d.useState(!1),[S,v]=d.useState(null);d.useEffect(()=>{var h;!i&&((h=n[0])!=null&&h.id)&&l(n[0].id)},[i,n]),d.useEffect(()=>{r&&n.some(h=>h.id===r)&&l(r)},[n,r]),d.useEffect(()=>{if(!i){o(null);return}let h=!1;return x(!0),v(null),D.getDomainKnowledge(i).then(u=>{h||o(u)}).catch(u=>{h||(o(null),v(u instanceof Error?u.message:"Could not load the compiled knowledge capsule."))}).finally(()=>{h||x(!1)}),()=>{h=!0}},[i]);const c=d.useMemo(()=>{const h={};for(const u of(a==null?void 0:a.objects)??[])h[u.kind]=(h[u.kind]??0)+1;return Object.entries(h).sort((u,R)=>R[1]-u[1]||u[0].localeCompare(R[0]))},[a]);return e.jsxs("div",{style:{display:"grid",gap:14},children:[e.jsx("section",{style:{border:`1px solid ${t.cellBorder}`,borderRadius:10,background:t.cellBg,padding:15},children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:12,flexWrap:"wrap"},children:[e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",gap:7,alignItems:"center",color:t.textPrimary,fontWeight:700,fontSize:13},children:[e.jsx(Ie,{size:16,color:t.accent})," Compiled Domain 360"]}),e.jsx("div",{style:{marginTop:4,color:t.textMuted,fontSize:12},children:"The same qualified graph, route policy, and skill snapshot used by Ask."})]}),e.jsxs("select",{"aria-label":"Domain knowledge capsule",value:i,onChange:h=>l(h.target.value),style:{minWidth:210,border:`1px solid ${t.inputBorder}`,borderRadius:7,background:t.inputBg,color:t.textPrimary,padding:"7px 9px",fontFamily:t.font},children:[e.jsx("option",{value:"",children:"Select a domain"}),[...n].sort((h,u)=>h.name.localeCompare(u.name)).map(h=>e.jsx("option",{value:h.id,children:h.name},h.id))]})]})}),s?e.jsxs("div",{style:{color:t.textMuted,display:"flex",gap:8,alignItems:"center",padding:24},children:[e.jsx(_,{size:15})," Loading compiled knowledge…"]}):null,S?e.jsx("div",{style:{border:`1px solid ${t.error}`,background:t.cellBg,color:t.error,borderRadius:8,padding:12,fontSize:12.5},children:S}):null,a?e.jsxs(e.Fragment,{children:[e.jsxs("section",{style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:9},children:[e.jsx(Y,{t,label:"Objects",value:a.counts.objects,detail:"qualified knowledge",icon:e.jsx(se,{size:16})}),e.jsx(Y,{t,label:"Relations",value:a.counts.edges,detail:"provenance + policy",icon:e.jsx(Ie,{size:16})}),e.jsx(Y,{t,label:"Authorized",value:a.counts.routeStates.authorized??0,detail:"safe cross-domain routes",icon:e.jsx(Xe,{size:16})}),e.jsx(Y,{t,label:"Blocked / stale",value:(a.counts.routeStates.blocked??0)+(a.counts.routeStates.stale??0),detail:"never auto-joined",icon:e.jsx(Le,{size:16})})]}),e.jsxs("section",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1.2fr) minmax(0, 1fr)",gap:12},children:[e.jsxs("div",{style:{border:`1px solid ${t.cellBorder}`,borderRadius:9,background:t.cellBg,padding:14},children:[e.jsx("strong",{style:{color:t.textPrimary,fontSize:13},children:"Knowledge capsule"}),e.jsx("p",{style:{color:t.textSecondary,fontSize:12.5,lineHeight:1.5,margin:"7px 0 11px"},children:((b=a.capsule)==null?void 0:b.description)||"Compiled domain boundary and governed references."}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:c.map(([h,u])=>e.jsxs("span",{style:{border:`1px solid ${t.cellBorder}`,background:t.pillBg,color:t.textSecondary,borderRadius:999,padding:"3px 7px",fontSize:11},children:[h.replace(/_/g," ")," · ",u]},h))}),e.jsxs("div",{style:{marginTop:11,color:t.textMuted,fontSize:11},children:["Snapshot ",a.snapshotId.slice(0,12)," · graph ",a.sourceFingerprint.slice(0,12),a.truncated?" · bounded response":""]})]}),e.jsxs("div",{style:{border:`1px solid ${t.cellBorder}`,borderRadius:9,background:t.cellBg,padding:14},children:[e.jsx("strong",{style:{color:t.textPrimary,fontSize:13},children:"Cross-domain routes"}),e.jsx("div",{style:{display:"grid",gap:7,marginTop:9},children:a.routes.length?a.routes.map(h=>e.jsxs("div",{style:{borderTop:`1px solid ${t.headerBorder}`,paddingTop:7},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:8,color:t.textSecondary,fontSize:12},children:[e.jsxs("span",{children:[h.providerDomainId," → ",h.consumerDomainId]}),e.jsx("span",{style:{color:h.state==="authorized"?t.success:h.state==="observed"?t.textMuted:t.warning,fontWeight:700},children:h.state})]}),e.jsx("div",{style:{marginTop:3,color:t.textMuted,fontSize:11},children:h.purpose||h.reasonCodes.join(", ")||"governed route"})]},h.id)):e.jsx("div",{style:{color:t.textMuted,fontSize:12,marginTop:8},children:"No cross-domain routes declared."})})]})]})]}):null]})}function Kt({t,loading:n,domains:r,skills:i,status:l,onBuild:a,onTab:o}){if(n)return e.jsxs("div",{style:{padding:"42px 0",color:t.textMuted,display:"flex",gap:8,alignItems:"center",fontSize:13},children:[e.jsx(_,{size:15})," Loading governed context…"]});const s=[];return r.length?l.ownedDomains<r.length&&s.push(`${r.length-l.ownedDomains} domain${r.length-l.ownedDomains===1?"":"s"} still need an owner.`):s.push("Create a business domain before relying on AI guidance."),i.length||s.push("Draft a domain skill so the agent has governed business guidance."),l.draftSkills&&s.push(`${l.draftSkills} skill${l.draftSkills===1?" is":"s are"} still draft-only and will not guide answers.`),e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("section",{style:{display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gap:10},children:[e.jsx(Y,{t,label:"Domains",value:r.length,detail:`${l.ownedDomains} with an owner`,icon:e.jsx(se,{size:17})}),e.jsx(Y,{t,label:"Active skills",value:l.activeSkills,detail:"available to the agent",icon:e.jsx(re,{size:17})}),e.jsx(Y,{t,label:"Draft skills",value:l.draftSkills,detail:"review before activation",icon:e.jsx(ne,{size:17})})]}),e.jsxs("section",{style:{border:`1px solid ${t.cellBorder}`,borderRadius:10,background:t.cellBg,padding:16,display:"grid",gap:10},children:[e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[e.jsx(Ze,{size:16,color:s.length?t.warning:t.success}),e.jsx("strong",{style:{color:t.textPrimary,fontSize:13},children:"Readiness"})]}),s.length?e.jsx("div",{style:{display:"grid",gap:6},children:s.map(x=>e.jsxs("div",{style:{display:"flex",gap:7,color:t.textSecondary,fontSize:12.5},children:[e.jsx(Le,{size:14,color:t.warning}),x]},x))}):e.jsx("div",{style:{color:t.success,fontSize:12.5},children:"Your agent has owned domains and active governed skills available for retrieval."}),e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginTop:2},children:[e.jsxs("button",{type:"button",onClick:a,style:Qe(t),children:[e.jsx(ne,{size:13})," Build domains & skills with AI"]}),e.jsx("button",{type:"button",onClick:()=>o("domains"),style:Ae(t),children:"Manage domains"}),e.jsx("button",{type:"button",onClick:()=>o("skills"),style:Ae(t),children:"Manage skills"})]})]})]})}function Y({t,label:n,value:r,detail:i,icon:l}){return e.jsxs("div",{style:{border:`1px solid ${t.cellBorder}`,borderRadius:9,background:t.cellBg,padding:13},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",color:t.textMuted,fontSize:12},children:[n,l]}),e.jsx("div",{style:{color:t.textPrimary,fontSize:25,fontWeight:750,marginTop:7},children:r}),e.jsx("div",{style:{color:t.textMuted,fontSize:11.5,marginTop:3},children:i})]})}function Qe(t){return{display:"inline-flex",alignItems:"center",gap:6,padding:"7px 12px",borderRadius:7,border:`1px solid ${t.accent}`,background:t.accent,color:"#fff",fontWeight:700,fontSize:12.5,fontFamily:t.font,cursor:"pointer"}}function Ae(t){return{display:"inline-flex",alignItems:"center",padding:"7px 12px",borderRadius:7,border:`1px solid ${t.btnBorder}`,background:t.btnBg,color:t.textSecondary,fontWeight:650,fontSize:12.5,fontFamily:t.font,cursor:"pointer"}}const Zt=Object.freeze(Object.defineProperty({__proto__:null,GovernedContextPage:Gt,Knowledge360:Ue},Symbol.toStringTag,{value:"Module"}));export{Zt as G,Ue as K,zt as S};
|
package/dist/assets/dql-notebook/assets/{HelpDocsPage-CL0vbSER.js → HelpDocsPage-BDPNVot1.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as k,u as z,t as R,r as u,j as e,
|
|
1
|
+
import{c as k,u as z,t as R,r as u,j as e,aC as I}from"./index-1mIC_XX4.js";import"./react-CRB3T2We.js";/**
|
|
2
2
|
* @license lucide-react v0.563.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as ot,r as c,a as q,j as e,u as Be,t as Ye,S as Ie,B as ue,C as rt,b as Je,d as st,e as at,L as lt,f as dt,G as Ne,D as be,N as ct,g as pt}from"./index-
|
|
1
|
+
import{c as ot,r as c,a as q,j as e,u as Be,t as Ye,S as Ie,B as ue,C as rt,b as Je,d as st,e as at,L as lt,f as dt,G as Ne,D as be,N as ct,g as pt}from"./index-1mIC_XX4.js";import{T as xt}from"./TrustBadge-vQQh8d0D.js";import{A as he}from"./arrow-right-DvB_DONr.js";import{T as Ke}from"./triangle-alert-2ZXx8wAu.js";import{B as Ee}from"./book-open-text-CJ3NAvrs.js";import{W as ut}from"./workflow-CZtyrcR-.js";import"./react-CRB3T2We.js";/**
|
|
2
2
|
* @license lucide-react v0.563.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as Se,i as je,k as Ce,t as Re,r as a,aw as O,a as pe,ax as Ee,ay as Le,az as Te,aA as Be,j as e,p as E,au as H,aB as Ie,l as ge}from"./index-1mIC_XX4.js";import{u as ze,a as We,M as Me,i as Fe,B as Ne,C as Pe,b as Oe,P as De,T as he,c as P,H as xe}from"./dagre.esm-GKp7qoUL.js";import"./react-CRB3T2We.js";const G=[{key:"technical",label:"Technical",title:"Physical sources and dbt transformations",types:Ee},{key:"domain",label:"Domain",title:"Business terms, governed domains, semantic metrics, and certified blocks",types:Le},{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 $e(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=Ie.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"?P.Left:P.Top,v=p==="LR"?P.Right:P.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 Ae={dagNode:_e};function Qe(){var ae,le,de;const n=Se(je(t=>({lineageFocusNodeId:t.lineageFocusNodeId,themeMode:t.themeMode}))),h=Ce(),o=Re[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,j]=a.useState(Object.fromEntries(O.map(t=>[t,!0]))),[k,Q]=a.useState("flow"),[C,J]=a.useState("LR"),[B,M]=a.useState(null),[D,F]=a.useState(!1),[V,q]=a.useState("block"),[U,K]=a.useState(""),[X,N]=a.useState(!1),[Z,ee]=a.useState(""),[ye,te,fe]=ze([]),[be,oe,me]=We([]),re=a.useCallback(async()=>{p(!0);try{const t=await pe.fetchLineage();v({nodes:t.nodes??[],edges:t.edges??[]})}finally{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),F(!1),M(null),s(null),T(!0);try{const r=await pe.queryLineage({focus:t,upstreamDepth:12,downstreamDepth:12});y(r.graph??{nodes:[],edges:[]}),w(r.focalNode??null)}finally{T(!1)}},[]);a.useCallback(()=>{L(null),y({nodes:[],edges:[]}),w(null),s(null),M(null),F(!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);j(Object.fromEntries(O.map(i=>[i,r.has(i)])))},[]),S=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:Te(i),dimmed:S?!S.has(i.id):!1}})),r=m.edges.map((i,u)=>{const A=S?S.has(i.source)&&S.has(i.target):!1,ce=A?"var(--accent)":Be[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:S&&!A?.25:1},markerEnd:{type:Me.ArrowClosed,color:ce,width:12,height:12}}});te($e(t,r,k,C)),oe(r)},[m,k,C,S,c,oe,te]);const ke=a.useCallback((t,r)=>{M(r.id);const i=m.nodes.find(u=>u.id===r.id)??null;s(i)},[m.nodes]),$=a.useCallback(()=>{M(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:()=>F(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 ${D?o.accent:o.headerBorder}`,background:D?"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:"▾"})]}),D&&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: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:V,onTypeChange:q,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),N(!0)},onFocus:()=>N(!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:()=>N(!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(""),N(!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:$,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(Fe,{nodes:ye,edges:be,onNodesChange:fe,onEdgesChange:me,onNodeClick:ke,onPaneClick:$,nodeTypes:Ae,fitView:!0,fitViewOptions:{padding:.18},proOptions:{hideAttribution:!0},style:{background:"var(--bg-canvas)"},children:[e.jsx(Ne,{color:"var(--border-strong)",gap:22,size:1}),e.jsx(Pe,{showInteractive:!1}),e.jsx(Oe,{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(De,{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:$,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:V,onTypeChange:q,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,j=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:j})]},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 j=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:j?"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:j?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{Qe as LineageDAG};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as O,t as N,r as u,a as A,j as t,l as C,n as E,ao as W,ap as R}from"./index-BTuliKhK.js";import{M as _}from"./MiniLineageGraph-zg_1wW3M.js";import{LineageDAG as H}from"./LineageDAG-QHqd_AM5.js";import{A as F}from"./arrow-left-IjlnAihE.js";import{L as G}from"./list-tree-Ced8e_S1.js";import"./react-CRB3T2We.js";import"./dagre.esm-CycymVj6.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};
|
|
1
|
+
import{u as O,t as N,r as u,a as A,j as t,p as C,q as E,au as W,av as R}from"./index-1mIC_XX4.js";import{M as _}from"./MiniLineageGraph-GkD4y17x.js";import{LineageDAG as H}from"./LineageDAG-BiUFX2KL.js";import{A as F}from"./arrow-left-CMe1kkOL.js";import{L as G}from"./list-tree-BRFpEmvV.js";import"./react-CRB3T2We.js";import"./dagre.esm-GKp7qoUL.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};
|
package/dist/assets/dql-notebook/assets/{LineageDrawer-BvrVZNKY.js → LineageDrawer-CgTScaGB.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as F,t as J,r as l,a as K,l as R,n as I,j as t,ao as Q,ap as Z}from"./index-BTuliKhK.js";import{M as ee}from"./MiniLineageGraph-zg_1wW3M.js";import{P as te}from"./panel-right-open-po3bWSeL.js";import{X as B}from"./x-CeNgQwGm.js";import{M as re}from"./minimize-2-CBIAE0XH.js";import{R as ie}from"./rotate-ccw-B9v1LTJ0.js";import{G as ne}from"./grip-vertical-Dnp2st8l.js";import{E as se}from"./external-link-ZwE5iHsX.js";import"./react-CRB3T2We.js";import"./dagre.esm-CycymVj6.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};
|
|
1
|
+
import{u as F,t as J,r as l,a as K,p as R,q as I,j as t,au as Q,av as Z}from"./index-1mIC_XX4.js";import{M as ee}from"./MiniLineageGraph-GkD4y17x.js";import{P as te}from"./panel-right-open-CunA1xO7.js";import{X as B}from"./x-CSo1M3tu.js";import{M as re}from"./minimize-2-CDwSCGlO.js";import{R as ie}from"./rotate-ccw-DOrfTZk8.js";import{G as ne}from"./grip-vertical-B4EHbGXW.js";import{E as se}from"./external-link-C-PXokWV.js";import"./react-CRB3T2We.js";import"./dagre.esm-GKp7qoUL.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 q=r=>{r!==n&&a({type:"OPEN_LINEAGE_DRAWER",nodeId:r})},Y=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:Y,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:q,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};
|