@likec4/core 1.49.0 → 1.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/THIRD-PARTY-LICENSES.md +24 -2
- package/dist/_chunks/Builder.view-element.mjs +2 -2
- package/dist/_chunks/LikeC4Model.d.mts +3 -3
- package/dist/_chunks/_types.d.mts +1 -1
- package/dist/_chunks/_types2.d.mts +2 -2
- package/dist/_chunks/assignTagColors.mjs +1 -1
- package/dist/_chunks/geometry.mjs +1 -0
- package/dist/_chunks/index.d.mts +1964 -219
- package/dist/_chunks/{theme.d.mts → index3.d.mts} +1 -1
- package/dist/_chunks/index4.d.mts +288 -0
- package/dist/_chunks/{to-text.d.mts → index5.d.mts} +1 -1
- package/dist/_chunks/libs/@mantine/colors-generator.mjs +2 -2
- package/dist/_chunks/libs/@radix-ui/colors.mjs +1 -1
- package/dist/_chunks/libs/@ungap/structured-clone.mjs +1 -1
- package/dist/_chunks/libs/bail.mjs +1 -1
- package/dist/_chunks/libs/ccount.mjs +1 -1
- package/dist/_chunks/libs/character-entities-html4.mjs +1 -1
- package/dist/_chunks/libs/character-entities-legacy.mjs +1 -1
- package/dist/_chunks/libs/character-entities.mjs +2 -2
- package/dist/_chunks/libs/comma-separated-tokens.mjs +1 -1
- package/dist/_chunks/libs/decode-named-character-reference.mjs +1 -1
- package/dist/_chunks/libs/defu.mjs +1 -1
- package/dist/_chunks/libs/devlop.mjs +1 -1
- package/dist/_chunks/libs/escape-string-regexp.mjs +1 -1
- package/dist/_chunks/libs/extend.mjs +1 -1
- package/dist/_chunks/libs/graphology-dag.mjs +1 -1
- package/dist/_chunks/libs/graphology.mjs +1 -1
- package/dist/_chunks/libs/hast-util-sanitize.mjs +1 -1
- package/dist/_chunks/libs/hast-util-to-html.mjs +2 -2
- package/dist/_chunks/libs/is-plain-obj.mjs +1 -1
- package/dist/_chunks/libs/longest-streak.mjs +1 -1
- package/dist/_chunks/libs/markdown-table.mjs +2 -2
- package/dist/_chunks/libs/mdast-util-find-and-replace.mjs +1 -1
- package/dist/_chunks/libs/mdast-util-from-markdown.mjs +2 -2
- package/dist/_chunks/libs/mdast-util-gfm.mjs +9 -9
- package/dist/_chunks/libs/mdast-util-to-hast.mjs +7 -7
- package/dist/_chunks/libs/micromark-extension-gfm.mjs +1 -1
- package/dist/_chunks/libs/mnemonist.mjs +1 -1
- package/dist/_chunks/libs/natural-compare-lite.mjs +2 -2
- package/dist/_chunks/libs/ohash.mjs +1 -1
- package/dist/_chunks/libs/rehype-sanitize.mjs +1 -1
- package/dist/_chunks/libs/rehype-stringify.mjs +1 -1
- package/dist/_chunks/libs/remark-gfm.mjs +1 -1
- package/dist/_chunks/libs/remark-github-blockquote-alert.mjs +2 -2
- package/dist/_chunks/libs/remark-parse.mjs +1 -1
- package/dist/_chunks/libs/remark-rehype.mjs +1 -1
- package/dist/_chunks/libs/remeda.mjs +2 -1
- package/dist/_chunks/libs/trough.mjs +1 -1
- package/dist/_chunks/libs/unified.mjs +1 -1
- package/dist/_chunks/manual-layout.mjs +1 -0
- package/dist/_chunks/mnemonist.d.mts +1 -0
- package/dist/_chunks/model.mjs +4 -0
- package/dist/_chunks/rolldown-runtime.mjs +1 -1
- package/dist/_chunks/types.mjs +1 -0
- package/dist/_chunks/utils.mjs +1 -0
- package/dist/builder/index.d.mts +5 -2
- package/dist/builder/index.mjs +1 -1
- package/dist/compute-view/index.d.mts +6 -5
- package/dist/compute-view/index.mjs +2 -2
- package/dist/geometry/index.d.mts +1 -1
- package/dist/geometry/index.mjs +1 -1
- package/dist/index.d.mts +5 -7
- package/dist/index.mjs +1 -1
- package/dist/model/index.d.mts +7 -4
- package/dist/model/index.mjs +1 -1
- package/dist/styles/index.d.mts +3 -2
- package/dist/styles/index.mjs +1 -1
- package/dist/types/index.d.mts +3 -3
- package/dist/types/index.mjs +1 -1
- package/dist/utils/graphology/index.mjs +1 -1
- package/dist/utils/index.d.mts +4 -2
- package/dist/utils/index.mjs +1 -1
- package/package.json +10 -10
- package/dist/_chunks/RichText.mjs +0 -1
- package/dist/_chunks/calcDriftsFromSnapshot.mjs +0 -1
- package/dist/_chunks/guards.d.mts +0 -2026
- package/dist/_chunks/guards.mjs +0 -4
- package/dist/_chunks/to-text.mjs +0 -1
- package/dist/_chunks/vector.mjs +0 -1
- /package/dist/_chunks/{vector.d.mts → index2.d.mts} +0 -0
|
@@ -1 +1,2 @@
|
|
|
1
|
-
function e
|
|
1
|
+
function e(e,t,n){let r=n=>e(n,...t);return n===void 0?r:Object.assign(r,{lazy:n,lazyArgs:t})}function t(t,n,r){let i=t.length-n.length;if(i===0)return t(...n);if(i===1)return e(t,n,r);throw Error(`Wrong number of arguments`)}function n(...e){return t(r,e)}const r=(e,t)=>t.every(t=>t(e));function i(...e){return t(a,e)}const a=(e,t)=>t.some(t=>t(e));function o(...e){return t(s,e)}const s=(e,t)=>[...e,...t];function c(e){return()=>e}const l={done:!0,hasNext:!1},u={done:!1,hasNext:!1},d=()=>l,f=e=>({hasNext:!0,next:e,done:!1});function p(e,...t){let n=e,r=t.map(e=>`lazy`in e?h(e):void 0),i=0;for(;i<t.length;){if(r[i]===void 0||!g(n)){let e=t[i];n=e(n),i+=1;continue}let e=[];for(let n=i;n<t.length;n++){let t=r[n];if(t===void 0||(e.push(t),t.isSingle))break}let a=[];for(let t of n)if(m(t,a,e))break;let{isSingle:o}=e.at(-1);n=o?a[0]:a,i+=e.length}return n}function m(e,t,n){if(n.length===0)return t.push(e),!1;let r=e,i=u,a=!1;for(let[e,o]of n.entries()){let{index:s,items:c}=o;if(c.push(r),i=o(r,s,c),o.index+=1,i.hasNext){if(i.hasMany??!1){for(let r of i.next)if(m(r,t,n.slice(e+1)))return!0;return a}r=i.next}if(!i.hasNext)break;i.done&&(a=!0)}return i.hasNext&&t.push(r),a}function h(e){let{lazy:t,lazyArgs:n}=e,r=t(...n);return Object.assign(r,{isSingle:t.single??!1,index:0,items:[]})}function g(e){return typeof e==`string`||typeof e==`object`&&!!e&&Symbol.iterator in e}function ee(e,t){let n=t.length-e.length;if(n===1){let[n,...r]=t;return p(n,{lazy:e,lazyArgs:r})}if(n===0){let n={lazy:e,lazyArgs:t};return Object.assign(e=>p(e,n),n)}throw Error(`Wrong number of arguments`)}function te(...e){return t(ne,e,re)}const ne=(e,t)=>t<0?[...e]:e.slice(t);function re(e){if(e<=0)return f;let t=e;return e=>t>0?(--t,u):{done:!1,hasNext:!0,next:e}}function _(...e){return t(v,e)}const v=(e,t)=>e.length>=t,y={asc:(e,t)=>e>t,desc:(e,t)=>e<t};function b(e,t){let[n,...r]=t;if(!S(n))return e(n,x(...r));let i=x(n,...r);return t=>e(t,i)}function x(e,t,...n){let r=typeof e==`function`?e:e[0],i=typeof e==`function`?`asc`:e[1],{[i]:a}=y,o=t===void 0?void 0:x(t,...n);return(e,t)=>{let n=r(e),i=r(t);return a(n,i)?1:a(i,n)?-1:o?.(e,t)??0}}function S(e){if(C(e))return!0;if(typeof e!=`object`||!Array.isArray(e))return!1;let[t,n,...r]=e;return C(t)&&typeof n==`string`&&n in y&&r.length===0}const C=e=>typeof e==`function`&&e.length===1;function w(...e){return t(T,e)}function T(e,t){for(let[n,r]of e.entries())if(!t(r,n,e))return e.slice(n);return[]}function E(...e){return t(Object.entries,e)}function D(...e){return t(O,e,k)}const O=(e,t)=>e.filter(t),k=e=>(t,n,r)=>e(t,n,r)?{done:!1,hasNext:!0,next:t}:u,A=e=>Object.assign(e,{single:!0});function j(...e){return t(M,e)}const M=(e,t)=>{for(let n=e.length-1;n>=0;n--){let r=e[n];if(t(r,n,e))return r}};function N(...e){return t(P,e,A(F))}const P=([e])=>e,F=()=>I,I=e=>({hasNext:!0,next:e,done:!0});function L(...e){return t(R,e,z)}const R=(e,t)=>e.flatMap(t),z=e=>(t,n,r)=>{let i=e(t,n,r);return Array.isArray(i)?{done:!1,hasNext:!0,hasMany:!0,next:i}:{done:!1,hasNext:!0,next:i}};function B(...e){return t(V,e,H)}function V(e,t){return e.forEach(t),e}const H=e=>(t,n,r)=>(e(t,n,r),{done:!1,hasNext:!0,next:t});function U(...e){return t(Object.fromEntries,e)}function W(...e){return t(G,e)}function G(e,t){let n={};for(let[r,i]of e.entries())n[i]=t(i,r,e);return n}function K(...e){return t(q,e)}const q=(e,t)=>{let n=Object.create(null);for(let r=0;r<e.length;r++){let i=e[r],a=t(i,r,e);if(a!==void 0){let e=n[a];e===void 0?n[a]=[i]:e.push(i)}}return Object.setPrototypeOf(n,Object.prototype),n};function J(...e){return t(Y,e)}function Y(e,t){if(e===t||Object.is(e,t))return!0;if(typeof e!=`object`||typeof t!=`object`||e===null||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;if(Array.isArray(e))return X(e,t);if(e instanceof Map)return ie(e,t);if(e instanceof Set)return ae(e,t);if(e instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp)return e.toString()===t.toString();if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let[n,r]of Object.entries(e))if(!(n in t)||!Y(r,t[n]))return!1;return!0}function X(e,t){if(e.length!==t.length)return!1;for(let[n,r]of e.entries())if(!Y(r,t[n]))return!1;return!0}function ie(e,t){if(e.size!==t.size)return!1;for(let[n,r]of e.entries())if(!t.has(n)||!Y(r,t.get(n)))return!1;return!0}function ae(e,t){if(e.size!==t.size)return!1;let n=[...t];for(let t of e){let e=!1;for(let[r,i]of n.entries())if(Y(t,i)){e=!0,n.splice(r,1);break}if(!e)return!1}return!0}function oe(e){return Array.isArray(e)}function se(e){return typeof e==`boolean`}function ce(e){return e!==void 0}function le(e){return e===``||e===void 0?!0:Array.isArray(e)?e.length===0:Object.keys(e).length===0}function ue(e){if(e==null||e===``)return!0;if(typeof e!=`object`)return!1;if(`length`in e&&typeof e.length==`number`)return e.length===0;if(`size`in e&&typeof e.size==`number`)return e.size===0;for(let t in e)return!1;return Object.getOwnPropertySymbols(e).length===0}const de=e=>typeof e==`function`;function fe(e){return e!=null}function pe(e){return t=>!e(t)}function me(e){return e==null}function he(e){return typeof e==`number`&&!Number.isNaN(e)}function ge(...e){return t(_e,e)}function _e(e,t){if(e===t||Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map)return ve(e,t);if(e instanceof Set&&t instanceof Set)return ye(e,t);let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n){if(!Object.hasOwn(t,r))return!1;let{[r]:n}=e,{[r]:i}=t;if(n!==i||!Object.is(n,i))return!1}return!0}function ve(e,t){if(e.size!==t.size)return!1;for(let[n,r]of e){let e=t.get(n);if(r!==e||!Object.is(r,e))return!1}return!0}function ye(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function be(e){return typeof e==`string`}function xe(e){return!!e}function Se(...e){return t(Object.keys,e)}function Ce(...e){return t(we,e)}const we=e=>e.at(-1);function Te(...e){return t(Ee,e,De)}const Ee=(e,t)=>e.map(t),De=e=>(t,n,r)=>({done:!1,hasNext:!0,next:e(t,n,r)});function Oe(...e){return t(ke,e)}function ke(e,t){let n={};for(let[r,i]of e.entries()){let[a,o]=t(i,r,e);n[a]=o}return n}function Ae(...e){return t(je,e)}function je(e,t){let n={};for(let[r,i]of Object.entries(e))n[r]=t(i,r,e);return n}function Me(...e){return t(Ne,e)}function Ne(e,t){if(!_(t,1))return{...e};if(!_(t,2)){let{[t[0]]:n,...r}=e;return r}let n={...e};for(let e of t)delete n[e];return n}function Pe(...e){return t(Fe,e)}function Fe(e,t){let n={...e};for(let[r,i]of Object.entries(n))t(i,r,e)&&delete n[r];return n}function Ie(e){let t=!1,n;return()=>(t||=(n=e(),!0),n)}function Le(...e){return t(Re,e)}const Re=e=>e.length===1?e[0]:void 0;function ze(...e){return t(Be,e)}const Be=(e,t)=>{let n=[[],[]];for(let[r,i]of e.entries())t(i,r,e)?n[0].push(i):n[1].push(i);return n};function Ve(...e){return t(He,e)}function He(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}function Ue(...e){return t(We,e)}function We(e,t){let n={};for(let[r,i]of Object.entries(e))t(i,r,e)&&(n[r]=i);return n}function Ge(...e){return t=>p(t,...e)}function Ke(e,...t){return typeof e==`string`||typeof e==`number`||typeof e==`symbol`?n=>Z(n,e,...t):Z(e,...t)}function Z(e,...t){let n=e;for(let e of t){if(n==null)return;n=n[e]}return n}function qe(...e){return t(Je,e)}function Je(e,t,n){let r={};for(let[i,a]of e.entries()){let o=t(a,i,e);r[o]=n(a,i,e)}return r}function Ye(e,t){let n=Math.ceil(e),r=Math.floor(t);if(r<n)throw RangeError(`randomInteger: The range [${e.toString()},${t.toString()}] contains no integer`);return Math.floor(Math.random()*(r-n+1)+n)}function Xe(...e){return t(Ze,e)}const Ze=(e,t,n)=>e.reduce(t,n);function Qe(...e){return t($e,e)}function $e(e){return[...e].reverse()}function et(...e){return t(tt,e)}function tt(e,t){let n=[...e];return n.sort(t),n}function nt(...e){return b(Q,e)}const Q=(e,t)=>[...e].sort(t);function rt(e,t,n){return typeof t==`number`||t===void 0?n=>n.split(e,t):e.split(t,n)}function it(...e){return t(at,e,ot)}const at=(e,t)=>t<0?[]:e.slice(0,t);function ot(e){if(e<=0)return d;let t=e;return e=>(--t,{done:t<=0,hasNext:!0,next:e})}function st(...e){return t(ct,e)}function ct(e,t){let n=[];for(let[r,i]of e.entries()){if(!t(i,r,e))break;n.push(i)}return n}new Set([`-`,`_`,...` .
|
|
2
|
+
.\v.\f.\r. .
.\xA0. . . . . . . . . . . . .\u2028.\u2029. . . .`.split(`.`)]);function lt(...e){return ee(ut,e)}function ut(){let e=new Set;return t=>e.has(t)?u:(e.add(t),{done:!1,hasNext:!0,next:t})}function dt(...e){return t(Object.values,e)}function ft(...e){return e.length===2?(t,...n)=>$(t,...e,...n):$(...e)}const $=(e,t,n,...r)=>t(e,...r)?typeof n==`function`?n(e,...r):n.onTrue(e,...r):typeof n==`function`?e:n.onFalse(e,...r);function pt(...e){return t(mt,e,ht)}const mt=(e,t)=>e.length<t.length?e.map((e,n)=>[e,t[n]]):t.map((t,n)=>[e[n],t]),ht=e=>(t,n)=>({hasNext:!0,next:[t,e[n]],done:n>=e.length-1});export{te as $,ge as A,oe as B,Ae as C,Se as D,Ce as E,de as F,B as G,K as H,ue as I,j as J,L as K,le as L,me as M,pe as N,xe as O,fe as P,_ as Q,ce as R,Me as S,Te as T,W as U,J as V,U as W,E as X,D as Y,w as Z,Ve as _,st as a,Ie as b,nt as c,Xe as d,p as et,Ye as f,Ue as g,Ge as h,lt as i,n as it,he as j,be as k,et as l,Ke as m,ft as n,o as nt,it as o,qe as p,N as q,dt as r,i as rt,rt as s,pt as t,c as tt,Qe as u,ze as v,Oe as w,Pe as x,Le as y,se as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function e(){let e=[],n={run:r,use:i};return n;function r(...n){let r=-1,i=n.pop();if(typeof i!=`function`)throw TypeError(`Expected function as last argument, not `+i);a(null,...n);function a(o,...s){let c=e[++r],l=-1;if(o){i(o);return}for(;++l<n.length;)(s[l]===null||s[l]===void 0)&&(s[l]=n[l]);n=s,c?t(c,a)(...s):i(null,...s)}}function i(t){if(typeof t!=`function`)throw TypeError("Expected `middelware` to be a function, not "+t);return e.push(t),n}}function t(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}export{e as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as __toESM}from"../rolldown-runtime.mjs";import{t as ok}from"./devlop.mjs";import{n as stringifyPosition}from"./mdast-util-from-markdown.mjs";import{t as bail}from"./bail.mjs";import{t as require_extend}from"./extend.mjs";import{t as isPlainObject}from"./is-plain-obj.mjs";import{t as trough}from"./trough.mjs";var VFileMessage=class extends Error{constructor(e,t,r){super(),typeof t==`string`&&(r=t,t=void 0);let i=``,a={},o=!1;if(t&&(a=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?i=e:!a.cause&&e&&(o=!0,i=e.message,a.cause=e),!a.ruleId&&!a.source&&typeof r==`string`){let e=r.indexOf(`:`);e===-1?a.ruleId=r:(a.source=r.slice(0,e),a.ruleId=r.slice(e+1))}if(!a.place&&a.ancestors&&a.ancestors){let e=a.ancestors[a.ancestors.length-1];e&&(a.place=e.position)}let s=a.place&&`start`in a.place?a.place.start:a.place;this.ancestors=a.ancestors||void 0,this.cause=a.cause||void 0,this.column=s?s.column:void 0,this.fatal=void 0,this.file,this.message=i,this.line=s?s.line:void 0,this.name=stringifyPosition(a.place)||`1:1`,this.place=a.place||void 0,this.reason=this.message,this.ruleId=a.ruleId||void 0,this.source=a.source||void 0,this.stack=o&&a.cause&&typeof a.cause.stack==`string`?a.cause.stack:``,this.actual,this.expected,this.note,this.url}};VFileMessage.prototype.file=``,VFileMessage.prototype.name=``,VFileMessage.prototype.reason=``,VFileMessage.prototype.message=``,VFileMessage.prototype.stack=``,VFileMessage.prototype.column=void 0,VFileMessage.prototype.line=void 0,VFileMessage.prototype.ancestors=void 0,VFileMessage.prototype.cause=void 0,VFileMessage.prototype.fatal=void 0,VFileMessage.prototype.place=void 0,VFileMessage.prototype.ruleId=void 0,VFileMessage.prototype.source=void 0;const minpath={basename,dirname,extname,join,sep:`/`};function basename(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);assertPath$1(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function dirname(e){if(assertPath$1(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function extname(e){assertPath$1(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function join(...e){let t=-1,n;for(;++t<e.length;)assertPath$1(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:normalize(n)}function normalize(e){assertPath$1(e);let t=e.codePointAt(0)===47,n=normalizeString(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function normalizeString(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(!(i===o-1||a===1))if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function assertPath$1(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}const minproc={cwd};function cwd(){return`/`}function isUrl(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function urlToPath(e){if(typeof e==`string`)e=new URL(e);else if(!isUrl(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return getPathFromURLPosix(e)}function getPathFromURLPosix(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}const order=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`];var VFile=class{constructor(e){let t;t=e?isUrl(e)?{path:e}:typeof e==`string`||isUint8Array$1(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:minproc.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<order.length;){let e=order[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)order.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?minpath.basename(this.path):void 0}set basename(e){assertNonEmpty(e,`basename`),assertPart(e,`basename`),this.path=minpath.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?minpath.dirname(this.path):void 0}set dirname(e){assertPath(this.basename,`dirname`),this.path=minpath.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?minpath.extname(this.path):void 0}set extname(e){if(assertPart(e,`extname`),assertPath(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=minpath.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){isUrl(e)&&(e=urlToPath(e)),assertNonEmpty(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?minpath.basename(this.path,this.extname):void 0}set stem(e){assertNonEmpty(e,`stem`),assertPart(e,`stem`),this.path=minpath.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new VFileMessage(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function assertPart(e,t){if(e&&e.includes(minpath.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+minpath.sep+"`")}function assertNonEmpty(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function assertPath(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function isUint8Array$1(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}const CallableInstance=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r});var import_extend=__toESM(require_extend(),1);const own={}.hasOwnProperty,unified=new class e extends CallableInstance{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=trough()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,import_extend.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(assertUnfrozen(`data`,this.frozen),this.namespace[e]=t,this):own.call(this.namespace,e)&&this.namespace[e]||void 0:e?(assertUnfrozen(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=vfile(e),n=this.parser||this.Parser;return assertParser(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),assertParser(`process`,this.parser||this.Parser),assertCompiler(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=vfile(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);looksLikeAValue(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),assertParser(`processSync`,this.parser||this.Parser),assertCompiler(`processSync`,this.compiler||this.Compiler),this.process(e,i),assertDone(`processSync`,`process`,t),n;function i(e,i){t=!0,bail(e),n=i}}run(e,t,n){assertNode(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=vfile(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,i;return this.run(e,t,a),assertDone(`runSync`,`run`,n),i;function a(e,t){bail(e),i=t,n=!0}}stringify(e,t){this.freeze();let n=vfile(t),r=this.compiler||this.Compiler;return assertCompiler(`stringify`,r),assertNode(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(assertUnfrozen(`use`,this.frozen),e!=null)if(typeof e==`function`)c(e,t);else if(typeof e==`object`)Array.isArray(e)?s(e):o(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function i(e){if(typeof e==`function`)c(e,[]);else if(typeof e==`object`)if(Array.isArray(e)){let[t,...n]=e;c(t,n)}else o(e);else throw TypeError("Expected usable value, not `"+e+"`")}function o(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");s(e.plugins),e.settings&&(r.settings=(0,import_extend.default)(!0,r.settings,e.settings))}function s(e){let t=-1;if(e!=null)if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}function c(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...o]=t,s=n[i][1];isPlainObject(s)&&isPlainObject(r)&&(r=(0,import_extend.default)(!0,s,r)),n[i]=[e,r,...o]}}}}().freeze();function assertParser(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function assertCompiler(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function assertUnfrozen(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function assertNode(e){if(!isPlainObject(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function assertDone(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function vfile(e){return looksLikeAVFile(e)?e:new VFile(e)}function looksLikeAVFile(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function looksLikeAValue(e){return typeof e==`string`||isUint8Array(e)}function isUint8Array(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}export{unified as t};
|
|
1
|
+
import{r as e}from"../rolldown-runtime.mjs";import"./devlop.mjs";import{n as t}from"./mdast-util-from-markdown.mjs";import{t as n}from"./bail.mjs";import{t as r}from"./extend.mjs";import{t as i}from"./is-plain-obj.mjs";import{t as a}from"./trough.mjs";var o=class extends Error{constructor(e,n,r){super(),typeof n==`string`&&(r=n,n=void 0);let i=``,a={},o=!1;if(n&&(a=`line`in n&&`column`in n||`start`in n&&`end`in n?{place:n}:`type`in n?{ancestors:[n],place:n.position}:{...n}),typeof e==`string`?i=e:!a.cause&&e&&(o=!0,i=e.message,a.cause=e),!a.ruleId&&!a.source&&typeof r==`string`){let e=r.indexOf(`:`);e===-1?a.ruleId=r:(a.source=r.slice(0,e),a.ruleId=r.slice(e+1))}if(!a.place&&a.ancestors&&a.ancestors){let e=a.ancestors[a.ancestors.length-1];e&&(a.place=e.position)}let s=a.place&&`start`in a.place?a.place.start:a.place;this.ancestors=a.ancestors||void 0,this.cause=a.cause||void 0,this.column=s?s.column:void 0,this.fatal=void 0,this.file,this.message=i,this.line=s?s.line:void 0,this.name=t(a.place)||`1:1`,this.place=a.place||void 0,this.reason=this.message,this.ruleId=a.ruleId||void 0,this.source=a.source||void 0,this.stack=o&&a.cause&&typeof a.cause.stack==`string`?a.cause.stack:``,this.actual,this.expected,this.note,this.url}};o.prototype.file=``,o.prototype.name=``,o.prototype.reason=``,o.prototype.message=``,o.prototype.stack=``,o.prototype.column=void 0,o.prototype.line=void 0,o.prototype.ancestors=void 0,o.prototype.cause=void 0,o.prototype.fatal=void 0,o.prototype.place=void 0,o.prototype.ruleId=void 0,o.prototype.source=void 0;const s={basename:c,dirname:l,extname:u,join:d,sep:`/`};function c(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);m(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function l(e){if(m(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function u(e){m(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function d(...e){let t=-1,n;for(;++t<e.length;)m(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:f(n)}function f(e){m(e);let t=e.codePointAt(0)===47,n=p(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function p(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(!(i===o-1||a===1))if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function m(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}const h={cwd:g};function g(){return`/`}function _(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function v(e){if(typeof e==`string`)e=new URL(e);else if(!_(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return y(e)}function y(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}const b=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`];var x=class{constructor(e){let t;t=e?_(e)?{path:e}:typeof e==`string`||T(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:h.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<b.length;){let e=b[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)b.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?s.basename(this.path):void 0}set basename(e){C(e,`basename`),S(e,`basename`),this.path=s.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?s.dirname(this.path):void 0}set dirname(e){w(this.basename,`dirname`),this.path=s.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?s.extname(this.path):void 0}set extname(e){if(S(e,`extname`),w(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=s.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){_(e)&&(e=v(e)),C(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?s.basename(this.path,this.extname):void 0}set stem(e){C(e,`stem`),S(e,`stem`),this.path=s.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new o(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function S(e,t){if(e&&e.includes(s.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+s.sep+"`")}function C(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function w(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function T(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}const E=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r});var D=e(r(),1);const O={}.hasOwnProperty,k=new class e extends E{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=a()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,D.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(M(`data`,this.frozen),this.namespace[e]=t,this):O.call(this.namespace,e)&&this.namespace[e]||void 0:e?(M(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=F(e),n=this.parser||this.Parser;return A(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),A(`process`,this.parser||this.Parser),j(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=F(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);L(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,r;return this.freeze(),A(`processSync`,this.parser||this.Parser),j(`processSync`,this.compiler||this.Compiler),this.process(e,i),P(`processSync`,`process`,t),r;function i(e,i){t=!0,n(e),r=i}}run(e,t,n){N(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=F(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let r=!1,i;return this.run(e,t,a),P(`runSync`,`run`,r),i;function a(e,t){n(e),i=t,r=!0}}stringify(e,t){this.freeze();let n=F(t),r=this.compiler||this.Compiler;return j(`stringify`,r),N(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(M(`use`,this.frozen),e!=null)if(typeof e==`function`)c(e,t);else if(typeof e==`object`)Array.isArray(e)?s(e):o(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function a(e){if(typeof e==`function`)c(e,[]);else if(typeof e==`object`)if(Array.isArray(e)){let[t,...n]=e;c(t,n)}else o(e);else throw TypeError("Expected usable value, not `"+e+"`")}function o(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");s(e.plugins),e.settings&&(r.settings=(0,D.default)(!0,r.settings,e.settings))}function s(e){let t=-1;if(e!=null)if(Array.isArray(e))for(;++t<e.length;){let n=e[t];a(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}function c(e,t){let r=-1,a=-1;for(;++r<n.length;)if(n[r][0]===e){a=r;break}if(a===-1)n.push([e,...t]);else if(t.length>0){let[r,...o]=t,s=n[a][1];i(s)&&i(r)&&(r=(0,D.default)(!0,s,r)),n[a]=[e,r,...o]}}}}().freeze();function A(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function j(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function M(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function N(e){if(!i(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function P(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function F(e){return I(e)?e:new x(e)}function I(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function L(e){return typeof e==`string`||R(e)}function R(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}export{k as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as e,H as t,K as n,M as r,O as i,Q as a,T as o,V as s,X as c,Y as l,_ as u,c as d,et as f,h as p,i as m,j as h,m as g}from"./libs/remeda.mjs";import{g as _,h as v,ht as y}from"./types.mjs";import{D as b,Q as x,S,l as C}from"./utils.mjs";import{castDraft as w,produce as T}from"immer";function E(r){return f(r,l(e=>!!e.notation),t(g(`notation`)),e(p(t(g(`shape`)),e(p(t(g(`color`)),e(p(o(g(`kind`)),m())),c(),o(([e,t])=>({kinds:t,color:e})))),c(),n(([e,t])=>t.map(({color:t,kinds:n})=>({shape:e,color:t,kinds:n}))))),c(),n(([e,t])=>t.map(({shape:t,color:n,kinds:r})=>({title:e,shape:t,color:n,kinds:r}))),d(g(`shape`),g(`title`),[e=>e.kinds.length,`desc`]))}const D=(e,t)=>e===t||r(e)&&r(t)?!1:!s(e,t);function O(e,t){e.color=t.color,e.kind=t.kind,e.navigateTo=t.navigateTo??null,e.links=t.links?[...t.links]:null,e.tags=[...t.tags],r(t.style.border)?delete e.style.border:e.style.border=t.style.border,h(t.style.opacity)?e.style.opacity=t.style.opacity:delete e.style.opacity,r(t.style.multiple)?delete e.style.multiple:e.style.multiple=t.style.multiple}function k(e,t,n){if(D(t.icon??`none`,e.icon??`none`)){let a=i(e.icon)&&e.icon!==`none`;switch(!0){case a&&i(t.icon)&&t.icon!==`none`:return e.icon=t.icon,!0;case a&&(r(t.icon)||t.icon===`none`):return e.icon=`none`,!0;case!a&&i(t.icon)&&t.icon!==`none`:return n?(e.icon=t.icon,!0):!1}}return!0}function A(e,t,n){let i=!0;return D(e.style.iconColor,t.style.iconColor)&&(r(t.style.iconColor)?delete e.style.iconColor:e.style.iconColor=t.style.iconColor),D(e.style.iconSize,t.style.iconSize)&&(n?r(t.style.iconSize)?delete e.style.iconSize:e.style.iconSize=t.style.iconSize:i=!1),D(e.style.iconPosition,t.style.iconPosition)&&(n?r(t.style.iconPosition)?delete e.style.iconPosition:e.style.iconPosition=t.style.iconPosition:i=!1),i}function j(e,t){return e?`md`in t?(e.md=t.md,delete e.txt,e):(`txt`in t&&(e.txt=t.txt,delete e.md),e):t}function M(e,t,n){let i=!0;return D(e.title,t.title)&&(n?e.title=t.title:i=!1),D(e.description,t.description)&&(r(t.description)?delete e.description:n?e.description=j(e.description,t.description):i=!1),D(e.technology,t.technology)&&(r(t.technology)?delete e.technology:n?e.technology=t.technology:i=!1),i}function N(e,t,n){return e.title=t.title,r(t.description)?delete e.description:e.description=j(e.description,t.description),r(t.technology)?delete e.technology:e.technology=t.technology,!0}function P(e,t){x(e.id===t.id,`applyManualLayout: view ids do not match`),x(e._stage===`layouted`,`applyManualLayout: expected layouted view`),x(t._stage===`layouted`,`applyManualLayout: expected layouted snapshot`),x(e._layout!==`manual`,`applyManualLayout: expected auto-layouted view`);let n=new Set;e._type!==t._type&&n.add(`type-changed`);let r=F(t.nodes,e.nodes,n),i=I(t.edges,e.edges,n),o=E(r);return T(t,s=>{s.title=e.title??t.title,s.description=e.description??t.description,s.tags=e.tags?[...e.tags]:null,s.links=e.links?[...e.links]:null,s.sourcePath=e.sourcePath,s[y]=`manual`,o&&o.length>0?s.notation={nodes:o}:delete s.notation,s.nodes=w(r),s.edges=w(i),v(e)&&s._type===`dynamic`&&(s.variant=e.variant),_(e)&&s._type===`element`&&(e.viewOf?s.viewOf=e.viewOf:delete s.viewOf,e.extends?s.extends=e.extends:delete s.extends);let c=[...n];a(c,1)?s.drifts=c:(s.hash=e.hash,delete s.drifts)})}function F(e,t,n){let i=new Map(t.map(e=>[e.id,e])),o=e.map(e=>{let t=i.get(e.id);return t?(i.delete(t.id),T(e,i=>{O(i,t);let o=new Set,s=e.children.length>0,c=t.children.length>0;(D(i.modelRef,t.modelRef)||D(i.deploymentRef,t.deploymentRef))&&o.add(`modelRef-changed`),c&&!s&&o.add(`became-compound`),!c&&s&&o.add(`became-leaf`),D(i.parent,t.parent)&&o.add(`parent-changed`);let l=i.width+5>=t.width&&i.height+5>=t.height;D(i.shape,t.shape)&&(l?i.shape=t.shape:o.add(`shape-changed`)),A(i,t,l)||o.add(`label-changed`),k(i,t,l&&c===s)||o.add(`label-changed`),(s?N:M)(i,t,l)||o.add(`label-changed`),D(i.notes,t.notes)&&(r(t.notes)?delete i.notes:i.notes=j(i.notes,t.notes)),D(e.notation,t.notation)&&(i.notation=t.notation??null),s&&c&&C(new Set(e.children),new Set(t.children)).size>0&&o.add(`children-changed`);let u=[...o];a(u,1)?(n.add(`nodes-drift`),i.drifts=u):delete i.drifts})):(n.add(`nodes-removed`),{...e,drifts:[`removed`]})});return i.size>0&&n.add(`nodes-added`),o}function I(e,t,n){let i=new Map(t.map(e=>[e.id,e])),o=e.map(e=>{let t=i.get(e.id)??f(i.values(),b(t=>t.source===e.source&&t.target===e.target),S());return t&&i.delete(t.id),T(e,i=>{if(!t){i.drifts=[`removed`],n.add(`edges-removed`);return}let o=new Set,s=e.id===t.id;switch(!0){case s&&e.source==t.source&&e.target==t.target:D(i.dir??`forward`,t.dir??`forward`)&&o.add(`direction-changed`);break;case s&&e.source==t.target&&e.target==t.source:e.source!==e.target&&o.add(`direction-changed`);break;case s:e.source!=t.source&&o.add(`source-changed`),e.target!=t.target&&o.add(`target-changed`);break;default:x(e.id!=t.id,`Unexpected case in edge drift detection, ids should not match`),x(e.source==t.source,`Unexpected case in edge drift detection, sources should match`),x(e.target==t.target,`Unexpected case in edge drift detection, targets should match`),D(i.dir??`forward`,t.dir??`forward`)&&o.add(`direction-changed`);break}if(i.color=t.color,i.line=t.line,i.navigateTo=t.navigateTo??null,i.tags=t.tags?[...t.tags]:null,D(e.notes,t.notes)&&(r(e.notes)!==r(t.notes)&&o.add(`notes-changed`),i.notes=t.notes??e.notes),t.astPath?i.astPath=t.astPath:delete i.astPath,D(u(e,[`label`,`description`,`technology`,`labelBBox`]),u(t,[`label`,`description`,`technology`,`labelBBox`])))switch(!0){case t.labelBBox&&!e.labelBBox:o.add(`label-added`);break;case e.labelBBox&&!t.labelBBox:o.add(`label-removed`);break;case!!e.labelBBox&&!!t.labelBBox:t.labelBBox.width*t.labelBBox.height>(e.labelBBox.width+5)*(e.labelBBox.height+5)&&(i.labelBBox.width=Math.round(t.labelBBox.width),i.labelBBox.height=Math.round(t.labelBBox.height)),D(e.label,t.label)&&(r(t.label)!==r(e.label)&&o.add(`label-changed`),i.label=t.label??e.label),D(e.description,t.description)&&(r(t.description)!==r(e.description)&&o.add(`label-changed`),t.description&&(i.description=j(e.description,t.description))),D(e.technology,t.technology)&&(r(t.technology)!==r(e.technology)&&o.add(`label-changed`),i.technology=t.technology??e.technology??null);break;default:x(!e.labelBBox,`Unexpected case in edge labelBBox drift detection`),x(!t.labelBBox,`Unexpected case in next labelBBox drift detection`);break}let c=[...o];a(c,1)?(n.add(`edges-drift`),i.drifts=c):delete i.drifts})});return i.size>0&&n.add(`edges-added`),o}function L(e,t){let{drifts:n,...r}=P(e,t);if(!n||n.length===0)return T(e,e=>{delete e.drifts,e[y]=`auto`});let i=new Set;n.includes(`type-changed`)&&i.add(`type-changed`);let o=new Map(r.nodes.map(e=>[e.id,e])),s=new Map(r.edges.map(e=>[e.id,e])),c=e.nodes.map(e=>{let t=o.get(e.id);return t&&o.delete(t.id),T(e,e=>{if(!t){i.add(`nodes-added`),e.drifts=[`added`];return}t.drifts?(i.add(`nodes-drift`),e.drifts=[...t.drifts]):delete e.drifts})});o.size>0&&i.add(`nodes-removed`);let l=e.edges.map(e=>{let t=s.get(e.id)??f(s.values(),b(t=>t.source===e.source&&t.target===e.target),S());return t&&s.delete(t.id),T(e,e=>{if(!t){i.add(`edges-added`),e.drifts=[`added`];return}t.drifts?(i.add(`edges-drift`),e.drifts=[...t.drifts]):delete e.drifts})});s.size>0&&i.add(`edges-removed`);let u=[...i];return T(e,e=>{a(u,1)?e.drifts=u:delete e.drifts,e.nodes=w(c),e.edges=w(l),e[y]=`auto`})}export{P as n,E as r,L as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime.mjs";import{A as t,E as n,I as r,L as i,N as a,O as o,Q as s,T as c,X as ee,c as te,et as l,i as u,l as d,m as ne,r as f,s as re}from"./libs/remeda.mjs";import{A as ie,D as ae,J as p,Q as oe,V as se,_t as m,bt as h,dt as ce,gt as g,lt as le,pt as ue,st as de,t as _,ut as fe,vt as pe,xt as v,yt as y}from"./types.mjs";import{$ as b,A as x,B as S,D as me,E as he,F as C,H as ge,I as w,J as _e,L as T,Q as E,R as ve,S as D,U as ye,Y as be,a as O,c as k,h as A,j,k as xe,o as M,q as Se,r as Ce,u as N,y as we,z as Te}from"./utils.mjs";import{t as P}from"./libs/mnemonist.mjs";import{n as Ee,t as De}from"./manual-layout.mjs";var F=class{Aux;id;_literalId;hierarchyLevel;imported;constructor(e,t){this.$model=e,this.$element=t,this.id=this.$element.id,this._literalId=this.$element.id;let[n,r]=ue(this.id);n?(this.imported={from:n,fqn:r},this.hierarchyLevel=C(r)):(this.imported=null,this.hierarchyLevel=C(this.id))}get name(){return Te(this.id)}get parent(){return this.$model.parent(this)}get kind(){return this.$element.kind}get shape(){return this.style.shape}get color(){return this.style.color}get icon(){return this.style.icon??null}get tags(){return A(this,Symbol.for(`tags`),()=>u([...this.$element.tags??[],...this.$model.specification.elements[this.$element.kind]?.tags??[]]))}get title(){return this.$element.title}get hasSummary(){return!!this.$element.summary&&!!this.$element.description&&!t(this.$element.summary,this.$element.description)}get summary(){return _.memoize(this,`summary`,h(this.$element))}get description(){return _.memoize(this,`description`,y(this.$element))}get technology(){return this.$element.technology??null}get links(){return this.$element.links??[]}get defaultView(){return A(this,Symbol.for(`defaultView`),()=>D(this.scopedViews())??null)}get isRoot(){return this.parent===null}get style(){return A(this,`style`,()=>v({shape:this.$model.$styles.defaults.shape,color:this.$model.$styles.defaults.color,border:this.$model.$styles.defaults.border,opacity:this.$model.$styles.defaults.opacity,size:this.$model.$styles.defaults.size,padding:this.$model.$styles.defaults.padding,textSize:this.$model.$styles.defaults.text,iconPosition:this.$model.$styles.defaults.iconPosition,...this.$element.style}))}get projectId(){return this.imported?.from??this.$model.projectId}isAncestorOf(e){return w(this,e)}isDescendantOf(e){return w(e,this)}ancestors(){return this.$model.ancestors(this)}commonAncestor(e){let t=j(this.id,e.id);return t?this.$model.element(t):null}children(){return this.$model.children(this)}descendants(e){return e?ge([...this.$model.descendants(this)],e)[Symbol.iterator]():this.$model.descendants(this)}siblings(){return this.$model.siblings(this)}*ascendingSiblings(){yield*this.siblings();for(let e of this.ancestors())yield*e.siblings()}*descendingSiblings(){for(let e of[...this.ancestors()].reverse())yield*e.siblings();yield*this.siblings()}incoming(e=`all`){return this.$model.incoming(this,e)}*incomers(e=`all`){let t=new Set;for(let n of this.incoming(e))t.has(n.source.id)||(t.add(n.source.id),yield n.source)}outgoing(e=`all`){return this.$model.outgoing(this,e)}*outgoers(e=`all`){let t=new Set;for(let n of this.outgoing(e))t.has(n.target.id)||(t.add(n.target.id),yield n.target)}get allOutgoing(){return A(this,Symbol.for(`allOutgoing`),()=>new Set(this.outgoing()))}get allIncoming(){return A(this,Symbol.for(`allIncoming`),()=>new Set(this.incoming()))}views(){return A(this,Symbol.for(`views`),()=>{let e=new Set;for(let t of this.$model.views())t.includesElement(this.id)&&e.add(t);return e})}scopedViews(){return A(this,Symbol.for(`scopedViews`),()=>{let e=new Set;for(let t of this.$model.views())t.isScopedElementView()&&t.viewOf.id===this.id&&e.add(t);return e})}isDeployed(){return o(D(this.deployments()))}deployments(){return this.$model.deployment.instancesOf(this)}hasMetadata(){return!!this.$element.metadata&&!i(this.$element.metadata)}getMetadata(e){return e?this.$element.metadata?.[e]:this.$element.metadata??{}}isTagged(e){return this.tags.includes(e)}},Oe=class{Aux;get style(){return A(this,`style`,()=>v({shape:this.$model.$styles.defaults.shape,color:this.$model.$styles.defaults.color,border:this.$model.$styles.defaults.border,opacity:this.$model.$styles.defaults.opacity,size:this.$model.$styles.defaults.size,padding:this.$model.$styles.defaults.padding,textSize:this.$model.$styles.defaults.text,iconPosition:this.$model.$styles.defaults.iconPosition,...this.$node.style}))}get name(){return Te(this.id)}get shape(){return this.style.shape}get color(){return this.style.color}get icon(){return this.style.icon??null}get summary(){return _.memoize(this,`summary`,h(this.$node))}get description(){return _.memoize(this,`description`,y(this.$node))}get technology(){return this.$node.technology??null}get links(){return this.$node.links??[]}ancestors(){return this.$model.ancestors(this)}commonAncestor(e){let t=j(this.id,e.id);return t?this.$model.node(t):null}siblings(){return this.$model.siblings(this)}isSibling(e){return this.parent===e.parent}*ascendingSiblings(){yield*this.siblings();for(let e of this.ancestors())yield*e.siblings()}*descendingSiblings(){for(let e of[...this.ancestors()].reverse())yield*e.siblings();yield*this.siblings()}incoming(e=`all`){return this.$model.incoming(this,e)}outgoing(e=`all`){return this.$model.outgoing(this,e)}*incomers(e=`all`){let t=new Set;for(let n of this.incoming(e))t.has(n.source.id)||(t.add(n.source.id),yield n.source)}*outgoers(e=`all`){let t=new Set;for(let n of this.outgoing(e))t.has(n.target.id)||(t.add(n.target.id),yield n.target)}*views(){for(let e of this.$model.views())e._type===`deployment`&&e.includesDeployment(this.id)&&(yield e)}isDeploymentNode(){return!1}isInstance(){return!1}get allOutgoing(){return A(this,Symbol.for(`allOutgoing`),()=>z.from(new Set(this.outgoingModelRelationships()),new Set(this.outgoing())))}get allIncoming(){return A(this,Symbol.for(`allIncoming`),()=>z.from(new Set(this.incomingModelRelationships()),new Set(this.incoming())))}hasMetadata(){return!!this.$node.metadata&&!i(this.$node.metadata)}getMetadata(e){return e?this.$node.metadata?.[e]:this.$node.metadata??{}}isTagged(e){return this.tags.includes(e)}},I=class extends Oe{id;_literalId;title;hierarchyLevel;constructor(e,t){super(),this.$model=e,this.$node=t,this.id=t.id,this._literalId=t.id,this.title=t.title,this.hierarchyLevel=C(t.id)}get parent(){return this.$model.parent(this)}get kind(){return this.$node.kind}get tags(){return A(this,Symbol.for(`tags`),()=>u([...this.$node.tags??[],...this.$model.$model.specification.deployments[this.kind]?.tags??[]]))}children(){return this.$model.children(this)}descendants(e=`desc`){return this.$model.descendants(this,e)}isDeploymentNode(){return!0}*instances(){for(let e of this.descendants(`desc`))e.isInstance()&&(yield e)}onlyOneInstance(){let e=this.children();if(e.size!==1)return null;let t=D(e);return t?t.isInstance()?t:t.onlyOneInstance():null}_relationshipsFromInstances=null;relationshipsFromInstances(){if(this._relationshipsFromInstances)return this._relationshipsFromInstances;let{outgoing:e,incoming:t}=this._relationshipsFromInstances={outgoing:new Set,incoming:new Set};for(let n of this.instances()){for(let t of n.element.outgoing())e.add(t);for(let e of n.element.incoming())t.add(e)}return this._relationshipsFromInstances}outgoingModelRelationships(){return this.relationshipsFromInstances().outgoing.values()}incomingModelRelationships(){return this.relationshipsFromInstances().incoming.values()}internalModelRelationships(){let{outgoing:e,incoming:t}=this.relationshipsFromInstances();return k(t,e)}},L=class extends Oe{id;_literalId;title;hierarchyLevel;constructor(e,t,n){super(),this.$model=e,this.$instance=t,this.element=n,this.id=t.id,this._literalId=t.id,this.title=t.title??n.title,this.hierarchyLevel=C(t.id)}get $node(){return this.$instance}get parent(){return b(this.$model.parent(this),`Parent of ${this.id} not found`)}get style(){return A(this,`style`,()=>v({shape:this.$model.$styles.defaults.shape,color:this.$model.$styles.defaults.color,border:this.$model.$styles.defaults.border,opacity:this.$model.$styles.defaults.opacity,size:this.$model.$styles.defaults.size,padding:this.$model.$styles.defaults.padding,textSize:this.$model.$styles.defaults.text,iconPosition:this.$model.$styles.defaults.iconPosition,...this.element.$element.style,...this.$instance.style}))}get tags(){return A(this,Symbol.for(`tags`),()=>u([...this.$instance.tags??[],...this.element.tags]))}get kind(){return this.element.kind}get summary(){return _.memoize(this,`summary`,h(this.$instance)??h(this.element.$element))}get description(){return _.memoize(this,`description`,y(this.$instance)??y(this.element.$element))}get technology(){return this.$instance.technology??this.element.technology??null}get links(){return this.$instance.links??this.element.links}isInstance(){return!0}outgoingModelRelationships(){return this.element.outgoing()}incomingModelRelationships(){return this.element.incoming()}*views(){for(let e of this.$model.views())if(e._type===`deployment`){if(e.includesDeployment(this.id)){yield e;continue}e.includesDeployment(this.parent.id)&&this.parent.onlyOneInstance()&&(yield e)}}},ke=class{constructor(e,t){this.instance=e,this.element=t}get id(){return this.instance.id}get _literalId(){return this.instance.id}get style(){return A(this,`style `,()=>({shape:this.element.shape,color:this.element.color,...this.element.$element.style}))}get shape(){return this.element.shape}get color(){return this.element.color}get title(){return this.element.title}get summary(){return this.element.summary}get description(){return this.element.description}get technology(){return this.element.technology}isDeploymentNode(){return!1}isInstance(){return!1}},R=class{boundary;source;target;constructor(e,t){this.$model=e,this.$relationship=t,this.source=e.deploymentRef(t.source),this.target=e.deploymentRef(t.target);let n=j(this.source.id,this.target.id);this.boundary=n?this.$model.node(n):null}get id(){return this.$relationship.id}get expression(){return`${this.source.id} -> ${this.target.id}`}get title(){return o(this.$relationship.title)?this.$relationship.title:null}get technology(){return r(this.$relationship.technology)?(this.kind&&this.$model.specification.relationships[this.kind])?.technology??null:this.$relationship.technology}get hasSummary(){return!!this.$relationship.summary&&!!this.$relationship.description&&!t(this.$relationship.summary,this.$relationship.description)}get summary(){return _.memoize(this,`summary`,h(this.$relationship))}get description(){return _.memoize(this,`description`,y(this.$relationship))}get tags(){return this.$relationship.tags??[]}get kind(){return this.$relationship.kind??null}get navigateTo(){return this.$relationship.navigateTo?this.$model.$model.view(this.$relationship.navigateTo):null}get links(){return this.$relationship.links??[]}get color(){return this.$relationship.color??this.$model.$styles.defaults.relationship.color}get line(){return this.$relationship.line??this.$model.$styles.defaults.relationship.line}get head(){return this.$relationship.head??this.$model.$styles.defaults.relationship.arrow}get tail(){return this.$relationship.tail}*views(){for(let e of this.$model.views())e.includesRelation(this.id)&&(yield e)}isDeploymentRelation(){return!0}isModelRelation(){return!1}hasMetadata(){return!!this.$relationship.metadata&&!i(this.$relationship.metadata)}getMetadata(e){return e?this.$relationship.metadata?.[e]:this.$relationship.metadata??{}}isTagged(e){return this.tags.includes(e)}},z=class e{static empty(){return new e}static from(t,n){return new e(new Set(t),new Set(n))}constructor(e=new Set,t=new Set){this.model=e,this.deployment=t}get isEmpty(){return this.model.size===0&&this.deployment.size===0}get nonEmpty(){return this.model.size>0||this.deployment.size>0}get size(){return this.model.size+this.deployment.size}intersect(t){return e.from(k(this.model,t.model),k(this.deployment,t.deployment))}difference(t){return e.from(O(this.model,t.model),O(this.deployment,t.deployment))}union(t){return e.from(N(this.model,t.model),N(this.deployment,t.deployment))}};const B=e=>typeof e==`string`?e:e.id,Ae=`/`,V=e=>{if(E(!e.includes(`
|
|
2
|
+
`),`View title cannot contain newlines`),e.includes(`/`)){let t=e.split(`/`).map(e=>e.trim()).filter(e=>e.length>0);return s(t,1)?t:[``]}return[e.trim()]},H=e=>V(e).join(`/`),je=e=>{let t=V(e);return s(t,2)?t.slice(0,-1).join(`/`):null},Me=e=>e.includes(`/`)?V(e).pop()??e:e.trim();var Ne=class{#e=new Map;#t=new Map;#n=new P.default(()=>new Set);#r=new P.default(()=>new Set);#i=new Set;#a=new Map;#o=new P.default(()=>new Set);#s=new P.default(()=>new Set);#c=new P.default(()=>new Set);#l=new P.default(()=>new Set);#u=new Map;$deployments;constructor(e){this.$model=e;let t=this.$deployments=e.$data.deployments,n=f(t.elements);for(let e of ye(n)){let t=this.addElement(e);for(let e of t.tags)this.#l.get(e).add(t);t.isInstance()&&this.#r.get(t.element.id).add(t)}for(let e of f(t.relations)){let t=this.addRelation(e);for(let e of t.tags)this.#l.get(e).add(t)}}get $styles(){return this.$model.$styles}get projectId(){return this.$model.projectId}get project(){return this.$model.project}get specification(){return this.$model.specification}element(e){if(e instanceof I||e instanceof L)return e;let t=B(e);return b(this.#e.get(t),`Element ${t} not found`)}findElement(e){return this.#e.get(e)??null}node(e){let t=this.element(e);return E(t.isDeploymentNode(),`Element ${t.id} is not a deployment node`),t}findNode(e){let t=this.findElement(e);return t?(E(t.isDeploymentNode(),`Element ${t?.id} is not a deployment node`),t):null}instance(e){let t=this.element(e);return E(t.isInstance(),`Element ${t.id} is not a deployed instance`),t}findInstance(e){let t=this.findElement(e);return t?(E(t.isInstance(),`Element ${t?.id} is not a deployed instance`),t):null}roots(){return this.#i.values()}elements(){return this.#e.values()}*nodes(){for(let e of this.#e.values())e.isDeploymentNode()&&(yield e)}*nodesOfKind(e){for(let t of this.#e.values())t.isDeploymentNode()&&t.kind===e&&(yield t)}*instances(){for(let e of this.#e.values())e.isInstance()&&(yield e)}*instancesOf(e){let t=B(e),n=this.#r.get(t);n&&(yield*n)}deploymentRef(e){if(p.isInsideInstanceRef(e)){let{deployment:t,element:n}=e;return xe(this.#u,`${t}@${n}`,()=>new ke(this.instance(t),this.$model.element(n)))}return this.element(e.deployment)}relationships(){return this.#a.values()}relationship(e){let t=B(e);return b(this.#a.get(t),`DeploymentRelationModel ${t} not found`)}findRelationship(e){return this.#a.get(e)??null}*views(){for(let e of this.$model.views())e.isDeploymentView()&&(yield e)}parent(e){let t=B(e);return this.#t.get(t)||null}children(e){let t=B(e);return this.#n.get(t)}*siblings(e){let t=B(e),n=this.parent(e)?.children()??this.roots();for(let e of n)e.id!==t&&(yield e)}*ancestors(e){let t=B(e),n;for(;n=this.#t.get(t);)yield n,t=n.id}*descendants(e,t=`desc`){for(let n of this.children(e))t===`asc`?(yield n,yield*this.descendants(n.id)):(yield*this.descendants(n.id),yield n)}*incoming(e,t=`all`){let n=B(e);for(let e of this.#o.get(n))switch(!0){case t===`all`:case t===`direct`&&e.target.id===n:case t===`to-descendants`&&e.target.id!==n:yield e;break}}*outgoing(e,t=`all`){let n=B(e);for(let e of this.#s.get(n))switch(!0){case t===`all`:case t===`direct`&&e.source.id===n:case t===`from-descendants`&&e.source.id!==n:yield e;break}}addElement(e){if(this.#e.has(e.id))throw Error(`Element ${e.id} already exists`);let t=se(e)?new I(this,Object.freeze(e)):new L(this,Object.freeze(e),this.$model.element(e.element));this.#e.set(t.id,t);let n=S(t.id);return n?(E(this.#e.has(n),`Parent ${n} of ${t.id} not found`),this.#t.set(t.id,this.node(n)),this.#n.get(n).add(t)):(E(t.isDeploymentNode(),`Root element ${t.id} is not a deployment node`),this.#i.add(t)),t}addRelation(e){if(this.#a.has(e.id))throw Error(`Relation ${e.id} already exists`);let t=new R(this,Object.freeze(e));this.#a.set(t.id,t),this.#o.get(t.target.id).add(t),this.#s.get(t.source.id).add(t);let n=t.boundary?.id??null;if(n)for(let e of[n,...x(n)])this.#c.get(e).add(t);for(let e of x(t.source.id)){if(e===n)break;this.#s.get(e).add(t)}for(let e of x(t.target.id)){if(e===n)break;this.#o.get(e).add(t)}return t}},U=class{source;target;boundary;constructor(e,t){this.model=e,this.$relationship=t,this.source=e.element(p.flatten(t.source)),this.target=e.element(p.flatten(t.target));let n=j(this.source.id,this.target.id);this.boundary=n?this.model.element(n):null}get id(){return this.$relationship.id}get expression(){return`${this.source.id} -> ${this.target.id}`}get title(){return r(this.$relationship.title)?null:this.$relationship.title}get technology(){return r(this.$relationship.technology)?(this.kind&&this.model.specification.relationships[this.kind])?.technology??null:this.$relationship.technology}get hasSummary(){return!!this.$relationship.summary&&!!this.$relationship.description&&!t(this.$relationship.summary,this.$relationship.description)}get summary(){return _.memoize(this,`summary`,h(this.$relationship))}get description(){return _.memoize(this,`description`,y(this.$relationship))}get navigateTo(){return this.$relationship.navigateTo?this.model.view(this.$relationship.navigateTo):null}get tags(){return this.$relationship.tags??[]}get kind(){return this.$relationship.kind??null}get links(){return this.$relationship.links??[]}get color(){return this.$relationship.color??this.model.$styles.defaults.relationship.color}get line(){return this.$relationship.line??this.model.$styles.defaults.relationship.line}get head(){return this.$relationship.head??this.model.$styles.defaults.relationship.arrow}get tail(){return this.$relationship.tail}*views(){for(let e of this.model.views())e.includesRelation(this.id)&&(yield e)}isDeploymentRelation(){return!1}isModelRelation(){return!0}hasMetadata(){return!!this.$relationship.metadata&&!i(this.$relationship.metadata)}getMetadata(e){return e?this.$relationship.metadata?.[e]:this.$relationship.metadata??{}}isTagged(e){return this.tags.includes(e)}},W=class{Aux;$viewModel;$view;$edge;constructor(e,t,n,r){this.source=n,this.target=r,this.$viewModel=e,this.$view=e.$view,this.$edge=t}get id(){return this.$edge.id}get parent(){return this.$edge.parent?this.$viewModel.node(this.$edge.parent):null}get label(){return this.$edge.label??null}get description(){return _.memoize(this,`description`,this.$edge.description)}get technology(){return this.$edge.technology??null}hasParent(){return this.$edge.parent!==null}get tags(){return this.$edge.tags??[]}get stepNumber(){return this.isStep()?de(this.id):null}get navigateTo(){return this.$edge.navigateTo?this.$viewModel.$model.view(this.$edge.navigateTo):null}get color(){return this.$edge.color}get line(){return this.$edge.line??this.$viewModel.$styles.defaults.relationship.line}get head(){return this.$edge.head??this.$viewModel.$styles.defaults.relationship.arrow}get tail(){return this.$edge.tail}isStep(){return ce(this.id)}*relationships(e){for(let t of this.$edge.relations)if(e){let n=this.$viewModel.$model.findRelationship(t,e);n&&(yield n)}else yield this.$viewModel.$model.relationship(t)}includesRelation(e){let t=typeof e==`string`?e:e.id;return this.$edge.relations.includes(t)}isTagged(e){return this.tags.includes(e)}},G=class{Aux;$viewModel;$view;$node;constructor(e,t){this.$viewModel=e,this.$view=e.$view,this.$node=t}get id(){return this.$node.id}get title(){return this.$node.title}get kind(){return this.$node.kind}get description(){return _.memoize(this,`description`,this.$node.description)}get technology(){return this.$node.technology??null}get notes(){return _.memoize(this,`notes`,this.$node.notes)}get parent(){return this.$node.parent?this.$viewModel.node(this.$node.parent):null}get element(){let e=this.$node.modelRef;return e?this.$viewModel.$model.element(e):null}get deployment(){let e=this.$node.deploymentRef;return e?this.$viewModel.$model.deployment.element(e):null}get shape(){return this.$node.shape}get color(){return this.$node.color}get icon(){return this.$node.icon??null}get tags(){return this.$node.tags}get links(){return this.$node.links??[]}get navigateTo(){return this.$node.navigateTo?this.$viewModel.$model.view(this.$node.navigateTo):null}get style(){return this.$node.style}get x(){return`x`in this.$node?this.$node.x:void 0}get y(){return`y`in this.$node?this.$node.y:void 0}get width(){return`width`in this.$node?this.$node.width:void 0}get height(){return`height`in this.$node?this.$node.height:void 0}children(){return A(this,`children`,()=>new Set(this.$node.children.map(e=>this.$viewModel.node(e))))}*ancestors(){let e=this.parent;for(;e;)yield e,e=e.parent}*siblings(){let e=this.parent?.children()??this.$viewModel.roots();for(let t of e)t.id!==this.id&&(yield t)}*incoming(e=`all`){for(let t of this.$node.inEdges){let n=this.$viewModel.edge(t);switch(!0){case e===`all`:case e===`direct`&&n.target.id===this.id:case e===`to-descendants`&&n.target.id!==this.id:yield n;break}}}*incomers(e=`all`){let t=new Set;for(let n of this.incoming(e))t.has(n.source.id)||(t.add(n.source.id),yield n.source)}*outgoing(e=`all`){for(let t of this.$node.outEdges){let n=this.$viewModel.edge(t);switch(!0){case e===`all`:case e===`direct`&&n.source.id===this.id:case e===`from-descendants`&&n.source.id!==this.id:yield n;break}}}*outgoers(e=`all`){let t=new Set;for(let n of this.outgoing(e))t.has(n.target.id)||(t.add(n.target.id),yield n.target)}isLayouted(){return`width`in this.$node&&`height`in this.$node}hasChildren(){return this.$node.children.length>0}hasParent(){return this.$node.parent!==null}hasElement(){return o(this.$node.modelRef)}hasDeployment(){return o(this.$node.deploymentRef)}hasDeployedInstance(){return this.hasElement()&&this.hasDeployment()}isGroup(){return fe(this.$node)}isTagged(e){return this.tags.includes(e)}},K=class{Aux;#e;#t=new Set;#n=new Map;#r=new Map;#i=new Set;#a=new Set;#o=new Set;#s=new P.default(e=>new Set);#c;id;$model;title;folder;viewPath;constructor(e,t,n,r){this.$model=e,this.#e=n,this.id=n.id,this.folder=t,this.#c=r;for(let e of this.#e.nodes){let t=new G(this,Object.freeze(e));this.#n.set(e.id,t),e.parent||this.#t.add(t),e.deploymentRef&&this.#a.add(e.deploymentRef),e.modelRef&&this.#i.add(e.modelRef);for(let e of t.tags)this.#s.get(e).add(t)}for(let e of this.#e.edges){let t=new W(this,Object.freeze(e),this.node(e.source),this.node(e.target));for(let e of t.tags)this.#s.get(e).add(t);for(let t of e.relations)this.#o.add(t);this.#r.set(e.id,t)}this.title=n.title?Me(n.title):null,this.viewPath=n.title?H(n.title):n.id}get $styles(){return this.$model.$styles}get _type(){return this.#e[m]}get stage(){return this.#e[g]}get bounds(){if(`bounds`in this.#e)return this.#e.bounds;if(this.#c)return this.#c.bounds;throw Error(`View is not layouted`)}get titleOrId(){return this.title??this.viewOf?.title??this.id}get titleOrUntitled(){return this.title??`Untitled`}get breadcrumbs(){return A(this,`breadcrumbs`,()=>this.folder.isRoot?[this]:[...this.folder.breadcrumbs,this])}get description(){return _.memoize(this,`description`,this.#e.description)}get tags(){return this.#e.tags??[]}get links(){return this.#e.links??[]}get viewOf(){if(this.isElementView()){let e=this.#e.viewOf;return e?this.$model.element(e):null}return null}get mode(){return this.isDynamicView()?this.#e.variant??`diagram`:null}get includedTags(){return[...this.#s.keys()]}get $view(){if(!this.isLayouted()||`drifts`in this.#e)return this.#e;let e=this.#c;return e?A(this,`withDriftReasons`,()=>De(this.#e,e)):this.#e}get $layouted(){if(!this.isLayouted())throw Error(`View is not layouted`);return this.$manual??this.#e}get hasManualLayout(){return this.#c!==void 0}get hasLayoutDrifts(){if(!this.isLayouted())return!1;let e=this.$manual;return!!e?.drifts&&e.drifts.length>0}get $manual(){if(!this.isLayouted())return null;let e=this.#c;return e?A(this,`snapshotWithManualLayout`,()=>Ee(this.#e,e)):null}get projectId(){return this.$model.projectId}roots(){return this.#t.values()}*compounds(){for(let e of this.#n.values())e.hasChildren()&&(yield e)}node(e){let t=B(e);return b(this.#n.get(t),`Node ${t} not found in view ${this.#e.id}`)}findNode(e){return this.#n.get(B(e))??null}findNodeWithElement(e){let t=B(e);return this.#i.has(t)?he(this.#n.values(),e=>e.hasElement()&&e.element.id===t)??null:null}nodes(){return this.#n.values()}edge(e){let t=B(e);return b(this.#r.get(t),`Edge ${t} not found in view ${this.#e.id}`)}findEdge(e){return this.#r.get(B(e))??null}edges(){return this.#r.values()}*edgesWithRelation(e){for(let t of this.#r.values())t.includesRelation(e)&&(yield t)}*elements(){for(let e of this.#n.values())e.hasElement()&&(yield e)}isTagged(e){return this.tags.includes(e)}includesElement(e){return this.#i.has(B(e))}includesDeployment(e){return this.#a.has(B(e))}includesRelation(e){return this.#o.has(B(e))}isComputed(){return this.#e[g]===`computed`}isLayouted(){return this.#e[g]===`layouted`}isDiagram(){return this.#e[g]===`layouted`}isElementView(){return this.#e[m]===`element`}isScopedElementView(){return this.#e[m]===`element`&&o(this.#e.viewOf)}isDeploymentView(){return this.#e[m]===`deployment`}isDynamicView(){return this.#e[m]===`dynamic`}},q=class e{$model;path;title;isRoot;parentPath;defaultViewId;constructor(e,t,r){this.$model=e,this.path=t.join(`/`),this.isRoot=this.path===``,this.title=n(t),this.isRoot?this.parentPath=void 0:this.parentPath=t.slice(0,-1).join(`/`),this.defaultViewId=r}get defaultView(){return this.defaultViewId?this.$model.view(this.defaultViewId):null}get breadcrumbs(){return E(!this.isRoot,`Root view folder has no breadcrumbs`),A(this,`breadcrumbs`,()=>{let e=this.parent;return e?e.isRoot?[e,this]:[...e.breadcrumbs,this]:[this]})}get parent(){return E(!this.isRoot,`Root view folder has no parent`),r(this.parentPath)?null:this.$model.viewFolder(this.parentPath)}get children(){return this.$model.viewFolderItems(this.path)}get folders(){return A(this,`folders`,()=>{let t=[];for(let n of this.children)n instanceof e&&t.push(n);return t})}get views(){return A(this,`views`,()=>{let e=[];for(let t of this.children)t instanceof K&&e.push(t);return e})}},J=class e{Aux;_elements=new Map;_parents=new Map;_children=new P.default(()=>new Set);_rootElements=new Set;_relations=new Map;_incoming=new P.default(()=>new Set);_outgoing=new P.default(()=>new Set);_internal=new P.default(()=>new Set);_views=new Map;_rootViewFolder;_viewFolders=new Map;_viewFolderItems=new P.default(()=>new Set);_allTags=new P.default(()=>new Set);static fromParsed(t){return new e(t)}static create(t){return new e(t)}static fromDump(t){let{_stage:n=`layouted`,projectId:r=`unknown`,project:i,globals:a,imports:o,deployments:s,views:c,relations:ee,elements:te,specification:l}=t;return new e({[g]:n,projectId:r,project:i,globals:{predicates:a?.predicates??{},dynamicPredicates:a?.dynamicPredicates??{},styles:a?.styles??{}},imports:o??{},deployments:{elements:s?.elements??{},relations:s?.relations??{}},views:c??{},relations:ee??{},elements:te??{},specification:l})}deployment;$data;constructor(e){this.$data=e;for(let[,t]of ee(e.elements)){let e=this.addElement(t);for(let t of e.tags)this._allTags.get(t).add(e)}for(let[t,n]of ee(e.imports??{}))for(let e of ye(n)){let n=this.addImportedElement(t,e);for(let e of n.tags)this._allTags.get(e).add(n)}for(let t of f(e.relations)){let e=this.addRelation(t);for(let t of e.tags)this._allTags.get(t).add(e)}if(this.deployment=new Ne(this),pe(e,`computed`)||pe(e,`layouted`)){let t=be(`/`),n=l(f(e.views),c(e=>({view:e,path:H(e.title??e.id),folderPath:e.title&&je(e.title)||``})),d((e,n)=>t(e.folderPath,n.folderPath))),r=e=>{let t=this._viewFolders.get(e);if(!t){let r=re(e,`/`);E(s(r,1),`View group path "${e}" must have at least one element`);let i;i=e===``?n.find(e=>e.view.id===`index`):n.find(t=>t.path===e),t=new q(this,r,i?.view.id),this._viewFolders.set(e,t)}return t};this._rootViewFolder=r(``);for(let{folderPath:e}of n)this._viewFolders.has(e)||re(e,`/`).reduce((e,t)=>{let n=e.join(`/`),a=r(i(n)?t:n+`/`+t);return this._viewFolderItems.get(n).add(a),e.push(t),e},[]);for(let{view:t,folderPath:i}of n){let n=new K(this,r(i),t,e.manualLayouts?.[t.id]);this._viewFolderItems.get(i).add(n),this._views.set(t.id,n);for(let e of n.tags)this._allTags.get(e).add(n)}}else this._rootViewFolder=new q(this,[``],void 0),this._viewFolders.set(this._rootViewFolder.path,this._rootViewFolder)}get asParsed(){return this}get asComputed(){return this}get asLayouted(){return this}get $styles(){return A(this,`styles`,()=>ie.from(this.project.styles,this.specification.customColors))}isParsed(){return this.stage===`parsed`}isLayouted(){return this.stage===`layouted`}isComputed(){return this.stage===`computed`}get $model(){return this.$data}get stage(){return this.$data[g]}get projectId(){return this.$data.projectId??`default`}get project(){return this.$data.project??A(this,Symbol.for(`project`),()=>({id:this.projectId,styles:{},manualLayouts:{}}))}get specification(){return this.$data.specification}get globals(){return A(this,Symbol.for(`globals`),()=>({predicates:{...this.$data.globals?.predicates},dynamicPredicates:{...this.$data.globals?.dynamicPredicates},styles:{...this.$data.globals?.styles}}))}element(e){if(e instanceof F)return e;let t=B(e);return b(this._elements.get(t),`Element ${t} not found`)}findElement(e){return this._elements.get(B(e))??null}roots(){return this._rootElements.values()}elements(){return this._elements.values()}relationships(){return this._relations.values()}relationship(e,t){if(t===`deployment`)return this.deployment.relationship(e);let n=B(e),r=this._relations.get(n)??null;return r||t===`model`?b(r,`Model relation ${n} not found`):b(this.deployment.findRelationship(n),`No model/deployment relation ${n} not found`)}findRelationship(e,t){if(t===`deployment`)return this.deployment.findRelationship(e);let n=this._relations.get(B(e))??null;return n||t===`model`?n:this.deployment.findRelationship(e)}views(){return this._views.values()}view(e){let t=B(e);return b(this._views.get(t),`View ${t} not found`)}findView(e){return this._views.get(e)??null}findManualLayout(e){return`manualLayouts`in this.$data?this.$data.manualLayouts?.[e]??null:null}viewFolder(e){return b(this._viewFolders.get(e),`View folder ${e} not found`)}get rootViewFolder(){return this._rootViewFolder}get hasViewFolders(){return this._viewFolders.size>1}viewFolderItems(e){return E(this._viewFolders.has(e),`View folder ${e} not found`),this._viewFolderItems.get(e)}parent(e){let t=B(e);return this._parents.get(t)||null}children(e){let t=B(e);return this._children.get(t)}*siblings(e){let t=B(e),n=this._parents.get(t),r=n?this._children.get(n.id).values():this.roots();for(let e of r)e.id!==t&&(yield e)}*ancestors(e){let t=B(e),n;for(;n=this._parents.get(t);)yield n,t=n.id}*descendants(e){for(let t of this.children(e))yield t,yield*this.descendants(t.id)}*incoming(e,t=`all`){let n=B(e);for(let e of this._incoming.get(n))switch(!0){case t===`all`:case t===`direct`&&e.target.id===n:case t===`to-descendants`&&e.target.id!==n:yield e;break}}*outgoing(e,t=`all`){let n=B(e);for(let e of this._outgoing.get(n))switch(!0){case t===`all`:case t===`direct`&&e.source.id===n:case t===`from-descendants`&&e.source.id!==n:yield e;break}}get tags(){return A(this,`tags`,()=>d([...this._allTags.keys()],_e))}get tagsSortedByUsage(){return A(this,`tagsSortedByUsage`,()=>l([...this._allTags.entries()],c(([e,t])=>({tag:e,count:t.size,tagged:t})),d((e,t)=>_e(e.tag,t.tag)),te([ne(`count`),`desc`])))}findByTag(e,t){return me(this._allTags.get(e),e=>t===`elements`?e instanceof F:t===`views`?e instanceof K:t===`relationships`?e instanceof U:!0)}*elementsOfKind(e){for(let t of this._elements.values())t.kind===e&&(yield t)}*elementsWhere(e){let t=ae(e);for(let e of this._elements.values())t(e)&&(yield e)}*relationshipsWhere(e){let t=ae(e);for(let e of this._relations.values())t(e)&&(yield e)}addElement(e){if(this._elements.has(e.id))throw Error(`Element ${e.id} already exists`);let t=new F(this,Object.freeze(e));this._elements.set(t.id,t);let n=S(t.id);return n?(E(this._elements.has(n),`Parent ${n} of ${t.id} not found`),this._parents.set(t.id,this.element(n)),this._children.get(n).add(t)):this._rootElements.add(t),t}addImportedElement(e,t){E(!le(t.id),`Imported element already has global FQN`);let n=oe(e,t.id);if(this._elements.has(n))throw Error(`Element ${n} already exists`);let r=new F(this,Object.freeze({...t,id:n}));this._elements.set(r.id,r);let i=S(r.id);for(;i;){if(i.includes(`.`)&&this._elements.has(i))return this._parents.set(r.id,this.element(i)),this._children.get(i).add(r),r;i=S(i)}return this._rootElements.add(r),r}addRelation(e){if(this._relations.has(e.id))throw Error(`Relation ${e.id} already exists`);let t=new U(this,Object.freeze(e)),{source:n,target:r}=t;this._relations.set(t.id,t),this._incoming.get(r.id).add(t),this._outgoing.get(n.id).add(t);let i=j(n.id,r.id);if(i)for(let e of[i,...x(i)])this._internal.get(e).add(t);for(let e of x(n.id)){if(e===i)break;this._outgoing.get(e).add(t)}for(let e of x(r.id)){if(e===i)break;this._incoming.get(e).add(t)}return t}};(function(e){e.EMPTY=J.create({_stage:`computed`,projectId:`default`,project:{id:`default`},specification:{elements:{},relationships:{},deployments:{},tags:{}},globals:{predicates:{},dynamicPredicates:{},styles:{}},deployments:{elements:{},relations:{}},elements:{},relations:{},views:{},imports:{}})})(J||={});let Pe;(function(e){e.isInside=e=>t=>w(e,t.source.id)&&w(e,t.target.id);let t=e.isDirectedBetween=(e,t)=>n=>(n.source.id===e||w(e,n.source.id))&&(n.target.id===t||w(t,n.target.id));e.isAnyBetween=(e,n)=>{let r=t(e,n),i=t(n,e);return e=>r(e)||i(e)};let n=e.isIncoming=e=>t=>(t.target.id===e||w(e,t.target.id))&&!w(e,t.source.id),r=e.isOutgoing=e=>t=>(t.source.id===e||w(e,t.source.id))&&!w(e,t.target.id);e.isAnyInOut=e=>{let t=n(e),i=r(e);return e=>t(e)||i(e)}})(Pe||={});const Y=Symbol.for(`nodejs.util.inspect.custom`);var Fe=class e{id;constructor(e,t,n){this.source=e,this.target=t,this.relations=n,this.id=Ce(`deployment:${e.id}:${t.id}`)}get expression(){return`${this.source.id} -> ${this.target.id}`}_boundary;get boundary(){return this._boundary??=this.source.commonAncestor(this.target),this._boundary}nonEmpty(){return this.relations.nonEmpty}[Y](t,n,r){let i=this.toString();return Object.defineProperty(i,`constructor`,{value:e,enumerable:!1}),i}toString(){let e=[...this.relations.model].map(e=>` `+e.expression);e.length?e.unshift(` model:`):e.unshift(` model: []`);let t=[...this.relations.deployment].map(e=>` `+e.expression);return t.length?t.unshift(` deployment:`):t.unshift(` deployment: []`),[this.expression,...e,...t].join(`
|
|
3
|
+
`)}hasDirectDeploymentRelation(){for(let e of this.relations.deployment)if(e.source.id===this.source.id||e.target.id===this.target.id)return!0;return!1}*values(){yield*this.relations.model,yield*this.relations.deployment}mergeWith(t){return Array.isArray(t)?t.reduce((e,t)=>e.mergeWith(t),this):(E(this.source.id===t.source.id,`Cannot merge connections with different sources`),E(this.target.id===t.target.id,`Cannot merge connections with different targets`),new e(this.source,this.target,this.relations.union(t.relations)))}difference(t){return new e(this.source,this.target,this.relations.difference(t.relations))}intersect(t){return new e(this.source,this.target,this.relations.intersect(t.relations))}equals(t){return E(t instanceof e,`Other should ne DeploymentConnectionModel`),this.id===t.id&&this.source.id===t.source.id&&this.target.id===t.target.id&&M(this.relations.model,t.relations.model)&&M(this.relations.deployment,t.relations.deployment)}update(t){return t&&={model:this.relations.model,deployment:this.relations.deployment,...t},new e(this.source,this.target,t?new z(t.model??new Set,t.deployment??new Set):this.relations)}};function X(e,t){if(!t){let t=e;return e=>X(e,t)}let n=e.source===t.source,r=e.target===t.target;if(n&&r)return!1;let i=w(t.source.id,e.source.id),a=w(t.target.id,e.target.id);return i&&a||n&&a||r&&i}function Ie(e,t){let n=t;for(let t of e)X(t,n)&&(n=t);return n===t?null:n}function Le(e){let t=[],n=e.slice(),r;for(;r=n.shift();){let e;for(;e=Ie(n,r);){let r=n.indexOf(e);t.push(n.splice(r,1)[0])}t.push(r)}return t}function Re(e){return e.boundary?.id?`.${e.boundary.id}`:``}function ze(e,t){if(!e||Se(e)){let t=e??`asc`;return e=>Be(e,t)}return Be(e,t??`asc`)}function Be(e,t){return l(e,c(e=>({id:Re(e),conn:e})),ge(t),c(e=>e.conn))}function Ve(e,t){return e.filter(e=>X(t,e))}function He(e,t){return e.filter(X(t))}function Ue(e){let t=new Map;for(let n of e){let e=t.get(n.id);e?t.set(n.id,n.mergeWith(e)):t.set(n.id,n)}return[...t.values()]}function We(e,t){let n=new Map([...t].map(e=>[e.id,e]));return[...e].reduce((e,t)=>{let r=n.get(t.id);if(!r)return e.push(t),e;let i=t.difference(r);return i.nonEmpty()&&e.push(i),e},[])}function Z(e,t){return t?e.source===t.source&&e.target===t.target:t=>e.source===t.source&&e.target===t.target}function Ge(e,t){return t?e.source===t.source:t=>e.source===t.source}function Ke(e,t){return t?e.target===t.target:t=>e.target===t.target}function qe(e,t){if(!t){let t=e;return e=>qe(e,t)}let n=e;return T(n.source,t)&&!T(n.target,t)}function Je(e,t){if(!t){let t=e;return e=>Je(e,t)}let n=e;return T(n.target,t)&&!T(n.source,t)}function Ye(e,t){if(!t){let t=e;return e=>Ye(e,t)}let n=e;return T(n.source,t)!==T(n.target,t)}var Q=class e{id;constructor(e,t,n=new Set){this.source=e,this.target=t,this.relations=n,this.id=Ce(`model:${e.id}:${t.id}`)}_boundary;get boundary(){return this._boundary??=this.source.commonAncestor(this.target)}get expression(){return`${this.source.id} -> ${this.target.id}`}get isDirect(){return this.nonEmpty()&&!this.isImplicit}get isImplicit(){return this.nonEmpty()&&we(this.relations,a(Z(this)))}get directRelations(){return new Set(me(this.relations,Z(this)))}nonEmpty(){return this.relations.size>0}mergeWith(t){return E(this.source.id===t.source.id,`Cannot merge connections with different sources`),E(this.target.id===t.target.id,`Cannot merge connections with different targets`),new e(this.source,this.target,N(this.relations,t.relations))}difference(t){return new e(this.source,this.target,O(this.relations,t.relations))}intersect(t){return E(t instanceof e,`Cannot intersect connection with different type`),new e(this.source,this.target,k(this.relations,t.relations))}equals(t){E(t instanceof e,`Cannot merge connection with different type`);let n=t;return this.id===n.id&&this.source.id===n.source.id&&this.target.id===n.target.id&&M(this.relations,n.relations)}update(t){return new e(this.source,this.target,t)}[Y](t,n,r){let i=this.toString();return Object.defineProperty(i,`constructor`,{value:e,enumerable:!1}),i}toString(){return[this.expression,this.relations.size?` relations:`:` relations: [ ]`,...[...this.relations].map(e=>` `+e.expression)].join(`
|
|
4
|
+
`)}reversed(){return new e(this.target,this.source)}},Xe=e({findConnection:()=>$,findConnectionsBetween:()=>Ze,findConnectionsWithin:()=>Qe});function $(e,t,n=`directed`){if(e===t||ve(e,t))return[];let r=e.allOutgoing.intersect(t.allIncoming),i=r.nonEmpty?[new Fe(e,t,r)]:[];return n===`directed`?i:[...i,...$(t,e,`directed`)]}function Ze(e,t,n=`both`){if(e.allIncoming.isEmpty&&e.allOutgoing.isEmpty)return[];let r=[],i=[];for(let a of t)if(e!==a)for(let t of $(e,a,n))t.source===e?r.push(t):i.push(t);return[...r,...i]}function Qe(e){return[...e].reduce((e,t,n,r)=>(n===r.length-1||e.push(...Ze(t,r.slice(n+1),`both`)),e),[])}var $e=e({findConnection:()=>et,findConnectionsBetween:()=>tt,findConnectionsWithin:()=>nt});function et(e,t,n=`directed`){if(e===t||ve(e,t))return[];let r=k(e.allOutgoing,t.allIncoming),i=r.size>0?new Q(e,t,r):null;if(n===`directed`)return i?[i]:[];let a=k(e.allIncoming,t.allOutgoing),o=a.size>0?new Q(t,e,a):null;return i&&o?[i,o]:i?[i]:o?[o]:[]}function tt(e,t,n=`both`){if(e.allIncoming.size===0&&e.allOutgoing.size===0)return[];let r=[],i=[];for(let a of t)if(e!==a)for(let t of et(e,a,n))t.source===e?r.push(t):i.push(t);return[...r,...i]}function nt(e){return[...e].reduce((e,t,n,r)=>(n===r.length-1||e.push(...tt(t,r.slice(n+1),`both`)),e),[])}function rt(e){return e instanceof I}function it(e){return e instanceof L}function at(e){return rt(e)||it(e)}function ot(e){return e instanceof ke}function st(e){return e instanceof R}function ct(e){return e instanceof U}function lt(e){return e instanceof F}function ut(e){return e instanceof K}function dt(e){return e instanceof G}function ft(e){return e instanceof W}export{Fe as A,Ae as B,Ye as C,Ue as D,qe as E,K as F,I as G,je as H,G as I,F as J,R as K,W as L,Pe as M,J as N,ze as O,q as P,U as R,Ke as S,X as T,H as U,Me as V,L as W,Ve as _,ft as a,Ge as b,ot as c,et as d,tt as f,We as g,Q as h,st as i,Y as j,Le as k,dt as l,Xe as m,at as n,lt as o,$e as p,z as q,rt as r,ut as s,it as t,ct as u,Ie as v,Je as w,Z as x,He as y,Ne as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));export{s as n,l as r,o as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime.mjs";import{t}from"./libs/defu.mjs";import{B as n,I as r,M as i,N as a,O as o,T as s,V as c,et as l,it as ee,k as u,rt as te,t as ne,x as re}from"./libs/remeda.mjs";import{Q as d,et as f,h as p,n as ie,t as ae}from"./utils.mjs";import{i as m,n as oe,t as se}from"./libs/mnemonist.mjs";import{a as ce,c as le,d as ue,f as de,h as fe,i as pe,l as me,m as he,n as ge,o as _e,p as ve,r as ye,s as be,t as xe,u as Se}from"./libs/@radix-ui/colors.mjs";import{n as h,t as Ce}from"./libs/@mantine/colors-generator.mjs";function we(e){return re(e,e=>e===void 0)}function Te(e){return e.summary??e.description}function Ee(e){return e.description??e.summary}function De(e,t){return e[g]===t}const g=`_stage`,Oe=`_type`,ke=`_layout`;var Ae=e({DeploymentFqn:()=>w,EdgeId:()=>j,Fqn:()=>x,GlobalFqn:()=>D,GroupElementKind:()=>S,MarkdownOrString:()=>v,NodeId:()=>A,NoneIcon:()=>b,ProjectId:()=>_,RelationId:()=>E,StepEdgeKind:()=>je,ViewId:()=>T,extractStep:()=>P,flattenMarkdownOrString:()=>y,isGlobalFqn:()=>O,isGroupElementKind:()=>C,isStepEdgeId:()=>N,splitGlobalFqn:()=>k,stepEdgeId:()=>M});function _(e){return e}function v(e){return typeof e==`string`?{txt:e}:e}function y(e){if(r(e))return null;let t=u(e)?e:e.txt??e.md;return o(t?.trim())?t:null}const b=`none`;function x(e,t){return t?t+`.`+e:e}const S=`@group`;function C(e){return e.kind===S}function w(e,t){return t?t+`.`+e:e}function T(e){return e}function E(e){return e}function D(e,t){return d(typeof e==`string`&&e!=``),`@`+e+`.`+t}function O(e){return e.startsWith(`@`)}function k(e){if(!e.startsWith(`@`))return[null,e];let t=e.indexOf(`.`);if(t<2)throw Error(`Invalid global FQN`);return[e.slice(1,t),e.slice(t+1)]}function A(e){return e}function j(e){return e}function M(e,t){let n=`step-${String(e).padStart(2,`0`)}`;return t?`${n}.${t}`:n}const je=`@step`;function N(e){return e.startsWith(`step-`)}function P(e){if(!N(e))throw Error(`Invalid step edge id: ${e}`);return parseFloat(e.slice(5))}let F;(function(e){function t(e){return`model`in e&&!(`project`in e)}e.isElementRef=t;function n(e){return`project`in e&&`model`in e}e.isImportRef=n;function r(e){if(u(e))throw Error(`Expected FqnRef, got: "${e}"`);if(n(e))return D(e.project,e.model);if(t(e))return e.model;throw Error(`Expected FqnRef.ModelRef or FqnRef.ImportRef`)}e.flatten=r;function i(e){return t(e)||n(e)}e.isModelRef=i;function a(e){return`deployment`in e&&`element`in e}e.isInsideInstanceRef=a;function o(e){return`deployment`in e&&!(`element`in e)}e.isDeploymentElementRef=o;function s(e){return o(e)||a(e)}e.isDeploymentRef=s})(F||={});let I;(function(e){function t(e){return`wildcard`in e&&e.wildcard===!0}e.isWildcard=t;function n(e){return`ref`in e&&F.isModelRef(e.ref)}e.isModelRef=n;function r(e){return`ref`in e&&F.isDeploymentRef(e.ref)}e.isDeploymentRef=r;function i(e){return`elementKind`in e&&`isEqual`in e}e.isElementKindExpr=i;function a(e){return`elementTag`in e&&`isEqual`in e}e.isElementTagExpr=a;function o(e){return`where`in e&&c(e.where.expr)}e.isWhere=o;function s(e){return`custom`in e&&(c(e.custom.expr)||o(e.custom.expr))}e.isCustom=s;function c(e){return t(e)||n(e)||r(e)||i(e)||a(e)}e.is=c;function l(e){return s(e)&&(e=e.custom.expr),o(e)&&(e=e.where.expr),e}e.unwrap=l})(I||={});let L;(function(e){function t(e){return`source`in e&&`target`in e}e.isDirect=t;function n(e){return`incoming`in e}e.isIncoming=n;function r(e){return`outgoing`in e}e.isOutgoing=r;function i(e){return`inout`in e}e.isInOut=i;function a(e){return`where`in e&&(t(e.where.expr)||n(e.where.expr)||r(e.where.expr)||i(e.where.expr))}e.isWhere=a;function o(e){return`customRelation`in e}e.isCustom=o;function s(e){return t(e)||n(e)||r(e)||i(e)}e.is=s;function c(e){return o(e)&&(e=e.customRelation.expr),a(e)&&(e=e.where.expr),e}e.unwrap=c})(L||={});let R;(function(e){function t(e){return`where`in e}e.isWhere=t;function n(e){return L.isWhere(e)}e.isRelationWhere=n;function r(e){return I.isWhere(e)}e.isFqnExprWhere=r;function i(e){return I.is(e)||I.isWhere(e)||I.isCustom(e)}e.isFqnExpr=i;function a(e){return L.is(e)||L.isWhere(e)||L.isCustom(e)}e.isRelation=a})(R||={});let z;(function(e){function t(e){return`wildcard`in e&&e.wildcard===!0}e.isWildcard=t;function n(e){return`ref`in e&&F.isModelRef(e.ref)}e.isModelRef=n;function r(e){return`elementKind`in e&&`isEqual`in e}e.isElementKindExpr=r;function i(e){return`elementTag`in e&&`isEqual`in e}e.isElementTagExpr=i;function a(e){return`where`in e&&s(e.where.expr)}e.isWhere=a;function o(e){return`custom`in e&&(s(e.custom.expr)||a(e.custom.expr))}e.isCustom=o;function s(e){return t(e)||n(e)||r(e)||i(e)}e.is=s;function c(e){return o(e)&&(e=e.custom.expr),a(e)&&(e=e.where.expr),e}e.unwrap=c})(z||={});let B;(function(e){function t(e){return`source`in e&&`target`in e}e.isDirect=t;function n(e){return`incoming`in e}e.isIncoming=n;function r(e){return`outgoing`in e}e.isOutgoing=r;function i(e){return`inout`in e}e.isInOut=i;function a(e){return`where`in e&&(t(e.where.expr)||n(e.where.expr)||r(e.where.expr)||i(e.where.expr))}e.isWhere=a;function o(e){return`customRelation`in e}e.isCustom=o;function s(e){return t(e)||n(e)||r(e)||i(e)}e.is=s;function c(e){return o(e)&&(e=e.customRelation.expr),a(e)&&(e=e.where.expr),e}e.unwrap=c})(B||={});let V;(function(e){function t(e){return`where`in e}e.isWhere=t;function n(e){return B.isWhere(e)}e.isRelationWhere=n;function r(e){return z.isWhere(e)}e.isFqnExprWhere=r;function i(e){return z.is(e)||z.isWhere(e)||z.isCustom(e)}e.isFqnExpr=i;function a(e){return B.is(e)||B.isWhere(e)||B.isCustom(e)}e.isRelationExpr=a})(V||={});function Me(e){return o(e.kind)&&!o(e.element)}function Ne(e){return o(e.element)&&!o(e.kind)}const H={fill:`#3b82f6`,stroke:`#2563eb`,hiContrast:`#eff6ff`,loContrast:`#bfdbfe`},U={fill:`#0284c7`,stroke:`#0369a1`,hiContrast:`#f0f9ff`,loContrast:`#B6ECF7`},W={fill:`#64748b`,stroke:`#475569`,hiContrast:`#f8fafc`,loContrast:`#cbd5e1`},Pe={primary:H,blue:H,secondary:U,sky:U,muted:W,slate:W,gray:{fill:`#737373`,stroke:`#525252`,hiContrast:`#fafafa`,loContrast:`#d4d4d4`},red:{fill:`#AC4D39`,stroke:`#853A2D`,hiContrast:`#FBD3CB`,loContrast:`#f5b2a3`},green:{fill:`#428a4f`,stroke:`#2d5d39`,hiContrast:`#f8fafc`,loContrast:`#c2f0c2`},amber:{fill:`#A35829`,stroke:`#7E451D`,hiContrast:`#FFE0C2`,loContrast:`#f9b27c`},indigo:{fill:`#6366f1`,stroke:`#4f46e5`,hiContrast:`#eef2ff`,loContrast:`#c7d2fe`}},Fe={line:`#8D8D8D`,labelBg:`#18191B`,label:`#C9C9C9`},G={line:`#64748b`,labelBg:`#0f172a`,label:`#cbd5e1`},K={line:`#3b82f6`,labelBg:`#172554`,label:`#60a5fa`},q={line:`#0ea5e9`,labelBg:`#082f49`,label:`#38bdf8`},Ie={amber:{line:`#b45309`,labelBg:`#78350f`,label:`#FFE0C2`},blue:K,gray:Fe,green:{line:`#15803d`,labelBg:`#052e16`,label:`#22c55e`},indigo:{line:`#6366f1`,labelBg:`#1e1b4b`,label:`#818cf8`},muted:G,primary:K,red:{line:`#AC4D39`,labelBg:`#b91c1c`,label:`#f5b2a3`},secondary:q,sky:q,slate:G},Le={sizes:{xs:{width:180,height:100},sm:{width:240,height:135},md:{width:320,height:180},lg:{width:420,height:234},xl:{width:520,height:290}},spacing:{xs:8,sm:10,md:16,lg:24,xl:32},textSizes:{xs:13.33,sm:16,md:19.2,lg:23.04,xl:27.65},iconSizes:{xs:24,sm:36,md:60,lg:82,xl:90}},Re=[`xs`,`sm`,`md`,`lg`,`xl`],ze=[`left`,`right`,`top`,`bottom`],Be=[`solid`,`dashed`,`dotted`,`none`],Ve=[`rectangle`,`person`,`browser`,`mobile`,`cylinder`,`storage`,`queue`,`bucket`,`document`,`component`],J=[`amber`,`blue`,`gray`,`slate`,`green`,`indigo`,`muted`,`primary`,`red`,`secondary`,`sky`],He=[`tomato`,`grass`,`blue`,`ruby`,`orange`,`indigo`,`pink`,`teal`,`purple`,`amber`,`crimson`,`red`,`lime`,`yellow`,`violet`],Y={tomato:ve.tomato9,grass:pe.grass9,blue:ge.blue9,ruby:ue.ruby9,orange:be.orange9,indigo:ce.indigo9,pink:le.pink9,teal:de.teal9,purple:me.purple9,amber:xe.amber9,crimson:ye.crimson9,red:Se.red9,lime:_e.lime9,yellow:fe.yellow9,violet:he.violet9};function Ue(e){return e in Y}const We={colors:J.reduce((e,t)=>(e[t]={elements:Pe[t],relationships:Ie[t]},e),{}),...Le};function Ge(e){d(h.valid(e),`Invalid color: ${e}`);let t=Ce(e),n=t[6],r=Ke(n);return{elements:{fill:n,stroke:t[7],...r},relationships:{line:t[4],label:t[3],labelBg:t[9]}}}function Ke(e){let t=h(e),n=t.brighten(2),r=t.darken(2),i,a,o,s;do i=n,a=r,n=n.brighten(1),r=r.darken(1),o=h.contrastAPCA(t,n),s=h.contrastAPCA(t,r);while(Math.abs(o)<60&&Math.abs(s)<60&&(!c(n,i)||!c(r,a)));return Math.abs(o)>Math.abs(s)?{hiContrast:n.brighten(.4).hex(),loContrast:n.hex()}:{hiContrast:r.darken(.4).hex(),loContrast:r.hex()}}function qe(e,t){let n=t??6,r=h(e.fill),i=h(e.stroke),a=r.luminance()>.8,o=l(ne(h.scale(a?[r.darken(.02).desaturate(.05),r.darken(.1).desaturate(.1)]:[r.shade(.12,`lch`).desaturate(.05),r.shade(.35,`lch`).desaturate(.4)]).mode(`oklch`).correctLightness().colors(n,null),h.scale(a?[i.darken(.04).desaturate(.05),i.darken(.12).desaturate(.1)]:[i.shade(.15,`lch`).desaturate(.08),i.shade(.4,`lch`).desaturate(.4)]).mode(`oklch`).correctLightness().colors(n,null)),s(([t,n])=>({...e,fill:t.hex(),stroke:n.hex()})));return d(o.length===n,`Expected ${n} colors, got ${o.length}`),o}const Je={color:`primary`,size:`md`,opacity:15,shape:`rectangle`,group:{opacity:15,border:`dashed`},relationship:{color:`gray`,line:`dashed`,arrow:`normal`}},Ye=We,X={theme:Ye,defaults:Je};var Xe=class e{theme;defaults;static DEFAULT=new e(X);static from(n,i){if(!n&&!i)return this.DEFAULT;let{customCss:a,theme:o,defaults:s}={...n},l=t({theme:o},{defaults:{...s}},{theme:{colors:{...i}}},X);return r(a?.content)&&c(l,X)?this.DEFAULT:new e(l,a)}constructor(e,t){this.config=e,this.customCss=t,this.theme=e.theme,this.defaults=e.defaults}get elementColors(){return this.theme.colors[this.defaults.color].elements}get relationshipColors(){return this.theme.colors[this.defaults.relationship.color].relationships}get groupColors(){let e=this.defaults.group?.color;if(!e)return this.elementColors;if(!this.isThemeColor(e))throw Error(`Default group color not found in theme: ${e}`);return p(this,`defaultGroup`,()=>({...this.elementColors,...this.theme.colors[e].elements}))}isDefaultColor(e){return e===this.defaults.color}colors(e){return this.computeFrom(e??=this.defaults.color)}compoundColorsCache=new oe.default(e=>new se.default(t=>qe(e,t)));colorsForCompounds(e,t){return this.compoundColorsCache.get(e).get(t??6)}fontSize(e){return e??=this.defaults.text??this.defaults.size,this.theme.textSizes[e]}padding(e){return e??=this.defaults.padding??this.defaults.size,this.theme.spacing[e]}iconSize(e){return e??=this.defaults.size,this.theme.iconSizes[e]}isThemeColor(e){return e in this.theme.colors}nodeSizes(e){let t=Ze(e,this.defaults.size);return{sizes:t,values:{sizes:this.theme.sizes[t.size],padding:this.padding(t.padding),textSize:this.fontSize(t.textSize),iconSize:this.iconSize(t.iconSize)}}}computeFrom(e){if(this.isThemeColor(e))return this.theme.colors[e];if(!h.valid(e))throw Error(`Invalid color value: "${e}" (not a theme color and not a valid CSS color)`);return Ge(e)}equals(e){return e===this?!0:this.constructor===e.constructor?c(this.config,e.config)&&c(this.customCss??null,e.customCss??null):!1}tagColor(e){return this.isThemeColor(e)?this.theme.colors[e].elements:Ue(e)?this.computeFrom(Y[e]).elements:this.computeFrom(e).elements}};function Ze({size:e,padding:t,textSize:n,iconSize:r,...i},a=X.defaults.size){return e??=a,n??=e,t??=e,r??=e,{...i,size:e,padding:t,textSize:n,iconSize:r}}function Qe(e){let t=typeof e==`string`?e:e.color;return t.startsWith(`#`)||t.startsWith(`rgb`)}function $e(e){return`tag`in e}function et(e){return`kind`in e}function tt(e){return`participant`in e}function nt(e){return`not`in e}function rt(e){return`and`in e}function Z(e){return`or`in e}function Q(e){switch(!0){case tt(e):{let t=e.participant;return it(t,Q(e.operator))}case $e(e):{if(u(e.tag)||`eq`in e.tag){let t=u(e.tag)?e.tag:e.tag.eq;return e=>Array.isArray(e.tags)&&e.tags.includes(t)}let t=e.tag.neq;return e=>!Array.isArray(e.tags)||!e.tags.includes(t)}case et(e):{if(u(e.kind)||`eq`in e.kind){let t=u(e.kind)?e.kind:e.kind.eq;return e=>e.kind===t}let t=e.kind.neq;return e=>i(e.kind)||e.kind!==t}case nt(e):return a(Q(e.not));case rt(e):return ee(e.and.map(Q));case Z(e):return te(e.or.map(Q));default:f(e)}}function it(e,t){return n=>{if(!n.source||!n.target)return!1;switch(e){case`source`:return t(n.source);case`target`:return t(n.target)}}}function at(e){return`include`in e||`exclude`in e}function ot(e){return`targets`in e&&`style`in e}function st(e){return e._stage===`computed`}function ct(e){return e._stage===`layouted`}function $(e){return e._type===`element`}function lt(e){return $(e)&&o(e.viewOf)}function ut(e){return $(e)&&o(e.extends)}function dt(e){return e._type===`deployment`}function ft(e){return e._type===`dynamic`}function pt(e){return`styleId`in e}function mt(e){return`predicateId`in e}function ht(e){return e===`TB`||e===`BT`||e===`LR`||e===`RL`}function gt(e){return`direction`in e}function _t(e){return N(e)&&e.includes(`.`)?e.slice(0,e.indexOf(`.`)+1):null}function vt(e){return!!e&&!(`__series`in e||`__parallel`in e)}function yt(e){return!!e&&`__parallel`in e&&n(e.__parallel)}function bt(e){return!!e&&`__series`in e&&n(e.__series)}function xt(e){return`title`in e&&`groupRules`in e&&Array.isArray(e.groupRules)}function St(e){return`rank`in e&&Array.isArray(e.targets)}const Ct=Symbol.for(`text`),wt=Symbol.for(`html`);var Tt=class e{static mdcache=new m.default(500);static txtcache=new m.default(500);static getOrCreateFromText(t){if(t=t.trimEnd(),t===``)return e.EMPTY;let n=e.txtcache.get(t);return n||(n=new e({txt:t}),e.txtcache.set(t,n),n)}static getOrCreateFromMarkdown(t){if(t=t.trimEnd(),t===``)return e.EMPTY;let n=e.mdcache.get(t);return n||(n=new e({md:t}),e.mdcache.set(t,n),n)}static memoize(t,n,r){return p(t,n,()=>e.from(r))}static from(t){return t==null||t===e.EMPTY?e.EMPTY:t instanceof e?t:typeof t==`string`?this.getOrCreateFromText(t):`isEmpty`in t&&t.isEmpty?e.EMPTY:`md`in t?this.getOrCreateFromMarkdown(t.md):this.getOrCreateFromText(t.txt)}static EMPTY=new class extends e{isEmpty=!0;nonEmpty=!1;isMarkdown=!1;$source=null;constructor(){super({txt:``})}get text(){return null}get md(){return null}get html(){return null}};$source;isEmpty;nonEmpty;isMarkdown;constructor(e){this.isMarkdown=!1,typeof e==`string`?(this.$source={txt:e},this.isEmpty=e.trim()===``):(this.$source=e,this.isEmpty=!0,`md`in e?(this.isEmpty=e.md===``,this.isMarkdown=!0):this.isEmpty=e.txt===``),this.nonEmpty=!this.isEmpty}get text(){if(this.isEmpty||this.$source===null)return``;let e=this.$source;return`txt`in e?e.txt:p(this,Ct,()=>ae(e.md))}get md(){if(this.isEmpty||this.$source===null)return``;let e=this.$source;if(`md`in e)return e.md;if(`txt`in e)return e.txt;f(e)}get html(){if(this.isEmpty||this.$source===null)return``;let e=this.$source;return`txt`in e?e.txt:p(this,wt,()=>ie(e.md))}equals(t){return this===t?!0:t instanceof e?this.isEmpty&&t.isEmpty?!0:this.isEmpty!==t.isEmpty||this.isMarkdown!==t.isMarkdown?!1:this.isMarkdown?this.$source?.md===t.$source?.md:this.$source?.txt===t.$source?.txt:!1}};export{S as $,Xe as A,Ne as B,nt as C,Q as D,$e as E,He as F,R as G,V as H,Ve as I,F as J,I as K,ze as L,Je as M,Ge as N,Qe as O,Be as P,D as Q,Re as R,et as S,tt as T,z as U,Me as V,B as W,j as X,w as Y,x as Z,ut as _,Oe as _t,vt as a,je as at,ot as b,Te as bt,ht as c,y as ct,pt as d,N as dt,v as et,st as f,Ae as ft,$ as g,g as gt,ft as h,ke as ht,_t as i,E as it,Ye as j,Ze as k,gt as l,O as lt,ct as m,M as mt,xt as n,b as nt,yt as o,T as ot,dt as p,k as pt,L as q,St as r,_ as rt,bt as s,P as st,Tt as t,A as tt,mt as u,C as ut,lt as v,De as vt,Z as w,rt as x,we as xt,at as y,Ee as yt,J as z};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime.mjs";import{t}from"./libs/defu.mjs";import{F as n,P as r,Q as i,R as a,T as o,a as s,et as c,f as l,k as u,l as d,t as f}from"./libs/remeda.mjs";import{s as p}from"./libs/mnemonist.mjs";import{t as m}from"./libs/natural-compare-lite.mjs";import{t as h}from"./libs/ohash.mjs";import{n as g}from"./libs/hast-util-sanitize.mjs";import{t as _}from"./libs/rehype-sanitize.mjs";import{t as v}from"./libs/rehype-stringify.mjs";import{l as y,t as b}from"./libs/mdast-util-from-markdown.mjs";import{t as ee}from"./libs/remark-gfm.mjs";import{t as te}from"./libs/remark-github-blockquote-alert.mjs";import{t as ne}from"./libs/remark-parse.mjs";import{t as re}from"./libs/remark-rehype.mjs";import{t as ie}from"./libs/unified.mjs";function x(e,t){if(e===void 0||e==null){let n=typeof t==`function`?t():t;throw Error(n??`Expected defined value, but received ${e}`)}return e}function S(e,t){if(!e)throw Error(t??`Invariant failed`)}function C(e){throw Error(`NonExhaustive value: ${e}`)}function w(e,t,n){return e.length===0||t.length===0?[]:(n??=Object.is,c(f(e,t),s(([e,t])=>n(e,t)),o(([e,t])=>e)))}var T=e(m(),1);function E(e,t){return e===t?0:u(e)?u(t)?(0,T.default)(e,t):1:u(t)?-1:0}function D(e){return d(e,E)}function O(...e){return e.length===0?D:D(e[0])}function k(e=`.`,t=!1){return(n,r)=>{if(n===r)return 0;if(!n)return-1;if(!r)return 1;let i=n.split(e),a=r.split(e),o=Math.min(i.length,a.length);for(let e=0;e<o;e++){let t=i[e],n=a[e],r=(0,T.default)(t,n);if(r!==0)return r}let s=i.length-a.length;return t?-1*s:s}}function A(e){return e!=null&&typeof e==`string`}function j(e){return!!e&&Array.isArray(e)&&e.length>0}function M(e,t){return e[t]!=null}function N(...e){return(t=>e.some(e=>e(t)))}function P(e){let t=e.lastIndexOf(`.`);return t>0?e.slice(0,t):null}function F(e){let t=e.lastIndexOf(`.`);return t>0?e.slice(t+1):e}const I=e=>A(e)?e:e.id;function L(e,t){let n=I(e);return t?I(t).startsWith(n+`.`):e=>{let t=I(e);return n.startsWith(t+`.`)}}function R(e,t){if(!t)return t=>R(e,t);let n=I(e),r=I(t);return n===r||r.startsWith(n+`.`)||n.startsWith(r+`.`)}function z(e,t){return t?L(t,e):t=>L(e,t)}function B(e){return(A(e)?e:e.id).split(`.`).length}function V(e,t){let n=A(e)?e:e.id,r=A(t)?t:t.id;if(n===r)return 0;let i=B(n),a=B(r);if(R(n,r))return Math.abs(i-a);let o=H(n,r),s=o?B(o):0;return i+a-(2*s+1)}function H(e,t){let n=e.split(`.`);if(n.length<2)return null;let r=t.split(`.`);if(r.length<2)return null;let i=[];for(let e=0;e<Math.min(n.length,r.length)-1&&n[e]===r[e];e++)i.push(n[e]);return i.length===0?null:i.join(`.`)}function U(e){let t=e.split(`.`);if(t.pop(),!i(t,2))return t;for(let e=1;e<t.length;e++)t[e]=t[e-1]+`.`+t[e];return t.reverse()}function W(e,t){let n=e.split(`.`).length,r=t.split(`.`).length;switch(!0){case n>r:return 1;case n<r:return-1;default:return 0}}function G(e,t){return W(e.id,t.id)}function K(e){return e.map(e=>({item:e,fqn:e.id.split(`.`)})).sort((e,t)=>e.fqn.length-t.fqn.length).map(({item:e})=>e)}function q(e,t){let n=t;for(let t of e)t!==n&&L(t,n)&&(n=t);return n===t?null:n}function J(e){let t=[],n=[...e],r;for(;r=n.shift();){let e;for(;e=q(n,r);)t.push(...n.splice(n.indexOf(e),1));t.push(r)}return t}function Y(e,t){if(!e||A(e)){let t=e??`asc`;return e=>Y(e,t)}let n=t===`desc`?-1:1;return e.map(e=>({item:e,fqn:e.id.split(`.`)})).sort((e,t)=>{if(e.fqn.length!==t.fqn.length)return(e.fqn.length-t.fqn.length)*n;for(let n=0;n<e.fqn.length;n++){let r=E(e.fqn[n],t.fqn[n]);if(r!==0)return r}return 0}).map(({item:e})=>e)}function ae(e,t,n){let r=e.get(t);return r||(r=n(t),e.set(t,r)),r}function oe(e){return typeof e==`object`&&!!e&&Symbol.iterator in e}function se(e,t){let r=t??e;S(n(r));function*i(e){for(let t of e)r(t)&&(yield t)}return t?i(e):i}function ce(e,t){let r=t??e;S(n(r));function i(e){for(let t of e)if(r(t))return t}return t?i(e):i}function le(e,t){let n=t??e;S(typeof n==`number`&&n>=0,`Count must be a non-negative number`);function*r(e){let t=0;for(let r of e){if(t>=n)break;yield r,t++}}return t===void 0?e=>r(e):r(e)}function ue(e){return e?X(e):X}function*X(e){for(let t of e)yield*t}function de(e,t){let r=t??e;S(n(r));function*i(e){for(let t of e)yield*r(t)}return t?i(e):i}function fe(e){return e?Z(e):Z}function Z(e){let{value:t}=e[Symbol.iterator]().next();return t}function pe(e,t){let r=t??e;S(n(r));function*i(e){for(let t of e)yield r(t)}return t?i(e):i}function me(e,t,r){let i=a(r)?t:e,o=r??t;S(n(i));function s(e){let t=o;for(let n of e)t=i(t,n);return t}return a(r)?s(e):s}function he(e,t){let r=t??e;S(n(r));function i(e){for(let t of e)if(r(t))return!0;return!1}return t?i(e):i}function ge(e){return e?Array.from(e):e=>Array.from(e)}function _e(e){return e?new Set(e):e=>new Set(e)}function ve(e){return e?Q(e):Q}function*Q(e){let t=new Set;for(let n of e)t.has(n)||(t.add(n),yield n)}function ye(e,t,n){let r=typeof t==`symbol`?t:Symbol.for(t);return e.hasOwnProperty(r)||Object.defineProperty(e,r,{enumerable:!1,writable:!1,value:n()}),e[r]}function be(...e){let t=100;return e.length===2?t=l(e[0],e[1]):e.length===1&&(t=e[0]),new Promise(e=>{setTimeout(()=>{e(`LIKEC4_DELAY`)},t??100)})}function xe(){return Promise.resolve().then(()=>void 0)}function Se(e){Promise.resolve().then(e)}const Ce=(e,t)=>{let n=H(e.source.id,e.target.id),r=H(t.source.id,t.target.id);if(n&&!r)return 1;if(!n&&r)return-1;let i=n&&r?W(n,r):0;if(i!==0)return i;let a=W(e.source.id,t.source.id);return a===0?W(e.target.id,t.target.id):a};function we(...e){let t=new Set;for(let n of e)for(let e of n)t.add(e);return t}function Te(e,...t){let n=new Set;if(e.size===0)return n;let r=i(t,2)?(0,p.intersection)(...t):t[0];if(r.size===0)return n;for(let t of e)r.has(t)&&n.add(t);return n}function Ee(e,t){if(e.size===0)return new Set;if(t.size===0)return new Set(e);let n=new Set;for(let r of e)t.has(r)||n.add(r);return n}function De(e,t){return e.size===t.size&&[...e].every(e=>t.has(e))}function $(e,t){return(0,p.symmetricDifference)(e,t)}function Oe(e,t){if(e.size===0||t.size===0)return!1;t.size<e.size&&([e,t]=[t,e]);for(let n of e)if(t.has(n))return!0;return!1}function ke(e){return S(typeof e==`object`&&r(e),`objectHash: value must be an object`),h(e)}function Ae(e){let t=5381,n=e.length;S(n>0,`stringHash: empty string`);for(let r=0;r<n;r++)t=t*33^e.charCodeAt(r);return(t>>>0).toString(36)}function je(){return ie().use(ne).use(ee).use(te).use(re,{allowDangerousHtml:!0}).use(_,t({attributes:{"*":[`className`],svg:[`width`,`height`,`viewBox`,`fill`,`ariaHidden`],path:[`d`,`fill`,`stroke`,`strokeWidth`,`strokeLinecap`,`strokeLinejoin`]},tagNames:[`svg`,`g`,`path`,`div`]},g)).use(v,{allowDangerousHtml:!0})}function Me(e){return(``+je().processSync(e)).trim()}function Ne(e){return y(b(e),{includeHtml:!1,includeImageAlt:!1})}export{x as $,U as A,P as B,de as C,se as D,ce as E,B as F,N as G,Y as H,L as I,E as J,j as K,z as L,G as M,W as N,oe as O,V as P,S as Q,R,fe as S,le as T,J as U,K as V,M as W,O as X,k as Y,w as Z,ge as _,Ee as a,me as b,Te as c,Ce as d,C as et,be as f,ve as g,ye as h,ke as i,H as j,ae as k,$ as l,xe as m,Me as n,De as o,Se as p,A as q,Ae as r,Oe as s,Ne as t,we as u,_e as v,ue as w,pe as x,he as y,F as z};
|
package/dist/builder/index.d.mts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import "../_chunks/
|
|
2
|
-
import "../_chunks/
|
|
1
|
+
import "../_chunks/index.mjs";
|
|
2
|
+
import "../_chunks/index2.mjs";
|
|
3
|
+
import "../_chunks/index3.mjs";
|
|
4
|
+
import "../_chunks/libs/mnemonist.mjs";
|
|
5
|
+
import "../_chunks/mnemonist.mjs";
|
|
3
6
|
import "../_chunks/LikeC4Model.mjs";
|
|
4
7
|
import { $ as DeloymentModelHelpers, A as AddDeploymentViewHelper, B as ViewPredicate, C as AddViewHelper, D as ElementViewRulesBuilder, E as ElementViewBuilder, F as $exclude, G as NestedRelationshipHelper, H as ModelBuilder, I as $include, J as AddElement, K as RelationshipHelper, L as $rules, M as DeploymentRulesBuilderOp, N as DeploymentViewBuilder, O as TypedAddViewOfHelper, P as $autoLayout, Q as DeloymentModelBuildFunction, R as $style, S as $expr, T as AddViewRules, U as ModelBuilderFunction, V as AddElementHelpers, W as ModelHelpers, X as AddDeploymentNodeHelpers, Y as AddDeployedInstance, Z as AddDeploymentRelation, _ as ViewsBuilder, a as Invalid, b as mkViewBuilder, c as NewElementProps, d as Types, et as DeploymentModelBuilder, f as TypesNested, g as BuilderMethods, h as Builder, i as BuilderSpecification, j as AddDeploymentViewRules, k as $deploymentExpr, l as NewRelationProps, m as Warn, n as AnyTypesNested, nt as AddDeploymentNode, o as Metadata, p as ValidId, q as model, r as BuilderProjectSpecification, s as NewDeploymentNodeProps, t as AnyTypes, tt as deployment, u as NewViewProps, v as ViewsBuilderFunction, w as AddViewOfHelper, x as views, y as ViewsHelpers, z as LikeC4ViewBuilder } from "../_chunks/_types.mjs";
|
|
5
8
|
export { $autoLayout, $deploymentExpr, $exclude, $expr, $include, $rules, $style, AddDeployedInstance, AddDeploymentNode, AddDeploymentNodeHelpers, AddDeploymentRelation, AddDeploymentViewHelper, AddDeploymentViewRules, AddElement, AddElementHelpers, AddViewHelper, AddViewOfHelper, AddViewRules, AnyTypes, AnyTypesNested, Builder, BuilderMethods, BuilderProjectSpecification, BuilderSpecification, DeloymentModelBuildFunction, DeloymentModelHelpers, DeploymentModelBuilder, DeploymentRulesBuilderOp, DeploymentViewBuilder, ElementViewBuilder, ElementViewRulesBuilder, Invalid, LikeC4ViewBuilder, Metadata, ModelBuilder, ModelBuilderFunction, ModelHelpers, NestedRelationshipHelper, NewDeploymentNodeProps, NewElementProps, NewRelationProps, NewViewProps, RelationshipHelper, TypedAddViewOfHelper, Types, TypesNested, ValidId, ViewPredicate, ViewsBuilder, ViewsBuilderFunction, ViewsHelpers, Warn, deployment, mkViewBuilder, model, views };
|
package/dist/builder/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as defu}from"../_chunks/libs/defu.mjs";import{B as e$1,C as t$7,F as e$3,M as e$2,Q as t$3,T as t,U as t$1,W as t$4,X as t$2,Y as n,et as t$6,k as e,w as t$5}from"../_chunks/libs/remeda.mjs";import{B as isDeployedInstance,J as FqnRef,U as ModelFqnExpr,_t as _type,g as isElementView,gt as _stage,lt as isGlobalFqn,pt as splitGlobalFqn,xt as exact}from"../_chunks/RichText.mjs";import{B as parentFqn,Q as invariant,R as isSameHierarchy,z as nameFromFqn}from"../_chunks/to-text.mjs";import"../_chunks/libs/graphology-dag.mjs";import{t as import_default_map}from"../_chunks/libs/mnemonist.mjs";import"../_chunks/libs/natural-compare-lite.mjs";import"../_chunks/libs/extend.mjs";import"../_chunks/libs/@mantine/colors-generator.mjs";import{n as computeLikeC4Model,t as $expr}from"../_chunks/Builder.view-element.mjs";import"../_chunks/libs/graphology.mjs";import{t as assignTagColors}from"../_chunks/assignTagColors.mjs";function parseWhere(r){if(e(r)){let i=r;switch(!0){case i.startsWith(`tag is not #`):return{tag:{neq:i.replace(`tag is not #`,``)}};case i.startsWith(`tag is #`):return{tag:{eq:i.replace(`tag is #`,``)}};case i.startsWith(`kind is not `):return{kind:{neq:i.replace(`kind is not `,``)}};case i.startsWith(`kind is `):return{kind:{eq:i.replace(`kind is `,``)}};case i.startsWith(`source.`):return{operator:parseWhere(i.replace(`source.`,``)),participant:`source`};case i.startsWith(`target.`):return{operator:parseWhere(i.replace(`target.`,``)),participant:`target`};default:throw Error(`Unknown where operator: ${r}`)}}if(r.and)return{and:t(r.and,parseWhere)};if(r.or)return{or:t(r.or,parseWhere)};if(r.not)return{not:parseWhere(r.not)};throw Error(`Unknown where operator: ${r}`)}function $include(...r){return i=>{let a=i.$expr(r[0]);if(r.length===2){let i=r[1].where?parseWhere(r[1].where):void 0;i&&(a={where:{expr:a,condition:i}});let o=r[1].with;o&&(a=ModelFqnExpr.is(a)?{custom:{...o,expr:a}}:{customRelation:{...o,expr:a}})}return i.include(a),i}}function $exclude(...r){return i=>{let a=i.$expr(r[0]);if(r.length===2&&r[1].where){let i=parseWhere(r[1].where);a={where:{expr:a,condition:i}}}return i.exclude(a),i}}function $style(r,{notation:a,...o}){return s=>s.style({targets:(e$1(r)?r:[r]).map(r=>s.$expr(r)),...a?{notation:a}:{},style:{...o}})}function $autoLayout(r){return i=>i.autoLayout(r)}function $rules(...r){return i=>r.reduce((r,i)=>i(r),i)}function $deploymentExpr(r){if(!e(r))return r;let i=r=>r;if(r===`*`)return i({wildcard:!0});if(r.startsWith(`->`))return r.endsWith(`->`)?i({inout:$deploymentExpr(r.replace(/->/g,``).trim())}):i({incoming:$deploymentExpr(r.replace(`-> `,``))});if(r.endsWith(` ->`))return i({outgoing:$deploymentExpr(r.replace(` ->`,``))});if(r.includes(` <-> `)){let[a,o]=r.split(` <-> `);return i({source:$deploymentExpr(a),target:$deploymentExpr(o),isBidirectional:!0})}if(r.includes(` -> `)){let[a,o]=r.split(` -> `);return i({source:$deploymentExpr(a),target:$deploymentExpr(o)})}return r.endsWith(`._`)?i({ref:{deployment:r.replace(`._`,``)},selector:`expanded`}):r.endsWith(`.**`)?i({ref:{deployment:r.replace(`.**`,``)},selector:`descendants`}):r.endsWith(`.*`)?i({ref:{deployment:r.replace(`.*`,``)},selector:`children`}):i({ref:{deployment:r}})}function mkViewBuilder(r){let i={$expr:r[_type]===`deployment`?$deploymentExpr:$expr,autoLayout(a){return r.rules.push({direction:a}),i},exclude(a){return r.rules.push({exclude:[a]}),i},include(a){return r.rules.push({include:[a]}),i},style(a){return r.rules.push(a),i}};return i}function ensureObj(r){return e$1(r)?t$1(r,r=>({})):r}function validateSpec({tags:r,elements:i,deployments:a,relationships:o,...s}){let c={};r&&Object.assign(c,ensureObj(r));let l=ensureObj(i);for(let[r,i]of t$2(l))if(i.tags)for(let a of i.tags)invariant(a in c,`Invalid specification for element kind "${r}": tag "${a}" not found`);let u=ensureObj(a??{});for(let[r,i]of t$2(u))if(i.tags)for(let a of i.tags)invariant(a in c,`Invalid specification for deployment kind "${r}": tag "${a}" not found`);return{...s,tags:c,elements:l,deployments:u,relationships:ensureObj(o??{})}}function toMarkdownOrString(r){return e$2(r)?null:typeof r==`string`?{txt:r}:r}function builder(i,u=new Map,f=[],h=new Map,y={predicates:{},dynamicPredicates:{},styles:{}},b=new Map,x=[],S=new import_default_map.default(()=>new Map)){let C=validateSpec(i),w=()=>({elements:structuredClone(C.elements),deployments:structuredClone(C.deployments),relationships:structuredClone(C.relationships),tags:assignTagColors(structuredClone(C.tags)),...C.metadataKeys?{metadataKeys:C.metadataKeys}:{},customColors:{}}),T=r=>{if(!(!r||!t$3(r,1)))return t(r,r=>typeof r==`string`?{url:r}:r)},E=(r,i,a)=>{e$3(i)&&(a=i,i={}),i??={};let{links:s=[],title:c=null,description:l=null,tags:u=[],...d}=typeof i==`string`?{title:i}:{...i},f=T(s);return[exact({id:r,title:c,description:toMarkdownOrString(l),tags:u,links:f,_stage:`parsed`,...d}),a]},D=r=>{let[i,a]=splitGlobalFqn(r),o=(i?S.get(i):u).get(a);return invariant(o,`Element with id "${r}" not found`),o},O=r=>{if(typeof r==`string`){let[i,a]=splitGlobalFqn(r);return i?{project:i,model:a}:{model:a}}return`project`in r||`deployment`in r?r:O(r.model)},k={get Types(){throw Error(`Types are not available in runtime`)},clone:()=>{let r=new import_default_map.default(()=>new Map);for(let[i,a]of S)r.set(i,structuredClone(a));return builder(structuredClone(C),structuredClone(u),structuredClone(f),structuredClone(h),structuredClone(y),structuredClone(b),structuredClone(x),r)},__addElement:r=>{let[i,a]=splitGlobalFqn(r.id),o=parentFqn(a),s=i?S.get(i):u;if(o&&invariant(s.get(o),`Parent element with id "${o}" not found for element with id "${r.id}"`),s.has(a))throw Error(`Element with id "${r.id}" already exists`);return s.set(a,i?{...r,id:a}:r),k},__addRelation(r){let i=O(r.source),a=FqnRef.flatten(i),o=O(r.target),s=FqnRef.flatten(o),c=D(a),l=D(s);if(isGlobalFqn(a)&&isGlobalFqn(s))throw Error(`Cannot create relationship between global elements`);return!isGlobalFqn(a)&&!isGlobalFqn(s)&&invariant(!isSameHierarchy(c,l),`Cannot create relationship between elements in the same hierarchy`),f.push({id:`rel${f.length+1}`,...r,source:i,target:o}),k},__fqn(r){return invariant(r.trim()!==``,`Id must be non-empty`),r},__deploymentFqn(r){return invariant(r.trim()!==``,`Id must be non-empty`),r},__addSourcelessRelation(){throw Error(`Can be called only in nested model`)},__addView:r=>{if(h.has(r.id))throw Error(`View with id "${r.id}" already exists`);return isElementView(r)&&`viewOf`in r&&invariant(u.get(r.viewOf),`Invalid scoped view ${r.id}, wlement with id "${r.viewOf}" not found`),h.set(r.id,r),k},__addDeployment:r=>{if(b.has(r.id))throw Error(`Deployment with id "${r.id}" already exists`);let i=parentFqn(r.id);return i&&invariant(b.get(i),`Parent element with id "${i}" not found for node with id "${r.id}"`),isDeployedInstance(r)&&(invariant(i,`Instance ${r.id} of ${r.element} must be deployed under a parent node`),invariant(u.get(r.element),`Instance "${r.id}" references non-existing element "${r.element}"`)),b.set(r.id,r),k},__addDeploymentRelation:r=>(invariant(!isSameHierarchy(r.source.deployment,r.target.deployment),`Cannot create relationship between elements in the same hierarchy`),invariant(b.has(r.source.deployment),`Relation "${r.source.deployment} -> ${r.target.deployment}" references non-existing source`),invariant(b.has(r.target.deployment),`Relation "${r.source.deployment} -> ${r.target.deployment}" references non-existing target`),x.push({id:`deploy_rel${x.length+1}`,...r}),k),build:r=>({[_stage]:`parsed`,projectId:typeof r==`string`?r:r?.id??`from-builder`,project:{id:typeof r==`string`?r:`from-builder`,...typeof r==`object`&&r?r:{}},specification:w(),elements:t$4(structuredClone(Array.from(u.entries()))),relations:t$5(f,r=>[r.id,structuredClone(r)]),globals:structuredClone(y),deployments:{elements:t$4(structuredClone(Array.from(b.entries()))),relations:t$5(x,r=>[r.id,structuredClone(r)])},views:t$4(structuredClone(Array.from(h.entries()))),imports:t$6(Array.from(S.entries()),t(([r,i])=>[r,structuredClone([...i.values()])]),n(([r,i])=>i.length>0),t$4())}),toLikeC4Model:r=>computeLikeC4Model(k.build(r)),helpers:()=>({model:{model:(...r)=>i=>r.reduce((r,i)=>i(r),i),rel:(i,a,o)=>s=>{let{title:c=``,links:l=[],description:u=null,notes:d=null,...f}=defu(typeof o==`string`?{title:o}:{...o},{title:null,links:null}),p=T(l);return s.__addRelation(exact({source:{model:i},target:{model:a},title:c,...u&&{description:toMarkdownOrString(u)},...d&&{notes:toMarkdownOrString(d)},links:p,...f})),s},relTo:(i,a)=>o=>{let{title:s=``,links:c,description:l=null,notes:u=null,...d}=defu(typeof a==`string`?{title:a}:{...a},{title:null,links:null});return o.__addSourcelessRelation(exact({target:{model:i},title:s,...l&&{description:toMarkdownOrString(l)},...u&&{notes:toMarkdownOrString(u)},links:T(c),...d})),o},...t$7(C.elements,({style:r,...i},a)=>(o,s)=>{let c=(c=>{let{links:l,icon:u,color:d,shape:f,style:p,title:m,description:h,summary:g,..._}=typeof s==`string`?{title:s}:{...s},v=u??r?.icon,y=c.__fqn(o);return c.__addElement(exact({id:y,kind:a,title:m??nameFromFqn(y),...h&&{description:toMarkdownOrString(h)},...g&&{summary:toMarkdownOrString(g)},style:exact({icon:v,color:d??r?.color,shape:f??r?.shape,border:r?.border,opacity:r?.opacity,size:r?.size,padding:r?.padding,textSize:r?.textSize,...p}),links:T(l),...i,..._})),c});return c.with=(...r)=>i=>{c(i);let{__fqn:a,__addSourcelessRelation:s}=i;try{i.__fqn=r=>`${a(o)}.${r}`,i.__addSourcelessRelation=r=>i.__addRelation({...r,source:{model:a(o)}}),r.reduce((r,i)=>i(r),i)}finally{i.__fqn=a,i.__addSourcelessRelation=s}return i},c})},views:{views:(...r)=>i=>r.reduce((r,i)=>i(r),i),view:(r,i,a)=>{let[o,s]=E(r,i,a),c={...o,[_type]:`element`,rules:[]},l=r=>(r.__addView(c),s&&s(mkViewBuilder(c)),r);return l.with=(...r)=>i=>{l(i);let a=mkViewBuilder(c);for(let i of r)i(a);return i},l},viewOf:(r,i,a,o)=>{let[s,c]=E(r,a,o),l={...s,viewOf:i,[_type]:`element`,rules:[]},u=r=>(r.__addView(l),c&&c(mkViewBuilder(l)),r);return u.with=(...r)=>i=>{u(i);let a=mkViewBuilder(l);for(let i of r)i(a);return i},u},deploymentView:(r,i,a)=>{let[o,s]=E(r,i,a),c={...o,[_type]:`deployment`,rules:[]},l=r=>(r.__addView(c),s&&s(mkViewBuilder(c)),r);return l.with=(...r)=>i=>{l(i);let a=mkViewBuilder(c);for(let i of r)i(a);return i},l},$autoLayout,$exclude,$include,$rules,$style},deployment:{deployment:(...r)=>i=>r.reduce((r,i)=>i(r),i),instanceOf:(r,i,a)=>o=>{e$2(i)?(i=r,r=nameFromFqn(r)):typeof i==`string`?a??={}:(a=i,i=r,r=nameFromFqn(r));let{links:c,title:l,description:u,summary:d,icon:f,color:p,shape:m,style:h,...g}=typeof a==`string`?{title:a}:{...a},_=o.__deploymentFqn(r);return o.__addDeployment(exact({id:_,element:i,...l&&{title:l},...d&&{summary:toMarkdownOrString(d)},...u&&{description:toMarkdownOrString(u)},style:exact({icon:f,color:p,shape:m,...h}),links:T(c),...g})),o},rel:(r,i,a)=>o=>{let{title:s=null,links:c,description:l=null,notes:u=null,...d}=typeof a==`string`?{title:a}:{...a};return o.__addDeploymentRelation(exact({source:{deployment:r},target:{deployment:i},title:s,...l&&{description:toMarkdownOrString(l)},...u&&{notes:toMarkdownOrString(u)},links:T(c),...d})),o},...t$7(C.deployments??{},({style:r,...i},a)=>(o,s)=>{let c=(c=>{let{links:l,icon:u,style:d,title:f,description:p,summary:m,color:h,shape:g,..._}=typeof s==`string`?{title:s}:{...s},v=u??r?.icon,y=c.__deploymentFqn(o);return c.__addDeployment(exact({id:y,kind:a,title:f??nameFromFqn(y),...p&&{description:toMarkdownOrString(p)},...m&&{summary:toMarkdownOrString(m)},style:exact({icon:v,color:h??r?.color,shape:g??r?.shape,border:r?.border,opacity:r?.opacity,size:r?.size,padding:r?.padding,textSize:r?.textSize,...d}),links:T(l),...i,..._})),c});return c.with=(...r)=>i=>{c(i);let{__deploymentFqn:a}=i;try{i.__deploymentFqn=r=>`${a(o)}.${r}`,r.reduce((r,i)=>i(r),i)}finally{i.__deploymentFqn=a}return i},c})}}),with:(...r)=>{let i=k.clone();return r.reduce((r,i)=>i(r),i)},model:r=>{let i=k.clone(),a=i.helpers().model,o=a.model;return r({...a,_:o},o)(i)},deployment:r=>{let i=k.clone(),a=i.helpers().deployment,o=a.deployment;return r({...a,_:o},o)(i)},views:r=>{let i=k.clone(),a=i.helpers().views;return r({...a,_:a.views},a.views)(i)}};return k}const Builder={forSpecification(r){let i=builder(r);return{...i.helpers(),builder:i}},specification(r){return builder(r)}};export{Builder};
|
|
1
|
+
import{t as e}from"../_chunks/libs/defu.mjs";import{B as t,C as n,F as r,M as i,Q as a,T as o,U as s,W as c,X as l,Y as u,et as d,k as f,w as p}from"../_chunks/libs/remeda.mjs";import{B as m,J as h,U as g,_t as _,g as v,gt as y,lt as b,pt as x,xt as S}from"../_chunks/types.mjs";import"../_chunks/geometry.mjs";import{B as C,Q as w,R as T,z as E}from"../_chunks/utils.mjs";import"../_chunks/libs/graphology-dag.mjs";import{t as D}from"../_chunks/libs/mnemonist.mjs";import"../_chunks/libs/natural-compare-lite.mjs";import"../_chunks/libs/ohash.mjs";import"../_chunks/libs/@ungap/structured-clone.mjs";import"../_chunks/libs/hast-util-sanitize.mjs";import"../_chunks/libs/rehype-sanitize.mjs";import"../_chunks/libs/hast-util-to-html.mjs";import"../_chunks/libs/character-entities-legacy.mjs";import"../_chunks/libs/character-entities-html4.mjs";import"../_chunks/libs/ccount.mjs";import"../_chunks/libs/comma-separated-tokens.mjs";import"../_chunks/libs/rehype-stringify.mjs";import"../_chunks/libs/devlop.mjs";import"../_chunks/libs/mdast-util-from-markdown.mjs";import"../_chunks/libs/escape-string-regexp.mjs";import"../_chunks/libs/mdast-util-find-and-replace.mjs";import"../_chunks/libs/mdast-util-gfm.mjs";import"../_chunks/libs/markdown-table.mjs";import"../_chunks/libs/longest-streak.mjs";import"../_chunks/libs/character-entities.mjs";import"../_chunks/libs/decode-named-character-reference.mjs";import"../_chunks/libs/micromark-extension-gfm.mjs";import"../_chunks/libs/remark-gfm.mjs";import"../_chunks/libs/remark-github-blockquote-alert.mjs";import"../_chunks/libs/remark-parse.mjs";import"../_chunks/libs/mdast-util-to-hast.mjs";import"../_chunks/libs/remark-rehype.mjs";import"../_chunks/libs/bail.mjs";import"../_chunks/libs/extend.mjs";import"../_chunks/libs/is-plain-obj.mjs";import"../_chunks/libs/trough.mjs";import"../_chunks/libs/unified.mjs";import"../_chunks/libs/@radix-ui/colors.mjs";import"../_chunks/libs/@mantine/colors-generator.mjs";import"../_chunks/model.mjs";import"../_chunks/manual-layout.mjs";import{n as O,t as k}from"../_chunks/Builder.view-element.mjs";import"../_chunks/libs/graphology.mjs";import{t as A}from"../_chunks/assignTagColors.mjs";function j(e){if(f(e)){let t=e;switch(!0){case t.startsWith(`tag is not #`):return{tag:{neq:t.replace(`tag is not #`,``)}};case t.startsWith(`tag is #`):return{tag:{eq:t.replace(`tag is #`,``)}};case t.startsWith(`kind is not `):return{kind:{neq:t.replace(`kind is not `,``)}};case t.startsWith(`kind is `):return{kind:{eq:t.replace(`kind is `,``)}};case t.startsWith(`source.`):return{operator:j(t.replace(`source.`,``)),participant:`source`};case t.startsWith(`target.`):return{operator:j(t.replace(`target.`,``)),participant:`target`};default:throw Error(`Unknown where operator: ${e}`)}}if(e.and)return{and:o(e.and,j)};if(e.or)return{or:o(e.or,j)};if(e.not)return{not:j(e.not)};throw Error(`Unknown where operator: ${e}`)}function M(...e){return t=>{let n=t.$expr(e[0]);if(e.length===2){let t=e[1].where?j(e[1].where):void 0;t&&(n={where:{expr:n,condition:t}});let r=e[1].with;r&&(n=g.is(n)?{custom:{...r,expr:n}}:{customRelation:{...r,expr:n}})}return t.include(n),t}}function N(...e){return t=>{let n=t.$expr(e[0]);if(e.length===2&&e[1].where){let t=j(e[1].where);n={where:{expr:n,condition:t}}}return t.exclude(n),t}}function P(e,{notation:n,...r}){return i=>i.style({targets:(t(e)?e:[e]).map(e=>i.$expr(e)),...n?{notation:n}:{},style:{...r}})}function F(e){return t=>t.autoLayout(e)}function I(...e){return t=>e.reduce((e,t)=>t(e),t)}function L(e){if(!f(e))return e;let t=e=>e;if(e===`*`)return t({wildcard:!0});if(e.startsWith(`->`))return e.endsWith(`->`)?t({inout:L(e.replace(/->/g,``).trim())}):t({incoming:L(e.replace(`-> `,``))});if(e.endsWith(` ->`))return t({outgoing:L(e.replace(` ->`,``))});if(e.includes(` <-> `)){let[n,r]=e.split(` <-> `);return t({source:L(n),target:L(r),isBidirectional:!0})}if(e.includes(` -> `)){let[n,r]=e.split(` -> `);return t({source:L(n),target:L(r)})}return e.endsWith(`._`)?t({ref:{deployment:e.replace(`._`,``)},selector:`expanded`}):e.endsWith(`.**`)?t({ref:{deployment:e.replace(`.**`,``)},selector:`descendants`}):e.endsWith(`.*`)?t({ref:{deployment:e.replace(`.*`,``)},selector:`children`}):t({ref:{deployment:e}})}function R(e){let t={$expr:e[_]===`deployment`?L:k,autoLayout(n){return e.rules.push({direction:n}),t},exclude(n){return e.rules.push({exclude:[n]}),t},include(n){return e.rules.push({include:[n]}),t},style(n){return e.rules.push(n),t}};return t}function z(e){return t(e)?s(e,e=>({})):e}function B({tags:e,elements:t,deployments:n,relationships:r,...i}){let a={};e&&Object.assign(a,z(e));let o=z(t);for(let[e,t]of l(o))if(t.tags)for(let n of t.tags)w(n in a,`Invalid specification for element kind "${e}": tag "${n}" not found`);let s=z(n??{});for(let[e,t]of l(s))if(t.tags)for(let n of t.tags)w(n in a,`Invalid specification for deployment kind "${e}": tag "${n}" not found`);return{...i,tags:a,elements:o,deployments:s,relationships:z(r??{})}}function V(e){return i(e)?null:typeof e==`string`?{txt:e}:e}function H(t,s=new Map,l=[],f=new Map,g={predicates:{},dynamicPredicates:{},styles:{}},k=new Map,j=[],L=new D.default(()=>new Map)){let z=B(t),U=()=>({elements:structuredClone(z.elements),deployments:structuredClone(z.deployments),relationships:structuredClone(z.relationships),tags:A(structuredClone(z.tags)),...z.metadataKeys?{metadataKeys:z.metadataKeys}:{},customColors:{}}),W=e=>{if(!(!e||!a(e,1)))return o(e,e=>typeof e==`string`?{url:e}:e)},G=(e,t,n)=>{r(t)&&(n=t,t={}),t??={};let{links:i=[],title:a=null,description:o=null,tags:s=[],...c}=typeof t==`string`?{title:t}:{...t},l=W(i);return[S({id:e,title:a,description:V(o),tags:s,links:l,_stage:`parsed`,...c}),n]},K=e=>{let[t,n]=x(e),r=(t?L.get(t):s).get(n);return w(r,`Element with id "${e}" not found`),r},q=e=>{if(typeof e==`string`){let[t,n]=x(e);return t?{project:t,model:n}:{model:n}}return`project`in e||`deployment`in e?e:q(e.model)},J={get Types(){throw Error(`Types are not available in runtime`)},clone:()=>{let e=new D.default(()=>new Map);for(let[t,n]of L)e.set(t,structuredClone(n));return H(structuredClone(z),structuredClone(s),structuredClone(l),structuredClone(f),structuredClone(g),structuredClone(k),structuredClone(j),e)},__addElement:e=>{let[t,n]=x(e.id),r=C(n),i=t?L.get(t):s;if(r&&w(i.get(r),`Parent element with id "${r}" not found for element with id "${e.id}"`),i.has(n))throw Error(`Element with id "${e.id}" already exists`);return i.set(n,t?{...e,id:n}:e),J},__addRelation(e){let t=q(e.source),n=h.flatten(t),r=q(e.target),i=h.flatten(r),a=K(n),o=K(i);if(b(n)&&b(i))throw Error(`Cannot create relationship between global elements`);return!b(n)&&!b(i)&&w(!T(a,o),`Cannot create relationship between elements in the same hierarchy`),l.push({id:`rel${l.length+1}`,...e,source:t,target:r}),J},__fqn(e){return w(e.trim()!==``,`Id must be non-empty`),e},__deploymentFqn(e){return w(e.trim()!==``,`Id must be non-empty`),e},__addSourcelessRelation(){throw Error(`Can be called only in nested model`)},__addView:e=>{if(f.has(e.id))throw Error(`View with id "${e.id}" already exists`);return v(e)&&`viewOf`in e&&w(s.get(e.viewOf),`Invalid scoped view ${e.id}, wlement with id "${e.viewOf}" not found`),f.set(e.id,e),J},__addDeployment:e=>{if(k.has(e.id))throw Error(`Deployment with id "${e.id}" already exists`);let t=C(e.id);return t&&w(k.get(t),`Parent element with id "${t}" not found for node with id "${e.id}"`),m(e)&&(w(t,`Instance ${e.id} of ${e.element} must be deployed under a parent node`),w(s.get(e.element),`Instance "${e.id}" references non-existing element "${e.element}"`)),k.set(e.id,e),J},__addDeploymentRelation:e=>(w(!T(e.source.deployment,e.target.deployment),`Cannot create relationship between elements in the same hierarchy`),w(k.has(e.source.deployment),`Relation "${e.source.deployment} -> ${e.target.deployment}" references non-existing source`),w(k.has(e.target.deployment),`Relation "${e.source.deployment} -> ${e.target.deployment}" references non-existing target`),j.push({id:`deploy_rel${j.length+1}`,...e}),J),build:e=>({[y]:`parsed`,projectId:typeof e==`string`?e:e?.id??`from-builder`,project:{id:typeof e==`string`?e:`from-builder`,...typeof e==`object`&&e?e:{}},specification:U(),elements:c(structuredClone(Array.from(s.entries()))),relations:p(l,e=>[e.id,structuredClone(e)]),globals:structuredClone(g),deployments:{elements:c(structuredClone(Array.from(k.entries()))),relations:p(j,e=>[e.id,structuredClone(e)])},views:c(structuredClone(Array.from(f.entries()))),imports:d(Array.from(L.entries()),o(([e,t])=>[e,structuredClone([...t.values()])]),u(([e,t])=>t.length>0),c())}),toLikeC4Model:e=>O(J.build(e)),helpers:()=>({model:{model:(...e)=>t=>e.reduce((e,t)=>t(e),t),rel:(t,n,r)=>i=>{let{title:a=``,links:o=[],description:s=null,notes:c=null,...l}=e(typeof r==`string`?{title:r}:{...r},{title:null,links:null}),u=W(o);return i.__addRelation(S({source:{model:t},target:{model:n},title:a,...s&&{description:V(s)},...c&&{notes:V(c)},links:u,...l})),i},relTo:(t,n)=>r=>{let{title:i=``,links:a,description:o=null,notes:s=null,...c}=e(typeof n==`string`?{title:n}:{...n},{title:null,links:null});return r.__addSourcelessRelation(S({target:{model:t},title:i,...o&&{description:V(o)},...s&&{notes:V(s)},links:W(a),...c})),r},...n(z.elements,({style:e,...t},n)=>(r,i)=>{let a=(a=>{let{links:o,icon:s,color:c,shape:l,style:u,title:d,description:f,summary:p,...m}=typeof i==`string`?{title:i}:{...i},h=s??e?.icon,g=a.__fqn(r);return a.__addElement(S({id:g,kind:n,title:d??E(g),...f&&{description:V(f)},...p&&{summary:V(p)},style:S({icon:h,color:c??e?.color,shape:l??e?.shape,border:e?.border,opacity:e?.opacity,size:e?.size,padding:e?.padding,textSize:e?.textSize,...u}),links:W(o),...t,...m})),a});return a.with=(...e)=>t=>{a(t);let{__fqn:n,__addSourcelessRelation:i}=t;try{t.__fqn=e=>`${n(r)}.${e}`,t.__addSourcelessRelation=e=>t.__addRelation({...e,source:{model:n(r)}}),e.reduce((e,t)=>t(e),t)}finally{t.__fqn=n,t.__addSourcelessRelation=i}return t},a})},views:{views:(...e)=>t=>e.reduce((e,t)=>t(e),t),view:(e,t,n)=>{let[r,i]=G(e,t,n),a={...r,[_]:`element`,rules:[]},o=e=>(e.__addView(a),i&&i(R(a)),e);return o.with=(...e)=>t=>{o(t);let n=R(a);for(let t of e)t(n);return t},o},viewOf:(e,t,n,r)=>{let[i,a]=G(e,n,r),o={...i,viewOf:t,[_]:`element`,rules:[]},s=e=>(e.__addView(o),a&&a(R(o)),e);return s.with=(...e)=>t=>{s(t);let n=R(o);for(let t of e)t(n);return t},s},deploymentView:(e,t,n)=>{let[r,i]=G(e,t,n),a={...r,[_]:`deployment`,rules:[]},o=e=>(e.__addView(a),i&&i(R(a)),e);return o.with=(...e)=>t=>{o(t);let n=R(a);for(let t of e)t(n);return t},o},$autoLayout:F,$exclude:N,$include:M,$rules:I,$style:P},deployment:{deployment:(...e)=>t=>e.reduce((e,t)=>t(e),t),instanceOf:(e,t,n)=>r=>{i(t)?(t=e,e=E(e)):typeof t==`string`?n??={}:(n=t,t=e,e=E(e));let{links:a,title:o,description:s,summary:c,icon:l,color:u,shape:d,style:f,...p}=typeof n==`string`?{title:n}:{...n},m=r.__deploymentFqn(e);return r.__addDeployment(S({id:m,element:t,...o&&{title:o},...c&&{summary:V(c)},...s&&{description:V(s)},style:S({icon:l,color:u,shape:d,...f}),links:W(a),...p})),r},rel:(e,t,n)=>r=>{let{title:i=null,links:a,description:o=null,notes:s=null,...c}=typeof n==`string`?{title:n}:{...n};return r.__addDeploymentRelation(S({source:{deployment:e},target:{deployment:t},title:i,...o&&{description:V(o)},...s&&{notes:V(s)},links:W(a),...c})),r},...n(z.deployments??{},({style:e,...t},n)=>(r,i)=>{let a=(a=>{let{links:o,icon:s,style:c,title:l,description:u,summary:d,color:f,shape:p,...m}=typeof i==`string`?{title:i}:{...i},h=s??e?.icon,g=a.__deploymentFqn(r);return a.__addDeployment(S({id:g,kind:n,title:l??E(g),...u&&{description:V(u)},...d&&{summary:V(d)},style:S({icon:h,color:f??e?.color,shape:p??e?.shape,border:e?.border,opacity:e?.opacity,size:e?.size,padding:e?.padding,textSize:e?.textSize,...c}),links:W(o),...t,...m})),a});return a.with=(...e)=>t=>{a(t);let{__deploymentFqn:n}=t;try{t.__deploymentFqn=e=>`${n(r)}.${e}`,e.reduce((e,t)=>t(e),t)}finally{t.__deploymentFqn=n}return t},a})}}),with:(...e)=>{let t=J.clone();return e.reduce((e,t)=>t(e),t)},model:e=>{let t=J.clone(),n=t.helpers().model,r=n.model;return e({...n,_:r},r)(t)},deployment:e=>{let t=J.clone(),n=t.helpers().deployment,r=n.deployment;return e({...n,_:r},r)(t)},views:e=>{let t=J.clone(),n=t.helpers().views;return e({...n,_:n.views},n.views)(t)}};return J}const U={forSpecification(e){let t=H(e);return{...t.helpers(),builder:t}},specification(e){return H(e)}};export{U as Builder};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { Br as ElementId, Ji as _stage, On as ModelExpression, Pr as AnyParsed, S as ComputedView, Yi as _type, _ as ComputedLikeC4ModelData, at as ComputedNode, b as ParsedLikeC4ModelData, ci as ViewId, cn as AnyIncludePredicate, fn as BaseViewProperties, hn as ViewAutoLayout, ia as NonEmptyArray, ii as Unknown, jr as Any, pi as toComputed, rt as ComputedEdge, sn as AnyExcludePredicate, w as ParsedView } from "../_chunks/
|
|
2
|
-
import "../
|
|
3
|
-
import "../_chunks/
|
|
1
|
+
import { Br as ElementId, Ji as _stage, On as ModelExpression, Pr as AnyParsed, S as ComputedView, Yi as _type, _ as ComputedLikeC4ModelData, at as ComputedNode, b as ParsedLikeC4ModelData, ci as ViewId, cn as AnyIncludePredicate, fn as BaseViewProperties, hn as ViewAutoLayout, ia as NonEmptyArray, ii as Unknown, jr as Any, pi as toComputed, rt as ComputedEdge, sn as AnyExcludePredicate, w as ParsedView } from "../_chunks/index.mjs";
|
|
2
|
+
import "../_chunks/index2.mjs";
|
|
3
|
+
import "../_chunks/index3.mjs";
|
|
4
|
+
import "../_chunks/libs/mnemonist.mjs";
|
|
5
|
+
import "../_chunks/mnemonist.mjs";
|
|
4
6
|
import { C as ElementModel, T as RelationshipModel, n as LikeC4Model } from "../_chunks/LikeC4Model.mjs";
|
|
5
7
|
import { B as ViewPredicate } from "../_chunks/_types.mjs";
|
|
6
|
-
import "../_chunks/
|
|
7
|
-
import "../model/index.mjs";
|
|
8
|
+
import "../_chunks/index4.mjs";
|
|
8
9
|
import { a as LayoutedProjectNode, i as LayoutedProjectEdge, n as ComputedProjectNode, o as LayoutedProjectsView, r as ComputedProjectsView, t as ComputedProjectEdge } from "../_chunks/_types2.mjs";
|
|
9
10
|
|
|
10
11
|
//#region src/compute-view/compute-view.d.ts
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as
|
|
2
|
-
`)},shape:`rectangle`,children:[],inEdges:[],outEdges:[],color:`primary`,level:0,style:{},tags:[]};
|
|
1
|
+
import{r as e}from"../_chunks/rolldown-runtime.mjs";import"../_chunks/libs/defu.mjs";import{$ as t,C as n,D as r,K as i,L as a,Q as o,S as s,T as c,X as l,Y as u,b as d,d as f,et as p,i as m,m as h,r as ee,w as te,y as ne}from"../_chunks/libs/remeda.mjs";import{Q as g,_,_t as v,bt as y,g as re,gt as ie,ot as ae,rt as b}from"../_chunks/types.mjs";import"../_chunks/geometry.mjs";import{$ as x,D as S,I as C,K as w,L as T,Q as E,U as D,_ as O,r as k,v as A,x as j}from"../_chunks/utils.mjs";import{n as M,t as N}from"../_chunks/libs/graphology-dag.mjs";import{t as P}from"../_chunks/libs/mnemonist.mjs";import"../_chunks/libs/natural-compare-lite.mjs";import"../_chunks/libs/ohash.mjs";import"../_chunks/libs/@ungap/structured-clone.mjs";import"../_chunks/libs/hast-util-sanitize.mjs";import"../_chunks/libs/rehype-sanitize.mjs";import"../_chunks/libs/hast-util-to-html.mjs";import"../_chunks/libs/character-entities-legacy.mjs";import"../_chunks/libs/character-entities-html4.mjs";import"../_chunks/libs/ccount.mjs";import"../_chunks/libs/comma-separated-tokens.mjs";import"../_chunks/libs/rehype-stringify.mjs";import"../_chunks/libs/devlop.mjs";import"../_chunks/libs/mdast-util-from-markdown.mjs";import"../_chunks/libs/escape-string-regexp.mjs";import"../_chunks/libs/mdast-util-find-and-replace.mjs";import"../_chunks/libs/mdast-util-gfm.mjs";import"../_chunks/libs/markdown-table.mjs";import"../_chunks/libs/longest-streak.mjs";import"../_chunks/libs/character-entities.mjs";import"../_chunks/libs/decode-named-character-reference.mjs";import"../_chunks/libs/micromark-extension-gfm.mjs";import"../_chunks/libs/remark-gfm.mjs";import"../_chunks/libs/remark-github-blockquote-alert.mjs";import"../_chunks/libs/remark-parse.mjs";import"../_chunks/libs/mdast-util-to-hast.mjs";import"../_chunks/libs/remark-rehype.mjs";import"../_chunks/libs/bail.mjs";import"../_chunks/libs/extend.mjs";import"../_chunks/libs/is-plain-obj.mjs";import"../_chunks/libs/trough.mjs";import"../_chunks/libs/unified.mjs";import"../_chunks/libs/@radix-ui/colors.mjs";import"../_chunks/libs/@mantine/colors-generator.mjs";import"../_chunks/model.mjs";import"../_chunks/manual-layout.mjs";import{a as F,c as I,i as L,n as R,o as z,r as B,s as V,t as H}from"../_chunks/Builder.view-element.mjs";import{t as U}from"../_chunks/libs/graphology.mjs";var W=M(),G=e(N(),1);function K(e){let t=new U({type:`directed`}),n=[];for(let r of ee(e))t.addNode(r.id,{view:r}),_(r)&&n.push(r);if(n.length===0)return e;for(let e of n){if(!t.hasNode(e.extends)){console.warn(`View "${e.id}" extends from "${e.extends}" which does not exist`);continue}if((0,G.default)(t,e.id,e.extends)){console.warn(`View "${e.id}" extends from "${e.extends}" which creates a cycle`);continue}t.addDirectedEdge(e.id,e.extends)}return(0,W.topologicalSort)(t).reverse().reduce((e,n)=>{let r=t.getNodeAttribute(n,`view`);if(!_(r))return e[r.id]=r,e;let i=e[r.extends];if(!i||!re(i))return e;let a=m([...i.tags??[],...r.tags??[]]),o=[...i.links??[],...r.links??[]];return e[r.id]={...i,...r,title:r.title??i.title??null,description:r.description??i.description??null,tags:a,links:w(o)?o:null,rules:[...i.rules,...r.rules]},e},{})}function q({edges:e,nodes:t,...n},r=`:`){let i=te(e,e=>[e.id,`${e.source}${r}${e.target}`]);return{...n,edges:e.map(e=>({...e,id:i[e.id]})),nodes:t.map(e=>({...e,inEdges:c(e.inEdges,e=>i[e]),outEdges:c(e.outEdges,e=>i[e])})),nodeIds:t.map(e=>e.id),edgeIds:e.map(e=>i[e.id])}}function oe({views:e,...t}){return{...t,views:n(e,e=>s(q(e),[`nodeIds`,`edgeIds`]))}}const J=e=>r(e).length,Y=e=>k(e);function se(e){let t=ce(e),n=(e,t)=>`${e}->${t}`,r=new P.default(e=>{let[t,n]=e.split(`->`);return{from:t,to:n,relationships:new Set}}),s=(e,t)=>r.get(n(e,t)).relationships,u=(e,t)=>{let n=t.projectId;E(n!==e.projectId,`Imported element must have a different project id`);let r=s(e.projectId,n);for(let n of t.incoming(`direct`))n.source.projectId===e.projectId&&r.add(n);let i=s(n,e.projectId);for(let n of t.outgoing(`direct`))n.target.projectId===e.projectId&&i.add(n)};for(let t of e)if(!a(t.$data.imports))for(let[e,n]of l(t.$data.imports))for(let r of n){let n=g(e,r.id);u(t,x(t.findElement(n),`Element ${r.id} from project ${e} not found in model ${t.projectId}`))}let d=Array.from(r.entries()).filter(([e,{relationships:t}])=>t.size>0).map(([e,{from:t,to:n,relationships:r}])=>{let a=[...r];E(o(a,1),`Relationships set must have at least one relationship`);let s={id:k(e),source:Y(t),target:Y(n),projectId:t,relations:c(a,h(`id`)),label:null,color:`gray`,parent:null,line:`solid`,tags:m(i(a,h(`tags`)))},l=ne(a);return l&&(s.label=l.title,s.description=y(l.$relationship)??null,s.technology=l.technology,s.color=l.color,s.line=l.line,l.kind&&(s.kind=l.kind),l.$relationship.navigateTo&&(s.navigateTo=l.$relationship.navigateTo)),s});I(t,d);let f=V({nodes:t,edges:d});return{id:`projects-view`,[v]:`projects`,[ie]:`computed`,title:`Projects`,description:{txt:`Overview of all projects and their relationships`},autoLayout:{direction:`TB`},...f}}function ce(e){let t=new Map;for(let n of e){let e=b(n.projectId),r={id:Y(e),kind:`@project`,parent:null,projectId:e,title:n.project.title??n.project.id,description:{txt:[`Elements: ${J(n.$data.elements)}`,`Relationships: ${J(n.$data.relations)}`,`Views: ${J(n.$data.views)}`].join(`
|
|
2
|
+
`)},shape:`rectangle`,children:[],inEdges:[],outEdges:[],color:`primary`,level:0,style:{},tags:[]};t.set(r.id,r)}return t}function X(e){let n=D([...e]),r=new Set(n),i=new Map,a=new P.default(()=>null),o=n.reduce((e,n,o,s)=>(i.set(n.id,n),e.set(n.id,p(s,t(o+1),u(T(n)),f((e,t)=>(r.delete(t),e.some(C(t))||(e.push(t),a.set(t.id,n)),e),[]))),e),new P.default(()=>[]));return{sorted:n,byId:e=>x(i.get(e),`Element not found by id: ${e}`),root:r,parent:e=>a.get(typeof e==`string`?e:e.id),children:e=>o.get(typeof e==`string`?e:e.id),flatten:d(()=>new Set([...r,...n.reduce((e,t)=>{let n=o.get(t.id);return n.length===0?(e.push(t),e):(n.length>1&&e.push(...n),e)},[])]))}}const Z=(e,t)=>e.size>2&&t.size!==e.size?new Set(D([...X(e).flatten(),...t])):e.size>1?new Set(D([...e])):e;function Q(e,t,n){let r=e=>t.has(e),i=new Set([e]),a={incomers:new Set,subjects:new Set([e]),outgoers:new Set},o=new Set(n.incoming.flatMap(t=>{if(a.subjects.add(t.target),a.incomers.add(t.source),i.add(t.target),t.target!==e){let n=t.target.parent;for(;n&&n!==e;)i.add(n),n=n.parent}let n=t.source,o=[];for(;o.push(n),!(r(n)||!n.parent);)n=n.parent;return o})),s=new Set(n.outgoing.flatMap(t=>{if(a.subjects.add(t.source),a.outgoers.add(t.target),i.add(t.source),t.source!==e){let n=t.source.parent;for(;n&&n!==e;)i.add(n),n=n.parent}let n=t.target,o=[];for(;o.push(n),!(r(n)||!n.parent);)n=n.parent;return o}));return{incomers:Z(o,a.incomers),incoming:new Set(n.incoming),subjects:Z(i,a.subjects),outgoing:new Set(n.outgoing),outgoers:Z(s,a.outgoers)}}function le(e,t,n,r=`global`){let i=n?t.findView(n):null;if(r===`view`)return E(i,`Scope view id is required when scope is "view"`),ue(e,i,t);let a=t.element(e);return Q(a,A(a.ascendingSiblings()),{incoming:[...a.incoming()],outgoing:[...a.outgoing()]})}function ue(e,t,n){let r=n.element(e),i={incoming:O(S(r.incoming(),e=>t.includesRelation(e.id))),outgoing:O(S(r.outgoing(),e=>t.includesRelation(e.id)))},a=T(r);return Q(r,new Set([...r.ascendingSiblings(),...p(t.elements(),j(e=>e.element),S(e=>e!==r&&a(e)))]),i)}function $(e,t){return{...z(e,{id:ae(`adhoc`),_stage:`parsed`,_type:`element`,rules:t,title:null,description:null}),_type:`adhoc`,_stage:`computed`}}var de=class e{static use(t){return new e(t)}#e=[];constructor(e){this.model=e}Expr;include(...e){return this.#e.push({include:e.map(e=>H(e))}),this}exclude(...e){return this.#e.push({exclude:e.map(e=>H(e))}),this}compute(){return $(this.model,this.#e)}};export{de as AdhocView,$ as computeAdhocView,R as computeLikeC4Model,B as computeParsedModelData,se as computeProjectsView,le as computeRelationshipsView,L as computeView,K as resolveRulesExtendedViews,X as treeFromElements,F as unsafeComputeView,oe as viewsWithReadableEdges,q as withReadableEdges};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as RectBox, c as XYPoint, i as BBox, l as convertPoint, n as VectorValue, o as Dimensions, r as vector, s as Point, t as Vector, u as isPoint } from "../_chunks/
|
|
1
|
+
import { a as RectBox, c as XYPoint, i as BBox, l as convertPoint, n as VectorValue, o as Dimensions, r as vector, s as Point, t as Vector, u as isPoint } from "../_chunks/index2.mjs";
|
|
2
2
|
export { BBox, Dimensions, Point, RectBox, Vector, VectorValue, XYPoint, convertPoint, isPoint, vector };
|
package/dist/geometry/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../_chunks/libs/defu.mjs";import{a as
|
|
1
|
+
import"../_chunks/libs/defu.mjs";import"../_chunks/libs/remeda.mjs";import{a as e,i as t,n,o as r,r as i,t as a}from"../_chunks/geometry.mjs";import"../_chunks/utils.mjs";import"../_chunks/libs/graphology-dag.mjs";import"../_chunks/libs/mnemonist.mjs";import"../_chunks/libs/natural-compare-lite.mjs";import"../_chunks/libs/ohash.mjs";import"../_chunks/libs/@ungap/structured-clone.mjs";import"../_chunks/libs/hast-util-sanitize.mjs";import"../_chunks/libs/rehype-sanitize.mjs";import"../_chunks/libs/hast-util-to-html.mjs";import"../_chunks/libs/character-entities-legacy.mjs";import"../_chunks/libs/character-entities-html4.mjs";import"../_chunks/libs/ccount.mjs";import"../_chunks/libs/comma-separated-tokens.mjs";import"../_chunks/libs/rehype-stringify.mjs";import"../_chunks/libs/devlop.mjs";import"../_chunks/libs/mdast-util-from-markdown.mjs";import"../_chunks/libs/escape-string-regexp.mjs";import"../_chunks/libs/mdast-util-find-and-replace.mjs";import"../_chunks/libs/mdast-util-gfm.mjs";import"../_chunks/libs/markdown-table.mjs";import"../_chunks/libs/longest-streak.mjs";import"../_chunks/libs/character-entities.mjs";import"../_chunks/libs/decode-named-character-reference.mjs";import"../_chunks/libs/micromark-extension-gfm.mjs";import"../_chunks/libs/remark-gfm.mjs";import"../_chunks/libs/remark-github-blockquote-alert.mjs";import"../_chunks/libs/remark-parse.mjs";import"../_chunks/libs/mdast-util-to-hast.mjs";import"../_chunks/libs/remark-rehype.mjs";import"../_chunks/libs/bail.mjs";import"../_chunks/libs/extend.mjs";import"../_chunks/libs/is-plain-obj.mjs";import"../_chunks/libs/trough.mjs";import"../_chunks/libs/unified.mjs";export{i as BBox,t as RectBox,a as Vector,e as convertPoint,r as isPoint,n as vector};
|