@eventcatalog/core 5.7.6 → 5.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/analytics/analytics.cjs +1 -1
  2. package/dist/analytics/analytics.js +2 -2
  3. package/dist/analytics/log-build.cjs +1 -1
  4. package/dist/analytics/log-build.js +3 -3
  5. package/dist/{chunk-SLN5D6WP.js → chunk-26C26LFE.js} +1 -1
  6. package/dist/{chunk-E2262TPK.js → chunk-C4L6B5KR.js} +1 -1
  7. package/dist/{chunk-XB4U75TZ.js → chunk-SZU7I2PD.js} +1 -1
  8. package/dist/{chunk-UI2XA4V7.js → chunk-UIJUSHOT.js} +1 -1
  9. package/dist/{chunk-A22MC5P5.js → chunk-WN6ZFSXF.js} +1 -1
  10. package/dist/constants.cjs +1 -1
  11. package/dist/constants.js +1 -1
  12. package/dist/docs/api/02-config.md +1 -1
  13. package/dist/docs/development/00-why-eventcatalog.md +12 -8
  14. package/dist/docs/development/01-adopting-eventcatalog.md +51 -0
  15. package/dist/docs/development/{ask-your-architecture/03-install-skills.md → 01-getting-started/install-skills.md} +10 -4
  16. package/dist/docs/development/01-getting-started/installation.md +5 -1
  17. package/dist/docs/development/ask-your-architecture/01-intro.md +7 -5
  18. package/dist/docs/development/ask-your-architecture/03-mcp-server/getting-started.md +17 -3
  19. package/dist/docs/development/ask-your-architecture/03-mcp-server/introduction.md +3 -0
  20. package/dist/docs/development/ask-your-architecture/06-sync-docs-with-your-code.md +220 -0
  21. package/dist/docs/development/ask-your-architecture/07-catch-breaking-changes.md +142 -0
  22. package/dist/docs/development/components/custom-components/02-create-your-first-component.md +4 -0
  23. package/dist/docs/development/customization/customize-visualizer/00-visualizer-nodes.md +7 -5
  24. package/dist/docs/development/developer-tools/api-catalog.md +1 -1
  25. package/dist/docs/development/{ask-your-architecture/02-llms.txt.md → developer-tools/llms.txt.md} +2 -0
  26. package/dist/docs/development/{ask-your-architecture/03-schemas.txt.md → developer-tools/schemas.txt.md} +1 -1
  27. package/dist/docs/development/developer-tools/ubiquitous-language.txt.md +42 -0
  28. package/dist/docs/development/guides/domains/03-ownership-and-language/02-adding-ubiquitous-language.md +3 -0
  29. package/dist/eventcatalog.cjs +1 -1
  30. package/dist/eventcatalog.js +21 -21
  31. package/dist/federation/federate.js +2 -2
  32. package/dist/generate.cjs +1 -1
  33. package/dist/generate.js +3 -3
  34. package/dist/utils/cli-logger.cjs +1 -1
  35. package/dist/utils/cli-logger.js +2 -2
  36. package/eventcatalog/src/components/Settings/LlmAccessSettingsForm.tsx +23 -3
  37. package/eventcatalog/src/components/SpecificationDownloadButton.astro +24 -0
  38. package/eventcatalog/src/features/auth/middleware/middleware-auth.ts +1 -0
  39. package/eventcatalog/src/features/mcp/apps/generated/viewer.html +1 -1
  40. package/eventcatalog/src/features/mcp/mcp-scoped-tools.ts +7 -4
  41. package/eventcatalog/src/features/mcp/mcp-server.ts +13 -1
  42. package/eventcatalog/src/features/tools/catalog-tools.ts +97 -30
  43. package/eventcatalog/src/pages/api/schemas/services/[id]/[version]/[specification]/index.ts +25 -27
  44. package/eventcatalog/src/pages/discover/[type]/index.astro +9 -2
  45. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/asyncapi/[filename]/[file].ts +7 -0
  46. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/asyncapi/[filename].astro +19 -7
  47. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/generic/[filename]/[file].ts +7 -0
  48. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/generic/[filename].astro +21 -1
  49. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/graphql/[filename]/[file].ts +7 -0
  50. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/graphql/[filename].astro +19 -1
  51. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/spec/[filename]/[file].ts +7 -0
  52. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/spec/[filename].astro +4 -0
  53. package/eventcatalog/src/pages/docs/llm/llms.txt.ts +24 -17
  54. package/eventcatalog/src/pages/docs/llm/schemas.txt.ts +1 -1
  55. package/eventcatalog/src/pages/docs/llm/ubiquitous-language.txt.ts +68 -0
  56. package/eventcatalog/src/pages/docs/services/[id]/asyncapi/[filename]/[file].ts +7 -0
  57. package/eventcatalog/src/pages/docs/services/[id]/graphql/[filename]/[file].ts +7 -0
  58. package/eventcatalog/src/pages/docs/services/[id]/spec/[filename]/[file].ts +7 -0
  59. package/eventcatalog/src/pages/docs/services/_latest-raw-specification-route.ts +37 -0
  60. package/eventcatalog/src/pages/settings/llm-access.astro +2 -0
  61. package/eventcatalog/src/stores/sidebar-store/builders/data-product.ts +7 -3
  62. package/eventcatalog/src/utils/collections/domains.ts +84 -0
  63. package/eventcatalog/src/utils/raw-specification.ts +126 -0
  64. package/package.json +4 -4
  65. package/dist/docs/development/ask-your-architecture/04-agents/01-overview.md +0 -27
  66. package/dist/docs/development/ask-your-architecture/04-agents/02-code-to-docs.md +0 -124
  67. package/dist/docs/development/ask-your-architecture/04-agents/03-breaking-changes.md +0 -170
  68. package/dist/docs/development/ask-your-architecture/04-agents/_category_.json +0 -12
  69. package/dist/{chunk-46TBJZC3.js → chunk-QJ7KKN2D.js} +4 -4
@@ -216,7 +216,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
216
216
  </svg>
