@duckcodeailabs/dql-cli 1.12.9 → 1.12.11
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/assets/dql-notebook/assets/{AgentAnswerCard-DbI0CAsX.js → AgentAnswerCard-CpL2kDCV.js} +1 -1
- package/dist/assets/dql-notebook/assets/{AgentLogPage-BbMhuJps.js → AgentLogPage-hzHqpD3-.js} +1 -1
- package/dist/assets/dql-notebook/assets/{AiBuildDialog-DNgkam6H.js → AiBuildDialog-BQRWoxp9.js} +1 -1
- package/dist/assets/dql-notebook/assets/AiBuildResult-D9t_4sQl.js +33 -0
- package/dist/assets/dql-notebook/assets/{AiSidePanel-D-EhCOEd.js → AiSidePanel-BCQB9rVF.js} +1 -1
- package/dist/assets/dql-notebook/assets/{AnalyticsHome-BTjkolBn.js → AnalyticsHome-Ba4Ve_Gd.js} +1 -1
- package/dist/assets/dql-notebook/assets/AppsView-CdAT9BOq.js +4466 -0
- package/dist/assets/dql-notebook/assets/{BlockStudio-DTFHMR3y.js → BlockStudio-Brg4fwn5.js} +13 -13
- package/dist/assets/dql-notebook/assets/{BusinessArtifactView-DGiHB7OS.js → BusinessArtifactView-CnTbFVGT.js} +1 -1
- package/dist/assets/dql-notebook/assets/DbtFirstModelingPage-CQe2FUZq.js +22 -0
- package/dist/assets/dql-notebook/assets/{GitPage-BWzPKyws.js → GitPage-DHyDBChc.js} +1 -1
- package/dist/assets/dql-notebook/assets/{GlobalAiRail-CGvBUci2.js → GlobalAiRail-Cys4n_rq.js} +1 -1
- package/dist/assets/dql-notebook/assets/GovernedContextPage-DyKoDSZ2.js +7 -0
- package/dist/assets/dql-notebook/assets/{HelpDocsPage-C7IX_7xh.js → HelpDocsPage-CL0vbSER.js} +3 -3
- package/dist/assets/dql-notebook/assets/{HomePage-e0CObjOb.js → HomePage-DzAucwBW.js} +9 -4
- package/dist/assets/dql-notebook/assets/{LineageDAG-DV6T_0ha.js → LineageDAG-QHqd_AM5.js} +1 -1
- package/dist/assets/dql-notebook/assets/{LineageDetailView-ZVJiCqua.js → LineageDetailView-DdVH-nz6.js} +1 -1
- package/dist/assets/dql-notebook/assets/{LineageDrawer-DQdzGIoL.js → LineageDrawer-BvrVZNKY.js} +1 -1
- package/dist/assets/dql-notebook/assets/LineagePathBreadcrumb-CSut-zvm.js +14 -0
- package/dist/assets/dql-notebook/assets/{MiniLineageGraph-BlJYiAY0.js → MiniLineageGraph-zg_1wW3M.js} +1 -1
- package/dist/assets/dql-notebook/assets/NewBlockModal-9cDletl-.js +1 -0
- package/dist/assets/dql-notebook/assets/NewNotebookModal-V6de8L4d.js +46 -0
- package/dist/assets/dql-notebook/assets/NotebookEditor-EZ0pfWVs.js +200 -0
- package/dist/assets/dql-notebook/assets/{ReadinessPage-m8jlEKzQ.js → ReadinessPage-BaGvjyfd.js} +1 -1
- package/dist/assets/dql-notebook/assets/{SetupOnboarding-ClldPV4C.js → SetupOnboarding-Bg-MjbC9.js} +2 -2
- package/dist/assets/dql-notebook/assets/{TrustBadge-C0FyL1ZO.js → TrustBadge-DGuHB8kP.js} +1 -1
- package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-BlWAVEwO.js +83 -0
- package/dist/assets/dql-notebook/assets/{answer-to-notebook-CgVDBH0o.js → answer-to-notebook-BDzY4MuQ.js} +1 -1
- package/dist/assets/dql-notebook/assets/{arrow-left-XTRkwgdW.js → arrow-left-IjlnAihE.js} +1 -1
- package/dist/assets/dql-notebook/assets/{arrow-right-BUYb7B8y.js → arrow-right-BI4cXgOY.js} +2 -2
- package/dist/assets/dql-notebook/assets/{book-open-text-CQHKAXcN.js → book-open-text-i6xhxu_I.js} +1 -1
- package/dist/assets/dql-notebook/assets/{bot-D9ODKCwi.js → bot-C6DE7Q6m.js} +1 -1
- package/dist/assets/dql-notebook/assets/{chevron-up-BR57nCns.js → chevron-up-DSEILnDs.js} +2 -2
- package/dist/assets/dql-notebook/assets/{circle-x-B3MKf4hs.js → circle-x-BoAorVSm.js} +1 -1
- package/dist/assets/dql-notebook/assets/{codemirror-1_I9gm6Z.js → codemirror-DXt7RW72.js} +1 -1
- package/dist/assets/dql-notebook/assets/{dagre.esm-BWViOEog.js → dagre.esm-CycymVj6.js} +1 -1
- package/dist/assets/dql-notebook/assets/{external-link-D2rxGhQ_.js → external-link-ZwE5iHsX.js} +1 -1
- package/dist/assets/dql-notebook/assets/{grip-vertical-Bzs7bIWP.js → grip-vertical-Dnp2st8l.js} +1 -1
- package/dist/assets/dql-notebook/assets/index-BTuliKhK.js +634 -0
- package/dist/assets/dql-notebook/assets/{link-2-D6nW0_qQ.js → link-2-CTKe6Snr.js} +2 -2
- package/dist/assets/dql-notebook/assets/{list-tree-MH5kYamM.js → list-tree-Ced8e_S1.js} +1 -1
- package/dist/assets/dql-notebook/assets/{maximize-2-C3bEmsdA.js → maximize-2-Cojc6867.js} +1 -1
- package/dist/assets/dql-notebook/assets/{minimize-2-cji4jKmJ.js → minimize-2-CBIAE0XH.js} +1 -1
- package/dist/assets/dql-notebook/assets/{panel-right-open-T-_o8FS9.js → panel-right-open-po3bWSeL.js} +2 -2
- package/dist/assets/dql-notebook/assets/{pencil-BzJ_vZuL.js → pencil-Cb45c6WU.js} +2 -2
- package/dist/assets/dql-notebook/assets/{rotate-ccw-CqSfrg2J.js → rotate-ccw-B9v1LTJ0.js} +2 -2
- package/dist/assets/dql-notebook/assets/{semantic-fields-BXNCrm72.js → semantic-fields-B6ii0an0.js} +1 -1
- package/dist/assets/dql-notebook/assets/{star-C22MG8pV.js → star-CO4tfaDq.js} +2 -2
- package/dist/assets/dql-notebook/assets/{triangle-alert-BtoT0VL-.js → triangle-alert-BSdIu2El.js} +1 -1
- package/dist/assets/dql-notebook/assets/{usePersistedAgentThreadId-BL9P0gFB.js → usePersistedAgentThreadId-CkVFrrjk.js} +2 -2
- package/dist/assets/dql-notebook/assets/{user-round-CpifcAyh.js → user-round-BfrV8U-W.js} +3 -3
- package/dist/assets/dql-notebook/assets/{wand-sparkles-BiOywrQh.js → wand-sparkles-BgTxZNBc.js} +1 -1
- package/dist/assets/dql-notebook/assets/{workflow-DDvVMZ2B.js → workflow--2ycp0yy.js} +2 -2
- package/dist/assets/dql-notebook/assets/{wrench-CoKg2kyO.js → wrench-LMCrpa9_.js} +1 -1
- package/dist/assets/dql-notebook/assets/{x-CCmr0LQ8.js → x-CeNgQwGm.js} +2 -2
- package/dist/assets/dql-notebook/index.html +1 -1
- package/dist/local-runtime.d.ts +90 -2
- package/dist/local-runtime.d.ts.map +1 -1
- package/dist/local-runtime.js +1005 -152
- package/dist/local-runtime.js.map +1 -1
- package/dist/package.json +10 -10
- package/package.json +10 -10
- package/dist/assets/dql-notebook/assets/AiBuildResult-BuTao779.js +0 -33
- package/dist/assets/dql-notebook/assets/AppsView-B3jlWoNm.js +0 -4466
- package/dist/assets/dql-notebook/assets/DbtFirstModelingPage-D-fv_dS2.js +0 -22
- package/dist/assets/dql-notebook/assets/GovernedContextPage-CxkrtqyP.js +0 -7
- package/dist/assets/dql-notebook/assets/LineagePathBreadcrumb-6gFsnWlN.js +0 -14
- package/dist/assets/dql-notebook/assets/NewBlockModal-DaxBAFLu.js +0 -1
- package/dist/assets/dql-notebook/assets/NewNotebookModal-B7GPLsYc.js +0 -46
- package/dist/assets/dql-notebook/assets/NotebookEditor-RuxFQnQC.js +0 -202
- package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-Bd1qmRFx.js +0 -83
- package/dist/assets/dql-notebook/assets/index-CDpukm0G.js +0 -644
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as C,t as k,r as l,a as I,j as t,
|
|
1
|
+
import{u as C,t as k,r as l,a as I,j as t,l as j,n as S,ao as L,ap as N}from"./index-BTuliKhK.js";import{M as W}from"./MiniLineageGraph-zg_1wW3M.js";import"./react-CRB3T2We.js";import"./dagre.esm-CycymVj6.js";function w(r){return r.replace(/\.(dqlnb|dql)$/i,"")}function $(r,o){return`${r}:${w(o)}`}function U(){var y,x;const{state:r,dispatch:o}=C(),e=k[r.themeMode],i=r.activeFile,d=i&&(i.type==="term"||i.type==="business_view")?$(i.type,i.name):null,[a,B]=l.useState({nodes:[],edges:[],focalNode:null}),[M,u]=l.useState(!1);l.useEffect(()=>{if(!d)return;let s=!1;return u(!0),I.queryLineage({focus:d,upstreamDepth:3,downstreamDepth:3}).then(h=>{var f,v;s||(B({nodes:((f=h.graph)==null?void 0:f.nodes)??[],edges:((v=h.graph)==null?void 0:v.edges)??[],focalNode:h.focalNode??null}),u(!1))}).catch(()=>{s||u(!1)}),()=>{s=!0}},[d]);const n=a.focalNode,c=l.useMemo(()=>new Map(a.nodes.map(s=>[s.id,s])),[a.nodes]),g=l.useMemo(()=>n?a.edges.filter(s=>s.target===n.id).map(s=>({edge:s,node:c.get(s.source)})).filter(s=>!!s.node):[],[n,a.edges,c]),m=l.useMemo(()=>n?a.edges.filter(s=>s.source===n.id).map(s=>({edge:s,node:c.get(s.target)})).filter(s=>!!s.node):[],[n,a.edges,c]);if(!i||!d)return t.jsx("div",{style:{flex:1,padding:24,color:e.textMuted},children:"Select a business term or business view from Explorer."});const p=(n==null?void 0:n.type)??i.type,T=j[p]??e.accent,E=S[p]??p.toUpperCase(),z=((y=n==null?void 0:n.metadata)==null?void 0:y.path)??((x=n==null?void 0:n.metadata)==null?void 0:x.filePath)??i.path;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.jsx("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:T,borderRadius:5,padding:"3px 7px",fontSize:10,fontWeight:800,letterSpacing:0},title:L[p]??p,children:E}),t.jsxs("span",{style:{color:e.textMuted,fontSize:12},children:["Lineage · ↑ ",g.length," · ↓ ",m.length]})]}),t.jsx("h1",{style:{margin:0,fontSize:26,lineHeight:1.15,color:e.textPrimary},children:(n==null?void 0:n.name)??w(i.name)}),t.jsx("div",{style:{marginTop:7,color:e.textMuted,fontSize:13},children:i.type==="term"?"Business definition used by blocks, views, dashboards, and AI agents.":"Business composition built from trusted terms, DQL blocks, and other business views."})]})})}),t.jsxs("div",{style:{padding:24,display:"grid",gridTemplateColumns:"minmax(300px, 420px) minmax(420px, 1fr)",gap:18},children:[t.jsxs("section",{style:{display:"grid",gap:14,alignContent:"start"},children:[n&&t.jsx(P,{node:n,t:e}),t.jsx(b,{title:"Upstream",connections:g,t:e}),t.jsx(b,{title:"Downstream",connections:m,t:e}),t.jsxs("div",{style:{border:`1px solid ${e.headerBorder}`,borderRadius:8,padding:12,color:e.textMuted,fontSize:12,background:e.sidebarBg},children:[t.jsx("div",{style:{fontWeight:800,color:e.textSecondary,marginBottom:6},children:"Source file"}),t.jsx("div",{style:{overflowWrap:"anywhere"},children:String(z)})]})]}),t.jsxs("section",{style:{minHeight:520,border:`1px solid ${e.headerBorder}`,borderRadius:8,background:e.sidebarBg,overflow:"hidden"},children:[t.jsxs("div",{style:{padding:"12px 14px",borderBottom:`1px solid ${e.headerBorder}`},children:[t.jsx("div",{style:{fontWeight:800,color:e.textPrimary,fontSize:14},children:"Focused lineage"}),t.jsxs("div",{style:{color:e.textMuted,fontSize:12,marginTop:3},children:["Technical inputs and business composition for this ",i.type==="term"?"term":"view","."]})]}),t.jsx("div",{style:{height:470,padding:12},children:M?t.jsx("div",{style:{color:e.textMuted,fontSize:12},children:"Loading lineage..."}):a.nodes.length===0?t.jsx("div",{style:{color:e.textMuted,fontSize:12},children:"No lineage available."}):t.jsx(W,{nodes:a.nodes,edges:a.edges,focalNodeId:d,height:"100%",onNodeClick:s=>{o({type:"SET_LINEAGE_FOCUS",nodeId:s})},interactive:!0})})]})]})]})}function P({node:r,t:o}){const e=r.metadata??{},i=[];return r.domain&&i.push({label:"Domain",value:r.domain}),r.owner&&i.push({label:"Owner",value:r.owner}),r.status&&i.push({label:"Status",value:r.status}),r.type==="term"&&typeof e.termType=="string"&&i.push({label:"Term Type",value:e.termType}),Array.isArray(e.identifiers)&&e.identifiers.length>0&&i.push({label:"Identifiers",value:e.identifiers.map(String).join(", ")}),Array.isArray(e.synonyms)&&e.synonyms.length>0&&i.push({label:"Synonyms",value:e.synonyms.map(String).join(", ")}),typeof e.description=="string"&&e.description.trim()&&i.push({label:"Description",value:e.description}),typeof e.businessOutcome=="string"&&e.businessOutcome.trim()&&i.push({label:"Business Outcome",value:e.businessOutcome}),typeof e.decisionUse=="string"&&e.decisionUse.trim()&&i.push({label:"Decision Use",value:e.decisionUse}),typeof e.reviewCadence=="string"&&e.reviewCadence.trim()&&i.push({label:"Review Cadence",value:e.reviewCadence}),t.jsxs("div",{style:{border:`1px solid ${o.headerBorder}`,borderRadius:8,background:o.sidebarBg,padding:12},children:[t.jsx("div",{style:{fontWeight:800,color:o.textPrimary,marginBottom:10},children:"Business metadata"}),t.jsx("div",{style:{display:"grid",gap:8},children:i.map(d=>t.jsxs("div",{style:{display:"grid",gap:3},children:[t.jsx("div",{style:{color:o.textMuted,fontSize:10,fontWeight:800,textTransform:"uppercase"},children:d.label}),t.jsx("div",{style:{color:o.textSecondary,fontSize:12,lineHeight:1.45},children:d.value})]},d.label))})]})}function b({title:r,connections:o,t:e}){return t.jsxs("div",{style:{border:`1px solid ${e.headerBorder}`,borderRadius:8,background:e.sidebarBg,padding:12},children:[t.jsx("div",{style:{fontWeight:800,color:e.textPrimary,marginBottom:10},children:r}),o.length===0?t.jsxs("div",{style:{color:e.textMuted,fontSize:12},children:["No ",r.toLowerCase()," connections in this focused window."]}):t.jsxs("div",{style:{display:"grid",gap:7},children:[o.slice(0,8).map(({edge:i,node:d})=>{const a=j[d.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:N[i.type]??i.type}),t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,minWidth:0},children:[t.jsx("span",{style:{color:e.appBg,background:a,borderRadius:3,padding:"1px 4px",fontSize:9,fontWeight:800,flexShrink:0},children:S[d.type]??d.type.slice(0,4).toUpperCase()}),t.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:d.name,children:d.name})]})]},`${i.source}-${i.target}-${i.type}`)}),o.length>8&&t.jsxs("div",{style:{color:e.textMuted,fontSize:12},children:[o.length-8," more connection",o.length-8===1?"":"s"," in the graph"]})]})]})}export{U as BusinessArtifactView};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import{c as Qt,r as a,j as e,P as ke,u as $t,t as Po,a as le,a0 as Fe,aw as No,Y as Oo,M as Ao,aC as Eo,B as Zt,G as so,N as io,h as lo,aD as To,aE as qo,S as ro,aj as Rt,aF as Lo}from"./index-BTuliKhK.js";import{S as _o,K as Fo}from"./GovernedContextPage-DyKoDSZ2.js";import{u as Wo,i as Ho,B as Uo,C as Ko,b as Vo,M as Jo,T as Wn,N as Go,H as it,c as lt,d as Yo}from"./dagre.esm-CycymVj6.js";import{L as Ge}from"./link-2-CTKe6Snr.js";import{M as ao}from"./maximize-2-Cojc6867.js";import{P as Qo}from"./panel-right-open-po3bWSeL.js";import{G as Xt}from"./user-round-BfrV8U-W.js";import{C as ut}from"./circle-x-BoAorVSm.js";import{R as Zo}from"./rotate-ccw-B9v1LTJ0.js";import"./react-CRB3T2We.js";import"./triangle-alert-BSdIu2El.js";import"./chevron-up-DSEILnDs.js";import"./pencil-Cb45c6WU.js";import"./x-CeNgQwGm.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 Xo=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],co=Qt("columns-3",Xo);/**
|
|
7
|
+
* @license lucide-react v0.563.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const es=[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]],Dt=Qt("folder-tree",es);/**
|
|
12
|
+
* @license lucide-react v0.563.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const ts=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],ns=Qt("panel-right-close",ts),en=[{items:[{id:"diagram",label:"Models"},{id:"skills",label:"Skills"},{id:"blocks",label:"Blocks"},{id:"notebooks",label:"Notebooks"},{id:"apps",label:"Apps"}]}],os=new Set(en.flatMap(t=>t.items.map(n=>n.id)));function ss(t){return t!==null&&os.has(t)}function is(t,n){const o=new URL(t);return n.domain?o.searchParams.set("domain",n.domain):o.searchParams.delete("domain"),o.searchParams.set("domainSection",n.section),n.modelAreaId?o.searchParams.set("modelArea",n.modelAreaId):o.searchParams.delete("modelArea"),n.selectedId?o.searchParams.set("domainObject",n.selectedId):o.searchParams.delete("domainObject"),`${o.pathname}${o.search}${o.hash}`}function ls(t){const n=Object.values(t),o=new Map;for(const c of n){const l=c.parent&&t[c.parent]?c.parent:void 0;o.set(l,[...o.get(l)??[],c])}for(const c of o.values())c.sort((l,d)=>l.id.localeCompare(d.id));const s=[],i=new Set,r=(c,l)=>{for(const d of o.get(c)??[])i.has(d.id)||(i.add(d.id),s.push({id:d.id,parent:d.parent,depth:l,label:l===0?d.id:`${"— ".repeat(l)}${d.id.split(".").at(-1)??d.id}`}),r(d.id,l+1))};r(void 0,0);for(const c of n.sort((l,d)=>l.id.localeCompare(d.id)))i.has(c.id)||s.push({id:c.id,parent:c.parent,depth:0,label:c.id});return s}function uo(t){const n=(t??"").toLowerCase();return n==="dimension"?"var(--status-success)":n==="bridge"?"var(--status-warning)":n==="event"||n==="snapshot"?"var(--accent)":"var(--text-tertiary)"}function tn(t){return Object.entries(t.entities).map(([n,o])=>({recordKey:n,entity:o}))}function Hn(t,n){if(t.entities[n])return n;const o=tn(t).filter(({entity:s})=>s.id===n||s.qualifiedId===n);return o.length===1?o[0].recordKey:void 0}function nn(t,n){return tn(t).filter(({entity:o})=>!n||o.domain===n)}function rs({modeling:t,relationByDbtId:n,detailsByDbtId:o,selectedDomain:s,selectedAreaId:i,selectedId:r,viewMode:c,columnMode:l,search:d,layoutMode:u,density:h,visibleLimit:g,dimUnrelated:b,showEdgeLabels:x,resetLayoutToken:y,focusRequest:j,onVisibleDbtIdsChange:f,onSelectEntity:k,onSelectRelationship:I,onEditRelationship:v,onDraftRelationship:B,onAddRelatedModel:$,onDropDbtModel:T,onCreateDomain:Q,onEditEntity:D,onOpenAi:U,theme:Y}){const q=`dql-model-layout:${i??s??"all"}`,N=`${q}:sizes`,[ne,ue]=a.useState(()=>Un(q)),[S,C]=a.useState(()=>Kn(N));a.useEffect(()=>ue(Un(q)),[q]),a.useEffect(()=>C(Kn(N)),[N]),a.useEffect(()=>{y&&(localStorage.removeItem(q),localStorage.removeItem(N),ue({}),C({}))},[y]);const[R,A]=a.useState(null),[W,Z]=a.useState(null),V=(M,oe)=>{const ae={...S,[M]:Math.round(oe)};C(ae),localStorage.setItem(N,JSON.stringify(ae))},{nodes:re,edges:he}=a.useMemo(()=>cs(t,n,o,s,i,r,c,l,d,u,h,g,b,x,ne,S,$,V,Y),[t,n,o,s,i,r,c,l,d,u,h,g,b,x,ne,S,$,Y]),[Re,ye,We]=Wo(re);a.useEffect(()=>ye(re),[re,ye]);const be=re.map(M=>M.data.entity.dbtUniqueId),ze=be.join("|");if(a.useEffect(()=>f(be),[f,ze]),!re.length)return e.jsxs("div",{style:{display:"flex",flexDirection:"column",placeItems:"center",justifyContent:"center",alignItems:"center",gap:12,height:"100%",color:Y.textMuted},children:[e.jsx("strong",{style:{color:Y.textPrimary},children:d.trim()?`No models or columns match “${d.trim()}”.`:"Start your Domain Model"}),!d.trim()&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"Bind a dbt model, then connect its columns to define governed analytical relationships."}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsxs("button",{onClick:Q,style:Jn(Y),children:[e.jsx(ke,{size:13})," Create domain"]}),e.jsxs("button",{onClick:()=>T(""),style:Jn(Y,!0),children:[e.jsx(Ge,{size:13})," Bind first model"]})]})]})]});const L=M=>{!M.source||!M.target||B({from:M.source,to:M.target,fromColumn:Vn(M.sourceHandle),toColumn:Vn(M.targetHandle)})},Se=W?t.relationships[W.recordKey]:void 0;return e.jsxs("div",{style:{height:"100%",position:"relative"},onClick:()=>{A(null),Z(null)},children:[e.jsx("style",{children:ms}),e.jsxs(Ho,{nodes:Re,edges:he,onNodesChange:We,nodeTypes:{entity:ds},fitView:!0,fitViewOptions:{padding:.16},minZoom:.2,maxZoom:1.8,nodesDraggable:!0,nodesConnectable:!0,onConnect:L,onNodeDragStop:(M,oe)=>{const ae={...ne,[oe.id]:oe.position};ue(ae),localStorage.setItem(q,JSON.stringify(ae))},onDragOver:M=>{M.dataTransfer.types.includes("application/x-dql-dbt-model")&&M.preventDefault()},onDrop:M=>{const oe=M.dataTransfer.getData("application/x-dql-dbt-model");oe&&(M.preventDefault(),T(oe))},onNodeClick:(M,oe)=>k(oe.id),onNodeDoubleClick:(M,oe)=>D(oe.id),onNodeContextMenu:(M,oe)=>{M.preventDefault(),A({x:M.clientX,y:M.clientY,nodeId:oe.id})},onEdgeClick:(M,oe)=>{M.stopPropagation(),I(oe.id),Z({x:Math.min(M.clientX,window.innerWidth-340),y:Math.min(M.clientY,window.innerHeight-320),recordKey:oe.id})},colorMode:Y.appBg.toLowerCase().includes("0")?"dark":"light",proOptions:{hideAttribution:!0},children:[e.jsx(ps,{focusRequest:j}),e.jsx(Uo,{color:"var(--border-strong)",gap:22,size:1}),e.jsx(Ko,{showInteractive:!1}),e.jsx(Vo,{pannable:!0,zoomable:!0,nodeColor:M=>po(String(M.data.entity.domain)),maskColor:`${Y.appBg}bb`})]},`${u}:${h}:${g}:${y}:${d}`),R&&e.jsxs("div",{style:{position:"fixed",left:R.x,top:R.y,zIndex:50,width:178,border:`1px solid ${Y.headerBorder}`,borderRadius:7,background:Y.cellBg,boxShadow:"0 12px 32px #0004",padding:4},onClick:M=>M.stopPropagation(),children:[e.jsx(It,{label:"Inspect entity",onClick:()=>{k(R.nodeId),A(null)},theme:Y}),e.jsx(It,{label:"Edit Domain Model binding",onClick:()=>{D(R.nodeId),A(null)},theme:Y}),e.jsx(It,{label:"Ask AI about entity",onClick:()=>{U(R.nodeId),A(null)},theme:Y}),e.jsx(It,{label:"Start relationship",onClick:()=>{B({from:R.nodeId,to:""}),A(null)},theme:Y})]}),W&&Se&&e.jsx(as,{relationship:Se,entities:t.entities,x:W.x,y:W.y,theme:Y,onClose:()=>Z(null),onEdit:v?()=>{v(W.recordKey),Z(null)}:void 0,onViewProof:()=>{I(W.recordKey),Z(null)}})]})}function as({relationship:t,entities:n,x:o,y:s,theme:i,onClose:r,onEdit:c,onViewProof:l}){var b,x;const d=((b=t.validation)==null?void 0:b.status)==="passed",u=t.keys.map(y=>`${y.from} = ${y.to}`).join(" and ")||"No join keys declared",h=y=>{const j=n[y]??Object.values(n).find(f=>f.id===y||f.localId===y);return(j==null?void 0:j.businessName)||(j==null?void 0:j.localId)||y.split("::").pop()||y},g=y=>e.jsx("span",{style:{padding:"3px 8px",borderRadius:6,background:"var(--accent-dim)",color:"var(--accent)",border:"1px solid rgba(107,93,211,0.2)",fontFamily:i.fontMono,fontSize:11.5,maxWidth:120,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:y});return e.jsxs("div",{onClick:y=>y.stopPropagation(),style:{position:"fixed",left:o,top:s,zIndex:60,width:316,background:i.cellBg,border:`1px solid ${i.headerBorder}`,borderRadius:12,boxShadow:"0 12px 34px rgba(26,26,26,0.16)",overflow:"hidden",fontFamily:i.font},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"11px 13px",borderBottom:"1px solid var(--border-subtle)",background:"var(--bg-1)"},children:[e.jsx(Ge,{size:14,color:"var(--accent)",style:{flexShrink:0}}),e.jsx("span",{style:{flex:1,minWidth:0,fontSize:12.5,fontWeight:700,color:i.textPrimary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.localId}),e.jsx("span",{style:{flexShrink:0,border:`1px solid ${d?"var(--status-success-border)":"var(--status-warning-border)"}`,color:d?"var(--status-success)":"var(--status-warning)",background:d?"var(--status-success-bg)":"var(--status-warning-bg)",borderRadius:999,padding:"2px 8px",fontSize:9.5,fontWeight:700},children:d?"Proven":"Unproven"}),e.jsx("button",{type:"button",onClick:r,title:"Close",style:{flexShrink:0,width:20,height:20,borderRadius:5,border:"none",background:"none",color:i.textMuted,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0},children:"×"})]}),e.jsxs("div",{style:{padding:"12px 13px",display:"flex",flexDirection:"column",gap:11},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,fontSize:11.5},children:[g(h(t.from)),e.jsx("span",{style:{color:i.textMuted,fontSize:10.5,fontWeight:650,whiteSpace:"nowrap"},children:t.cardinality.replace(/_/g," ")}),g(h(t.to))]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",color:i.textMuted,marginBottom:4},children:"Join"}),e.jsx("div",{style:{fontSize:11,fontFamily:i.fontMono,color:i.textPrimary,background:"var(--bg-1)",border:"1px solid var(--border-subtle)",borderRadius:7,padding:"7px 9px",overflowWrap:"anywhere"},children:u})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",color:i.textMuted,marginBottom:4},children:"Business context"}),e.jsx("div",{style:{fontSize:12,lineHeight:1.55,color:i.textSecondary},children:t.description||`${t.from} ${t.verb??"relates to"} ${t.to}. Add a business description so agents can pick this route with confidence.`})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:11,color:d?"var(--status-success)":"var(--status-warning)"},children:d?`Join proof passed — ${((x=t.validation)==null?void 0:x.joinedRows)??"?"} rows joined, agents may use this route.`:"No warehouse proof yet — automatic agent joins stay blocked."}),e.jsxs("div",{style:{display:"flex",gap:8},children:[c?e.jsx("button",{type:"button",onClick:c,style:{display:"inline-flex",alignItems:"center",gap:5,height:27,padding:"0 11px",borderRadius:7,border:"none",background:"var(--accent)",color:"#fff",fontSize:11.5,fontWeight:650,cursor:"pointer",fontFamily:i.font},children:"Edit relationship"}):null,e.jsx("button",{type:"button",onClick:l,style:{display:"inline-flex",alignItems:"center",gap:5,height:27,padding:"0 11px",borderRadius:7,border:`1px solid ${i.headerBorder}`,background:i.cellBg,color:i.textSecondary,fontSize:11.5,fontWeight:600,cursor:"pointer",fontFamily:i.font},children:"View join proof"})]})]})]})}function ds({data:t}){var T,Q;const{recordKey:n,entity:o,detail:s,relation:i,selected:r,viewMode:c,columnMode:l,density:d,theme:u,onAddRelatedModel:h,onResize:g}=t,[b,x]=a.useState(d==="compact"),y=po(o.domain),j=uo(o.analyticalRole),f=o.analyticalRole&&o.analyticalRole!=="unknown"?o.analyticalRole:"entity",k=(s==null?void 0:s.columns)??[],I=new Set(o.keys.length?o.keys:((T=s==null?void 0:s.dqlMeta)==null?void 0:T.keys)??[]),v=new Set(k.filter(D=>!I.has(D.name)&&/(^|_)id$/.test(D.name)).map(D=>D.name)),B=b||c==="business"?[]:l==="all"?k.slice(0,16):l==="keys"?k.filter(D=>I.has(D.name)).slice(0,10):k.filter(D=>I.has(D.name)||D.tests.length>0).slice(0,10),$=(Q=o.conceptRefs)!=null&&Q.length?o.conceptRefs.join(", "):Gt(o.localId??o.id);return e.jsxs("div",{style:{position:"relative",width:"100%",minWidth:236,borderRadius:10,overflow:"visible",border:`1.5px solid ${r?"var(--accent)":"var(--border-default)"}`,boxShadow:r?"0 1px 6px rgba(107,93,211,0.14)":"0 1px 4px rgba(26,26,26,0.05)",background:u.cellBg,color:u.textPrimary},children:[e.jsx(Go,{position:"bottom-right",resizeDirection:"horizontal",minWidth:240,maxWidth:620,onResizeEnd:(D,U)=>g(n,U.width),style:{width:16,height:16,border:0,background:"transparent",color:u.textMuted},children:e.jsx("span",{title:"Drag to resize model",style:{display:"grid",placeItems:"center"},children:e.jsx(ao,{size:12})})}),b&&c==="data"&&e.jsx(it,{className:"dql-modeling-handle",id:"entity-target",type:"target",position:lt.Left,style:rt(y)}),e.jsx("button",{className:"nodrag",title:"Add a related model",onClick:D=>{D.stopPropagation(),h({from:n})},style:{position:"absolute",right:-9,top:-9,zIndex:5,width:22,height:22,display:"grid",placeItems:"center",padding:0,borderRadius:999,border:`2px solid ${u.cellBg}`,background:"var(--accent)",color:"#fff",cursor:"pointer",boxShadow:"0 1px 4px rgba(107,93,211,0.3)"},children:e.jsx(ke,{size:12})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,padding:"9px 12px",borderBottom:"1px solid var(--border-subtle)",background:"var(--bg-1)",borderRadius:"8.5px 8.5px 0 0"},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:2.5,background:j,flexShrink:0}}),e.jsx("span",{style:{flex:1,minWidth:0,fontSize:12.5,fontWeight:700,color:u.textPrimary,fontFamily:u.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c==="business"?o.businessName||Gt(o.localId??o.id):o.localId??o.id}),e.jsx("span",{style:{flexShrink:0,fontSize:9,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.05em",color:j},children:f}),c==="data"&&e.jsx("button",{className:"nodrag",title:b?"Expand columns":"Collapse columns",onClick:D=>{D.stopPropagation(),x(U=>!U)},style:{border:0,background:"transparent",color:u.textMuted,cursor:"pointer",padding:0,flexShrink:0},children:b?"▾":"▴"})]}),c==="business"?e.jsxs(e.Fragment,{children:[e.jsx("div",{title:o.businessContext,style:{padding:"9px 12px 7px",fontSize:11.5,lineHeight:1.5,color:u.textSecondary,display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},children:o.businessContext||$}),e.jsxs("div",{style:{display:"flex",gap:6,padding:"0 12px 10px",flexWrap:"wrap"},children:[o.owner?e.jsx("span",{style:{fontSize:10,color:u.textMuted,border:"1px solid var(--border-subtle)",background:"var(--bg-1)",borderRadius:999,padding:"2px 7px"},children:o.owner}):null,e.jsx("span",{style:{fontSize:10,color:u.textMuted,border:"1px solid var(--border-subtle)",background:"var(--bg-1)",borderRadius:999,padding:"2px 7px"},children:o.grain?`1 row = ${o.grain}`:o.domain})]})]}):null,B.length>0&&e.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle)",maxHeight:242,overflow:"auto"},children:[B.map(D=>e.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center",gap:7,padding:"4px 12px",borderBottom:"1px solid var(--border-subtle)",fontSize:11},children:[e.jsx(it,{className:"dql-modeling-handle",id:`target:${D.name}`,type:"target",position:lt.Left,style:{...rt(y),top:"50%"}}),e.jsx("span",{style:{flexShrink:0,width:17,fontSize:8.5,fontWeight:700,fontFamily:u.fontMono,color:I.has(D.name)?"var(--pk)":v.has(D.name)?"var(--fk)":"transparent"},children:I.has(D.name)?"PK":v.has(D.name)?"FK":"·"}),e.jsx("span",{style:{flex:1,minWidth:0,color:u.textSecondary,fontFamily:u.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontWeight:I.has(D.name)?700:500},children:D.name}),e.jsx("span",{style:{flexShrink:0,fontSize:9.5,color:u.textMuted,fontFamily:u.fontMono},children:D.type??""}),e.jsx(it,{className:"dql-modeling-handle",id:`source:${D.name}`,type:"source",position:lt.Right,style:{...rt(y),top:"50%"}})]},D.name)),k.length>B.length&&e.jsxs("div",{style:{padding:"6px 12px",color:u.textMuted,fontSize:9},children:["+ ",k.length-B.length," more dbt-owned columns"]})]}),(b||c==="business")&&e.jsxs(e.Fragment,{children:[e.jsx(it,{className:"dql-modeling-handle",id:"entity-target",type:"target",position:lt.Left,style:rt(y)}),e.jsx(it,{className:"dql-modeling-handle",id:"entity-source",type:"source",position:lt.Right,style:rt(y)})]})]})}function cs(t,n,o,s,i,r,c,l,d,u,h,g,b,x,y,j,f,k,I){const v=i?t.areas[i]:void 0,B=new Set(v?[...v.entityIds,...v.referencedEntityIds]:[]),$=Object.entries(t.relationships).flatMap(([S,C])=>{const R=Hn(t,C.from),A=Hn(t,C.to);return R&&A?[{recordKey:S,relationship:C,from:R,to:A}]:[]}).filter(({recordKey:S,from:C,to:R})=>{var A,W;return v?v.relationshipIds.includes(S):s?((A=t.entities[C])==null?void 0:A.domain)===s||((W=t.entities[R])==null?void 0:W.domain)===s:!0}),T=new Set($.flatMap(({from:S,to:C})=>[S,C])),Q=d.trim().toLowerCase();let D=tn(t).filter(({recordKey:S,entity:C})=>{if(v&&!B.has(S)&&!T.has(S)||s&&C.domain!==s&&!T.has(S))return!1;if(!Q)return!0;const R=o[C.dbtUniqueId];return[S,C.id,C.qualifiedId,C.domain,R==null?void 0:R.relation,...(R==null?void 0:R.columns.map(A=>A.name))??[]].some(A=>String(A??"").toLowerCase().includes(Q))});const U=Math.min(200,g>0?g:50);if(D.length>U){const S=new Map;for(const C of $)S.set(C.from,(S.get(C.from)??0)+1),S.set(C.to,(S.get(C.to)??0)+1);D=[...D].sort((C,R)=>C.recordKey===r?-1:R.recordKey===r?1:(S.get(R.recordKey)??0)-(S.get(C.recordKey)??0)||C.recordKey.localeCompare(R.recordKey)).slice(0,U)}const Y=[...new Set(D.map(({entity:S})=>S.domain))].sort(),q=[];Y.forEach((S,C)=>D.filter(({entity:R})=>R.domain===S).sort((R,A)=>R.recordKey.localeCompare(A.recordKey)).forEach(({recordKey:R,entity:A},W)=>{const Z=o[A.dbtUniqueId],V=c==="business"?0:hs(A,Z,l),re=j[R]??xs(A,Z,n[A.dbtUniqueId],h);q.push({id:R,type:"entity",position:{x:C*390,y:W*190},data:{recordKey:R,entity:A,detail:Z,relation:n[A.dbtUniqueId],selected:r===R,viewMode:c,columnMode:l,density:h,theme:I,onAddRelatedModel:f,onResize:k},style:{width:re,height:116+V*29}})}));const N=new Set(q.map(S=>S.id)),ne=$.filter(({from:S,to:C})=>N.has(S)&&N.has(C)).map(({recordKey:S,relationship:C,from:R,to:A})=>{var ze,L;const W=((ze=C.validation)==null?void 0:ze.status)==="passed";C.automaticJoinAllowed||C.staleCertification;const Z=C.keys.map(Se=>`${Se.from} → ${Se.to}`).join(", "),V=C.keys[0],re=t.entities[R],he=t.entities[A],Re=re?Vt(re,o[re.dbtUniqueId],l):new Set,ye=he?Vt(he,o[he.dbtUniqueId],l):new Set,be=((L=C.verb)==null?void 0:L.trim())||Z;return{id:S,source:R,target:A,sourceHandle:c==="data"&&V&&Re.has(V.from)?`source:${V.from}`:void 0,targetHandle:c==="data"&&V&&ye.has(V.to)?`target:${V.to}`:void 0,type:"default",label:x?`${be} · ${us(C.cardinality)}`:void 0,animated:C.status==="review",markerEnd:{type:Jo.ArrowClosed,color:r===S?"var(--accent)":"var(--border-strong)"},style:{stroke:r===S?"var(--accent)":"var(--border-strong)",strokeWidth:r===S?2:1.5,cursor:"pointer"},labelStyle:{fill:r===S?"var(--accent)":I.textSecondary,fontSize:10.5,fontWeight:650,cursor:"pointer"},labelBgStyle:{fill:I.cellBg,fillOpacity:1,stroke:r===S?"var(--accent)":I.headerBorder,strokeWidth:1},labelBgPadding:[9,4],labelBgBorderRadius:999}}),ue=new Wn.graphlib.Graph().setDefaultEdgeLabel(()=>({}));if(ue.setGraph({rankdir:"LR",ranksep:h==="compact"?90:h==="wide"?190:135,nodesep:h==="compact"?35:h==="wide"?90:60,marginx:35,marginy:35}),q.forEach(S=>{var C,R;return ue.setNode(S.id,{width:Number(((C=S.style)==null?void 0:C.width)??Jt(h)),height:Number(((R=S.style)==null?void 0:R.height)??100)})}),ne.forEach(S=>ue.setEdge(S.source,S.target)),u==="auto"&&Wn.layout(ue),q.forEach(S=>{var A,W;const C=y[S.id];if(C){S.position=C;return}if(u==="grid"){const Z=q.indexOf(S),V=Math.max(1,Math.ceil(Math.sqrt(q.length)));S.position={x:Z%V*360,y:Math.floor(Z/V)*260};return}if(u==="star"){const Z=q.indexOf(S);if(Z===0){S.position={x:0,y:0};return}const V=(Z-1)/Math.max(1,q.length-1)*Math.PI*2;S.position={x:Math.cos(V)*460,y:Math.sin(V)*330};return}const R=ue.node(S.id);R&&(S.position={x:R.x-Number(((A=S.style)==null?void 0:A.width)??Jt(h))/2,y:R.y-Number(((W=S.style)==null?void 0:W.height)??100)/2})}),b&&r&&t.entities[r]){const S=new Set([r]);for(const C of $)C.from===r&&S.add(C.to),C.to===r&&S.add(C.from);for(const C of q)C.style={...C.style,opacity:S.has(C.id)?1:.18,transition:"opacity 160ms ease"}}return{nodes:q,edges:ne}}function us(t){return t==="one_to_one"?"1:1":t==="one_to_many"?"1:N":t==="many_to_one"?"N:1":t==="many_to_many"?"N:N":"?"}function ps({focusRequest:t}){const n=Yo(),o=a.useRef(-1);return a.useEffect(()=>{if(!t||t.token===o.current)return;o.current=t.token;const s=window.setTimeout(()=>{var l,d,u,h;const i=n.getNode(t.id);if(!i)return;const r=Number(((l=i.measured)==null?void 0:l.width)??i.width??((d=i.style)==null?void 0:d.width)??280),c=Number(((u=i.measured)==null?void 0:u.height)??i.height??((h=i.style)==null?void 0:h.height)??120);n.setCenter(i.position.x+r/2,i.position.y+c/2,{zoom:Math.max(.85,n.getZoom()),duration:500})},60);return()=>window.clearTimeout(s)},[t,n]),null}function It({label:t,onClick:n,theme:o}){return e.jsx("button",{onClick:n,style:{width:"100%",textAlign:"left",border:0,borderRadius:4,padding:"7px 8px",background:"transparent",color:o.textPrimary,fontSize:11,cursor:"pointer"},children:t})}function hs(t,n,o){return Vt(t,n,o).size}function Vt(t,n,o){var r;const s=(n==null?void 0:n.columns)??[];if(o==="all")return new Set(s.slice(0,16).map(c=>c.name));const i=new Set(t.keys.length?t.keys:((r=n==null?void 0:n.dqlMeta)==null?void 0:r.keys)??[]);return o==="keys"?new Set(s.filter(c=>i.has(c.name)).slice(0,10).map(c=>c.name)):new Set(s.filter(c=>i.has(c.name)||c.tests.length>0).slice(0,10).map(c=>c.name))}function Jt(t){return t==="compact"?250:t==="wide"?340:280}function xs(t,n,o,s){var r;const i=Math.max(Gt(t.localId??t.id).length,(o==null?void 0:o.length)??0,((r=n==null?void 0:n.description)==null?void 0:r.length)??0,...((n==null?void 0:n.columns)??[]).map(c=>c.name.length));return Math.min(s==="wide"?440:380,Jt(s)+Math.max(0,i-34)*2)}function Un(t){try{const n=JSON.parse(localStorage.getItem(t)??"{}");return Object.fromEntries(Object.entries(n).filter(([,o])=>typeof o.x=="number"&&typeof o.y=="number"))}catch{return{}}}function Kn(t){try{const n=JSON.parse(localStorage.getItem(t)??"{}");return Object.fromEntries(Object.entries(n).filter(([,o])=>typeof o=="number"&&o>=240&&o<=620))}catch{return{}}}function Vn(t){return t!=null&&t.includes(":")?t.slice(t.indexOf(":")+1):void 0}function rt(t){return{background:t,border:"2px solid var(--color-bg-card)",width:9,height:9,cursor:"crosshair"}}const ms=`
|
|
17
|
+
.dql-modeling-handle { opacity: 0; transition: opacity 0.12s ease; }
|
|
18
|
+
.react-flow__node:hover .dql-modeling-handle,
|
|
19
|
+
.dql-modeling-handle.connecting,
|
|
20
|
+
.dql-modeling-handle:hover { opacity: 1; }
|
|
21
|
+
`;function Jn(t,n=!1){return{display:"inline-flex",alignItems:"center",gap:6,border:`1px solid ${n?t.accent:t.headerBorder}`,borderRadius:6,padding:"7px 10px",color:n?t.accent:t.textSecondary,background:n?`${t.accent}12`:t.cellBg,cursor:"pointer",fontSize:11,fontWeight:650}}function Gt(t){return t.replace(/[._-]+/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function po(t){const n=["#6d5ce7","#2e9b63","#d47822","#377cc8","#bd4f8b","#8a6d3b"];let o=0;for(const s of t)o=(o<<5)-o+s.charCodeAt(0)|0;return n[Math.abs(o)%n.length]}function fs(t){return t instanceof Error?t:void 0}function gs(t){return t.details&&typeof t.details=="object"&&!Array.isArray(t.details)?t.details:void 0}function Gn(t){const n=fs(t);if((n==null?void 0:n.code)==="DBT_FIRST_NOT_ENABLED")return{title:"Set up dbt-first modeling",detail:"Domain Studio requires a connected dbt project with manifest v3 and dbt-first modeling enabled. Open Settings → Project & dbt to connect and apply the project.",status:"Modeling mode · Not enabled"};if((n==null?void 0:n.code)==="DBT_MANIFEST_NOT_FOUND"){const s=gs(n),i=typeof(s==null?void 0:s.manifestPath)=="string"&&s.manifestPath.trim()?s.manifestPath:"target/manifest.json";return{title:"dbt manifest is not ready",detail:`The dbt project is connected, but ${i} was not found. Run dbt parse, dbt compile, or dbt build in the configured dbt project, then refresh Domain Studio.`,status:`dbt manifest · Missing (${i})`}}return(n==null?void 0:n.code)==="DBT_MANIFEST_COMPILE_FAILED"?{title:"dbt manifest could not be loaded",detail:`${n.message} Rebuild the dbt manifest, then refresh Domain Studio.`,status:"dbt manifest · Load failed"}:{title:"Domain Studio could not load",detail:t instanceof Error&&t.message?t.message:"The local DQL notebook server did not return Domain Studio data.",status:"Domain Studio · Unavailable"}}function at(t){return t.toLowerCase().replace(/[^a-z0-9]+/g," ").trim()}function ys(t,n,o=50){const s=at(n),i=s.split(/\s+/).filter(Boolean);return t.map(r=>{var b;const c=at(r.label),l=at(r.value),d=at(r.description??""),u=at(((b=r.keywords)==null?void 0:b.join(" "))??""),h=`${c} ${l} ${d} ${u}`;if(i.length&&!i.every(x=>h.includes(x)))return null;let g=0;return s&&((c===s||l===s)&&(g+=1e3),c.startsWith(s)&&(g+=500),l.startsWith(s)&&(g+=350),c.includes(s)&&(g+=200),g+=i.reduce((x,y)=>x+(c.startsWith(y)?80:c.includes(y)?40:10),0)),{option:r,score:g}}).filter(r=>!!r).sort((r,c)=>c.score-r.score||r.option.label.localeCompare(c.option.label)||r.option.value.localeCompare(c.option.value)).slice(0,Math.max(1,o)).map(({option:r})=>r)}function ai(){const{state:t,dispatch:n}=$t(),o=Po[t.themeMode],[s,i]=a.useState(null),[r,c]=a.useState(!0),[l,d]=a.useState(null),u=a.useMemo(()=>Yn(),[]),[h,g]=a.useState(u.section),[b,x]=a.useState(u.domain),[y,j]=a.useState(u.modelAreaId),[f,k]=a.useState(u.selectedId),[I,v]=a.useState(null),[B,$]=a.useState({}),T=a.useRef(new Map),Q=a.useRef(new Set),D=a.useMemo(()=>Hs(),[]),[U,Y]=a.useState(D.viewMode??"business"),[q,N]=a.useState(D.columnMode??"relevant"),[ne,ue]=a.useState(""),[S,C]=a.useState(0),[R,A]=a.useState(null),[W,Z]=a.useState(D.layoutMode??"auto"),[V,re]=a.useState(D.density??"normal"),[he,Re]=a.useState(D.visibleLimit??50),[ye,We]=a.useState(D.dimUnrelated??!0),[be,ze]=a.useState(D.showEdgeLabels??!0),[L,Se]=a.useState(!1),[M,oe]=a.useState(!1),[ae,He]=a.useState(!1),[Ue,Pt]=a.useState(()=>typeof window<"u"&&window.innerWidth<980),Pe=a.useRef(null),pt=a.useRef(null),[xe,H]=a.useState(null),[Qe,Ze]=a.useState(null),[ve,Ke]=a.useState(null),[Xe,ht]=a.useState(!1),[et,Ne]=a.useState(null);a.useEffect(()=>{localStorage.setItem("dql-modeling-preferences",JSON.stringify({modelingView:U,columnMode:q,layoutMode:W,density:V,visibleLimit:he,dimUnrelated:ye,showEdgeLabels:be}))},[U,q,W,V,he,ye,be]),a.useEffect(()=>{const m=()=>Pt(window.innerWidth<980);return window.addEventListener("resize",m),()=>window.removeEventListener("resize",m)},[]);const tt=a.useCallback(()=>{He(m=>{const z=!m;return z?window.requestAnimationFrame(()=>{var J;return(J=pt.current)==null?void 0:J.focus()}):window.requestAnimationFrame(()=>{var J;return(J=Pe.current)==null?void 0:J.focus()}),z})},[]),nt=a.useCallback(m=>{g(m),Mt(b,m,!1,y,f)},[y,b,f]),xt=a.useCallback(m=>{x(m),j(null),k(null),Mt(m,h,!1,null,null)},[h]);a.useEffect(()=>{const m=()=>{const z=Yn();x(z.domain),j(z.modelAreaId),k(z.selectedId),g(z.section)};return window.addEventListener("popstate",m),()=>window.removeEventListener("popstate",m)},[]),a.useEffect(()=>{Mt(b,h,!0,y,f)},[y,b,f,h]);const Oe=async()=>{c(!0);try{const m=await le.getDbtFirstModeling();i(m),d(null);const z=b&&m.modeling.packages[b]?b:null;z!==b&&(x(z),Mt(z,h,!0))}catch(m){i(null),d(Gn(m))}finally{c(!1)}};a.useEffect(()=>{Oe()},[]);const X=s==null?void 0:s.modeling.entities[f??""],je=s==null?void 0:s.modeling.relationships[f??""],Ae=a.useMemo(()=>s?Object.values(s.modeling.areas).filter(m=>!b||m.domain===b).sort((m,z)=>m.name.localeCompare(z.name)):[],[s,b]),ee=s==null?void 0:s.modeling.areas[y??""];a.useEffect(()=>{s&&y&&!Ae.some(m=>m.qualifiedId===y)&&j(null)},[s,Ae,y]);const De=a.useCallback(m=>{const z=T.current.get(m);if(z)return z;if(Q.current.has(m))return Promise.resolve(void 0);const J=le.getDbtModelingNode(m).then(Be=>(Q.current.add(m),$(we=>({...we,[m]:Be})),Be)).catch(()=>{Q.current.add(m)}).finally(()=>T.current.delete(m));return T.current.set(m,J),J},[]);a.useEffect(()=>{if(!X){v(null);return}const m=B[X.dbtUniqueId];if(m){v(m);return}let z=!1;return De(X.dbtUniqueId).then(J=>{z||v(J??null)}),()=>{z=!0}},[B,De,X==null?void 0:X.dbtUniqueId]),a.useEffect(()=>{T.current.clear(),Q.current.clear(),$({})},[s==null?void 0:s.dbtProvenance.manifestFingerprint]);const Nt=a.useCallback(m=>{for(const z of m.slice(0,24))De(z)},[De]);if(r&&!s)return e.jsx(eo,{t:o,title:"Loading Domain Studio…",detail:"Compiling dbt provenance and the sparse DQL analytical overlay."});if(!s){const m=l??Gn(null);return e.jsx(eo,{t:o,title:m.title,detail:m.detail,status:m.status})}const mt=Object.fromEntries(Object.values(s.dbtProvenance.nodes).map(m=>[m.uniqueId,m.relation])),Ot=Object.entries(s.modeling.entities).flatMap(([m,z])=>{var we;const J=z.businessName||z.localId||z.id,Be=[{recordKey:m,type:"model",label:J,sublabel:z.domain,role:z.analyticalRole}];for(const jt of((we=B[z.dbtUniqueId])==null?void 0:we.columns)??[])Be.push({recordKey:m,type:"column",label:jt.name,sublabel:J,role:z.analyticalRole});return Be}),ft=m=>{k(m),ue(""),A(z=>({id:m,token:((z==null?void 0:z.token)??0)+1}))},Ee=ee?new Set([...ee.entityIds,...ee.referencedEntityIds]):void 0,gt=nn(s.modeling,b).filter(({recordKey:m})=>!Ee||Ee.has(m)),ot=Object.values(s.modeling.relationships).filter(m=>{const z=s.modeling.entities[m.from],J=s.modeling.entities[m.to];return ee?ee.relationshipIds.includes(m.qualifiedId):!b||(z==null?void 0:z.domain)===b||(J==null?void 0:J.domain)===b}),yt=Object.values(s.dbtProvenance.nodes).filter(m=>!Object.values(s.modeling.entities).some(z=>z.dbtUniqueId===m.uniqueId)),bt=ae&&h==="diagram";return e.jsxs("div",{style:{flex:1,minHeight:0,display:"flex",flexDirection:"column",background:o.appBg,color:o.textPrimary},children:[e.jsx("header",{style:{minHeight:52,padding:"0 14px",borderBottom:`1px solid ${o.headerBorder}`,background:o.headerBg,display:"flex",alignItems:"center"},children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,alignItems:"center",width:"100%"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[e.jsx(Fe,{size:16,color:o.accent}),e.jsx("h1",{style:{margin:0,fontSize:12,fontWeight:800,whiteSpace:"nowrap"},children:"Domain workspace"}),e.jsx("span",{style:{color:o.textMuted,fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b?`/${b}`:"/all domains"})]}),e.jsxs("div",{style:{display:"flex",gap:7},children:[b&&e.jsxs(K,{t:o,onClick:()=>{try{window.sessionStorage.setItem("dql-ask-domain-context",JSON.stringify({domain:b,modelAreaId:ee==null?void 0:ee.qualifiedId}))}catch{}n({type:"SET_MAIN_VIEW",view:"ask"})},children:[e.jsx(No,{size:14})," Ask"]}),e.jsxs(K,{t:o,onClick:()=>H(b?{kind:"area"}:{kind:"domain"}),children:[e.jsx(ke,{size:14})," ",b?"New model area":"New domain"]}),e.jsx(Ls,{t:o,title:"Recompile",onClick:()=>void Oe(),children:e.jsx(Oo,{size:15})})]})]})}),e.jsxs("div",{style:{flex:1,minHeight:0,display:"grid",gridTemplateColumns:bt&&!Ue?"clamp(190px, 15vw, 232px) minmax(460px, 1fr) clamp(270px, 22vw, 380px)":"clamp(190px, 15vw, 232px) minmax(0, 1fr)"},children:[e.jsxs("aside",{style:{borderRight:`1px solid ${o.headerBorder}`,overflow:"auto",background:o.appBg},children:[e.jsx(js,{data:s,selectedDomain:b,onSelect:xt,t:o}),e.jsx(vs,{data:s,domain:b,active:h,onSelect:nt,t:o}),e.jsx("div",{style:{padding:"10px 12px",borderTop:`1px solid ${o.headerBorder}`,display:"flex",flexDirection:"column",gap:5,fontSize:10.5,color:o.textMuted,fontFamily:o.font},children:e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:999,background:"var(--status-success)",flexShrink:0}}),"dbt synced · ",Object.keys(s.dbtProvenance.nodes).length," model",Object.keys(s.dbtProvenance.nodes).length===1?"":"s"]})})]}),e.jsxs("main",{style:{minWidth:0,minHeight:0,display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{minHeight:42,display:"flex",alignItems:"center",gap:7,padding:"0 10px 0 14px",borderBottom:`1px solid ${o.headerBorder}`,background:o.headerBg},children:[ho(h,14,o),e.jsx("strong",{style:{fontSize:11},children:Ss(h)}),e.jsx("span",{style:{width:1,height:15,background:o.headerBorder}}),e.jsx("span",{style:{color:o.textMuted,fontSize:10},children:b??"All domains"}),(h==="diagram"||h==="skills")&&b&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,marginLeft:5},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:5,color:o.textMuted,fontSize:10},children:["Area",e.jsxs("select",{"aria-label":"Active model area",value:y??"",onChange:m=>{j(m.target.value||null),k(null)},style:{...ge(o),minWidth:146,padding:"4px 6px"},children:[e.jsx("option",{value:"",children:"All domain"}),Ae.map(m=>e.jsx("option",{value:m.qualifiedId,children:m.name},m.qualifiedId))]})]}),e.jsx("button",{"aria-label":"Add model area",title:"Add model area",onClick:()=>H({kind:"area"}),style:{...fe(o),width:27,height:27},children:e.jsx(ke,{size:13})})]}),h==="diagram"&&e.jsx("button",{ref:Pe,"aria-expanded":ae,"aria-controls":"domain-studio-inspector","aria-label":ae?"Hide inspector":"Show inspector",title:ae?"Hide inspector":"Show inspector",onClick:tt,style:{...fe(o),marginLeft:"auto"},children:ae?e.jsx(ns,{size:14}):e.jsx(Qo,{size:14})})]}),e.jsxs("div",{style:{flex:1,minHeight:0},children:[h==="overview"&&e.jsx(ks,{data:s,domain:b,t:o,onOpen:nt}),h==="diagram"&&e.jsxs("div",{id:"dql-modeling-diagram",style:{height:"100%",display:"flex",flexDirection:"column",...M?{position:"fixed",inset:0,zIndex:90,background:o.appBg}:{}},children:[e.jsx(Is,{modelingView:U,columnMode:q,search:ne,layoutMode:W,density:V,visibleLimit:he,totalEntities:(Ee==null?void 0:Ee.size)??Object.keys(s.modeling.entities).length,dimUnrelated:ye,showEdgeLabels:be,showLegend:L,fullscreen:M,onBindModel:()=>H({kind:"entity"}),onRelationship:()=>H({kind:"relationship"}),onNewArea:()=>H({kind:"area"}),onModelingView:Y,onColumnMode:N,onSearch:ue,searchItems:Ot,onPickModel:ft,onLayoutMode:Z,onDensity:re,onVisibleLimit:Re,onDimUnrelated:We,onEdgeLabels:ze,onLegend:Se,onFullscreen:()=>oe(m=>!m),onExport:()=>zs(),onReset:()=>C(m=>m+1),t:o}),ee?e.jsxs("div",{style:{padding:"7px 14px",borderBottom:`1px solid ${o.headerBorder}`,background:"var(--accent-dim)",color:o.textSecondary,display:"flex",alignItems:"center",gap:8,fontSize:10.5},children:[e.jsx(Fe,{size:13,color:o.accent}),e.jsx("strong",{style:{color:o.textPrimary},children:ee.name}),e.jsx("span",{children:ee.description??"Focused business modeling area"}),e.jsxs("span",{style:{marginLeft:"auto",color:o.textMuted},children:[ee.entityIds.length," model",ee.entityIds.length===1?"":"s"," · ",ee.intentExamples.length," example question",ee.intentExamples.length===1?"":"s"]})]}):null,L&&e.jsx(Ms,{t:o}),e.jsx("div",{style:{flex:1,minHeight:0},children:e.jsx(rs,{modeling:s.modeling,relationByDbtId:mt,detailsByDbtId:B,selectedDomain:b,selectedAreaId:y,selectedId:f,viewMode:U,columnMode:q,search:ne,layoutMode:W,density:V,visibleLimit:he,dimUnrelated:ye,showEdgeLabels:be,resetLayoutToken:S,focusRequest:R??void 0,onVisibleDbtIdsChange:Nt,onSelectEntity:k,onSelectRelationship:k,onEditRelationship:m=>{const z=s.modeling.relationships[m];z&&H({kind:"relationship",relationship:z})},onDraftRelationship:m=>H({kind:"relationship",draft:m}),onAddRelatedModel:m=>H({kind:"entity",relationshipFrom:m}),onDropDbtModel:m=>H({kind:"entity",dbtUniqueId:m}),onCreateDomain:()=>H({kind:"domain"}),onEditEntity:m=>{const z=s.modeling.entities[m];z&&H({kind:"entity",entity:z,dbtUniqueId:z.dbtUniqueId})},onOpenAi:m=>{k(m);try{window.sessionStorage.setItem("dql-ask-domain-context",JSON.stringify({domain:b,modelAreaId:ee==null?void 0:ee.qualifiedId,objectId:m}))}catch{}n({type:"SET_MAIN_VIEW",view:"ask"})},theme:o})})]}),h==="terms"&&e.jsx(Ht,{data:s,domain:b,kinds:["terms"],title:"Domain terms",detail:"Business vocabulary owned by this domain and available to governed retrieval.",t:o}),h==="skills"&&e.jsx(_o,{embedded:!0,domainFilter:b,modelAreaFilter:y}),h==="knowledge"&&e.jsx("div",{style:{height:"100%",overflow:"auto",padding:"18px 20px"},children:e.jsx(Fo,{t:o,domains:Object.values(s.modeling.packages).map(m=>({id:m.id,name:m.id})),initialDomainId:b})}),h==="blocks"&&e.jsx(Ds,{data:s,domain:b,t:o}),h==="views"&&e.jsx(Ht,{data:s,domain:b,kinds:["views"],title:"Business views",detail:"Domain-owned business views that compose governed models and blocks.",t:o}),h==="ai"&&e.jsx(Bs,{domain:b,selectedId:f,data:s,t:o,onOpenSkills:()=>nt("skills"),onDraftRelationship:()=>H({kind:"relationship",draft:X&&f?{from:f,to:""}:void 0})}),h==="join-proofs"&&e.jsx(Rs,{relationships:ot,entities:s.modeling.entities,t:o,onSelect:m=>k(Ft(s.modeling.relationships,m)),onEdit:m=>H({kind:"relationship",relationship:m})}),h==="contracts"&&e.jsx(Ps,{data:s,domain:b,t:o,onCreate:()=>H({kind:"contract"})}),h==="interfaces"&&e.jsx($s,{data:s,domain:b,t:o,onCreateExport:()=>H({kind:"export"}),onCreateImport:()=>H({kind:"import"})}),h==="evaluations"&&e.jsx(Ht,{data:s,domain:b,kinds:["evaluations","tests"],title:"Evaluations",detail:"Evidence and regression checks required before governed assets guide agents.",t:o}),h==="notebooks"&&e.jsx(Qn,{data:s,domain:b,kind:"notebooks",t:o}),h==="apps"&&e.jsx(Qn,{data:s,domain:b,kind:"apps",t:o}),h==="dbt"&&e.jsx(Ns,{data:s,domain:b,unbound:yt,t:o,onBind:m=>H({kind:"entity",dbtUniqueId:m})})]})]}),bt&&e.jsxs("aside",{id:"domain-studio-inspector",ref:pt,role:"complementary","aria-label":"Domain Studio inspector",tabIndex:-1,onKeyDown:m=>{m.key==="Escape"&&tt()},style:{borderLeft:`1px solid ${o.headerBorder}`,overflow:"auto",background:o.appBg,minWidth:0,...Ue?{position:"fixed",inset:"0 0 0 auto",width:"min(90vw, 380px)",zIndex:95,boxShadow:"-12px 0 30px rgba(0,0,0,.18)"}:{}},children:[e.jsx(_s,{t:o,children:"Inspector"}),X?e.jsx(Os,{entity:X,detail:I,relationships:ot,t:o,onEdit:()=>H({kind:"entity",entity:X,dbtUniqueId:X.dbtUniqueId}),onEditDbtSource:()=>Ze(X),onSelectRelationship:m=>k(Ft(s.modeling.relationships,m)),onDelete:()=>{Ne(null),Ke({kind:"entity",id:X.localId||X.id,domain:X.domain,areaId:X.areaId,label:X.businessName||X.localId||X.id})}}):je?e.jsx(Es,{relationship:je,t:o,onEdit:()=>H({kind:"relationship",relationship:je}),onDelete:()=>{Ne(null),Ke({kind:"relationship",id:je.localId||je.id,domain:je.ownerDomain??je.qualifiedId.split("::")[0],areaId:je.areaId,label:je.localId||je.id})}}):e.jsx(Ts,{data:s,domainEntities:gt.map(({entity:m})=>m),domainRelationships:ot,t:o,onSelectRelationship:m=>k(Ft(s.modeling.relationships,m))})]})]}),xe&&e.jsx(ws,{editor:xe,data:s,selectedDomain:b,selectedArea:ee,t:o,onClose:()=>H(null),onApplied:async m=>{H(null),await Oe(),xe.kind==="entity"&&xe.relationshipFrom&&m.operation==="upsert_entity"&&H({kind:"relationship",draft:{...xe.relationshipFrom,to:m.value.id}})}}),Qe&&I&&e.jsx(As,{entity:Qe,detail:I,snapshotId:s.snapshotId,t:o,onClose:()=>Ze(null),onApplied:async()=>{Ze(null),await Oe()}}),ve&&e.jsx(bs,{pending:ve,busy:Xe,error:et,t:o,onCancel:()=>{Ke(null),Ne(null)},onConfirm:async()=>{ht(!0),Ne(null);try{const m={operation:ve.kind==="entity"?"remove_entity":"remove_relationship",value:{id:ve.id,domain:ve.domain,...ve.areaId?{areaId:ve.areaId}:{}}},z=await le.previewModelingChange(m,s.snapshotId);if(!z.patches.some(J=>J.changed))throw new Error("Nothing to remove — it is no longer in the domain source.");await le.applyModelingChange(m,z.fingerprint,s.snapshotId),Ke(null),k(null),await Oe()}catch(m){Ne(m instanceof Error?m.message:String(m))}finally{ht(!1)}}})]})}function bs({pending:t,busy:n,error:o,t:s,onCancel:i,onConfirm:r}){return e.jsx("div",{role:"dialog","aria-modal":"true","aria-label":`Delete ${t.kind}`,style:{position:"fixed",inset:0,background:"rgba(15,23,42,0.34)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:130},onClick:c=>{c.target===c.currentTarget&&!n&&i()},children:e.jsxs("div",{style:{width:"min(92vw, 420px)",background:s.appBg,border:`1px solid ${s.headerBorder}`,borderRadius:12,padding:18,boxShadow:"0 18px 44px rgba(0,0,0,.22)"},children:[e.jsxs("div",{style:{fontSize:14,fontWeight:700,color:s.textPrimary,marginBottom:6},children:["Delete this ",t.kind,"?"]}),e.jsxs("div",{style:{fontSize:12,color:s.textSecondary,lineHeight:1.5},children:[e.jsx("strong",{style:{fontFamily:s.fontMono},children:t.label})," will be removed from the"," ",e.jsx("strong",{children:t.domain})," domain source. dbt models and warehouse data are not affected."]}),t.kind==="entity"?e.jsx("div",{style:{fontSize:11.5,color:s.textMuted,marginTop:8,lineHeight:1.5},children:"Relationships that reference it are left in place and will report a missing endpoint until you remove or repoint them."}):null,o?e.jsx("div",{style:{fontSize:11.5,color:s.error,marginTop:10,lineHeight:1.5},children:o}):null,e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:16},children:[e.jsx(K,{t:s,onClick:i,disabled:n,children:"Cancel"}),e.jsx(K,{t:s,danger:!0,onClick:r,disabled:n,children:n?"Deleting…":`Delete ${t.kind}`})]})]})})}function js({data:t,selectedDomain:n,onSelect:o,t:s}){const{state:i}=$t(),r=ls(t.modeling.packages),c=new Map(Ao(i.authoredDomains).map(l=>[l.value,l.label]));return e.jsx("nav",{"aria-label":"Domain packages",children:e.jsx(Eo,{id:"domain-workspace-filter",ariaLabel:"Domain workspace",value:n??"",options:r.map(l=>({value:l.id,label:c.get(l.id)??l.label})),onChange:l=>o(l||null),summary:e.jsxs(e.Fragment,{children:[r.length," domain",r.length===1?"":"s"," available"]}),t:s})})}function vs({data:t,domain:n,active:o,onSelect:s,t:i}){var d;const r=n?[((d=t.domainAssets)==null?void 0:d[n])??{}]:Object.values(t.domainAssets??{}),l={diagram:nn(t.modeling,n).length,skills:r.reduce((u,h)=>{var g;return u+(((g=h.skills)==null?void 0:g.length)??0)},0),blocks:new Set(r.flatMap(u=>u.blocks??[])).size};return e.jsx("nav",{"aria-label":n?`${n} workspace`:"All domains workspace",style:{padding:"10px 7px 14px"},children:en.map((u,h)=>e.jsxs("div",{style:{marginTop:h===0?0:12},children:[u.label?e.jsx("div",{style:{padding:"0 8px 6px",color:i.textMuted,fontSize:9,fontWeight:800,textTransform:"uppercase",letterSpacing:".06em"},children:u.label}):null,u.items.map(g=>e.jsxs("button",{onClick:()=>s(g.id),"aria-current":o===g.id?"page":void 0,style:Ks(i,o===g.id,!1),children:[ho(g.id,14,i,o===g.id),e.jsx("span",{style:{flex:1},children:g.label}),l[g.id]!==void 0&&e.jsx("small",{style:{color:o===g.id?i.accent:i.textMuted},children:l[g.id]})]},g.id))]},u.label??`group-${h}`))})}function ho(t,n,o,s=!1){const i=t==="blocks"?Zt:t==="diagram"||t==="dbt"?so:t==="knowledge"||t==="interfaces"?io:t==="skills"?Xt:t==="join-proofs"?Ge:t==="contracts"||t==="evaluations"?lo:t==="views"?co:t==="terms"||t==="notebooks"||t==="apps"?Dt:Fe;return e.jsx(i,{size:n,color:s?o.accent:o.textMuted})}function Ss(t){var n;return t==="ai"?"Draft context":((n=en.flatMap(o=>o.items).find(o=>o.id===t))==null?void 0:n.label)??t}function Yn(){if(typeof window>"u")return{domain:null,section:"diagram",modelAreaId:null,selectedId:null};const t=new URL(window.location.href).searchParams,n=t.get("domainSection"),o=ss(n)?n:"diagram";return{domain:t.get("domain"),section:o,modelAreaId:t.get("modelArea"),selectedId:o==="diagram"&&n==="diagram"?t.get("domainObject"):null}}function Mt(t,n,o=!1,s=null,i=null){if(typeof window>"u")return;const r=is(window.location.href,{domain:t,section:n,modelAreaId:s,selectedId:i});o?window.history.replaceState(window.history.state,"",r):window.history.pushState(window.history.state,"",r)}function Ft(t,n){const o=Object.entries(t).find(([,s])=>s===n);return o?o[0]:n.qualifiedId??n.id}function ws({editor:t,data:n,selectedDomain:o,selectedArea:s,t:i,onClose:r,onApplied:c}){var Sn,wn,kn,Cn,In,Mn,zn,Dn,Bn,$n,Rn,Pn,Nn,On,An,En,Tn,qn,Ln,_n,Fn;const l=t.kind==="relationship"?t.relationship:void 0,d=t.kind==="entity"?t.entity:void 0,u=t.kind==="area"?t.area:void 0,h=t.kind==="relationship"?t.draft:void 0,[g,b]=a.useState((u==null?void 0:u.domain)??(d==null?void 0:d.domain)??o??Object.keys(n.modeling.packages)[0]??""),[x,y]=a.useState((u==null?void 0:u.localId)??((Sn=n.modeling.areas[(d==null?void 0:d.areaId)??(l==null?void 0:l.areaId)??""])==null?void 0:Sn.localId)??(s==null?void 0:s.localId)??""),[j,f]=a.useState((l==null?void 0:l.localId)??(d==null?void 0:d.localId)??(u==null?void 0:u.localId)??""),[k,I]=a.useState((l==null?void 0:l.owner)??(d==null?void 0:d.owner)??""),[v,B]=a.useState(""),[$,T]=a.useState(t.kind==="entity"?(d==null?void 0:d.dbtUniqueId)??t.dbtUniqueId??"":""),[Q,D]=a.useState((d==null?void 0:d.businessName)??""),[U,Y]=a.useState((d==null?void 0:d.businessContext)??""),[q,N]=a.useState(((wn=d==null?void 0:d.conceptRefs)==null?void 0:wn.join(", "))??""),[ne,ue]=a.useState((d==null?void 0:d.analyticalRole)??"unknown"),[S,C]=a.useState((d==null?void 0:d.status)??"draft"),[R,A]=a.useState((d==null?void 0:d.grain)??""),[W,Z]=a.useState((d==null?void 0:d.keys.join(", "))??""),[V,re]=a.useState((u==null?void 0:u.name)??""),[he,Re]=a.useState((u==null?void 0:u.description)??""),[ye,We]=a.useState((u==null?void 0:u.intentExamples.join(", "))??""),[be,ze]=a.useState((u==null?void 0:u.referencedEntityIds.map(p=>{var P;return((P=n.modeling.entities[p])==null?void 0:P.localId)??p}).join(", "))??""),[L,Se]=a.useState((l==null?void 0:l.from)??(h==null?void 0:h.from)??""),[M,oe]=a.useState((l==null?void 0:l.to)??(h==null?void 0:h.to)??""),[ae,He]=a.useState((l==null?void 0:l.keys.map(p=>`${p.from}=${p.to}`).join(", "))??(h!=null&&h.fromColumn&&h.toColumn?`${h.fromColumn}=${h.toColumn}`:"")),[Ue,Pt]=a.useState((l==null?void 0:l.cardinality)??"unknown"),[Pe,pt]=a.useState((l==null?void 0:l.fanout)??"unknown"),[xe,H]=a.useState((l==null?void 0:l.status)??"draft"),[Qe,Ze]=a.useState((l==null?void 0:l.verb)??""),[ve,Ke]=a.useState((l==null?void 0:l.description)??""),[Xe,ht]=a.useState(((kn=l==null?void 0:l.roles)==null?void 0:kn.from)??""),[et,Ne]=a.useState(((Cn=l==null?void 0:l.roles)==null?void 0:Cn.to)??""),[tt,nt]=a.useState(((In=l==null?void 0:l.optionality)==null?void 0:In.from)??"unknown"),[xt,Oe]=a.useState(((Mn=l==null?void 0:l.optionality)==null?void 0:Mn.to)??"unknown"),[X,je]=a.useState(((zn=l==null?void 0:l.joinTypes)==null?void 0:zn.join(", "))??"left"),[Ae,ee]=a.useState(((Dn=l==null?void 0:l.aggregation)==null?void 0:Dn.measuresFrom.join(", "))??""),[De,Nt]=a.useState(((Bn=l==null?void 0:l.aggregation)==null?void 0:Bn.dimensionsFrom.join(", "))??""),[mt,Ot]=a.useState((($n=l==null?void 0:l.importRefs)==null?void 0:$n.join(", "))??""),[ft,Ee]=a.useState((l==null?void 0:l.attributionBlock)??""),[gt,ot]=a.useState((l==null?void 0:l.evidenceExpiresAt)??""),[yt,bt]=a.useState(""),[m,z]=a.useState(""),[J,Be]=a.useState(""),[we,jt]=a.useState(""),[vt,sn]=a.useState(""),[St,ln]=a.useState(""),[rn,fo]=a.useState(""),[an,go]=a.useState(""),[dn,yo]=a.useState(""),[cn,bo]=a.useState(""),[un,jo]=a.useState(""),[pn,vo]=a.useState(""),[hn,So]=a.useState("internal"),[xn,wo]=a.useState(""),[wt,At]=a.useState(null),[Et,ko]=a.useState(null),[Tt,Ve]=a.useState(!1),[kt,Je]=a.useState(null),[qt,st]=a.useState(l==null?void 0:l.validation),[Te,Lt]=a.useState(null),[_t,Co]=a.useState({}),[mn,Io]=a.useState(!!(l&&(l.roles||l.aggregation||(Rn=l.importRefs)!=null&&Rn.length||l.attributionBlock||l.evidenceExpiresAt)));a.useEffect(()=>{t.kind!=="relationship"||l||j||!L||!M||f(`${L}_to_${M}`.replace(/[^a-zA-Z0-9]+/g,"_").replace(/^_+|_+$/g,"").toLowerCase())},[t.kind,l,L,M,j]),a.useEffect(()=>{var P;if(t.kind!=="entity"||j||!$)return;const p=(P=n.dbtProvenance.nodes[$])==null?void 0:P.name;p&&f(p.replace(/[^a-zA-Z0-9]+/g,"_").replace(/^_+|_+$/g,"").toLowerCase())},[t.kind,j,$,n.dbtProvenance.nodes]),a.useEffect(()=>{if(t.kind!=="entity"||!$){Lt(null);return}let p=!1;return le.getDbtModelingNode($).then(P=>{var E,se;p||(Lt(P),Q||D(P.name.replace(/[_-]+/g," ").replace(/\b\w/g,te=>te.toUpperCase())),!R&&((E=P.dqlMeta)!=null&&E.grain)&&A(P.dqlMeta.grain),!W&&((se=P.dqlMeta)!=null&&se.keys.length)&&Z(P.dqlMeta.keys.join(", ")))}).catch(()=>{p||Lt(null)}),()=>{p=!0}},[$,t.kind]),a.useEffect(()=>{if(t.kind!=="relationship")return;const P=[L,M].map(se=>{var te;return(te=n.modeling.entities[se])==null?void 0:te.dbtUniqueId}).filter(se=>!!se).filter(se=>!_t[se]);if(!P.length)return;let E=!1;return le.getDbtModelingNodes(P).then(({details:se})=>{E||Co(te=>({...te,...Object.fromEntries(se.map(me=>[me.uniqueId,me]))}))}).catch(()=>{}),()=>{E=!0}},[t.kind,L,M]);const fn=()=>{if(t.kind==="domain")return{operation:"upsert_domain",value:{id:j,name:j,owner:k,parent:v||void 0,exports:[]}};if(t.kind==="area")return{operation:"upsert_area",value:{id:j,domain:g,name:V||j,description:he||void 0,intentExamples:G(ye),references:G(be)}};if(t.kind==="entity")return{operation:"upsert_entity",value:{id:j,domain:g,dbtModel:$,areaId:x||void 0,businessName:Q||void 0,businessContext:U||void 0,conceptRefs:G(q),analyticalRole:ne,status:S,owner:k||void 0,grain:R||void 0,keys:G(W)}};if(t.kind==="contract")return{operation:"upsert_contract",value:{id:j,domain:g,entities:G(yt),blocks:G(m),status:"draft",owner:k,requiredEvaluation:!0,purpose:J||void 0,metricRefs:G(we),dimensions:G(vt),allowedFilters:G(St),requiredFilters:G(rn),evaluationRefs:G(an)}};if(t.kind==="export")return{operation:"upsert_export",value:{id:j,domain:g,entity:dn||void 0,metrics:G(we),blocks:G(m),allowedKeys:G(cn),allowedDimensions:G(vt),allowedFilters:G(St),purposes:G(un),consumerDomains:G(pn),classification:hn||void 0,status:xe,owner:k||void 0}};if(t.kind==="import")return{operation:"upsert_import",value:{id:j||void 0,domain:g,exportRef:xn,purpose:J,status:xe,owner:k||void 0}};const p=Ws(ae),E=!l||l.from===L&&l.to===M&&JSON.stringify(l.keys)===JSON.stringify(p)&&l.cardinality===Ue&&l.fanout===Pe?qt:void 0,se=xe==="certified"&&(E==null?void 0:E.status)!=="passed"?"review":xe,te=n.modeling.entities[L],me=n.modeling.entities[M];return{operation:"upsert_relationship",value:{id:j,domain:g,areaId:x||void 0,from:L,to:M,keys:p,cardinality:Ue,fanout:Pe,status:se,owner:k||void 0,ownerDomain:g,verb:Qe||void 0,description:ve||void 0,roles:Xe||et?{from:Xe||void 0,to:et||void 0}:void 0,optionality:{from:tt,to:xt},joinTypes:G(X),aggregation:Ae||De?{measuresFrom:G(Ae),dimensionsFrom:G(De),requiresPreAggregation:Pe!=="safe"}:void 0,attributionBlock:ft||void 0,importRefs:G(mt),evidenceExpiresAt:gt||void 0,crossDomain:(te==null?void 0:te.domain)!==(me==null?void 0:me.domain),validation:E,certifiedAgainst:se==="certified"&&(te!=null&&te.grain)&&(me!=null&&me.grain)?{from:{grain:te.grain,keys:te.keys},to:{grain:me.grain,keys:me.keys}}:void 0}}},Mo=async()=>{try{Ve(!0),Je(null);const p=fn();ko(p),At(await le.previewModelingChange(p,n.snapshotId))}catch(p){Je(p instanceof Error?p.message:String(p))}finally{Ve(!1)}},zo=async()=>{try{Ve(!0),Je(null);const p=fn();if(p.operation!=="upsert_relationship")return;const P=await le.validateModelingRelationship(p.value,n.snapshotId);st(P),Je(P.status==="passed"?"Warehouse proof passed. Preview the source change to save it.":P.message??"Validation failed."),At(null)}catch(p){Je(p instanceof Error?p.message:String(p))}finally{Ve(!1)}},Do=async()=>{if(!(!wt||!Et))try{Ve(!0),await le.applyModelingChange(Et,wt.fingerprint,n.snapshotId),await c(Et)}catch(p){Je(p instanceof Error?p.message:String(p))}finally{Ve(!1)}},gn=Object.entries(n.modeling.entities).map(([p,P])=>{const E=n.dbtProvenance.nodes[P.dbtUniqueId];return{value:p,label:P.businessName||P.localId||P.id,description:`${P.domain} · ${(E==null?void 0:E.relation)??(E==null?void 0:E.name)??P.dbtUniqueId}`,keywords:[P.qualifiedId,P.businessContext??"",P.analyticalRole??""]}}),qe=_t[((Pn=n.modeling.entities[L])==null?void 0:Pn.dbtUniqueId)??""],Le=_t[((Nn=n.modeling.entities[M])==null?void 0:Nn.dbtUniqueId)??""],yn=((qe==null?void 0:qe.columns)??[]).map(p=>({value:p.name,label:p.name,description:[p.type,p.description].filter(Boolean).join(" · ")||"dbt column"})),bn=((Le==null?void 0:Le.columns)??[]).map(p=>({value:p.name,label:p.name,description:[p.type,p.description].filter(Boolean).join(" · ")||"dbt column"})),Ct=yn.map(p=>p.value).filter(p=>bn.some(P=>P.value.toLowerCase()===p.toLowerCase())).slice(0,5),$e=ae?ae.split(",").map(p=>{const[P="",E=""]=p.split("=").map(se=>se.trim());return{from:P,to:E}}):[{from:"",to:""}],jn=(p,P,E)=>{const se=$e.map((te,me)=>me===p?{...te,[P]:E}:te);He(se.map(te=>`${te.from}=${te.to}`).join(", ")),st(void 0)},Bo=p=>{const P=$e.filter((E,se)=>se!==p);He(P.map(E=>`${E.from}=${E.to}`).join(", ")),st(void 0)},$o=()=>He([...$e.filter(p=>p.from||p.to),{from:"",to:""}].map(p=>`${p.from}=${p.to}`).join(", ")),vn=t.kind==="entity"?!!(g&&j&&$):t.kind==="relationship"?!!(g&&j&&L&&M&&$e.some(p=>p.from&&p.to)&&$e.every(p=>p.from&&p.to)):!0,Ro=t.kind==="domain"?"Create Domain Package":t.kind==="area"?u?"Edit model area":"Create model area":t.kind==="entity"?d?"Edit business entity":"Add dbt model":t.kind==="contract"?"Create analytical contract":t.kind==="export"?"Publish domain export":t.kind==="import"?"Request domain import":l?"Edit relationship":"Create relationship";return e.jsx(mo,{title:Ro,t:i,onClose:r,children:wt?e.jsxs("div",{children:[e.jsx("p",{style:{margin:"0 0 12px",fontSize:12,color:i.textSecondary},children:"Review the exact Domain Package source change before it is written."}),wt.patches.map(p=>e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("strong",{style:{fontSize:12},children:p.path}),e.jsx("pre",{style:Us(i),children:p.after})]},p.path)),kt&&e.jsx(ce,{text:kt,t:i}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx(K,{t:i,onClick:()=>At(null),children:"Back"}),e.jsx(K,{primary:!0,t:i,onClick:()=>void Do(),disabled:Tt,children:"Apply to Domain Package"})]})]}):e.jsxs("div",{style:{display:"grid",gap:12},children:[t.kind!=="domain"&&e.jsx(w,{label:"Domain",children:e.jsx(de,{value:g,onChange:b,values:Object.keys(n.modeling.packages),t:i})}),t.kind!=="relationship"&&e.jsx(w,{label:t.kind==="entity"?"Entity id":t.kind==="area"?"Area id":t.kind==="contract"?"Contract id":t.kind==="export"?"Export id":t.kind==="import"?"Import id (optional)":"Domain id",children:e.jsx(O,{value:j,onChange:f,t:i,placeholder:"stable_snake_case_id"})}),t.kind==="domain"&&e.jsx(w,{label:"Parent domain (optional)",children:e.jsx(de,{value:v,onChange:B,values:Object.keys(n.modeling.packages),t:i})}),t.kind==="area"&&e.jsxs(e.Fragment,{children:[e.jsx(ce,{text:"A Model Area is one small, reviewable source file. It filters the same domain graph; it never creates a competing semantic model.",t:i}),e.jsx(w,{label:"Area name",children:e.jsx(O,{value:V,onChange:re,t:i,placeholder:"Customer lifecycle"})}),e.jsx(w,{label:"Business question or scope",children:e.jsx(O,{value:he,onChange:Re,t:i,placeholder:"How customers progress from first order to repeat purchase."})}),e.jsx(w,{label:"Example questions (comma-separated)",children:e.jsx(O,{value:ye,onChange:We,t:i,placeholder:"Which customers made a second purchase?"})}),e.jsx(w,{label:"Read-only boundary entities (comma-separated)",children:e.jsx(O,{value:be,onChange:ze,t:i,placeholder:"customer"})})]}),t.kind==="entity"&&e.jsxs(e.Fragment,{children:[e.jsx(to,{current:$?2:1,labels:["Find dbt model","Add business meaning","Review source change"],t:i}),e.jsx(ce,{text:"Search by model name, relation, or source path. Results stay bounded even when the dbt project has thousands of models.",t:i}),e.jsx(w,{label:"Model area",children:e.jsx(de,{value:x,onChange:y,values:Object.values(n.modeling.areas).filter(p=>p.domain===g).map(p=>p.localId),labels:Object.fromEntries(Object.values(n.modeling.areas).filter(p=>p.domain===g).map(p=>[p.localId,p.name])),t:i})}),e.jsx(w,{label:"dbt model",children:e.jsx(qs,{value:$,onChange:T,selectedNode:n.dbtProvenance.nodes[$],domain:g,t:i})}),Te&&e.jsx(no,{title:Te.name,detail:`${Te.relation??Te.uniqueId} · ${Te.columns.length} columns${(On=Te.dqlMeta)!=null&&On.grain?` · grain: ${Te.dqlMeta.grain}`:""}`,t:i}),e.jsx(w,{label:"Business name",children:e.jsx(O,{value:Q,onChange:D,t:i,placeholder:"Customer order"})}),e.jsx(w,{label:"Business context",children:e.jsx(O,{value:U,onChange:Y,t:i,placeholder:"One order used to understand repeat purchasing and revenue."})}),e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"Business concepts",children:e.jsx(O,{value:q,onChange:N,t:i,placeholder:"customer_lifecycle, revenue"})}),e.jsx(w,{label:"Analytical role",children:e.jsx(de,{value:ne,onChange:p=>ue(p),values:["event","dimension","snapshot","bridge","unknown"],t:i})})]}),e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"Grain override (optional)",children:e.jsx(O,{value:R,onChange:A,t:i,placeholder:"Use dbt meta.dql by default"})}),e.jsx(w,{label:"Key overrides (optional)",children:e.jsx(O,{value:W,onChange:Z,t:i,placeholder:"customer_id, order_id"})})]}),e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"Lifecycle",children:e.jsx(de,{value:S,onChange:p=>C(p),values:["draft","review","certified","deprecated"],t:i})}),e.jsx(w,{label:"Owner",children:e.jsx(O,{value:k,onChange:I,t:i,placeholder:"team@company.com"})})]})]}),t.kind==="relationship"&&e.jsxs(e.Fragment,{children:[e.jsx(to,{current:!L||!M?1:$e.some(p=>p.from&&p.to)?3:2,labels:["Choose models","Match join keys","Review policy"],t:i}),e.jsx(ce,{text:"Search business names or dbt relations, then match columns from only those two models. DQL keeps the relationship in draft until warehouse validation passes.",t:i}),e.jsx(w,{label:"Model area",children:e.jsx(de,{value:x,onChange:y,values:Object.values(n.modeling.areas).filter(p=>p.domain===g).map(p=>p.localId),labels:Object.fromEntries(Object.values(n.modeling.areas).filter(p=>p.domain===g).map(p=>[p.localId,p.name])),t:i})}),e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"From entity",children:e.jsx(zt,{ariaLabel:"From entity",value:L,onChange:p=>{Se(p),st(void 0)},options:gn,placeholder:"Search source model…",t:i})}),e.jsx(w,{label:"To entity",children:e.jsx(zt,{ariaLabel:"To entity",value:M,onChange:p=>{oe(p),st(void 0)},options:gn.filter(p=>p.value!==L),placeholder:"Search target model…",t:i})})]}),L&&M&&e.jsx(no,{title:`${((An=n.modeling.entities[L])==null?void 0:An.businessName)||((En=n.modeling.entities[L])==null?void 0:En.localId)} → ${((Tn=n.modeling.entities[M])==null?void 0:Tn.businessName)||((qn=n.modeling.entities[M])==null?void 0:qn.localId)}`,detail:`${(qe==null?void 0:qe.columns.length)??0} source columns · ${(Le==null?void 0:Le.columns.length)??0} target columns`,t:i}),e.jsx(w,{label:"Join keys",children:e.jsxs("div",{style:{display:"grid",gap:8},children:[Ct.length>0&&!$e.some(p=>p.from&&p.to)&&e.jsxs("button",{type:"button",onClick:()=>He(`${Ct[0]}=${Ct[0]}`),style:{..._e(i),justifySelf:"start"},children:[e.jsx(ro,{size:13})," Use exact match: ",Ct[0]]}),$e.map((p,P)=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) 24px minmax(0, 1fr) 30px",gap:7,alignItems:"center"},children:[e.jsx(zt,{ariaLabel:`Source join column ${P+1}`,value:p.from,onChange:E=>jn(P,"from",E),options:yn,placeholder:L?"Source column…":"Choose source first",disabled:!L||!qe,t:i}),e.jsx("span",{"aria-hidden":"true",style:{color:i.textMuted,textAlign:"center"},children:"→"}),e.jsx(zt,{ariaLabel:`Target join column ${P+1}`,value:p.to,onChange:E=>jn(P,"to",E),options:bn,placeholder:M?"Target column…":"Choose target first",disabled:!M||!Le,t:i}),e.jsx("button",{type:"button","aria-label":"Remove join key",title:"Remove join key",onClick:()=>Bo(P),style:fe(i),children:e.jsx(ut,{size:14})})]},`${P}:${p.from}:${p.to}`)),e.jsxs("button",{type:"button",onClick:$o,style:{..._e(i),justifySelf:"start"},children:[e.jsx(ke,{size:13})," Add key pair"]})]})}),j&&e.jsxs("div",{style:{color:i.textMuted,fontSize:9.5},children:["Relationship id: ",e.jsx("code",{children:j})]}),e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"Cardinality",children:e.jsx(de,{value:Ue,onChange:p=>Pt(p),values:["unknown","one_to_one","one_to_many","many_to_one","many_to_many"],t:i})}),e.jsx(w,{label:"Fanout policy",children:e.jsx(de,{value:Pe,onChange:p=>pt(p),values:["safe","attribution_required","unsafe","unknown"],t:i})})]}),e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"Business verb (optional)",children:e.jsx(O,{value:Qe,onChange:Ze,t:i,placeholder:"belongs to"})}),e.jsx(w,{label:"Description (optional)",children:e.jsx(O,{value:ve,onChange:Ke,t:i,placeholder:"Why this relationship exists"})})]}),L&&M&&((Ln=n.modeling.entities[L])==null?void 0:Ln.domain)!==((_n=n.modeling.entities[M])==null?void 0:_n.domain)&&e.jsx(ce,{text:"This is a cross-domain relationship. Add the approved provider import in Advanced governance before certification.",t:i}),e.jsx("button",{type:"button",onClick:()=>Io(p=>!p),style:{..._e(i),justifySelf:"start",padding:"6px 0"},children:mn?"Hide advanced governance":"Advanced governance and aggregation"}),mn&&e.jsxs("div",{style:{display:"grid",gap:12,padding:12,border:`1px solid ${i.headerBorder}`,borderRadius:8,background:i.cellBg},children:[e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"Allowed join types",children:e.jsx(O,{value:X,onChange:je,t:i,placeholder:"left, inner"})}),e.jsx(w,{label:"Lifecycle",children:e.jsx(de,{value:xe??"draft",onChange:p=>H(p),values:["draft","review","certified","deprecated"],t:i})})]}),e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"From role",children:e.jsx(O,{value:Xe,onChange:ht,t:i})}),e.jsx(w,{label:"To role",children:e.jsx(O,{value:et,onChange:Ne,t:i})})]}),e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"From optionality",children:e.jsx(de,{value:tt,onChange:p=>nt(p),values:["required","optional","unknown"],t:i})}),e.jsx(w,{label:"To optionality",children:e.jsx(de,{value:xt,onChange:p=>Oe(p),values:["required","optional","unknown"],t:i})})]}),e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"Measures allowed from",children:e.jsx(O,{value:Ae,onChange:ee,t:i,placeholder:"order"})}),e.jsx(w,{label:"Dimensions allowed from",children:e.jsx(O,{value:De,onChange:Nt,t:i,placeholder:"customer"})})]}),e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"Required import refs",children:e.jsx(O,{value:mt,onChange:Ot,t:i,placeholder:"commerce.customer@1"})}),e.jsx(w,{label:"Attribution block",children:e.jsx(O,{value:ft,onChange:Ee,t:i,placeholder:"growth.revenue_by_channel"})})]}),e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"Evidence expires",children:e.jsx(O,{value:gt,onChange:ot,t:i,placeholder:"2026-12-31"})}),e.jsx(w,{label:"Owner",children:e.jsx(O,{value:k,onChange:I,t:i,placeholder:"team@company.com"})})]})]}),qt&&e.jsx(xo,{evidence:qt,t:i})]}),t.kind==="contract"&&e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Covered entities",children:e.jsx(O,{value:yt,onChange:bt,t:i,placeholder:"order, customer"})}),e.jsx(w,{label:"Certified blocks",children:e.jsx(O,{value:m,onChange:z,t:i,placeholder:"orders_360"})}),e.jsx(w,{label:"Decision purpose",children:e.jsx(O,{value:J,onChange:Be,t:i,placeholder:"Revenue reporting"})}),e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"Metrics",children:e.jsx(O,{value:we,onChange:jt,t:i})}),e.jsx(w,{label:"Dimensions",children:e.jsx(O,{value:vt,onChange:sn,t:i})})]}),e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"Allowed filters",children:e.jsx(O,{value:St,onChange:ln,t:i})}),e.jsx(w,{label:"Required filters",children:e.jsx(O,{value:rn,onChange:fo,t:i})})]}),e.jsx(w,{label:"Evaluation refs",children:e.jsx(O,{value:an,onChange:go,t:i,placeholder:"revenue_accuracy"})})]}),t.kind==="export"&&e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Exported entity",children:e.jsx(de,{value:dn,onChange:yo,values:Object.keys(n.modeling.entities).filter(p=>{var P;return((P=n.modeling.entities[p])==null?void 0:P.domain)===g}),t:i})}),e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"Allowed keys",children:e.jsx(O,{value:cn,onChange:bo,t:i})}),e.jsx(w,{label:"Allowed dimensions",children:e.jsx(O,{value:vt,onChange:sn,t:i})})]}),e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"Metrics",children:e.jsx(O,{value:we,onChange:jt,t:i})}),e.jsx(w,{label:"Blocks",children:e.jsx(O,{value:m,onChange:z,t:i})})]}),e.jsx(w,{label:"Allowed filters",children:e.jsx(O,{value:St,onChange:ln,t:i})}),e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"Approved purposes",children:e.jsx(O,{value:un,onChange:jo,t:i,placeholder:"revenue reporting"})}),e.jsx(w,{label:"Consumer domains",children:e.jsx(O,{value:pn,onChange:vo,t:i,placeholder:"growth"})})]}),e.jsxs("div",{style:ie,children:[e.jsx(w,{label:"Classification",children:e.jsx(O,{value:hn,onChange:So,t:i})}),e.jsx(w,{label:"Lifecycle",children:e.jsx(de,{value:xe??"draft",onChange:p=>H(p),values:["draft","review","certified","deprecated"],t:i})})]})]}),t.kind==="import"&&e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Provider export",children:e.jsx(de,{value:xn,onChange:wo,values:Object.values(((Fn=n.modeling.interfaces)==null?void 0:Fn.exports)??{}).map(p=>`${p.domain}.${p.localId}@${p.version}`),t:i})}),e.jsx(w,{label:"Exact analytical purpose",children:e.jsx(O,{value:J,onChange:Be,t:i,placeholder:"Revenue by acquisition channel"})}),e.jsx(w,{label:"Lifecycle",children:e.jsx(de,{value:xe??"draft",onChange:p=>H(p),values:["draft","review","certified","deprecated"],t:i})})]}),t.kind!=="entity"&&t.kind!=="relationship"&&t.kind!=="area"&&e.jsx(w,{label:"Owner",children:e.jsx(O,{value:k,onChange:I,t:i,placeholder:"team@company.com"})}),kt&&e.jsx(ce,{text:kt,t:i}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[t.kind==="relationship"&&e.jsxs(K,{t:i,onClick:()=>void zo(),disabled:Tt||!vn,children:[e.jsx(lo,{size:14})," Validate in warehouse"]}),e.jsx(K,{primary:!0,t:i,onClick:()=>void Mo(),disabled:Tt||!vn,children:"Preview source change"})]})]})})}function ks({data:t,domain:n,t:o,onOpen:s}){var l,d,u;const i=Object.values(t.modeling.entities).filter(h=>!n||h.domain===n),r=n?t.modeling.packages[n]:void 0,c=n?((l=t.domainAssets)==null?void 0:l[n])??{}:Object.values(t.domainAssets??{}).reduce((h,g)=>{for(const[b,x]of Object.entries(g))h[b]=[...h[b]??[],...x];return h},{});return e.jsxs(Ie,{children:[e.jsx(Me,{title:(r==null?void 0:r.id)??"Domains",detail:r?"Business context for reusable blocks, safe models, and agent instructions.":"Choose a domain to work with its blocks, modeling, and skills.",t:o}),r&&e.jsxs("div",{style:{display:"grid",gap:16,maxWidth:980},children:[e.jsxs("section",{style:{border:`1px solid ${o.headerBorder}`,borderRadius:8,background:o.cellBg,display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(175px, 1fr))"},children:[e.jsx(Wt,{label:"Owner",value:r.owner??"Not declared",t:o}),e.jsx(Wt,{label:"Parent",value:r.parent??"Top-level domain",t:o}),e.jsx(Wt,{label:"Source",value:r.filePath,t:o})]}),e.jsxs("section",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[e.jsx("h3",{style:{margin:0,fontSize:12},children:"Continue building"}),e.jsxs("span",{style:{color:o.textMuted,fontSize:10},children:["Everything here is scoped to ",r.id,"."]})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(190px, 1fr))",gap:8},children:[{id:"blocks",title:"Blocks",count:((d=c.blocks)==null?void 0:d.length)??0,detail:"Reusable analytics.",icon:e.jsx(Zt,{size:16})},{id:"diagram",title:"Modeling",count:i.length,detail:"Models and relationships.",icon:e.jsx(so,{size:16})},{id:"knowledge",title:"Knowledge 360",count:Object.values(t.modeling.relationships).filter(h=>{var g,b;return((g=t.modeling.entities[h.from])==null?void 0:g.domain)===n||((b=t.modeling.entities[h.to])==null?void 0:b.domain)===n}).length,detail:"Governed routes and evidence.",icon:e.jsx(io,{size:16})},{id:"skills",title:"Skills",count:((u=c.skills)==null?void 0:u.length)??0,detail:"Agent instructions.",icon:e.jsx(Xt,{size:16})}].map(h=>e.jsxs("button",{type:"button",onClick:()=>s(h.id),style:Vs(o),children:[e.jsx("span",{style:{display:"grid",placeItems:"center",width:28,height:28,borderRadius:6,color:o.accent,background:`${o.accent}12`},children:h.icon}),e.jsxs("span",{style:{flex:1,minWidth:0,display:"grid",gap:2,textAlign:"left"},children:[e.jsx("b",{style:{fontSize:11},children:h.title}),e.jsx("span",{style:{color:o.textSecondary,fontSize:10},children:h.detail})]}),e.jsx("strong",{style:{color:o.accent,fontSize:16},children:h.count})]},h.id))})]})]})]})}function Wt({label:t,value:n,t:o}){return e.jsxs("div",{style:{minWidth:0,padding:"10px 12px",borderRight:`1px solid ${o.headerBorder}`},children:[e.jsx("div",{style:{color:o.textMuted,fontSize:9,fontWeight:800,textTransform:"uppercase",letterSpacing:".05em"},children:t}),e.jsx("div",{title:n,style:{marginTop:4,color:o.textSecondary,fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n})]})}function Cs({search:t,onSearch:n,items:o,onPick:s,t:i}){var b;const[r,c]=a.useState(!1),l=a.useRef(null),d=t.trim().toLowerCase(),u=d?o.filter(x=>x.label.toLowerCase().includes(d)||x.sublabel.toLowerCase().includes(d)).sort((x,y)=>x.type===y.type?x.label.localeCompare(y.label):x.type==="model"?-1:1).slice(0,14):[],h=x=>x==="dimension"?"var(--status-success)":x==="bridge"?"var(--status-warning)":x==="event"||x==="snapshot"?"var(--accent)":"var(--text-tertiary)",g=r&&d?(b=l.current)==null?void 0:b.getBoundingClientRect():void 0;return e.jsxs("label",{ref:l,style:{position:"relative",width:210,flex:"0 0 210px"},children:[e.jsx(Rt,{size:12,style:{position:"absolute",left:7,top:8,color:i.textMuted}}),e.jsx("input",{"aria-label":"Search diagram",value:t,onChange:x=>{n(x.target.value),c(!0)},onFocus:()=>c(!0),placeholder:"Find model or column",style:{...ge(i),padding:"6px 7px 6px 24px"}}),g&&e.jsxs(e.Fragment,{children:[e.jsx("div",{onClick:()=>c(!1),style:{position:"fixed",inset:0,zIndex:60}}),e.jsx("div",{style:{position:"fixed",top:g.bottom+5,left:g.left,zIndex:61,width:300,maxHeight:340,overflow:"auto",background:i.cellBg,border:`1px solid ${i.headerBorder}`,borderRadius:9,boxShadow:"0 12px 30px rgba(26,26,26,0.16)",padding:4},children:u.length===0?e.jsx("div",{style:{padding:"10px 10px",fontSize:11.5,color:i.textMuted,fontFamily:i.font},children:"No matching model or column."}):u.map((x,y)=>e.jsxs("button",{type:"button",onMouseDown:j=>{j.preventDefault(),s(x.recordKey),c(!1)},style:{width:"100%",display:"flex",alignItems:"center",gap:8,textAlign:"left",padding:"7px 8px",border:"none",borderRadius:6,background:"transparent",cursor:"pointer",fontFamily:i.font},children:[e.jsx("span",{style:{width:7,height:7,borderRadius:999,background:h(x.role),flexShrink:0}}),e.jsx("span",{style:{flex:1,minWidth:0,fontSize:12,fontWeight:x.type==="model"?650:500,color:i.textPrimary,fontFamily:i.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:x.label}),e.jsx("span",{style:{flexShrink:0,fontSize:9,fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",color:i.textMuted},children:x.type==="model"?"model":x.sublabel})]},`${x.type}-${x.recordKey}-${x.label}-${y}`))})]})]})}function Is({modelingView:t,columnMode:n,search:o,layoutMode:s,density:i,visibleLimit:r,totalEntities:c,dimUnrelated:l,showEdgeLabels:d,showLegend:u,fullscreen:h,onBindModel:g,onRelationship:b,onNewArea:x,onModelingView:y,onColumnMode:j,onSearch:f,searchItems:k,onPickModel:I,onLayoutMode:v,onDensity:B,onVisibleLimit:$,onDimUnrelated:T,onEdgeLabels:Q,onLegend:D,onFullscreen:U,onExport:Y,onReset:q,t:N}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,minHeight:50,padding:"0 10px",borderBottom:`1px solid ${N.headerBorder}`,background:N.headerBg,flexWrap:"nowrap",overflowX:"auto",scrollbarWidth:"thin"},children:[e.jsxs("div",{role:"group","aria-label":"Modeling view",style:{display:"inline-flex",alignItems:"center",gap:2,padding:2,border:`1px solid ${N.headerBorder}`,borderRadius:7,background:N.appBg,flexShrink:0},children:[e.jsx("button",{type:"button",onClick:()=>y("business"),style:{border:"none",borderRadius:5,padding:"4px 11px",fontSize:11.5,fontWeight:600,cursor:"pointer",fontFamily:N.font,whiteSpace:"nowrap",background:t==="business"?"var(--accent-dim)":"transparent",color:t==="business"?N.accent:N.textMuted},children:"Business modeling"}),e.jsx("button",{type:"button",onClick:()=>y("data"),style:{border:"none",borderRadius:5,padding:"4px 11px",fontSize:11.5,fontWeight:600,cursor:"pointer",fontFamily:N.font,whiteSpace:"nowrap",background:t==="data"?"var(--accent-dim)":"transparent",color:t==="data"?N.accent:N.textMuted},children:"Data modeling"})]}),e.jsxs("button",{type:"button",onClick:g,style:Kt(N,!0),children:[e.jsx(ke,{size:13})," Add model"]}),e.jsxs("button",{type:"button",onClick:b,style:Kt(N),children:[e.jsx(Ge,{size:13})," Connect"]}),e.jsxs("button",{type:"button",onClick:x,style:Kt(N),children:[e.jsx(Fe,{size:13})," New area"]}),t==="data"&&e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:5,color:N.textMuted,fontSize:10},children:[e.jsx(co,{size:13}),e.jsxs("select",{"aria-label":"Visible columns",value:n,onChange:ne=>j(ne.target.value),style:{...ge(N),width:104,padding:"5px 6px"},children:[e.jsx("option",{value:"keys",children:"Keys only"}),e.jsx("option",{value:"relevant",children:"Relevant"}),e.jsx("option",{value:"all",children:"All columns"})]})]}),e.jsx(Cs,{search:o,onSearch:f,items:k,onPick:I,t:N}),e.jsxs("select",{"aria-label":"Diagram layout",value:s,onChange:ne=>{v(ne.target.value),q()},style:{...ge(N),width:94,padding:"5px 6px"},children:[e.jsx("option",{value:"auto",children:"Auto"}),e.jsx("option",{value:"grid",children:"Grid"}),e.jsx("option",{value:"star",children:"Star"})]}),e.jsxs("select",{"aria-label":"Diagram density",value:i,onChange:ne=>B(ne.target.value),style:{...ge(N),width:92,padding:"5px 6px"},children:[e.jsx("option",{value:"compact",children:"Compact"}),e.jsx("option",{value:"normal",children:"Normal"}),e.jsx("option",{value:"wide",children:"Wide"})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:4,color:N.textMuted,fontSize:9.5},children:["Canvas ",e.jsxs("select",{"aria-label":"Visible model limit",value:r||50,onChange:ne=>$(Number(ne.target.value)),style:{...ge(N),width:94,padding:"5px 6px"},children:[e.jsx("option",{value:25,children:"25 models"}),e.jsx("option",{value:50,children:"50 models"}),e.jsx("option",{value:100,children:"100 models"}),e.jsx("option",{value:200,children:"200 max"})]})]}),e.jsx("button",{"aria-label":"Dim unrelated models",title:"Dim unrelated models",onClick:()=>T(!l),style:{...fe(N),color:l?N.accent:N.textMuted},children:e.jsx(To,{size:14})}),e.jsx("button",{"aria-label":"Toggle relationship labels",title:"Toggle relationship labels",onClick:()=>Q(!d),style:{...fe(N),color:d?N.accent:N.textMuted},children:e.jsx(Ge,{size:14})}),e.jsx("button",{"aria-label":"Relationship legend",title:"Relationship legend",onClick:()=>D(!u),style:{...fe(N),color:u?N.accent:N.textMuted},children:e.jsx(Fe,{size:14})}),e.jsx("button",{"aria-label":"Export diagram as SVG",title:"Export diagram as SVG",onClick:Y,style:fe(N),children:e.jsx(qo,{size:14})}),e.jsx("button",{"aria-label":h?"Exit fullscreen":"Fullscreen diagram",title:h?"Exit fullscreen":"Fullscreen diagram",onClick:U,style:fe(N),children:h?e.jsx(ut,{size:14}):e.jsx(ao,{size:14})}),e.jsx("button",{"aria-label":"Reset to automatic layout",title:"Reset to automatic layout",onClick:q,style:fe(N),children:e.jsx(Zo,{size:14})})]})}function Ms({t}){return e.jsxs("div",{style:{display:"flex",gap:14,padding:"7px 12px",borderBottom:`1px solid ${t.headerBorder}`,background:t.headerBg,color:t.textSecondary,fontSize:9.5},children:[[["Safe certified","#2e9b63"],["Validated review","#5b73d6"],["Attribution / draft","#9a6b2f"],["Stale certification","#d47822"]].map(([n,o])=>e.jsxs("span",{style:{display:"flex",gap:5,alignItems:"center"},children:[e.jsx("i",{style:{display:"inline-block",width:18,height:3,background:o,borderRadius:2}}),n]},n)),e.jsx("span",{style:{marginLeft:"auto"},children:"1:1 · 1:N · N:1 · N:N"})]})}function zs(){const t=document.querySelector("#dql-modeling-diagram .react-flow__renderer");if(!(t instanceof HTMLElement))return;const n=t.cloneNode(!0),o=t.getBoundingClientRect(),s=new XMLSerializer().serializeToString(n),i=`<svg xmlns="http://www.w3.org/2000/svg" width="${Math.ceil(o.width)}" height="${Math.ceil(o.height)}"><foreignObject width="100%" height="100%"><div xmlns="http://www.w3.org/1999/xhtml">${s}</div></foreignObject></svg>`,r=URL.createObjectURL(new Blob([i],{type:"image/svg+xml"})),c=document.createElement("a");c.href=r,c.download="dql-domain-model.svg",c.click(),URL.revokeObjectURL(r)}function Ht({data:t,domain:n,kinds:o,title:s,detail:i,t:r}){var l;const c=n?((l=t.domainAssets)==null?void 0:l[n])??{}:Object.values(t.domainAssets??{}).reduce((d,u)=>{for(const[h,g]of Object.entries(u))d[h]=[...d[h]??[],...g];return d},{});return e.jsxs(Ie,{children:[e.jsx(Me,{title:s,detail:i,t:r}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(250px, 1fr))",gap:12},children:o.map(d=>{var u,h;return e.jsxs("section",{style:ct(r),children:[e.jsxs("div",{style:{display:"flex",gap:7,alignItems:"center"},children:[e.jsx(Dt,{size:14,color:r.accent}),e.jsx("b",{style:{textTransform:"capitalize"},children:d}),e.jsx(Ye,{t:r,children:((u=c[d])==null?void 0:u.length)??0})]}),(h=c[d])!=null&&h.length?c[d].map(g=>e.jsx("code",{style:{display:"block",padding:"7px 0",borderBottom:`1px solid ${r.headerBorder}`,color:r.textSecondary,fontSize:10},children:g},g)):e.jsxs("p",{style:{color:r.textMuted,fontSize:11},children:["No ",d," in this domain yet."]})]},d)})})]})}function Ds({data:t,domain:n,t:o}){var g,b;const{state:s,dispatch:i}=$t(),[r,c]=a.useState(null),[l,d]=a.useState(null),u=[...new Set(n?((b=(g=t.domainAssets)==null?void 0:g[n])==null?void 0:b.blocks)??[]:Object.values(t.domainAssets??{}).flatMap(x=>x.blocks??[]))].sort(),h=async x=>{c(x),d(null);try{if(n)try{window.localStorage.setItem("dql.block-studio.domain",n)}catch{}const y=s.files.find(f=>f.path===x)??{name:x.split("/").at(-1)??x,path:x,type:"block",folder:x.split("/").slice(0,-1).join("/")};s.files.some(f=>f.path===x)||i({type:"FILE_ADDED",file:y});const j=await le.openBlockStudio(x);i({type:"OPEN_BLOCK_STUDIO",file:y,payload:j})}catch(y){d(y instanceof Error?y.message:String(y))}finally{c(null)}};return e.jsxs(Ie,{children:[e.jsx(Me,{title:"Blocks",detail:n?`Reusable blocks owned by ${n}. Select one to open the exact source in Block Studio.`:"All reusable blocks grouped across the current Domain Packages. Select one to open the exact source in Block Studio.",t:o}),l?e.jsx(ce,{text:l,t:o}):null,u.length?e.jsx("div",{style:{display:"grid",gap:10},children:u.map(x=>{var f;const y=(x.split("/").at(-1)??x).replace(/\.dql$/i,""),j=(f=Object.entries(t.domainAssets??{}).find(([,k])=>{var I;return(I=k.blocks)==null?void 0:I.includes(x)}))==null?void 0:f[0];return e.jsxs("button",{type:"button",onClick:()=>void h(x),"aria-label":`Open block ${y}`,style:{...ct(o),width:"100%",textAlign:"left",cursor:"pointer"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(Zt,{size:14,color:o.accent}),e.jsx("b",{children:y}),n?null:e.jsx(Ye,{t:o,children:j??"shared"}),r===x?e.jsx(Ye,{t:o,children:"Opening…"}):null]}),e.jsx("code",{style:{display:"block",marginTop:7,color:o.textMuted,fontSize:10},children:x})]},x)})}):e.jsx(Ce,{title:"No domain blocks yet",detail:"Create a block in Block Studio and assign this domain to make it appear here.",t:o})]})}function Qn({data:t,domain:n,kind:o,t:s}){var k,I;const{state:i,dispatch:r}=$t(),[c,l]=a.useState([]),[d,u]=a.useState(!0),[h,g]=a.useState(null),[b,x]=a.useState(null);a.useEffect(()=>{let v=!0;return u(!0),(n?le.getRelatedDomainProducts(n):le.getAllRelatedDomainProducts()).then(B=>{v&&l(B[o])}).catch(()=>{v&&l([])}).finally(()=>{v&&u(!1)}),()=>{v=!1}},[n,o]);const y=n?((I=(k=t.domainAssets)==null?void 0:k[n])==null?void 0:I[o])??[]:Object.values(t.domainAssets??{}).flatMap(v=>v[o]??[]),j=o==="notebooks"?"Notebooks":"Apps",f=async v=>{const B=String(v.id??v.filePath??v.title??v.name??"product");g(B),x(null);try{if(o==="apps"){const U=String(v.id??Zn(String(v.filePath??"")));if(!U)throw new Error("This App has no stable id to open.");r({type:"OPEN_APP",appId:U,experience:"view",section:"dashboards"});return}const $=String(v.filePath??"");if(!$)throw new Error("This Notebook has no source path to open.");const T=i.files.find(U=>U.path===$)??{name:$.split("/").at(-1)??String(v.title??B),path:$,type:"notebook",folder:$.split("/").slice(0,-1).join("/"),...typeof v.ownerDomain=="string"?{ownerDomain:v.ownerDomain}:{},usesDomains:Array.isArray(v.usesDomains)?v.usesDomains.map(String):[]};i.files.some(U=>U.path===$)||r({type:"FILE_ADDED",file:T});const{content:Q}=await le.readNotebook($),D=Lo($,Q);r({type:"OPEN_FILE",file:T,cells:D.cells,title:D.title,metadata:D.metadata})}catch($){x($ instanceof Error?$.message:String($))}finally{g(null)}};return e.jsxs(Ie,{children:[e.jsx(Me,{title:n?`Related ${j}`:`All ${j}`,detail:n?`${j} are global shared products related to ${n}. This backlink does not create a second copy inside the Domain Package.`:`All global ${j.toLowerCase()} across Domain Packages. Select a domain above to narrow by owner/uses-domain metadata.`,t:s}),b?e.jsx(ce,{text:b,t:s}):null,d?e.jsx(Ce,{title:`Loading related ${j.toLowerCase()}…`,detail:"Resolving global product backlinks from the compiled project snapshot.",t:s}):c.length?e.jsx("div",{style:{display:"grid",gap:10},children:c.map(v=>{const B=String(v.id??v.filePath??v.title??"product"),$=Array.isArray(v.usesDomains)?v.usesDomains.map(String):[],T=String(v.name??v.title??B);return e.jsxs("button",{type:"button",onClick:()=>void f(v),"aria-label":`Open ${o==="notebooks"?"notebook":"app"} ${T}`,style:{...ct(s),width:"100%",textAlign:"left",cursor:"pointer"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(Dt,{size:14,color:s.accent}),e.jsx("b",{children:T}),v.lifecycle?e.jsx(Ye,{t:s,children:String(v.lifecycle)}):null,h===B?e.jsx(Ye,{t:s,children:"Opening…"}):null]}),e.jsx("p",{style:{color:s.textSecondary,fontSize:11,margin:"7px 0 0"},children:String(v.purpose??"No analytical purpose declared yet.")}),e.jsx("code",{style:{display:"block",marginTop:7,color:s.textMuted,fontSize:10},children:String(v.filePath??"")}),e.jsxs("div",{style:{marginTop:7,color:s.textMuted,fontSize:10},children:["Owner: ",String(v.ownerDomain??"Shared")," · Uses: ",$.join(", ")||"none declared"]})]},B)})}):y.length?e.jsxs("div",{style:{display:"grid",gap:10},children:[e.jsx(ce,{text:"These paths use the legacy domain-local layout. They remain readable during migration, but new products should be global and declare ownerDomain / usesDomains.",t:s}),y.map(v=>e.jsxs("button",{type:"button",onClick:()=>void f({id:o==="apps"?Zn(v):v,filePath:v}),"aria-label":`Open ${o==="notebooks"?"notebook":"app"} ${v}`,style:{...ct(s),width:"100%",textAlign:"left",cursor:"pointer"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(Dt,{size:14,color:s.accent}),e.jsx("code",{style:{color:s.textPrimary,fontSize:11},children:v})]}),e.jsx("p",{style:{color:s.textMuted,fontSize:10,margin:"7px 0 0"},children:"Legacy backlink · migrate without duplicating the product."})]},v))]}):e.jsx(Ce,{title:`No related ${j.toLowerCase()} yet`,detail:`Create the ${o==="notebooks"?"notebook":"app"} from the global ${j} surface, then declare this domain in its product context to make the backlink appear here.`,t:s})]})}function Zn(t){const n=t.replace(/\\/g,"/").split("/").filter(Boolean),o=n.indexOf("apps");return o>=0?n[o+1]??"":""}function Bs({domain:t,selectedId:n,data:o,t:s,onOpenSkills:i,onDraftRelationship:r}){const[c,l]=a.useState(null),[d,u]=a.useState([]),[h,g]=a.useState(!1),[b,x]=a.useState(null),y=async()=>{try{g(!0),x(null);const f=await le.startContextBootstrap({ai:!0});l(f),u(f.candidates.filter(k=>{var I;return!t||k.kind!=="domain"||((I=k.domain)==null?void 0:I.id)===t}).map(k=>k.id))}catch(f){x(f instanceof Error?f.message:String(f))}finally{g(!1)}},j=async()=>{if(c)try{g(!0),await le.saveContextBootstrapSelected(c.id,d),x("Selected domain and skill drafts were saved. Review them in Git before activation.")}catch(f){x(f instanceof Error?f.message:String(f))}finally{g(!1)}};return e.jsxs(Ie,{children:[e.jsx(Me,{title:"Modeling Copilot",detail:"AI can propose business context and modeling work from dbt evidence. It writes drafts only; relationships, contracts, blocks, and skills still require explicit review.",t:s,action:e.jsxs(K,{primary:!0,t:s,onClick:()=>void y(),disabled:h,children:[e.jsx(ro,{size:14})," Analyze project"]})}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, minmax(190px, 1fr))",gap:10,marginBottom:18},children:[e.jsx(Ut,{icon:e.jsx(Fe,{size:16}),title:"Domains and concepts",detail:"Detect ownership boundaries, vocabulary, concepts, and candidate subdomains.",t:s}),e.jsx(Ut,{icon:e.jsx(Ge,{size:16}),title:"Relationship proposals",detail:"Suggest keys and cardinality from dbt evidence, then require warehouse validation.",t:s,action:e.jsx("button",{style:_e(s),onClick:r,children:"Draft manually"})}),e.jsx(Ut,{icon:e.jsx(Xt,{size:16}),title:"Domain skills",detail:"Draft governed vocabulary, preferred metrics, blocks, and clarification rules.",t:s,action:e.jsx("button",{style:_e(s),onClick:i,children:"Manage skills"})})]}),e.jsx(ce,{text:`Active scope: ${t??"all domains"}${n?` · focused object: ${n}`:""} · ${Object.keys(o.modeling.entities).length} bindings · ${Object.keys(o.modeling.relationships).length} governed relationships. AI proposals never treat dbt lineage as join proof and never auto-certify.`,t:s}),c&&e.jsxs("div",{style:{marginTop:16},children:[e.jsx("h3",{style:Yt(s),children:"Review proposal pack"}),c.candidates.length?c.candidates.map(f=>{var k,I,v;return e.jsxs("label",{style:{display:"grid",gridTemplateColumns:"20px 110px 1fr 70px",gap:8,padding:"10px 8px",borderBottom:`1px solid ${s.headerBorder}`,fontSize:11},children:[e.jsx("input",{type:"checkbox",checked:d.includes(f.id),onChange:B=>u($=>B.target.checked?[...$,f.id]:$.filter(T=>T!==f.id))}),e.jsx("b",{children:f.kind}),e.jsxs("span",{children:[((k=f.domain)==null?void 0:k.name)??((I=f.domain)==null?void 0:I.id)??((v=f.skill)==null?void 0:v.id)??f.id,e.jsx("small",{style:{display:"block",color:s.textMuted,marginTop:3},children:f.evidence.slice(0,2).join(" · ")||"Evidence review required"})]}),e.jsxs("span",{children:[Math.round(f.confidence*100),"%"]})]},f.id)}):e.jsx(Ce,{title:"No proposals",detail:"The current project evidence did not produce a safe domain or skill proposal.",t:s}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:12},children:e.jsx(K,{primary:!0,t:s,onClick:()=>void j(),disabled:h||d.length===0,children:"Save selected drafts"})})]}),b&&e.jsx("div",{style:{marginTop:12},children:e.jsx(ce,{text:b,t:s})})]})}function Ut({icon:t,title:n,detail:o,t:s,action:i}){return e.jsxs("div",{style:ct(s),children:[e.jsxs("div",{style:{display:"flex",gap:7,color:s.accent},children:[t,e.jsx("b",{style:{color:s.textPrimary},children:n})]}),e.jsx("p",{style:{color:s.textSecondary,fontSize:11,lineHeight:1.5},children:o}),i]})}function $s({data:t,domain:n,t:o,onCreateExport:s,onCreateImport:i}){var l,d;const r=Object.values(((l=t.modeling.interfaces)==null?void 0:l.exports)??{}).filter(u=>!n||u.domain===n),c=Object.values(((d=t.modeling.interfaces)==null?void 0:d.imports)??{}).filter(u=>!n||u.domain===n);return e.jsxs(Ie,{children:[e.jsx(Me,{title:"Cross-domain interfaces",detail:"Domains never join through discovery alone. Providers certify a narrow export; consumers import it for an explicit purpose.",t:o,action:e.jsxs("div",{style:{display:"flex",gap:7},children:[e.jsxs(K,{t:o,onClick:i,children:[e.jsx(ke,{size:14})," Import"]}),e.jsxs(K,{primary:!0,t:o,onClick:s,children:[e.jsx(ke,{size:14})," Export"]})]})}),e.jsx("h3",{style:Yt(o),children:"Published exports"}),r.length?e.jsxs("table",{style:dt,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(_,{children:"Interface"}),e.jsx(_,{children:"Entity"}),e.jsx(_,{children:"Allowed surface"}),e.jsx(_,{children:"Consumers"}),e.jsx(_,{children:"Status"})]})}),e.jsx("tbody",{children:r.map(u=>e.jsxs("tr",{children:[e.jsx(F,{children:e.jsxs("b",{children:[u.domain,".",u.localId,"@",u.version]})}),e.jsx(F,{children:u.entity??"—"}),e.jsx(F,{children:[...u.metrics,...u.blocks,...u.allowedDimensions].join(", ")||"keys only"}),e.jsx(F,{children:u.consumerDomains.join(", ")||"none"}),e.jsx(F,{children:e.jsx(Bt,{status:u.status,t:o})})]},u.qualifiedId))})]}):e.jsx(Ce,{title:"No exports in this scope",detail:"Publish only the entity, metrics, blocks, dimensions, keys, filters, purposes, and consumers another domain may use.",t:o}),e.jsx("h3",{style:Yt(o),children:"Approved imports"}),c.length?e.jsxs("table",{style:dt,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(_,{children:"Import"}),e.jsx(_,{children:"Consumer"}),e.jsx(_,{children:"Provider export"}),e.jsx(_,{children:"Purpose"}),e.jsx(_,{children:"Status"})]})}),e.jsx("tbody",{children:c.map(u=>e.jsxs("tr",{children:[e.jsx(F,{children:e.jsx("b",{children:u.localId})}),e.jsx(F,{children:u.domain}),e.jsx(F,{children:u.exportRef}),e.jsx(F,{children:u.purpose}),e.jsx(F,{children:e.jsx(Bt,{status:u.status,t:o})})]},u.id))})]}):e.jsx(Ce,{title:"No imports in this scope",detail:"A consumer import is required before an automatic cross-domain path can use the provider export.",t:o})]})}function Rs({relationships:t,entities:n,t:o,onSelect:s,onEdit:i}){return e.jsxs(Ie,{children:[e.jsx(Me,{title:"Analytical relationships",detail:"Transformation lineage is context; only these governed edges can prove an analytical join.",t:o}),t.length?e.jsxs("table",{style:dt,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(_,{children:"Relationship"}),e.jsx(_,{children:"Path"}),e.jsx(_,{children:"Cardinality"}),e.jsx(_,{children:"Safety"}),e.jsx(_,{children:"Status"}),e.jsx(_,{children:"Proof"}),e.jsx(_,{})]})}),e.jsx("tbody",{children:t.map(r=>{var c,l,d;return e.jsxs("tr",{onClick:()=>s(r),style:{cursor:"pointer"},children:[e.jsx(F,{children:e.jsx("b",{children:r.localId})}),e.jsxs(F,{children:[r.from," ",e.jsx("span",{style:{color:o.textMuted},children:"→"})," ",r.to,((c=n[r.from])==null?void 0:c.domain)!==((l=n[r.to])==null?void 0:l.domain)&&e.jsx(Ye,{t:o,children:"cross-domain"})]}),e.jsx(F,{children:r.cardinality.replace(/_/g," ")}),e.jsx(F,{children:r.fanout}),e.jsx(F,{children:e.jsx(Bt,{status:r.status,t:o})}),e.jsx(F,{children:r.automaticJoinAllowed?e.jsx("span",{style:{color:"#2e9b63"},children:"certified"}):r.staleCertification?e.jsx("span",{style:{color:"#d47822"},children:"stale"}):((d=r.validation)==null?void 0:d.status)??"not run"}),e.jsx(F,{children:e.jsx("button",{onClick:u=>{u.stopPropagation(),i(r)},style:_e(o),children:"Edit"})})]},r.qualifiedId??r.id)})})]}):e.jsx(Ce,{title:"No join proofs in this domain",detail:"Drag from a source column handle to a target column handle in Domain Model to create a draft, then validate its cardinality and fanout.",t:o})]})}function Ps({data:t,domain:n,t:o,onCreate:s}){const i=Object.values(t.modeling.contracts).filter(r=>!n||r.domain===n);return e.jsxs(Ie,{children:[e.jsx(Me,{title:"Analytical contracts",detail:"Contracts bind governed entities and blocks to evaluation and review requirements.",t:o,action:e.jsxs(K,{primary:!0,t:o,onClick:s,children:[e.jsx(ke,{size:14})," Contract"]})}),i.length?e.jsxs("table",{style:dt,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(_,{children:"Contract"}),e.jsx(_,{children:"Domain"}),e.jsx(_,{children:"Entities"}),e.jsx(_,{children:"Blocks"}),e.jsx(_,{children:"Status"}),e.jsx(_,{children:"Evaluation"})]})}),e.jsx("tbody",{children:i.map(r=>e.jsxs("tr",{children:[e.jsx(F,{children:e.jsx("b",{children:r.id})}),e.jsx(F,{children:r.domain}),e.jsx(F,{children:r.entities.join(", ")||"—"}),e.jsx(F,{children:r.blocks.join(", ")||"—"}),e.jsx(F,{children:e.jsx(Bt,{status:r.status,t:o})}),e.jsx(F,{children:r.requiredEvaluation?"Required":"Optional"})]},r.id))})]}):e.jsx(Ce,{title:"No contracts in this scope",detail:"Create a contract when a set of entities and certified blocks must move through evaluation and review together.",t:o})]})}function Ns({data:t,domain:n,unbound:o,t:s,onBind:i}){const[r,c]=a.useState(""),[l,d]=a.useState(0),u=50,h=new Set(nn(t.modeling,n).map(({entity:f})=>f.dbtUniqueId)),g=r.trim().toLowerCase(),b=Object.values(t.dbtProvenance.nodes).filter(f=>n&&!h.has(f.uniqueId)?!1:g?[f.name,f.uniqueId,f.relation,f.sourcePath].some(k=>String(k??"").toLowerCase().includes(g)):!0),x=Math.max(1,Math.ceil(b.length/u)),y=Math.min(l,x-1),j=b.slice(y*u,(y+1)*u);return e.jsxs(Ie,{children:[e.jsx(Me,{title:"dbt-owned scope",detail:`Read on demand from ${t.dbtProvenance.manifestPath}. Columns, descriptions, tests, and MetricFlow formulas remain dbt-owned.${n?" This view shows dbt models already bound to this domain.":""}`,t:s,action:e.jsxs("label",{style:{position:"relative",width:230},children:[e.jsx(Rt,{size:13,style:{position:"absolute",top:9,left:8,color:s.textMuted}}),e.jsx("input",{"aria-label":"Search dbt scope",value:r,onChange:f=>{c(f.target.value),d(0)},placeholder:"Find model, relation, or path",style:{...ge(s),paddingLeft:27}})]})}),j.length?e.jsxs(e.Fragment,{children:[e.jsxs("table",{style:dt,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(_,{children:"dbt model"}),e.jsx(_,{children:"Relation"}),e.jsx(_,{children:"Source"}),e.jsx(_,{children:"Metadata"}),e.jsx(_,{})]})}),e.jsx("tbody",{children:j.map(f=>{const k=o.some(I=>I.uniqueId===f.uniqueId);return e.jsxs("tr",{children:[e.jsx(F,{children:e.jsx("b",{children:f.name})}),e.jsx(F,{children:f.relation??"—"}),e.jsx(F,{children:f.sourcePath??"—"}),e.jsx(F,{children:Object.entries(f.available).filter(([,I])=>I).map(([I])=>I).join(", ")}),e.jsx(F,{children:k?e.jsx("button",{onClick:()=>i(f.uniqueId),style:_e(s),children:"Bind"}):e.jsx("span",{style:{color:"#2e9b63"},children:"Bound"})})]},f.uniqueId)})})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:12,color:s.textMuted,fontSize:10},children:[e.jsxs("span",{children:[b.length," models · page ",y+1," of ",x]}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx(K,{t:s,disabled:y===0,onClick:()=>d(f=>Math.max(0,f-1)),children:"Previous"}),e.jsx(K,{t:s,disabled:y>=x-1,onClick:()=>d(f=>Math.min(x-1,f+1)),children:"Next"})]})]})]}):e.jsx(Ce,{title:r?"No dbt models match this search":n?"No dbt models are bound to this domain":"No dbt models found",detail:n?"Use Bind model in Domain Model to add a dbt model without copying its schema.":"Compile the dbt project, then refresh Domain Studio.",t:s})]})}function Os({entity:t,detail:n,relationships:o=[],t:s,onEdit:i,onEditDbtSource:r,onSelectRelationship:c,onDelete:l}){var b,x,y,j;const d=uo(t.analyticalRole),u=new Set(t.keys.length?t.keys:((b=n==null?void 0:n.dqlMeta)==null?void 0:b.keys)??[]),h={fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",color:s.textMuted,margin:"0 0 5px"},g=o.filter(f=>f.from===t.id||f.to===t.id||f.from===t.localId||f.to===t.localId);return e.jsxs(on,{t:s,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,marginBottom:12},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:2.5,background:d,flexShrink:0}}),e.jsx("span",{style:{flex:1,minWidth:0,fontSize:13.5,fontWeight:700,color:s.textPrimary,fontFamily:s.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.businessName||t.localId}),e.jsx("span",{style:{flexShrink:0,fontSize:9,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.05em",color:d},children:t.analyticalRole??"entity"})]}),e.jsx("p",{style:{margin:"0 0 12px",color:s.textSecondary,fontSize:12,lineHeight:1.6},children:t.businessContext||`Add the DQL-owned business context for ${t.localId}. dbt descriptions remain physical-source documentation.`}),e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("div",{style:h,children:"dbt binding"}),e.jsx("div",{style:{fontSize:11,fontFamily:s.fontMono,color:s.textPrimary,background:"var(--bg-1)",border:"1px solid var(--border-subtle)",borderRadius:7,padding:"7px 9px",overflowWrap:"anywhere"},children:(n==null?void 0:n.relation)??t.dbtUniqueId})]}),e.jsxs("div",{style:{marginBottom:12},children:[e.jsxs("div",{style:h,children:["Columns · ",(n==null?void 0:n.columns.length)??"…"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column"},children:n==null?void 0:n.columns.slice(0,16).map(f=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,padding:"4px 2px",borderBottom:"1px solid var(--border-subtle)",fontSize:11.5},children:[e.jsx("span",{style:{flexShrink:0,width:17,fontSize:8.5,fontWeight:700,fontFamily:s.fontMono,color:u.has(f.name)?"var(--pk)":/(^|_)id$/.test(f.name)?"var(--fk)":"transparent"},children:u.has(f.name)?"PK":/(^|_)id$/.test(f.name)?"FK":"·"}),e.jsx("span",{style:{flex:1,minWidth:0,color:s.textSecondary,fontFamily:s.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:f.name}),e.jsx("span",{style:{flexShrink:0,fontSize:10,color:s.textMuted,fontFamily:s.fontMono},children:f.type??"—"})]},f.name))})]}),g.length>0&&c?e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("div",{style:h,children:"Relationships"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:g.map(f=>e.jsxs("button",{type:"button",onClick:()=>c(f),style:{display:"flex",alignItems:"center",gap:7,padding:"6px 8px",borderRadius:7,border:"1px solid var(--border-subtle)",background:"var(--bg-1)",cursor:"pointer",textAlign:"left",fontFamily:s.font,fontSize:11,color:s.textSecondary},children:[e.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:f.localId}),e.jsx("span",{style:{fontFamily:s.fontMono,fontSize:10,color:s.textMuted,flexShrink:0},children:f.cardinality==="one_to_one"?"1:1":f.cardinality==="one_to_many"?"1:N":f.cardinality==="many_to_one"?"N:1":"N:N"})]},f.qualifiedId??f.localId))})]}):null,e.jsxs("details",{style:{marginBottom:12},children:[e.jsx("summary",{style:{...h,cursor:"pointer"},children:"More metadata"}),e.jsx(pe,{label:"concepts",value:((x=t.conceptRefs)==null?void 0:x.join(", "))||"Not mapped",t:s}),e.jsx(pe,{label:"owner",value:t.owner??"Not declared",t:s}),e.jsx(pe,{label:"grain",value:t.grain??((y=n==null?void 0:n.dqlMeta)==null?void 0:y.grain)??"Not declared",t:s}),e.jsx(pe,{label:"keys",value:(t.keys.length?t.keys:((j=n==null?void 0:n.dqlMeta)==null?void 0:j.keys)??[]).join(", ")||"Not declared",t:s}),e.jsx(pe,{label:"source",value:(n==null?void 0:n.sourcePath)??t.sourcePath,t:s}),e.jsx(pe,{label:"dbt description",value:(n==null?void 0:n.description)??"Not declared",t:s})]}),e.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[e.jsx(K,{primary:!0,t:s,onClick:i,children:"Edit entity"}),e.jsx(K,{t:s,onClick:r,children:"Preview dbt source patch"}),l?e.jsx(K,{t:s,danger:!0,onClick:l,children:"Delete entity"}):null]})]})}function As({entity:t,detail:n,snapshotId:o,t:s,onClose:i,onApplied:r}){const c=n.columns.filter(B=>B.tests.length>0).map(B=>`${B.name}: ${B.tests.join(", ")}`).join(`
|
|
22
|
+
`),[l,d]=a.useState(n.description??""),[u,h]=a.useState(c),[g,b]=a.useState(null),[x,y]=a.useState(!1),[j,f]=a.useState(null),k=()=>({uniqueId:t.dbtUniqueId,description:l,columns:u.split(/\r?\n/).flatMap(B=>{const $=B.indexOf(":");if($<1)return[];const T=B.slice(0,$).trim(),Q=G(B.slice($+1));return T?[{name:T,tests:Q}]:[]})}),I=async()=>{try{y(!0),f(null),b(await le.previewDbtSourcePatch(k(),o))}catch(B){f(B instanceof Error?B.message:String(B))}finally{y(!1)}},v=async()=>{if(g)try{y(!0),f(null),await le.applyDbtSourcePatch(k(),g.fingerprint,g.snapshotId),await r()}catch(B){f(B instanceof Error?B.message:String(B))}finally{y(!1)}};return e.jsxs(mo,{title:`Edit dbt source · ${n.name}`,t:s,onClose:i,children:[e.jsx(ce,{text:"dbt owns descriptions and tests. DQL will preview a guarded patch to the dbt YAML source; no dbt metadata is copied into the Domain Package.",t:s}),g?e.jsxs("div",{style:{display:"grid",gap:10},children:[e.jsxs("div",{style:{color:s.textSecondary,fontSize:11},children:["Source: ",e.jsx("code",{children:g.patch.path})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[e.jsx(Xn,{title:"Current dbt YAML",source:g.patch.before||"# New dbt schema YAML",t:s}),e.jsx(Xn,{title:"Proposed dbt YAML",source:g.patch.after,t:s})]}),j&&e.jsx(ce,{text:j,t:s}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:7},children:[e.jsx(K,{t:s,onClick:()=>b(null),children:"Back"}),e.jsx(K,{primary:!0,t:s,disabled:x||!g.patch.changed,onClick:()=>void v(),children:g.patch.changed?"Apply dbt source patch":"No changes"})]})]}):e.jsxs("div",{style:{display:"grid",gap:12},children:[e.jsx(w,{label:"Model description",children:e.jsx("textarea",{"aria-label":"Model description",value:l,onChange:B=>d(B.target.value),rows:5,style:{...ge(s),resize:"vertical"}})}),e.jsx(w,{label:"Column tests (one column per line)",children:e.jsx("textarea",{"aria-label":"Column tests",value:u,onChange:B=>h(B.target.value),rows:6,placeholder:"order_id: unique, not_null",style:{...ge(s),resize:"vertical",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace"}})}),e.jsx("p",{style:{margin:0,color:s.textMuted,fontSize:10},children:"Descriptions/tests stay in dbt YAML. Business meaning, relationships, contracts, and policies stay in the DQL Domain Package."}),j&&e.jsx(ce,{text:j,t:s}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:7},children:[e.jsx(K,{t:s,onClick:i,children:"Cancel"}),e.jsx(K,{primary:!0,t:s,disabled:x,onClick:()=>void I(),children:"Preview source patch"})]})]})]})}function Xn({title:t,source:n,t:o}){return e.jsxs("section",{children:[e.jsx("strong",{style:{fontSize:10},children:t}),e.jsx("pre",{tabIndex:0,style:{maxHeight:360,overflow:"auto",whiteSpace:"pre-wrap",background:o.appBg,border:`1px solid ${o.headerBorder}`,borderRadius:6,padding:10,fontSize:9.5,color:o.textSecondary},children:n})]})}function Es({relationship:t,t:n,onEdit:o,onDelete:s}){var i,r,c;return e.jsxs(on,{t:n,children:[e.jsx(Fs,{title:t.localId,subtitle:`${t.from} → ${t.to}`,t:n}),e.jsx(K,{primary:!0,t:n,onClick:o,children:"Validate / edit"}),e.jsx("h3",{style:oo(n),children:"Business meaning"}),e.jsx(pe,{label:"verb",value:t.verb??"Not described",t:n}),e.jsx("p",{style:{margin:"0 0 8px",color:n.textSecondary,fontSize:11,lineHeight:1.55},children:t.description||`${t.from} relates to ${t.to}. Add a business description so agents can distinguish this route from similarly shaped joins.`}),e.jsx("h3",{style:oo(n),children:"Join route"}),e.jsx(pe,{label:"cardinality",value:t.cardinality,t:n}),e.jsx(pe,{label:"fanout",value:t.fanout,t:n}),e.jsx(pe,{label:"lifecycle",value:t.status,t:n}),e.jsx(pe,{label:"join keys",value:t.keys.map(l=>`${l.from} = ${l.to}`).join(", "),t:n}),e.jsx(pe,{label:"endpoint roles",value:[(i=t.roles)==null?void 0:i.from,(r=t.roles)==null?void 0:r.to].filter(Boolean).join(" → ")||"Not declared",t:n}),e.jsx(pe,{label:"allowed joins",value:((c=t.joinTypes)==null?void 0:c.join(", "))||"left",t:n}),e.jsx(pe,{label:"automatic agent join",value:t.automaticJoinAllowed?"Allowed":"Blocked",t:n}),t.validation?e.jsx(xo,{evidence:t.validation,t:n}):e.jsx(ce,{text:"No warehouse proof has been captured. This edge cannot authorize automatic SQL joins.",t:n}),e.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginTop:12},children:[e.jsx(K,{primary:!0,t:n,onClick:o,children:"Edit relationship"}),s?e.jsx(K,{t:n,danger:!0,onClick:s,children:"Delete relationship"}):null]})]})}function Ts({data:t,domainEntities:n,domainRelationships:o,t:s,onSelectRelationship:i}){var b;const r=((b=n[0])==null?void 0:b.domain)??"All domains",c=o.filter(x=>{var y;return((y=x.validation)==null?void 0:y.status)==="passed"}).length,l=n.filter(x=>!!x.dbtUniqueId).length,d=n.filter(x=>!x.businessContext),u={fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",color:s.textMuted,margin:"14px 0 5px"},h=(x,y)=>e.jsxs("div",{style:{border:"1px solid var(--border-subtle)",borderRadius:9,padding:"10px 12px",background:"var(--bg-1)"},children:[e.jsx("div",{style:{fontSize:18,fontWeight:700,color:s.textPrimary},children:x}),e.jsx("div",{style:{fontSize:10.5,color:s.textMuted},children:y})]}),g=(x,y)=>e.jsxs("span",{style:{display:"flex",alignItems:"flex-start",gap:7,fontSize:11.5,color:s.textSecondary,lineHeight:1.45},children:[e.jsx("span",{style:{color:x?"var(--status-success)":"var(--status-warning)",flexShrink:0,fontWeight:700},children:x?"✓":"△"}),y]},y);return e.jsxs(on,{t:s,children:[e.jsxs("div",{style:{fontSize:11,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",color:s.textMuted},children:[r," model"]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8,marginTop:12},children:[h(n.length,n.length===1?"entity":"entities"),h(o.length,o.length===1?"relationship":"relationships")]}),e.jsx("p",{style:{margin:"12px 0 0",color:s.textSecondary,fontSize:12,lineHeight:1.6},children:"Select an entity to see its columns and dbt binding, or click a relationship label to review its join, cardinality, and business context."}),e.jsx("div",{style:u,children:"Model health"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[o.length>0?g(c===o.length,c===o.length?"All relationships have join proofs":`${c} of ${o.length} relationships have join proofs`):g(!1,"No relationships yet — drag between column handles to create one"),g(l===n.length&&n.length>0,n.length===0?"No entities bound yet — use Bind model":`${l} of ${n.length} entities bound to dbt`),d.length>0?g(!1,`${d[0].localId}${d.length>1?` and ${d.length-1} more`:""} ha${d.length>1?"ve":"s"} no business description`):n.length>0?g(!0,"Every entity has a business description"):null]}),e.jsx("div",{style:u,children:"Relationships"}),o.length?o.map(x=>e.jsxs("button",{onClick:()=>i(x),style:{display:"flex",alignItems:"center",gap:7,width:"100%",textAlign:"left",border:"1px solid var(--border-subtle)",borderRadius:7,background:"var(--bg-1)",color:s.textSecondary,padding:"6px 8px",marginBottom:4,cursor:"pointer",fontSize:11,fontFamily:s.font},children:[e.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:x.localId}),e.jsx("span",{style:{fontFamily:s.fontMono,fontSize:10,color:s.textMuted,flexShrink:0},children:x.cardinality==="one_to_one"?"1:1":x.cardinality==="one_to_many"?"1:N":x.cardinality==="many_to_one"?"N:1":"N:N"})]},x.qualifiedId)):e.jsx("p",{style:{color:s.textMuted,fontSize:10.5,margin:0},children:"Drag between two column handles to create the first relationship."}),e.jsx("div",{style:u,children:"Ownership boundary"}),e.jsx("p",{style:{color:s.textSecondary,fontSize:11,lineHeight:1.55,margin:0},children:"dbt owns tables, columns, descriptions, tests, and metrics. DQL owns domain membership, analytical identity, safe relationship proof, contracts, certified blocks, and agent policy. Shared apps and notebooks reference this domain without moving inside it."})]})}function xo({evidence:t,t:n}){return e.jsxs("div",{style:{marginTop:12,padding:10,border:`1px solid ${t.status==="passed"?"#2e9b6355":"#c94b5555"}`,background:t.status==="passed"?"#2e9b630d":"#c94b550d",borderRadius:7,fontSize:11},children:[e.jsx("b",{style:{color:t.status==="passed"?"#2e9b63":"#c94b55"},children:t.status==="passed"?"Warehouse proof passed":"Warehouse proof failed"}),e.jsxs("div",{style:{color:n.textSecondary,marginTop:7,lineHeight:1.55},children:["Rows: ",t.fromRows," → ",t.toRows,e.jsx("br",{}),"Joined: ",t.joinedRows," · unmatched: ",t.unmatchedFrom,e.jsx("br",{}),"Max rows/key: ",t.maxFromPerKey," → ",t.maxToPerKey]})]})}function eo({t,title:n,detail:o,status:s}){return e.jsx("div",{style:{flex:1,display:"grid",placeItems:"center",background:t.appBg,color:t.textPrimary},children:e.jsxs("div",{style:{maxWidth:560,textAlign:"center"},children:[e.jsx(Fe,{size:34,color:t.accent}),e.jsx("h1",{style:{fontSize:20},children:n}),e.jsx("p",{style:{color:t.textSecondary,lineHeight:1.6},children:o}),s&&e.jsx("code",{style:{fontSize:12},children:s})]})})}function mo({title:t,t:n,onClose:o,children:s}){return e.jsx("div",{style:{position:"fixed",inset:0,zIndex:100,background:"#0008",display:"grid",placeItems:"center",padding:20},onMouseDown:i=>{i.target===i.currentTarget&&o()},children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":t,tabIndex:-1,onKeyDown:i=>{i.key==="Escape"&&o()},style:{width:"min(720px, 94vw)",maxHeight:"88vh",overflow:"auto",background:n.appBg,border:`1px solid ${n.headerBorder}`,borderRadius:12,boxShadow:"0 24px 80px #0006"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",padding:"15px 18px",borderBottom:`1px solid ${n.headerBorder}`},children:[e.jsx("strong",{children:t}),e.jsx("button",{"aria-label":`Close ${t}`,title:"Close",onClick:o,style:fe(n),children:e.jsx(ut,{size:17})})]}),e.jsx("div",{style:{padding:18},children:s})]})})}function to({current:t,labels:n,t:o}){return e.jsx("div",{"aria-label":`Step ${t} of ${n.length}`,style:{display:"grid",gridTemplateColumns:`repeat(${n.length}, minmax(0, 1fr))`,gap:6},children:n.map((s,i)=>{const r=i+1,c=r===t,l=r<t;return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0,color:c?o.textPrimary:o.textMuted,fontSize:10,fontWeight:c?700:550},children:[e.jsx("span",{style:{display:"grid",placeItems:"center",width:20,height:20,flex:"0 0 auto",borderRadius:999,border:`1px solid ${c||l?o.accent:o.headerBorder}`,background:l?o.accent:c?"var(--accent-dim)":o.appBg,color:l?"#fff":c?o.accent:o.textMuted},children:l?"✓":r}),e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s})]},s)})})}function no({title:t,detail:n,t:o}){return e.jsxs("div",{style:{display:"grid",gap:3,padding:"9px 11px",border:`1px solid ${o.headerBorder}`,borderRadius:7,background:o.cellBg},children:[e.jsx("strong",{style:{fontSize:11},children:t}),e.jsx("span",{style:{color:o.textMuted,fontSize:9.5,overflowWrap:"anywhere"},children:n})]})}function zt({ariaLabel:t,value:n,onChange:o,options:s,placeholder:i,disabled:r=!1,t:c}){const[l,d]=a.useState(!1),[u,h]=a.useState(""),g=s.find(x=>x.value===n),b=ys(s,u,50);return e.jsxs("div",{style:{position:"relative",minWidth:0},children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Rt,{size:13,"aria-hidden":"true",style:{position:"absolute",left:9,top:"50%",transform:"translateY(-50%)",color:c.textMuted,pointerEvents:"none"}}),e.jsx("input",{role:"combobox","aria-label":t,"aria-expanded":l,"aria-controls":l?"modeling-search-results":void 0,disabled:r,value:l?u:(g==null?void 0:g.label)??n,placeholder:i,onFocus:()=>{d(!0),h("")},onBlur:()=>{d(!1),h("")},onChange:x=>{d(!0),h(x.target.value)},onKeyDown:x=>{x.key==="Escape"&&(d(!1),h(""))},style:{...ge(c),paddingLeft:29,paddingRight:n?29:8,opacity:r?.6:1}}),n&&!r&&e.jsx("button",{type:"button","aria-label":"Clear selection",onMouseDown:x=>x.preventDefault(),onClick:()=>{o(""),h(""),d(!0)},style:{...fe(c),position:"absolute",right:3,top:"50%",transform:"translateY(-50%)",width:24,height:24,border:"none"},children:e.jsx(ut,{size:13})})]}),l&&!r&&e.jsxs("div",{id:"modeling-search-results",role:"listbox",style:{position:"absolute",zIndex:90,top:"calc(100% + 4px)",left:0,right:0,maxHeight:230,overflowY:"auto",border:`1px solid ${c.headerBorder}`,borderRadius:7,background:c.cellBg,boxShadow:"0 12px 32px #0004",padding:4},children:[b.length?b.map(x=>e.jsxs("button",{type:"button",role:"option","aria-selected":x.value===n,onMouseDown:y=>y.preventDefault(),onClick:()=>{o(x.value),d(!1),h("")},style:{display:"grid",width:"100%",gap:2,padding:"8px 9px",border:"none",borderRadius:5,textAlign:"left",background:x.value===n?"var(--accent-dim)":"transparent",color:c.textPrimary,cursor:"pointer"},children:[e.jsx("strong",{style:{fontSize:10.5},children:x.label}),x.description&&e.jsx("span",{style:{color:c.textMuted,fontSize:9,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:x.description})]},x.value)):e.jsx("div",{style:{padding:12,color:c.textMuted,fontSize:10},children:"No matching results."}),s.length>50&&e.jsxs("div",{style:{padding:"6px 9px 4px",borderTop:`1px solid ${c.headerBorder}`,color:c.textMuted,fontSize:9},children:["Showing the best 50 of ",s.length.toLocaleString(),". Refine your search for a specific result."]})]})]})}function qs({value:t,onChange:n,selectedNode:o,t:s}){const[i,r]=a.useState(""),[c,l]=a.useState(!1),[d,u]=a.useState(!1),[h,g]=a.useState(0),[b,x]=a.useState([]);return a.useEffect(()=>{let y=!1;const j=window.setTimeout(()=>{u(!0),le.getDbtModelInventory({q:i,limit:50}).then(f=>{y||(g(f.total),x(f.items.map(k=>{var v;const I=k;return{value:I.uniqueId??"",label:I.name??I.uniqueId??"Unnamed model",description:`${I.relation??I.sourcePath??I.uniqueId}${I.binding?` · already bound to ${I.binding.domain??"a domain"}`:" · unbound"}`,keywords:[I.sourcePath??"",((v=I.binding)==null?void 0:v.businessName)??""]}}).filter(k=>k.value)))}).catch(()=>{y||x([])}).finally(()=>{y||u(!1)})},140);return()=>{y=!0,window.clearTimeout(j)}},[i]),e.jsxs("div",{style:{position:"relative"},children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Rt,{size:13,"aria-hidden":"true",style:{position:"absolute",left:9,top:"50%",transform:"translateY(-50%)",color:s.textMuted,pointerEvents:"none"}}),e.jsx("input",{role:"combobox","aria-label":"Search dbt models","aria-expanded":c,value:c?i:(o==null?void 0:o.name)??t,placeholder:"Search model, relation, or path…",onFocus:()=>{l(!0),r("")},onBlur:()=>{l(!1),r("")},onChange:y=>{r(y.target.value),l(!0)},onKeyDown:y=>{y.key==="Escape"&&l(!1)},style:{...ge(s),paddingLeft:29,paddingRight:t?29:8}}),t&&e.jsx("button",{type:"button","aria-label":"Clear dbt model",onMouseDown:y=>y.preventDefault(),onClick:()=>{n(""),l(!0)},style:{...fe(s),position:"absolute",right:3,top:"50%",transform:"translateY(-50%)",width:24,height:24,border:"none"},children:e.jsx(ut,{size:13})})]}),c&&e.jsxs("div",{role:"listbox",style:{position:"absolute",zIndex:90,top:"calc(100% + 4px)",left:0,right:0,maxHeight:260,overflowY:"auto",border:`1px solid ${s.headerBorder}`,borderRadius:7,background:s.cellBg,boxShadow:"0 12px 32px #0004",padding:4},children:[d&&e.jsx("div",{style:{padding:10,color:s.textMuted,fontSize:10},children:"Searching project inventory…"}),!d&&b.map(y=>e.jsxs("button",{type:"button",role:"option","aria-selected":y.value===t,onMouseDown:j=>j.preventDefault(),onClick:()=>{n(y.value),l(!1),r("")},style:{display:"grid",width:"100%",gap:2,padding:"8px 9px",border:"none",borderRadius:5,textAlign:"left",background:y.value===t?"var(--accent-dim)":"transparent",color:s.textPrimary,cursor:"pointer"},children:[e.jsx("strong",{style:{fontSize:10.5},children:y.label}),e.jsx("span",{style:{color:s.textMuted,fontSize:9,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:y.description})]},y.value)),!d&&!b.length&&e.jsx("div",{style:{padding:10,color:s.textMuted,fontSize:10},children:"No dbt models match this search."}),!d&&h>b.length&&e.jsxs("div",{style:{padding:"6px 9px 4px",borderTop:`1px solid ${s.headerBorder}`,color:s.textMuted,fontSize:9},children:["Showing 50 of ",h.toLocaleString(),". Keep typing to narrow the inventory."]})]})]})}function w({label:t,children:n}){return e.jsxs("label",{style:{display:"grid",gap:6,fontSize:11,fontWeight:650},children:[t,n]})}function O({value:t,onChange:n,t:o,placeholder:s}){return e.jsx("input",{value:t,placeholder:s,onChange:i=>n(i.target.value),style:ge(o)})}function de({value:t,onChange:n,values:o,labels:s,t:i}){return e.jsxs("select",{value:t,onChange:r=>n(r.target.value),style:ge(i),children:[e.jsx("option",{value:"",children:"Select…"}),o.map(r=>e.jsx("option",{value:r,children:(s==null?void 0:s[r])??r},r))]})}function K({children:t,t:n,onClick:o,primary:s,disabled:i,danger:r}){return e.jsx("button",{disabled:i,onClick:o,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6,border:`1px solid ${r?n.error:s?n.accent:n.headerBorder}`,background:r?`${n.error}12`:s?n.accent:n.appBg,color:r?n.error:s?"#fff":n.textPrimary,borderRadius:6,padding:"7px 10px",fontSize:11,fontWeight:650,cursor:i?"wait":"pointer",opacity:i?.65:1},children:t})}function Ls({children:t,title:n,t:o,onClick:s}){return e.jsx("button",{"aria-label":n,title:n,onClick:s,style:fe(o),children:t})}function Ye({children:t,t:n}){return e.jsx("span",{style:{marginLeft:5,border:`1px solid ${n.accent}55`,color:n.accent,background:`${n.accent}10`,borderRadius:999,padding:"3px 7px",fontSize:9,fontWeight:750},children:t})}function _s({children:t,t:n}){return e.jsx("div",{style:{padding:"15px 12px 8px",color:n.textMuted,fontSize:10,fontWeight:750,textTransform:"uppercase",letterSpacing:".07em"},children:t})}function Ie({children:t}){return e.jsx("div",{style:{height:"100%",overflow:"auto",padding:20},children:t})}function Me({title:t,detail:n,t:o,action:s}){return e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:20,alignItems:"start",marginBottom:18},children:[e.jsxs("div",{children:[e.jsx("h2",{style:{margin:0,fontSize:16},children:t}),e.jsx("p",{style:{margin:"5px 0 0",color:o.textSecondary,fontSize:11},children:n})]}),s]})}function Ce({title:t,detail:n,t:o}){return e.jsxs("div",{style:{border:`1px dashed ${o.headerBorder}`,borderRadius:10,padding:30,textAlign:"center"},children:[e.jsx("strong",{children:t}),e.jsx("p",{style:{color:o.textSecondary,fontSize:12},children:n})]})}function on({children:t}){return e.jsx("div",{style:{padding:"4px 14px 20px"},children:t})}function Fs({title:t,subtitle:n,t:o}){return e.jsxs("div",{style:{marginBottom:14},children:[e.jsx("h2",{style:{margin:0,fontSize:16},children:t}),e.jsx("div",{style:{color:o.textMuted,fontSize:11,marginTop:4},children:n})]})}function pe({label:t,value:n,t:o}){return e.jsxs("div",{style:{padding:"9px 0",borderBottom:`1px solid ${o.headerBorder}`},children:[e.jsx("div",{style:{color:o.textMuted,fontSize:9,textTransform:"uppercase",letterSpacing:".05em"},children:t}),e.jsx("div",{style:{fontSize:11,marginTop:4,overflowWrap:"anywhere"},children:n})]})}function Bt({status:t,t:n}){const o=t==="certified"?"#2e9b63":t==="deprecated"?n.textMuted:t==="review"?"#377cc8":"#9a6b2f";return e.jsx("span",{style:{color:o,background:`${o}15`,borderRadius:999,padding:"3px 7px",fontSize:10},children:t})}function ce({text:t,t:n}){return e.jsx("div",{style:{borderLeft:`3px solid ${n.accent}`,background:`${n.accent}0d`,padding:"9px 10px",color:n.textSecondary,fontSize:11,lineHeight:1.5},children:t})}function _({children:t}){return e.jsx("th",{style:{textAlign:"left",padding:"9px 10px",fontSize:9,textTransform:"uppercase",letterSpacing:".05em",opacity:.65},children:t})}function F({children:t}){return e.jsx("td",{style:{padding:"11px 10px",borderTop:"1px solid var(--border-subtle)",fontSize:11},children:t})}function G(t){return t.split(",").map(n=>n.trim()).filter(Boolean)}function Ws(t){return G(t).map(n=>{const[o,s]=n.split("=").map(i=>i.trim());if(!o||!s)throw new Error(`Invalid join key pair "${n}". Use from_key=to_key.`);return{from:o,to:s}})}function Hs(){try{return JSON.parse(localStorage.getItem("dql-modeling-preferences")??"{}")}catch{return{}}}const ie={display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},Kt=(t,n=!1)=>({display:"inline-flex",alignItems:"center",gap:5,flex:"0 0 auto",border:`1px solid ${n?t.accent:t.headerBorder}`,borderRadius:6,background:n?"var(--accent-dim)":t.appBg,color:n?t.accent:t.textSecondary,padding:"5px 8px",fontSize:10.5,fontWeight:650,cursor:"pointer",whiteSpace:"nowrap"}),dt={width:"100%",borderCollapse:"collapse"},Us=t=>({whiteSpace:"pre-wrap",maxHeight:300,overflow:"auto",padding:12,borderRadius:7,background:t.activityBarBg,color:t.textSecondary,fontSize:10,lineHeight:1.5}),ge=t=>({width:"100%",boxSizing:"border-box",border:`1px solid ${t.headerBorder}`,background:t.cellBg,color:t.textPrimary,borderRadius:6,padding:"8px 9px",fontSize:11}),fe=t=>({border:`1px solid ${t.headerBorder}`,background:t.appBg,color:t.textSecondary,borderRadius:6,padding:7,display:"grid",placeItems:"center",cursor:"pointer"}),Ks=(t,n,o)=>({width:"100%",minHeight:30,padding:o?"6px 8px 6px 14px":"7px 8px",display:"flex",alignItems:"center",gap:7,border:0,borderRadius:6,background:n?`${t.accent}18`:"transparent",color:n?t.accent:t.textSecondary,fontSize:10.5,fontWeight:n?700:500,textAlign:"left",cursor:"pointer"}),_e=t=>({border:0,background:"transparent",color:t.accent,fontSize:10,fontWeight:650,cursor:"pointer"}),oo=t=>({margin:"18px 0 7px",paddingBottom:7,borderBottom:`1px solid ${t.headerBorder}`,fontSize:11,textTransform:"uppercase",letterSpacing:".05em",color:t.textMuted}),Yt=t=>({margin:"22px 0 10px",paddingBottom:8,borderBottom:`1px solid ${t.headerBorder}`,fontSize:12,color:t.textPrimary}),ct=t=>({border:`1px solid ${t.headerBorder}`,background:t.cellBg,borderRadius:9,padding:14}),Vs=t=>({display:"flex",alignItems:"center",gap:9,minHeight:58,border:`1px solid ${t.headerBorder}`,background:t.cellBg,borderRadius:8,padding:"9px 10px",color:t.textPrimary,cursor:"pointer",fontFamily:t.font});export{ai as DbtFirstModelingPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{c as Ke,u as Ve,t as Xe,r as d,a as g,j as t,G as re,d as Ye,g as ie,P as Je,Y as Ze,ax as et,ay as ke,aj as tt,h as nt,az as rt,S as it}from"./index-BTuliKhK.js";import{E as we}from"./external-link-ZwE5iHsX.js";import{X as st}from"./x-CeNgQwGm.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.
|
package/dist/assets/dql-notebook/assets/{GlobalAiRail-CGvBUci2.js → GlobalAiRail-Cys4n_rq.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as m,t as u,r as c,j as s}from"./index-
|
|
1
|
+
import{u as m,t as u,r as c,j as s}from"./index-BTuliKhK.js";import{U as A}from"./UnifiedAgentRunPanel-BlWAVEwO.js";import{A as g,a as x,b as h}from"./AiSidePanel-BCQB9rVF.js";import{u as b}from"./usePersistedAgentThreadId-CkVFrrjk.js";import"./react-CRB3T2We.js";import"./AgentAnswerCard-CpL2kDCV.js";import"./TrustBadge-DGuHB8kP.js";import"./AiBuildResult-D9t_4sQl.js";import"./user-round-BfrV8U-W.js";import"./triangle-alert-BSdIu2El.js";import"./rotate-ccw-B9v1LTJ0.js";import"./x-CeNgQwGm.js";import"./pencil-Cb45c6WU.js";import"./list-tree-Ced8e_S1.js";import"./wrench-LMCrpa9_.js";import"./arrow-right-BI4cXgOY.js";import"./chevron-up-DSEILnDs.js";import"./minimize-2-CBIAE0XH.js";import"./maximize-2-Cojc6867.js";function O(){const{state:e,dispatch:n}=m(),r=u[e.themeMode],{audience:p,context:t}=e.globalAi,l=t.selectedObject,a=b("global-rail"),[i,d]=c.useState(!1);return s.jsx(g,{t:r,title:t.title??"AI copilot",subtitle:t.scopeHint??"Ask a follow-up about what you are viewing",expanded:i,onToggleExpanded:()=>d(o=>!o),onClose:()=>n({type:"CLOSE_GLOBAL_AI"}),ariaLabel:"App AI",style:{width:i?`min(${x}px, calc(100vw - 96px))`:`min(${h}px, calc(100vw - 64px))`,maxWidth:i?"62vw":"46vw",minWidth:320,flex:"0 0 auto"},children:s.jsx(A,{themeMode:e.themeMode,title:t.title??"AI copilot",scopeHint:t.scopeHint??"Ask a follow-up about what you are viewing",audience:p,selectedObject:l,workspaceContext:t.workspaceContext,examplePrompts:Array.isArray(t.suggestedQuestions)&&t.suggestedQuestions.length>0?t.suggestedQuestions.filter(o=>typeof o=="string").slice(0,4).map(o=>({label:o,prompt:o})):void 0,autoRun:e.globalAi.autoRun?{text:e.globalAi.autoRun.text,mode:e.globalAi.autoRun.mode,nonce:e.globalAi.autoRun.nonce}:void 0,threadId:a.threadId,onThreadIdChange:a.onThreadIdChange,initialMode:"auto"})})}export{O as GlobalAiRail};
|