217
217
  `,xIe=1024,SIe=768,hz=40;function gz(e){let t={x:e.x-hz,y:e.y-hz,width:e.width+hz*2,height:e.height+hz*2},n=Math.max(xIe,Math.ceil(t.width)),r=Math.max(SIe,Math.ceil(t.height));return{width:n,height:r,viewport:sv(t,n,r,.5,2,0)}}function CIe(e){return Array.from(new Set(e.match(/--ec-[a-z0-9-]+/g)??[]))}function _z(e){return[`* { ${Object.entries(e).map(([e,t])=>`${e}: ${t};`).join(` `)} }`,`.react-flow__edge-path { stroke: var(--ec-edge-stroke, #6b7280); stroke-width: 1.5; fill: none; }`].join(`
218
218
  `)}function wIe(e){let t=new Set;for(let e of Array.from(document.styleSheets)){let n;try{n=e.cssRules}catch{continue}for(let e of Array.from(n))for(let n of CIe(e.cssText))t.add(n)}let n=window.getComputedStyle(e),r={};for(let e of t){let t=n.getPropertyValue(e).trim();t&&(r[e]=t)}return r}var TIe=[`fill`,`fill-opacity`,`stroke`,`stroke-width`,`stroke-dasharray`,`stroke-linecap`,`stroke-linejoin`,`opacity`,`font-family`,`font-size`,`font-weight`,`letter-spacing`,`text-anchor`,`dominant-baseline`];function EIe(e){let t=[];return e.querySelectorAll(`svg, svg *`).forEach(e=>{if(!(e instanceof SVGElement))return;let n=window.getComputedStyle(e),r=e.getAttribute(`style`);for(let t of TIe){let r=n.getPropertyValue(t);r&&e.style.setProperty(t,r)}t.push(()=>{r===null?e.removeAttribute(`style`):e.setAttribute(`style`,r)})}),()=>t.forEach(e=>e())}function vz(e){let t=document.createElement(`style`);t.textContent=_z(wIe(e)),e.appendChild(t);let n=EIe(e);return()=>{n(),t.remove()}}var DIe=e=>new Promise((t,n)=>{let r=new Image;r.onload=()=>t(r),r.onerror=n,r.src=e}),yz=(e,t=1)=>{let n=getComputedStyle(document.documentElement).getPropertyValue(e).trim()||getComputedStyle(document.body).getPropertyValue(e).trim();return n?`rgb(${n} / ${t})`:t===1?`#0f172a`:`rgb(15 23 42 / ${t})`};async function OIe(e,t,{padding:n=0,background:r}){let i=await DIe(e),a=Math.max(t,Math.min(i.width/1200,i.height/500)),o=30*a,s=20*a,c=n*t,l=document.createElement(`canvas`);l.width=i.width+c*2,l.height=i.height+c*2+o+s;let u=l.getContext(`2d`);if(!u)return e;u.drawImage(i,c,c);let[d,f,p,m]=u.getImageData(c,c+i.height-1,1,1).data;u.globalCompositeOperation=`destination-over`,u.fillStyle=r??`rgba(${d}, ${f}, ${p}, ${m/255})`,u.fillRect(0,0,l.width,l.height),u.globalCompositeOperation=`source-over`,await document.fonts?.ready;let h=yz(`--ec-page-text`),g=yz(`--ec-page-text-muted`),_=e=>`${e} ${12*a}px Inter, ui-sans-serif, system-ui, sans-serif`,v=[{label:`Made with `,weight:400,color:g},{label:`EventCatalog`,weight:600,color:h},{label:` · eventcatalog.dev`,weight:400,color:g}],y=v.map(e=>(u.font=_(e.weight),u.measureText(e.label).width)),b=16*a,x=12*a,S=7*a,C=x*2+b+S+y.reduce((e,t)=>e+t,0),w=l.width-C-s,T=i.height+c*2;u.fillStyle=yz(`--ec-card-bg`,.96),u.strokeStyle=yz(`--ec-page-border`),u.lineWidth=a,u.beginPath(),u.roundRect(w,T,C,o,o/2),u.fill(),u.stroke();let E=await DIe(`data:image/svg+xml;charset=utf-8,${encodeURIComponent(bIe.replace(/currentColor/g,h))}`);u.drawImage(E,w+x,T+(o-b)/2,b,b);let ee=w+x+b+S;return u.textBaseline=`middle`,v.forEach((e,t)=>{u.font=_(e.weight),u.fillStyle=e.color,u.fillText(e.label,ee,T+o/2+a),ee+=y[t]}),l.toDataURL(`image/png`)}async function bz(e,t,n={}){try{return await OIe(e,t,n)}catch{return e}}var kIe=200,xz=80,Sz={service:{width:300,height:140},agent:{width:300,height:140},"agent-tool":{width:260,height:120},agentTool:{width:260,height:120},event:{width:240,height:140},command:{width:300,height:120},query:{width:300,height:120},channel:{width:300,height:140},container:{width:300,height:140},"data-product":{width:300,height:140},data:{width:320,height:120},domain:{width:300,height:120},flow:{width:300,height:140},actor:{width:240,height:100},"external-system":{width:300,height:100},step:{width:280,height:100},"message-group":{width:350,height:200},group:{width:kIe,height:xz}},AIe={width:280,height:100},jIe=e=>Sz[e.type||``]||AIe;function Cz(e,t){let n=e.metadata.notes||[],r=e.metadata.owners||[],i={name:e.label,version:e.metadata.version||``,summary:e.metadata.summary||``,deprecated:e.metadata.deprecated===!0,draft:e.metadata.draft===!0,...n.length>0?{notes:n}:{},...r.length>0?{owners:r}:{}};switch(e.type){case`service`:return{mode:`full`,style:t,service:i};case`agent`:return{mode:`full`,style:t,agent:{...i,...e.metadata.model?{model:e.metadata.model}:{},...Array.isArray(e.metadata.tools)?{tools:e.metadata.tools}:{}}};case`agent-tool`:case`agentTool`:return{mode:`full`,style:t,agentTool:{id:e.id,name:e.label,type:e.metadata.type||``,icon:e.metadata.icon||``,url:e.metadata.url||``,description:e.metadata.description||``}};case`event`:case`command`:case`query`:return{mode:`full`,style:t,message:{...i,schema:e.metadata.schema||``,...e.metadata.method?{method:e.metadata.method}:{},...e.metadata.path?{path:e.metadata.path}:{},...Array.isArray(e.metadata.statusCodes)&&e.metadata.statusCodes.length>0?{statusCodes:e.metadata.statusCodes}:{}}};case`channel`:return{mode:`full`,style:t,channel:{...i,protocols:e.metadata.protocols||[],address:e.metadata.address||``,...e.metadata.deliveryGuarantee?{deliveryGuarantee:e.metadata.deliveryGuarantee}:{}}};case`container`:return{mode:`full`,style:t,data:{...i,type:e.metadata.containerType||`Database`}};case`data-product`:return{mode:`full`,style:t,dataProduct:i};case`data`:return{mode:`full`,style:t,data:{...i,type:e.metadata.containerType||`Database`}};case`domain`:return{mode:`full`,style:t,domain:{data:{...i,id:e.id}}};case`flow`:return{mode:`full`,style:t,flow:{data:{...i,id:e.id}}};case`actor`:return{...i,label:e.label,mode:`full`,style:t,id:e.id};case`external-system`:return{mode:`full`,style:t,externalSystem:{label:e.label,...i,id:e.id}};case`step`:return{mode:`full`,style:t,step:{...i,title:e.label,id:e.id}};default:return{...i,style:t,resourceType:e.type}}}async function wz(e,t,{style:n}={}){if(e.length===0)return{nodes:[],edges:[]};let r=new Map(e.map(e=>[e.id,e])),i=new Set(e.filter(t=>t.type===`domain`||e.some(e=>e.parentId===t.id)).map(e=>e.id));return kx({nodes:e.map(e=>{let t=e.parentId&&e.parentId!==e.id&&i.has(e.parentId)?e.parentId:void 0,r={id:e.id,position:{x:0,y:0},...t?{parentId:t,extent:`parent`}:{}};return i.has(e.id)?{...r,type:`group`,data:{mode:`full`,domain:{name:e.label,version:e.metadata.version||``,summary:e.metadata.summary||``}},style:{width:kIe,height:xz,background:`transparent`,border:`none`,padding:0}}:{...r,type:e.type,data:Cz(e,n)}}),edges:t.filter(e=>!i.has(e.source)&&!i.has(e.target)).map(e=>{let t=NIe(e,r),n=e.type===`flow-step`,i=e.type===`calls`,a=e.type===`reads-writes`,o={type:z_.ArrowClosed,width:20,height:20,color:`rgb(var(--ec-page-text-muted))`};return{id:e.id,source:e.source,target:e.target,label:a?`reads/writes`:n?e.label||void 0:e.label||e.type,type:n?`flow-edge`:i?`step`:`animated`,markerEnd:o,...a?{markerStart:o}:{},data:{edgeType:e.type,message:{collection:t}}}})},{sizeOf:jIe})}var MIe=new Set([`event`,`command`,`query`]);function NIe(e,t){let n=t.get(e.target);if(n&&MIe.has(n.type))return`${n.type}s`;let r=t.get(e.source);return r&&MIe.has(r.type)?`${r.type}s`:n?`${n.type}s`:void 0}var Tz=e=>{if(typeof e==`number`)return e;if(typeof e==`string`){let t=Number.parseFloat(e);return Number.isFinite(t)?t:void 0}},Ez=e=>({width:Tz(e.measured?.width)??Tz(e.width)??Tz(e.style?.width)??260,height:Tz(e.measured?.height)??Tz(e.height)??Tz(e.style?.height)??140}),PIe=(e,t,n=0)=>e.x<t.x+t.width+n&&e.x+e.width+n>t.x&&e.y<t.y+t.height+n&&e.y+e.height+n>t.y,FIe=(e,t=e.position.y)=>{let n=Ez(e);return{x:e.position.x,y:t,width:n.width,height:n.height}},IIe=({nodes:e,movableNodeIds:t,protectedBounds:n,groupNodeId:r,gap:i=40})=>{let a=e.filter(e=>t.has(e.id)).sort((e,t)=>e.position.y-t.position.y),o=new Set(a.map(e=>e.id)),s=[n,...e.filter(e=>!e.parentId&&e.id!==r&&!o.has(e.id)).map(e=>FIe(e))],c=new Map,l=n.y+n.height/2,u=e=>{let t=Ez(e),r=e.position.y+t.height/2>=l?1:-1,a=r>0?Math.max(e.position.y,n.y+n.height+i):Math.min(e.position.y,n.y-t.height-i),o=0;for(;o<s.length+8;){let n={x:e.position.x,y:a,width:t.width,height:t.height},l=s.find(e=>PIe(n,e,i));if(!l){s.push(n),c.set(e.id,{...e.position,y:a});return}a=r>0?l.y+l.height+i:l.y-t.height-i,o+=1}s.push({x:e.position.x,y:a,width:t.width,height:t.height}),c.set(e.id,{...e.position,y:a})},d=a.filter(e=>{let t=Ez(e);return e.position.y+t.height/2>=l}),f=new Set(d.map(e=>e.id)),p=a.filter(e=>!f.has(e.id)).reverse();return d.forEach(u),p.forEach(u),c},LIe=(e,t)=>e.find(e=>e.id===t&&e.type===`messageGroupExpanded`),Dz=({currentNodes:e,groupNodeId:t,expandedContainerNode:n,childNodes:r,downstreamNodes:i,getDownstreamPosition:a})=>{let o=e.filter(e=>e.id!==t&&e.parentId!==t),s=new Set(o.map(e=>e.id)),c=i.filter(e=>!s.has(e.id)).map((e,t)=>({...e,position:a(e,t)}));return[...o,n,...r,...c]},Oz={service:{icon:GS,color:`#ec4899`,label:`Service`},services:{icon:GS,color:`#ec4899`,label:`Service`},agent:{icon:gS,color:`#0ea5e9`,label:`Agent`},agents:{icon:gS,color:`#0ea5e9`,label:`Agent`},event:{icon:QS,color:`#f97316`,label:`Event`},events:{icon:QS,color:`#f97316`,label:`Event`},command:{icon:FS,color:`#3b82f6`,label:`Command`},commands:{icon:FS,color:`#3b82f6`,label:`Command`},query:{icon:WS,color:`#22c55e`,label:`Query`},queries:{icon:WS,color:`#22c55e`,label:`Query`},channel:{icon:pS,color:`#6b7280`,label:`Channel`},channels:{icon:pS,color:`#6b7280`,label:`Channel`},data:{icon:ES,color:`#3b82f6`,label:`Data`},"data-products":{icon:zS,color:`#6366f1`,label:`Data Product`},externalSystem:{icon:kS,color:`#ec4899`,label:`External System`},actor:{icon:JS,color:`#eab308`,label:`Actor`},view:{icon:ple,color:`#8b5cf6`,label:`View`},domain:{icon:vS,color:`#14b8a6`,label:`Domain`},domains:{icon:vS,color:`#14b8a6`,label:`Domain`}};function kz(e){return e&&Oz[e]||null}function RIe(e){let t=e.data,n=[t?.service,t?.message,t?.channel,t?.data,t?.dataProduct,t?.externalSystem,t?.actor];for(let t of n)if(t?.notes&&t.notes.length>0)return{name:t.name||e.id,notes:t.notes,nodeType:e.type||`unknown`};return t?.notes&&t.notes.length>0?{name:t.name||e.id,notes:t.notes,nodeType:e.type||`unknown`}:null}var Az={50:`#fffbeb`,100:`#fef3c7`,200:`#fde68a`,400:`#fbbf24`,500:`#f59e0b`,600:`#d97706`,700:`#b45309`,800:`#92400e`},zIe={high:{bg:`#fef2f2`,fg:`#b91c1c`,border:`#fecaca`,label:`High`,accent:`#ef4444`},critical:{bg:`#fef2f2`,fg:`#991b1b`,border:`#fecaca`,label:`Critical`,accent:`#dc2626`},low:{bg:`#f0fdf4`,fg:`#15803d`,border:`#bbf7d0`,label:`Low`,accent:`#22c55e`}},BIe=[[`#7c3aed`,`#a78bfa`],[`#2563eb`,`#60a5fa`],[`#0891b2`,`#22d3ee`],[`#059669`,`#34d399`],[`#d97706`,`#fbbf24`],[`#dc2626`,`#f87171`],[`#db2777`,`#f472b6`],[`#4f46e5`,`#818cf8`]];function VIe(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)|0;return Math.abs(t)}function HIe({name:e,size:t=28}){let n=e.split(/\s+/).map(e=>e[0]).join(``).toUpperCase().slice(0,2),[r,i]=BIe[VIe(e)%BIe.length];return(0,k.jsx)(`div`,{style:{width:t,height:t,borderRadius:`50%`,background:`linear-gradient(135deg, ${r}, ${i})`,display:`flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0},children:(0,k.jsx)(`span`,{style:{fontSize:Math.round(t*.42),fontWeight:700,color:`white`,lineHeight:1},children:n})})}function UIe({priority:e}){let t=zIe[e.toLowerCase()];if(!t)return null;let n=e===`high`||e===`critical`;return(0,k.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:3,fontSize:10,fontWeight:600,color:t.fg,background:t.bg,border:`1px solid ${t.border}`,borderRadius:99,padding:`2px 7px`,textTransform:`uppercase`,letterSpacing:`0.03em`,lineHeight:1.4},children:[n&&(0,k.jsx)(yle,{style:{width:9,height:9},strokeWidth:2.5}),t.label]})}function WIe({note:e,index:t}){let n=e.priority?zIe[e.priority.toLowerCase()]:null;return(0,k.jsxs)(`div`,{style:{background:`white`,border:`1px solid #e2e8f0`,borderRadius:10,padding:`14px 16px`,position:`relative`,boxShadow:`0 1px 3px rgba(0,0,0,0.04)`},children:[n&&(0,k.jsx)(`div`,{style:{position:`absolute`,left:0,top:10,bottom:10,width:3,borderRadius:`0 2px 2px 0`,background:n.accent}}),(0,k.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:8},children:[e.author?(0,k.jsx)(HIe,{name:e.author,size:24}):(0,k.jsx)(`div`,{style:{width:24,height:24,borderRadius:`50%`,background:`#f1f5f9`,border:`2px solid ${Az[200]}`,display:`flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0},children:(0,k.jsx)(`span`,{style:{fontSize:10,fontWeight:700,color:Az[700]},children:t+1})}),(0,k.jsx)(`div`,{style:{flex:1,minWidth:0},children:e.author&&(0,k.jsx)(`span`,{style:{fontSize:13,fontWeight:600,color:`#0f172a`,lineHeight:1},children:e.author})}),e.priority&&(0,k.jsx)(UIe,{priority:e.priority})]}),(0,k.jsx)(`p`,{style:{fontSize:13,lineHeight:1.6,color:`#334155`,margin:0,whiteSpace:`pre-wrap`,wordBreak:`break-word`,paddingLeft:n?6:0},children:e.content})]})}function GIe({noteGroups:e,isOpen:t,onClose:n,nodes:r}){let{setCenter:i,getZoom:a}=qy(),[o,s]=(0,p.useState)(0),c=PI(),l=e.reduce((e,t)=>e+t.notes.length,0),u=e[o]||e[0],d=(0,p.useCallback)(e=>{let t=r.find(t=>t.id===e);if(!t)return;let o=Math.max(a(),1);i(t.position.x+100,t.position.y+50,{zoom:o,duration:600}),n()},[r,i,a,n]);return l===0?null:(0,k.jsx)(kD,{open:t,onOpenChange:e=>{e||(n(),s(0))},children:(0,k.jsx)(_he,{container:c,children:(0,k.jsxs)(`div`,{className:`fixed inset-0 z-[99999]`,style:{isolation:`isolate`},children:[(0,k.jsx)(AD,{style:{position:`fixed`,inset:0,background:`rgba(15, 23, 42, 0.55)`,backdropFilter:`blur(6px)`}}),(0,k.jsxs)(jD,{style:{position:`fixed`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,width:`94vw`,maxWidth:720,height:`78vh`,maxHeight:560,background:`white`,borderRadius:14,boxShadow:`0 0 0 1px rgba(0,0,0,0.06), 0 20px 50px rgba(0,0,0,0.2)`,display:`flex`,flexDirection:`column`,overflow:`hidden`,outline:`none`},children:[(0,k.jsxs)(`div`,{style:{padding:`14px 20px`,borderBottom:`1px solid #e2e8f0`,display:`flex`,alignItems:`center`,gap:12,flexShrink:0},children:[(0,k.jsx)(`div`,{style:{width:32,height:32,borderRadius:8,background:`#f1f5f9`,display:`flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0},children:(0,k.jsx)(PS,{style:{width:16,height:16,color:`#64748b`},strokeWidth:2.5})}),(0,k.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,k.jsx)(MD,{style:{fontSize:15,fontWeight:700,color:`#0f172a`,margin:0,lineHeight:1.25},children:`Notes`}),(0,k.jsxs)(vhe,{style:{fontSize:12,color:`#64748b`,margin:0,marginTop:1},children:[l,` note`,l===1?``:`s`,` across`,` `,e.length,` resource`,e.length===1?``:`s`]})]}),(0,k.jsx)(yhe,{asChild:!0,children:(0,k.jsx)(`button`,{style:{width:30,height:30,borderRadius:8,border:`none`,background:`rgba(0,0,0,0.04)`,display:`flex`,alignItems:`center`,justifyContent:`center`,cursor:`pointer`,color:`#94a3b8`,flexShrink:0},"aria-label":`Close`,children:(0,k.jsx)(ZS,{style:{width:15,height:15}})})})]}),(0,k.jsxs)(`div`,{style:{display:`flex`,flex:1,overflow:`hidden`},children:[(0,k.jsx)(`div`,{style:{width:240,flexShrink:0,borderRight:`1px solid #e2e8f0`,overflowY:`auto`,background:`#f8fafc`},children:e.map((e,t)=>{let n=t===o,r=kz(e.nodeType),i=r?.icon||PS,a=r?.color||`#64748b`;return(0,k.jsxs)(`button`,{onClick:()=>s(t),style:{width:`100%`,padding:`12px 16px`,background:n?`white`:`transparent`,border:`none`,borderBottom:`1px solid #f1f5f9`,borderRight:n?`2px solid ${a}`:`2px solid transparent`,cursor:`pointer`,display:`flex`,alignItems:`center`,gap:10,textAlign:`left`,transition:`background 0.1s`},children:[(0,k.jsx)(`div`,{style:{width:28,height:28,borderRadius:7,background:n?a:`${a}14`,display:`flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0,transition:`background 0.15s`},children:(0,k.jsx)(i,{style:{width:14,height:14,color:n?`white`:a,transition:`color 0.15s`},strokeWidth:2})}),(0,k.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,k.jsx)(`div`,{style:{fontSize:12,fontWeight:n?600:500,color:n?`#0f172a`:`#475569`,lineHeight:1.3,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.name}),(0,k.jsxs)(`div`,{style:{fontSize:10,color:`#94a3b8`,lineHeight:1.3,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,marginTop:2},children:[r?.label||e.nodeType,` ·`,` `,e.notes.length,` note`,e.notes.length===1?``:`s`]})]}),(0,k.jsx)(bS,{style:{width:14,height:14,color:n?a:`#cbd5e1`,flexShrink:0},strokeWidth:2})]},e.nodeId)})}),(0,k.jsx)(`div`,{style:{flex:1,overflowY:`auto`,display:`flex`,flexDirection:`column`},children:u&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{style:{padding:`14px 20px`,borderBottom:`1px solid #f1f5f9`,display:`flex`,alignItems:`center`,justifyContent:`space-between`,flexShrink:0,background:`#fafbfc`},children:[(0,k.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10},children:[(()=>{let e=kz(u.nodeType),t=e?.icon||PS,n=e?.color||`#64748b`;return(0,k.jsx)(`div`,{style:{width:30,height:30,borderRadius:8,background:`${n}14`,display:`flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0},children:(0,k.jsx)(t,{style:{width:15,height:15,color:n},strokeWidth:2})})})(),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{style:{fontSize:14,fontWeight:600,color:`#0f172a`,lineHeight:1.3},children:u.name}),(0,k.jsxs)(`div`,{style:{fontSize:11,color:`#94a3b8`,marginTop:2},children:[kz(u.nodeType)?.label||u.nodeType,` `,`· `,u.notes.length,` note`,u.notes.length===1?``:`s`]})]})]}),(0,k.jsxs)(`button`,{onClick:()=>d(u.nodeId),style:{display:`flex`,alignItems:`center`,gap:5,padding:`5px 10px`,borderRadius:6,border:`1px solid #e2e8f0`,background:`white`,cursor:`pointer`,fontSize:11,fontWeight:500,color:`#475569`,transition:`all 0.12s`},onMouseEnter:e=>{e.currentTarget.style.borderColor=Az[400],e.currentTarget.style.color=Az[700]},onMouseLeave:e=>{e.currentTarget.style.borderColor=`#e2e8f0`,e.currentTarget.style.color=`#475569`},children:[(0,k.jsx)(lle,{style:{width:12,height:12}}),`Find on canvas`]})]}),(0,k.jsx)(`div`,{style:{flex:1,overflowY:`auto`,padding:`16px 20px`,display:`flex`,flexDirection:`column`,gap:10},children:u.notes.map((e,t)=>(0,k.jsx)(WIe,{note:e,index:t},t))})]})})]})]})]})})})}var KIe=300,jz=12,Mz=8,Nz=32;function Pz(e,t,n,r=Mz){let[i,a]=(0,p.useState)(null);return(0,p.useEffect)(()=>{let i=0,o=()=>{let s=t.current,c=s?.querySelector(`.react-flow__node[data-id="${CSS.escape(e)}"]`);if(s&&c){let e=s.getBoundingClientRect(),t=c.getBoundingClientRect(),i=n.current?.offsetHeight??200,o=n.current?.offsetWidth||KIe,l=t.right+jz+o<=e.right-Mz?`right`:`left`,u=l===`right`?t.right-e.left+jz:t.left-e.left-jz-o,d=(e,t)=>Math.min(Math.max(e,Mz),Math.max(t,Mz)),f=d(Math.min(t.top,t.top+t.height/2-Nz)-e.top,e.height-i-r),p=d(u,e.width-o-Mz),m=t.top+t.height/2-e.top-f,h={side:l,left:p,top:f,pointsAt:p===u&&m>=14&&m<=i-14?Math.round(m):void 0};a(e=>e?.left===h.left&&e?.top===h.top&&e?.side===h.side&&e?.pointsAt===h.pointsAt?e:h)}i=requestAnimationFrame(o)};return o(),()=>cancelAnimationFrame(i)},[e,t,n,r]),i}function Fz({nodeId:e,containerRef:t,label:n,kicker:r,header:i,children:a,width:o=340,bottomInset:s=76,onClose:c}){let l=(0,p.useRef)(null),u=Pz(e,t,l,s),d=(0,p.useRef)(c);d.current=c,(0,p.useEffect)(()=>{let e=()=>{let e=document.activeElement;e instanceof HTMLElement&&l.current?.contains(e)&&e.blur(),d.current()},t=t=>{l.current?.contains(t.target)||e()},n=t=>t.key===`Escape`&&e();return document.addEventListener(`pointerdown`,t,!0),document.addEventListener(`keydown`,n),()=>{document.removeEventListener(`pointerdown`,t,!0),document.removeEventListener(`keydown`,n)}},[]);let f=!!u,m=(0,p.useRef)(!1);return(0,p.useEffect)(()=>{if(!f||m.current)return;m.current=!0;let e=l.current?.querySelector(`input:not([readonly]):not([disabled]), textarea:not([readonly]):not([disabled])`);if(e){e.focus({preventScroll:!0});try{e.setSelectionRange(e.value.length,e.value.length)}catch{}}},[f]),(0,k.jsxs)(k.Fragment,{children:[u?.pointsAt!==void 0&&(0,k.jsx)(`span`,{"aria-hidden":!0,className:`ec-doc-card-arrow is-${u.side}`,style:{top:u.top+u.pointsAt-7,left:u.side===`right`?u.left-6:u.left+o-8}}),(0,k.jsxs)(`div`,{ref:l,className:`ec-doc-card`,role:`dialog`,"aria-label":n,style:{width:o,top:u?.top??8,left:u?.left??8,visibility:u?`visible`:`hidden`},children:[(0,k.jsxs)(`header`,{className:`ec-doc-card-header`,children:[(0,k.jsxs)(`div`,{className:`ec-doc-card-kicker`,children:[r,(0,k.jsx)(`button`,{type:`button`,className:`ec-icon-button ec-doc-card-close`,"aria-label":`Close`,onClick:c,children:(0,k.jsx)(ZS,{"aria-hidden":!0})})]}),i]}),a]})]})}var Iz={domain:`domain-group`,system:`system-group`},Lz=(e,t)=>({name:e,version:`0.0.1`,summary:t,owners:[]}),Rz=[{type:Iz.domain,firstLevel:1,label:`Domain`,summary:`A business area, e.g. Sales`,category:`boundaries`,resourceKey:`domain`,defaultSize:{width:720,height:460},createData:()=>({domain:{name:`New Domain`,version:`0.0.1`}})},{type:Iz.system,firstLevel:1,label:`System`,summary:`Services doing one job`,category:`boundaries`,resourceKey:`system`,defaultSize:{width:560,height:360},createData:()=>({system:{name:`New System`,version:`0.0.1`}})},{type:`service`,firstLevel:2,category:`architecture`,label:`Service`,summary:`An API, worker or function`,resourceKey:`service`,createData:()=>({mode:`full`,service:{...Lz(`New Service`,`Describe what this service does.`),sends:[],receives:[]}})},{type:`event`,firstLevel:3,category:`messages`,label:`Event`,summary:`Something that happened`,resourceKey:`message`,createData:()=>({mode:`full`,message:Lz(`NewEvent`,`Something happened.`)})},{type:`command`,firstLevel:3,category:`messages`,label:`Command`,summary:`A request to do something`,resourceKey:`message`,createData:()=>({mode:`full`,message:Lz(`NewCommand`,`Asks a service to do something.`)})},{type:`query`,firstLevel:3,category:`messages`,label:`Query`,summary:`A request for data`,resourceKey:`message`,createData:()=>({mode:`full`,message:Lz(`NewQuery`,`Asks for some information.`)})},{type:`channel`,firstLevel:3,category:`messages`,label:`Channel`,summary:`A topic, queue or bus`,resourceKey:`channel`,createData:()=>({mode:`full`,channel:{...Lz(`new.channel`,`Where messages are routed.`),protocols:[]}})},{type:`view`,firstLevel:2,category:`architecture`,label:`View`,summary:`A screen or app people use`,resourceKey:`view`,createData:()=>({mode:`full`,view:Lz(`New View`,`What the user sees.`)})},{type:`externalSystem`,firstLevel:1,category:`architecture`,label:`External System`,summary:`A third party you use`,resourceKey:`externalSystem`,createData:()=>({mode:`full`,externalSystem:Lz(`External System`,`A third party system.`)})},{type:`agent`,firstLevel:3,category:`architecture`,label:`Agent`,summary:`An AI agent at work`,resourceKey:`agent`,createData:()=>({mode:`full`,agent:{...Lz(`New Agent`,`What this agent does.`),sends:[],receives:[]}})},{type:`actor`,firstLevel:1,category:`people`,label:`Actor`,summary:`Someone who uses it`,createData:()=>({mode:`full`,name:`Customer`,summary:``})},{type:`team`,firstLevel:1,category:`people`,label:`Team`,summary:`Who owns what`,resourceKey:`team`,createData:()=>({mode:`full`,team:Lz(`New Team`,`What this team looks after.`)})},{type:`text`,unlisted:!0,firstLevel:2,category:`other`,label:`Text`,defaultSize:{width:240,height:40},autoSize:!0,createData:()=>({text:`Add some text`})},{type:`note`,unlisted:!0,firstLevel:1,category:`other`,label:`Sticky Note`,defaultSize:{width:200,height:176},autoHeight:!0,createData:()=>({text:``,color:`yellow`})},...[{containerType:`database`,label:`Database`,name:`New Database`,summary:`Tables, e.g. PostgreSQL`},{containerType:`cache`,label:`Cache`,name:`New Cache`,summary:`Fast data, e.g. Redis`},{containerType:`searchIndex`,label:`Search index`,name:`New Search Index`,summary:`Search, e.g. Elasticsearch`},{containerType:`objectStore`,label:`Object store`,name:`New Object Store`,summary:`Files and blobs, e.g. S3`}].map(({containerType:e,label:t,name:n,summary:r})=>({type:`data`,...e!==`database`&&{id:`data:${e}`},firstLevel:2,category:`data`,label:t,summary:r,resourceKey:`data`,createData:()=>({mode:`full`,data:{...Lz(n,`Stores data.`),container_type:e}})})),{type:`entity`,firstLevel:3,category:`data`,label:`Entity`,summary:`Part of the domain model`,resourceKey:`entity`,createData:()=>({mode:`full`,entity:{...Lz(`NewEntity`,`Something the domain keeps track of.`),properties:[{name:`id`,type:`string`,required:!0},{name:`createdAt`,type:`string`}]}})}],zz=e=>e.id??e.type;[...new Set(Rz.filter(e=>!e.unlisted).map(e=>e.type))],new Map(Rz.map(e=>[zz(e),e]));var Bz={[Iz.domain]:{icon:vS,className:`text-yellow-500`},[Iz.system]:{icon:AS,className:`text-violet-600`},"context-domain":{icon:vS,className:`text-yellow-500`},system:{icon:AS,className:`text-violet-600`},service:{icon:GS,className:`text-pink-600`},event:{icon:QS,className:`text-orange-600`},command:{icon:ule,className:`text-blue-600`},query:{icon:WS,className:`text-green-600`},channel:{icon:pS,className:`text-gray-600`},data:{icon:ES,className:`text-blue-600`},"data:cache":{icon:TS,className:`text-blue-600`},"data:searchIndex":{icon:US,className:`text-blue-600`},"data:objectStore":{icon:P,className:`text-blue-600`},view:{icon:LS,className:`text-sky-600`},externalSystem:{icon:kS,className:`text-purple-600`},agent:{icon:gS,className:`text-violet-600`},actor:{icon:JS,className:`text-yellow-500`},team:{icon:Sle,className:`text-emerald-600`},entity:{icon:_le,className:`text-blue-600`},note:{icon:gle,className:`text-yellow-500`},text:{icon:ble,className:`text-[rgb(var(--ec-icon-color))]`}};({...Bz[Iz.domain]}),{...Bz[Iz.system]},{...Bz.service},{...Bz.event},{...Bz.command},{...Bz.query},{...Bz.channel},{...Bz.data};var qIe={service:`services`,agent:`agents`,event:`events`,command:`commands`,query:`queries`,channel:`channels`,flow:`flows`,system:`systems`,domain:`domains`,"domain-group":`domains`,"system-group":`systems`,container:`data`,"data-product":`data-products`,entity:`entities`},JIe=e=>qIe[e??``]??e??``,YIe=e=>AR[JIe(e)]??`Node`,XIe=e=>kR[JIe(e)]??`bg-gray-500`,ZIe={services:`service`,agents:`agent`,events:`event`,commands:`command`,queries:`query`,channels:`channel`,systems:`system`,"system-group":`system`,domains:Iz.domain,"domain-group":Iz.domain,"context-domain":Iz.domain,"external-system":`externalSystem`,"context-actor":`actor`,user:`actor`,entities:`entity`},QIe={flows:{icon:YS,className:`text-teal-600`},"data-products":{icon:zS,className:`text-indigo-600`},agentTool:{icon:XS,className:`text-violet-600`}},$Ie=e=>{let t=JIe(e);return QIe[t]??Bz[ZIe[t]??ZIe[e??``]??e??``]??{icon:_S,className:`text-[rgb(var(--ec-icon-color))]`}},eLe=6;function Vz({group:e,onOpenNode:t}){let[n,r]=(0,p.useState)(!1),i=n?0:Math.max(0,e.items.length-eLe),a=i?e.items.slice(0,eLe):e.items;return(0,k.jsxs)(`section`,{className:`mt-3`,children:[(0,k.jsx)(`h3`,{className:`mb-1.5 text-xs font-semibold text-[rgb(var(--ec-page-text-muted))]`,children:e.heading}),(0,k.jsx)(`ul`,{className:`m-0 list-none space-y-px p-0`,children:a.map(e=>{let{icon:n,className:r}=$Ie(e.type);return(0,k.jsx)(`li`,{children:(0,k.jsxs)(`button`,{type:`button`,title:`Go to ${e.name}`,onClick:()=>t(e.id),className:`ec-doc-card-item`,children:[(0,k.jsx)(`span`,{"aria-hidden":!0,className:`ec-doc-card-item-icon ${r}`,children:(0,k.jsx)(n,{})}),(0,k.jsx)(`span`,{className:`min-w-[35%] flex-1 truncate`,children:e.name}),e.label&&(0,k.jsx)(`span`,{title:e.label,className:`min-w-0 max-w-[55%] flex-none truncate text-right text-[11px] text-[rgb(var(--ec-page-text-muted))]`,children:e.label}),(0,k.jsx)(bS,{"aria-hidden":!0,className:`ec-doc-card-item-chevron`})]})},e.id)})}),i>0&&(0,k.jsxs)(`button`,{type:`button`,onClick:()=>r(!0),className:`ec-doc-card-item ec-doc-card-more`,children:[(0,k.jsx)(`span`,{"aria-hidden":!0,className:`ec-doc-card-item-icon`,children:(0,k.jsx)($ce,{})}),`Show `,i,` more`]})]})}var tLe=(0,p.memo)(function({node:e,parentName:t,neighbours:n,diagramUrl:r,docsUrl:i,onOpenDiagram:a,onOpenNode:o,containerRef:s,onClose:c}){let{name:l,version:u,summary:d}=NR(e);return(0,k.jsx)(Fz,{nodeId:e.id,containerRef:s,label:l,onClose:c,bottomInset:64,kicker:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{className:`inline-flex flex-none items-center rounded px-1.5 text-[9px] font-bold uppercase leading-4 tracking-wider text-white ${XIe(e.type)}`,children:YIe(e.type)}),t&&(0,k.jsxs)(`span`,{className:`ec-doc-card-breadcrumb`,children:[`in `,t]})]}),header:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`h2`,{className:`ec-doc-card-title`,children:[l,u&&(0,k.jsxs)(`span`,{className:`ec-doc-card-version`,children:[`v`,u]})]}),d&&(0,k.jsx)(`p`,{className:`ec-doc-card-summary is-clamped`,title:d,children:d}),(r||i)&&(0,k.jsxs)(`div`,{className:`ec-doc-card-actions`,children:[r&&(0,k.jsxs)(`a`,{href:r,onClick:e=>{e.metaKey||e.ctrlKey||(e.preventDefault(),a(r))},className:`ec-doc-card-action is-primary`,children:[(0,k.jsx)(RS,{"aria-hidden":!0}),` Open diagram`,(0,k.jsx)(mS,{"aria-hidden":!0,className:`ec-doc-card-action-arrow`})]}),i&&(0,k.jsxs)(`a`,{href:i,className:`ec-doc-card-action`,children:[(0,k.jsx)(OS,{"aria-hidden":!0}),` Docs`]})]})]}),children:(0,k.jsx)(`div`,{className:`ec-doc-card-body ec-doc-card-scroll px-4 pb-3.5 pt-1 empty:hidden`,children:n.map(e=>(0,k.jsx)(Vz,{group:e,onOpenNode:o},e.heading))})})}),Hz=new Set([`events`,`commands`,`queries`,`event`,`command`,`query`]),Uz=new Set([`channels`,`channel`]),nLe=new Set([`services`,`service`,`agents`,`agent`]),rLe=new Set([`note`,`text`]),Wz=5,iLe=(e,t)=>{let n=e.data,r=(n.service??n.agent)?.[t];return Array.isArray(r)?new Set(r.map(e=>e?.id)):void 0},aLe=e=>e.data.message?.id,oLe=e=>{let t=e.label??e.data?.label;return typeof t==`string`&&t.trim()?t.replace(/\s+/g,` `).trim():void 0};function sLe(e,t,n){let r=new Map(t.map(e=>[e.id,e])),i=r.get(e);if(!i)return[];let a=e=>r.get(e)?.type??``,o=(e,t)=>n.filter(n=>t===`out`?n.source===e:n.target===e).map(e=>({id:t===`out`?e.target:e.source,label:oLe(e)})),s=e=>Uz.has(a(e)),c=(t,n)=>{let i=r.get(e),a=r.get(t),[o,s]=Hz.has(i.type??``)?[a,i]:[i,a];if(!nLe.has(o.type??``)||!Hz.has(s.type??``))return!0;let c=iLe(o,o===a==(n===`out`)?`receives`:`sends`);return!c||c.has(aLe(s))},l=(e,t)=>({id:e,type:r.get(e).type,name:NR(r.get(e)).name,...t&&{label:t}}),u=(t,n,i)=>{let u=new Map,d=(t,n)=>{t===e||u.has(t)||r.has(t)&&!rLe.has(a(t))&&u.set(t,n)},f=(t,i,a)=>{let l=`via ${i.join(` → `)}`,u=o(t,n).filter(t=>t.id!==e&&!a.has(t.id));if(!u.length)return d(t);for(let e of u)s(e.id)&&i.length<Wz?f(e.id,[...i,NR(r.get(e.id)).name],new Set([...a,e.id])):c(e.id,n)&&d(e.id,l)};for(let e of o(t,n))i&&s(e.id)?f(e.id,[NR(r.get(e.id)).name],new Set([e.id])):d(e.id,e.label);return[...u].map(([e,t])=>l(e,t))},d=e=>Hz.has(e.type??``),f=e=>Uz.has(e.type??``);if(Uz.has(i.type??``)){let t=u(e,`in`,!1),n=u(e,`out`,!1),i=new Map,c=(e,t,n)=>{for(let l of o(e,`in`))!n.has(l.id)&&r.has(l.id)&&(Hz.has(a(l.id))?i.has(l.id)||i.set(l.id,t.length?`via ${t.join(` → `)}`:void 0):s(l.id)&&t.length<Wz&&c(l.id,[NR(r.get(l.id)).name,...t],new Set([...n,l.id])))};c(e,[],new Set([e]));let p=[...i].map(([e,t])=>l(e,t)),m=new Map;for(let e of p)for(let t of o(e.id,`in`))!s(t.id)&&r.has(t.id)&&!rLe.has(a(t.id))&&m.set(t.id,(m.get(t.id)??0)+1);let h=({label:e,...t})=>t;return[{heading:`Messages`,items:p},{heading:`Produced by`,items:[...m].map(([e,t])=>l(e,t===1?`1 message`:`${t} messages`))},{heading:`Consumed by`,items:n.filter(e=>!d(e)&&!f(e))},{heading:`Routes from`,items:t.filter(f).map(h)},{heading:`Routes to`,items:n.filter(f).map(h)},{heading:`Connected from`,items:t.filter(e=>!d(e)&&!f(e))}].filter(e=>e.items.length>0)}let p=u(e,`in`,!0),m=u(e,`out`,!0);return(Hz.has(i.type??``)?[{heading:`Produced by`,items:p},{heading:`Consumed by`,items:m}]:nLe.has(i.type??``)?[{heading:`Sends`,items:m.filter(d)},{heading:`Receives`,items:p.filter(d)},{heading:`Connects to`,items:m.filter(e=>!d(e))},{heading:`Connected from`,items:p.filter(e=>!d(e))}]:[{heading:`Connects to`,items:m},{heading:`Connected from`,items:p}]).filter(e=>e.items.length>0)}var cLe=1,lLe=[.1,.1],uLe=[`services`,`service`,`agents`,`agent`,`externalSystem`,`data`,`data-products`,`events`,`event`,`commands`,`command`,`queries`,`query`,`messageGroup`,`messageGroupExpanded`,`channels`,`channel`],Gz=[`domains`,`domain`,`domain-group`,`context-domain`,`systems`,`system`,`external-system`,`externalSystem`,`context-actor`,`actor`,`actors`,`note`,`notes`],Kz={...KR,duration:0},qz={hideAttribution:!0},Jz=`render`,Yz=()=>new URLSearchParams(window.location.search).get(Jz)===`mermaid`,dLe=e=>{let t=new URL(e,window.location.href);return t.searchParams.set(Jz,`mermaid`),/^[a-z]+:/i.test(e)?t.href:`${t.pathname}${t.search}${t.hash}`},fLe=e=>{let t=new URL(window.location.href);e?t.searchParams.set(Jz,`mermaid`):t.searchParams.delete(Jz),window.history.replaceState(window.history.state,``,t)},Xz=2,pLe=[],Zz=[],Qz={marginBottom:`20px`,marginLeft:`420px`},mLe={marginLeft:`60px`},hLe=new Set([`flowExpanded`,`messageGroupExpanded`]),$z=e=>e!=null&&hLe.has(e),gLe=new Set([`system`,`systems`,`context-domain`]),_Le=e=>e!=null&&gLe.has(e),eB=new Set([`domain-group`,`system-group`]),tB=e=>e!=null&&eB.has(e),vLe=e=>!!e.target?.closest?.(`[data-ec-container-header]`),yLe=new Set([`note`,`text`]),bLe=e=>{let t=e=>e.replace(/\/+$/,``);return t(new URL(e,window.location.href).pathname)===t(window.location.pathname)},nB=`ec-walkthrough-current`,rB=(e,t)=>{let n=(e.className??``).split(` `).filter(e=>e&&e!==nB);return t&&n.push(nB),n.length>0?n.join(` `):void 0},iB=e=>e?.opacity===void 0||e.opacity===1,xLe=e=>{let t=rB(e,!1);return!e.selected&&t===e.className&&iB(e.style)?e:{...e,style:{...e.style,opacity:1},className:t,selected:!1}},SLe=(e,t)=>{let n=e.data?.canAnimate!==!1&&t;return iB(e.style)&&iB(e.labelStyle)&&iB(e.data)&&!!e.animated===n&&!!e.data?.animated===n?e:{...e,style:{...e.style,opacity:1},labelStyle:{...e.labelStyle,opacity:1},data:{...e.data,opacity:1,animated:n},animated:n}},aB=(e,t)=>{let n=!1,r=e.map(e=>{let r=t(e);return r!==e&&(n=!0),r});return n?r:e},CLe=170,oB=`group`,sB=`groupStyle`,wLe=(e,t)=>{try{let n=new URL(window.location.href);e?(n.searchParams.set(oB,e),n.searchParams.set(sB,t)):(n.searchParams.delete(oB),n.searchParams.delete(sB)),window.history.replaceState(window.history.state,``,n)}catch{}},TLe=()=>{try{let e=new URL(window.location.href).searchParams;return{groupBy:e.get(oB),style:e.get(sB)}}catch{return{groupBy:null,style:null}}},ELe={marginTop:64},DLe=(e,t,n)=>{let r=e.filter(e=>!e.hidden),i=new Set(r.map(e=>e.id));return{nodes:r.map(e=>{let{position:t,width:r,height:i}=n(e);return{id:e.id,type:e.type,data:e.data,...e.parentId&&{parentId:e.parentId},center:{x:t.x+r/2,y:t.y+i/2},width:r,height:i}}),edges:t.filter(e=>!e.hidden&&i.has(e.source)&&i.has(e.target)).map(e=>{let t=e.data?.route;return{source:e.source,target:e.target,...typeof e.label==`string`&&{label:e.label},...t&&{route:{points:t.points,label:t.label,sourceHeight:t.source?.height,targetHeight:t.target?.height}}}})}},cB=e=>({width:e.measured?.width??e.width??(typeof e.style?.width==`number`?e.style.width:0),height:e.measured?.height??e.height??(typeof e.style?.height==`number`?e.style.height:0)}),lB={strokeWidth:1,stroke:`var(--ec-edge-stroke, #6b7280)`},uB={type:z_.ArrowClosed,width:20,height:20},OLe=(e,t)=>e===`sends`?t===`commands`?`invokes`:t===`queries`?`requests`:`publishes
219
- event`:t===`commands`||t===`queries`?`accepts`:`subscribed by`,kLe=(e,t,n)=>{let r=new Map;for(let e of n)r.has(e.source)||r.set(e.source,[]),r.get(e.source).push(e.target);let i=new Set([e]),a=[e];for(;a.length>0;){let e=a.shift();for(let n of r.get(e)||[]){if(n===t)return!0;i.has(n)||(i.add(n),a.push(n))}}return!1},ALe=(e,t,n,r)=>{let i=e.expandedEdges||[];return(e.messages||[]).map(t=>{let a=t.message,o=`${a.data.id}-${a.data.version}`,s=r.get(o),c=a.collection||`events`,l=OLe(e.direction,c);return e.direction===`sends`?{id:`${n}-to-${s}`,source:n,target:s,label:l,type:`animated`,style:lB,markerEnd:uB}:kLe(o,n,i)?null:{id:`${s}-to-${n}`,source:s,target:n,label:l,type:`animated`,style:lB,markerEnd:uB}}).filter(Boolean)},jLe=({nodes:e,edges:t,title:n,includeBackground:r=!0,linkTo:i=`docs`,includeKey:a=!0,links:o=[],mode:s=`full`,showFlowWalkthrough:c=!0,showSearch:l=!0,showMenu:u=!0,compactSearch:d=!1,hideAttribution:f=!1,zoomOnScroll:m=!1,isChatEnabled:h=!1,maxTextSize:g,isDevMode:_=!1,resourceKey:v,animated:y,disableMessageAnimation:b=!1,overviewLabel:x,isOverview:S=!1,onShowOverview:C,transitionFrom:w,hiddenMessagesGraph:T,initialHiddenLegendKeys:E,onHiddenLegendKeysChange:ee,initialMermaidView:te=!1,onMermaidViewChange:ne,initialLevel:re,preferenceScope:ie,swimlanes:ae,focusNodeId:oe,focusRequestId:se,fitRequestId:ce,onNodeClick:le,onBuildUrl:ue,onNavigate:de,getNodeDiagramUrl:fe,onSaveLayout:pe,onResetLayout:me,onOpenInStudio:he,studioGraphs:ge})=>{(0,p.useEffect)(()=>{ue&&qMe(ue)},[]);let _e=(0,p.useMemo)(()=>{let e=e=>{let t=t=>{let n=t.data?.contextMenu;return n?.length?(0,k.jsx)(hIe,{items:n,children:(0,k.jsx)(e,{...t})}):(0,k.jsx)(e,{...t})};return t.displayName=`WithContextMenu(${e.displayName||e.name||`Component`})`,t},t=e=>(0,k.jsx)(KMe,{...e,readOnly:!0});t.displayName=`ReadOnlyNoteNode`;let n={...Object.fromEntries(Object.entries(fR).map(([t,n])=>[t,pR.has(t)?e(n):n])),note:t};return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,vIe(t)]))},[]),ve=(0,p.useMemo)(()=>({animated:TR,multiline:tFe,"flow-edge":iFe,default:ER,smoothstep:oFe,step:sFe}),[]),[ye,be]=(0,p.useState)(()=>dIe({disabled:b,animated:y,nodeCount:e.length})),xe=(0,p.useCallback)(e=>cz(e,ye),[ye]),[Se]=(0,p.useState)(()=>xe(t)),[Ce,we,Te]=Wse(e),[Ee,De,Oe]=Yb(Se),{fitView:ke,getNodes:Ae,getIntersectingNodes:je,getZoom:Me,setCenter:Ne,getEdges:Pe,getViewport:Fe,setViewport:Ie,getInternalNode:Le}=qy(),Re=my(),ze=(0,p.useRef)({nodes:e,edges:t});(0,p.useEffect)(()=>{let n=ze.current;ze.current={nodes:e,edges:t},(n.nodes!==e||n.edges!==t)&&(we(e),De(xe(t)),requestAnimationFrame(()=>{ke({duration:300,padding:.2})}))},[e,t,we,De,ke,xe]);let[Be,Ve]=(0,p.useState)(null),[He,Ue]=(0,p.useState)(!1),[We,Ge]=(0,p.useState)(!1),[Ke,qe]=(0,p.useState)(!1),Je=(0,p.useCallback)(()=>qe(!0),[]),Ye=(0,p.useCallback)(()=>qe(!1),[]),[Xe,Ze]=(0,p.useState)(!1),[Qe,$e]=(0,p.useState)(te),et=(0,p.useCallback)(e=>{$e(e),ne?.(e)},[ne]),tt=(0,p.useCallback)(()=>et(!0),[et]),[nt,rt]=(0,p.useState)(RFe),it=(0,p.useCallback)(e=>{rt(e),HR(e)},[]),[at,ot]=(0,p.useState)(!1),[st,ct]=(0,p.useState)(!1),lt=(0,p.useRef)({}),[ut,dt]=(0,p.useState)(null),ft=(0,p.useRef)(null),[pt,mt]=(0,p.useState)(`boxes`),ht=(0,p.useRef)(`boxes`),gt=(0,p.useRef)(null),[_t,vt]=(0,p.useState)(!1),yt=(0,p.useCallback)(()=>vt(!0),[]),bt=(0,p.useRef)(0),xt=(0,p.useCallback)(()=>{bt.current+=1,bt.current===1&&(ln.current?.classList.add(`ec-interaction-active`),yIe(ln.current,!0))},[]),St=(0,p.useCallback)(()=>{bt.current=Math.max(0,bt.current-1),bt.current===0&&(ln.current?.classList.remove(`ec-interaction-active`),yIe(ln.current,!1))},[]),Ct=(0,p.useRef)([]),wt=(0,p.useCallback)((e,t)=>{let n=ln.current;if(!n)return;let r=n.querySelectorAll(`[data-id="${t.source}"], [data-id="${t.target}"]`);r.forEach(e=>e.classList.add(`ec-edge-hover-node`)),Ct.current=Array.from(r)},[]),Tt=(0,p.useCallback)(()=>{Ct.current.forEach(e=>e.classList.remove(`ec-edge-hover-node`)),Ct.current=[]},[]),[Et,Dt]=(0,p.useState)(null),Ot=(0,p.useCallback)(e=>{let t=dn.current,n=t.find(t=>t.id===e);if(!n)return;let r=n.parentId?t.find(e=>e.id===n.parentId):void 0,i=MR(n),a=i?_I(i):void 0;Dt({node:{id:n.id,type:n.type,data:n.data},...r&&tB(r.type)&&{parentName:NR(r).name},neighbours:sLe(e,t,fn.current),diagramUrl:fe?.(n),docsUrl:a&&!bLe(a)?a:void 0})},[fe]),kt=(0,p.useCallback)(()=>Dt(null),[]),At=(0,p.useCallback)(e=>{let t=Me();ke({nodes:[{id:e}],duration:400,minZoom:t,maxZoom:t}),Ot(e)},[ke,Me,Ot]),jt=(0,p.useCallback)(e=>!e.type||yLe.has(e.type)||_Le(e.type)||$z(e.type)||[`domain`,`domains`,`context-actor`,`messageGroup`].includes(e.type)||Wx(e)?!1:!fn.current.some(e=>e.type===`flow-edge`)&&!dn.current.some(e=>e.type===`entities`),[]),Mt=(0,p.useRef)([]),Nt=(0,p.useRef)([]),Pt=(0,p.useRef)(null),Ft=(0,p.useCallback)((e,t)=>{let n=ln.current;if(!n)return;if(jt(t)){let n=tB(t.type)?e.currentTarget.querySelector(`[data-ec-container-header]`):e.currentTarget;n&&(n.classList.add(`ec-node-clickable`),Pt.current=n)}let r=new Set,i=[];for(let e of fn.current){if(e.source!==t.id&&e.target!==t.id)continue;let a=n.querySelector(`.react-flow__edge[data-id="${e.id}"]`);a&&(a.classList.add(`ec-node-hover-edge`),i.push(a)),e.source!==t.id&&r.add(e.source),e.target!==t.id&&r.add(e.target)}Mt.current=i,r.add(t.id);let a=Array.from(r).map(e=>`[data-id="${e}"]`).join(`, `);if(a){let e=n.querySelectorAll(a);e.forEach(e=>e.classList.add(`ec-edge-hover-node`)),Nt.current=Array.from(e)}},[jt]),It=(0,p.useCallback)(()=>{Pt.current?.classList.remove(`ec-node-clickable`),Pt.current=null,Mt.current.forEach(e=>e.classList.remove(`ec-node-hover-edge`)),Mt.current=[],Nt.current.forEach(e=>e.classList.remove(`ec-edge-hover-node`)),Nt.current=[]},[]),Lt=(0,p.useMemo)(()=>e.some(e=>e.type===`channels`),[e]),Rt=(0,p.useMemo)(()=>e.some(Hce),[e]),zt=(0,p.useMemo)(()=>e.some(oS),[e]),Bt=(0,p.useMemo)(()=>t.some(e=>e.type===`flow-edge`),[t]),Vt=(0,p.useCallback)(e=>{let t=Re.getState().nodeLookup.get(e.id)?.measured;return t?.width&&t?.height?{width:t.width,height:t.height}:Tx(e)},[Re]),Ht=(0,p.useCallback)(e=>ht.current===`lanes`?Sce(e):e,[]),Ut=(0,p.useCallback)(e=>{let t=ft.current,n=ht.current,r=xce(e.nodes);if(!r&&!t||r?.groupBy===t&&r?.style===n)return e;let i=Sce(e);return!t||n===`boxes`||t===`domain-system`?i:(gt.current=i,bce(i,t,{sizeOf:Vt}))},[]),Wt=(0,p.useMemo)(()=>e.some(e=>uLe.includes(e.type||``)),[e]),Gt=(0,p.useMemo)(()=>e.every(e=>Gz.includes(e.type||``)),[e]),Kt=(0,p.useMemo)(()=>s===`full`&&e.some(e=>!!e.data?.otherDomain),[e,s]),qt=(0,p.useRef)({}),{hideChannels:Jt,toggleChannelsVisibility:Yt,hideMessages:Xt,toggleMessagesVisibility:Zt,setDetailLevel:Qt,isLayingOut:$t,hiddenLegendKeys:en,toggleLegendKey:tn,highlightCrossDomain:nn,toggleHighlightCrossDomain:rn}=cIe({nodes:Ce,edges:Ee,setNodes:we,setEdges:De,hasChannels:Lt,hasLevel3Detail:zt,transitionFrom:w,nodeOrigin:lLe,disableAnimation:Qe,hiddenMessagesGraph:T,prepareEdges:xe,matchesLegendKey:(0,p.useCallback)((e,t)=>{let n=qt.current[t]?.groupId;return n?e.data?.group?.id===n:e.type===t},[]),initialHiddenLegendKeys:E,onHiddenLegendKeysChange:ee,preferenceScope:ie??v?.split(`/`)[0],ignoreSavedLevel:Bt,initialLevel:re,beforeLayout:Ht,afterLayout:Ut}),an=(0,p.useCallback)(e=>C?.(e,{nodes:Ae(),edges:Pe(),viewport:Fe()}),[C,Ae,Pe,Fe]),on=(0,p.useMemo)(()=>{if(Bt||!x&&!Gt&&!Wt)return[];let e=e=>{S&&an(!1),Qt(e)};return[{description:x??`domains, systems and relationships`,active:S||!x&&Gt,disabledReason:!x&&!Gt?`Not available here: this diagram has no overview of domains or systems`:void 0,onSelect:()=>{x&&!S&&an(!0)}},{description:`services and data stores`,active:!S&&!Gt&&(Xt||!zt),disabledReason:x||!Gt?void 0:`Not available here: this diagram only shows domains, systems and their relationships`,onSelect:()=>e(2)},{description:`messages and channels`,active:!S&&zt&&!Xt,disabledReason:S||zt?void 0:`Not available here: this diagram has no messages, channels or agent tools`,onSelect:()=>e(3)}]},[x,S,Gt,Wt,Bt,Xt,zt,Qt,an]),sn=(0,p.useMemo)(()=>Kt?[{label:nn?`Stop highlighting cross-domain communication`:`Highlight cross-domain communication`,icon:(0,k.jsx)(Cle,{className:`w-4 h-4`}),active:nn,onClick:rn}]:[],[Kt,nn,rn]),cn=(0,p.useRef)(null),ln=(0,p.useRef)(null),un=(0,p.useRef)(null),dn=(0,p.useRef)(Ce);dn.current=Ce;let fn=(0,p.useRef)(Ee);fn.current=Ee;let pn=(0,p.useRef)(0),mn=(0,p.useRef)(Jt);mn.current=Jt;let hn=(0,p.useRef)(``),gn=`${Ce.map(e=>`${e.id}:${e.type}`).join(`,`)}|${Ee.map(e=>`${e.source}>${e.target}`).join(`,`)}`;gn!==hn.current&&(hn.current=gn);let _n=hn.current,{walkthroughNodes:vn,walkthroughEdges:yn}=(0,p.useMemo)(()=>{let e=new Set(Ce.filter(e=>$z(e.type)||Wx(e)).map(e=>e.id));return{walkthroughNodes:Ce.filter(t=>!e.has(t.id)),walkthroughEdges:Ee.filter(t=>!e.has(t.source)&&!e.has(t.target))}},[_n]),bn=(0,p.useCallback)(()=>{let e=ln.current;e&&(e.classList.add(`ec-animating-layout`),setTimeout(()=>e.classList.remove(`ec-animating-layout`),400))},[]),xn=(0,p.useCallback)((e,t)=>{let n={x:t.x-80,y:t.y-80,width:t.width+160,height:t.height+160},r=new Set(je(n,!0).filter(t=>t.id!==e&&!t.parentId).map(e=>e.id));r.size!==0&&we(t=>{let i=IIe({nodes:t,movableNodeIds:r,protectedBounds:n,groupNodeId:e});return t.map(e=>{let t=i.get(e.id);return t?{...e,position:t}:e})})},[je,we]),Sn=(0,p.useCallback)(n=>{let r=n.target;if(!r.closest(`.ec-collapse-group-btn, .ec-collapse-flow-btn`))return;n.stopPropagation();let i=r.closest(`[data-id]`);if(!i)return;let a=i.getAttribute(`data-id`);if(!a)return;let o=dn.current,s=fn.current,c=o.find(e=>e.id===a);if(!c||!$z(c.type))return;pn.current++;let l=c.data.__preExpansion,u=l?.node??e.find(e=>e.id===a&&(e.type===`messageGroup`||e.type===`flows`||e.type===`flow`));if(!u)return;let d=l?.edges??t.filter(e=>e.source===a||e.target===a),f=new Set(o.filter(e=>e.parentId===a).map(e=>e.id)),p=u.data,m=new Set(l?l.nodeIds:e.map(e=>e.id)),h=new Set((p.expandedNodes||[]).map(e=>e.id).filter(e=>!m.has(e))),g=e=>e.id.startsWith(`${a}__`);bn(),we(e=>{let t=s.filter(e=>!f.has(e.source)&&!f.has(e.target)&&!g(e)).concat(d),n=new Set;for(let e of t)n.add(e.source),n.add(e.target);return[...e.filter(e=>e.id!==a&&!f.has(e.id)&&!(h.has(e.id)&&!n.has(e.id))).map(e=>{let t=l?.nodePositions?.[e.id];return!t||e.parentId?e:{...e,position:t}}),{...u,position:l?.nodePositions?.[a]??c.position}]}),De(e=>[...e.filter(e=>!f.has(e.source)&&!f.has(e.target)&&!g(e)),...d].map(e=>{let t=l?.edgeRoutes?.[e.id];return t?{...e,data:{...e.data,route:t}}:e}))},[e,t,we,De,bn]);(0,p.useEffect)(()=>{if(_&&e.length>0){let t={};e.forEach(e=>{t[e.id]={x:e.position.x,y:e.position.y}}),lt.current=t}},[_,e]);let Cn=(0,p.useCallback)(()=>{if(!_)return;let e=lt.current;if(Object.keys(e).length===0)return;let t=dn.current.some(t=>{let n=e[t.id];return n&&(Math.abs(t.position.x-n.x)>cLe||Math.abs(t.position.y-n.y)>cLe)});ot(t)},[_]),wn=(0,p.useCallback)(e=>{Te(e),e.some(e=>e.type===`position`&&!e.dragging)&&setTimeout(Cn,0)},[Te,Cn]),Tn=(0,p.useCallback)(()=>{we(e=>aB(e,xLe)),De(e=>aB(e,e=>SLe(e,ye)))},[we,De,ye]);(0,p.useEffect)(()=>{if(!oe)return;let e=dn.current.find(e=>e.id===oe);e&&(we(e=>e.map(e=>({...e,selected:e.id===oe}))),requestAnimationFrame(()=>{ke({duration:450,padding:.35,nodes:[e]})}))},[oe,se,ke,we]),(0,p.useEffect)(()=>{ce!=null&&requestAnimationFrame(()=>{ke({duration:400,padding:.2})})},[ce,ke]);let En=(0,p.useCallback)((e,t)=>{if(le){le(t);return}let n=()=>{if(e&&(e.metaKey||e.ctrlKey)){let e=fe?.(t);e&&window.open(e,`_blank`,`noopener`)}else e||ke({nodes:[{id:t.id}],maxZoom:1,duration:800}),Ot(t.id)},r=fn.current.some(e=>e.type===`flow-edge`),i=dn.current.some(e=>e.type===`entities`),a=(t.type===`flows`||t.type===`flow`)&&Array.isArray(t.data?.expandedNodes)&&t.data.expandedNodes.length>0;if((!r&&!i||a)&&!(a&&ft.current)&&!Wx(t)&&t.type!==`domain`&&t.type!==`domains`&&!_Le(t.type)&&t.type!==`context-actor`){if(tB(t.type))(!e||vLe(e))&&n();else if(!$z(t.type)){if(t.type===`messageGroup`){let e=t.data,n=t.id,r=LIe(dn.current,n);if(r?.type===`messageGroupExpanded`){let e=r?.measured,t=e?.width??r.style?.width??380,n=e?.height??r.style?.height??300;Ne(r.position.x+t/2,r.position.y+n/2,{duration:300,zoom:Math.min(Math.max(Me(),.55),1)});return}let i=`${e.service.id}-${e.service.version}`,a=e.messages?.length||0,o=a*190+100,s=fn.current.filter(e=>e.source===n||e.target===n),c=dn.current.map(e=>e.id),l=Object.fromEntries(dn.current.map(e=>[e.id,{...e.position}])),u={id:n,type:`messageGroupExpanded`,position:t.position,data:{groupName:e.groupName,direction:e.direction,messageCount:a,onCollapse:n,__preExpansion:{node:t,edges:s,nodeIds:c,nodePositions:l}},style:{width:380,height:o}},d=(e.messages||[]).map((t,r)=>{let i=t.message,a=`${i.data.id}-${i.data.version}`;return{id:`${n}__${a}`,type:i.collection,parentId:n,extent:`parent`,position:{x:70,y:70+r*190},data:{mode:e.mode||`simple`,message:{...i.data}}}}),f=new Map;for(let t of e.messages||[]){let e=t.message,r=`${e.data.id}-${e.data.version}`;f.set(r,`${n}__${r}`)}let p=ALe(e,n,i,f),m=mn.current?new Set((e.expandedNodes||[]).filter(e=>e.type===`channels`).map(e=>e.id)):new Set,h=(e.expandedNodes||[]).filter(e=>!m.has(e.id)),g=new Set,_=(e.expandedEdges||[]).map(e=>({...e,type:`animated`,source:f.get(e.source)||e.source,target:f.get(e.target)||e.target,id:`${n}__${e.id}`})).filter(e=>!(g.has(e.id)||(g.add(e.id),m.has(e.source)||m.has(e.target))));bn(),we(r=>{let i=e.direction===`sends`?t.position.x+380+260:t.position.x-420,a=t.position.y+40;return Dz({currentNodes:r,groupNodeId:n,expandedContainerNode:u,childNodes:d,downstreamNodes:h,getDownstreamPosition:(e,t)=>({x:i,y:a+t*190})})}),De(e=>[...e.filter(e=>e.source!==n&&e.target!==n),...xe([...p,..._])]),requestAnimationFrame(()=>{let e={x:t.position.x,y:t.position.y,width:380,height:o};we(r=>{let i=r.filter(e=>e.parentId===n);if(i.length===0)return r;let a=i.map(e=>{let t=document.querySelector(`[data-id="${e.id}"]`);return{id:e.id,w:t?.offsetWidth??240,h:t?.offsetHeight??120}}),o=50+(a.reduce((e,t)=>e+t.h,0)+25*(a.length-1))+60,s=80;return e={x:t.position.x,y:t.position.y,width:380,height:o},r.map(t=>{if(t.id===n)return e={x:t.position.x,y:t.position.y,width:380,height:o},{...t,style:{...t.style,height:o}};if(t.parentId!==n)return t;let r=a.find(e=>e.id===t.id);if(!r)return t;let i=Math.max(0,(380-r.w)/2),c=s;return s+=r.h+25,{...t,position:{x:i,y:c}}})}),requestAnimationFrame(()=>{let t=Ae().find(e=>e.id===n),r=t?.measured,i=r?.width??t?.style?.width??380,a=r?.height??t?.style?.height??e.height,o={x:t?.position.x??e.x,y:t?.position.y??e.y,width:i,height:a};xn(n,o),Ne(o.x+i/2,o.y+a/2,{duration:450,zoom:Math.min(Math.max(Me(),.55),1)})})})}else if(a){let e=t.data,n=t.id,r=e.expandedNodes||[],i=e.expandedEdges||[],a=r.map(e=>({...e,parentId:n,extent:`parent`,position:{x:0,y:0}})),o=fn.current.filter(e=>e.source===n||e.target===n),s=dn.current.map(e=>e.id),c=Object.fromEntries(dn.current.filter(e=>!e.parentId).map(e=>[e.id,e.position])),l=Object.fromEntries(fn.current.filter(e=>e.data?.route).map(e=>[e.id,e.data.route])),u={id:n,type:`flowExpanded`,position:t.position,data:{flowName:e.flow?.name||e.flow?.data?.name,version:e.flow?.version||e.flow?.data?.version,__preExpansion:{node:t,edges:o,nodeIds:s,nodePositions:c,edgeRoutes:l}},style:{background:`transparent`,border:`none`,padding:0,overflow:`visible`}},d=new Set(a.map(e=>e.id)),f=new Set,p=new Set;for(let e of i)d.has(e.target)&&f.add(e.target),d.has(e.source)&&p.add(e.source);let m=a.map(e=>e.id).filter(e=>!f.has(e)),h=a.map(e=>e.id).filter(e=>!p.has(e)),g=fn.current,_=g.filter(e=>e.target===n),v=g.filter(e=>e.source===n),y=[];for(let e of _)for(let t of m.length>0?m:[n])y.push({...e,id:`${e.id}__to__${t}`,target:t});let b=[];for(let e of v)for(let t of h.length>0?h:[n])b.push({...e,id:`${e.id}__from__${t}`,source:t});let x=++pn.current,S=dn.current;kx({nodes:[...S.filter(e=>e.id!==n),u,...a],edges:[...g.filter(e=>e.source!==n&&e.target!==n),...i,...y,...b]}).then(e=>{x===pn.current&&(bn(),we(e.nodes),De(e.edges),ke({duration:400,padding:.2}))})}else jt(t)&&n()}}},[le,fe,Ot,jt,ke,xn,Ae,Me,Ne,xe]),Dn=(0,p.useCallback)(()=>{be(e=>{let t=!e;return localStorage.setItem(uIe,JSON.stringify(t)),t})},[]),On=(0,p.useCallback)(()=>{ke({...KR,duration:400})},[ke]);(0,p.useEffect)(()=>{be(dIe({disabled:b,animated:y,nodeCount:e.length}))},[y,b,e.length]);let kn=(0,p.useRef)(ye);(0,p.useEffect)(()=>{kn.current!==ye&&(kn.current=ye,De(e=>cz(e,ye)))},[ye]),(0,p.useEffect)(()=>{w||setTimeout(()=>{ke({maxZoom:1,duration:800})},150)},[]);let An=(0,p.useRef)(Qe);(0,p.useEffect)(()=>{An.current&&!Qe&&ke(Kz),An.current=Qe},[Qe,ke]);let jn=(0,p.useCallback)(()=>{try{return nS(dn.current,fn.current,{includeStyles:!0,direction:`LR`})}catch(e){return console.error(`Error generating mermaid code:`,e),``}},[]);(0,p.useEffect)(()=>{if(m)return;un.current||=(()=>{for(let e of[`.docs-layout .overflow-y-auto`,`.overflow-y-auto`,`[style*="overflow-y:auto"]`,`[style*="overflow-y: auto"]`]){let t=document.querySelector(e);if(t)return t}return null})();let e=e=>{if(!e.target?.closest?.(`.ec-doc-card`)&&!e.ctrlKey&&!e.shiftKey&&!e.metaKey){e.preventDefault();let t=un.current;t?t.scrollBy({top:e.deltaY,left:e.deltaX,behavior:`instant`}):window.scrollBy({top:e.deltaY,left:e.deltaX,behavior:`instant`})}},t=ln.current;if(t)return t.addEventListener(`wheel`,e,{passive:!1}),()=>{t.removeEventListener(`wheel`,e)}},[m]);let Mn=(0,p.useCallback)(()=>{cn.current?.hideSuggestions(),Tn(),ke({maxZoom:1,duration:800})},[Tn,ke]),Nn=(0,p.useCallback)(e=>{En(null,e)},[En]),Pn=(0,p.useCallback)(()=>{Tn(),ke({maxZoom:1,duration:800})},[Tn,ke]),Fn=(0,p.useCallback)((e,t)=>{let n=document.createElement(`a`);n.setAttribute(`download`,`${t||`eventcatalog`}.png`),n.setAttribute(`href`,e),n.click()},[]),In=(0,p.useCallback)(()=>{window.dispatchEvent(new CustomEvent(`eventcatalog:open-chat`))},[]),Ln=(0,p.useCallback)(async()=>{if(!v||!pe||ft.current)return!1;let e={};return dn.current.forEach(t=>{Wx(t)||(e[t.id]={x:t.position.x,y:t.position.y})}),await pe(v,e)},[v,pe]),Rn=(0,p.useCallback)(async()=>{let{detail:e,overview:t,hiddenMessages:r}=ge,i=on.findIndex(e=>e.active)+1||3,a={nodes:Ae().filter(e=>!e.hidden),edges:Pe().filter(e=>!e.hidden)},o=new Map(e.nodes.map(e=>[e.id,e])),s=i===3?DLe(a.nodes,a.edges,e=>{let t=Le(e.id);return{position:t?.internals.positionAbsolute??e.position,width:t?.measured.width??e.width??0,height:t?.measured.height??e.height??0}}):DLe(e.nodes,e.edges,e=>{let t={...e.position};for(let n=e.parentId&&o.get(e.parentId);n;n=n.parentId&&o.get(n.parentId))t.x+=n.position.x,t.y+=n.position.y;return{position:t,...cB(e)}}),c=({nodes:e,edges:t})=>({nodes:e,edges:xe(t)}),l=async()=>{if(i===2)return a;if(r)return c(r);let t=i===3?a:e;return t.nodes.some(oS)?c(await kx(sS(t.nodes,t.edges))):c(t)};return{title:n,level:i,...s,levels:{...(i===1||t)&&{1:i===1?a:c(t)},2:await l()},unavailableLevels:{...on[0]?.disabledReason&&{1:on[0].disabledReason},...on[1]?.disabledReason&&{2:on[1].disabledReason}}}},[n,on,ge,xe,Ae,Pe,Le]),zn=(0,p.useCallback)(()=>{he&&ge&&he({title:n,getSnapshot:Rn})},[he,ge,n,Rn]),Bn=(0,p.useCallback)(async()=>!v||!me?!1:await me(v),[v,me]),Vn=(0,p.useCallback)(async()=>{ct(!0);let e=await Ln();if(ct(!1),e){let e={};dn.current.forEach(t=>{e[t.id]={x:t.position.x,y:t.position.y}}),lt.current=e,ot(!1)}},[Ln]),Hn=(0,p.useCallback)(async()=>{await qFe(jn())},[jn]),Un=(0,p.useCallback)(async()=>{await qFe(typeof window<`u`?window.location.href:``),Ze(!0),setTimeout(()=>Ze(!1),2e3)},[]),Wn=(0,p.useCallback)(()=>{document.fullscreenElement?document.exitFullscreen():ln.current?.requestFullscreen().catch(e=>{console.error(`Error attempting to enable full-screen mode: ${e.message} (${e.name})`)})},[]);(0,p.useEffect)(()=>{let e=()=>{Ue(!!document.fullscreenElement),setTimeout(()=>{ke({duration:800})},100)};return document.addEventListener(`fullscreenchange`,e),()=>{document.removeEventListener(`fullscreenchange`,e)}},[ke]);let Gn=(0,p.useCallback)(()=>{let{width:e,height:t,viewport:r}=gz(nae(Ae(),{nodeLookup:Re.getState().nodeLookup})),i=document.querySelector(`.react-flow__controls`);i&&(i.style.display=`none`);let a=document.querySelector(`.react-flow__viewport`),o=vz(a);Vme(a,{backgroundColor:`#f1f1f1`,width:e,height:t,pixelRatio:Xz,style:{width:`${e}px`,height:`${t}px`,transform:`translate(${r.x}px, ${r.y}px) scale(${r.zoom})`}}).then(e=>bz(e,Xz)).then(e=>{Fn(e,n)}).finally(()=>{o(),i&&(i.style.display=`block`)})},[Ae,Re,Fn,n]),Kn=(0,p.useCallback)(()=>{let e=ln.current?.querySelector(`svg[id^="mermaid-view"]`);if(!e)return;let t=getComputedStyle(ln.current).backgroundColor;Vme(e,{backgroundColor:t,pixelRatio:Xz}).then(e=>bz(e,Xz,{padding:hz,background:t})).then(e=>Fn(e,n))},[Fn,n]),qn=(0,p.useCallback)(()=>{let e=jn();if(!e)return;let t=URL.createObjectURL(new Blob([e],{type:`text/plain;charset=utf-8`})),r=document.createElement(`a`);r.setAttribute(`download`,`${n||`eventcatalog`}.mmd`),r.setAttribute(`href`,t),r.click(),URL.revokeObjectURL(t)},[jn,n]),Jn=(0,p.useRef)(``),Yn=Ce.map(e=>`${e.id}:${e.type}:${e.data.group?.id||``}`).join(`,`);Yn!==Jn.current&&(Jn.current=Yn);let Xn=Jn.current,Zn=(0,p.useMemo)(()=>WFe(Ce),[Xn]),Qn=(0,p.useRef)(null),$n=(0,p.useMemo)(()=>(Qn.current??=WFe(e),Object.assign(Qn.current,Zn),Object.fromEntries(Object.entries(Qn.current).filter(([e])=>e in Zn||en.includes(e)))),[Zn,en]);qt.current=$n;let er=(0,p.useRef)(``),tr=Ce.map(e=>e.id).join(`,`);tr!==er.current&&(er.current=tr);let nr=er.current;(0,p.useEffect)(()=>{Et&&!dn.current.some(e=>e.id===Et.node.id)&&Dt(null)},[nr,Et]);let rr=(0,p.useMemo)(()=>Ce.filter(e=>!Wx(e)),[nr]),ir=(0,p.useMemo)(()=>{let e=[];for(let t of Ce){let n=RIe(t);n&&e.push({nodeId:t.id,name:n.name,notes:n.notes,nodeType:n.nodeType})}return e},[nr]),ar=(0,p.useMemo)(()=>ir.reduce((e,t)=>e+t.notes.length,0),[ir]),[eee,or]=(0,p.useState)([]),sr=(0,p.useRef)([]),cr=(0,p.useCallback)((e,t,n=e?[e]:[])=>{if(e===null){Tn(),or([]),sr.current=[],Ve(null),t&&setTimeout(()=>{ke({duration:800,padding:.1})},100);return}let r=dn.current,i=fn.current;if(!r.find(t=>t.id===e))return;let a=new Set(n),o=new Set;n.slice(1).forEach((e,t)=>{let r=n[t];i.forEach(t=>{t.source===r&&t.target===e&&o.add(t.id)})});let s=i.filter(t=>t.source===e),c=new Set(s.map(e=>e.target)),l=e=>a.has(e.id)||Wx(e)?1:c.has(e.id)?.75:.15;we(r.map(t=>({...t,className:rB(t,t.id===e),style:{...t.style,opacity:l(t)}}))),De(i.map(t=>{let n=t.source===e,r=n||o.has(t.id);return{...t,data:{...t.data,opacity:r?1:.15,animated:n},style:{...t.style,opacity:r?1:.15,strokeWidth:r?3:2},labelStyle:{...t.labelStyle,opacity:r?1:.15},animated:n}})),or(n),sr.current=n;let u=ln.current?.getBoundingClientRect();if(!u)return;let d=nae([e,...c],{nodeLookup:Re.getState().nodeLookup}),f=Math.min(CLe,u.height*.35);Ie(sv(d,u.width,u.height-f,.1,.9,.15),{duration:700})},[we,De,Tn,Ie,Re]),lr=(0,p.useMemo)(()=>Bt?jx.filter(t=>Gx(e,t)):[],[Bt,e]),ur=(0,p.useMemo)(()=>Object.fromEntries(lr.map(t=>[t,Kx(e,t)])),[lr,e]),[dr,fr]=(0,p.useState)(0),pr=(0,p.useRef)(0),mr=(0,p.useCallback)((e,t=ht.current)=>{let n=t===`lanes`&&e===`domain-system`?`domain`:e;if(n===ft.current&&t===ht.current)return;let r=gt.current??{nodes:dn.current,edges:fn.current};gt.current=n?r:null,ft.current=n,ht.current=t,dt(n),mt(t);let i=++pr.current,a=e=>{i===pr.current&&(bn(),we(e.nodes),De(e.edges),fr(e=>e+1))};n?t===`lanes`&&n!==`domain-system`?a(bce(r,n,{sizeOf:Vt})):Cce(r,n,{sizeOf:Vt}).then(a):a(r),wLe(n,t)},[bn,we,De,Vt]);(0,p.useEffect)(()=>{if(dr===0)return;let e=sr.current;e.length>0?cr(e[e.length-1],!1,e):(Tn(),ke({duration:400,padding:.1}))},[dr]);let hr=Zb(),gr=(0,p.useRef)(!1);(0,p.useEffect)(()=>{if(!hr||gr.current)return;gr.current=!0;let t=TLe(),n=t.groupBy??ae,r=t.style??`boxes`;Mx(n)&&Gx(e,n)&&Nx(r)&&mr(n,r)},[hr]);let _r=!n,vr=_r?pIe:fIe,yr=_r?mIe:lz,br=(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`flex space-x-2 justify-between items-center pointer-events-auto`,children:[(0,k.jsx)(`div`,{className:`flex space-x-2 ml-4`,children:u&&(0,k.jsxs)(Ope,{children:[(0,k.jsx)(kpe,{asChild:!0,children:(0,k.jsxs)(`button`,{className:vr,"aria-label":`Open menu`,children:[n&&(0,k.jsx)(`span`,{className:`text-base font-medium text-[rgb(var(--ec-page-text))] leading-tight`,children:n}),(0,k.jsx)(tle,{className:yr})]})}),(0,k.jsx)(nD,{container:ln.current,children:(0,k.jsxs)(Ape,{className:`min-w-56 bg-[rgb(var(--ec-page-bg))] border border-[rgb(var(--ec-page-border))] rounded-lg shadow-xl z-50 py-1.5`,sideOffset:0,align:`end`,alignOffset:-180,children:[(0,k.jsx)(Npe,{className:`fill-[rgb(var(--ec-page-bg))] stroke-[rgb(var(--ec-page-border))] stroke-1`}),(0,k.jsx)(mz,{isMermaidView:Qe,setIsMermaidView:et,animateMessages:ye,toggleAnimateMessages:Dn,hideAnimateMessages:b,hideChannels:Jt,toggleChannelsVisibility:Yt,hasChannels:Lt,hideMessages:Xt,toggleMessagesVisibility:Zt,hasMessages:Rt,showMinimap:nt,setShowMinimap:it,handleFitView:On,searchRef:cn,isChatEnabled:h,openChat:In,handleCopyArchitectureCode:Hn,onOpenExport:Je,setIsShareModalOpen:Ge,toggleFullScreen:Wn,isDevMode:_,onSaveLayout:ut?void 0:Ln,onResetLayout:Bn,notesCount:ar,onOpenNotes:yt,onOpenInStudio:he?zn:void 0})]})})]})}),s===`full`&&l&&(0,k.jsx)(`div`,{className:`flex justify-end items-center gap-2`,children:!Qe&&(0,k.jsx)(`div`,{className:d?`w-60`:`w-96`,children:(0,k.jsx)(fFe,{ref:cn,nodes:rr,onNodeSelect:Nn,onClear:Pn})})})]}),o.length>0&&(0,k.jsx)(`div`,{className:`flex justify-end mt-3`,children:(0,k.jsxs)(`div`,{className:`relative flex items-center -mt-1`,children:[(0,k.jsx)(`span`,{className:`absolute left-2 pointer-events-none flex items-center h-full`,children:(0,k.jsx)(jS,{className:`h-4 w-4 text-[rgb(var(--ec-page-text-muted))]`})}),(0,k.jsx)(`select`,{value:o.find(e=>window.location.href.includes(e.url))?.url||o[0].url,onChange:e=>{let t=o.find(t=>t.url===e.target.value)?.url;if(!t)return;let n=Qe&&Yz()?dLe(t):t;de?de(n):window.location.href=n},className:`appearance-none pl-7 pr-6 py-0 text-[14px] bg-[rgb(var(--ec-card-bg))] text-[rgb(var(--ec-page-text))] rounded-md border border-[rgb(var(--ec-page-border))] hover:bg-[rgb(var(--ec-page-border)/0.5)] focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-[rgb(var(--ec-accent))]`,style:{minWidth:120,height:`26px`},children:o.map(e=>(0,k.jsx)(`option`,{value:e.url,children:e.label},e.url))}),(0,k.jsx)(`span`,{className:`absolute right-2 pointer-events-none`,children:(0,k.jsx)(`svg`,{className:`w-4 h-4 text-[rgb(var(--ec-page-text-muted))]`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,viewBox:`0 0 24 24`,children:(0,k.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M19 9l-7 7-7-7`})})})]})})]});return(0,k.jsx)(`div`,{ref:ln,onClick:Sn,className:`relative w-full h-full bg-[rgb(var(--ec-page-bg))] flex flex-col eventcatalog-visualizer`,style:{width:`100%`,height:`100%`,display:`flex`,flexDirection:`column`},children:(0,k.jsxs)($Me,{value:ln.current,children:[Qe?(0,k.jsxs)(`div`,{className:`flex-1 overflow-hidden relative`,children:[(0,k.jsx)(XR,{nodes:Ce,edges:Ee,maxTextSize:g,levels:s===`full`?on:[],zoomOnScroll:m,onShowDiagram:s===`full`?()=>et(!1):void 0}),(0,k.jsx)(by,{position:`top-center`,className:`w-full pr-6 pointer-events-none`,children:br})]}):(0,k.jsxs)(Use,{nodeTypes:_e,proOptions:f?qz:void 0,edgeTypes:ve,minZoom:.07,nodes:Ce,edges:Ee,fitView:!w,fitViewOptions:Kz,defaultViewport:w?.viewport,onNodesChange:wn,onEdgesChange:Oe,onEdgeMouseEnter:wt,onEdgeMouseLeave:Tt,connectionLineType:R_.SmoothStep,nodeOrigin:lLe,elevateNodesOnSelect:!1,onNodeClick:En,onNodeMouseEnter:Ft,onNodeMouseLeave:It,onPaneClick:Mn,onMoveStart:xt,onMoveEnd:St,onNodeDragStart:xt,onNodeDragStop:St,zoomOnScroll:m,className:`relative${$t?` ec-laying-out`:``}${Kt&&nn?` ec-highlight-cross-domain`:``}`,children:[(0,k.jsx)(by,{position:`top-center`,className:`w-full pr-6 pointer-events-none`,children:br}),r&&(0,k.jsx)(jFe,{}),r&&(0,k.jsx)($se,{}),s===`full`&&(0,k.jsx)(DFe,{levels:on,tools:sn,onShowMermaid:tt,animateMessages:ye,toggleAnimateMessages:Dn,hideAnimateMessages:b||Ee.length===0,showMinimap:nt,setShowMinimap:it,handleFitView:On}),nt&&(0,k.jsx)(BFe,{}),lr.length>0&&(0,k.jsx)(by,{position:`top-right`,style:s===`full`&&l?ELe:void 0,children:(0,k.jsx)(VR,{options:lr,counts:ur,value:ut,style:pt,onChange:mr})}),Bt&&c&&(0,k.jsx)(yFe,{trail:eee}),Bt&&c&&(0,k.jsx)(by,{position:`bottom-left`,children:(0,k.jsx)(K,{nodes:vn,edges:yn,isFlowVisualization:Bt,onStepChange:cr,mode:s})}),_&&at&&!ut&&(0,k.jsx)(by,{position:`bottom-left`,style:Bt&&c?Qz:mLe,children:(0,k.jsxs)(`div`,{className:`bg-[rgb(var(--ec-card-bg))] border border-[rgb(var(--ec-page-border))] rounded-lg shadow-md px-3 py-2 flex items-center gap-3`,children:[(0,k.jsx)(`span`,{className:`text-xs text-[rgb(var(--ec-page-text-muted))]`,children:`Layout changed`}),(0,k.jsx)(`button`,{onClick:Vn,disabled:st,className:`text-xs font-medium text-white bg-[rgb(var(--ec-accent))] hover:bg-[rgb(var(--ec-accent-hover))] px-2 py-1 rounded transition-colors disabled:opacity-50`,children:st?`Saving...`:`Save`})]})}),a&&(0,k.jsx)(KFe,{legend:$n,hiddenKeys:en,showMinimap:nt,onLegendClick:tn})]}),Et&&(0,k.jsx)(tLe,{...Et,onOpenDiagram:vI,onOpenNode:At,containerRef:ln,onClose:kt},Et.node.id),(0,k.jsx)(GIe,{noteGroups:ir,isOpen:_t,onClose:()=>vt(!1),nodes:Ce}),Ke&&(0,k.jsx)(nIe,{onClose:Ye,onExportImage:Qe?Kn:Gn,onExportMermaid:qn}),We&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:`absolute inset-0 bg-black/20 z-40`,onClick:()=>Ge(!1),style:{animation:`fadeIn 150ms ease-out`}}),(0,k.jsxs)(`div`,{className:`absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 bg-[rgb(var(--ec-page-bg))] rounded-lg shadow-xl z-50 w-[calc(100%-2rem)] max-w-md p-6 border border-[rgb(var(--ec-page-border))]`,style:{animation:`slideInCenter 250ms ease-out`},children:[(0,k.jsx)(`style`,{children:`
219
+ event`:t===`commands`||t===`queries`?`accepts`:`subscribed by`,kLe=(e,t,n)=>{let r=new Map;for(let e of n)r.has(e.source)||r.set(e.source,[]),r.get(e.source).push(e.target);let i=new Set([e]),a=[e];for(;a.length>0;){let e=a.shift();for(let n of r.get(e)||[]){if(n===t)return!0;i.has(n)||(i.add(n),a.push(n))}}return!1},ALe=(e,t,n,r)=>{let i=e.expandedEdges||[];return(e.messages||[]).map(t=>{let a=t.message,o=`${a.data.id}-${a.data.version}`,s=r.get(o),c=a.collection||`events`,l=OLe(e.direction,c);return e.direction===`sends`?{id:`${n}-to-${s}`,source:n,target:s,label:l,type:`animated`,style:lB,markerEnd:uB}:kLe(o,n,i)?null:{id:`${s}-to-${n}`,source:s,target:n,label:l,type:`animated`,style:lB,markerEnd:uB}}).filter(Boolean)},jLe=({nodes:e,edges:t,title:n,includeBackground:r=!0,linkTo:i=`docs`,includeKey:a=!0,links:o=[],mode:s=`full`,showFlowWalkthrough:c=!0,showSearch:l=!0,showMenu:u=!0,compactSearch:d=!1,hideAttribution:f=!1,zoomOnScroll:m=!1,isChatEnabled:h=!1,maxTextSize:g,isDevMode:_=!1,resourceKey:v,animated:y,disableMessageAnimation:b=!1,overviewLabel:x,isOverview:S=!1,onShowOverview:C,transitionFrom:w,hiddenMessagesGraph:T,initialHiddenLegendKeys:E,onHiddenLegendKeysChange:ee,initialMermaidView:te=!1,onMermaidViewChange:ne,initialLevel:re,preferenceScope:ie,swimlanes:ae,focusNodeId:oe,focusRequestId:se,fitRequestId:ce,onNodeClick:le,onBuildUrl:ue,onNavigate:de,getNodeDiagramUrl:fe,onSaveLayout:pe,onResetLayout:me,onOpenInStudio:he,studioGraphs:ge})=>{(0,p.useEffect)(()=>{ue&&qMe(ue)},[]);let _e=(0,p.useMemo)(()=>{let e=e=>{let t=t=>{let n=t.data?.contextMenu;return n?.length?(0,k.jsx)(hIe,{items:n,children:(0,k.jsx)(e,{...t})}):(0,k.jsx)(e,{...t})};return t.displayName=`WithContextMenu(${e.displayName||e.name||`Component`})`,t},t=e=>(0,k.jsx)(KMe,{...e,readOnly:!0});t.displayName=`ReadOnlyNoteNode`;let n={...Object.fromEntries(Object.entries(fR).map(([t,n])=>[t,pR.has(t)?e(n):n])),note:t};return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,vIe(t)]))},[]),ve=(0,p.useMemo)(()=>({animated:TR,multiline:tFe,"flow-edge":iFe,default:ER,smoothstep:oFe,step:sFe}),[]),[ye,be]=(0,p.useState)(()=>dIe({disabled:b,animated:y,nodeCount:e.length})),xe=(0,p.useCallback)(e=>cz(e,ye),[ye]),[Se]=(0,p.useState)(()=>xe(t)),[Ce,we,Te]=Wse(e),[Ee,De,Oe]=Yb(Se),{fitView:ke,getNodes:Ae,getIntersectingNodes:je,getZoom:Me,setCenter:Ne,getEdges:Pe,getViewport:Fe,setViewport:Ie,getInternalNode:Le}=qy(),Re=my(),ze=(0,p.useRef)({nodes:e,edges:t});(0,p.useEffect)(()=>{let n=ze.current;ze.current={nodes:e,edges:t},(n.nodes!==e||n.edges!==t)&&(we(e),De(xe(t)),requestAnimationFrame(()=>{ke({duration:300,padding:.2})}))},[e,t,we,De,ke,xe]);let[Be,Ve]=(0,p.useState)(null),[He,Ue]=(0,p.useState)(!1),[We,Ge]=(0,p.useState)(!1),[Ke,qe]=(0,p.useState)(!1),Je=(0,p.useCallback)(()=>qe(!0),[]),Ye=(0,p.useCallback)(()=>qe(!1),[]),[Xe,Ze]=(0,p.useState)(!1),[Qe,$e]=(0,p.useState)(te),et=(0,p.useCallback)(e=>{$e(e),ne?.(e)},[ne]),tt=(0,p.useCallback)(()=>et(!0),[et]),[nt,rt]=(0,p.useState)(RFe),it=(0,p.useCallback)(e=>{rt(e),HR(e)},[]),[at,ot]=(0,p.useState)(!1),[st,ct]=(0,p.useState)(!1),lt=(0,p.useRef)({}),[ut,dt]=(0,p.useState)(null),ft=(0,p.useRef)(null),[pt,mt]=(0,p.useState)(`boxes`),ht=(0,p.useRef)(`boxes`),gt=(0,p.useRef)(null),[_t,vt]=(0,p.useState)(!1),yt=(0,p.useCallback)(()=>vt(!0),[]),bt=(0,p.useRef)(0),xt=(0,p.useCallback)(()=>{bt.current+=1,bt.current===1&&(ln.current?.classList.add(`ec-interaction-active`),yIe(ln.current,!0))},[]),St=(0,p.useCallback)(()=>{bt.current=Math.max(0,bt.current-1),bt.current===0&&(ln.current?.classList.remove(`ec-interaction-active`),yIe(ln.current,!1))},[]),Ct=(0,p.useRef)([]),wt=(0,p.useCallback)((e,t)=>{let n=ln.current;if(!n)return;let r=n.querySelectorAll(`[data-id="${t.source}"], [data-id="${t.target}"]`);r.forEach(e=>e.classList.add(`ec-edge-hover-node`)),Ct.current=Array.from(r)},[]),Tt=(0,p.useCallback)(()=>{Ct.current.forEach(e=>e.classList.remove(`ec-edge-hover-node`)),Ct.current=[]},[]),[Et,Dt]=(0,p.useState)(null),Ot=(0,p.useCallback)(e=>{let t=dn.current,n=t.find(t=>t.id===e);if(!n)return;let r=n.parentId?t.find(e=>e.id===n.parentId):void 0,i=MR(n),a=i?_I(i):void 0;Dt({node:{id:n.id,type:n.type,data:n.data},...r&&tB(r.type)&&{parentName:NR(r).name},neighbours:sLe(e,t,fn.current),diagramUrl:fe?.(n),docsUrl:a&&!bLe(a)?a:void 0})},[fe]),kt=(0,p.useCallback)(()=>Dt(null),[]),At=(0,p.useCallback)(e=>{let t=Me();ke({nodes:[{id:e}],duration:400,minZoom:t,maxZoom:t}),Ot(e)},[ke,Me,Ot]),jt=(0,p.useCallback)(e=>!e.type||yLe.has(e.type)||_Le(e.type)||$z(e.type)||[`domain`,`domains`,`context-actor`,`messageGroup`].includes(e.type)||Wx(e)?!1:!fn.current.some(e=>e.type===`flow-edge`)&&!dn.current.some(e=>e.type===`entities`),[]),Mt=(0,p.useRef)([]),Nt=(0,p.useRef)([]),Pt=(0,p.useRef)(null),Ft=(0,p.useCallback)((e,t)=>{let n=ln.current;if(!n)return;if(jt(t)){let n=tB(t.type)?e.currentTarget.querySelector(`[data-ec-container-header]`):e.currentTarget;n&&(n.classList.add(`ec-node-clickable`),Pt.current=n)}let r=new Set,i=[];for(let e of fn.current){if(e.source!==t.id&&e.target!==t.id)continue;let a=n.querySelector(`.react-flow__edge[data-id="${e.id}"]`);a&&(a.classList.add(`ec-node-hover-edge`),i.push(a)),e.source!==t.id&&r.add(e.source),e.target!==t.id&&r.add(e.target)}Mt.current=i,r.add(t.id);let a=Array.from(r).map(e=>`[data-id="${e}"]`).join(`, `);if(a){let e=n.querySelectorAll(a);e.forEach(e=>e.classList.add(`ec-edge-hover-node`)),Nt.current=Array.from(e)}},[jt]),It=(0,p.useCallback)(()=>{Pt.current?.classList.remove(`ec-node-clickable`),Pt.current=null,Mt.current.forEach(e=>e.classList.remove(`ec-node-hover-edge`)),Mt.current=[],Nt.current.forEach(e=>e.classList.remove(`ec-edge-hover-node`)),Nt.current=[]},[]),Lt=(0,p.useMemo)(()=>e.some(e=>e.type===`channels`),[e]),Rt=(0,p.useMemo)(()=>e.some(Hce),[e]),zt=(0,p.useMemo)(()=>e.some(oS),[e]),Bt=(0,p.useMemo)(()=>t.some(e=>e.type===`flow-edge`),[t]),Vt=(0,p.useCallback)(e=>{let t=Re.getState().nodeLookup.get(e.id)?.measured;return t?.width&&t?.height?{width:t.width,height:t.height}:Tx(e)},[Re]),Ht=(0,p.useCallback)(e=>ht.current===`lanes`?Sce(e):e,[]),Ut=(0,p.useCallback)(e=>{let t=ft.current,n=ht.current,r=xce(e.nodes);if(!r&&!t||r?.groupBy===t&&r?.style===n)return e;let i=Sce(e);return!t||n===`boxes`||t===`domain-system`?i:(gt.current=i,bce(i,t,{sizeOf:Vt}))},[]),Wt=(0,p.useMemo)(()=>e.some(e=>uLe.includes(e.type||``)),[e]),Gt=(0,p.useMemo)(()=>e.every(e=>Gz.includes(e.type||``)),[e]),Kt=(0,p.useMemo)(()=>s===`full`&&e.some(e=>!!e.data?.otherDomain),[e,s]),qt=(0,p.useRef)({}),{hideChannels:Jt,toggleChannelsVisibility:Yt,hideMessages:Xt,toggleMessagesVisibility:Zt,setDetailLevel:Qt,isLayingOut:$t,hiddenLegendKeys:en,toggleLegendKey:tn,highlightCrossDomain:nn,toggleHighlightCrossDomain:rn}=cIe({nodes:Ce,edges:Ee,setNodes:we,setEdges:De,hasChannels:Lt,hasLevel3Detail:zt,transitionFrom:w,nodeOrigin:lLe,disableAnimation:Qe,hiddenMessagesGraph:T,prepareEdges:xe,matchesLegendKey:(0,p.useCallback)((e,t)=>{let n=qt.current[t]?.groupId;return n?e.data?.group?.id===n:e.type===t},[]),initialHiddenLegendKeys:E,onHiddenLegendKeysChange:ee,preferenceScope:ie??v?.split(`/`)[0],ignoreSavedLevel:Bt,initialLevel:re,beforeLayout:Ht,afterLayout:Ut}),an=(0,p.useCallback)(e=>C?.(e,{nodes:Ae(),edges:Pe(),viewport:Fe()}),[C,Ae,Pe,Fe]),on=(0,p.useMemo)(()=>{if(Bt||!x&&!Gt&&!Wt)return[];let e=e=>{S&&an(!1),Qt(e)};return[{description:x??`domains, systems and relationships`,active:S||!x&&Gt,disabledReason:!x&&!Gt?`Not available here: this diagram has no overview of domains or systems`:void 0,onSelect:()=>{x&&!S&&an(!0)}},{description:`services and data stores`,active:!S&&!Gt&&(Xt||!zt),disabledReason:x||!Gt?void 0:`Not available here: this diagram only shows domains, systems and their relationships`,onSelect:()=>e(2)},{description:`messages and channels`,active:!S&&zt&&!Xt,disabledReason:S||zt?void 0:`Not available here: this diagram has no messages, channels or agent tools`,onSelect:()=>e(3)}]},[x,S,Gt,Wt,Bt,Xt,zt,Qt,an]),sn=(0,p.useMemo)(()=>Kt?[{label:nn?`Stop highlighting cross-domain communication`:`Highlight cross-domain communication`,icon:(0,k.jsx)(Cle,{className:`w-4 h-4`}),active:nn,onClick:rn}]:[],[Kt,nn,rn]),cn=(0,p.useRef)(null),ln=(0,p.useRef)(null),un=(0,p.useRef)(null),dn=(0,p.useRef)(Ce);dn.current=Ce;let fn=(0,p.useRef)(Ee);fn.current=Ee;let pn=(0,p.useRef)(0),mn=(0,p.useRef)(Jt);mn.current=Jt;let hn=(0,p.useRef)(``),gn=`${Ce.map(e=>`${e.id}:${e.type}`).join(`,`)}|${Ee.map(e=>`${e.source}>${e.target}`).join(`,`)}`;gn!==hn.current&&(hn.current=gn);let _n=hn.current,{walkthroughNodes:vn,walkthroughEdges:yn}=(0,p.useMemo)(()=>{let e=new Set(Ce.filter(e=>$z(e.type)||Wx(e)).map(e=>e.id));return{walkthroughNodes:Ce.filter(t=>!e.has(t.id)),walkthroughEdges:Ee.filter(t=>!e.has(t.source)&&!e.has(t.target))}},[_n]),bn=(0,p.useCallback)(()=>{let e=ln.current;e&&(e.classList.add(`ec-animating-layout`),setTimeout(()=>e.classList.remove(`ec-animating-layout`),400))},[]),xn=(0,p.useCallback)((e,t)=>{let n={x:t.x-80,y:t.y-80,width:t.width+160,height:t.height+160},r=new Set(je(n,!0).filter(t=>t.id!==e&&!t.parentId).map(e=>e.id));r.size!==0&&we(t=>{let i=IIe({nodes:t,movableNodeIds:r,protectedBounds:n,groupNodeId:e});return t.map(e=>{let t=i.get(e.id);return t?{...e,position:t}:e})})},[je,we]),Sn=(0,p.useCallback)(n=>{let r=n.target;if(!r.closest(`.ec-collapse-group-btn, .ec-collapse-flow-btn`))return;n.stopPropagation();let i=r.closest(`[data-id]`);if(!i)return;let a=i.getAttribute(`data-id`);if(!a)return;let o=dn.current,s=fn.current,c=o.find(e=>e.id===a);if(!c||!$z(c.type))return;pn.current++;let l=c.data.__preExpansion,u=l?.node??e.find(e=>e.id===a&&(e.type===`messageGroup`||e.type===`flows`||e.type===`flow`));if(!u)return;let d=l?.edges??t.filter(e=>e.source===a||e.target===a),f=new Set(o.filter(e=>e.parentId===a).map(e=>e.id)),p=u.data,m=new Set(l?l.nodeIds:e.map(e=>e.id)),h=new Set((p.expandedNodes||[]).map(e=>e.id).filter(e=>!m.has(e))),g=e=>e.id.startsWith(`${a}__`);bn(),we(e=>{let t=s.filter(e=>!f.has(e.source)&&!f.has(e.target)&&!g(e)).concat(d),n=new Set;for(let e of t)n.add(e.source),n.add(e.target);return[...e.filter(e=>e.id!==a&&!f.has(e.id)&&!(h.has(e.id)&&!n.has(e.id))).map(e=>{let t=l?.nodePositions?.[e.id];return!t||e.parentId?e:{...e,position:t}}),{...u,position:l?.nodePositions?.[a]??c.position}]}),De(e=>[...e.filter(e=>!f.has(e.source)&&!f.has(e.target)&&!g(e)),...d].map(e=>{let t=l?.edgeRoutes?.[e.id];return t?{...e,data:{...e.data,route:t}}:e}))},[e,t,we,De,bn]);(0,p.useEffect)(()=>{if(_&&e.length>0){let t={};e.forEach(e=>{t[e.id]={x:e.position.x,y:e.position.y}}),lt.current=t}},[_,e]);let Cn=(0,p.useCallback)(()=>{if(!_)return;let e=lt.current;if(Object.keys(e).length===0)return;let t=dn.current.some(t=>{let n=e[t.id];return n&&(Math.abs(t.position.x-n.x)>cLe||Math.abs(t.position.y-n.y)>cLe)});ot(t)},[_]),wn=(0,p.useCallback)(e=>{Te(e),e.some(e=>e.type===`position`&&!e.dragging)&&setTimeout(Cn,0)},[Te,Cn]),Tn=(0,p.useCallback)(()=>{we(e=>aB(e,xLe)),De(e=>aB(e,e=>SLe(e,ye)))},[we,De,ye]);(0,p.useEffect)(()=>{if(!oe)return;let e=dn.current.find(e=>e.id===oe);e&&(we(e=>e.map(e=>({...e,selected:e.id===oe}))),requestAnimationFrame(()=>{ke({duration:450,padding:.35,nodes:[e]})}))},[oe,se,ke,we]),(0,p.useEffect)(()=>{ce!=null&&requestAnimationFrame(()=>{ke({duration:400,padding:.2})})},[ce,ke]);let En=(0,p.useCallback)((e,t)=>{if(le){le(t);return}let n=()=>{if(e&&(e.metaKey||e.ctrlKey)){let e=fe?.(t);e&&window.open(e,`_blank`,`noopener`)}else e||ke({nodes:[{id:t.id}],maxZoom:1,duration:800}),Ot(t.id)},r=fn.current.some(e=>e.type===`flow-edge`),i=dn.current.some(e=>e.type===`entities`),a=(t.type===`flows`||t.type===`flow`)&&Array.isArray(t.data?.expandedNodes)&&t.data.expandedNodes.length>0;if((!r&&!i||a)&&!(a&&ft.current)&&!Wx(t)&&t.type!==`domain`&&t.type!==`domains`&&!_Le(t.type)&&t.type!==`context-actor`){if(tB(t.type))(!e||vLe(e))&&n();else if(!$z(t.type)){if(t.type===`messageGroup`){let e=t.data,n=t.id,r=LIe(dn.current,n);if(r?.type===`messageGroupExpanded`){let e=r?.measured,t=e?.width??r.style?.width??380,n=e?.height??r.style?.height??300;Ne(r.position.x+t/2,r.position.y+n/2,{duration:300,zoom:Math.min(Math.max(Me(),.55),1)});return}let i=`${e.service.id}-${e.service.version}`,a=e.messages?.length||0,o=a*190+100,s=fn.current.filter(e=>e.source===n||e.target===n),c=dn.current.map(e=>e.id),l=Object.fromEntries(dn.current.map(e=>[e.id,{...e.position}])),u={id:n,type:`messageGroupExpanded`,position:t.position,data:{groupName:e.groupName,direction:e.direction,messageCount:a,onCollapse:n,__preExpansion:{node:t,edges:s,nodeIds:c,nodePositions:l}},style:{width:380,height:o}},d=(e.messages||[]).map((t,r)=>{let i=t.message,a=`${i.data.id}-${i.data.version}`;return{id:`${n}__${a}`,type:i.collection,parentId:n,extent:`parent`,position:{x:70,y:70+r*190},data:{mode:e.mode||`simple`,message:{...i.data}}}}),f=new Map;for(let t of e.messages||[]){let e=t.message,r=`${e.data.id}-${e.data.version}`;f.set(r,`${n}__${r}`)}let p=ALe(e,n,i,f),m=mn.current?new Set((e.expandedNodes||[]).filter(e=>e.type===`channels`).map(e=>e.id)):new Set,h=(e.expandedNodes||[]).filter(e=>!m.has(e.id)),g=new Set,_=(e.expandedEdges||[]).map(e=>({...e,type:`animated`,source:f.get(e.source)||e.source,target:f.get(e.target)||e.target,id:`${n}__${e.id}`})).filter(e=>!(g.has(e.id)||(g.add(e.id),m.has(e.source)||m.has(e.target))));bn(),we(r=>{let i=e.direction===`sends`?t.position.x+380+260:t.position.x-420,a=t.position.y+40;return Dz({currentNodes:r,groupNodeId:n,expandedContainerNode:u,childNodes:d,downstreamNodes:h,getDownstreamPosition:(e,t)=>({x:i,y:a+t*190})})}),De(e=>[...e.filter(e=>e.source!==n&&e.target!==n),...xe([...p,..._])]),requestAnimationFrame(()=>{let e={x:t.position.x,y:t.position.y,width:380,height:o};we(r=>{let i=r.filter(e=>e.parentId===n);if(i.length===0)return r;let a=i.map(e=>{let t=document.querySelector(`[data-id="${e.id}"]`);return{id:e.id,w:t?.offsetWidth??240,h:t?.offsetHeight??120}}),o=50+(a.reduce((e,t)=>e+t.h,0)+25*(a.length-1))+60,s=80;return e={x:t.position.x,y:t.position.y,width:380,height:o},r.map(t=>{if(t.id===n)return e={x:t.position.x,y:t.position.y,width:380,height:o},{...t,style:{...t.style,height:o}};if(t.parentId!==n)return t;let r=a.find(e=>e.id===t.id);if(!r)return t;let i=Math.max(0,(380-r.w)/2),c=s;return s+=r.h+25,{...t,position:{x:i,y:c}}})}),requestAnimationFrame(()=>{let t=Ae().find(e=>e.id===n),r=t?.measured,i=r?.width??t?.style?.width??380,a=r?.height??t?.style?.height??e.height,o={x:t?.position.x??e.x,y:t?.position.y??e.y,width:i,height:a};xn(n,o),Ne(o.x+i/2,o.y+a/2,{duration:450,zoom:Math.min(Math.max(Me(),.55),1)})})})}else if(a){let e=t.data,n=t.id,r=e.expandedNodes||[],i=e.expandedEdges||[],a=r.map(e=>({...e,parentId:n,extent:`parent`,position:{x:0,y:0}})),o=fn.current.filter(e=>e.source===n||e.target===n),s=dn.current.map(e=>e.id),c=Object.fromEntries(dn.current.filter(e=>!e.parentId).map(e=>[e.id,e.position])),l=Object.fromEntries(fn.current.filter(e=>e.data?.route).map(e=>[e.id,e.data.route])),u={id:n,type:`flowExpanded`,position:t.position,data:{flowName:e.flow?.name||e.flow?.data?.name,version:e.flow?.version||e.flow?.data?.version,__preExpansion:{node:t,edges:o,nodeIds:s,nodePositions:c,edgeRoutes:l}},style:{background:`transparent`,border:`none`,padding:0,overflow:`visible`}},d=new Set(a.map(e=>e.id)),f=new Set,p=new Set;for(let e of i)d.has(e.target)&&f.add(e.target),d.has(e.source)&&p.add(e.source);let m=a.map(e=>e.id).filter(e=>!f.has(e)),h=a.map(e=>e.id).filter(e=>!p.has(e)),g=fn.current,_=g.filter(e=>e.target===n),v=g.filter(e=>e.source===n),y=[];for(let e of _)for(let t of m.length>0?m:[n])y.push({...e,id:`${e.id}__to__${t}`,target:t});let b=[];for(let e of v)for(let t of h.length>0?h:[n])b.push({...e,id:`${e.id}__from__${t}`,source:t});let x=++pn.current,S=dn.current;kx({nodes:[...S.filter(e=>e.id!==n),u,...a],edges:[...g.filter(e=>e.source!==n&&e.target!==n),...i,...y,...b]}).then(e=>{x===pn.current&&(bn(),we(e.nodes),De(e.edges),ke({duration:400,padding:.2}))})}else jt(t)&&n()}}},[le,fe,Ot,jt,ke,xn,Ae,Me,Ne,xe]),Dn=(0,p.useCallback)(()=>{be(e=>{let t=!e;return localStorage.setItem(uIe,JSON.stringify(t)),t})},[]),On=(0,p.useCallback)(()=>{ke({...KR,duration:400})},[ke]);(0,p.useEffect)(()=>{be(dIe({disabled:b,animated:y,nodeCount:e.length}))},[y,b,e.length]);let kn=(0,p.useRef)(ye);(0,p.useEffect)(()=>{kn.current!==ye&&(kn.current=ye,De(e=>cz(e,ye)))},[ye]),(0,p.useEffect)(()=>{w||setTimeout(()=>{ke({maxZoom:1,duration:800})},150)},[]);let An=(0,p.useRef)(Qe);(0,p.useEffect)(()=>{An.current&&!Qe&&ke(Kz),An.current=Qe},[Qe,ke]);let jn=(0,p.useCallback)(()=>{try{return nS(dn.current,fn.current,{includeStyles:!0,direction:`LR`})}catch(e){return console.error(`Error generating mermaid code:`,e),``}},[]);(0,p.useEffect)(()=>{if(m)return;un.current||=(()=>{for(let e of[`.docs-layout .overflow-y-auto`,`.overflow-y-auto`,`[style*="overflow-y:auto"]`,`[style*="overflow-y: auto"]`]){let t=document.querySelector(e);if(t)return t}return null})();let e=e=>{if(!e.target?.closest?.(`.ec-doc-card`)&&!e.ctrlKey&&!e.shiftKey&&!e.metaKey){e.preventDefault();let t=un.current;t?t.scrollBy({top:e.deltaY,left:e.deltaX,behavior:`instant`}):window.scrollBy({top:e.deltaY,left:e.deltaX,behavior:`instant`})}},t=ln.current;if(t)return t.addEventListener(`wheel`,e,{passive:!1}),()=>{t.removeEventListener(`wheel`,e)}},[m]);let Mn=(0,p.useCallback)(()=>{cn.current?.hideSuggestions(),Tn()},[Tn]),Nn=(0,p.useCallback)(e=>{En(null,e)},[En]),Pn=(0,p.useCallback)(()=>{Tn(),ke({maxZoom:1,duration:800})},[Tn,ke]),Fn=(0,p.useCallback)((e,t)=>{let n=document.createElement(`a`);n.setAttribute(`download`,`${t||`eventcatalog`}.png`),n.setAttribute(`href`,e),n.click()},[]),In=(0,p.useCallback)(()=>{window.dispatchEvent(new CustomEvent(`eventcatalog:open-chat`))},[]),Ln=(0,p.useCallback)(async()=>{if(!v||!pe||ft.current)return!1;let e={};return dn.current.forEach(t=>{Wx(t)||(e[t.id]={x:t.position.x,y:t.position.y})}),await pe(v,e)},[v,pe]),Rn=(0,p.useCallback)(async()=>{let{detail:e,overview:t,hiddenMessages:r}=ge,i=on.findIndex(e=>e.active)+1||3,a={nodes:Ae().filter(e=>!e.hidden),edges:Pe().filter(e=>!e.hidden)},o=new Map(e.nodes.map(e=>[e.id,e])),s=i===3?DLe(a.nodes,a.edges,e=>{let t=Le(e.id);return{position:t?.internals.positionAbsolute??e.position,width:t?.measured.width??e.width??0,height:t?.measured.height??e.height??0}}):DLe(e.nodes,e.edges,e=>{let t={...e.position};for(let n=e.parentId&&o.get(e.parentId);n;n=n.parentId&&o.get(n.parentId))t.x+=n.position.x,t.y+=n.position.y;return{position:t,...cB(e)}}),c=({nodes:e,edges:t})=>({nodes:e,edges:xe(t)}),l=async()=>{if(i===2)return a;if(r)return c(r);let t=i===3?a:e;return t.nodes.some(oS)?c(await kx(sS(t.nodes,t.edges))):c(t)};return{title:n,level:i,...s,levels:{...(i===1||t)&&{1:i===1?a:c(t)},2:await l()},unavailableLevels:{...on[0]?.disabledReason&&{1:on[0].disabledReason},...on[1]?.disabledReason&&{2:on[1].disabledReason}}}},[n,on,ge,xe,Ae,Pe,Le]),zn=(0,p.useCallback)(()=>{he&&ge&&he({title:n,getSnapshot:Rn})},[he,ge,n,Rn]),Bn=(0,p.useCallback)(async()=>!v||!me?!1:await me(v),[v,me]),Vn=(0,p.useCallback)(async()=>{ct(!0);let e=await Ln();if(ct(!1),e){let e={};dn.current.forEach(t=>{e[t.id]={x:t.position.x,y:t.position.y}}),lt.current=e,ot(!1)}},[Ln]),Hn=(0,p.useCallback)(async()=>{await qFe(jn())},[jn]),Un=(0,p.useCallback)(async()=>{await qFe(typeof window<`u`?window.location.href:``),Ze(!0),setTimeout(()=>Ze(!1),2e3)},[]),Wn=(0,p.useCallback)(()=>{document.fullscreenElement?document.exitFullscreen():ln.current?.requestFullscreen().catch(e=>{console.error(`Error attempting to enable full-screen mode: ${e.message} (${e.name})`)})},[]);(0,p.useEffect)(()=>{let e=()=>{Ue(!!document.fullscreenElement),setTimeout(()=>{ke({duration:800})},100)};return document.addEventListener(`fullscreenchange`,e),()=>{document.removeEventListener(`fullscreenchange`,e)}},[ke]);let Gn=(0,p.useCallback)(()=>{let{width:e,height:t,viewport:r}=gz(nae(Ae(),{nodeLookup:Re.getState().nodeLookup})),i=document.querySelector(`.react-flow__controls`);i&&(i.style.display=`none`);let a=document.querySelector(`.react-flow__viewport`),o=vz(a);Vme(a,{backgroundColor:`#f1f1f1`,width:e,height:t,pixelRatio:Xz,style:{width:`${e}px`,height:`${t}px`,transform:`translate(${r.x}px, ${r.y}px) scale(${r.zoom})`}}).then(e=>bz(e,Xz)).then(e=>{Fn(e,n)}).finally(()=>{o(),i&&(i.style.display=`block`)})},[Ae,Re,Fn,n]),Kn=(0,p.useCallback)(()=>{let e=ln.current?.querySelector(`svg[id^="mermaid-view"]`);if(!e)return;let t=getComputedStyle(ln.current).backgroundColor;Vme(e,{backgroundColor:t,pixelRatio:Xz}).then(e=>bz(e,Xz,{padding:hz,background:t})).then(e=>Fn(e,n))},[Fn,n]),qn=(0,p.useCallback)(()=>{let e=jn();if(!e)return;let t=URL.createObjectURL(new Blob([e],{type:`text/plain;charset=utf-8`})),r=document.createElement(`a`);r.setAttribute(`download`,`${n||`eventcatalog`}.mmd`),r.setAttribute(`href`,t),r.click(),URL.revokeObjectURL(t)},[jn,n]),Jn=(0,p.useRef)(``),Yn=Ce.map(e=>`${e.id}:${e.type}:${e.data.group?.id||``}`).join(`,`);Yn!==Jn.current&&(Jn.current=Yn);let Xn=Jn.current,Zn=(0,p.useMemo)(()=>WFe(Ce),[Xn]),Qn=(0,p.useRef)(null),$n=(0,p.useMemo)(()=>(Qn.current??=WFe(e),Object.assign(Qn.current,Zn),Object.fromEntries(Object.entries(Qn.current).filter(([e])=>e in Zn||en.includes(e)))),[Zn,en]);qt.current=$n;let er=(0,p.useRef)(``),tr=Ce.map(e=>e.id).join(`,`);tr!==er.current&&(er.current=tr);let nr=er.current;(0,p.useEffect)(()=>{Et&&!dn.current.some(e=>e.id===Et.node.id)&&Dt(null)},[nr,Et]);let rr=(0,p.useMemo)(()=>Ce.filter(e=>!Wx(e)),[nr]),ir=(0,p.useMemo)(()=>{let e=[];for(let t of Ce){let n=RIe(t);n&&e.push({nodeId:t.id,name:n.name,notes:n.notes,nodeType:n.nodeType})}return e},[nr]),ar=(0,p.useMemo)(()=>ir.reduce((e,t)=>e+t.notes.length,0),[ir]),[eee,or]=(0,p.useState)([]),sr=(0,p.useRef)([]),cr=(0,p.useCallback)((e,t,n=e?[e]:[])=>{if(e===null){Tn(),or([]),sr.current=[],Ve(null),t&&setTimeout(()=>{ke({duration:800,padding:.1})},100);return}let r=dn.current,i=fn.current;if(!r.find(t=>t.id===e))return;let a=new Set(n),o=new Set;n.slice(1).forEach((e,t)=>{let r=n[t];i.forEach(t=>{t.source===r&&t.target===e&&o.add(t.id)})});let s=i.filter(t=>t.source===e),c=new Set(s.map(e=>e.target)),l=e=>a.has(e.id)||Wx(e)?1:c.has(e.id)?.75:.15;we(r.map(t=>({...t,className:rB(t,t.id===e),style:{...t.style,opacity:l(t)}}))),De(i.map(t=>{let n=t.source===e,r=n||o.has(t.id);return{...t,data:{...t.data,opacity:r?1:.15,animated:n},style:{...t.style,opacity:r?1:.15,strokeWidth:r?3:2},labelStyle:{...t.labelStyle,opacity:r?1:.15},animated:n}})),or(n),sr.current=n;let u=ln.current?.getBoundingClientRect();if(!u)return;let d=nae([e,...c],{nodeLookup:Re.getState().nodeLookup}),f=Math.min(CLe,u.height*.35);Ie(sv(d,u.width,u.height-f,.1,.9,.15),{duration:700})},[we,De,Tn,Ie,Re]),lr=(0,p.useMemo)(()=>Bt?jx.filter(t=>Gx(e,t)):[],[Bt,e]),ur=(0,p.useMemo)(()=>Object.fromEntries(lr.map(t=>[t,Kx(e,t)])),[lr,e]),[dr,fr]=(0,p.useState)(0),pr=(0,p.useRef)(0),mr=(0,p.useCallback)((e,t=ht.current)=>{let n=t===`lanes`&&e===`domain-system`?`domain`:e;if(n===ft.current&&t===ht.current)return;let r=gt.current??{nodes:dn.current,edges:fn.current};gt.current=n?r:null,ft.current=n,ht.current=t,dt(n),mt(t);let i=++pr.current,a=e=>{i===pr.current&&(bn(),we(e.nodes),De(e.edges),fr(e=>e+1))};n?t===`lanes`&&n!==`domain-system`?a(bce(r,n,{sizeOf:Vt})):Cce(r,n,{sizeOf:Vt}).then(a):a(r),wLe(n,t)},[bn,we,De,Vt]);(0,p.useEffect)(()=>{if(dr===0)return;let e=sr.current;e.length>0?cr(e[e.length-1],!1,e):(Tn(),ke({duration:400,padding:.1}))},[dr]);let hr=Zb(),gr=(0,p.useRef)(!1);(0,p.useEffect)(()=>{if(!hr||gr.current)return;gr.current=!0;let t=TLe(),n=t.groupBy??ae,r=t.style??`boxes`;Mx(n)&&Gx(e,n)&&Nx(r)&&mr(n,r)},[hr]);let _r=!n,vr=_r?pIe:fIe,yr=_r?mIe:lz,br=(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:`flex space-x-2 justify-between items-center pointer-events-auto`,children:[(0,k.jsx)(`div`,{className:`flex space-x-2 ml-4`,children:u&&(0,k.jsxs)(Ope,{children:[(0,k.jsx)(kpe,{asChild:!0,children:(0,k.jsxs)(`button`,{className:vr,"aria-label":`Open menu`,children:[n&&(0,k.jsx)(`span`,{className:`text-base font-medium text-[rgb(var(--ec-page-text))] leading-tight`,children:n}),(0,k.jsx)(tle,{className:yr})]})}),(0,k.jsx)(nD,{container:ln.current,children:(0,k.jsxs)(Ape,{className:`min-w-56 bg-[rgb(var(--ec-page-bg))] border border-[rgb(var(--ec-page-border))] rounded-lg shadow-xl z-50 py-1.5`,sideOffset:0,align:`end`,alignOffset:-180,children:[(0,k.jsx)(Npe,{className:`fill-[rgb(var(--ec-page-bg))] stroke-[rgb(var(--ec-page-border))] stroke-1`}),(0,k.jsx)(mz,{isMermaidView:Qe,setIsMermaidView:et,animateMessages:ye,toggleAnimateMessages:Dn,hideAnimateMessages:b,hideChannels:Jt,toggleChannelsVisibility:Yt,hasChannels:Lt,hideMessages:Xt,toggleMessagesVisibility:Zt,hasMessages:Rt,showMinimap:nt,setShowMinimap:it,handleFitView:On,searchRef:cn,isChatEnabled:h,openChat:In,handleCopyArchitectureCode:Hn,onOpenExport:Je,setIsShareModalOpen:Ge,toggleFullScreen:Wn,isDevMode:_,onSaveLayout:ut?void 0:Ln,onResetLayout:Bn,notesCount:ar,onOpenNotes:yt,onOpenInStudio:he?zn:void 0})]})})]})}),s===`full`&&l&&(0,k.jsx)(`div`,{className:`flex justify-end items-center gap-2`,children:!Qe&&(0,k.jsx)(`div`,{className:d?`w-60`:`w-96`,children:(0,k.jsx)(fFe,{ref:cn,nodes:rr,onNodeSelect:Nn,onClear:Pn})})})]}),o.length>0&&(0,k.jsx)(`div`,{className:`flex justify-end mt-3`,children:(0,k.jsxs)(`div`,{className:`relative flex items-center -mt-1`,children:[(0,k.jsx)(`span`,{className:`absolute left-2 pointer-events-none flex items-center h-full`,children:(0,k.jsx)(jS,{className:`h-4 w-4 text-[rgb(var(--ec-page-text-muted))]`})}),(0,k.jsx)(`select`,{value:o.find(e=>window.location.href.includes(e.url))?.url||o[0].url,onChange:e=>{let t=o.find(t=>t.url===e.target.value)?.url;if(!t)return;let n=Qe&&Yz()?dLe(t):t;de?de(n):window.location.href=n},className:`appearance-none pl-7 pr-6 py-0 text-[14px] bg-[rgb(var(--ec-card-bg))] text-[rgb(var(--ec-page-text))] rounded-md border border-[rgb(var(--ec-page-border))] hover:bg-[rgb(var(--ec-page-border)/0.5)] focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-[rgb(var(--ec-accent))]`,style:{minWidth:120,height:`26px`},children:o.map(e=>(0,k.jsx)(`option`,{value:e.url,children:e.label},e.url))}),(0,k.jsx)(`span`,{className:`absolute right-2 pointer-events-none`,children:(0,k.jsx)(`svg`,{className:`w-4 h-4 text-[rgb(var(--ec-page-text-muted))]`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,viewBox:`0 0 24 24`,children:(0,k.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M19 9l-7 7-7-7`})})})]})})]});return(0,k.jsx)(`div`,{ref:ln,onClick:Sn,className:`relative w-full h-full bg-[rgb(var(--ec-page-bg))] flex flex-col eventcatalog-visualizer`,style:{width:`100%`,height:`100%`,display:`flex`,flexDirection:`column`},children:(0,k.jsxs)($Me,{value:ln.current,children:[Qe?(0,k.jsxs)(`div`,{className:`flex-1 overflow-hidden relative`,children:[(0,k.jsx)(XR,{nodes:Ce,edges:Ee,maxTextSize:g,levels:s===`full`?on:[],zoomOnScroll:m,onShowDiagram:s===`full`?()=>et(!1):void 0}),(0,k.jsx)(by,{position:`top-center`,className:`w-full pr-6 pointer-events-none`,children:br})]}):(0,k.jsxs)(Use,{nodeTypes:_e,proOptions:f?qz:void 0,edgeTypes:ve,minZoom:.07,nodes:Ce,edges:Ee,fitView:!w,fitViewOptions:Kz,defaultViewport:w?.viewport,onNodesChange:wn,onEdgesChange:Oe,onEdgeMouseEnter:wt,onEdgeMouseLeave:Tt,connectionLineType:R_.SmoothStep,nodeOrigin:lLe,elevateNodesOnSelect:!1,onNodeClick:En,onNodeMouseEnter:Ft,onNodeMouseLeave:It,onPaneClick:Mn,onMoveStart:xt,onMoveEnd:St,onNodeDragStart:xt,onNodeDragStop:St,zoomOnScroll:m,className:`relative${$t?` ec-laying-out`:``}${Kt&&nn?` ec-highlight-cross-domain`:``}`,children:[(0,k.jsx)(by,{position:`top-center`,className:`w-full pr-6 pointer-events-none`,children:br}),r&&(0,k.jsx)(jFe,{}),r&&(0,k.jsx)($se,{}),s===`full`&&(0,k.jsx)(DFe,{levels:on,tools:sn,onShowMermaid:tt,animateMessages:ye,toggleAnimateMessages:Dn,hideAnimateMessages:b||Ee.length===0,showMinimap:nt,setShowMinimap:it,handleFitView:On}),nt&&(0,k.jsx)(BFe,{}),lr.length>0&&(0,k.jsx)(by,{position:`top-right`,style:s===`full`&&l?ELe:void 0,children:(0,k.jsx)(VR,{options:lr,counts:ur,value:ut,style:pt,onChange:mr})}),Bt&&c&&(0,k.jsx)(yFe,{trail:eee}),Bt&&c&&(0,k.jsx)(by,{position:`bottom-left`,children:(0,k.jsx)(K,{nodes:vn,edges:yn,isFlowVisualization:Bt,onStepChange:cr,mode:s})}),_&&at&&!ut&&(0,k.jsx)(by,{position:`bottom-left`,style:Bt&&c?Qz:mLe,children:(0,k.jsxs)(`div`,{className:`bg-[rgb(var(--ec-card-bg))] border border-[rgb(var(--ec-page-border))] rounded-lg shadow-md px-3 py-2 flex items-center gap-3`,children:[(0,k.jsx)(`span`,{className:`text-xs text-[rgb(var(--ec-page-text-muted))]`,children:`Layout changed`}),(0,k.jsx)(`button`,{onClick:Vn,disabled:st,className:`text-xs font-medium text-white bg-[rgb(var(--ec-accent))] hover:bg-[rgb(var(--ec-accent-hover))] px-2 py-1 rounded transition-colors disabled:opacity-50`,children:st?`Saving...`:`Save`})]})}),a&&(0,k.jsx)(KFe,{legend:$n,hiddenKeys:en,showMinimap:nt,onLegendClick:tn})]}),Et&&(0,k.jsx)(tLe,{...Et,onOpenDiagram:vI,onOpenNode:At,containerRef:ln,onClose:kt},Et.node.id),(0,k.jsx)(GIe,{noteGroups:ir,isOpen:_t,onClose:()=>vt(!1),nodes:Ce}),Ke&&(0,k.jsx)(nIe,{onClose:Ye,onExportImage:Qe?Kn:Gn,onExportMermaid:qn}),We&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:`absolute inset-0 bg-black/20 z-40`,onClick:()=>Ge(!1),style:{animation:`fadeIn 150ms ease-out`}}),(0,k.jsxs)(`div`,{className:`absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 bg-[rgb(var(--ec-page-bg))] rounded-lg shadow-xl z-50 w-[calc(100%-2rem)] max-w-md p-6 border border-[rgb(var(--ec-page-border))]`,style:{animation:`slideInCenter 250ms ease-out`},children:[(0,k.jsx)(`style`,{children:`
220
220
  @keyframes fadeIn {
221
221
  from { opacity: 0; }
222
222
  to { opacity: 1; }
@@ -196,10 +196,13 @@ export function createScopedCatalogTools(scope: McpScope) {
196
196
  return { ...result, scope: scope.ref };
197
197
  },
198
198
 
199
- async explainUbiquitousLanguageTerms(params: { domainId: string; domainVersion?: string }) {
200
- const entry = scope.find('domains', params.domainId, params.domainVersion);
201
- if (!entry) return notFound('domains', params.domainId, params.domainVersion);
202
- return explainUbiquitousLanguageTerms({ ...params, domainVersion: entry.data.version });
199
+ async explainUbiquitousLanguageTerms(params: { domainId?: string; domainVersion?: string; term?: string; cursor?: string }) {
200
+ // Without a domain, look in the scoped domain rather than across the whole catalog
201
+ const domainId = params.domainId || scope.ref.id;
202
+ const domainVersion = params.domainId ? params.domainVersion : scope.ref.version;
203
+ const entry = scope.find('domains', domainId, domainVersion);
204
+ if (!entry) return notFound('domains', domainId, domainVersion);
205
+ return explainUbiquitousLanguageTerms({ ...params, domainId, domainVersion: entry.data.version });
203
206
  },
204
207
  };
205
208
  }
@@ -130,6 +130,11 @@ function getServerInstructions(scope?: McpScope) {
130
130
  'When the user wants to see or understand how something works or fits together (e.g. "show me how the Order Service works"), call showResource with view "architecture": it shows them an interactive diagram. Do not draw your own diagram of the architecture.',
131
131
  'When the user wants to see a schema, payload or the fields of a message (e.g. "show me the schema for OrderCreated"), call showResource with view "schema", not getSchemaForResource: it shows them an interactive schema viewer. Do not print the schema yourself.',
132
132
  'For relationships use getMessagesProducedOrConsumedByResource, getProducersOfMessage and getConsumersOfMessage. Before changing a message, call analyzeChangeImpact to find the affected services, agents and owning teams.',
133
+ ...(!scope || scope.ref.kind === 'domain'
134
+ ? [
135
+ 'To find out what a business term means, or to use the right names when writing about or building for a domain, call explainUbiquitousLanguageTerms. A term can mean different things in different domains, so use the meaning from the domain you are working in.',
136
+ ]
137
+ : []),
133
138
  ...(scope
134
139
  ? []
135
140
  : [
@@ -570,8 +575,15 @@ function createMcpServer(
570
575
  title: 'Explain ubiquitous language terms',
571
576
  description: catalogTools.toolDescriptions.explainUbiquitousLanguageTerms,
572
577
  inputSchema: z.object({
573
- domainId: z.string().describe('The id of the domain to get ubiquitous language terms for'),
578
+ domainId: z
579
+ .string()
580
+ .optional()
581
+ .describe(
582
+ 'The id of the domain to get ubiquitous language terms for. Omit it to look across every domain available.'
583
+ ),
574
584
  domainVersion: optionalVersion('domain'),
585
+ term: z.string().optional().describe('Only return terms whose name or id contains this text (case-insensitive)'),
586
+ cursor: z.string().optional().describe('Pagination cursor from a previous response, when looking across every domain'),
575
587
  }),
576
588
  annotations: readOnlyAnnotations,
577
589
  },
@@ -11,7 +11,12 @@ import {
11
11
  processSpecifications,
12
12
  versionMatches,
13
13
  } from '@utils/collections/util';
14
- import { getUbiquitousLanguageWithSubdomains } from '@utils/collections/domains';
14
+ import {
15
+ getDomains,
16
+ getTermsDefinedInSeveralDomains,
17
+ getUbiquitousLanguageGlossary,
18
+ getUbiquitousLanguageWithSubdomains,
19
+ } from '@utils/collections/domains';
15
20
  import { getAbsoluteFilePathForAstroFile } from '@utils/files';
16
21
  import fs from 'node:fs';
17
22
  import { getArchitectureDiagramGraph } from '@utils/node-graphs/architecture-diagram';
@@ -910,12 +915,71 @@ export async function findMessageBySchemaId(params: {
910
915
  // Ubiquitous Language (DDD)
911
916
  // ============================================
912
917
 
918
+ const toUbiquitousLanguageTermResult = (
919
+ term: any,
920
+ domain: { id: string; name: string },
921
+ isDuplicate: boolean,
922
+ parentDomainId?: string
923
+ ) => ({
924
+ id: term.id,
925
+ term: term.name,
926
+ summary: term.summary,
927
+ description: term.description || term.summary,
928
+ icon: term.icon,
929
+ domainId: domain.id,
930
+ domainName: domain.name,
931
+ ...(parentDomainId ? { isSubdomain: true, parentDomainId } : {}),
932
+ isDuplicate,
933
+ });
934
+
913
935
  /**
914
- * Get ubiquitous language terms for a domain (including subdomains)
915
- * Returns the domain's language/glossary if defined
936
+ * Get ubiquitous language terms, optionally filtered to the terms matching `term`.
937
+ * With a domainId, returns that domain's terms and its subdomains' terms.
938
+ * Without one, returns the terms of every domain (paginated), keeping each domain's meaning of a term separate.
916
939
  */
917
- export async function explainUbiquitousLanguageTerms(params: { domainId: string; domainVersion?: string }) {
918
- const domains = await getCollection('domains');
940
+ export async function explainUbiquitousLanguageTerms(params: {
941
+ domainId?: string;
942
+ domainVersion?: string;
943
+ term?: string;
944
+ cursor?: string;
945
+ }) {
946
+ const search = params.term?.trim().toLowerCase();
947
+ const matchesSearch = (term: { id: string; term: string }) =>
948
+ !search || term.term.toLowerCase().includes(search) || term.id.toLowerCase().includes(search);
949
+
950
+ if (!params.domainId) {
951
+ const glossary = await getUbiquitousLanguageGlossary();
952
+ const definedInSeveralDomains = getTermsDefinedInSeveralDomains(glossary);
953
+ const isDuplicate = (term: { name: string }) => definedInSeveralDomains.has(term.name.toLowerCase());
954
+
955
+ const terms = glossary
956
+ .flatMap((domain) => [
957
+ ...domain.terms.map((term) => toUbiquitousLanguageTermResult(term, domain, isDuplicate(term))),
958
+ ...domain.subdomains.flatMap((subdomain) =>
959
+ subdomain.terms.map((term) => toUbiquitousLanguageTermResult(term, subdomain, isDuplicate(term), subdomain.parentId))
960
+ ),
961
+ ])
962
+ .filter(matchesSearch);
963
+
964
+ const page = paginate(terms, params.cursor);
965
+ if ('error' in page) return page;
966
+
967
+ return {
968
+ terms: page.items,
969
+ nextCursor: page.nextCursor,
970
+ totalCount: page.totalCount,
971
+ duplicateTerms: Array.from(new Set(page.items.filter((term) => term.isDuplicate).map((term) => term.term.toLowerCase()))),
972
+ message:
973
+ terms.length === 0
974
+ ? search
975
+ ? `No ubiquitous language terms match "${params.term}"`
976
+ : 'No ubiquitous language terms are defined in this catalog'
977
+ : undefined,
978
+ };
979
+ }
980
+
981
+ // getDomains resolves subdomains to their entries, which is what finds the subdomains' terms
982
+ const domains = await getDomains({ getAllVersions: true });
919
983
 
920
984
  // Use the existing utility to find the domain by id and version (or latest)
921
985
  const matches = getItemsFromCollectionByIdAndSemverOrLatest(domains, params.domainId, params.domainVersion);
@@ -930,31 +994,32 @@ export async function explainUbiquitousLanguageTerms(params: { domainId: string;
930
994
  // Get ubiquitous language including subdomains
931
995
  const ubiquitousLanguageData = await getUbiquitousLanguageWithSubdomains(domain as any);
932
996
  const { domain: domainUL, subdomains, duplicateTerms } = ubiquitousLanguageData;
997
+ const domainName = (domain.data as any).name || params.domainId;
933
998
 
934
999
  // Extract terms from domain's ubiquitous language
935
- const domainTerms =
936
- domainUL?.data?.dictionary?.map((term: any) => ({
937
- term: term.name,
938
- description: term.summary,
939
- icon: term.icon,
940
- domainId: params.domainId,
941
- domainName: (domain.data as any).name || params.domainId,
942
- isDuplicate: duplicateTerms.has(term.name.toLowerCase()),
943
- })) || [];
1000
+ const domainTerms = (domainUL?.data?.dictionary || [])
1001
+ .map((term: any) =>
1002
+ toUbiquitousLanguageTermResult(
1003
+ term,
1004
+ { id: params.domainId!, name: domainName },
1005
+ duplicateTerms.has(term.name.toLowerCase())
1006
+ )
1007
+ )
1008
+ .filter(matchesSearch);
944
1009
 
945
1010
  // Extract terms from subdomains
946
- const subdomainTerms = subdomains.flatMap(({ subdomain, ubiquitousLanguage }) => {
947
- if (!ubiquitousLanguage?.data?.dictionary) return [];
948
- return ubiquitousLanguage.data.dictionary.map((term: any) => ({
949
- term: term.name,
950
- description: term.summary,
951
- icon: term.icon,
952
- domainId: (subdomain.data as any).id,
953
- domainName: (subdomain.data as any).name || (subdomain.data as any).id,
954
- isSubdomain: true,
955
- isDuplicate: duplicateTerms.has(term.name.toLowerCase()),
956
- }));
957
- });
1011
+ const subdomainTerms = subdomains
1012
+ .flatMap(({ subdomain, ubiquitousLanguage }) =>
1013
+ (ubiquitousLanguage?.data?.dictionary || []).map((term: any) =>
1014
+ toUbiquitousLanguageTermResult(
1015
+ term,
1016
+ { id: (subdomain.data as any).id, name: (subdomain.data as any).name || (subdomain.data as any).id },
1017
+ duplicateTerms.has(term.name.toLowerCase()),
1018
+ params.domainId
1019
+ )
1020
+ )
1021
+ )
1022
+ .filter(matchesSearch);
958
1023
 
959
1024
  const allTerms = [...domainTerms, ...subdomainTerms];
960
1025
 
@@ -962,8 +1027,10 @@ export async function explainUbiquitousLanguageTerms(params: { domainId: string;
962
1027
  return {
963
1028
  domainId: params.domainId,
964
1029
  domainVersion: (domain.data as any).version,
965
- domainName: (domain.data as any).name || params.domainId,
966
- message: 'No ubiquitous language terms defined for this domain or its subdomains',
1030
+ domainName,
1031
+ message: search
1032
+ ? `No ubiquitous language terms match "${params.term}" in this domain or its subdomains`
1033
+ : 'No ubiquitous language terms defined for this domain or its subdomains',
967
1034
  terms: [],
968
1035
  subdomainCount: subdomains.length,
969
1036
  };
@@ -972,7 +1039,7 @@ export async function explainUbiquitousLanguageTerms(params: { domainId: string;
972
1039
  return {
973
1040
  domainId: params.domainId,
974
1041
  domainVersion: (domain.data as any).version,
975
- domainName: (domain.data as any).name || params.domainId,
1042
+ domainName,
976
1043
  terms: allTerms,
977
1044
  totalCount: allTerms.length,
978
1045
  domainTermCount: domainTerms.length,
@@ -1359,7 +1426,7 @@ export const toolDescriptions = {
1359
1426
  findMessageBySchemaId:
1360
1427
  'Use this tool when a user shares a schema file (Avro, JSON Schema, Protobuf) and wants to find it in EventCatalog. Look for "x-eventcatalog-id" and "x-eventcatalog-version" in the schema - these may be properties in the schema OR in comments (e.g. // x-eventcatalog-id: OrderCreated). Pass the id as messageId. If version exists, pass it as messageVersion, otherwise omit it to get the latest version. Returns the message resource along with its producers and consumers.',
1361
1428
  explainUbiquitousLanguageTerms:
1362
- 'Use this tool to explain ubiquitous language terms from Domain-Driven Design for a specific domain. Returns the glossary of terms defined for the domain and its subdomains, including duplicate term detection.',
1429
+ "Use this tool to find out what a business term means, or to get the ubiquitous language (Domain-Driven Design glossary) of a domain or of every domain. Pass domainId for a domain's terms and its subdomains' terms, term to find a term by name, or neither for the whole glossary. The same term can mean different things in different domains: each domain's meaning is returned separately and duplicates are flagged.",
1363
1430
  getDataProductInputs:
1364
1431
  'Use this tool to get the inputs (resources consumed) for a data product. Returns fully hydrated input resources with their id, version, name, summary, and collection type.',
1365
1432
  getDataProductOutputs:
@@ -1,34 +1,32 @@
1
1
  import type { APIRoute } from 'astro';
2
- import { getCollection } from 'astro:content';
3
- import path from 'node:path';
4
- import fs from 'node:fs';
2
+ import { getCollection, type CollectionEntry } from 'astro:content';
5
3
  import { getSpecificationsForService } from '@utils/collections/services';
4
+ import { getSpecificationMediaType } from '@utils/collections/util';
6
5
  import { resourceFileExists, readResourceFile } from '@utils/resource-files';
7
6
 
7
+ // The Schema API: kept for the API consumers that already use it. It finds a specification by its type, so it
8
+ // serves the first of each type. The file of every specification is also served next to its page:
9
+ // /docs/{type}/{id}/{version}/{asyncapi|spec|graphql|generic}/{filename}/{file}
10
+ const getFirstSpecificationOfEachType = (service: CollectionEntry<'services'>) =>
11
+ getSpecificationsForService(service).filter(
12
+ (specification, index, specifications) => specifications.findIndex((spec) => spec.type === specification.type) === index
13
+ );
14
+
8
15
  export async function getStaticPaths() {
9
16
  const services = await getCollection('services');
10
- const servicesWithSpecifications = services.filter((service) => getSpecificationsForService(service).length > 0);
11
- return servicesWithSpecifications.reduce<
12
- { params: { collection: string; id: string; version: string; specification: string }; props: { schema: string } }[]
13
- >(
14
- (acc, service) => {
15
- const specifications = getSpecificationsForService(service);
16
- return [
17
- ...acc,
18
- ...specifications.map((specification) => ({
19
- params: {
20
- collection: service.collection,
21
- id: service.data.id,
22
- version: service.data.version,
23
- specification: specification.type,
24
- },
25
- props: {
26
- schema: fs.readFileSync(path.join(path.dirname(service.filePath ?? ''), specification.path ?? ''), 'utf8'),
27
- },
28
- })),
29
- ];
30
- },
31
- [] as { params: { collection: string; id: string; version: string; specification: string }; props: { schema: string } }[]
17
+ return services.flatMap((service) =>
18
+ getFirstSpecificationOfEachType(service).map((specification) => ({
19
+ params: {
20
+ collection: service.collection,
21
+ id: service.data.id,
22
+ version: service.data.version,
23
+ specification: specification.type,
24
+ },
25
+ props: {
26
+ schema: readResourceFile(service, specification.path),
27
+ contentType: getSpecificationMediaType(specification),
28
+ },
29
+ }))
32
30
  );
33
31
  }
34
32
 
@@ -36,7 +34,7 @@ export const GET: APIRoute = async ({ props, params }) => {
36
34
  // In static mode, props are pre-computed by getStaticPaths
37
35
  if (props.schema) {
38
36
  return new Response(props.schema, {
39
- headers: { 'Content-Type': 'text/plain' },
37
+ headers: { 'Content-Type': props.contentType },
40
38
  });
41
39
  }
42
40
 
@@ -80,6 +78,6 @@ export const GET: APIRoute = async ({ props, params }) => {
80
78
  }
81
79
 
82
80
  return new Response(schema, {
83
- headers: { 'Content-Type': 'text/plain' },
81
+ headers: { 'Content-Type': getSpecificationMediaType(spec) },
84
82
  });
85
83
  };
@@ -282,6 +282,13 @@ function resolvePointer(pointer: { id: string; version?: string }) {
282
282
  };
283
283
  }
284
284
 
285
+ // Resolve a list of pointers, listing each resource once (a data product can point at the
286
+ // same resource more than once, e.g. one output per data contract)
287
+ function resolvePointers(pointers: { id: string; version?: string }[] = []) {
288
+ const resolved = pointers.map(resolvePointer).filter((item) => item !== null);
289
+ return [...new Map(resolved.map((item) => [`${item.collection}:${item.data.id}:${item.data.version}`, item])).values()];
290
+ }
291
+
285
292
  // Build a Set of subdomain IDs (domains that are nested within other domains)
286
293
  const allSubdomainIds = new Set(
287
294
  domains.flatMap((d: any) => (d.data?.domains || []).map((sd: any) => sd.data?.id || sd.id)).filter(Boolean)
@@ -368,8 +375,8 @@ const tableData = enrichedData.map((d: any) => ({
368
375
  flows: d.data?.flows?.map(mapToItem) ?? [],
369
376
  servicesThatWriteToContainer: d.data?.servicesThatWriteToContainer?.map(mapToItem) ?? [],
370
377
  servicesThatReadFromContainer: d.data?.servicesThatReadFromContainer?.map(mapToItem) ?? [],
371
- inputs: d.data?.inputs?.map(resolvePointer).filter(Boolean) ?? [],
372
- outputs: d.data?.outputs?.map(resolvePointer).filter(Boolean) ?? [],
378
+ inputs: resolvePointers(d.data?.inputs),
379
+ outputs: resolvePointers(d.data?.outputs),
373
380
  },
374
381
  }));
375
382
 
@@ -0,0 +1,7 @@
1
+ import { isSSR } from '@utils/feature';
2
+ import { createRawSpecificationRoute } from '@utils/raw-specification';
3
+ import { Page } from '../_[filename].data';
4
+
5
+ // The specification's file, as written, next to its page
6
+ export const prerender = !isSSR();
7
+ export const { getStaticPaths, GET } = createRawSpecificationRoute('asyncapi', Page);