diff --git a/README.md b/README.md index a0f409c..1dd45e9 100644 --- a/README.md +++ b/README.md @@ -153,6 +153,13 @@ The inspector above shows one entity carrying an enumerated domain (`asset_class a named primary key and a unique key, user-defined properties, and its relationships, all first-class in the model. +Relationship lines anchor to the exact columns that join, not to the entity headers, so +with composite keys or several relationships between the same pair the diagram still says +which columns join which; hovering an attribute highlights the relationships it takes part +in and dims the rest. + +![The ER canvas with a relationship line running from one entity's foreign-key attribute row to the referenced entity's primary-key row, with crow's-foot cardinality](docs/assets/canvas.png) + ## In VS Code Install the extension from `vscode/modelith-vscode-0.1.0.vsix`: @@ -207,8 +214,8 @@ Modelith represents the core data-modeling taxonomy as first-class, git-tracked |---|---| | Conceptual / logical / physical layers | Separate object kinds, referenced by immutable ULID | | Entities and attributes | Name, domain, role (business key / surrogate / attribute / measure), nullability | -| Relationships | Four cardinalities, identifying vs non-identifying, optionality, crow's-foot rendering | -| Named keys | Primary, alternate, unique, and index key groups with ordered, composite members | +| Relationships | Four cardinalities, identifying vs non-identifying, optionality, crow's-foot rendering; lines anchor to the concrete attribute rows on both sides, not the entity box | +| Named keys | Primary, alternate, unique, and index key groups with ordered, composite members; validated (one primary key per entity, a warning on a nullable PK column, and an error when a foreign key's domains don't match) | | Domains and reference data | Reusable domains, inline enumerations, and shared code sets that emit dbt `accepted_values` tests | | Subtypes and supertypes | Category clusters with a discriminator and a physical materialization strategy (single-table or table-per-subtype) | | User-defined properties | Extensible metadata on any object, flowing through to dbt `meta` | @@ -235,6 +242,10 @@ deterministically from the one definition: | Semantic layer | `mdl emit semantic` | MetricFlow semantic models and metrics, or OSI | | Ontology | `mdl export rdf` / `shacl` | RDF/OWL with SKOS alignments, and SHACL shapes | | Knowledge graph | `mdl export r2rml` | A W3C R2RML mapping: the deterministic term-map from warehouse rows to typed, ontology-aligned graph nodes; fails loud on any unmapped entity unless `--allow-unmapped` | +| SQL DDL | `mdl export sql --dialect …` | `CREATE TABLE` with primary keys, foreign-key `REFERENCES`, `UNIQUE`, and `NOT NULL`, in a chosen dialect (postgres/snowflake/duckdb/…) — the universal interchange target | +| Mermaid | `mdl export mermaid` | A Mermaid `erDiagram` with PK/FK/UK markers and crow's-foot cardinality, rendering natively in GitHub, GitLab, and most markdown | +| DBML | `mdl export dbml` | Database Markup Language that opens directly in dbdiagram.io, dbdocs, and ChartDB | +| CSV | `mdl export csv` | A flat attributes sheet (entity, attribute, type, PK/FK, nullable) for spreadsheets and BI tools | `mdl generate --emit-contract` (also `--emit-pydantic`, `--emit-graph`, `--emit-r2rml`) turns Modelith into a contract factory: on every regeneration it drops a fresh, valid @@ -268,6 +279,14 @@ misclassification on non-standard naming is visible immediately, not discovered time; the conventions it keys off are overridable via `mdl reverse --naming ` (medallion `gold_`, `f_`/`d_`, non-English). See [Reverse engineering a real warehouse](#reverse-engineering-a-real-warehouse) below. +**Import & interchange.** Bring a model in from the wider toolset and hand it back out. +Import **SQL DDL** (parsed with a real SQL AST, so dialects, quoting, composite keys, and +inline vs table-level constraints all work), a **Mermaid `erDiagram`**, or a **JSON +Schema** — each parsed into entities, attributes, keys, and relationships that stage as a +normal proposal. Export **SQL DDL, Mermaid, DBML, CSV** (alongside the compile targets +above). All of it is a menu in the Model tab's toolbar, and on the CLI as `mdl import +sql|mermaid|json-schema` and `mdl export sql|mermaid|dbml|csv`. + **Drift detection.** `mdl drift` compares the committed model to a compiled warehouse and classifies each difference as breaking, additive, or cosmetic, with a CI gate mode and a reconcile mode. A 400-model breaking change classifies in under thirty seconds. @@ -282,6 +301,19 @@ below. customer-owned Jinja profile. A Collibra adapter ships, along with OpenLineage emission and a conformance kit that validates a bespoke mapping in CI. +### Import and export, from the Model tab + +The Model tab's toolbar has **Export** and **Import** menus. Export downloads the model +in any interchange format; import parses SQL DDL, a Mermaid diagram, or a JSON Schema and +stages it as a proposal you review before it lands. + +![The Export menu open in the Model-tab toolbar: a SQL dialect selector and download items for SQL DDL, Mermaid erDiagram, DBML, CSV, an ODCS data contract, and Neo4j Cypher](docs/assets/export-menu.png) + +![The Import panel on its SQL DDL tab, with a dialect selector, a paste area, and a file picker; tabs switch to Mermaid erDiagram and JSON Schema](docs/assets/import-panel.png) + +An imported model is visible on the canvas immediately as a staged preview — nothing +touches disk or git until you submit the proposal. + ## Reverse engineering a real warehouse `mdl reverse` lifts a compiled dbt project into a logical model. On a real, organically @@ -796,6 +828,15 @@ lists your open proposal branches. Stage an edit and the tray takes you to by severity, everything else dimmed to context. Erwin's Complete Compare is a tree and structurally cannot do this. +![The Review screen: a Counterparty entity marked modified, a before/after definition diff with the added words highlighted, and a footer showing the review route (Governance), the reviewers, the CI gates, and that it merges cleanly onto main](docs/assets/review-screen.png) + +Submitting opens one dialog that carries the whole git handoff — a word-level diff of +each change, who the proposal is attributed to (the resolved identity, not a +self-asserted name), an editable branch name, the route-advice callout when a change +spans review routes, and the branch and reviewers it will land on. + +![The Submit-for-review dialog: the definition diff, "Signed in as Debasish Bose", an editable title and branch name, a callout explaining the change spans routes A and E so it takes the stricter Governance review, and the target branch sme/debasish-bose/update-definition with its reviewers](docs/assets/propose-dialog.png) + A banner states the git reality plainly. There is no lock file and no "claim this area" button: the branch **is** the lock, so the banner says which branch you are on, and greys out Submit with the reason when the working tree is dirty — rather diff --git a/canvas/src/ModelCanvas.tsx b/canvas/src/ModelCanvas.tsx index 9a84801..29ec4e8 100644 --- a/canvas/src/ModelCanvas.tsx +++ b/canvas/src/ModelCanvas.tsx @@ -182,22 +182,34 @@ export function ModelCanvas({ // flags below rather than a parallel highlight system. const relsForAttr = new Set(); // relationship ids touching hoveredAttr const entsForAttr = new Set(); // entities on those relationships + // The attribute rows to emphasise at BOTH ends, keyed by entity. Populated for a + // hovered edge (both its paired columns) and for a hovered attribute (that column + // plus the columns it joins to at the other end), so hovering one data element + // lights up the data element it links to on the far side. + const hitAttrsByEntity = new Map>(); + const mark = (entity: string, attrs: string[]) => { + if (!attrs.length) return; + const s = hitAttrsByEntity.get(entity) ?? new Set(); + attrs.forEach((a) => s.add(a)); + hitAttrsByEntity.set(entity, s); + }; if (hoveredAttr) { for (const r of doc.relationships) { if (r.from.attributes.includes(hoveredAttr) || r.to.attributes.includes(hoveredAttr)) { relsForAttr.add(r.id); entsForAttr.add(r.from.entity); entsForAttr.add(r.to.entity); + // light up the joined columns on BOTH sides of this relationship + mark(r.from.entity, r.from.attributes); + mark(r.to.entity, r.to.attributes); } } } - // attribute rows to emphasise, keyed by entity, when an edge is hovered - const hitAttrsByEntity = new Map>(); if (hoveredEdge) { const r = doc.relationships.find((x) => x.id === hoveredEdge); if (r) { - hitAttrsByEntity.set(r.from.entity, new Set(r.from.attributes)); - hitAttrsByEntity.set(r.to.entity, new Set(r.to.attributes)); + mark(r.from.entity, r.from.attributes); + mark(r.to.entity, r.to.attributes); } } diff --git a/canvas/src/sme/ModelWorkspace.tsx b/canvas/src/sme/ModelWorkspace.tsx index 9642dbc..ed815eb 100644 --- a/canvas/src/sme/ModelWorkspace.tsx +++ b/canvas/src/sme/ModelWorkspace.tsx @@ -140,6 +140,25 @@ export function ModelWorkspace({ {creatingArea && ( + e.conceptual + ? [ + { + id: e.conceptual.id, + kind: "conceptual_entity" as const, + name: e.conceptual.name, + definition: e.conceptual.definition ?? null, + synonyms: [], + subject_area: e.conceptual.subject_area ?? null, + // the picker only reads id/name/definition; the rest of the + // GlossaryTerm shape is filled with empties to satisfy the type. + stewardship: null, + ontology: null, + where_used: [], + }, + ] + : [], + )} onClose={() => setCreatingArea(false)} onCreate={(name, definition, members) => { // Client-minted so the area keeps its identity from preview to PR, and @@ -176,6 +195,20 @@ export function ModelWorkspace({ )} drag between entities to relate them + + diff --git a/canvas/src/styles.css b/canvas/src/styles.css index 893c035..2fe85a7 100644 --- a/canvas/src/styles.css +++ b/canvas/src/styles.css @@ -95,7 +95,10 @@ body { font-family: var(--font); background: var(--bg); color: var(--text); } .attr-row.empty { color: var(--text-dim); font-style: italic; } /* attribute-level relationship highlighting (issue #5): the rows an edge/attribute hover touches brighten; the rest recede. */ -.attr-row.rel-hit { background: var(--accent-soft); } +/* a joined column at either end of the hovered relationship: accent wash + a left + marker + brighter name, so the linked data elements read as a pair across cards. */ +.attr-row.rel-hit { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); } +.attr-row.rel-hit .attr-name { color: var(--accent); font-weight: 600; } .attr-row.rel-dim { opacity: 0.35; } .attr-row.endpoint .attr-name { font-style: normal; } /* per-attribute connection ports: sit on the row's own edge, revealed on hover so diff --git a/docs/assets/export-menu.png b/docs/assets/export-menu.png new file mode 100644 index 0000000..740d487 Binary files /dev/null and b/docs/assets/export-menu.png differ diff --git a/docs/assets/import-panel.png b/docs/assets/import-panel.png new file mode 100644 index 0000000..3cf039e Binary files /dev/null and b/docs/assets/import-panel.png differ diff --git a/docs/assets/propose-dialog.png b/docs/assets/propose-dialog.png new file mode 100644 index 0000000..c28c60b Binary files /dev/null and b/docs/assets/propose-dialog.png differ diff --git a/docs/assets/review-screen.png b/docs/assets/review-screen.png new file mode 100644 index 0000000..bff7de1 Binary files /dev/null and b/docs/assets/review-screen.png differ diff --git a/packages/server/src/mdl_server/static/assets/ModelDiagram-C1PzETqC.js b/packages/server/src/mdl_server/static/assets/ModelDiagram-gE_Z16kV.js similarity index 97% rename from packages/server/src/mdl_server/static/assets/ModelDiagram-C1PzETqC.js rename to packages/server/src/mdl_server/static/assets/ModelDiagram-gE_Z16kV.js index 5c93e3f..48abf47 100644 --- a/packages/server/src/mdl_server/static/assets/ModelDiagram-C1PzETqC.js +++ b/packages/server/src/mdl_server/static/assets/ModelDiagram-gE_Z16kV.js @@ -1 +1 @@ -import{r,j as s}from"./client-DOmNpTln.js";import{f as T,v as _,w as O,x as R,E as D,B as P,C as z,y as A}from"./styles-DG4k7QGS.js";const V={entity:D},$={relationship:R},l={breaking:"#f87171",additive:"#34d399",cosmetic:"#fcd34d"},N=["#5eead4","#fcd34d","#a78bfa","#fb923c","#38bdf8","#f472b6","#a3e635"],d="#64748b";function Y({subjectArea:u,severityByUlid:a,focusUlid:m,onSelect:c}){const[t,g]=r.useState(null),[f,w]=r.useState(null),[h,E]=r.useState(!0);r.useEffect(()=>{g(null),T(u).then(g).catch(n=>w(String(n)))},[u]);const{nodes:k,edges:M}=r.useMemo(()=>{if(!t)return{nodes:[],edges:[]};const n=new Map;t.subject_areas.forEach(e=>{let o=2166136261;for(let i=0;i[e.id,e])),x=a&&a.size>0,C=t.entities.map(e=>{var j;const o=(a==null?void 0:a.get(e.id))??(e.conceptual?a==null?void 0:a.get(e.conceptual.id):void 0),i=x?o?l[o]??d:d:(j=e.conceptual)!=null&&j.subject_area?n.get(e.conceptual.subject_area.id)??d:d;return{id:e.id,type:"entity",position:{x:0,y:0},data:{entity:e,color:i,dimmed:!!(x&&!o),highlighted:e.id===m,showTypes:h}}}),b=t.relationships.map(e=>({id:e.id,source:e.from.entity,target:e.to.entity,type:"relationship",data:{relationship:e,dimmed:!1}}));return{nodes:_(C,b,p),edges:b}},[t,a,m,h]);return f?s.jsx("p",{className:"sme-splash error",children:f}):t?t.entities.length?s.jsxs("div",{className:"erd-wrap",children:[s.jsxs("div",{className:"erd-bar",children:[s.jsxs("span",{className:"erd-count",children:[t.entities.length," entities · ",t.relationships.length," relationships",t.scope&&" · scoped"]}),s.jsxs("label",{className:"erd-toggle",children:[s.jsx("input",{type:"checkbox",checked:h,onChange:n=>E(n.target.checked)}),"show types"]}),a&&a.size>0&&s.jsxs("span",{className:"erd-legend",children:[s.jsx("span",{className:"sw",style:{background:l.breaking}})," breaking",s.jsx("span",{className:"sw",style:{background:l.additive}})," added",s.jsx("span",{className:"sw",style:{background:l.cosmetic}})," changed",s.jsx("span",{className:"sw",style:{background:d}})," unchanged"]})]}),s.jsx("div",{className:"erd-canvas",children:s.jsxs(O,{nodes:k,edges:M,nodeTypes:V,edgeTypes:$,fitView:!0,minZoom:.1,nodesConnectable:!1,onNodeClick:(n,p)=>c==null?void 0:c(p.id),onPaneClick:()=>c==null?void 0:c(null),onlyRenderVisibleElements:!0,proOptions:{hideAttribution:!0},children:[s.jsx(P,{gap:16,color:"#1f2937"}),s.jsx(z,{showInteractive:!1}),s.jsx(A,{pannable:!0,zoomable:!0})]})})]}):s.jsx("p",{className:"sme-placeholder",children:"Nothing to draw — this subject area has no entities in it yet."}):s.jsx("div",{className:"sme-splash",children:"◮ drawing the model…"})}export{Y as ModelDiagram}; +import{r,j as s}from"./client-DOmNpTln.js";import{f as T,v as _,w as O,x as R,E as D,B as P,C as z,y as A}from"./styles-BTZUJ0jx.js";const V={entity:D},$={relationship:R},l={breaking:"#f87171",additive:"#34d399",cosmetic:"#fcd34d"},N=["#5eead4","#fcd34d","#a78bfa","#fb923c","#38bdf8","#f472b6","#a3e635"],d="#64748b";function Y({subjectArea:u,severityByUlid:a,focusUlid:m,onSelect:c}){const[t,g]=r.useState(null),[f,w]=r.useState(null),[h,E]=r.useState(!0);r.useEffect(()=>{g(null),T(u).then(g).catch(n=>w(String(n)))},[u]);const{nodes:k,edges:M}=r.useMemo(()=>{if(!t)return{nodes:[],edges:[]};const n=new Map;t.subject_areas.forEach(e=>{let o=2166136261;for(let i=0;i[e.id,e])),x=a&&a.size>0,C=t.entities.map(e=>{var j;const o=(a==null?void 0:a.get(e.id))??(e.conceptual?a==null?void 0:a.get(e.conceptual.id):void 0),i=x?o?l[o]??d:d:(j=e.conceptual)!=null&&j.subject_area?n.get(e.conceptual.subject_area.id)??d:d;return{id:e.id,type:"entity",position:{x:0,y:0},data:{entity:e,color:i,dimmed:!!(x&&!o),highlighted:e.id===m,showTypes:h}}}),b=t.relationships.map(e=>({id:e.id,source:e.from.entity,target:e.to.entity,type:"relationship",data:{relationship:e,dimmed:!1}}));return{nodes:_(C,b,p),edges:b}},[t,a,m,h]);return f?s.jsx("p",{className:"sme-splash error",children:f}):t?t.entities.length?s.jsxs("div",{className:"erd-wrap",children:[s.jsxs("div",{className:"erd-bar",children:[s.jsxs("span",{className:"erd-count",children:[t.entities.length," entities · ",t.relationships.length," relationships",t.scope&&" · scoped"]}),s.jsxs("label",{className:"erd-toggle",children:[s.jsx("input",{type:"checkbox",checked:h,onChange:n=>E(n.target.checked)}),"show types"]}),a&&a.size>0&&s.jsxs("span",{className:"erd-legend",children:[s.jsx("span",{className:"sw",style:{background:l.breaking}})," breaking",s.jsx("span",{className:"sw",style:{background:l.additive}})," added",s.jsx("span",{className:"sw",style:{background:l.cosmetic}})," changed",s.jsx("span",{className:"sw",style:{background:d}})," unchanged"]})]}),s.jsx("div",{className:"erd-canvas",children:s.jsxs(O,{nodes:k,edges:M,nodeTypes:V,edgeTypes:$,fitView:!0,minZoom:.1,nodesConnectable:!1,onNodeClick:(n,p)=>c==null?void 0:c(p.id),onPaneClick:()=>c==null?void 0:c(null),onlyRenderVisibleElements:!0,proOptions:{hideAttribution:!0},children:[s.jsx(P,{gap:16,color:"#1f2937"}),s.jsx(z,{showInteractive:!1}),s.jsx(A,{pannable:!0,zoomable:!0})]})})]}):s.jsx("p",{className:"sme-placeholder",children:"Nothing to draw — this subject area has no entities in it yet."}):s.jsx("div",{className:"sme-splash",children:"◮ drawing the model…"})}export{Y as ModelDiagram}; diff --git a/packages/server/src/mdl_server/static/assets/main-C_5CUOf3.js b/packages/server/src/mdl_server/static/assets/main-C5mPrY7K.js similarity index 98% rename from packages/server/src/mdl_server/static/assets/main-C_5CUOf3.js rename to packages/server/src/mdl_server/static/assets/main-C5mPrY7K.js index 9a04ed9..564b899 100644 --- a/packages/server/src/mdl_server/static/assets/main-C_5CUOf3.js +++ b/packages/server/src/mdl_server/static/assets/main-C5mPrY7K.js @@ -1,2 +1,2 @@ -import{j as t,r as a,c as _,R as V}from"./client-DOmNpTln.js";import{R as X,P as D,f as F,a as B,g as K,s as z,A as G,M as H,S as J}from"./styles-DG4k7QGS.js";function W(n){return{canEdit:!n,mode:"direct",canArbitrate:!n,canCommit:!n}}function Y({doc:n,diagnostics:o,query:T,onQuery:m,onSubmitQuery:b,showTypes:R,onToggleTypes:f,onFitView:p,onRelayout:y,onRefresh:v,saColors:N,readOnly:C,dirty:S,panelTab:k,onPanelTab:j,onNewEntity:x}){const w=(o==null?void 0:o.items.filter(l=>l.severity==="error").length)??0,u=(o==null?void 0:o.items.filter(l=>l.severity==="warning").length)??0,g=(l,i,M,d)=>t.jsx("button",{className:"tool-btn"+(k===l?" active":"")+(d?" badged":""),onClick:()=>j(l),title:M,children:i});return t.jsxs("header",{className:"topbar",children:[t.jsxs("div",{className:"brand",children:[t.jsx("span",{className:"logo",children:"◮"}),t.jsx("span",{className:"brand-name",children:"Modelith"}),t.jsx("span",{className:"project-name",children:n.project.name}),C&&t.jsx("span",{className:"chip",children:"read-only"})]}),t.jsx("input",{className:"search",type:"search",placeholder:"Search entities & attributes… ( / , Enter jumps )",value:T,onChange:l=>m(l.target.value),onKeyDown:l=>{l.key==="Enter"&&b()},id:"mdl-search"}),t.jsx("div",{className:"legend",children:n.subject_areas.map(l=>t.jsxs("span",{className:"legend-item",children:[t.jsx("span",{className:"swatch",style:{background:N.get(l.id)}}),l.name]},l.id))}),t.jsxs("div",{className:"stats",children:[t.jsxs("span",{title:"entities",children:[n.counts.entities," ⬛"]}),t.jsxs("span",{title:"relationships",children:[n.counts.relationships," ⤳"]}),o&&t.jsx("span",{className:"diag-chip"+(w?" err":u?" warn":" ok"),title:o.items.map(l=>`${l.code} ${l.message}`).join(` +import{j as t,r as a,c as _,R as V}from"./client-DOmNpTln.js";import{R as X,P as D,f as F,a as B,g as K,s as z,A as G,M as H,S as J}from"./styles-BTZUJ0jx.js";function W(n){return{canEdit:!n,mode:"direct",canArbitrate:!n,canCommit:!n}}function Y({doc:n,diagnostics:o,query:T,onQuery:m,onSubmitQuery:b,showTypes:R,onToggleTypes:f,onFitView:p,onRelayout:y,onRefresh:v,saColors:N,readOnly:C,dirty:S,panelTab:k,onPanelTab:j,onNewEntity:x}){const w=(o==null?void 0:o.items.filter(l=>l.severity==="error").length)??0,u=(o==null?void 0:o.items.filter(l=>l.severity==="warning").length)??0,g=(l,i,M,d)=>t.jsx("button",{className:"tool-btn"+(k===l?" active":"")+(d?" badged":""),onClick:()=>j(l),title:M,children:i});return t.jsxs("header",{className:"topbar",children:[t.jsxs("div",{className:"brand",children:[t.jsx("span",{className:"logo",children:"◮"}),t.jsx("span",{className:"brand-name",children:"Modelith"}),t.jsx("span",{className:"project-name",children:n.project.name}),C&&t.jsx("span",{className:"chip",children:"read-only"})]}),t.jsx("input",{className:"search",type:"search",placeholder:"Search entities & attributes… ( / , Enter jumps )",value:T,onChange:l=>m(l.target.value),onKeyDown:l=>{l.key==="Enter"&&b()},id:"mdl-search"}),t.jsx("div",{className:"legend",children:n.subject_areas.map(l=>t.jsxs("span",{className:"legend-item",children:[t.jsx("span",{className:"swatch",style:{background:N.get(l.id)}}),l.name]},l.id))}),t.jsxs("div",{className:"stats",children:[t.jsxs("span",{title:"entities",children:[n.counts.entities," ⬛"]}),t.jsxs("span",{title:"relationships",children:[n.counts.relationships," ⤳"]}),o&&t.jsx("span",{className:"diag-chip"+(w?" err":u?" warn":" ok"),title:o.items.map(l=>`${l.code} ${l.message}`).join(` `)||"model valid",children:w?`${w} ✗`:u?`${u} ⚠`:"✓ valid"})]}),t.jsxs("div",{className:"actions",children:[!C&&t.jsx("button",{className:"tool-btn primary",onClick:x,title:"New entity (n)",children:"+ Entity"}),g("ontology","⬡","Ontology browser"),g("layers","≣","Four-layer stack & coverage"),g("changes","±",S?"Uncommitted changes!":"Changes",S),g("decisions","⚖","Decision ledger"),t.jsx("span",{className:"divider"}),t.jsx("button",{className:"tool-btn"+(R?" active":""),onClick:f,title:"Toggle data types",children:"{T}"}),t.jsx("button",{className:"tool-btn",onClick:v,title:"Refresh from disk (picks up terminal / external edits)",children:"⟳"}),t.jsx("button",{className:"tool-btn",onClick:y,title:"Auto-layout",children:"⌗"}),t.jsx("button",{className:"tool-btn",onClick:p,title:"Fit view",children:"⛶"})]})]})}function Z(){const[n,o]=a.useState(null),[T,m]=a.useState(null),[b,R]=a.useState(null),[f,p]=a.useState(null),[y,v]=a.useState(""),[N,C]=a.useState(!0),[S,k]=a.useState(null),[j,x]=a.useState(null),[w,u]=a.useState(!1),[g,l]=a.useState(0),i=a.useRef(null),M=a.useMemo(()=>{const e=new Map;return n==null||n.subject_areas.forEach((r,s)=>e.set(r.id,D[s%D.length])),e},[n]),d=(n==null?void 0:n.read_only)??!0,Q=a.useMemo(()=>W(d),[d]),A=a.useMemo(()=>new URLSearchParams(window.location.search),[]),I=A.get("minimal")==="1",P=a.useRef(!1),h=a.useCallback(()=>{F().then(o).catch(e=>R(String(e))),B().then(m).catch(()=>m(null)),K().then(e=>u(!!(e.git&&!e.clean))).catch(()=>u(!1)),l(e=>e+1)},[]);a.useEffect(h,[h]),a.useEffect(()=>{const e=setInterval(()=>{F().then(r=>{o(s=>s&&r.fingerprint===s.fingerprint?s:(I||(B().then(m).catch(()=>m(null)),K().then(c=>u(!!(c.git&&!c.clean))).catch(()=>u(!1))),l(c=>c+1),r))}).catch(()=>{})},3e3);return()=>clearInterval(e)},[I]);const $=a.useCallback(async(e,r)=>{if(n)try{const s=await z(e,r,n.fingerprint);return h(),s}catch(s){throw s instanceof G&&s.status===409?(p("Model changed on disk — view refreshed, please retry."),h()):p(s instanceof Error?s.message:String(s)),s}},[n,h]);a.useEffect(()=>{if(!f)return;const e=setTimeout(()=>p(null),5e3);return()=>clearTimeout(e)},[f]),a.useEffect(()=>{if(!n||P.current)return;const e=A.get("focus");if(!e)return;const r=n.entities.find(s=>{var c;return s.name===e||((c=s.conceptual)==null?void 0:c.name)===e});r&&(P.current=!0,requestAnimationFrame(()=>{var s;return(s=i.current)==null?void 0:s.focusEntity(r.id)}))},[n,A]);const q=a.useCallback(()=>{var s;if(!n)return;const e=y.trim().toLowerCase();if(!e)return;const r=n.entities.find(c=>{var E;return(c.name.toLowerCase()+" "+(((E=c.conceptual)==null?void 0:E.name.toLowerCase())??"")+" "+c.attributes.map(U=>U.name.toLowerCase()).join(" ")).includes(e)});r&&((s=i.current)==null||s.focusEntity(r.id))},[n,y]);return a.useEffect(()=>{const e=r=>{var c,L,E;const s=(c=document.activeElement)==null?void 0:c.tagName;s==="INPUT"||s==="TEXTAREA"||s==="SELECT"||(r.key==="/"&&(r.preventDefault(),(L=document.getElementById("mdl-search"))==null||L.focus()),r.key==="n"&&!d&&((E=i.current)==null||E.newEntity()),r.key==="Escape"&&(k(null),v(""),x(null)))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[d]),b?t.jsxs("div",{className:"splash error",children:[t.jsxs("h1",{children:["◮"," Modelith"]}),t.jsx("p",{children:"Could not load the model:"}),t.jsx("pre",{children:b}),t.jsxs("p",{children:["Is ",t.jsx("code",{children:"mdl serve"})," pointed at a model directory?"]})]}):n?t.jsxs("div",{className:"app",children:[!I&&t.jsx(Y,{doc:n,diagnostics:T,query:y,onQuery:v,onSubmitQuery:q,showTypes:N,onToggleTypes:()=>C(e=>!e),onFitView:()=>{var e;return(e=i.current)==null?void 0:e.fitView()},onRelayout:()=>{var e;return(e=i.current)==null?void 0:e.relayout()},onRefresh:h,saColors:M,readOnly:d,dirty:w,panelTab:j,onPanelTab:e=>x(r=>r===e?null:e),onNewEntity:()=>{var e;return(e=i.current)==null?void 0:e.newEntity()}}),t.jsxs("div",{className:"canvas-wrap",children:[t.jsx(H,{doc:n,caps:Q,exec:$,selectedId:j?null:S,onSelect:k,query:y,showTypes:N,onError:p,handleRef:i}),j&&t.jsx(J,{tab:j,onClose:()=>x(null),readOnly:d,refreshKey:g,onModelChanged:h,onFocusEntity:e=>{var r;x(null),(r=i.current)==null||r.focusEntity(e)}}),f&&t.jsx("div",{className:"toast",children:f})]})]}):t.jsxs("div",{className:"splash",children:["◮"," loading model…"]})}function O(){return t.jsx(X,{children:t.jsx(Z,{})})}_.createRoot(document.getElementById("root")).render(t.jsx(V.StrictMode,{children:t.jsx(O,{})})); diff --git a/packages/server/src/mdl_server/static/assets/sme-Sc2j0EUl.js b/packages/server/src/mdl_server/static/assets/sme-Sc2j0EUl.js new file mode 100644 index 0000000..1ba872f --- /dev/null +++ b/packages/server/src/mdl_server/static/assets/sme-Sc2j0EUl.js @@ -0,0 +1,2 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ModelDiagram-gE_Z16kV.js","assets/client-DOmNpTln.js","assets/styles-BTZUJ0jx.js","assets/styles-D49vPB68.css"])))=>i.map(i=>d[i]); +import{r as n,j as e,c as Ae,R as Re}from"./client-DOmNpTln.js";import{p as je,b as xe,c as $e,e as Me,i as De,d as fe,h as Pe,j as be,R as Oe,M as Ie,O as Te,L as Le,k as Be,l as Fe,A as qe,m as ze,n as We,o as Ge,q as He,s as Ke,f as le,r as Ve,t as Ue,u as Ye}from"./styles-BTZUJ0jx.js";/* empty css */const Qe="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function ce(s,t){let a="";for(let r=0;r>=5n;return a}function ge(){const s=BigInt(Date.now())&(1n<<48n)-1n,t=new Uint8Array(10);crypto.getRandomValues(t);let a=0n;for(const r of t)a=a<<8n|BigInt(r);return ce(s,10)+ce(a,16)}const Je={create_entity:["id","conceptual_id"],create_relationship:["id","from_fk_id"],create_subject_area:["id"],create_term:["id"],create_domain:["id"],create_code_set:["id"],create_key_group:["id"],create_category:["id"],add_attribute:["id"]};function Xe(s,t){const a=Je[s];if(!a)return t;const r={...t};for(const i of a)r[i]||(r[i]=ge());return r}function ve(s,t){if(s.startsWith("create_")||s==="add_attribute")return`${s}:${t.id??t.attribute_id}`;const a=t.id??t.entity_id??"",r=t.attribute_id??"";return r?`${s}:${a}:${r}`:`${s}:${a}`}function Ze({subjectArea:s,describe:t}){const[a,r]=n.useState([]),[i,x]=n.useState(null),[c,l]=n.useState(!1),u=n.useRef(null),N=n.useCallback(async(m,v)=>{v=Xe(m,v),m==="set_alignment"&&v.status===void 0&&(v={...v,status:"proposed"});const S=ve(m,v),{label:C,before:T,after:_}=t(m,v);return r(b=>{const k=b.filter(E=>E.key!==S);if(m.startsWith("delete_")){const E=v.id??v.entity_id;if(E&&b.some(o=>o.op.startsWith("create_")&&o.payload.id===E))return k.filter(o=>o.payload.id!==E)}return[...k,{op:m,payload:v,label:C,before:T,after:_,key:S}]}),{ok:!0,fingerprint:"",created_id:v.id??null,diagnostics:[]}},[t]);n.useEffect(()=>{if(!a.length){x(null);return}const m=setTimeout(()=>{var S;(S=u.current)==null||S.abort();const v=new AbortController;u.current=v,l(!0),je(a.map(C=>({op:C.op,payload:C.payload})),s,v.signal).then(x).catch(C=>{C.name!=="AbortError"&&x(null)}).finally(()=>l(!1))},250);return()=>clearTimeout(m)},[a,s]);const p=n.useCallback(m=>{r(v=>v.filter(S=>S.key!==m))},[]),h=n.useCallback(()=>r([]),[]);return n.useMemo(()=>({pending:a,previewDoc:(i==null?void 0:i.model)??null,previewDiff:(i==null?void 0:i.diff)??null,diagnostics:(i==null?void 0:i.diagnostics)??[],failure:i&&i.failed_index!==null?{index:i.failed_index,error:i.error??"invalid change"}:null,busy:c,exec:N,drop:p,clear:h}),[a,i,c,N,p,h])}function es(s){const t=new Map;for(const r of s)for(const i of["id","conceptual_id","from_fk_id"]){const x=r.payload[i];r.op.startsWith("create_")&&typeof x=="string"&&t.set(x,r.key)}if(!t.size)return new Set;const a=new Set;for(const r of s)if(!r.op.startsWith("create_"))for(const i of Object.values(r.payload))typeof i=="string"&&t.has(i)&&(a.add(r.key),a.add(t.get(i)));return a}function ss({user:s}){const[t,a]=n.useState(null);return n.useEffect(()=>{xe(s).then(a).catch(()=>{})},[s]),!(t!=null&&t.ok)||!t.git?null:t.read_only?e.jsxs("div",{className:"git-banner",children:[e.jsx("code",{children:t.branch}),e.jsx("span",{children:"browse only — editing is disabled on this deployment"})]}):t.dirty?e.jsxs("div",{className:"git-banner warn",children:[e.jsx("code",{children:t.branch}),e.jsx("span",{children:"uncommitted changes in the working tree — a proposal will be refused until they are committed or discarded"})]}):t.on_base?e.jsxs("div",{className:"git-banner",children:[e.jsx("code",{children:t.branch}),e.jsx("span",{children:"protected — your edits become a pull request"})]}):e.jsxs("div",{className:"git-banner",children:[e.jsx("code",{children:t.branch}),e.jsx("span",{children:"your proposal branch"}),t.behind?e.jsxs("span",{className:"dim",children:["· ",t.base_branch," is ",t.behind," ahead"]}):null]})}function ns({exec:s,canEdit:t,onImported:a}){const[r,i]=n.useState(null),[x,c]=n.useState([]),[l,u]=n.useState("postgres"),N=n.useRef(null);n.useEffect(()=>{$e().then(h=>c(h.formats)).catch(()=>c([]))},[]),n.useEffect(()=>{if(!r)return;const h=m=>{N.current&&!N.current.contains(m.target)&&i(null)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[r]);const p=x.find(h=>h.id==="sql");return e.jsxs("div",{className:"ie-wrap",ref:N,children:[e.jsx("button",{className:"erd-action ghost"+(r==="export"?" on":""),onClick:()=>i(r==="export"?null:"export"),children:"Export ▾"}),t&&e.jsx("button",{className:"erd-action ghost"+(r==="import"?" on":""),onClick:()=>i(r==="import"?null:"import"),children:"Import ▾"}),r==="export"&&e.jsxs("div",{className:"ie-menu",role:"menu",children:[(p==null?void 0:p.dialects)&&e.jsxs("label",{className:"ie-dialect",children:[e.jsx("span",{children:"SQL dialect"}),e.jsx("select",{value:l,onChange:h=>u(h.target.value),children:p.dialects.map(h=>e.jsx("option",{value:h,children:h},h))})]}),x.map(h=>e.jsx("a",{className:"ie-item",href:Me(h.id,h.id==="sql"?l:void 0),download:!0,onClick:()=>i(null),children:h.label},h.id))]}),r==="import"&&e.jsx(as,{exec:s,onClose:()=>i(null),onImported:h=>{i(null),a==null||a(h)}})]})}const oe=[{id:"sql",label:"SQL DDL",hint:"CREATE TABLE … PRIMARY KEY / FOREIGN KEY"},{id:"mermaid",label:"Mermaid erDiagram",hint:"structural: entities, attributes, relationships"},{id:"json-schema",label:"JSON Schema",hint:"each object definition becomes an entity"}];function as({exec:s,onClose:t,onImported:a}){var _;const[r,i]=n.useState("sql"),[x,c]=n.useState("postgres"),[l,u]=n.useState(""),[N,p]=n.useState(!1),[h,m]=n.useState(null),[v,S]=n.useState([]),C=b=>{b&&b.text().then(u).catch(()=>m("could not read that file"))},T=async()=>{p(!0),m(null),S([]);try{const b=await De(r,l,r==="sql"?x:void 0);if(!b.changes.length){m(b.warnings[0]??"nothing to import from that document"),p(!1);return}for(const k of b.changes)await s(k.op,k.payload);S(b.warnings),a(b.tables)}catch(b){m(b instanceof Error?b.message:String(b))}finally{p(!1)}};return e.jsxs("div",{className:"ie-menu ie-import",role:"dialog",children:[e.jsx("div",{className:"ie-tabs",children:oe.map(b=>e.jsx("button",{className:"ie-tab"+(r===b.id?" active":""),onClick:()=>i(b.id),children:b.label},b.id))}),e.jsx("p",{className:"ie-hint",children:(_=oe.find(b=>b.id===r))==null?void 0:_.hint}),r==="sql"&&e.jsxs("label",{className:"ie-dialect",children:[e.jsx("span",{children:"dialect"}),e.jsx("select",{value:x,onChange:b=>c(b.target.value),children:["postgres","snowflake","mysql","duckdb"].map(b=>e.jsx("option",{children:b},b))})]}),e.jsx("textarea",{className:"ie-textarea",placeholder:`Paste ${r} here, or choose a file…`,value:l,onChange:b=>u(b.target.value),rows:8}),e.jsx("input",{type:"file",className:"ie-file",accept:".sql,.mmd,.md,.json,.txt",onChange:b=>{var k;return C(((k=b.target.files)==null?void 0:k[0])??null)}}),r==="mermaid"&&e.jsx("p",{className:"ie-warn",children:"Mermaid is a diagram format: types and keys are approximate and relationships are inferred from the lines."}),v.map((b,k)=>e.jsx("p",{className:"ie-warn",children:b},k)),h&&e.jsx("p",{className:"ie-error",children:h}),e.jsxs("div",{className:"ie-foot",children:[e.jsx("button",{className:"erd-action ghost",onClick:t,children:"Cancel"}),e.jsx("button",{className:"erd-action",disabled:N||!l.trim(),onClick:T,children:N?"Importing…":"Import & review"})]})]})}function ts({exec:s,canEdit:t,stagedMembers:a}){const[r,i]=n.useState([]),[x,c]=n.useState(""),[l,u]=n.useState(null),[N,p]=n.useState(""),[h,m]=n.useState(new Set),[v,S]=n.useState("ancestors"),[C,T]=n.useState(1),[_,b]=n.useState(null),[k,E]=n.useState(new Set),[$,o]=n.useState(null);n.useEffect(()=>{fe().then(d=>{i(d.subject_areas),c(y=>{var M;return y||((M=d.subject_areas[0])==null?void 0:M.id)||""})}).catch(d=>o(String(d)))},[]),n.useEffect(()=>{x&&(b(null),m(new Set),Pe(x).then(u).catch(d=>o(String(d))))},[x]);const A=n.useMemo(()=>a[x]??(l==null?void 0:l.members)??[],[a,x,l]),R=n.useMemo(()=>{const d=new Map;for(const y of[...(l==null?void 0:l.included)??[],...(l==null?void 0:l.available)??[]])d.set(y.id,y);return d},[l]),D=N.trim().toLowerCase(),L=d=>!D||d.name.toLowerCase().includes(D),j=n.useMemo(()=>new Set(A),[A]),P=n.useMemo(()=>A.map(d=>R.get(d)).filter(d=>!!d&&L(d)),[A,R,D]),F=n.useMemo(()=>[...R.values()].filter(d=>!j.has(d.id)&&L(d)),[R,j,D]),O=n.useCallback(d=>{if(!l)return;const y=d.filter(z=>!(l.members??[]).includes(z)).length,M=(l.members??[]).filter(z=>!d.includes(z)).length;s("set_subject_area_members",{id:l.id,members:d,__label:`${l.name}: ${d.length} objects (+${y} −${M})`})},[l,s]),q=(d,y)=>{const M=y?[...A,...d.filter(z=>!j.has(z))]:A.filter(z=>!d.includes(z));O(M),m(new Set)},W=(d,y,M)=>{const z=new Set(d);z.has(y)?z.delete(y):z.add(y),M(z)},U=()=>{if(!l)return;const d=h.size?[...h]:A;if(!d.length){o("add an object first, or select one to expand from");return}o(null),be(l.id,{seeds:d,direction:v,levels:C}).then(y=>{b(y.hops),E(new Set(y.added))}).catch(y=>o(String(y)))},V=()=>{q([...k],!0),b(null)};if($&&!l)return e.jsx("p",{className:"sme-splash error",children:$});if(!r.length)return e.jsx("p",{className:"sme-placeholder",children:"No subject areas yet."});const g=((l==null?void 0:l.inconsistent)??[]).filter(d=>!j.has(d));return e.jsxs("div",{className:"sa-editor",children:[e.jsx("nav",{className:"sme-nav",children:r.map(d=>e.jsxs("button",{className:"sme-sa"+(d.id===x?" active":""),onClick:()=>c(d.id),title:d.definition??void 0,children:[d.name,e.jsx("span",{className:"sme-sa-count",children:(a[d.id]??d.members).length})]},d.id))}),e.jsxs("div",{className:"sa-main",children:[e.jsxs("div",{className:"sa-head",children:[e.jsx("h2",{children:(l==null?void 0:l.name)??"…"}),(l==null?void 0:l.definition)&&e.jsx("p",{className:"sme-muted",children:l.definition}),e.jsx("input",{className:"sme-search sa-filter",type:"search",placeholder:"Filter both lists…",value:N,onChange:d=>p(d.target.value)})]}),g.length>0&&t&&e.jsxs("div",{className:"sa-nudge",children:[g.length," object",g.length>1?"s are":" is"," homed in this area but not included.",e.jsxs("button",{className:"sme-link",onClick:()=>q(g,!0),children:["Add ",g.length>1?"them all":"it"]})]}),e.jsxs("div",{className:"sa-panes",children:[e.jsx(J,{title:`Available (${F.length})`,rows:F,picked:h,onToggle:d=>W(h,d,m),homedHere:(l==null?void 0:l.homed_here)??[]}),e.jsxs("div",{className:"sa-controls",children:[e.jsx("button",{className:"sme-secondary",disabled:!t||!h.size,onClick:()=>q([...h].filter(d=>!j.has(d)),!0),title:"Add the selected objects",children:"→"}),e.jsx("button",{className:"sme-secondary",disabled:!t||!F.length,onClick:()=>q(F.map(d=>d.id),!0),title:"Add everything matching the filter",children:"»"}),e.jsx("button",{className:"sme-secondary",disabled:!t||!h.size,onClick:()=>q([...h].filter(d=>j.has(d)),!1),title:"Remove the selected objects",children:"←"}),e.jsx("button",{className:"sme-secondary",disabled:!t||!P.length,onClick:()=>q(P.map(d=>d.id),!1),title:"Remove everything matching the filter",children:"«"})]}),e.jsx(J,{title:`Included (${P.length})`,rows:P,picked:h,onToggle:d=>W(h,d,m),homedHere:(l==null?void 0:l.homed_here)??[]})]}),e.jsxs("div",{className:"sa-expand",children:[e.jsx("h3",{children:"Add related objects"}),e.jsxs("div",{className:"sa-expand-row",children:[e.jsxs("select",{value:v,onChange:d=>S(d.target.value),children:[e.jsx("option",{value:"ancestors",children:"ancestors — the parents its keys point at"}),e.jsx("option",{value:"descendants",children:"descendants — what points at it"}),e.jsx("option",{value:"both",children:"both"})]}),e.jsxs("label",{children:["levels",e.jsx("input",{type:"number",min:1,max:10,value:C,onChange:d=>T(Math.max(1,Math.min(10,Number(d.target.value))))})]}),e.jsx("button",{className:"sme-secondary",onClick:U,disabled:!t,children:"Preview"})]}),$&&e.jsx("p",{className:"sme-error-line",children:$}),_&&e.jsxs("div",{className:"sa-hops",children:[_.length===0&&e.jsx("p",{className:"sme-muted",children:"nothing new to add"}),_.map(d=>e.jsxs("label",{className:"sa-hop",children:[e.jsx("input",{type:"checkbox",checked:k.has(d.id),onChange:()=>W(k,d.id,E)}),e.jsx("span",{className:"sa-hop-name",children:d.name}),e.jsxs("span",{className:"sa-hop-why",children:["via ",d.via_name," · ",d.direction.replace(/s$/,""),", level ",d.level]})]},d.id)),_.length>0&&e.jsxs("div",{className:"sa-hop-actions",children:[e.jsx("button",{className:"sme-secondary",onClick:()=>b(null),children:"Cancel"}),e.jsxs("button",{className:"sme-primary",onClick:V,disabled:!k.size,children:["Add ",k.size," object",k.size===1?"":"s"]})]})]})]})]})]})}function J({title:s,rows:t,picked:a,onToggle:r,homedHere:i}){const x=n.useMemo(()=>new Set(i),[i]);return e.jsxs("div",{className:"sa-pane",children:[e.jsx("h3",{children:s}),e.jsxs("ul",{children:[t.map(c=>e.jsxs("li",{className:"sa-row"+(a.has(c.id)?" picked":""),onClick:()=>r(c.id),children:[e.jsx("input",{type:"checkbox",readOnly:!0,checked:a.has(c.id)}),e.jsx("span",{className:"sa-row-name",children:c.name}),x.has(c.id)?e.jsx("span",{className:"sme-badge",children:"home"}):e.jsx("span",{className:"sme-badge borrowed",children:"borrowed"})]},c.id)),!t.length&&e.jsx("li",{className:"sme-empty",children:"nothing here"})]})]})}function rs({objects:s,onCreate:t,onClose:a}){const[r,i]=n.useState(""),[x,c]=n.useState(""),[l]=n.useState(s),[u,N]=n.useState([]),[p,h]=n.useState(new Set),[m,v]=n.useState(""),[S,C]=n.useState("ancestors"),[T,_]=n.useState(1),[b,k]=n.useState(null),[E,$]=n.useState(new Set),[o,A]=n.useState(""),[R,D]=n.useState(null);n.useEffect(()=>{fe().then(g=>{g.subject_areas[0]&&A(g.subject_areas[0].id)}).catch(()=>{})},[]);const L=n.useMemo(()=>new Set(u),[u]),j=m.trim().toLowerCase(),P=g=>!j||g.name.toLowerCase().includes(j),F=n.useMemo(()=>u.map(g=>l.find(d=>d.id===g)).filter(g=>!!g&&P(g)),[u,l,j]),O=n.useMemo(()=>l.filter(g=>!L.has(g.id)&&P(g)),[l,L,j]),q=(g,d)=>{N(y=>d?[...y,...g.filter(M=>!y.includes(M))]:y.filter(M=>!g.includes(M))),h(new Set)},W=(g,d,y)=>{const M=new Set(g);M.has(d)?M.delete(d):M.add(d),y(M)},U=()=>{const g=p.size?[...p]:u;if(!g.length){D("pick an object to expand from first");return}o&&(D(null),be(o,{seeds:g,direction:S,levels:T}).then(d=>{const y=d.hops.filter(M=>!L.has(M.id));k(y),$(new Set(y.map(M=>M.id)))}).catch(d=>D(String(d))))},V=()=>{r.trim()&&t(r.trim(),x.trim(),u)};return e.jsx("div",{className:"sme-modal-backdrop",onClick:a,children:e.jsxs("div",{className:"sme-modal sa-modal",onClick:g=>g.stopPropagation(),children:[e.jsx("h2",{children:"New subject area"}),e.jsx("p",{className:"sme-hint",children:"A subject area is a filtered view of the model. Name it and choose what it contains — both land as one proposal."}),e.jsxs("div",{className:"sme-field-row",children:[e.jsxs("label",{className:"sme-field",children:[e.jsx("span",{children:"Name"}),e.jsx("input",{autoFocus:!0,value:r,placeholder:"e.g. UseCase-ApraStressTesting",onChange:g=>i(g.target.value),onKeyDown:g=>g.key==="Enter"&&u.length===0&&V()})]}),e.jsxs("label",{className:"sme-field",children:[e.jsx("span",{children:"Definition (optional)"}),e.jsx("input",{value:x,placeholder:"what this view is for",onChange:g=>c(g.target.value)})]})]}),e.jsx("input",{className:"sme-search sa-filter",type:"search",placeholder:"Filter both lists…",value:m,onChange:g=>v(g.target.value)}),e.jsxs("div",{className:"sa-panes",children:[e.jsx(J,{title:`Available (${O.length})`,rows:O,picked:p,onToggle:g=>W(p,g,h),homedHere:[]}),e.jsxs("div",{className:"sa-controls",children:[e.jsx("button",{className:"sme-secondary",disabled:!p.size,onClick:()=>q([...p].filter(g=>!L.has(g)),!0),title:"Add the selected objects",children:"→"}),e.jsx("button",{className:"sme-secondary",disabled:!O.length,onClick:()=>q(O.map(g=>g.id),!0),title:"Add everything matching the filter",children:"»"}),e.jsx("button",{className:"sme-secondary",disabled:!p.size,onClick:()=>q([...p].filter(g=>L.has(g)),!1),title:"Remove the selected objects",children:"←"}),e.jsx("button",{className:"sme-secondary",disabled:!F.length,onClick:()=>q(F.map(g=>g.id),!1),title:"Remove everything matching the filter",children:"«"})]}),e.jsx(J,{title:`Included (${F.length})`,rows:F,picked:p,onToggle:g=>W(p,g,h),homedHere:[]})]}),e.jsxs("div",{className:"sa-expand",children:[e.jsx("h3",{children:"Add related objects"}),e.jsxs("div",{className:"sa-expand-row",children:[e.jsxs("select",{value:S,onChange:g=>C(g.target.value),children:[e.jsx("option",{value:"ancestors",children:"ancestors — the parents its keys point at"}),e.jsx("option",{value:"descendants",children:"descendants — what points at it"}),e.jsx("option",{value:"both",children:"both"})]}),e.jsxs("label",{children:["levels",e.jsx("input",{type:"number",min:1,max:10,value:T,onChange:g=>_(Math.max(1,Math.min(10,Number(g.target.value))))})]}),e.jsx("button",{className:"sme-secondary",onClick:U,disabled:!o,title:o?"Preview related objects to add":"Available once the model has at least one saved subject area to walk the graph from",children:"Preview"})]}),b&&e.jsxs("div",{className:"sa-hops",children:[b.length===0&&e.jsx("p",{className:"sme-muted",children:"nothing new to add"}),b.map(g=>e.jsxs("label",{className:"sa-hop",children:[e.jsx("input",{type:"checkbox",checked:E.has(g.id),onChange:()=>W(E,g.id,$)}),e.jsx("span",{className:"sa-hop-name",children:g.name}),e.jsxs("span",{className:"sa-hop-why",children:["via ",g.via_name," · ",g.direction.replace(/s$/,""),", level ",g.level]})]},g.id)),b.length>0&&e.jsxs("div",{className:"sa-hop-actions",children:[e.jsx("button",{className:"sme-secondary",onClick:()=>k(null),children:"Cancel"}),e.jsxs("button",{className:"sme-primary",disabled:!E.size,onClick:()=>{q([...E],!0),k(null)},children:["Add ",E.size]})]})]})]}),R&&e.jsx("p",{className:"sme-error-line",children:R}),e.jsxs("div",{className:"sme-modal-foot",children:[e.jsx("button",{className:"sme-secondary",onClick:a,children:"Cancel"}),e.jsxs("button",{className:"sme-primary",disabled:!r.trim(),onClick:V,children:["Create",u.length>0&&` with ${u.length} object${u.length===1?"":"s"}`]})]})]})})}const is=new Set(["set_definition","set_stewardship","set_subject_area","set_pattern","rename_entity","add_attribute","update_attribute","delete_attribute","set_alignment","clear_alignment","set_term_map","clear_term_map","update_synonyms","set_object_definition","set_subject_area_members","create_subject_area","update_subject_area","create_entity","delete_entity","create_relationship","rename_relationship","update_relationship","delete_relationship"]);function ls({doc:s,subjectArea:t,onSubjectArea:a,exec:r,canEdit:i,direct:x=!1,onSelectEntity:c,onImported:l,busy:u}){var $;const[N,p]=n.useState(null),[h,m]=n.useState(null),[v,S]=n.useState(!1),[C,T]=n.useState(null),[_]=n.useState(""),b=n.useRef(null),k=n.useMemo(()=>({canEdit:i,mode:x?"direct":"staged",allow:x?void 0:is,canArbitrate:x,canCommit:x}),[i,x]),E=n.useCallback(o=>{p(o),o&&(c==null||c(o))},[c]);return e.jsxs("div",{className:"sme-model-view",children:[e.jsxs("nav",{className:"sme-nav",children:[e.jsxs("div",{className:"sme-nav-head",children:[e.jsx("span",{children:"Subject areas"}),i&&e.jsx("button",{className:"sme-nav-add",title:"New subject area",onClick:()=>S(!0),children:"+"})]}),e.jsxs("button",{className:"sme-sa"+(t===""?" active":""),onClick:()=>a(""),children:["Whole model",e.jsx("span",{className:"sme-sa-count",children:(($=s.counts)==null?void 0:$.entities_total)??s.entities.length})]}),s.subject_areas.map(o=>e.jsxs("button",{className:"sme-sa"+(t===o.id?" active":""),onClick:()=>a(o.id),title:o.definition??void 0,children:[o.name,e.jsx("span",{className:"sme-sa-count",children:o.member_count??0})]},o.id))]}),v&&e.jsx(rs,{objects:s.entities.flatMap(o=>o.conceptual?[{id:o.conceptual.id,kind:"conceptual_entity",name:o.conceptual.name,definition:o.conceptual.definition??null,synonyms:[],subject_area:o.conceptual.subject_area??null,stewardship:null,ontology:null,where_used:[]}]:[]),onClose:()=>S(!1),onCreate:(o,A,R)=>{const D=ge();r("create_subject_area",{name:o,...A?{definition:A}:{},id:D}),R.length&&r("set_subject_area_members",{id:D,members:R}),S(!1),a(D)}}),e.jsxs("div",{className:"erd-wrap",children:[e.jsxs("div",{className:"erd-bar",children:[e.jsxs("span",{className:"erd-count",children:[s.entities.length," entities · ",s.relationships.length," relationships",s.scope&&" · scoped"]}),i&&e.jsx("button",{className:"erd-action",onClick:()=>{var o;return(o=b.current)==null?void 0:o.newEntity()},title:"Add an entity (n)",children:"+ Entity"}),e.jsx("span",{className:"erd-hint",children:"drag between entities to relate them"}),e.jsxs("span",{className:"erd-panels",children:[e.jsx("button",{className:"erd-action ghost",onClick:()=>{var o;return(o=b.current)==null?void 0:o.relayout()},title:"Auto-arrange the diagram",children:"Re-layout"}),e.jsx("button",{className:"erd-action ghost",onClick:()=>{var o;return(o=b.current)==null?void 0:o.fitView()},title:"Fit the whole model in view",children:"Fit"}),e.jsx("button",{className:"erd-action ghost"+(h==="ontology"?" on":""),onClick:()=>m(o=>o==="ontology"?null:"ontology"),children:"Ontology"}),e.jsx("button",{className:"erd-action ghost"+(h==="layers"?" on":""),onClick:()=>m(o=>o==="layers"?null:"layers"),children:"Layers"}),e.jsx(ns,{exec:r,canEdit:i,onImported:l})]}),u&&e.jsx("span",{className:"erd-busy",children:"updating…"}),!i&&e.jsx("span",{className:"sme-chip",children:"read-only"}),C&&e.jsx("span",{className:"erd-error",children:C})]}),e.jsxs("div",{className:"erd-canvas canvas-wrap",children:[e.jsx(Oe,{children:e.jsx(Ie,{doc:s,caps:k,exec:r,selectedId:N,onSelect:E,query:_,onError:T,handleRef:b})}),h&&e.jsxs("aside",{className:"side-panel",children:[e.jsxs("div",{className:"detail-header",children:[e.jsx("h2",{children:h==="ontology"?"Ontology":"Ontology layers"}),e.jsx("button",{className:"icon-btn",onClick:()=>m(null),children:"✕"})]}),h==="ontology"?e.jsx(Te,{}):e.jsx(Le,{refreshKey:0,onFocusEntity:o=>{var A;m(null),(A=b.current)==null||A.focusEntity(o)}})]})]})]})]})}function cs({user:s,onView:t}){const[a,r]=n.useState(null),[i,x]=n.useState(null);if(n.useEffect(()=>{Be(s).then(r).catch(l=>x(String(l)))},[s]),i)return e.jsx("p",{className:"sme-splash error",children:i});if(!a)return e.jsx("div",{className:"sme-splash",children:"◮ looking for your proposals…"});if(!a.git)return e.jsx("p",{className:"sme-placeholder",children:"This model isn't in a git repository."});const c=a.proposals.filter(l=>!l.merged).length;return e.jsxs("div",{className:"pr-wrap",children:[e.jsxs("div",{className:"pr-head",children:[e.jsx("h2",{children:"My proposals"}),e.jsxs("span",{className:"meta",children:[c," open · base: ",a.base]})]}),!a.proposals.length&&e.jsx("p",{className:"sme-placeholder",children:"Nothing proposed yet. Edits you submit for review will appear here."}),a.proposals.map(l=>e.jsx(ds,{p:l,gh:a.gh,onView:()=>t(l.branch)},l.branch)),!a.gh&&a.proposals.length>0&&e.jsxs("div",{className:"pr-degrade",children:["Review status isn't available here (",e.jsx("code",{children:"gh"})," is not installed or not signed in). Branch, contents, merge state and conflicts all still come from git — each card links out to the compare view."]})]})}function os(s,t){var a,r;return s.merged?{kind:"accepted",text:"✅ Accepted"}:s.pushed?t&&((a=s.pr)==null?void 0:a.state)==="CLOSED"?{kind:"declined",text:"✖ Declined"}:t&&((r=s.pr)==null?void 0:r.reviews)==="CHANGES_REQUESTED"?{kind:"changes",text:"💬 Changes requested"}:{kind:"awaiting",text:"⏳ Awaiting review"}:{kind:"local",text:"📥 Saved locally"}}function ds({p:s,gh:t,onView:a}){const r=os(s,t);return e.jsxs("div",{className:"pr-card"+(r.kind==="attention"?" attention":""),children:[e.jsxs("div",{className:"pr-top",children:[e.jsx("span",{className:"pr-title",children:s.title}),e.jsx("span",{className:"pr-chip "+r.kind,children:r.text})]}),e.jsxs("div",{className:"pr-branch",children:[s.branch," · ",s.created,s.behind>0&&` · ${s.behind} behind`]}),e.jsxs("div",{className:"pr-foot",children:[e.jsx("span",{className:"pr-link",children:s.merged?e.jsxs(e.Fragment,{children:["merged",t&&s.pr?` · PR #${s.pr.number}`:""]}):s.pushed?t&&s.pr?e.jsxs("a",{href:s.pr.url,target:"_blank",rel:"noreferrer",children:["PR #",s.pr.number]}):s.compare_url?e.jsx("a",{href:s.compare_url,target:"_blank",rel:"noreferrer",children:"open the compare view →"}):"pushed":"not sent yet — no connection to the shared repo"}),e.jsx("span",{className:"pr-btns",children:e.jsx("button",{className:"sme-secondary",onClick:a,children:"View"})})]})]})}function hs({changes:s,routeAdvice:t,identity:a,user:r,onUser:i,onDrop:x,onClose:c,onProposed:l}){const u=!!(a&&a.source!=="anonymous"),[N,p]=n.useState(r||(localStorage.getItem("mdl.sme.user")??"")),[h,m]=n.useState(s.length===1?`Update ${s[0].label.toLowerCase()}`:"Glossary updates"),[v,S]=n.useState(""),[C,T]=n.useState(!1),_=Ne(C?v:h),[b,k]=n.useState(""),[E,$]=n.useState(!1),[o,A]=n.useState(null),[R,D]=n.useState(null),L=()=>{!u&&!N.trim()||(u||(localStorage.setItem("mdl.sme.user",N.trim()),i==null||i(N.trim())),$(!0),D(null),Fe({user:u?"":N.trim(),slug:_,title:h,body:b.trim(),changes:s.map(j=>({op:j.op,payload:j.payload}))}).then(A).catch(j=>D(j instanceof qe?j.message:String(j))).finally(()=>$(!1)))};return o!=null&&o.ok?e.jsx("div",{className:"sme-modal-backdrop",onClick:()=>l(o),children:e.jsxs("div",{className:"sme-modal",onClick:j=>j.stopPropagation(),children:[e.jsx("h2",{children:"✓ Sent for review"}),e.jsx("p",{children:o.message}),o.pr_url&&e.jsx("p",{children:e.jsx("a",{href:o.pr_url,target:"_blank",rel:"noreferrer",children:"View pull request →"})}),o.compare_url&&e.jsx("p",{children:e.jsx("a",{href:o.compare_url,target:"_blank",rel:"noreferrer",children:"Open the pull request →"})}),e.jsxs("p",{className:"sme-muted",children:["Your suggestion is on branch ",e.jsx("code",{children:o.branch}),". A steward will review it."]}),e.jsx("div",{className:"sme-modal-foot",children:e.jsx("button",{className:"sme-primary",onClick:()=>l(o),children:"Done"})})]})}):e.jsx("div",{className:"sme-modal-backdrop",onClick:c,children:e.jsxs("div",{className:"sme-modal",onClick:j=>j.stopPropagation(),children:[e.jsxs("div",{className:"sme-card-head",children:[e.jsx("h2",{children:"Submit for review"}),e.jsx("button",{className:"sme-secondary",onClick:c,children:"✕"})]}),e.jsx("h3",{children:"Your changes"}),e.jsx("ul",{className:"sme-diff",children:s.map((j,P)=>e.jsxs("li",{children:[e.jsxs("div",{className:"sme-diff-head",children:[e.jsx("b",{children:j.label}),e.jsx("button",{className:"sme-link danger",onClick:()=>x(P),children:"discard"})]}),e.jsx("div",{className:"sme-diff-before",children:j.before}),e.jsx("div",{className:"sme-diff-after",children:j.after})]},P))}),u?e.jsxs("p",{className:"sme-signed-in",children:["Signed in as ",e.jsx("strong",{children:a.name}),a.email?` (${a.email})`:""," — this proposal is attributed to you."]}):e.jsxs("label",{className:"sme-field",children:[e.jsx("span",{children:"Your name (for attribution)"}),e.jsx("input",{value:N,onChange:j=>p(j.target.value),placeholder:"e.g. a.hough"})]}),e.jsxs("label",{className:"sme-field",children:[e.jsx("span",{children:"Title"}),e.jsx("input",{value:h,onChange:j=>m(j.target.value)})]}),e.jsxs("label",{className:"sme-field",children:[e.jsx("span",{children:"Branch name (edit to add a ticket id, e.g. PROJ-123)"}),e.jsx("input",{value:C?v:_,onChange:j=>{T(!0),S(j.target.value)},placeholder:"clarify-counterparty"})]}),e.jsxs("label",{className:"sme-field",children:[e.jsx("span",{children:"Note for the reviewer (optional)"}),e.jsx("textarea",{rows:2,value:b,onChange:j=>k(j.target.value)})]}),e.jsx(ms,{cl:t,user:u?a.name:N,changeSlug:_}),R&&e.jsx("p",{className:"sme-error-line",children:R}),e.jsxs("div",{className:"sme-modal-foot",children:[e.jsx("button",{className:"sme-secondary",onClick:c,children:"Keep editing"}),e.jsx("button",{className:"sme-primary",disabled:E||!u&&!N.trim()||s.length===0,onClick:L,children:E?"Submitting…":"Submit for review"})]})]})})}function ms({cl:s,user:t,changeSlug:a}){if(!(s!=null&&s.primary))return null;const r=s.reviewers_actual??s.reviewers,i=Ne(t||"you"),x=s.routes.length>1;return e.jsxs(e.Fragment,{children:[x&&e.jsxs("div",{className:"sub-advice",children:[e.jsx("span",{className:"i",children:"ⓘ"})," These changes span routes"," ",e.jsx("strong",{children:s.routes.join(" and ")}),". The whole proposal will be reviewed as route ",s.primary," (",s.primary_name,") — the strictest gate wins, so it needs"," ",r.join(", ")," plus ",e.jsx("code",{children:s.gates[s.gates.length-1]}),". Proposing the meaning-only changes separately would get them reviewed faster."]}),e.jsxs("div",{className:"sub-dest",children:[e.jsxs("div",{className:"row",children:[e.jsx("span",{className:"k",children:"Goes to"}),e.jsxs("code",{children:["sme/",i,"/",a||"…"]})]}),e.jsxs("div",{className:"row",children:[e.jsx("span",{className:"k",children:"Reviewers"}),e.jsx("span",{children:r.join(", ")})]})]})]})}function Ne(s){return s.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"change"}const us="modulepreload",ps=function(s){return"/"+s},de={},js=function(t,a,r){let i=Promise.resolve();if(a&&a.length>0){document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),l=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));i=Promise.allSettled(a.map(u=>{if(u=ps(u),u in de)return;de[u]=!0;const N=u.endsWith(".css"),p=N?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${p}`))return;const h=document.createElement("link");if(h.rel=N?"stylesheet":us,N||(h.as="script"),h.crossOrigin="",h.href=u,l&&h.setAttribute("nonce",l),document.head.appendChild(h),N)return new Promise((m,v)=>{h.addEventListener("load",m),h.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${u}`)))})}))}function x(c){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=c,window.dispatchEvent(l),!l.defaultPrevented)throw c}return i.then(c=>{for(const l of c||[])l.status==="rejected"&&x(l.reason);return t().catch(x)})};function xs({diff:s,selectable:t,selected:a,onToggle:r}){var l;const[i,x]=n.useState(((l=s.objects[0])==null?void 0:l.ulid)??null),c=n.useMemo(()=>s.objects.find(u=>u.ulid===i)??s.objects[0]??null,[s,i]);return s.objects.length?e.jsxs("div",{className:"rv-body",children:[e.jsx("div",{className:"rv-list",children:s.objects.map(u=>e.jsx(bs,{obj:u,active:u.ulid===((c==null?void 0:c.ulid)??""),checked:(a==null?void 0:a.has(u.ulid))??!0,selectable:t,onSelect:()=>x(u.ulid),onToggle:()=>r==null?void 0:r(u.ulid)},u.ulid))}),e.jsx("div",{className:"rv-detail",children:c&&e.jsx(gs,{obj:c})})]}):e.jsxs("p",{className:"sme-placeholder",children:["No model changes against ",s.base.label,"."]})}function fs(s){return s.renamed?"renamed":s.severity==="breaking"?"breaking":s.change}function bs({obj:s,active:t,checked:a,selectable:r,onSelect:i,onToggle:x}){return e.jsxs("div",{className:"rv-obj"+(t?" active":""),onClick:i,children:[e.jsxs("div",{className:"rv-obj-head",children:[r&&e.jsx("input",{type:"checkbox",checked:a,onClick:c=>c.stopPropagation(),onChange:x,"aria-label":`include ${s.name_before??s.name_after}`}),e.jsx("span",{className:"rv-obj-name",children:s.name_before??s.name_after}),e.jsx("span",{className:"rv-obj-kind",children:s.object_kind_label}),e.jsxs("span",{className:"sev "+(s.renamed?"renamed":s.severity),children:[s.severity==="breaking"&&"⚠ ",fs(s)]})]}),e.jsxs("ul",{className:"rv-obj-fields",children:[s.fields.map((c,l)=>e.jsx("li",{children:c.label},c.field+l)),s.children.flatMap(c=>c.fields.map((l,u)=>e.jsxs("li",{children:[l.label,": ",c.name_before??c.name_after]},c.ulid+u)))]})]})}function gs({obj:s}){const t=s.children.flatMap(a=>a.fields.map(r=>({field:r,on:a.name_before??a.name_after??""})));return e.jsxs(e.Fragment,{children:[e.jsx("h2",{children:s.renamed?`${s.name_before} → ${s.name_after}`:s.name_before??s.name_after}),e.jsxs("div",{className:"rv-detail-kind",children:[s.object_kind_label,s.renamed&&" · renamed",s.path&&e.jsxs("span",{className:"rv-src",children:[" · ",s.path]})]}),s.fields.map((a,r)=>e.jsx(he,{f:a},a.field+r)),t.map(({field:a,on:r},i)=>e.jsx(he,{f:a,on:r},"c"+i)),s.severity==="breaking"&&e.jsxs("div",{className:"rv-note",children:[e.jsx("span",{className:"i",children:"ⓘ"}),e.jsxs("span",{children:["This is a structural change (route B). It will need an architect's review, and CI will run ",e.jsx("code",{children:"mdl drift --check"}),"."]})]})]})}function he({f:s,on:t}){var r,i,x;const a=t?`${s.label}: ${t}`:s.label;if((r=s.breaks)!=null&&r.length)return e.jsxs("div",{className:"rv-section",children:[e.jsx("h3",{children:a}),e.jsxs("div",{className:"rv-break",children:[e.jsxs("div",{className:"rv-break-head",children:[e.jsx("span",{children:"⚠"}),e.jsxs("span",{children:[t??String(s.before??"")," removed"]}),s.detail&&e.jsx("span",{className:"rv-break-meta",children:s.detail})]}),e.jsxs("div",{className:"rv-break-body",children:["This is realised by ",s.breaks.length," dbt model",s.breaks.length>1?"s":"",". Removing it will break ",s.breaks.length>1?"them":"it","."]}),e.jsx("ul",{className:"rv-usage",children:s.breaks.map(c=>e.jsxs("li",{children:[e.jsxs("span",{className:"m",children:["→ ",c.name]}),e.jsxs("span",{className:"p",children:[c.target," · ",c.materialization]})]},c.name))})]})]});if(s.kind==="definition_changed"){const c=String(s.before??""),l=String(s.after??"");return e.jsxs("div",{className:"rv-section",children:[e.jsx("h3",{children:a}),e.jsxs("div",{className:"rv-ba",children:[e.jsxs("div",{className:"rv-ba-col",children:[e.jsx("div",{className:"rv-ba-label",children:"before"}),e.jsx("div",{className:"rv-ba-text",children:ue(c,l,"del")})]}),e.jsxs("div",{className:"rv-ba-col",children:[e.jsx("div",{className:"rv-ba-label",children:"after"}),e.jsx("div",{className:"rv-ba-text",children:ue(l,c,"ins")})]})]})]})}if(Array.isArray(s.before)||Array.isArray(s.after)){const c=new Set(((i=s.before)==null?void 0:i.map(String))??[]),l=new Set(((x=s.after)==null?void 0:x.map(String))??[]),u=[...l].filter(p=>!c.has(p)),N=[...c].filter(p=>!l.has(p));return e.jsxs("div",{className:"rv-section",children:[e.jsx("h3",{children:a}),e.jsxs("div",{className:"rv-chips",children:[u.map(p=>e.jsxs("span",{className:"rv-chip-add",children:["+ ",p]},"a"+p)),N.map(p=>e.jsxs("span",{className:"rv-chip-del",children:["− ",p]},"r"+p))]})]})}return e.jsxs("div",{className:"rv-section",children:[e.jsx("h3",{children:a}),e.jsxs("div",{className:"rv-scalar",children:[e.jsx("span",{className:"from",children:me(s.before)}),e.jsx("span",{className:"arrow",children:"→"}),e.jsx("span",{className:"to",children:me(s.after)})]})]})}function me(s){return s==null||s===""?"—":typeof s=="boolean"?s?"yes":"no":typeof s=="object"?JSON.stringify(s):String(s)}function ue(s,t,a){const r=s.split(/(\s+)/),i=t.split(/(\s+)/),x=m=>m.toLowerCase().replace(/[.,;:]/g,""),c=r.length,l=i.length,u=Array.from({length:c+1},()=>new Array(l+1).fill(0));for(let m=c-1;m>=0;m--)for(let v=l-1;v>=0;v--)u[m][v]=x(r[m])===x(i[v])?u[m+1][v+1]+1:Math.max(u[m+1][v],u[m][v+1]);const N=new Set;let p=0,h=0;for(;p=u[p][h+1]?p++:h++;return r.map((m,v)=>!m.trim()||N.has(v)?e.jsx("span",{children:m},v):a==="del"?e.jsx("del",{children:m},v):e.jsx("ins",{children:m},v))}const vs=n.lazy(()=>js(()=>import("./ModelDiagram-gE_Z16kV.js"),__vite__mapDeps([0,1,2,3])).then(s=>({default:s.ModelDiagram})));function Ns({stagedDiff:s,stagedRoute:t,user:a,onBack:r,onSubmit:i,excluded:x,onToggleObject:c,selectable:l}){const[u,N]=n.useState(null),[p,h]=n.useState(null),[m,v]=n.useState(null),[S,C]=n.useState(null),[T,_]=n.useState(null),[b,k]=n.useState("changes"),E=n.useCallback(()=>{xe(a).then(o=>{C(o);const A=o.base_branch??"main";s?N(s):ze("HEAD").then(R=>R.ok?N(R):_(R.error??"could not read the model")).catch(R=>_(String(R))),t?h(t):We("HEAD").then(h).catch(()=>{}),Ge(A).then(v).catch(()=>{})}).catch(o=>_(String(o)))},[a,s,t]);if(n.useEffect(E,[E]),T)return e.jsxs("div",{className:"rv-shell",children:[e.jsx(pe,{onBack:r,diff:null}),e.jsx("p",{className:"sme-splash error",children:e.jsx("pre",{children:T})})]});if(!u)return e.jsx("div",{className:"sme-splash",children:"◮ reading your changes…"});const $=new Set(u.objects.map(o=>o.ulid).filter(o=>!x.has(o)));return e.jsxs("div",{className:"rv-shell",children:[e.jsx(pe,{onBack:r,diff:u,tab:b,onTab:k}),b==="changes"?e.jsx(xs,{diff:u,selectable:l,selected:$,onToggle:c}):e.jsx(n.Suspense,{fallback:e.jsx("div",{className:"sme-splash",children:"◮ drawing the model…"}),children:e.jsx(vs,{severityByUlid:ws(u)})}),e.jsxs("div",{className:"rv-foot",children:[e.jsx(ys,{cl:p}),e.jsx(Ss,{conf:m,ctx:S}),e.jsxs("div",{className:"rv-actions",children:[e.jsx("button",{className:"sme-secondary",onClick:r,children:"Keep editing"}),e.jsx("button",{className:"sme-primary",disabled:!u.objects.length||(S?!S.can_propose:!1),title:S&&!S.can_propose?"the working tree has uncommitted changes":"",onClick:()=>i(p),children:"Submit for review →"})]})]})]})}function ws(s){const t=new Map;for(const a of s.objects)t.set(a.ulid,a.severity);return t}function pe({onBack:s,diff:t,tab:a,onTab:r}){const i=t==null?void 0:t.counts;return e.jsxs("div",{className:"rv-head",children:[e.jsxs("div",{children:[e.jsx("button",{className:"rv-back",onClick:s,children:"‹ Back to terms"}),e.jsx("h1",{className:"rv-title",children:"Review your changes"}),i&&e.jsxs("div",{className:"rv-sub",children:[i.objects," object",i.objects===1?"":"s"," ·"," ",(i.breaking??0)+(i.additive??0)+(i.cosmetic??0)," changes",(t==null?void 0:t.has_breaking)&&e.jsxs("span",{className:"warn",children:[" · ⚠ ",i.breaking," breaking"]})," · comparing to ",e.jsx("code",{children:t==null?void 0:t.base.label})]})]}),r&&e.jsxs("div",{className:"rv-tabs",children:[e.jsxs("button",{className:"rv-tab"+(a==="changes"?" active":""),onClick:()=>r("changes"),children:["Changes ",(t==null?void 0:t.objects.length)??0]}),e.jsx("button",{className:"rv-tab"+(a==="diagram"?" active":""),onClick:()=>r("diagram"),children:"Diagram"})]})]})}function ys({cl:s}){if(!(s!=null&&s.primary))return null;const t=s.reviewers_actual??s.reviewers;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"rv-route",children:[e.jsxs("span",{className:"rv-route-badge",children:["Route ",s.primary," · ",s.primary_name]}),e.jsx("span",{className:"k",children:"Reviewers"}),e.jsx("span",{children:t.join(", ")}),s.reviewers_actual&&e.jsx("span",{className:"rv-src",children:"from .github/CODEOWNERS"})]}),e.jsxs("div",{className:"rv-gates",children:["CI gates"," ",s.gates.map(a=>e.jsx("code",{children:a},a))]})]})}function Ss({conf:s,ctx:t}){return s!=null&&s.ok?s.clean?e.jsxs("div",{className:"rv-conflict ok",children:[e.jsx("span",{children:"✓"}),e.jsxs("span",{children:["Merges cleanly onto ",s.base]}),s.behind>0&&e.jsxs("span",{className:"detail",children:["· ",s.base," is ",s.behind," commit",s.behind===1?"":"s"," ahead"]}),(t==null?void 0:t.dirty)&&e.jsx("span",{className:"detail",children:"· uncommitted changes in the working tree"})]}):e.jsxs("div",{className:"rv-conflict bad",children:[e.jsx("span",{children:"⚠"}),e.jsxs("span",{children:[s.base," has changed and ",s.files.length," file",s.files.length===1?"":"s"," now conflict"]}),e.jsx("span",{className:"detail",children:s.files.map(a=>a.path).join(", ")})]}):null}function ks({term:s,canEdit:t,pendingCount:a,onEdit:r}){var i,x;return e.jsxs("div",{className:"sme-card",children:[e.jsxs("div",{className:"sme-card-head",children:[e.jsxs("div",{children:[e.jsx("h1",{children:s.name}),((i=s.subject_area)==null?void 0:i.name)&&e.jsx("span",{className:"sme-chip",children:s.subject_area.name}),s.kind==="term"&&e.jsx("span",{className:"sme-chip",children:"glossary term"})]}),t&&e.jsx("button",{className:"sme-primary",onClick:r,children:a>0?"Continue editing":"Suggest an edit"})]}),e.jsx("p",{className:"sme-definition",children:s.definition??e.jsx("em",{children:"No definition yet."})}),s.synonyms.length>0&&e.jsxs("section",{children:[e.jsx("h3",{children:"Also called"}),e.jsx("div",{children:s.synonyms.map(c=>e.jsx("span",{className:"sme-chip",children:c},c))})]}),s.stewardship&&(s.stewardship.owner||s.stewardship.steward)&&e.jsxs("section",{children:[e.jsx("h3",{children:"Who owns this"}),s.stewardship.owner&&e.jsxs("div",{className:"sme-kv",children:[e.jsx("span",{className:"k",children:"owner"}),e.jsx("span",{children:s.stewardship.owner})]}),s.stewardship.steward&&e.jsxs("div",{className:"sme-kv",children:[e.jsx("span",{className:"k",children:"steward"}),e.jsx("span",{children:s.stewardship.steward})]})]}),((x=s.ontology)==null?void 0:x.aligns_to)&&e.jsxs("section",{children:[e.jsx("h3",{children:"Standard it maps to"}),e.jsxs("div",{className:"sme-kv",children:[e.jsx("span",{className:"k",children:"aligned to"}),e.jsx("code",{children:s.ontology.aligns_to}),s.ontology.status==="proposed"&&e.jsx("span",{className:"sme-badge proposed",children:"awaiting architect"})]})]}),e.jsxs("section",{children:[e.jsx("h3",{children:"Where it's used"}),s.where_used.length===0?e.jsx("p",{className:"sme-muted",children:s.kind==="term"?"A glossary term — not yet realised by a data model.":"Not yet realised by any data model."}):e.jsx("ul",{className:"sme-usage",children:s.where_used.map(c=>e.jsxs("li",{children:[e.jsx("span",{className:"sme-usage-model",children:c.logical_entity}),c.unmanaged&&e.jsx("span",{className:"sme-badge",children:"engineer-owned"}),c.physical.length>0&&e.jsx("span",{className:"sme-usage-phys",children:c.physical.map(l=>l.name).join(", ")})]},c.logical_id))})]})]})}function _s({term:s,pending:t,onStage:a,onDone:r,catalogOwned:i=[],catalog:x=null}){var A,R,D,L;const c=j=>i.includes(j),l=j=>t.find(P=>P.label===j),u=(j,P)=>{const F=l(j);return F?F.after:P},[N,p]=n.useState(u("Definition",s.definition??"")),[h,m]=n.useState(s.synonyms),[v,S]=n.useState(""),[C,T]=n.useState(((A=s.stewardship)==null?void 0:A.owner)??""),[_,b]=n.useState(((R=s.stewardship)==null?void 0:R.steward)??""),k=()=>{N.trim()!==(s.definition??"").trim()&&a({op:"set_definition",payload:{id:s.id,definition:N.trim()},label:"Definition",before:s.definition??"(none)",after:N.trim()||"(none)"})},E=(j,P)=>{var F,O;a({op:"set_stewardship",payload:{id:s.id,owner:j||null,steward:P||null},label:"Stewardship",before:`owner: ${((F=s.stewardship)==null?void 0:F.owner)??"—"} · steward: ${((O=s.stewardship)==null?void 0:O.steward)??"—"}`,after:`owner: ${j||"—"} · steward: ${P||"—"}`})},$=j=>{m(j),a({op:"update_synonyms",payload:{id:s.id,synonyms:j},label:"Also called",before:s.synonyms.join(", ")||"(none)",after:j.join(", ")||"(none)"})},o=s.kind==="term";return e.jsxs("div",{className:"sme-editor",children:[e.jsxs("div",{className:"sme-card-head",children:[e.jsxs("h1",{children:["Suggest an edit — ",s.name]}),e.jsx("button",{className:"sme-secondary",onClick:r,children:"Back"})]}),e.jsxs("p",{className:"sme-hint",children:["You can refine what this term ",e.jsx("em",{children:"means"}),". Structure (keys, relationships, how it's built) stays with the data team."]}),(c("definition")||c("synonyms")||c("stewardship"))&&x&&e.jsxs("div",{className:"sme-catalog-banner",children:["Definitions, synonyms, and ownership are mastered in ",e.jsx("b",{children:x.name}),". Edit them there — this glossary mirrors them read-only.",x.url&&e.jsxs(e.Fragment,{children:[" ",e.jsxs("a",{href:x.url,target:"_blank",rel:"noreferrer",children:["Open in ",x.name," →"]})]}),e.jsx("div",{className:"sme-catalog-note",children:"You can still propose a standard mapping below."})]}),e.jsxs("label",{className:"sme-field",children:[e.jsx("span",{children:"Definition"}),c("definition")?e.jsx("p",{className:"sme-readonly-value",children:s.definition??"—"}):e.jsx("textarea",{rows:4,value:N,onChange:j=>p(j.target.value),onBlur:k,placeholder:"A plain-language business definition…"})]}),e.jsxs("label",{className:"sme-field",children:[e.jsx("span",{children:"Also called (synonyms)"}),c("synonyms")?e.jsx("div",{className:"sme-syn-row",children:s.synonyms.length?s.synonyms.map(j=>e.jsx("span",{className:"sme-chip",children:j},j)):e.jsx("span",{className:"sme-muted",children:"none"})}):e.jsxs("div",{className:"sme-syn-row",children:[h.map(j=>e.jsxs("span",{className:"sme-chip removable",onClick:()=>$(h.filter(P=>P!==j)),children:[j," ✕"]},j)),e.jsx("input",{value:v,placeholder:"add + Enter",onChange:j=>S(j.target.value),onKeyDown:j=>{j.key==="Enter"&&v.trim()&&($([...h,v.trim()]),S(""))}})]})]}),!o&&(c("stewardship")?e.jsxs("div",{className:"sme-field-row",children:[e.jsxs("label",{className:"sme-field",children:[e.jsx("span",{children:"Owner"}),e.jsx("p",{className:"sme-readonly-value",children:((D=s.stewardship)==null?void 0:D.owner)??"—"})]}),e.jsxs("label",{className:"sme-field",children:[e.jsx("span",{children:"Steward"}),e.jsx("p",{className:"sme-readonly-value",children:((L=s.stewardship)==null?void 0:L.steward)??"—"})]})]}):e.jsxs("div",{className:"sme-field-row",children:[e.jsxs("label",{className:"sme-field",children:[e.jsx("span",{children:"Owner"}),e.jsx("input",{value:C,onChange:j=>T(j.target.value),onBlur:()=>E(C,_)})]}),e.jsxs("label",{className:"sme-field",children:[e.jsx("span",{children:"Steward"}),e.jsx("input",{value:_,onChange:j=>b(j.target.value),onBlur:()=>E(C,_)})]})]})),e.jsx(Es,{term:s,onStage:a}),e.jsx("p",{className:"sme-note",children:t.length>0?`${t.length} change(s) staged — use “Submit for review” at the top when you're done.`:"Changes you make are collected until you submit them for review."})]})}const Cs=["skos:exactMatch","skos:closeMatch","skos:broadMatch","skos:narrowMatch"];function Es({term:s,onStage:t}){var h;const[a,r]=n.useState(!1),[i,x]=n.useState(s.name),[c,l]=n.useState([]),[u,N]=n.useState("skos:closeMatch"),p=m=>{x(m),He(m).then(v=>l(v.results)).catch(()=>l([]))};return a?e.jsxs("div",{className:"sme-field sme-align",children:[e.jsx("span",{children:"Propose a standard mapping (a suggestion; the architect confirms)"}),e.jsx("input",{value:i,onChange:m=>p(m.target.value),placeholder:"Search standards…",autoFocus:!0}),e.jsx("div",{className:"sme-align-results",children:c.map(m=>e.jsxs("button",{className:"sme-align-card",onClick:()=>{var v;t({op:"set_alignment",payload:{id:s.id,aligns_to:m.prefixed,alignment:u,status:"proposed"},label:"Standard mapping",before:((v=s.ontology)==null?void 0:v.aligns_to)??"(none)",after:`${m.prefixed} (${u}, proposed)`}),r(!1)},children:[e.jsx("strong",{children:m.label})," ",e.jsx("code",{children:m.prefixed}),m.definition&&e.jsx("span",{className:"sme-align-def",children:m.definition})]},m.iri))}),e.jsx("select",{value:u,onChange:m=>N(m.target.value),children:Cs.map(m=>e.jsx("option",{children:m},m))})]}):e.jsxs("div",{className:"sme-field",children:[e.jsx("span",{children:"Standard mapping"}),e.jsxs("div",{children:[(h=s.ontology)!=null&&h.aligns_to?e.jsx("code",{className:"sme-current-align",children:s.ontology.aligns_to}):e.jsx("span",{className:"sme-muted",children:"not mapped to a standard"}),e.jsx("button",{className:"sme-link",onClick:()=>r(!0),children:"Propose a mapping…"})]})]})}function As(){const[s,t]=n.useState(null),[a,r]=n.useState(!0),[i,x]=n.useState(null),[c,l]=n.useState(""),[u,N]=n.useState(null),[p,h]=n.useState(""),[m,v]=n.useState(""),[S,C]=n.useState(null),[T,_]=n.useState(!1),[b,k]=n.useState([]),[E,$]=n.useState(!1),[o,A]=n.useState(window.location.hash==="#proposals"?"proposals":"browse"),[R,D]=n.useState(new Set),[L,j]=n.useState(()=>localStorage.getItem("mdl.sme.user")??""),[P,F]=n.useState(null),[O,q]=n.useState(null),[W,U]=n.useState(!1),[V,g]=n.useState(null),d=n.useCallback((f,w)=>{var ae;const I=Q=>{var te;const K=O==null?void 0:O.entities.find(re=>{var ie;return re.id===Q||((ie=re.conceptual)==null?void 0:ie.id)===Q});return((te=K==null?void 0:K.conceptual)==null?void 0:te.name)??(K==null?void 0:K.name)??"object"},B=I(w.id??w.entity_id);switch(f){case"create_entity":return{label:`New entity: ${w.name}`,before:"—",after:String(w.name??"")};case"create_relationship":return{label:`New relationship: ${I(w.from_entity)} → ${I(w.to_entity)}`,before:"—",after:String(w.cardinality??"many_to_one")};case"delete_entity":return{label:`Deleted ${B}`,before:B,after:"—"};case"delete_relationship":return{label:"Relationship removed",before:"",after:"—"};case"update_relationship":return{label:"Relationship changed",before:"",after:[w.cardinality,w.optionality,w.identifying?"identifying":""].filter(Boolean).join(", ")};case"set_definition":return{label:`Definition: ${B}`,before:"",after:String(w.definition??"")};case"add_attribute":return{label:`Attribute added to ${B}`,before:"—",after:String(w.name??"")};case"delete_attribute":return{label:`Attribute removed from ${B}`,before:"",after:"—"};case"update_attribute":return{label:`Attribute changed on ${B}`,before:"",after:JSON.stringify(w)};case"rename_entity":return{label:`Renamed ${B}`,before:B,after:String(w.name??"")};case"set_subject_area":return{label:`Subject area: ${B}`,before:"",after:String(w.subject_area??"none")};case"set_stewardship":return{label:`Stewardship: ${B}`,before:"",after:String(w.steward??"")};case"set_subject_area_members":{const Q=w.__label,K=((ae=w.members)==null?void 0:ae.length)??0;return{label:Q??"Subject area members",before:"",after:`${K} object${K===1?"":"s"}`}}case"set_alignment":return{label:`Alignment: ${B}`,before:"",after:String(w.aligns_to??"")};default:return{label:`${f.replace(/_/g," ")}: ${B}`,before:"",after:""}}},[O]),y=Ze({subjectArea:p,describe:d}),M=n.useCallback(async(f,w)=>{const I=(O==null?void 0:O.fingerprint)??"",B=await Ke(f,w,I);return await le(p||void 0).then(q),B},[O,p]),z=n.useMemo(()=>{const f={};for(const w of y.pending)w.op==="set_subject_area_members"&&(f[w.payload.id]=w.payload.members??[]);return f},[y.pending]),G=n.useMemo(()=>[...b,...y.pending],[b,y.pending]),[we,X]=n.useState(null),[ye,Z]=n.useState(null);n.useEffect(()=>{if(!G.length){X(null),Z(null);return}const f=new AbortController,w=G.map(I=>({op:I.op,payload:I.payload}));return je(w,p||void 0,f.signal).then(I=>X(I.diff??null)).catch(I=>{I.name!=="AbortError"&&X(null)}),Ve(w).then(Z).catch(()=>Z(null)),()=>f.abort()},[G,p]);const Se=n.useMemo(()=>es(G),[G]).size{A(f),window.location.hash=f==="browse"?"":`#${f}`},[]);n.useEffect(()=>{const f=()=>{const w=window.location.hash;A(w==="#proposals"?"proposals":w==="#review"?"review":w==="#model"?"model":w==="#areas"?"areas":"browse")};return f(),window.addEventListener("hashchange",f),()=>window.removeEventListener("hashchange",f)},[]);const ee=n.useCallback(()=>{Ue({subject_area:p,q:m}).then(t).catch(f=>N(String(f)))},[p,m]);n.useEffect(ee,[ee]),n.useEffect(()=>{le(p||void 0).then(f=>{r(f.read_only),l(f.project.name),q(f),U(!!f.direct),F(f.identity??null),f.identity&&f.identity.source!=="anonymous"&&f.identity.name&&j(f.identity.name)}).catch(()=>{}),Ye().then(x).catch(()=>{})},[p]);const se=n.useMemo(()=>(s==null?void 0:s.terms.find(f=>f.id===S))??null,[s,S]),ke=n.useCallback(f=>{const w=f.key??ve(f.op,f.payload);k(I=>[...I.filter(B=>B.key!==w),{...f,key:w}])},[]),_e=f=>k(w=>w.filter((I,B)=>B!==f)),Ce=()=>{k([]),$(!1),_(!1),ee()};if(u)return e.jsxs("div",{className:"sme-splash error",children:[e.jsx("h1",{children:"◮ Glossary"}),e.jsx("pre",{children:u}),e.jsxs("p",{children:["Is ",e.jsx("code",{children:"mdl glossary"})," pointed at a model?"]})]});if(!s)return e.jsx("div",{className:"sme-splash",children:"◮ loading glossary…"});const Y=!a,ne=(i==null?void 0:i.catalog_owned_fields)??[],Ee=ne.length>0;return e.jsxs("div",{className:"sme",children:[e.jsxs("header",{className:"sme-top",children:[e.jsxs("div",{className:"sme-brand",children:[e.jsx("span",{className:"sme-logo",children:"◮"}),e.jsx("span",{children:"Glossary"}),e.jsx("span",{className:"sme-project",children:c}),a&&e.jsx("span",{className:"sme-chip",children:"read-only"}),Ee&&e.jsxs("span",{className:"sme-chip catalog",title:`Definitions are mastered in ${i==null?void 0:i.catalog_name}`,children:["mirrors ",i==null?void 0:i.catalog_name]})]}),e.jsx("input",{className:"sme-search",type:"search",placeholder:"Search terms & definitions…",value:m,onChange:f=>v(f.target.value)}),e.jsxs("nav",{className:"sme-tabs",children:[e.jsx("button",{className:"sme-tab"+(o==="browse"?" active":""),onClick:()=>H("browse"),children:"Terms"}),e.jsx("button",{className:"sme-tab"+(o==="model"?" active":""),onClick:()=>H("model"),children:"Model"}),e.jsx("button",{className:"sme-tab"+(o==="areas"?" active":""),onClick:()=>H("areas"),children:"Subject areas"}),e.jsx("button",{className:"sme-tab"+(o==="proposals"?" active":""),onClick:()=>H("proposals"),children:"My proposals"})]}),G.length>0&&e.jsxs("button",{className:"sme-tray",onClick:()=>H("review"),children:[G.length," change",G.length>1?"s":""," · Review →"]})]}),o==="browse"&&e.jsx(ss,{user:L}),o==="review"?e.jsx(Ns,{stagedDiff:we,stagedRoute:ye,user:L,selectable:Se,excluded:R,onToggleObject:f=>D(w=>{const I=new Set(w);return I.has(f)?I.delete(f):I.add(f),I}),onBack:()=>H("browse"),onSubmit:f=>{g(f),$(!0)}}):o==="model"?y.previewDoc??O?e.jsx(ls,{doc:y.previewDoc??O,subjectArea:p,onSubjectArea:h,exec:W?M:y.exec,canEdit:Y,direct:W,onImported:()=>H("review"),busy:y.busy}):e.jsx("div",{className:"sme-splash",children:"◮ loading the model…"}):o==="areas"?e.jsx(ts,{exec:y.exec,canEdit:Y,stagedMembers:z}):o==="proposals"?e.jsx(cs,{user:L,onView:()=>H("review")}):e.jsxs("div",{className:"sme-body",children:[e.jsxs("nav",{className:"sme-nav",children:[e.jsx("button",{className:"sme-sa"+(p===""?" active":""),onClick:()=>h(""),children:"All subject areas"}),s.subject_areas.map(f=>e.jsx("button",{className:"sme-sa"+(p===f.id?" active":""),onClick:()=>h(f.id),title:f.definition??void 0,children:f.name},f.id))]}),e.jsxs("ul",{className:"sme-list",children:[s.terms.map(f=>{var w;return e.jsxs("li",{className:"sme-list-item"+(f.id===S?" active":""),onClick:()=>{C(f.id),_(!1)},children:[e.jsx("span",{className:"sme-term-name",children:f.name}),f.kind==="term"&&e.jsx("span",{className:"sme-kind",children:"term"}),((w=f.ontology)==null?void 0:w.status)==="proposed"&&e.jsx("span",{className:"sme-badge proposed",title:"alignment awaiting architect",children:"proposed"}),e.jsx("span",{className:"sme-term-def",children:f.definition??"no definition yet"})]},f.id)}),s.terms.length===0&&e.jsx("li",{className:"sme-empty",children:"no terms match"})]}),e.jsx("section",{className:"sme-detail",children:se?T&&Y?e.jsx(_s,{term:se,pending:b,onStage:ke,onDone:()=>_(!1),catalogOwned:ne,catalog:i?{name:i.catalog_name,url:i.catalog_url}:null}):e.jsx(ks,{term:se,canEdit:Y,pendingCount:b.length,onEdit:()=>_(!0)}):e.jsx("div",{className:"sme-placeholder",children:"Select a term to see its definition."})})]}),E&&e.jsx(hs,{changes:G,routeAdvice:V,identity:P,user:L,onUser:f=>{j(f),localStorage.setItem("mdl.sme.user",f)},onDrop:_e,onClose:()=>$(!1),onProposed:()=>{Ce(),y.clear(),D(new Set),H("proposals")}})]})}Ae.createRoot(document.getElementById("root")).render(e.jsx(Re.StrictMode,{children:e.jsx(As,{})})); diff --git a/packages/server/src/mdl_server/static/assets/sme-bmuaEwPQ.js b/packages/server/src/mdl_server/static/assets/sme-bmuaEwPQ.js deleted file mode 100644 index 65af07e..0000000 --- a/packages/server/src/mdl_server/static/assets/sme-bmuaEwPQ.js +++ /dev/null @@ -1,2 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ModelDiagram-C1PzETqC.js","assets/client-DOmNpTln.js","assets/styles-DG4k7QGS.js","assets/styles-B4bhxAsE.css"])))=>i.map(i=>d[i]); -import{r as n,j as e,c as Re,R as $e}from"./client-DOmNpTln.js";import{p as je,b as xe,c as Me,e as De,i as Pe,d as fe,h as ge,j as be,R as Oe,M as Ie,O as Te,L as Le,k as Be,l as Fe,A as qe,m as ze,n as We,o as Ge,q as He,s as Ke,f as le,r as Ve,t as Ue,u as Ye}from"./styles-DG4k7QGS.js";/* empty css */const Qe="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function ce(s,t){let a="";for(let r=0;r>=5n;return a}function ve(){const s=BigInt(Date.now())&(1n<<48n)-1n,t=new Uint8Array(10);crypto.getRandomValues(t);let a=0n;for(const r of t)a=a<<8n|BigInt(r);return ce(s,10)+ce(a,16)}const Je={create_entity:["id","conceptual_id"],create_relationship:["id","from_fk_id"],create_subject_area:["id"],create_term:["id"],create_domain:["id"],create_code_set:["id"],create_key_group:["id"],create_category:["id"],add_attribute:["id"]};function Xe(s,t){const a=Je[s];if(!a)return t;const r={...t};for(const i of a)r[i]||(r[i]=ve());return r}function Ne(s,t){if(s.startsWith("create_")||s==="add_attribute")return`${s}:${t.id??t.attribute_id}`;const a=t.id??t.entity_id??"",r=t.attribute_id??"";return r?`${s}:${a}:${r}`:`${s}:${a}`}function Ze({subjectArea:s,describe:t}){const[a,r]=n.useState([]),[i,x]=n.useState(null),[c,l]=n.useState(!1),m=n.useRef(null),N=n.useCallback(async(h,v)=>{v=Xe(h,v),h==="set_alignment"&&v.status===void 0&&(v={...v,status:"proposed"});const S=Ne(h,v),{label:C,before:T,after:_}=t(h,v);return r(b=>{const k=b.filter(E=>E.key!==S);if(h.startsWith("delete_")){const E=v.id??v.entity_id;if(E&&b.some(p=>p.op.startsWith("create_")&&p.payload.id===E))return k.filter(p=>p.payload.id!==E)}return[...k,{op:h,payload:v,label:C,before:T,after:_,key:S}]}),{ok:!0,fingerprint:"",created_id:v.id??null,diagnostics:[]}},[t]);n.useEffect(()=>{if(!a.length){x(null);return}const h=setTimeout(()=>{var S;(S=m.current)==null||S.abort();const v=new AbortController;m.current=v,l(!0),je(a.map(C=>({op:C.op,payload:C.payload})),s,v.signal).then(x).catch(C=>{C.name!=="AbortError"&&x(null)}).finally(()=>l(!1))},250);return()=>clearTimeout(h)},[a,s]);const u=n.useCallback(h=>{r(v=>v.filter(S=>S.key!==h))},[]),d=n.useCallback(()=>r([]),[]);return n.useMemo(()=>({pending:a,previewDoc:(i==null?void 0:i.model)??null,previewDiff:(i==null?void 0:i.diff)??null,diagnostics:(i==null?void 0:i.diagnostics)??[],failure:i&&i.failed_index!==null?{index:i.failed_index,error:i.error??"invalid change"}:null,busy:c,exec:N,drop:u,clear:d}),[a,i,c,N,u,d])}function es(s){const t=new Map;for(const r of s)for(const i of["id","conceptual_id","from_fk_id"]){const x=r.payload[i];r.op.startsWith("create_")&&typeof x=="string"&&t.set(x,r.key)}if(!t.size)return new Set;const a=new Set;for(const r of s)if(!r.op.startsWith("create_"))for(const i of Object.values(r.payload))typeof i=="string"&&t.has(i)&&(a.add(r.key),a.add(t.get(i)));return a}function ss({user:s}){const[t,a]=n.useState(null);return n.useEffect(()=>{xe(s).then(a).catch(()=>{})},[s]),!(t!=null&&t.ok)||!t.git?null:t.read_only?e.jsxs("div",{className:"git-banner",children:[e.jsx("code",{children:t.branch}),e.jsx("span",{children:"browse only — editing is disabled on this deployment"})]}):t.dirty?e.jsxs("div",{className:"git-banner warn",children:[e.jsx("code",{children:t.branch}),e.jsx("span",{children:"uncommitted changes in the working tree — a proposal will be refused until they are committed or discarded"})]}):t.on_base?e.jsxs("div",{className:"git-banner",children:[e.jsx("code",{children:t.branch}),e.jsx("span",{children:"protected — your edits become a pull request"})]}):e.jsxs("div",{className:"git-banner",children:[e.jsx("code",{children:t.branch}),e.jsx("span",{children:"your proposal branch"}),t.behind?e.jsxs("span",{className:"dim",children:["· ",t.base_branch," is ",t.behind," ahead"]}):null]})}function ns({exec:s,canEdit:t,onImported:a}){const[r,i]=n.useState(null),[x,c]=n.useState([]),[l,m]=n.useState("postgres"),N=n.useRef(null);n.useEffect(()=>{Me().then(d=>c(d.formats)).catch(()=>c([]))},[]),n.useEffect(()=>{if(!r)return;const d=h=>{N.current&&!N.current.contains(h.target)&&i(null)};return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[r]);const u=x.find(d=>d.id==="sql");return e.jsxs("div",{className:"ie-wrap",ref:N,children:[e.jsx("button",{className:"erd-action ghost"+(r==="export"?" on":""),onClick:()=>i(r==="export"?null:"export"),children:"Export ▾"}),t&&e.jsx("button",{className:"erd-action ghost"+(r==="import"?" on":""),onClick:()=>i(r==="import"?null:"import"),children:"Import ▾"}),r==="export"&&e.jsxs("div",{className:"ie-menu",role:"menu",children:[(u==null?void 0:u.dialects)&&e.jsxs("label",{className:"ie-dialect",children:[e.jsx("span",{children:"SQL dialect"}),e.jsx("select",{value:l,onChange:d=>m(d.target.value),children:u.dialects.map(d=>e.jsx("option",{value:d,children:d},d))})]}),x.map(d=>e.jsx("a",{className:"ie-item",href:De(d.id,d.id==="sql"?l:void 0),download:!0,onClick:()=>i(null),children:d.label},d.id))]}),r==="import"&&e.jsx(as,{exec:s,onClose:()=>i(null),onImported:d=>{i(null),a==null||a(d)}})]})}const oe=[{id:"sql",label:"SQL DDL",hint:"CREATE TABLE … PRIMARY KEY / FOREIGN KEY"},{id:"mermaid",label:"Mermaid erDiagram",hint:"structural: entities, attributes, relationships"},{id:"json-schema",label:"JSON Schema",hint:"each object definition becomes an entity"}];function as({exec:s,onClose:t,onImported:a}){var _;const[r,i]=n.useState("sql"),[x,c]=n.useState("postgres"),[l,m]=n.useState(""),[N,u]=n.useState(!1),[d,h]=n.useState(null),[v,S]=n.useState([]),C=b=>{b&&b.text().then(m).catch(()=>h("could not read that file"))},T=async()=>{u(!0),h(null),S([]);try{const b=await Pe(r,l,r==="sql"?x:void 0);if(!b.changes.length){h(b.warnings[0]??"nothing to import from that document"),u(!1);return}for(const k of b.changes)await s(k.op,k.payload);S(b.warnings),a(b.tables)}catch(b){h(b instanceof Error?b.message:String(b))}finally{u(!1)}};return e.jsxs("div",{className:"ie-menu ie-import",role:"dialog",children:[e.jsx("div",{className:"ie-tabs",children:oe.map(b=>e.jsx("button",{className:"ie-tab"+(r===b.id?" active":""),onClick:()=>i(b.id),children:b.label},b.id))}),e.jsx("p",{className:"ie-hint",children:(_=oe.find(b=>b.id===r))==null?void 0:_.hint}),r==="sql"&&e.jsxs("label",{className:"ie-dialect",children:[e.jsx("span",{children:"dialect"}),e.jsx("select",{value:x,onChange:b=>c(b.target.value),children:["postgres","snowflake","mysql","duckdb"].map(b=>e.jsx("option",{children:b},b))})]}),e.jsx("textarea",{className:"ie-textarea",placeholder:`Paste ${r} here, or choose a file…`,value:l,onChange:b=>m(b.target.value),rows:8}),e.jsx("input",{type:"file",className:"ie-file",accept:".sql,.mmd,.md,.json,.txt",onChange:b=>{var k;return C(((k=b.target.files)==null?void 0:k[0])??null)}}),r==="mermaid"&&e.jsx("p",{className:"ie-warn",children:"Mermaid is a diagram format: types and keys are approximate and relationships are inferred from the lines."}),v.map((b,k)=>e.jsx("p",{className:"ie-warn",children:b},k)),d&&e.jsx("p",{className:"ie-error",children:d}),e.jsxs("div",{className:"ie-foot",children:[e.jsx("button",{className:"erd-action ghost",onClick:t,children:"Cancel"}),e.jsx("button",{className:"erd-action",disabled:N||!l.trim(),onClick:T,children:N?"Importing…":"Import & review"})]})]})}function ts({exec:s,canEdit:t,stagedMembers:a}){const[r,i]=n.useState([]),[x,c]=n.useState(""),[l,m]=n.useState(null),[N,u]=n.useState(""),[d,h]=n.useState(new Set),[v,S]=n.useState("ancestors"),[C,T]=n.useState(1),[_,b]=n.useState(null),[k,E]=n.useState(new Set),[$,p]=n.useState(null);n.useEffect(()=>{fe().then(o=>{i(o.subject_areas),c(y=>{var M;return y||((M=o.subject_areas[0])==null?void 0:M.id)||""})}).catch(o=>p(String(o)))},[]),n.useEffect(()=>{x&&(b(null),h(new Set),ge(x).then(m).catch(o=>p(String(o))))},[x]);const A=n.useMemo(()=>a[x]??(l==null?void 0:l.members)??[],[a,x,l]),R=n.useMemo(()=>{const o=new Map;for(const y of[...(l==null?void 0:l.included)??[],...(l==null?void 0:l.available)??[]])o.set(y.id,y);return o},[l]),D=N.trim().toLowerCase(),L=o=>!D||o.name.toLowerCase().includes(D),j=n.useMemo(()=>new Set(A),[A]),P=n.useMemo(()=>A.map(o=>R.get(o)).filter(o=>!!o&&L(o)),[A,R,D]),F=n.useMemo(()=>[...R.values()].filter(o=>!j.has(o.id)&&L(o)),[R,j,D]),O=n.useCallback(o=>{if(!l)return;const y=o.filter(z=>!(l.members??[]).includes(z)).length,M=(l.members??[]).filter(z=>!o.includes(z)).length;s("set_subject_area_members",{id:l.id,members:o,__label:`${l.name}: ${o.length} objects (+${y} −${M})`})},[l,s]),q=(o,y)=>{const M=y?[...A,...o.filter(z=>!j.has(z))]:A.filter(z=>!o.includes(z));O(M),h(new Set)},W=(o,y,M)=>{const z=new Set(o);z.has(y)?z.delete(y):z.add(y),M(z)},U=()=>{if(!l)return;const o=d.size?[...d]:A;if(!o.length){p("add an object first, or select one to expand from");return}p(null),be(l.id,{seeds:o,direction:v,levels:C}).then(y=>{b(y.hops),E(new Set(y.added))}).catch(y=>p(String(y)))},V=()=>{q([...k],!0),b(null)};if($&&!l)return e.jsx("p",{className:"sme-splash error",children:$});if(!r.length)return e.jsx("p",{className:"sme-placeholder",children:"No subject areas yet."});const g=((l==null?void 0:l.inconsistent)??[]).filter(o=>!j.has(o));return e.jsxs("div",{className:"sa-editor",children:[e.jsx("nav",{className:"sme-nav",children:r.map(o=>e.jsxs("button",{className:"sme-sa"+(o.id===x?" active":""),onClick:()=>c(o.id),title:o.definition??void 0,children:[o.name,e.jsx("span",{className:"sme-sa-count",children:(a[o.id]??o.members).length})]},o.id))}),e.jsxs("div",{className:"sa-main",children:[e.jsxs("div",{className:"sa-head",children:[e.jsx("h2",{children:(l==null?void 0:l.name)??"…"}),(l==null?void 0:l.definition)&&e.jsx("p",{className:"sme-muted",children:l.definition}),e.jsx("input",{className:"sme-search sa-filter",type:"search",placeholder:"Filter both lists…",value:N,onChange:o=>u(o.target.value)})]}),g.length>0&&t&&e.jsxs("div",{className:"sa-nudge",children:[g.length," object",g.length>1?"s are":" is"," homed in this area but not included.",e.jsxs("button",{className:"sme-link",onClick:()=>q(g,!0),children:["Add ",g.length>1?"them all":"it"]})]}),e.jsxs("div",{className:"sa-panes",children:[e.jsx(J,{title:`Available (${F.length})`,rows:F,picked:d,onToggle:o=>W(d,o,h),homedHere:(l==null?void 0:l.homed_here)??[]}),e.jsxs("div",{className:"sa-controls",children:[e.jsx("button",{className:"sme-secondary",disabled:!t||!d.size,onClick:()=>q([...d].filter(o=>!j.has(o)),!0),title:"Add the selected objects",children:"→"}),e.jsx("button",{className:"sme-secondary",disabled:!t||!F.length,onClick:()=>q(F.map(o=>o.id),!0),title:"Add everything matching the filter",children:"»"}),e.jsx("button",{className:"sme-secondary",disabled:!t||!d.size,onClick:()=>q([...d].filter(o=>j.has(o)),!1),title:"Remove the selected objects",children:"←"}),e.jsx("button",{className:"sme-secondary",disabled:!t||!P.length,onClick:()=>q(P.map(o=>o.id),!1),title:"Remove everything matching the filter",children:"«"})]}),e.jsx(J,{title:`Included (${P.length})`,rows:P,picked:d,onToggle:o=>W(d,o,h),homedHere:(l==null?void 0:l.homed_here)??[]})]}),e.jsxs("div",{className:"sa-expand",children:[e.jsx("h3",{children:"Add related objects"}),e.jsxs("div",{className:"sa-expand-row",children:[e.jsxs("select",{value:v,onChange:o=>S(o.target.value),children:[e.jsx("option",{value:"ancestors",children:"ancestors — the parents its keys point at"}),e.jsx("option",{value:"descendants",children:"descendants — what points at it"}),e.jsx("option",{value:"both",children:"both"})]}),e.jsxs("label",{children:["levels",e.jsx("input",{type:"number",min:1,max:10,value:C,onChange:o=>T(Math.max(1,Math.min(10,Number(o.target.value))))})]}),e.jsx("button",{className:"sme-secondary",onClick:U,disabled:!t,children:"Preview"})]}),$&&e.jsx("p",{className:"sme-error-line",children:$}),_&&e.jsxs("div",{className:"sa-hops",children:[_.length===0&&e.jsx("p",{className:"sme-muted",children:"nothing new to add"}),_.map(o=>e.jsxs("label",{className:"sa-hop",children:[e.jsx("input",{type:"checkbox",checked:k.has(o.id),onChange:()=>W(k,o.id,E)}),e.jsx("span",{className:"sa-hop-name",children:o.name}),e.jsxs("span",{className:"sa-hop-why",children:["via ",o.via_name," · ",o.direction.replace(/s$/,""),", level ",o.level]})]},o.id)),_.length>0&&e.jsxs("div",{className:"sa-hop-actions",children:[e.jsx("button",{className:"sme-secondary",onClick:()=>b(null),children:"Cancel"}),e.jsxs("button",{className:"sme-primary",onClick:V,disabled:!k.size,children:["Add ",k.size," object",k.size===1?"":"s"]})]})]})]})]})]})}function J({title:s,rows:t,picked:a,onToggle:r,homedHere:i}){const x=n.useMemo(()=>new Set(i),[i]);return e.jsxs("div",{className:"sa-pane",children:[e.jsx("h3",{children:s}),e.jsxs("ul",{children:[t.map(c=>e.jsxs("li",{className:"sa-row"+(a.has(c.id)?" picked":""),onClick:()=>r(c.id),children:[e.jsx("input",{type:"checkbox",readOnly:!0,checked:a.has(c.id)}),e.jsx("span",{className:"sa-row-name",children:c.name}),x.has(c.id)?e.jsx("span",{className:"sme-badge",children:"home"}):e.jsx("span",{className:"sme-badge borrowed",children:"borrowed"})]},c.id)),!t.length&&e.jsx("li",{className:"sme-empty",children:"nothing here"})]})]})}function rs({onCreate:s,onClose:t}){const[a,r]=n.useState(""),[i,x]=n.useState(""),[c,l]=n.useState([]),[m,N]=n.useState([]),[u,d]=n.useState(new Set),[h,v]=n.useState(""),[S,C]=n.useState("ancestors"),[T,_]=n.useState(1),[b,k]=n.useState(null),[E,$]=n.useState(new Set),[p,A]=n.useState(""),[R,D]=n.useState(null);n.useEffect(()=>{fe().then(g=>{const o=g.subject_areas[0];if(o)return A(o.id),ge(o.id).then(y=>l([...y.included,...y.available]))}).catch(g=>D(String(g)))},[]);const L=n.useMemo(()=>new Set(m),[m]),j=h.trim().toLowerCase(),P=g=>!j||g.name.toLowerCase().includes(j),F=n.useMemo(()=>m.map(g=>c.find(o=>o.id===g)).filter(g=>!!g&&P(g)),[m,c,j]),O=n.useMemo(()=>c.filter(g=>!L.has(g.id)&&P(g)),[c,L,j]),q=(g,o)=>{N(y=>o?[...y,...g.filter(M=>!y.includes(M))]:y.filter(M=>!g.includes(M))),d(new Set)},W=(g,o,y)=>{const M=new Set(g);M.has(o)?M.delete(o):M.add(o),y(M)},U=()=>{const g=u.size?[...u]:m;if(!g.length){D("pick an object to expand from first");return}p&&(D(null),be(p,{seeds:g,direction:S,levels:T}).then(o=>{const y=o.hops.filter(M=>!L.has(M.id));k(y),$(new Set(y.map(M=>M.id)))}).catch(o=>D(String(o))))},V=()=>{a.trim()&&s(a.trim(),i.trim(),m)};return e.jsx("div",{className:"sme-modal-backdrop",onClick:t,children:e.jsxs("div",{className:"sme-modal sa-modal",onClick:g=>g.stopPropagation(),children:[e.jsx("h2",{children:"New subject area"}),e.jsx("p",{className:"sme-hint",children:"A subject area is a filtered view of the model. Name it and choose what it contains — both land as one proposal."}),e.jsxs("div",{className:"sme-field-row",children:[e.jsxs("label",{className:"sme-field",children:[e.jsx("span",{children:"Name"}),e.jsx("input",{autoFocus:!0,value:a,placeholder:"e.g. UseCase-ApraStressTesting",onChange:g=>r(g.target.value),onKeyDown:g=>g.key==="Enter"&&m.length===0&&V()})]}),e.jsxs("label",{className:"sme-field",children:[e.jsx("span",{children:"Definition (optional)"}),e.jsx("input",{value:i,placeholder:"what this view is for",onChange:g=>x(g.target.value)})]})]}),e.jsx("input",{className:"sme-search sa-filter",type:"search",placeholder:"Filter both lists…",value:h,onChange:g=>v(g.target.value)}),e.jsxs("div",{className:"sa-panes",children:[e.jsx(J,{title:`Available (${O.length})`,rows:O,picked:u,onToggle:g=>W(u,g,d),homedHere:[]}),e.jsxs("div",{className:"sa-controls",children:[e.jsx("button",{className:"sme-secondary",disabled:!u.size,onClick:()=>q([...u].filter(g=>!L.has(g)),!0),title:"Add the selected objects",children:"→"}),e.jsx("button",{className:"sme-secondary",disabled:!O.length,onClick:()=>q(O.map(g=>g.id),!0),title:"Add everything matching the filter",children:"»"}),e.jsx("button",{className:"sme-secondary",disabled:!u.size,onClick:()=>q([...u].filter(g=>L.has(g)),!1),title:"Remove the selected objects",children:"←"}),e.jsx("button",{className:"sme-secondary",disabled:!F.length,onClick:()=>q(F.map(g=>g.id),!1),title:"Remove everything matching the filter",children:"«"})]}),e.jsx(J,{title:`Included (${F.length})`,rows:F,picked:u,onToggle:g=>W(u,g,d),homedHere:[]})]}),e.jsxs("div",{className:"sa-expand",children:[e.jsx("h3",{children:"Add related objects"}),e.jsxs("div",{className:"sa-expand-row",children:[e.jsxs("select",{value:S,onChange:g=>C(g.target.value),children:[e.jsx("option",{value:"ancestors",children:"ancestors — the parents its keys point at"}),e.jsx("option",{value:"descendants",children:"descendants — what points at it"}),e.jsx("option",{value:"both",children:"both"})]}),e.jsxs("label",{children:["levels",e.jsx("input",{type:"number",min:1,max:10,value:T,onChange:g=>_(Math.max(1,Math.min(10,Number(g.target.value))))})]}),e.jsx("button",{className:"sme-secondary",onClick:U,children:"Preview"})]}),b&&e.jsxs("div",{className:"sa-hops",children:[b.length===0&&e.jsx("p",{className:"sme-muted",children:"nothing new to add"}),b.map(g=>e.jsxs("label",{className:"sa-hop",children:[e.jsx("input",{type:"checkbox",checked:E.has(g.id),onChange:()=>W(E,g.id,$)}),e.jsx("span",{className:"sa-hop-name",children:g.name}),e.jsxs("span",{className:"sa-hop-why",children:["via ",g.via_name," · ",g.direction.replace(/s$/,""),", level ",g.level]})]},g.id)),b.length>0&&e.jsxs("div",{className:"sa-hop-actions",children:[e.jsx("button",{className:"sme-secondary",onClick:()=>k(null),children:"Cancel"}),e.jsxs("button",{className:"sme-primary",disabled:!E.size,onClick:()=>{q([...E],!0),k(null)},children:["Add ",E.size]})]})]})]}),R&&e.jsx("p",{className:"sme-error-line",children:R}),e.jsxs("div",{className:"sme-modal-foot",children:[e.jsx("button",{className:"sme-secondary",onClick:t,children:"Cancel"}),e.jsxs("button",{className:"sme-primary",disabled:!a.trim(),onClick:V,children:["Create",m.length>0&&` with ${m.length} object${m.length===1?"":"s"}`]})]})]})})}const is=new Set(["set_definition","set_stewardship","set_subject_area","set_pattern","rename_entity","add_attribute","update_attribute","delete_attribute","set_alignment","clear_alignment","set_term_map","clear_term_map","update_synonyms","set_object_definition","set_subject_area_members","create_subject_area","update_subject_area","create_entity","delete_entity","create_relationship","rename_relationship","update_relationship","delete_relationship"]);function ls({doc:s,subjectArea:t,onSubjectArea:a,exec:r,canEdit:i,direct:x=!1,onSelectEntity:c,onImported:l,busy:m}){var $;const[N,u]=n.useState(null),[d,h]=n.useState(null),[v,S]=n.useState(!1),[C,T]=n.useState(null),[_]=n.useState(""),b=n.useRef(null),k=n.useMemo(()=>({canEdit:i,mode:x?"direct":"staged",allow:x?void 0:is,canArbitrate:x,canCommit:x}),[i,x]),E=n.useCallback(p=>{u(p),p&&(c==null||c(p))},[c]);return e.jsxs("div",{className:"sme-model-view",children:[e.jsxs("nav",{className:"sme-nav",children:[e.jsxs("div",{className:"sme-nav-head",children:[e.jsx("span",{children:"Subject areas"}),i&&e.jsx("button",{className:"sme-nav-add",title:"New subject area",onClick:()=>S(!0),children:"+"})]}),e.jsxs("button",{className:"sme-sa"+(t===""?" active":""),onClick:()=>a(""),children:["Whole model",e.jsx("span",{className:"sme-sa-count",children:(($=s.counts)==null?void 0:$.entities_total)??s.entities.length})]}),s.subject_areas.map(p=>e.jsxs("button",{className:"sme-sa"+(t===p.id?" active":""),onClick:()=>a(p.id),title:p.definition??void 0,children:[p.name,e.jsx("span",{className:"sme-sa-count",children:p.member_count??0})]},p.id))]}),v&&e.jsx(rs,{onClose:()=>S(!1),onCreate:(p,A,R)=>{const D=ve();r("create_subject_area",{name:p,...A?{definition:A}:{},id:D}),R.length&&r("set_subject_area_members",{id:D,members:R}),S(!1),a(D)}}),e.jsxs("div",{className:"erd-wrap",children:[e.jsxs("div",{className:"erd-bar",children:[e.jsxs("span",{className:"erd-count",children:[s.entities.length," entities · ",s.relationships.length," relationships",s.scope&&" · scoped"]}),i&&e.jsx("button",{className:"erd-action",onClick:()=>{var p;return(p=b.current)==null?void 0:p.newEntity()},title:"Add an entity (n)",children:"+ Entity"}),e.jsx("span",{className:"erd-hint",children:"drag between entities to relate them"}),e.jsxs("span",{className:"erd-panels",children:[e.jsx("button",{className:"erd-action ghost"+(d==="ontology"?" on":""),onClick:()=>h(p=>p==="ontology"?null:"ontology"),children:"Ontology"}),e.jsx("button",{className:"erd-action ghost"+(d==="layers"?" on":""),onClick:()=>h(p=>p==="layers"?null:"layers"),children:"Layers"}),e.jsx(ns,{exec:r,canEdit:i,onImported:l})]}),m&&e.jsx("span",{className:"erd-busy",children:"updating…"}),!i&&e.jsx("span",{className:"sme-chip",children:"read-only"}),C&&e.jsx("span",{className:"erd-error",children:C})]}),e.jsxs("div",{className:"erd-canvas canvas-wrap",children:[e.jsx(Oe,{children:e.jsx(Ie,{doc:s,caps:k,exec:r,selectedId:N,onSelect:E,query:_,onError:T,handleRef:b})}),d&&e.jsxs("aside",{className:"side-panel",children:[e.jsxs("div",{className:"detail-header",children:[e.jsx("h2",{children:d==="ontology"?"Ontology":"Ontology layers"}),e.jsx("button",{className:"icon-btn",onClick:()=>h(null),children:"✕"})]}),d==="ontology"?e.jsx(Te,{}):e.jsx(Le,{refreshKey:0,onFocusEntity:p=>{var A;h(null),(A=b.current)==null||A.focusEntity(p)}})]})]})]})]})}function cs({user:s,onView:t}){const[a,r]=n.useState(null),[i,x]=n.useState(null);if(n.useEffect(()=>{Be(s).then(r).catch(l=>x(String(l)))},[s]),i)return e.jsx("p",{className:"sme-splash error",children:i});if(!a)return e.jsx("div",{className:"sme-splash",children:"◮ looking for your proposals…"});if(!a.git)return e.jsx("p",{className:"sme-placeholder",children:"This model isn't in a git repository."});const c=a.proposals.filter(l=>!l.merged).length;return e.jsxs("div",{className:"pr-wrap",children:[e.jsxs("div",{className:"pr-head",children:[e.jsx("h2",{children:"My proposals"}),e.jsxs("span",{className:"meta",children:[c," open · base: ",a.base]})]}),!a.proposals.length&&e.jsx("p",{className:"sme-placeholder",children:"Nothing proposed yet. Edits you submit for review will appear here."}),a.proposals.map(l=>e.jsx(ds,{p:l,gh:a.gh,onView:()=>t(l.branch)},l.branch)),!a.gh&&a.proposals.length>0&&e.jsxs("div",{className:"pr-degrade",children:["Review status isn't available here (",e.jsx("code",{children:"gh"})," is not installed or not signed in). Branch, contents, merge state and conflicts all still come from git — each card links out to the compare view."]})]})}function os(s,t){var a,r;return s.merged?{kind:"accepted",text:"✅ Accepted"}:s.pushed?t&&((a=s.pr)==null?void 0:a.state)==="CLOSED"?{kind:"declined",text:"✖ Declined"}:t&&((r=s.pr)==null?void 0:r.reviews)==="CHANGES_REQUESTED"?{kind:"changes",text:"💬 Changes requested"}:{kind:"awaiting",text:"⏳ Awaiting review"}:{kind:"local",text:"📥 Saved locally"}}function ds({p:s,gh:t,onView:a}){const r=os(s,t);return e.jsxs("div",{className:"pr-card"+(r.kind==="attention"?" attention":""),children:[e.jsxs("div",{className:"pr-top",children:[e.jsx("span",{className:"pr-title",children:s.title}),e.jsx("span",{className:"pr-chip "+r.kind,children:r.text})]}),e.jsxs("div",{className:"pr-branch",children:[s.branch," · ",s.created,s.behind>0&&` · ${s.behind} behind`]}),e.jsxs("div",{className:"pr-foot",children:[e.jsx("span",{className:"pr-link",children:s.merged?e.jsxs(e.Fragment,{children:["merged",t&&s.pr?` · PR #${s.pr.number}`:""]}):s.pushed?t&&s.pr?e.jsxs("a",{href:s.pr.url,target:"_blank",rel:"noreferrer",children:["PR #",s.pr.number]}):s.compare_url?e.jsx("a",{href:s.compare_url,target:"_blank",rel:"noreferrer",children:"open the compare view →"}):"pushed":"not sent yet — no connection to the shared repo"}),e.jsx("span",{className:"pr-btns",children:e.jsx("button",{className:"sme-secondary",onClick:a,children:"View"})})]})]})}function hs({changes:s,routeAdvice:t,identity:a,user:r,onUser:i,onDrop:x,onClose:c,onProposed:l}){const m=!!(a&&a.source!=="anonymous"),[N,u]=n.useState(r||(localStorage.getItem("mdl.sme.user")??"")),[d,h]=n.useState(s.length===1?`Update ${s[0].label.toLowerCase()}`:"Glossary updates"),[v,S]=n.useState(""),[C,T]=n.useState(!1),_=we(C?v:d),[b,k]=n.useState(""),[E,$]=n.useState(!1),[p,A]=n.useState(null),[R,D]=n.useState(null),L=()=>{!m&&!N.trim()||(m||(localStorage.setItem("mdl.sme.user",N.trim()),i==null||i(N.trim())),$(!0),D(null),Fe({user:m?"":N.trim(),slug:_,title:d,body:b.trim(),changes:s.map(j=>({op:j.op,payload:j.payload}))}).then(A).catch(j=>D(j instanceof qe?j.message:String(j))).finally(()=>$(!1)))};return p!=null&&p.ok?e.jsx("div",{className:"sme-modal-backdrop",onClick:()=>l(p),children:e.jsxs("div",{className:"sme-modal",onClick:j=>j.stopPropagation(),children:[e.jsx("h2",{children:"✓ Sent for review"}),e.jsx("p",{children:p.message}),p.pr_url&&e.jsx("p",{children:e.jsx("a",{href:p.pr_url,target:"_blank",rel:"noreferrer",children:"View pull request →"})}),p.compare_url&&e.jsx("p",{children:e.jsx("a",{href:p.compare_url,target:"_blank",rel:"noreferrer",children:"Open the pull request →"})}),e.jsxs("p",{className:"sme-muted",children:["Your suggestion is on branch ",e.jsx("code",{children:p.branch}),". A steward will review it."]}),e.jsx("div",{className:"sme-modal-foot",children:e.jsx("button",{className:"sme-primary",onClick:()=>l(p),children:"Done"})})]})}):e.jsx("div",{className:"sme-modal-backdrop",onClick:c,children:e.jsxs("div",{className:"sme-modal",onClick:j=>j.stopPropagation(),children:[e.jsxs("div",{className:"sme-card-head",children:[e.jsx("h2",{children:"Submit for review"}),e.jsx("button",{className:"sme-secondary",onClick:c,children:"✕"})]}),e.jsx("h3",{children:"Your changes"}),e.jsx("ul",{className:"sme-diff",children:s.map((j,P)=>e.jsxs("li",{children:[e.jsxs("div",{className:"sme-diff-head",children:[e.jsx("b",{children:j.label}),e.jsx("button",{className:"sme-link danger",onClick:()=>x(P),children:"discard"})]}),e.jsx("div",{className:"sme-diff-before",children:j.before}),e.jsx("div",{className:"sme-diff-after",children:j.after})]},P))}),m?e.jsxs("p",{className:"sme-signed-in",children:["Signed in as ",e.jsx("strong",{children:a.name}),a.email?` (${a.email})`:""," — this proposal is attributed to you."]}):e.jsxs("label",{className:"sme-field",children:[e.jsx("span",{children:"Your name (for attribution)"}),e.jsx("input",{value:N,onChange:j=>u(j.target.value),placeholder:"e.g. a.hough"})]}),e.jsxs("label",{className:"sme-field",children:[e.jsx("span",{children:"Title"}),e.jsx("input",{value:d,onChange:j=>h(j.target.value)})]}),e.jsxs("label",{className:"sme-field",children:[e.jsx("span",{children:"Branch name (edit to add a ticket id, e.g. PROJ-123)"}),e.jsx("input",{value:C?v:_,onChange:j=>{T(!0),S(j.target.value)},placeholder:"clarify-counterparty"})]}),e.jsxs("label",{className:"sme-field",children:[e.jsx("span",{children:"Note for the reviewer (optional)"}),e.jsx("textarea",{rows:2,value:b,onChange:j=>k(j.target.value)})]}),e.jsx(ms,{cl:t,user:m?a.name:N,changeSlug:_}),R&&e.jsx("p",{className:"sme-error-line",children:R}),e.jsxs("div",{className:"sme-modal-foot",children:[e.jsx("button",{className:"sme-secondary",onClick:c,children:"Keep editing"}),e.jsx("button",{className:"sme-primary",disabled:E||!m&&!N.trim()||s.length===0,onClick:L,children:E?"Submitting…":"Submit for review"})]})]})})}function ms({cl:s,user:t,changeSlug:a}){if(!(s!=null&&s.primary))return null;const r=s.reviewers_actual??s.reviewers,i=we(t||"you"),x=s.routes.length>1;return e.jsxs(e.Fragment,{children:[x&&e.jsxs("div",{className:"sub-advice",children:[e.jsx("span",{className:"i",children:"ⓘ"})," These changes span routes"," ",e.jsx("strong",{children:s.routes.join(" and ")}),". The whole proposal will be reviewed as route ",s.primary," (",s.primary_name,") — the strictest gate wins, so it needs"," ",r.join(", ")," plus ",e.jsx("code",{children:s.gates[s.gates.length-1]}),". Proposing the meaning-only changes separately would get them reviewed faster."]}),e.jsxs("div",{className:"sub-dest",children:[e.jsxs("div",{className:"row",children:[e.jsx("span",{className:"k",children:"Goes to"}),e.jsxs("code",{children:["sme/",i,"/",a||"…"]})]}),e.jsxs("div",{className:"row",children:[e.jsx("span",{className:"k",children:"Reviewers"}),e.jsx("span",{children:r.join(", ")})]})]})]})}function we(s){return s.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"change"}const us="modulepreload",ps=function(s){return"/"+s},de={},js=function(t,a,r){let i=Promise.resolve();if(a&&a.length>0){document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),l=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));i=Promise.allSettled(a.map(m=>{if(m=ps(m),m in de)return;de[m]=!0;const N=m.endsWith(".css"),u=N?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${m}"]${u}`))return;const d=document.createElement("link");if(d.rel=N?"stylesheet":us,N||(d.as="script"),d.crossOrigin="",d.href=m,l&&d.setAttribute("nonce",l),document.head.appendChild(d),N)return new Promise((h,v)=>{d.addEventListener("load",h),d.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${m}`)))})}))}function x(c){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=c,window.dispatchEvent(l),!l.defaultPrevented)throw c}return i.then(c=>{for(const l of c||[])l.status==="rejected"&&x(l.reason);return t().catch(x)})};function xs({diff:s,selectable:t,selected:a,onToggle:r}){var l;const[i,x]=n.useState(((l=s.objects[0])==null?void 0:l.ulid)??null),c=n.useMemo(()=>s.objects.find(m=>m.ulid===i)??s.objects[0]??null,[s,i]);return s.objects.length?e.jsxs("div",{className:"rv-body",children:[e.jsx("div",{className:"rv-list",children:s.objects.map(m=>e.jsx(gs,{obj:m,active:m.ulid===((c==null?void 0:c.ulid)??""),checked:(a==null?void 0:a.has(m.ulid))??!0,selectable:t,onSelect:()=>x(m.ulid),onToggle:()=>r==null?void 0:r(m.ulid)},m.ulid))}),e.jsx("div",{className:"rv-detail",children:c&&e.jsx(bs,{obj:c})})]}):e.jsxs("p",{className:"sme-placeholder",children:["No model changes against ",s.base.label,"."]})}function fs(s){return s.renamed?"renamed":s.severity==="breaking"?"breaking":s.change}function gs({obj:s,active:t,checked:a,selectable:r,onSelect:i,onToggle:x}){return e.jsxs("div",{className:"rv-obj"+(t?" active":""),onClick:i,children:[e.jsxs("div",{className:"rv-obj-head",children:[r&&e.jsx("input",{type:"checkbox",checked:a,onClick:c=>c.stopPropagation(),onChange:x,"aria-label":`include ${s.name_before??s.name_after}`}),e.jsx("span",{className:"rv-obj-name",children:s.name_before??s.name_after}),e.jsx("span",{className:"rv-obj-kind",children:s.object_kind_label}),e.jsxs("span",{className:"sev "+(s.renamed?"renamed":s.severity),children:[s.severity==="breaking"&&"⚠ ",fs(s)]})]}),e.jsxs("ul",{className:"rv-obj-fields",children:[s.fields.map((c,l)=>e.jsx("li",{children:c.label},c.field+l)),s.children.flatMap(c=>c.fields.map((l,m)=>e.jsxs("li",{children:[l.label,": ",c.name_before??c.name_after]},c.ulid+m)))]})]})}function bs({obj:s}){const t=s.children.flatMap(a=>a.fields.map(r=>({field:r,on:a.name_before??a.name_after??""})));return e.jsxs(e.Fragment,{children:[e.jsx("h2",{children:s.renamed?`${s.name_before} → ${s.name_after}`:s.name_before??s.name_after}),e.jsxs("div",{className:"rv-detail-kind",children:[s.object_kind_label,s.renamed&&" · renamed",s.path&&e.jsxs("span",{className:"rv-src",children:[" · ",s.path]})]}),s.fields.map((a,r)=>e.jsx(he,{f:a},a.field+r)),t.map(({field:a,on:r},i)=>e.jsx(he,{f:a,on:r},"c"+i)),s.severity==="breaking"&&e.jsxs("div",{className:"rv-note",children:[e.jsx("span",{className:"i",children:"ⓘ"}),e.jsxs("span",{children:["This is a structural change (route B). It will need an architect's review, and CI will run ",e.jsx("code",{children:"mdl drift --check"}),"."]})]})]})}function he({f:s,on:t}){var r,i,x;const a=t?`${s.label}: ${t}`:s.label;if((r=s.breaks)!=null&&r.length)return e.jsxs("div",{className:"rv-section",children:[e.jsx("h3",{children:a}),e.jsxs("div",{className:"rv-break",children:[e.jsxs("div",{className:"rv-break-head",children:[e.jsx("span",{children:"⚠"}),e.jsxs("span",{children:[t??String(s.before??"")," removed"]}),s.detail&&e.jsx("span",{className:"rv-break-meta",children:s.detail})]}),e.jsxs("div",{className:"rv-break-body",children:["This is realised by ",s.breaks.length," dbt model",s.breaks.length>1?"s":"",". Removing it will break ",s.breaks.length>1?"them":"it","."]}),e.jsx("ul",{className:"rv-usage",children:s.breaks.map(c=>e.jsxs("li",{children:[e.jsxs("span",{className:"m",children:["→ ",c.name]}),e.jsxs("span",{className:"p",children:[c.target," · ",c.materialization]})]},c.name))})]})]});if(s.kind==="definition_changed"){const c=String(s.before??""),l=String(s.after??"");return e.jsxs("div",{className:"rv-section",children:[e.jsx("h3",{children:a}),e.jsxs("div",{className:"rv-ba",children:[e.jsxs("div",{className:"rv-ba-col",children:[e.jsx("div",{className:"rv-ba-label",children:"before"}),e.jsx("div",{className:"rv-ba-text",children:ue(c,l,"del")})]}),e.jsxs("div",{className:"rv-ba-col",children:[e.jsx("div",{className:"rv-ba-label",children:"after"}),e.jsx("div",{className:"rv-ba-text",children:ue(l,c,"ins")})]})]})]})}if(Array.isArray(s.before)||Array.isArray(s.after)){const c=new Set(((i=s.before)==null?void 0:i.map(String))??[]),l=new Set(((x=s.after)==null?void 0:x.map(String))??[]),m=[...l].filter(u=>!c.has(u)),N=[...c].filter(u=>!l.has(u));return e.jsxs("div",{className:"rv-section",children:[e.jsx("h3",{children:a}),e.jsxs("div",{className:"rv-chips",children:[m.map(u=>e.jsxs("span",{className:"rv-chip-add",children:["+ ",u]},"a"+u)),N.map(u=>e.jsxs("span",{className:"rv-chip-del",children:["− ",u]},"r"+u))]})]})}return e.jsxs("div",{className:"rv-section",children:[e.jsx("h3",{children:a}),e.jsxs("div",{className:"rv-scalar",children:[e.jsx("span",{className:"from",children:me(s.before)}),e.jsx("span",{className:"arrow",children:"→"}),e.jsx("span",{className:"to",children:me(s.after)})]})]})}function me(s){return s==null||s===""?"—":typeof s=="boolean"?s?"yes":"no":typeof s=="object"?JSON.stringify(s):String(s)}function ue(s,t,a){const r=s.split(/(\s+)/),i=t.split(/(\s+)/),x=h=>h.toLowerCase().replace(/[.,;:]/g,""),c=r.length,l=i.length,m=Array.from({length:c+1},()=>new Array(l+1).fill(0));for(let h=c-1;h>=0;h--)for(let v=l-1;v>=0;v--)m[h][v]=x(r[h])===x(i[v])?m[h+1][v+1]+1:Math.max(m[h+1][v],m[h][v+1]);const N=new Set;let u=0,d=0;for(;u=m[u][d+1]?u++:d++;return r.map((h,v)=>!h.trim()||N.has(v)?e.jsx("span",{children:h},v):a==="del"?e.jsx("del",{children:h},v):e.jsx("ins",{children:h},v))}const vs=n.lazy(()=>js(()=>import("./ModelDiagram-C1PzETqC.js"),__vite__mapDeps([0,1,2,3])).then(s=>({default:s.ModelDiagram})));function Ns({stagedDiff:s,stagedRoute:t,user:a,onBack:r,onSubmit:i,excluded:x,onToggleObject:c,selectable:l}){const[m,N]=n.useState(null),[u,d]=n.useState(null),[h,v]=n.useState(null),[S,C]=n.useState(null),[T,_]=n.useState(null),[b,k]=n.useState("changes"),E=n.useCallback(()=>{xe(a).then(p=>{C(p);const A=p.base_branch??"main";s?N(s):ze("HEAD").then(R=>R.ok?N(R):_(R.error??"could not read the model")).catch(R=>_(String(R))),t?d(t):We("HEAD").then(d).catch(()=>{}),Ge(A).then(v).catch(()=>{})}).catch(p=>_(String(p)))},[a,s,t]);if(n.useEffect(E,[E]),T)return e.jsxs("div",{className:"rv-shell",children:[e.jsx(pe,{onBack:r,diff:null}),e.jsx("p",{className:"sme-splash error",children:e.jsx("pre",{children:T})})]});if(!m)return e.jsx("div",{className:"sme-splash",children:"◮ reading your changes…"});const $=new Set(m.objects.map(p=>p.ulid).filter(p=>!x.has(p)));return e.jsxs("div",{className:"rv-shell",children:[e.jsx(pe,{onBack:r,diff:m,tab:b,onTab:k}),b==="changes"?e.jsx(xs,{diff:m,selectable:l,selected:$,onToggle:c}):e.jsx(n.Suspense,{fallback:e.jsx("div",{className:"sme-splash",children:"◮ drawing the model…"}),children:e.jsx(vs,{severityByUlid:ws(m)})}),e.jsxs("div",{className:"rv-foot",children:[e.jsx(ys,{cl:u}),e.jsx(Ss,{conf:h,ctx:S}),e.jsxs("div",{className:"rv-actions",children:[e.jsx("button",{className:"sme-secondary",onClick:r,children:"Keep editing"}),e.jsx("button",{className:"sme-primary",disabled:!m.objects.length||(S?!S.can_propose:!1),title:S&&!S.can_propose?"the working tree has uncommitted changes":"",onClick:()=>i(u),children:"Submit for review →"})]})]})]})}function ws(s){const t=new Map;for(const a of s.objects)t.set(a.ulid,a.severity);return t}function pe({onBack:s,diff:t,tab:a,onTab:r}){const i=t==null?void 0:t.counts;return e.jsxs("div",{className:"rv-head",children:[e.jsxs("div",{children:[e.jsx("button",{className:"rv-back",onClick:s,children:"‹ Back to terms"}),e.jsx("h1",{className:"rv-title",children:"Review your changes"}),i&&e.jsxs("div",{className:"rv-sub",children:[i.objects," object",i.objects===1?"":"s"," ·"," ",(i.breaking??0)+(i.additive??0)+(i.cosmetic??0)," changes",(t==null?void 0:t.has_breaking)&&e.jsxs("span",{className:"warn",children:[" · ⚠ ",i.breaking," breaking"]})," · comparing to ",e.jsx("code",{children:t==null?void 0:t.base.label})]})]}),r&&e.jsxs("div",{className:"rv-tabs",children:[e.jsxs("button",{className:"rv-tab"+(a==="changes"?" active":""),onClick:()=>r("changes"),children:["Changes ",(t==null?void 0:t.objects.length)??0]}),e.jsx("button",{className:"rv-tab"+(a==="diagram"?" active":""),onClick:()=>r("diagram"),children:"Diagram"})]})]})}function ys({cl:s}){if(!(s!=null&&s.primary))return null;const t=s.reviewers_actual??s.reviewers;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"rv-route",children:[e.jsxs("span",{className:"rv-route-badge",children:["Route ",s.primary," · ",s.primary_name]}),e.jsx("span",{className:"k",children:"Reviewers"}),e.jsx("span",{children:t.join(", ")}),s.reviewers_actual&&e.jsx("span",{className:"rv-src",children:"from .github/CODEOWNERS"})]}),e.jsxs("div",{className:"rv-gates",children:["CI gates"," ",s.gates.map(a=>e.jsx("code",{children:a},a))]})]})}function Ss({conf:s,ctx:t}){return s!=null&&s.ok?s.clean?e.jsxs("div",{className:"rv-conflict ok",children:[e.jsx("span",{children:"✓"}),e.jsxs("span",{children:["Merges cleanly onto ",s.base]}),s.behind>0&&e.jsxs("span",{className:"detail",children:["· ",s.base," is ",s.behind," commit",s.behind===1?"":"s"," ahead"]}),(t==null?void 0:t.dirty)&&e.jsx("span",{className:"detail",children:"· uncommitted changes in the working tree"})]}):e.jsxs("div",{className:"rv-conflict bad",children:[e.jsx("span",{children:"⚠"}),e.jsxs("span",{children:[s.base," has changed and ",s.files.length," file",s.files.length===1?"":"s"," now conflict"]}),e.jsx("span",{className:"detail",children:s.files.map(a=>a.path).join(", ")})]}):null}function ks({term:s,canEdit:t,pendingCount:a,onEdit:r}){var i,x;return e.jsxs("div",{className:"sme-card",children:[e.jsxs("div",{className:"sme-card-head",children:[e.jsxs("div",{children:[e.jsx("h1",{children:s.name}),((i=s.subject_area)==null?void 0:i.name)&&e.jsx("span",{className:"sme-chip",children:s.subject_area.name}),s.kind==="term"&&e.jsx("span",{className:"sme-chip",children:"glossary term"})]}),t&&e.jsx("button",{className:"sme-primary",onClick:r,children:a>0?"Continue editing":"Suggest an edit"})]}),e.jsx("p",{className:"sme-definition",children:s.definition??e.jsx("em",{children:"No definition yet."})}),s.synonyms.length>0&&e.jsxs("section",{children:[e.jsx("h3",{children:"Also called"}),e.jsx("div",{children:s.synonyms.map(c=>e.jsx("span",{className:"sme-chip",children:c},c))})]}),s.stewardship&&(s.stewardship.owner||s.stewardship.steward)&&e.jsxs("section",{children:[e.jsx("h3",{children:"Who owns this"}),s.stewardship.owner&&e.jsxs("div",{className:"sme-kv",children:[e.jsx("span",{className:"k",children:"owner"}),e.jsx("span",{children:s.stewardship.owner})]}),s.stewardship.steward&&e.jsxs("div",{className:"sme-kv",children:[e.jsx("span",{className:"k",children:"steward"}),e.jsx("span",{children:s.stewardship.steward})]})]}),((x=s.ontology)==null?void 0:x.aligns_to)&&e.jsxs("section",{children:[e.jsx("h3",{children:"Standard it maps to"}),e.jsxs("div",{className:"sme-kv",children:[e.jsx("span",{className:"k",children:"aligned to"}),e.jsx("code",{children:s.ontology.aligns_to}),s.ontology.status==="proposed"&&e.jsx("span",{className:"sme-badge proposed",children:"awaiting architect"})]})]}),e.jsxs("section",{children:[e.jsx("h3",{children:"Where it's used"}),s.where_used.length===0?e.jsx("p",{className:"sme-muted",children:s.kind==="term"?"A glossary term — not yet realised by a data model.":"Not yet realised by any data model."}):e.jsx("ul",{className:"sme-usage",children:s.where_used.map(c=>e.jsxs("li",{children:[e.jsx("span",{className:"sme-usage-model",children:c.logical_entity}),c.unmanaged&&e.jsx("span",{className:"sme-badge",children:"engineer-owned"}),c.physical.length>0&&e.jsx("span",{className:"sme-usage-phys",children:c.physical.map(l=>l.name).join(", ")})]},c.logical_id))})]})]})}function _s({term:s,pending:t,onStage:a,onDone:r,catalogOwned:i=[],catalog:x=null}){var A,R,D,L;const c=j=>i.includes(j),l=j=>t.find(P=>P.label===j),m=(j,P)=>{const F=l(j);return F?F.after:P},[N,u]=n.useState(m("Definition",s.definition??"")),[d,h]=n.useState(s.synonyms),[v,S]=n.useState(""),[C,T]=n.useState(((A=s.stewardship)==null?void 0:A.owner)??""),[_,b]=n.useState(((R=s.stewardship)==null?void 0:R.steward)??""),k=()=>{N.trim()!==(s.definition??"").trim()&&a({op:"set_definition",payload:{id:s.id,definition:N.trim()},label:"Definition",before:s.definition??"(none)",after:N.trim()||"(none)"})},E=(j,P)=>{var F,O;a({op:"set_stewardship",payload:{id:s.id,owner:j||null,steward:P||null},label:"Stewardship",before:`owner: ${((F=s.stewardship)==null?void 0:F.owner)??"—"} · steward: ${((O=s.stewardship)==null?void 0:O.steward)??"—"}`,after:`owner: ${j||"—"} · steward: ${P||"—"}`})},$=j=>{h(j),a({op:"update_synonyms",payload:{id:s.id,synonyms:j},label:"Also called",before:s.synonyms.join(", ")||"(none)",after:j.join(", ")||"(none)"})},p=s.kind==="term";return e.jsxs("div",{className:"sme-editor",children:[e.jsxs("div",{className:"sme-card-head",children:[e.jsxs("h1",{children:["Suggest an edit — ",s.name]}),e.jsx("button",{className:"sme-secondary",onClick:r,children:"Back"})]}),e.jsxs("p",{className:"sme-hint",children:["You can refine what this term ",e.jsx("em",{children:"means"}),". Structure (keys, relationships, how it's built) stays with the data team."]}),(c("definition")||c("synonyms")||c("stewardship"))&&x&&e.jsxs("div",{className:"sme-catalog-banner",children:["Definitions, synonyms, and ownership are mastered in ",e.jsx("b",{children:x.name}),". Edit them there — this glossary mirrors them read-only.",x.url&&e.jsxs(e.Fragment,{children:[" ",e.jsxs("a",{href:x.url,target:"_blank",rel:"noreferrer",children:["Open in ",x.name," →"]})]}),e.jsx("div",{className:"sme-catalog-note",children:"You can still propose a standard mapping below."})]}),e.jsxs("label",{className:"sme-field",children:[e.jsx("span",{children:"Definition"}),c("definition")?e.jsx("p",{className:"sme-readonly-value",children:s.definition??"—"}):e.jsx("textarea",{rows:4,value:N,onChange:j=>u(j.target.value),onBlur:k,placeholder:"A plain-language business definition…"})]}),e.jsxs("label",{className:"sme-field",children:[e.jsx("span",{children:"Also called (synonyms)"}),c("synonyms")?e.jsx("div",{className:"sme-syn-row",children:s.synonyms.length?s.synonyms.map(j=>e.jsx("span",{className:"sme-chip",children:j},j)):e.jsx("span",{className:"sme-muted",children:"none"})}):e.jsxs("div",{className:"sme-syn-row",children:[d.map(j=>e.jsxs("span",{className:"sme-chip removable",onClick:()=>$(d.filter(P=>P!==j)),children:[j," ✕"]},j)),e.jsx("input",{value:v,placeholder:"add + Enter",onChange:j=>S(j.target.value),onKeyDown:j=>{j.key==="Enter"&&v.trim()&&($([...d,v.trim()]),S(""))}})]})]}),!p&&(c("stewardship")?e.jsxs("div",{className:"sme-field-row",children:[e.jsxs("label",{className:"sme-field",children:[e.jsx("span",{children:"Owner"}),e.jsx("p",{className:"sme-readonly-value",children:((D=s.stewardship)==null?void 0:D.owner)??"—"})]}),e.jsxs("label",{className:"sme-field",children:[e.jsx("span",{children:"Steward"}),e.jsx("p",{className:"sme-readonly-value",children:((L=s.stewardship)==null?void 0:L.steward)??"—"})]})]}):e.jsxs("div",{className:"sme-field-row",children:[e.jsxs("label",{className:"sme-field",children:[e.jsx("span",{children:"Owner"}),e.jsx("input",{value:C,onChange:j=>T(j.target.value),onBlur:()=>E(C,_)})]}),e.jsxs("label",{className:"sme-field",children:[e.jsx("span",{children:"Steward"}),e.jsx("input",{value:_,onChange:j=>b(j.target.value),onBlur:()=>E(C,_)})]})]})),e.jsx(Es,{term:s,onStage:a}),e.jsx("p",{className:"sme-note",children:t.length>0?`${t.length} change(s) staged — use “Submit for review” at the top when you're done.`:"Changes you make are collected until you submit them for review."})]})}const Cs=["skos:exactMatch","skos:closeMatch","skos:broadMatch","skos:narrowMatch"];function Es({term:s,onStage:t}){var d;const[a,r]=n.useState(!1),[i,x]=n.useState(s.name),[c,l]=n.useState([]),[m,N]=n.useState("skos:closeMatch"),u=h=>{x(h),He(h).then(v=>l(v.results)).catch(()=>l([]))};return a?e.jsxs("div",{className:"sme-field sme-align",children:[e.jsx("span",{children:"Propose a standard mapping (a suggestion; the architect confirms)"}),e.jsx("input",{value:i,onChange:h=>u(h.target.value),placeholder:"Search standards…",autoFocus:!0}),e.jsx("div",{className:"sme-align-results",children:c.map(h=>e.jsxs("button",{className:"sme-align-card",onClick:()=>{var v;t({op:"set_alignment",payload:{id:s.id,aligns_to:h.prefixed,alignment:m,status:"proposed"},label:"Standard mapping",before:((v=s.ontology)==null?void 0:v.aligns_to)??"(none)",after:`${h.prefixed} (${m}, proposed)`}),r(!1)},children:[e.jsx("strong",{children:h.label})," ",e.jsx("code",{children:h.prefixed}),h.definition&&e.jsx("span",{className:"sme-align-def",children:h.definition})]},h.iri))}),e.jsx("select",{value:m,onChange:h=>N(h.target.value),children:Cs.map(h=>e.jsx("option",{children:h},h))})]}):e.jsxs("div",{className:"sme-field",children:[e.jsx("span",{children:"Standard mapping"}),e.jsxs("div",{children:[(d=s.ontology)!=null&&d.aligns_to?e.jsx("code",{className:"sme-current-align",children:s.ontology.aligns_to}):e.jsx("span",{className:"sme-muted",children:"not mapped to a standard"}),e.jsx("button",{className:"sme-link",onClick:()=>r(!0),children:"Propose a mapping…"})]})]})}function As(){const[s,t]=n.useState(null),[a,r]=n.useState(!0),[i,x]=n.useState(null),[c,l]=n.useState(""),[m,N]=n.useState(null),[u,d]=n.useState(""),[h,v]=n.useState(""),[S,C]=n.useState(null),[T,_]=n.useState(!1),[b,k]=n.useState([]),[E,$]=n.useState(!1),[p,A]=n.useState(window.location.hash==="#proposals"?"proposals":"browse"),[R,D]=n.useState(new Set),[L,j]=n.useState(()=>localStorage.getItem("mdl.sme.user")??""),[P,F]=n.useState(null),[O,q]=n.useState(null),[W,U]=n.useState(!1),[V,g]=n.useState(null),o=n.useCallback((f,w)=>{var ae;const I=Q=>{var te;const K=O==null?void 0:O.entities.find(re=>{var ie;return re.id===Q||((ie=re.conceptual)==null?void 0:ie.id)===Q});return((te=K==null?void 0:K.conceptual)==null?void 0:te.name)??(K==null?void 0:K.name)??"object"},B=I(w.id??w.entity_id);switch(f){case"create_entity":return{label:`New entity: ${w.name}`,before:"—",after:String(w.name??"")};case"create_relationship":return{label:`New relationship: ${I(w.from_entity)} → ${I(w.to_entity)}`,before:"—",after:String(w.cardinality??"many_to_one")};case"delete_entity":return{label:`Deleted ${B}`,before:B,after:"—"};case"delete_relationship":return{label:"Relationship removed",before:"",after:"—"};case"update_relationship":return{label:"Relationship changed",before:"",after:[w.cardinality,w.optionality,w.identifying?"identifying":""].filter(Boolean).join(", ")};case"set_definition":return{label:`Definition: ${B}`,before:"",after:String(w.definition??"")};case"add_attribute":return{label:`Attribute added to ${B}`,before:"—",after:String(w.name??"")};case"delete_attribute":return{label:`Attribute removed from ${B}`,before:"",after:"—"};case"update_attribute":return{label:`Attribute changed on ${B}`,before:"",after:JSON.stringify(w)};case"rename_entity":return{label:`Renamed ${B}`,before:B,after:String(w.name??"")};case"set_subject_area":return{label:`Subject area: ${B}`,before:"",after:String(w.subject_area??"none")};case"set_stewardship":return{label:`Stewardship: ${B}`,before:"",after:String(w.steward??"")};case"set_subject_area_members":{const Q=w.__label,K=((ae=w.members)==null?void 0:ae.length)??0;return{label:Q??"Subject area members",before:"",after:`${K} object${K===1?"":"s"}`}}case"set_alignment":return{label:`Alignment: ${B}`,before:"",after:String(w.aligns_to??"")};default:return{label:`${f.replace(/_/g," ")}: ${B}`,before:"",after:""}}},[O]),y=Ze({subjectArea:u,describe:o}),M=n.useCallback(async(f,w)=>{const I=(O==null?void 0:O.fingerprint)??"",B=await Ke(f,w,I);return await le(u||void 0).then(q),B},[O,u]),z=n.useMemo(()=>{const f={};for(const w of y.pending)w.op==="set_subject_area_members"&&(f[w.payload.id]=w.payload.members??[]);return f},[y.pending]),G=n.useMemo(()=>[...b,...y.pending],[b,y.pending]),[ye,X]=n.useState(null),[Se,Z]=n.useState(null);n.useEffect(()=>{if(!G.length){X(null),Z(null);return}const f=new AbortController,w=G.map(I=>({op:I.op,payload:I.payload}));return je(w,u||void 0,f.signal).then(I=>X(I.diff??null)).catch(I=>{I.name!=="AbortError"&&X(null)}),Ve(w).then(Z).catch(()=>Z(null)),()=>f.abort()},[G,u]);const ke=n.useMemo(()=>es(G),[G]).size{A(f),window.location.hash=f==="browse"?"":`#${f}`},[]);n.useEffect(()=>{const f=()=>{const w=window.location.hash;A(w==="#proposals"?"proposals":w==="#review"?"review":w==="#model"?"model":w==="#areas"?"areas":"browse")};return f(),window.addEventListener("hashchange",f),()=>window.removeEventListener("hashchange",f)},[]);const ee=n.useCallback(()=>{Ue({subject_area:u,q:h}).then(t).catch(f=>N(String(f)))},[u,h]);n.useEffect(ee,[ee]),n.useEffect(()=>{le(u||void 0).then(f=>{r(f.read_only),l(f.project.name),q(f),U(!!f.direct),F(f.identity??null),f.identity&&f.identity.source!=="anonymous"&&f.identity.name&&j(f.identity.name)}).catch(()=>{}),Ye().then(x).catch(()=>{})},[u]);const se=n.useMemo(()=>(s==null?void 0:s.terms.find(f=>f.id===S))??null,[s,S]),_e=n.useCallback(f=>{const w=f.key??Ne(f.op,f.payload);k(I=>[...I.filter(B=>B.key!==w),{...f,key:w}])},[]),Ce=f=>k(w=>w.filter((I,B)=>B!==f)),Ee=()=>{k([]),$(!1),_(!1),ee()};if(m)return e.jsxs("div",{className:"sme-splash error",children:[e.jsx("h1",{children:"◮ Glossary"}),e.jsx("pre",{children:m}),e.jsxs("p",{children:["Is ",e.jsx("code",{children:"mdl glossary"})," pointed at a model?"]})]});if(!s)return e.jsx("div",{className:"sme-splash",children:"◮ loading glossary…"});const Y=!a,ne=(i==null?void 0:i.catalog_owned_fields)??[],Ae=ne.length>0;return e.jsxs("div",{className:"sme",children:[e.jsxs("header",{className:"sme-top",children:[e.jsxs("div",{className:"sme-brand",children:[e.jsx("span",{className:"sme-logo",children:"◮"}),e.jsx("span",{children:"Glossary"}),e.jsx("span",{className:"sme-project",children:c}),a&&e.jsx("span",{className:"sme-chip",children:"read-only"}),Ae&&e.jsxs("span",{className:"sme-chip catalog",title:`Definitions are mastered in ${i==null?void 0:i.catalog_name}`,children:["mirrors ",i==null?void 0:i.catalog_name]})]}),e.jsx("input",{className:"sme-search",type:"search",placeholder:"Search terms & definitions…",value:h,onChange:f=>v(f.target.value)}),e.jsxs("nav",{className:"sme-tabs",children:[e.jsx("button",{className:"sme-tab"+(p==="browse"?" active":""),onClick:()=>H("browse"),children:"Terms"}),e.jsx("button",{className:"sme-tab"+(p==="model"?" active":""),onClick:()=>H("model"),children:"Model"}),e.jsx("button",{className:"sme-tab"+(p==="areas"?" active":""),onClick:()=>H("areas"),children:"Subject areas"}),e.jsx("button",{className:"sme-tab"+(p==="proposals"?" active":""),onClick:()=>H("proposals"),children:"My proposals"})]}),G.length>0&&e.jsxs("button",{className:"sme-tray",onClick:()=>H("review"),children:[G.length," change",G.length>1?"s":""," · Review →"]})]}),p==="browse"&&e.jsx(ss,{user:L}),p==="review"?e.jsx(Ns,{stagedDiff:ye,stagedRoute:Se,user:L,selectable:ke,excluded:R,onToggleObject:f=>D(w=>{const I=new Set(w);return I.has(f)?I.delete(f):I.add(f),I}),onBack:()=>H("browse"),onSubmit:f=>{g(f),$(!0)}}):p==="model"?y.previewDoc??O?e.jsx(ls,{doc:y.previewDoc??O,subjectArea:u,onSubjectArea:d,exec:W?M:y.exec,canEdit:Y,direct:W,onImported:()=>H("review"),busy:y.busy}):e.jsx("div",{className:"sme-splash",children:"◮ loading the model…"}):p==="areas"?e.jsx(ts,{exec:y.exec,canEdit:Y,stagedMembers:z}):p==="proposals"?e.jsx(cs,{user:L,onView:()=>H("review")}):e.jsxs("div",{className:"sme-body",children:[e.jsxs("nav",{className:"sme-nav",children:[e.jsx("button",{className:"sme-sa"+(u===""?" active":""),onClick:()=>d(""),children:"All subject areas"}),s.subject_areas.map(f=>e.jsx("button",{className:"sme-sa"+(u===f.id?" active":""),onClick:()=>d(f.id),title:f.definition??void 0,children:f.name},f.id))]}),e.jsxs("ul",{className:"sme-list",children:[s.terms.map(f=>{var w;return e.jsxs("li",{className:"sme-list-item"+(f.id===S?" active":""),onClick:()=>{C(f.id),_(!1)},children:[e.jsx("span",{className:"sme-term-name",children:f.name}),f.kind==="term"&&e.jsx("span",{className:"sme-kind",children:"term"}),((w=f.ontology)==null?void 0:w.status)==="proposed"&&e.jsx("span",{className:"sme-badge proposed",title:"alignment awaiting architect",children:"proposed"}),e.jsx("span",{className:"sme-term-def",children:f.definition??"no definition yet"})]},f.id)}),s.terms.length===0&&e.jsx("li",{className:"sme-empty",children:"no terms match"})]}),e.jsx("section",{className:"sme-detail",children:se?T&&Y?e.jsx(_s,{term:se,pending:b,onStage:_e,onDone:()=>_(!1),catalogOwned:ne,catalog:i?{name:i.catalog_name,url:i.catalog_url}:null}):e.jsx(ks,{term:se,canEdit:Y,pendingCount:b.length,onEdit:()=>_(!0)}):e.jsx("div",{className:"sme-placeholder",children:"Select a term to see its definition."})})]}),E&&e.jsx(hs,{changes:G,routeAdvice:V,identity:P,user:L,onUser:f=>{j(f),localStorage.setItem("mdl.sme.user",f)},onDrop:Ce,onClose:()=>$(!1),onProposed:()=>{Ee(),y.clear(),D(new Set),H("proposals")}})]})}Re.createRoot(document.getElementById("root")).render(e.jsx($e.StrictMode,{children:e.jsx(As,{})})); diff --git a/packages/server/src/mdl_server/static/assets/styles-B4bhxAsE.css b/packages/server/src/mdl_server/static/assets/styles-B4bhxAsE.css deleted file mode 100644 index c99b6a1..0000000 --- a/packages/server/src/mdl_server/static/assets/styles-B4bhxAsE.css +++ /dev/null @@ -1 +0,0 @@ -.react-flow{direction:ltr}.react-flow__container{position:absolute;width:100%;height:100%;top:0;left:0}.react-flow__pane{z-index:1;cursor:-webkit-grab;cursor:grab}.react-flow__pane.selection{cursor:pointer}.react-flow__pane.dragging{cursor:-webkit-grabbing;cursor:grabbing}.react-flow__viewport{transform-origin:0 0;z-index:2;pointer-events:none}.react-flow__renderer{z-index:4}.react-flow__selection{z-index:6}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible{outline:none}.react-flow .react-flow__edges{pointer-events:none;overflow:visible}.react-flow__edge-path,.react-flow__connection-path{stroke:#b1b1b7;stroke-width:1;fill:none}.react-flow__edge{pointer-events:visibleStroke;cursor:pointer}.react-flow__edge.animated path{stroke-dasharray:5;-webkit-animation:dashdraw .5s linear infinite;animation:dashdraw .5s linear infinite}.react-flow__edge.animated path.react-flow__edge-interaction{stroke-dasharray:none;-webkit-animation:none;animation:none}.react-flow__edge.inactive{pointer-events:none}.react-flow__edge.selected,.react-flow__edge:focus,.react-flow__edge:focus-visible{outline:none}.react-flow__edge.selected .react-flow__edge-path,.react-flow__edge:focus .react-flow__edge-path,.react-flow__edge:focus-visible .react-flow__edge-path{stroke:#555}.react-flow__edge-textwrapper{pointer-events:all}.react-flow__edge-textbg{fill:#fff}.react-flow__edge .react-flow__edge-text{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__connection{pointer-events:none}.react-flow__connection .animated{stroke-dasharray:5;-webkit-animation:dashdraw .5s linear infinite;animation:dashdraw .5s linear infinite}.react-flow__connectionline{z-index:1001}.react-flow__nodes{pointer-events:none;transform-origin:0 0}.react-flow__node{position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:all;transform-origin:0 0;box-sizing:border-box;cursor:-webkit-grab;cursor:grab}.react-flow__node.dragging{cursor:-webkit-grabbing;cursor:grabbing}.react-flow__nodesselection{z-index:3;transform-origin:left top;pointer-events:none}.react-flow__nodesselection-rect{position:absolute;pointer-events:all;cursor:-webkit-grab;cursor:grab}.react-flow__handle{position:absolute;pointer-events:none;min-width:5px;min-height:5px;width:6px;height:6px;background:#1a192b;border:1px solid white;border-radius:100%}.react-flow__handle.connectionindicator{pointer-events:all;cursor:crosshair}.react-flow__handle-bottom{top:auto;left:50%;bottom:-4px;transform:translate(-50%)}.react-flow__handle-top{left:50%;top:-4px;transform:translate(-50%)}.react-flow__handle-left{top:50%;left:-4px;transform:translateY(-50%)}.react-flow__handle-right{right:-4px;top:50%;transform:translateY(-50%)}.react-flow__edgeupdater{cursor:move;pointer-events:all}.react-flow__panel{position:absolute;z-index:5;margin:15px}.react-flow__panel.top{top:0}.react-flow__panel.bottom{bottom:0}.react-flow__panel.left{left:0}.react-flow__panel.right{right:0}.react-flow__panel.center{left:50%;transform:translate(-50%)}.react-flow__attribution{font-size:10px;background:#ffffff80;padding:2px 3px;margin:0}.react-flow__attribution a{text-decoration:none;color:#999}@-webkit-keyframes dashdraw{0%{stroke-dashoffset:10}}@keyframes dashdraw{0%{stroke-dashoffset:10}}.react-flow__edgelabel-renderer{position:absolute;width:100%;height:100%;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__edge.updating .react-flow__edge-path{stroke:#777}.react-flow__edge-text{font-size:10px}.react-flow__node.selectable:focus,.react-flow__node.selectable:focus-visible{outline:none}.react-flow__node-default,.react-flow__node-input,.react-flow__node-output,.react-flow__node-group{padding:10px;border-radius:3px;width:150px;font-size:12px;color:#222;text-align:center;border-width:1px;border-style:solid;border-color:#1a192b;background-color:#fff}.react-flow__node-default.selectable:hover,.react-flow__node-input.selectable:hover,.react-flow__node-output.selectable:hover,.react-flow__node-group.selectable:hover{box-shadow:0 1px 4px 1px #00000014}.react-flow__node-default.selectable.selected,.react-flow__node-default.selectable:focus,.react-flow__node-default.selectable:focus-visible,.react-flow__node-input.selectable.selected,.react-flow__node-input.selectable:focus,.react-flow__node-input.selectable:focus-visible,.react-flow__node-output.selectable.selected,.react-flow__node-output.selectable:focus,.react-flow__node-output.selectable:focus-visible,.react-flow__node-group.selectable.selected,.react-flow__node-group.selectable:focus,.react-flow__node-group.selectable:focus-visible{box-shadow:0 0 0 .5px #1a192b}.react-flow__node-group{background-color:#f0f0f040}.react-flow__nodesselection-rect,.react-flow__selection{background:#0059dc14;border:1px dotted rgba(0,89,220,.8)}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible,.react-flow__selection:focus,.react-flow__selection:focus-visible{outline:none}.react-flow__controls{box-shadow:0 0 2px 1px #00000014}.react-flow__controls-button{border:none;background:#fefefe;border-bottom:1px solid #eee;box-sizing:content-box;display:flex;justify-content:center;align-items:center;width:16px;height:16px;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none;padding:5px}.react-flow__controls-button:hover{background:#f4f4f4}.react-flow__controls-button svg{width:100%;max-width:12px;max-height:12px}.react-flow__controls-button:disabled{pointer-events:none}.react-flow__controls-button:disabled svg{fill-opacity:.4}.react-flow__minimap{background-color:#fff}.react-flow__minimap svg{display:block}.react-flow__resize-control{position:absolute}.react-flow__resize-control.left,.react-flow__resize-control.right{cursor:ew-resize}.react-flow__resize-control.top,.react-flow__resize-control.bottom{cursor:ns-resize}.react-flow__resize-control.top.left,.react-flow__resize-control.bottom.right{cursor:nwse-resize}.react-flow__resize-control.bottom.left,.react-flow__resize-control.top.right{cursor:nesw-resize}.react-flow__resize-control.handle{width:4px;height:4px;border:1px solid #fff;border-radius:1px;background-color:#3367d9;transform:translate(-50%,-50%)}.react-flow__resize-control.handle.left{left:0;top:50%}.react-flow__resize-control.handle.right{left:100%;top:50%}.react-flow__resize-control.handle.top{left:50%;top:0}.react-flow__resize-control.handle.bottom{left:50%;top:100%}.react-flow__resize-control.handle.top.left,.react-flow__resize-control.handle.bottom.left{left:0}.react-flow__resize-control.handle.top.right,.react-flow__resize-control.handle.bottom.right{left:100%}.react-flow__resize-control.line{border-color:#3367d9;border-width:0;border-style:solid}.react-flow__resize-control.line.left,.react-flow__resize-control.line.right{width:1px;transform:translate(-50%);top:0;height:100%}.react-flow__resize-control.line.left{left:0;border-left-width:1px}.react-flow__resize-control.line.right{left:100%;border-right-width:1px}.react-flow__resize-control.line.top,.react-flow__resize-control.line.bottom{height:1px;transform:translateY(-50%);left:0;width:100%}.react-flow__resize-control.line.top{top:0;border-top-width:1px}.react-flow__resize-control.line.bottom{border-bottom-width:1px;top:100%}:root{--bg: #14110f;--bg-raised: #1c1815;--bg-card: #221d19;--border: #33291f;--border-strong: #4a3c2c;--text: #ece6dd;--text-dim: #a89a86;--accent: #e0a63a;--accent-soft: rgba(224, 166, 58, .15);--accent-ink: #241a08;--pk: #f2c14e;--err: #f0857a;--warn: #e6a94a;--ok: #6cbf73;--font: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;--mono: "SF Mono", ui-monospace, "Cascadia Code", Menlo, monospace}*{box-sizing:border-box}html,body,#root{height:100%;margin:0}body{font-family:var(--font);background:var(--bg);color:var(--text)}.app{display:flex;flex-direction:column;height:100%}.canvas-wrap{flex:1;position:relative;min-height:0}.react-flow{background:var(--bg)}.topbar{display:flex;align-items:center;gap:16px;padding:10px 16px;background:var(--bg-raised);border-bottom:1px solid var(--border);z-index:10}.brand{display:flex;align-items:baseline;gap:8px;white-space:nowrap}.logo{color:var(--accent);font-size:18px}.brand-name{font-weight:700;letter-spacing:.02em}.project-name{color:var(--text-dim);font-size:13px}.search{flex:0 1 340px;padding:7px 12px;border-radius:8px;border:1px solid var(--border);background:var(--bg-card);color:var(--text);font-size:13px;outline:none}.search:focus{border-color:var(--accent)}.legend{display:flex;gap:12px;flex-wrap:wrap;font-size:12px;color:var(--text-dim)}.legend-item{display:inline-flex;align-items:center;gap:5px}.swatch{width:10px;height:10px;border-radius:3px;display:inline-block}.stats{margin-left:auto;display:flex;gap:12px;font-size:12px;color:var(--text-dim)}.diag-chip{padding:2px 8px;border-radius:99px;font-weight:600}.diag-chip.ok{background:#34d39926;color:var(--ok)}.diag-chip.warn{background:#fbbf2426;color:var(--warn)}.diag-chip.err{background:#f8717126;color:var(--err)}.actions{display:flex;gap:6px}.tool-btn{padding:6px 10px;border-radius:8px;border:1px solid var(--border);background:var(--bg-card);color:var(--text-dim);cursor:pointer;font-size:13px}.tool-btn:hover{color:var(--text);border-color:var(--border-strong)}.tool-btn.active{color:var(--accent);border-color:var(--accent)}.entity-node{width:264px;background:var(--bg-card);border:1px solid var(--border);border-top:3px solid var(--accent);border-radius:10px;overflow:hidden;box-shadow:0 4px 18px #00000059;font-size:12px;transition:opacity .15s,box-shadow .15s,border-color .15s}.entity-node.selected{border-color:var(--accent);box-shadow:0 0 0 2px var(--accent),0 8px 24px #00000080}.entity-node.highlighted{box-shadow:0 0 0 2px var(--pk),0 8px 24px #00000080}.entity-node.dimmed{opacity:.18}.entity-header{display:flex;align-items:center;justify-content:space-between;padding:10px 12px;background:#ffffff08;border-bottom:1px solid var(--border)}.entity-name{font-weight:700;font-size:13px;letter-spacing:.01em}.entity-badges{display:flex;gap:4px}.badge{font-size:10px;padding:1px 6px;border-radius:99px;background:var(--accent-soft);color:var(--accent);text-transform:uppercase;letter-spacing:.05em}.badge.ontology{background:#93c5fd1f;color:#93c5fd}.attr-section{padding:4px 0}.attr-section.keys{border-bottom:1px solid var(--border);background:#fcd34d0a}.attr-row{display:flex;align-items:center;gap:6px;padding:3px 12px;height:26px;line-height:20px;position:relative}.attr-row.empty{color:var(--text-dim);font-style:italic}.attr-row.rel-hit{background:var(--accent-soft)}.attr-row.rel-dim{opacity:.35}.attr-row.endpoint .attr-name{font-style:normal}.attr-port{width:8px!important;height:8px!important;opacity:0;top:50%!important}.attr-port.react-flow__handle-left{left:-5px!important}.attr-port.react-flow__handle-right{right:-5px!important}.entity-node:hover .attr-port{opacity:.5}.attr-row:hover .attr-port{opacity:1!important;background:var(--accent)!important}.attr-icon{width:14px;text-align:center;font-size:10px;flex:none}.attr-name{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.attr-name.pk{color:var(--pk);font-weight:600}.attr-type{color:var(--text-dim);font-family:var(--mono);font-size:10px;flex:none}.attr-notnull{color:var(--text-dim);font-size:8px;flex:none}.port{width:11px!important;height:11px!important;background:var(--border-strong)!important;border:2px solid var(--bg)!important;opacity:.55;transition:transform .12s ease,background .12s ease,opacity .12s ease}.entity-node:hover .port{opacity:1;background:var(--accent)!important;transform:scale(1.25);box-shadow:0 0 0 4px var(--accent-soft);cursor:crosshair}.port:hover{transform:scale(1.6)!important;cursor:crosshair}.entity-node:hover{border-color:var(--accent);box-shadow:0 0 0 1px #e0a63a40}.react-flow__connectionline .react-flow__edge-path,.react-flow__connection-path{stroke:var(--accent)!important;stroke-width:2!important}.rel-path{stroke:var(--border-strong);stroke-width:1.6}.rel-edge{cursor:pointer}.rel-glyph{stroke:var(--border-strong);stroke-width:1.6;fill:none}.rel-glyph.ring{fill:var(--bg)}.rel-edge:hover .rel-path,.rel-edge.selected .rel-path,.rel-edge:hover .rel-glyph,.rel-edge.selected .rel-glyph{stroke:var(--accent)}.rel-edge.dimmed{opacity:.12}.rel-label{fill:var(--text);font-size:11px;text-anchor:middle;paint-order:stroke;stroke:var(--bg);stroke-width:4px}.detail-panel{position:absolute;top:12px;right:12px;bottom:12px;width:340px;background:var(--bg-raised);border:1px solid var(--border);border-radius:14px;padding:18px;overflow-y:auto;z-index:9;box-shadow:0 12px 40px #00000080}.detail-header{display:flex;justify-content:space-between;align-items:flex-start}.detail-header h2{margin:0 0 6px;font-size:18px}.icon-btn{background:none;border:none;color:var(--text-dim);cursor:pointer;font-size:14px}.icon-btn:hover{color:var(--text)}.definition{color:var(--text-dim);font-size:13px;line-height:1.5}.detail-panel section{margin-top:18px}.detail-panel h3{margin:0 0 8px;font-size:11px;text-transform:uppercase;letter-spacing:.08em;color:var(--text-dim)}.kv{display:flex;gap:8px;margin:4px 0;font-size:12px;align-items:baseline}.kv .k{color:var(--text-dim);min-width:72px}.kv .v{word-break:break-all}.chip{display:inline-block;font-size:11px;padding:2px 8px;margin:2px 4px 2px 0;border-radius:99px;background:#94a3b81f;color:var(--text-dim)}.chip.pattern{background:var(--accent-soft);color:var(--accent)}.chip.layer-industry{background:#93c5fd26;color:#93c5fd}.chip.layer-core{background:var(--accent-soft);color:var(--accent)}.chip.layer-domain{background:#f0abfc26;color:#f0abfc}.chip.layer-specialised{background:#fcd34d26;color:var(--pk)}.cat-badge{font-size:10px;font-weight:700;margin-left:6px;padding:2px 8px;border-radius:5px;cursor:help}.cat-badge.supertype{background:#a78bfa2e;color:#a78bfa}.cat-badge.subtype{background:var(--accent-soft);color:var(--accent)}.udp-row td{padding:3px 6px;border-bottom:1px solid var(--border);font-size:12px}.udp-key{color:var(--text-dim);font-family:var(--mono);font-size:11px}.udp-val{color:var(--text)}.enum-badge{font-size:8px;font-weight:700;margin-left:6px;padding:1px 5px;border-radius:4px;background:#a78bfa2e;color:#a78bfa;vertical-align:middle;cursor:help}.key-row{display:flex;align-items:center;gap:8px;padding:4px 0;font-size:12px}.key-badge{font-size:9px;font-weight:700;padding:2px 6px;border-radius:5px;background:#94a3b826;color:var(--text-dim);flex:none}.key-badge.pk{background:#fcd34d2e;color:var(--pk)}.key-badge.unique,.key-badge.alternate{background:var(--accent-soft);color:var(--accent)}.key-name{font-weight:600}.key-cols{color:var(--text-dim);font-family:var(--mono);font-size:11px}.attr-table{width:100%;border-collapse:collapse;font-size:12px;table-layout:auto}.attr-table td{padding:4px 6px;border-bottom:1px solid var(--border)}.attr-table td:first-child{width:100%}.attr-table td:first-child .edit-input{min-width:120px}.attr-table td.pk{color:var(--pk);font-weight:600}.attr-table td.type{color:var(--text-dim);font-family:var(--mono);font-size:11px}.attr-table td.null{color:var(--text-dim);font-size:10px;text-align:right}.rel-link{display:flex;gap:8px;align-items:center;width:100%;background:var(--bg-card);border:1px solid var(--border);border-radius:8px;color:var(--text);padding:7px 10px;margin:4px 0;cursor:pointer;font-size:12px;text-align:left}.rel-link:hover{border-color:var(--accent)}.rel-card{color:var(--text-dim);font-family:var(--mono);font-size:11px}.ulid{font-family:var(--mono);font-size:11px;color:var(--text-dim);cursor:copy;word-break:break-all}.ulid:hover{color:var(--accent)}.splash{height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;color:var(--text-dim)}.splash.error pre{background:var(--bg-card);padding:12px 16px;border-radius:8px;max-width:640px;overflow:auto;color:var(--err);font-size:12px}.react-flow__minimap{background:var(--bg-raised)!important;border-radius:10px}.react-flow__controls{border-radius:10px;overflow:hidden;box-shadow:none!important}.react-flow__controls-button{background:var(--bg-raised)!important;border-bottom:1px solid var(--border)!important;fill:var(--text-dim)!important}.react-flow__controls-button:hover{fill:var(--text)!important}.edit-input{width:100%;padding:6px 9px;border-radius:7px;font-size:12px;border:1px solid var(--border);background:var(--bg-card);color:var(--text);font-family:var(--font);outline:none}.edit-input:focus{border-color:var(--accent)}.entity-title-input{font-size:17px;font-weight:700;background:transparent;border-color:transparent;padding-left:0}.entity-title-input:hover,.entity-title-input:focus{border-color:var(--border);background:var(--bg-card);padding-left:9px}.definition-input{color:var(--text-dim);line-height:1.5;resize:vertical}.chip-select,.cell-select{font-size:11px;padding:2px 6px;margin:2px 6px 2px 0;border-radius:99px;background:#94a3b81f;color:var(--text-dim);border:1px solid transparent;outline:none}.chip-select:hover,.cell-select:hover{border-color:var(--border-strong);color:var(--text)}.cell-select{border-radius:6px;background:transparent;max-width:110px}.mini-btn{font-size:11px;padding:3px 9px;border-radius:7px;cursor:pointer;border:1px solid var(--border);background:var(--bg-card);color:var(--text-dim)}.mini-btn:hover{color:var(--accent);border-color:var(--accent)}.mini-btn.danger:hover{color:var(--err);border-color:var(--err)}.h3-actions{float:right;display:inline-flex;gap:6px}.empty-hint{color:var(--text-dim);font-size:12px;font-style:italic}.add-attr{display:flex;gap:6px;margin-top:8px}.rel-row{display:flex;gap:6px;align-items:center}.rel-row .rel-link{flex:1}.tool-btn.primary{color:var(--accent);border-color:#e0a63a66;font-weight:600}.tool-btn.badged:after{content:"●";color:var(--warn);margin-left:4px;font-size:8px;vertical-align:super}.divider{width:1px;background:var(--border);margin:0 4px;align-self:stretch}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;background:#05080db3;z-index:50;display:flex;align-items:center;justify-content:center}.modal{width:440px;max-height:80vh;overflow-y:auto;background:var(--bg-raised);border:1px solid var(--border-strong);border-radius:14px;padding:20px;box-shadow:0 24px 80px #0009}.modal.wide{width:600px}.modal-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:14px}.modal-header h2{margin:0;font-size:16px}.modal-search{margin-bottom:10px}.modal-footer{display:flex;gap:10px;justify-content:flex-end;align-items:center;margin-top:14px}.modal-footer label{font-size:11px;color:var(--text-dim);display:flex;flex-direction:column;gap:3px}.modal-footer select,.form-row select{background:var(--bg-card);color:var(--text);border:1px solid var(--border);border-radius:7px;padding:5px 8px;font-size:12px}.primary-btn{padding:8px 16px;border-radius:8px;border:none;cursor:pointer;background:var(--accent);color:var(--accent-ink);font-weight:700;font-size:13px}.primary-btn:disabled{opacity:.4;cursor:default}.danger-btn{padding:8px 16px;border-radius:8px;border:1px solid var(--err);cursor:pointer;background:#f8717124;color:var(--err);font-weight:700;font-size:13px}.form-row{display:flex;flex-direction:column;gap:4px;margin-bottom:14px;font-size:12px;color:var(--text-dim)}.form-row>label{font-weight:600;letter-spacing:.02em;text-transform:uppercase;font-size:10px}.form-error{color:var(--err);font-size:11px}.form-preview{color:var(--text-dim);font-size:11px;word-break:break-all;opacity:.85}.form-preview:before{content:""}.form-hint{color:var(--text-dim);font-size:11px;font-style:italic;opacity:.75;word-break:break-word}.term-results{display:flex;flex-direction:column;gap:8px;max-height:44vh;overflow-y:auto}.term-card{text-align:left;background:var(--bg-card);border:1px solid var(--border);border-radius:10px;padding:10px 12px;cursor:pointer;color:var(--text)}.term-card:hover{border-color:var(--border-strong)}.term-card.picked{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}.term-head{display:flex;justify-content:space-between;align-items:baseline}.term-label{font-weight:600;font-size:13px}.term-source{font-size:10px;color:var(--text-dim);text-transform:uppercase;letter-spacing:.06em}.term-iri{font-size:10px;color:var(--accent);display:block;margin:2px 0;word-break:break-all}.term-def{font-size:11px;color:var(--text-dim);margin:4px 0 0;line-height:1.45}.kind-badge{font-size:8px;padding:1px 5px;margin-right:6px;border-radius:999px;background:#f0abfc26;color:#f0abfc;letter-spacing:.04em}.src-picker{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:10px}.src-chip{display:inline-flex;align-items:center;gap:5px;font-size:11px;padding:3px 9px;border-radius:999px;background:var(--bg);border:1px solid var(--border);color:var(--text-dim);cursor:pointer}.src-chip:hover{border-color:var(--border-strong);color:var(--text)}.src-chip.active{border-color:var(--accent);color:var(--accent);background:var(--accent-soft)}.src-layer{font-size:8px;padding:0 5px;border-radius:999px;text-transform:uppercase;letter-spacing:.04em}.side-panel{position:absolute;top:12px;right:12px;bottom:12px;width:380px;background:var(--bg-raised);border:1px solid var(--border);border-radius:14px;padding:18px;overflow-y:auto;z-index:9;box-shadow:0 12px 40px #00000080}.side-panel h2{margin:0;font-size:16px}.side-panel h4{margin:10px 0 6px;font-size:10px;text-transform:uppercase;letter-spacing:.08em;color:var(--text-dim)}.panel-body{margin-top:12px}.panel-body.ok{color:var(--ok)}.meta-line{font-size:10px;color:var(--text-dim);margin:6px 0 10px}.coverage-banner{font-size:12px;padding:8px 12px;border-radius:9px;margin-bottom:12px;background:#34d3991a;color:var(--ok)}.coverage-banner.warn{background:#fbbf241a;color:var(--warn)}.layer-band{border:1px dashed var(--border);border-radius:10px;padding:8px 12px 10px;margin-bottom:10px}.layer-band.external{border-style:solid;background:#93c5fd0a}.stack-term{display:flex;justify-content:space-between;align-items:baseline;gap:8px;width:100%;background:var(--bg-card);border:1px solid var(--border);color:var(--text);border-radius:7px;padding:5px 10px;margin:4px 0;font-size:12px;cursor:pointer;text-align:left}div.stack-term{cursor:default}.stack-term:hover{border-color:var(--border-strong)}.stack-term.uncovered{border-color:var(--err)}.align-arrow{font-size:10px;color:var(--accent);white-space:nowrap}.align-arrow.unresolved{color:var(--warn)}.align-arrow.missing{color:var(--err);font-style:italic}.align-arrow.proposed{color:var(--warn);font-style:italic}.ref-list{display:flex;flex-direction:column;gap:6px;margin-top:4px}.ref-card{border:1px solid var(--border);border-radius:8px;padding:6px 8px;background:var(--bg)}.ref-card.proposed{border-color:var(--warn)}.ref-head{display:flex;align-items:baseline;gap:8px;justify-content:space-between}.ref-uri{font-family:var(--mono);font-size:12px;word-break:break-all}.ref-status{font-size:9px;text-transform:uppercase;letter-spacing:.04em}.ref-status.accepted{color:var(--accent)}.ref-status.proposed{color:var(--warn)}.ref-meta{display:flex;flex-wrap:wrap;align-items:center;gap:6px;margin-top:5px}.ref-pill{font-size:10px;padding:1px 6px;border-radius:999px;background:var(--accent-soft);color:var(--accent)}.ref-via{font-size:10px;color:var(--text-dim)}.ref-actions{display:flex;gap:6px;margin-top:6px}.dirty-list{list-style:none;padding:0;margin:0 0 10px;font-size:12px}.dirty-list li{padding:2px 0}.dirty-state{color:var(--warn);margin-right:6px;font-family:var(--mono)}.diff-view{background:var(--bg);border:1px solid var(--border);border-radius:9px;padding:10px;font-size:10.5px;line-height:1.5;overflow:auto;max-height:42vh;font-family:var(--mono);white-space:pre;margin-bottom:10px}.diff-add{color:var(--ok)}.diff-del{color:var(--err)}.diff-hunk{color:#93c5fd}.decision{border:1px solid var(--border);border-radius:9px;padding:8px 12px;margin-bottom:8px}.decision.accepted{opacity:.65}.decision.rejected{opacity:.45}.decision-head{display:flex;gap:6px;align-items:center}.decision-mark{font-weight:700}.decision-subject{font-size:12px;margin:6px 0}.decision-actions{display:flex;gap:6px}.toast{position:absolute;bottom:20px;left:50%;transform:translate(-50%);background:var(--bg-raised);border:1px solid var(--warn);color:var(--text);border-radius:10px;padding:10px 18px;font-size:12px;z-index:60;box-shadow:0 10px 30px #00000080} diff --git a/packages/server/src/mdl_server/static/assets/styles-DG4k7QGS.js b/packages/server/src/mdl_server/static/assets/styles-BTZUJ0jx.js similarity index 72% rename from packages/server/src/mdl_server/static/assets/styles-DG4k7QGS.js rename to packages/server/src/mdl_server/static/assets/styles-BTZUJ0jx.js index 8705310..f934b2f 100644 --- a/packages/server/src/mdl_server/static/assets/styles-DG4k7QGS.js +++ b/packages/server/src/mdl_server/static/assets/styles-BTZUJ0jx.js @@ -14,9 +14,9 @@ var Ua=Object.defineProperty;var Xa=(e,t,n)=>t in e?Ua(e,t,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var En=b,il=sl;function ol(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var al=typeof Object.is=="function"?Object.is:ol,ll=il.useSyncExternalStore,cl=En.useRef,ul=En.useEffect,dl=En.useMemo,fl=En.useDebugValue;ci.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var i=cl(null);if(i.current===null){var o={hasValue:!1,value:null};i.current=o}else o=i.current;i=dl(function(){function l(f){if(!c){if(c=!0,u=f,f=r(f),s!==void 0&&o.hasValue){var y=o.value;if(s(y,f))return d=y}return d=f}if(y=d,al(u,f))return y;var x=r(f);return s!==void 0&&s(y,x)?(u=f,y):(u=f,d=x)}var c=!1,u,d,m=n===void 0?null:n;return[function(){return l(t())},m===null?void 0:function(){return l(m())}]},[t,n,r,s]);var a=ll(e,i[0],i[1]);return ul(function(){o.hasValue=!0,o.value=a},[a]),fl(a),a};li.exports=ci;var hl=li.exports;const ml=ai(hl),pl={},Gr=e=>{let t;const n=new Set,r=(u,d)=>{const m=typeof u=="function"?u(t):u;if(!Object.is(m,t)){const f=t;t=d??(typeof m!="object"||m===null)?m:Object.assign({},t,m),n.forEach(y=>y(t,f))}},s=()=>t,l={setState:r,getState:s,getInitialState:()=>c,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(pl?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},c=t=e(r,s,l);return l},gl=e=>e?Gr(e):Gr,{useDebugValue:yl}=$,{useSyncExternalStoreWithSelector:xl}=ml,wl=e=>e;function fi(e,t=wl,n){const r=xl(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return yl(r),r}const Yr=(e,t)=>{const n=gl(e),r=(s,i=t)=>fi(n,s,i);return Object.assign(r,n),r},bl=(e,t)=>e?Yr(e,t):Yr;function fe(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,s]of e)if(!Object.is(s,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var vl={value:()=>{}};function Nn(){for(var e=0,t=arguments.length,n={},r;e=0&&(r=n.slice(s+1),n=n.slice(0,s)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}an.prototype=Nn.prototype={constructor:an,on:function(e,t){var n=this._,r=_l(e+"",n),s,i=-1,o=r.length;if(arguments.length<2){for(;++i0)for(var n=new Array(s),r=0,s,i;r=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Ur.hasOwnProperty(t)?{space:Ur[t],local:e}:e}function Nl(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===er&&t.documentElement.namespaceURI===er?t.createElement(e):t.createElementNS(n,e)}}function Sl(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function hi(e){var t=Sn(e);return(t.local?Sl:Nl)(t)}function kl(){}function yr(e){return e==null?kl:function(){return this.querySelector(e)}}function jl(e){typeof e!="function"&&(e=yr(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s=j&&(j=v+1);!(M=_[j])&&++j=0;)(o=r[s])&&(i&&o.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(o,i),i=o);return this}function Ql(e){e||(e=Jl);function t(d,m){return d&&m?e(d.__data__,m.__data__):!d-!m}for(var n=this._groups,r=n.length,s=new Array(r),i=0;it?1:e>=t?0:NaN}function ec(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function tc(){return Array.from(this)}function nc(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?hc:typeof t=="function"?pc:mc)(e,t,n??"")):vt(this.node(),e)}function vt(e,t){return e.style.getPropertyValue(t)||xi(e).getComputedStyle(e,null).getPropertyValue(t)}function yc(e){return function(){delete this[e]}}function xc(e,t){return function(){this[e]=t}}function wc(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function bc(e,t){return arguments.length>1?this.each((t==null?yc:typeof t=="function"?wc:xc)(e,t)):this.node()[e]}function wi(e){return e.trim().split(/^|\s+/)}function xr(e){return e.classList||new bi(e)}function bi(e){this._node=e,this._names=wi(e.getAttribute("class")||"")}bi.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function vi(e,t){for(var n=xr(e),r=-1,s=t.length;++r=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function Xc(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,s=t.length,i;n()=>e;function tr(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:i,x:o,y:a,dx:l,dy:c,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:u}})}tr.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function su(e){return!e.ctrlKey&&!e.button}function iu(){return this.parentNode}function ou(e,t){return t??{x:e.x,y:e.y}}function au(){return navigator.maxTouchPoints||"ontouchstart"in this}function lu(){var e=su,t=iu,n=ou,r=au,s={},i=Nn("start","drag","end"),o=0,a,l,c,u,d=0;function m(w){w.on("mousedown.drag",f).filter(r).on("touchstart.drag",_).on("touchmove.drag",g,ru).on("touchend.drag touchcancel.drag",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function f(w,M){if(!(u||!e.call(this,w,M))){var C=j(this,t.call(this,w,M),w,M,"mouse");C&&(xe(w.view).on("mousemove.drag",y,Pt).on("mouseup.drag",x,Pt),Si(w.view),Pn(w),c=!1,a=w.clientX,l=w.clientY,C("start",w))}}function y(w){if(yt(w),!c){var M=w.clientX-a,C=w.clientY-l;c=M*M+C*C>d}s.mouse("drag",w)}function x(w){xe(w.view).on("mousemove.drag mouseup.drag",null),ki(w.view,c),yt(w),s.mouse("end",w)}function _(w,M){if(e.call(this,w,M)){var C=w.changedTouches,A=t.call(this,w,M),F=C.length,S,O;for(S=0;S>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Kt(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Kt(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=uu.exec(e))?new ge(t[1],t[2],t[3],1):(t=du.exec(e))?new ge(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=fu.exec(e))?Kt(t[1],t[2],t[3],t[4]):(t=hu.exec(e))?Kt(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=mu.exec(e))?es(t[1],t[2]/100,t[3]/100,1):(t=pu.exec(e))?es(t[1],t[2]/100,t[3]/100,t[4]):Xr.hasOwnProperty(e)?Kr(Xr[e]):e==="transparent"?new ge(NaN,NaN,NaN,0):null}function Kr(e){return new ge(e>>16&255,e>>8&255,e&255,1)}function Kt(e,t,n,r){return r<=0&&(e=t=n=NaN),new ge(e,t,n,r)}function xu(e){return e instanceof Ut||(e=Ft(e)),e?(e=e.rgb(),new ge(e.r,e.g,e.b,e.opacity)):new ge}function nr(e,t,n,r){return arguments.length===1?xu(e):new ge(e,t,n,r??1)}function ge(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}wr(ge,nr,ji(Ut,{brighter(e){return e=e==null?fn:Math.pow(fn,e),new ge(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?zt:Math.pow(zt,e),new ge(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ge(nt(this.r),nt(this.g),nt(this.b),hn(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Qr,formatHex:Qr,formatHex8:wu,formatRgb:Jr,toString:Jr}));function Qr(){return`#${et(this.r)}${et(this.g)}${et(this.b)}`}function wu(){return`#${et(this.r)}${et(this.g)}${et(this.b)}${et((isNaN(this.opacity)?1:this.opacity)*255)}`}function Jr(){const e=hn(this.opacity);return`${e===1?"rgb(":"rgba("}${nt(this.r)}, ${nt(this.g)}, ${nt(this.b)}${e===1?")":`, ${e})`}`}function hn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function nt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function et(e){return e=nt(e),(e<16?"0":"")+e.toString(16)}function es(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Ne(e,t,n,r)}function Ci(e){if(e instanceof Ne)return new Ne(e.h,e.s,e.l,e.opacity);if(e instanceof Ut||(e=Ft(e)),!e)return new Ne;if(e instanceof Ne)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,s=Math.min(t,n,r),i=Math.max(t,n,r),o=NaN,a=i-s,l=(i+s)/2;return a?(t===i?o=(n-r)/a+(n0&&l<1?0:o,new Ne(o,a,l,e.opacity)}function bu(e,t,n,r){return arguments.length===1?Ci(e):new Ne(e,t,n,r??1)}function Ne(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}wr(Ne,bu,ji(Ut,{brighter(e){return e=e==null?fn:Math.pow(fn,e),new Ne(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?zt:Math.pow(zt,e),new Ne(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,s=2*n-r;return new ge(zn(e>=240?e-240:e+120,s,r),zn(e,s,r),zn(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new Ne(ts(this.h),Qt(this.s),Qt(this.l),hn(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=hn(this.opacity);return`${e===1?"hsl(":"hsla("}${ts(this.h)}, ${Qt(this.s)*100}%, ${Qt(this.l)*100}%${e===1?")":`, ${e})`}`}}));function ts(e){return e=(e||0)%360,e<0?e+360:e}function Qt(e){return Math.max(0,Math.min(1,e||0))}function zn(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const $i=e=>()=>e;function vu(e,t){return function(n){return e+n*t}}function _u(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function Eu(e){return(e=+e)==1?Mi:function(t,n){return n-t?_u(t,n,e):$i(isNaN(t)?n:t)}}function Mi(e,t){var n=t-e;return n?vu(e,n):$i(isNaN(e)?t:e)}const ns=function e(t){var n=Eu(t);function r(s,i){var o=n((s=nr(s)).r,(i=nr(i)).r),a=n(s.g,i.g),l=n(s.b,i.b),c=Mi(s.opacity,i.opacity);return function(u){return s.r=o(u),s.g=a(u),s.b=l(u),s.opacity=c(u),s+""}}return r.gamma=e,r}(1);function He(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var rr=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Hn=new RegExp(rr.source,"g");function Nu(e){return function(){return e}}function Su(e){return function(t){return e(t)+""}}function ku(e,t){var n=rr.lastIndex=Hn.lastIndex=0,r,s,i,o=-1,a=[],l=[];for(e=e+"",t=t+"";(r=rr.exec(e))&&(s=Hn.exec(t));)(i=s.index)>n&&(i=t.slice(n,i),a[o]?a[o]+=i:a[++o]=i),(r=r[0])===(s=s[0])?a[o]?a[o]+=s:a[++o]=s:(a[++o]=null,l.push({i:o,x:He(r,s)})),n=Hn.lastIndex;return n180?u+=360:u-c>180&&(c+=360),m.push({i:d.push(s(d)+"rotate(",null,r)-2,x:He(c,u)})):u&&d.push(s(d)+"rotate("+u+r)}function a(c,u,d,m){c!==u?m.push({i:d.push(s(d)+"skewX(",null,r)-2,x:He(c,u)}):u&&d.push(s(d)+"skewX("+u+r)}function l(c,u,d,m,f,y){if(c!==d||u!==m){var x=f.push(s(f)+"scale(",null,",",null,")");y.push({i:x-4,x:He(c,d)},{i:x-2,x:He(u,m)})}else(d!==1||m!==1)&&f.push(s(f)+"scale("+d+","+m+")")}return function(c,u){var d=[],m=[];return c=e(c),u=e(u),i(c.translateX,c.translateY,u.translateX,u.translateY,d,m),o(c.rotate,u.rotate,d,m),a(c.skewX,u.skewX,d,m),l(c.scaleX,c.scaleY,u.scaleX,u.scaleY,d,m),c=u=null,function(f){for(var y=-1,x=m.length,_;++y=0&&e._call.call(void 0,t),e=e._next;--_t}function is(){st=(pn=Vt.now())+kn,_t=Tt=0;try{Du()}finally{_t=0,Pu(),st=0}}function Lu(){var e=Vt.now(),t=e-pn;t>Ti&&(kn-=t,pn=e)}function Pu(){for(var e,t=mn,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:mn=n);Rt=e,ir(r)}function ir(e){if(!_t){Tt&&(Tt=clearTimeout(Tt));var t=e-st;t>24?(e<1/0&&(Tt=setTimeout(is,e-Vt.now()-kn)),Ct&&(Ct=clearInterval(Ct))):(Ct||(pn=Vt.now(),Ct=setInterval(Lu,Ti)),_t=1,Ri(is))}}function os(e,t,n){var r=new gn;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var zu=Nn("start","end","cancel","interrupt"),Hu=[],Di=0,as=1,or=2,ln=3,ls=4,ar=5,cn=6;function jn(e,t,n,r,s,i){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;Fu(e,n,{name:t,index:r,group:s,on:zu,tween:Hu,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Di})}function vr(e,t){var n=Se(e,t);if(n.state>Di)throw new Error("too late; already scheduled");return n}function $e(e,t){var n=Se(e,t);if(n.state>ln)throw new Error("too late; already running");return n}function Se(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Fu(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=Oi(i,0,n.time);function i(c){n.state=as,n.timer.restart(o,n.delay,n.time),n.delay<=c&&o(c-n.delay)}function o(c){var u,d,m,f;if(n.state!==as)return l();for(u in r)if(f=r[u],f.name===n.name){if(f.state===ln)return os(o);f.state===ls?(f.state=cn,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete r[u]):+uor&&r.state=0&&(t=t.slice(0,n)),!t||t==="start"})}function yd(e,t,n){var r,s,i=gd(t)?vr:$e;return function(){var o=i(this,e),a=o.on;a!==r&&(s=(r=a).copy()).on(t,n),o.on=s}}function xd(e,t){var n=this._id;return arguments.length<2?Se(this.node(),n).on.on(e):this.each(yd(n,e,t))}function wd(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function bd(){return this.on("end.remove",wd(this._id))}function vd(e){var t=this._name,n=this._id;typeof e!="function"&&(e=yr(e));for(var r=this._groups,s=r.length,i=new Array(s),o=0;o()=>e;function Wd(e,{sourceEvent:t,target:n,transform:r,dispatch:s}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:s}})}function Oe(e,t,n){this.k=e,this.x=t,this.y=n}Oe.prototype={constructor:Oe,scale:function(e){return e===1?this:new Oe(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Oe(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var De=new Oe(1,0,0);Oe.prototype;function Fn(e){e.stopImmediatePropagation()}function $t(e){e.preventDefault(),e.stopImmediatePropagation()}function Ud(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Xd(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function cs(){return this.__zoom||De}function qd(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Zd(){return navigator.maxTouchPoints||"ontouchstart"in this}function Kd(e,t,n){var r=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(s>r?(r+s)/2:Math.min(0,r)||Math.max(0,s),o>i?(i+o)/2:Math.min(0,i)||Math.max(0,o))}function Hi(){var e=Ud,t=Xd,n=Kd,r=qd,s=Zd,i=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],a=250,l=Ru,c=Nn("start","zoom","end"),u,d,m,f=500,y=150,x=0,_=10;function g(p){p.property("__zoom",cs).on("wheel.zoom",F,{passive:!1}).on("mousedown.zoom",S).on("dblclick.zoom",O).filter(s).on("touchstart.zoom",z).on("touchmove.zoom",G).on("touchend.zoom touchcancel.zoom",V).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}g.transform=function(p,k,E,T){var D=p.selection?p.selection():p;D.property("__zoom",cs),p!==D?M(p,k,E,T):D.interrupt().each(function(){C(this,arguments).event(T).start().zoom(null,typeof k=="function"?k.apply(this,arguments):k).end()})},g.scaleBy=function(p,k,E,T){g.scaleTo(p,function(){var D=this.__zoom.k,N=typeof k=="function"?k.apply(this,arguments):k;return D*N},E,T)},g.scaleTo=function(p,k,E,T){g.transform(p,function(){var D=t.apply(this,arguments),N=this.__zoom,I=E==null?w(D):typeof E=="function"?E.apply(this,arguments):E,L=N.invert(I),P=typeof k=="function"?k.apply(this,arguments):k;return n(j(v(N,P),I,L),D,o)},E,T)},g.translateBy=function(p,k,E,T){g.transform(p,function(){return n(this.__zoom.translate(typeof k=="function"?k.apply(this,arguments):k,typeof E=="function"?E.apply(this,arguments):E),t.apply(this,arguments),o)},null,T)},g.translateTo=function(p,k,E,T,D){g.transform(p,function(){var N=t.apply(this,arguments),I=this.__zoom,L=T==null?w(N):typeof T=="function"?T.apply(this,arguments):T;return n(De.translate(L[0],L[1]).scale(I.k).translate(typeof k=="function"?-k.apply(this,arguments):-k,typeof E=="function"?-E.apply(this,arguments):-E),N,o)},T,D)};function v(p,k){return k=Math.max(i[0],Math.min(i[1],k)),k===p.k?p:new Oe(k,p.x,p.y)}function j(p,k,E){var T=k[0]-E[0]*p.k,D=k[1]-E[1]*p.k;return T===p.x&&D===p.y?p:new Oe(p.k,T,D)}function w(p){return[(+p[0][0]+ +p[1][0])/2,(+p[0][1]+ +p[1][1])/2]}function M(p,k,E,T){p.on("start.zoom",function(){C(this,arguments).event(T).start()}).on("interrupt.zoom end.zoom",function(){C(this,arguments).event(T).end()}).tween("zoom",function(){var D=this,N=arguments,I=C(D,N).event(T),L=t.apply(D,N),P=E==null?w(L):typeof E=="function"?E.apply(D,N):E,R=Math.max(L[1][0]-L[0][0],L[1][1]-L[0][1]),H=D.__zoom,B=typeof k=="function"?k.apply(D,N):k,X=l(H.invert(P).concat(R/H.k),B.invert(P).concat(R/B.k));return function(q){if(q===1)q=B;else{var J=X(q),Q=R/J[2];q=new Oe(Q,P[0]-J[0]*Q,P[1]-J[1]*Q)}I.zoom(null,q)}})}function C(p,k,E){return!E&&p.__zooming||new A(p,k)}function A(p,k){this.that=p,this.args=k,this.active=0,this.sourceEvent=null,this.extent=t.apply(p,k),this.taps=0}A.prototype={event:function(p){return p&&(this.sourceEvent=p),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(p,k){return this.mouse&&p!=="mouse"&&(this.mouse[1]=k.invert(this.mouse[0])),this.touch0&&p!=="touch"&&(this.touch0[1]=k.invert(this.touch0[0])),this.touch1&&p!=="touch"&&(this.touch1[1]=k.invert(this.touch1[0])),this.that.__zoom=k,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(p){var k=xe(this.that).datum();c.call(p,this.that,new Wd(p,{sourceEvent:this.sourceEvent,target:g,transform:this.that.__zoom,dispatch:c}),k)}};function F(p,...k){if(!e.apply(this,arguments))return;var E=C(this,k).event(p),T=this.__zoom,D=Math.max(i[0],Math.min(i[1],T.k*Math.pow(2,r.apply(this,arguments)))),N=Ee(p);if(E.wheel)(E.mouse[0][0]!==N[0]||E.mouse[0][1]!==N[1])&&(E.mouse[1]=T.invert(E.mouse[0]=N)),clearTimeout(E.wheel);else{if(T.k===D)return;E.mouse=[N,T.invert(N)],un(this),E.start()}$t(p),E.wheel=setTimeout(I,y),E.zoom("mouse",n(j(v(T,D),E.mouse[0],E.mouse[1]),E.extent,o));function I(){E.wheel=null,E.end()}}function S(p,...k){if(m||!e.apply(this,arguments))return;var E=p.currentTarget,T=C(this,k,!0).event(p),D=xe(p.view).on("mousemove.zoom",P,!0).on("mouseup.zoom",R,!0),N=Ee(p,E),I=p.clientX,L=p.clientY;Si(p.view),Fn(p),T.mouse=[N,this.__zoom.invert(N)],un(this),T.start();function P(H){if($t(H),!T.moved){var B=H.clientX-I,X=H.clientY-L;T.moved=B*B+X*X>x}T.event(H).zoom("mouse",n(j(T.that.__zoom,T.mouse[0]=Ee(H,E),T.mouse[1]),T.extent,o))}function R(H){D.on("mousemove.zoom mouseup.zoom",null),ki(H.view,T.moved),$t(H),T.event(H).end()}}function O(p,...k){if(e.apply(this,arguments)){var E=this.__zoom,T=Ee(p.changedTouches?p.changedTouches[0]:p,this),D=E.invert(T),N=E.k*(p.shiftKey?.5:2),I=n(j(v(E,N),T,D),t.apply(this,k),o);$t(p),a>0?xe(this).transition().duration(a).call(M,I,T,p):xe(this).call(g.transform,I,T,p)}}function z(p,...k){if(e.apply(this,arguments)){var E=p.touches,T=E.length,D=C(this,k,p.changedTouches.length===T).event(p),N,I,L,P;for(Fn(p),I=0;I"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,t)=>`Couldn't create edge for ${e?"target":"source"} handle id: "${e?t.targetHandle:t.sourceHandle}", edge id: ${t.id}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`},Fi=Pe.error001();function re(e,t){const n=b.useContext(Cn);if(n===null)throw new Error(Fi);return fi(n,e,t)}const de=()=>{const e=b.useContext(Cn);if(e===null)throw new Error(Fi);return b.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},Jd=e=>e.userSelectionActive?"none":"all";function Er({position:e,children:t,className:n,style:r,...s}){const i=re(Jd),o=`${e}`.split("-");return $.createElement("div",{className:he(["react-flow__panel",n,...o]),style:{...r,pointerEvents:i},...s},t)}function ef({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:$.createElement(Er,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},$.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const tf=({x:e,y:t,label:n,labelStyle:r={},labelShowBg:s=!0,labelBgStyle:i={},labelBgPadding:o=[2,4],labelBgBorderRadius:a=2,children:l,className:c,...u})=>{const d=b.useRef(null),[m,f]=b.useState({x:0,y:0,width:0,height:0}),y=he(["react-flow__edge-textwrapper",c]);return b.useEffect(()=>{if(d.current){const x=d.current.getBBox();f({x:x.x,y:x.y,width:x.width,height:x.height})}},[n]),typeof n>"u"||!n?null:$.createElement("g",{transform:`translate(${e-m.width/2} ${t-m.height/2})`,className:y,visibility:m.width?"visible":"hidden",...u},s&&$.createElement("rect",{width:m.width+2*o[0],x:-o[0],y:-o[1],height:m.height+2*o[1],className:"react-flow__edge-textbg",style:i,rx:a,ry:a}),$.createElement("text",{className:"react-flow__edge-text",y:m.height/2,dy:"0.3em",ref:d,style:r},n),l)};var nf=b.memo(tf);const Nr=e=>({width:e.offsetWidth,height:e.offsetHeight}),Et=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Sr=(e={x:0,y:0},t)=>({x:Et(e.x,t[0][0],t[1][0]),y:Et(e.y,t[0][1],t[1][1])}),us=(e,t,n)=>en?-Et(Math.abs(e-n),1,50)/50:0,Vi=(e,t)=>{const n=us(e.x,35,t.width-35)*20,r=us(e.y,35,t.height-35)*20;return[n,r]},Bi=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},Gi=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Bt=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Yi=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),ds=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),rf=(e,t)=>Yi(Gi(Bt(e),Bt(t))),lr=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},sf=e=>we(e.width)&&we(e.height)&&we(e.x)&&we(e.y),we=e=>!isNaN(e)&&isFinite(e),ie=Symbol.for("internals"),Wi=["Enter"," ","Escape"],of=(e,t)=>{},af=e=>"nativeEvent"in e;function cr(e){var s,i;const t=af(e)?e.nativeEvent:e,n=((i=(s=t.composedPath)==null?void 0:s.call(t))==null?void 0:i[0])||e.target;return["INPUT","SELECT","TEXTAREA"].includes(n==null?void 0:n.nodeName)||(n==null?void 0:n.hasAttribute("contenteditable"))||!!(n!=null&&n.closest(".nokey"))}const Ui=e=>"clientX"in e,Ge=(e,t)=>{var i,o;const n=Ui(e),r=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,s=n?e.clientY:(o=e.touches)==null?void 0:o[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:s-((t==null?void 0:t.top)??0)}},yn=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},Xt=({id:e,path:t,labelX:n,labelY:r,label:s,labelStyle:i,labelShowBg:o,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,style:u,markerEnd:d,markerStart:m,interactionWidth:f=20})=>$.createElement($.Fragment,null,$.createElement("path",{id:e,style:u,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:d,markerStart:m}),f&&$.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:f,className:"react-flow__edge-interaction"}),s&&we(n)&&we(r)?$.createElement(nf,{x:n,y:r,label:s,labelStyle:i,labelShowBg:o,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c}):null);Xt.displayName="BaseEdge";function Mt(e,t,n){return n===void 0?n:r=>{const s=t().edges.find(i=>i.id===e);s&&n(r,{...s})}}function Xi({sourceX:e,sourceY:t,targetX:n,targetY:r}){const s=Math.abs(n-e)/2,i=n{const[_,g,v]=Zi({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:r,targetPosition:i});return $.createElement(Xt,{path:_,labelX:g,labelY:v,label:o,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:d,style:m,markerEnd:f,markerStart:y,interactionWidth:x})});kr.displayName="SimpleBezierEdge";const hs={[W.Left]:{x:-1,y:0},[W.Right]:{x:1,y:0},[W.Top]:{x:0,y:-1},[W.Bottom]:{x:0,y:1}},lf=({source:e,sourcePosition:t=W.Bottom,target:n})=>t===W.Left||t===W.Right?e.xMath.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function cf({source:e,sourcePosition:t=W.Bottom,target:n,targetPosition:r=W.Top,center:s,offset:i}){const o=hs[t],a=hs[r],l={x:e.x+o.x*i,y:e.y+o.y*i},c={x:n.x+a.x*i,y:n.y+a.y*i},u=lf({source:l,sourcePosition:t,target:c}),d=u.x!==0?"x":"y",m=u[d];let f=[],y,x;const _={x:0,y:0},g={x:0,y:0},[v,j,w,M]=Xi({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(o[d]*a[d]===-1){y=s.x??v,x=s.y??j;const A=[{x:y,y:l.y},{x:y,y:c.y}],F=[{x:l.x,y:x},{x:c.x,y:x}];o[d]===m?f=d==="x"?A:F:f=d==="x"?F:A}else{const A=[{x:l.x,y:c.y}],F=[{x:c.x,y:l.y}];if(d==="x"?f=o.x===m?F:A:f=o.y===m?A:F,t===r){const V=Math.abs(e[d]-n[d]);if(V<=i){const p=Math.min(i-1,i-V);o[d]===m?_[d]=(l[d]>e[d]?-1:1)*p:g[d]=(c[d]>n[d]?-1:1)*p}}if(t!==r){const V=d==="x"?"y":"x",p=o[d]===a[V],k=l[V]>c[V],E=l[V]=G?(y=(S.x+O.x)/2,x=f[0].y):(y=f[0].x,x=(S.y+O.y)/2)}return[[e,{x:l.x+_.x,y:l.y+_.y},...f,{x:c.x+g.x,y:c.y+g.y},n],y,x,w,M]}function uf(e,t,n,r){const s=Math.min(ms(e,t)/2,ms(t,n)/2,r),{x:i,y:o}=t;if(e.x===i&&i===n.x||e.y===o&&o===n.y)return`L${i} ${o}`;if(e.y===o){const c=e.x{let j="";return v>0&&v{const[g,v,j]=wn({sourceX:e,sourceY:t,sourcePosition:d,targetX:n,targetY:r,targetPosition:m,borderRadius:x==null?void 0:x.borderRadius,offset:x==null?void 0:x.offset});return $.createElement(Xt,{path:g,labelX:v,labelY:j,label:s,labelStyle:i,labelShowBg:o,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,style:u,markerEnd:f,markerStart:y,interactionWidth:_})});$n.displayName="SmoothStepEdge";const jr=b.memo(e=>{var t;return $.createElement($n,{...e,pathOptions:b.useMemo(()=>{var n;return{borderRadius:0,offset:(n=e.pathOptions)==null?void 0:n.offset}},[(t=e.pathOptions)==null?void 0:t.offset])})});jr.displayName="StepEdge";function df({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,i,o,a]=Xi({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,i,o,a]}const Cr=b.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:s,labelStyle:i,labelShowBg:o,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,style:u,markerEnd:d,markerStart:m,interactionWidth:f})=>{const[y,x,_]=df({sourceX:e,sourceY:t,targetX:n,targetY:r});return $.createElement(Xt,{path:y,labelX:x,labelY:_,label:s,labelStyle:i,labelShowBg:o,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,style:u,markerEnd:d,markerStart:m,interactionWidth:f})});Cr.displayName="StraightEdge";function tn(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function ps({pos:e,x1:t,y1:n,x2:r,y2:s,c:i}){switch(e){case W.Left:return[t-tn(t-r,i),n];case W.Right:return[t+tn(r-t,i),n];case W.Top:return[t,n-tn(n-s,i)];case W.Bottom:return[t,n+tn(s-n,i)]}}function Ki({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:r,targetY:s,targetPosition:i=W.Top,curvature:o=.25}){const[a,l]=ps({pos:n,x1:e,y1:t,x2:r,y2:s,c:o}),[c,u]=ps({pos:i,x1:r,y1:s,x2:e,y2:t,c:o}),[d,m,f,y]=qi({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:a,sourceControlY:l,targetControlX:c,targetControlY:u});return[`M${e},${t} C${a},${l} ${c},${u} ${r},${s}`,d,m,f,y]}const bn=b.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:s=W.Bottom,targetPosition:i=W.Top,label:o,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:d,style:m,markerEnd:f,markerStart:y,pathOptions:x,interactionWidth:_})=>{const[g,v,j]=Ki({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:r,targetPosition:i,curvature:x==null?void 0:x.curvature});return $.createElement(Xt,{path:g,labelX:v,labelY:j,label:o,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:d,style:m,markerEnd:f,markerStart:y,interactionWidth:_})});bn.displayName="BezierEdge";const $r=b.createContext(null),ff=$r.Provider;$r.Consumer;const hf=()=>b.useContext($r),mf=e=>"id"in e&&"source"in e&&"target"in e,pf=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`reactflow__edge-${e}${t||""}-${n}${r||""}`,ur=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`,gf=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),yf=(e,t)=>{if(!e.source||!e.target)return t;let n;return mf(e)?n={...e}:n={...e,id:pf(e)},gf(n,t)?t:t.concat(n)},dr=({x:e,y:t},[n,r,s],i,[o,a])=>{const l={x:(e-n)/s,y:(t-r)/s};return i?{x:o*Math.round(l.x/o),y:a*Math.round(l.y/a)}:l},Qi=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r}),rt=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(e.width??0)*t[0],r=(e.height??0)*t[1],s={x:e.position.x-n,y:e.position.y-r};return{...s,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-r}:s}},Mn=(e,t=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,s)=>{const{x:i,y:o}=rt(s,t).positionAbsolute;return Gi(r,Bt({x:i,y:o,width:s.width||0,height:s.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Yi(n)},Ji=(e,t,[n,r,s]=[0,0,1],i=!1,o=!1,a=[0,0])=>{const l={x:(t.x-n)/s,y:(t.y-r)/s,width:t.width/s,height:t.height/s},c=[];return e.forEach(u=>{const{width:d,height:m,selectable:f=!0,hidden:y=!1}=u;if(o&&!f||y)return!1;const{positionAbsolute:x}=rt(u,a),_={x:x.x,y:x.y,width:d||0,height:m||0},g=lr(l,_),v=typeof d>"u"||typeof m>"u"||d===null||m===null,j=i&&g>0,w=(d||0)*(m||0);(v||j||g>=w||u.dragging)&&c.push(u)}),c},eo=(e,t)=>{const n=e.map(r=>r.id);return t.filter(r=>n.includes(r.source)||n.includes(r.target))},to=(e,t,n,r,s,i=.1)=>{const o=t/(e.width*(1+i)),a=n/(e.height*(1+i)),l=Math.min(o,a),c=Et(l,r,s),u=e.x+e.width/2,d=e.y+e.height/2,m=t/2-u*c,f=n/2-d*c;return{x:m,y:f,zoom:c}},Je=(e,t=0)=>e.transition().duration(t);function gs(e,t,n,r){return(t[n]||[]).reduce((s,i)=>{var o,a;return`${e.id}-${i.id}-${n}`!==r&&s.push({id:i.id||null,type:n,nodeId:e.id,x:(((o=e.positionAbsolute)==null?void 0:o.x)??0)+i.x+i.width/2,y:(((a=e.positionAbsolute)==null?void 0:a.y)??0)+i.y+i.height/2}),s},[])}function xf(e,t,n,r,s,i){const{x:o,y:a}=Ge(e),c=t.elementsFromPoint(o,a).find(y=>y.classList.contains("react-flow__handle"));if(c){const y=c.getAttribute("data-nodeid");if(y){const x=Mr(void 0,c),_=c.getAttribute("data-handleid"),g=i({nodeId:y,id:_,type:x});if(g){const v=s.find(j=>j.nodeId===y&&j.type===x&&j.id===_);return{handle:{id:_,type:x,nodeId:y,x:(v==null?void 0:v.x)||n.x,y:(v==null?void 0:v.y)||n.y},validHandleResult:g}}}}let u=[],d=1/0;if(s.forEach(y=>{const x=Math.sqrt((y.x-n.x)**2+(y.y-n.y)**2);if(x<=r){const _=i(y);x<=d&&(xy.isValid),f=u.some(({handle:y})=>y.type==="target");return u.find(({handle:y,validHandleResult:x})=>f?y.type==="target":m?x.isValid:!0)||u[0]}const wf={source:null,target:null,sourceHandle:null,targetHandle:null},no=()=>({handleDomNode:null,isValid:!1,connection:wf,endHandle:null});function ro(e,t,n,r,s,i,o){const a=s==="target",l=o.querySelector(`.react-flow__handle[data-id="${e==null?void 0:e.nodeId}-${e==null?void 0:e.id}-${e==null?void 0:e.type}"]`),c={...no(),handleDomNode:l};if(l){const u=Mr(void 0,l),d=l.getAttribute("data-nodeid"),m=l.getAttribute("data-handleid"),f=l.classList.contains("connectable"),y=l.classList.contains("connectableend"),x={source:a?d:n,sourceHandle:a?m:r,target:a?n:d,targetHandle:a?r:m};c.connection=x,f&&y&&(t===it.Strict?a&&u==="source"||!a&&u==="target":d!==n||m!==r)&&(c.endHandle={nodeId:d,handleId:m,type:u},c.isValid=i(x))}return c}function bf({nodes:e,nodeId:t,handleId:n,handleType:r}){return e.reduce((s,i)=>{if(i[ie]){const{handleBounds:o}=i[ie];let a=[],l=[];o&&(a=gs(i,o,"source",`${t}-${n}-${r}`),l=gs(i,o,"target",`${t}-${n}-${r}`)),s.push(...a,...l)}return s},[])}function Mr(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function Vn(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function vf(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function so({event:e,handleId:t,nodeId:n,onConnect:r,isTarget:s,getState:i,setState:o,isValidConnection:a,edgeUpdaterType:l,onReconnectEnd:c}){const u=Bi(e.target),{connectionMode:d,domNode:m,autoPanOnConnect:f,connectionRadius:y,onConnectStart:x,panBy:_,getNodes:g,cancelConnection:v}=i();let j=0,w;const{x:M,y:C}=Ge(e),A=u==null?void 0:u.elementFromPoint(M,C),F=Mr(l,A),S=m==null?void 0:m.getBoundingClientRect();if(!S||!F)return;let O,z=Ge(e,S),G=!1,V=null,p=!1,k=null;const E=bf({nodes:g(),nodeId:n,handleId:t,handleType:F}),T=()=>{if(!f)return;const[I,L]=Vi(z,S);_({x:I,y:L}),j=requestAnimationFrame(T)};o({connectionPosition:z,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:F,connectionStartHandle:{nodeId:n,handleId:t,type:F},connectionEndHandle:null}),x==null||x(e,{nodeId:n,handleId:t,handleType:F});function D(I){const{transform:L}=i();z=Ge(I,S);const{handle:P,validHandleResult:R}=xf(I,u,dr(z,L,!1,[1,1]),y,E,H=>ro(H,d,n,t,s?"target":"source",a,u));if(w=P,G||(T(),G=!0),k=R.handleDomNode,V=R.connection,p=R.isValid,o({connectionPosition:w&&p?Qi({x:w.x,y:w.y},L):z,connectionStatus:vf(!!w,p),connectionEndHandle:R.endHandle}),!w&&!p&&!k)return Vn(O);V.source!==V.target&&k&&(Vn(O),O=k,k.classList.add("connecting","react-flow__handle-connecting"),k.classList.toggle("valid",p),k.classList.toggle("react-flow__handle-valid",p))}function N(I){var L,P;(w||k)&&V&&p&&(r==null||r(V)),(P=(L=i()).onConnectEnd)==null||P.call(L,I),l&&(c==null||c(I)),Vn(O),v(),cancelAnimationFrame(j),G=!1,p=!1,V=null,k=null,u.removeEventListener("mousemove",D),u.removeEventListener("mouseup",N),u.removeEventListener("touchmove",D),u.removeEventListener("touchend",N)}u.addEventListener("mousemove",D),u.addEventListener("mouseup",N),u.addEventListener("touchmove",D),u.addEventListener("touchend",N)}const ys=()=>!0,_f=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),Ef=(e,t,n)=>r=>{const{connectionStartHandle:s,connectionEndHandle:i,connectionClickStartHandle:o}=r;return{connecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.handleId)===t&&(s==null?void 0:s.type)===n||(i==null?void 0:i.nodeId)===e&&(i==null?void 0:i.handleId)===t&&(i==null?void 0:i.type)===n,clickConnecting:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.handleId)===t&&(o==null?void 0:o.type)===n}},io=b.forwardRef(({type:e="source",position:t=W.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:i=!0,id:o,onConnect:a,children:l,className:c,onMouseDown:u,onTouchStart:d,...m},f)=>{var S,O;const y=o||null,x=e==="target",_=de(),g=hf(),{connectOnClick:v,noPanClassName:j}=re(_f,fe),{connecting:w,clickConnecting:M}=re(Ef(g,y,e),fe);g||(O=(S=_.getState()).onError)==null||O.call(S,"010",Pe.error010());const C=z=>{const{defaultEdgeOptions:G,onConnect:V,hasDefaultEdges:p}=_.getState(),k={...G,...z};if(p){const{edges:E,setEdges:T}=_.getState();T(yf(k,E))}V==null||V(k),a==null||a(k)},A=z=>{if(!g)return;const G=Ui(z);s&&(G&&z.button===0||!G)&&so({event:z,handleId:y,nodeId:g,onConnect:C,isTarget:x,getState:_.getState,setState:_.setState,isValidConnection:n||_.getState().isValidConnection||ys}),G?u==null||u(z):d==null||d(z)},F=z=>{const{onClickConnectStart:G,onClickConnectEnd:V,connectionClickStartHandle:p,connectionMode:k,isValidConnection:E}=_.getState();if(!g||!p&&!s)return;if(!p){G==null||G(z,{nodeId:g,handleId:y,handleType:e}),_.setState({connectionClickStartHandle:{nodeId:g,type:e,handleId:y}});return}const T=Bi(z.target),D=n||E||ys,{connection:N,isValid:I}=ro({nodeId:g,id:y,type:e},k,p.nodeId,p.handleId||null,p.type,D,T);I&&C(N),V==null||V(z),_.setState({connectionClickStartHandle:null})};return $.createElement("div",{"data-handleid":y,"data-nodeid":g,"data-handlepos":t,"data-id":`${g}-${y}-${e}`,className:he(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",j,c,{source:!x,target:x,connectable:r,connectablestart:s,connectableend:i,connecting:M,connectionindicator:r&&(s&&!w||i&&w)}]),onMouseDown:A,onTouchStart:A,onClick:v?F:void 0,ref:f,...m},l)});io.displayName="Handle";var Be=b.memo(io);const oo=({data:e,isConnectable:t,targetPosition:n=W.Top,sourcePosition:r=W.Bottom})=>$.createElement($.Fragment,null,$.createElement(Be,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,$.createElement(Be,{type:"source",position:r,isConnectable:t}));oo.displayName="DefaultNode";var fr=b.memo(oo);const ao=({data:e,isConnectable:t,sourcePosition:n=W.Bottom})=>$.createElement($.Fragment,null,e==null?void 0:e.label,$.createElement(Be,{type:"source",position:n,isConnectable:t}));ao.displayName="InputNode";var lo=b.memo(ao);const co=({data:e,isConnectable:t,targetPosition:n=W.Top})=>$.createElement($.Fragment,null,$.createElement(Be,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label);co.displayName="OutputNode";var uo=b.memo(co);const Ar=()=>null;Ar.displayName="GroupNode";const Nf=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected).map(t=>({...t}))}),nn=e=>e.id;function Sf(e,t){return fe(e.selectedNodes.map(nn),t.selectedNodes.map(nn))&&fe(e.selectedEdges.map(nn),t.selectedEdges.map(nn))}const fo=b.memo(({onSelectionChange:e})=>{const t=de(),{selectedNodes:n,selectedEdges:r}=re(Nf,Sf);return b.useEffect(()=>{const s={nodes:n,edges:r};e==null||e(s),t.getState().onSelectionChange.forEach(i=>i(s))},[n,r,e]),null});fo.displayName="SelectionListener";const kf=e=>!!e.onSelectionChange;function jf({onSelectionChange:e}){const t=re(kf);return e||t?$.createElement(fo,{onSelectionChange:e}):null}const Cf=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset});function ft(e,t){b.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function K(e,t,n){b.useEffect(()=>{typeof t<"u"&&n({[e]:t})},[t])}const $f=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:s,onConnectStart:i,onConnectEnd:o,onClickConnectStart:a,onClickConnectEnd:l,nodesDraggable:c,nodesConnectable:u,nodesFocusable:d,edgesFocusable:m,edgesUpdatable:f,elevateNodesOnSelect:y,minZoom:x,maxZoom:_,nodeExtent:g,onNodesChange:v,onEdgesChange:j,elementsSelectable:w,connectionMode:M,snapGrid:C,snapToGrid:A,translateExtent:F,connectOnClick:S,defaultEdgeOptions:O,fitView:z,fitViewOptions:G,onNodesDelete:V,onEdgesDelete:p,onNodeDrag:k,onNodeDragStart:E,onNodeDragStop:T,onSelectionDrag:D,onSelectionDragStart:N,onSelectionDragStop:I,noPanClassName:L,nodeOrigin:P,rfId:R,autoPanOnConnect:H,autoPanOnNodeDrag:B,onError:X,connectionRadius:q,isValidConnection:J,nodeDragThreshold:Q})=>{const{setNodes:ee,setEdges:ae,setDefaultNodesAndEdges:Y,setMinZoom:te,setMaxZoom:se,setTranslateExtent:ne,setNodeExtent:le,reset:Z}=re(Cf,fe),U=de();return b.useEffect(()=>{const pe=r==null?void 0:r.map(Me=>({...Me,...O}));return Y(n,pe),()=>{Z()}},[]),K("defaultEdgeOptions",O,U.setState),K("connectionMode",M,U.setState),K("onConnect",s,U.setState),K("onConnectStart",i,U.setState),K("onConnectEnd",o,U.setState),K("onClickConnectStart",a,U.setState),K("onClickConnectEnd",l,U.setState),K("nodesDraggable",c,U.setState),K("nodesConnectable",u,U.setState),K("nodesFocusable",d,U.setState),K("edgesFocusable",m,U.setState),K("edgesUpdatable",f,U.setState),K("elementsSelectable",w,U.setState),K("elevateNodesOnSelect",y,U.setState),K("snapToGrid",A,U.setState),K("snapGrid",C,U.setState),K("onNodesChange",v,U.setState),K("onEdgesChange",j,U.setState),K("connectOnClick",S,U.setState),K("fitViewOnInit",z,U.setState),K("fitViewOnInitOptions",G,U.setState),K("onNodesDelete",V,U.setState),K("onEdgesDelete",p,U.setState),K("onNodeDrag",k,U.setState),K("onNodeDragStart",E,U.setState),K("onNodeDragStop",T,U.setState),K("onSelectionDrag",D,U.setState),K("onSelectionDragStart",N,U.setState),K("onSelectionDragStop",I,U.setState),K("noPanClassName",L,U.setState),K("nodeOrigin",P,U.setState),K("rfId",R,U.setState),K("autoPanOnConnect",H,U.setState),K("autoPanOnNodeDrag",B,U.setState),K("onError",X,U.setState),K("connectionRadius",q,U.setState),K("isValidConnection",J,U.setState),K("nodeDragThreshold",Q,U.setState),ft(e,ee),ft(t,ae),ft(x,te),ft(_,se),ft(F,ne),ft(g,le),null},xs={display:"none"},Mf={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},ho="react-flow__node-desc",mo="react-flow__edge-desc",Af="react-flow__aria-live",If=e=>e.ariaLiveMessage;function Tf({rfId:e}){const t=re(If);return $.createElement("div",{id:`${Af}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Mf},t)}function Rf({rfId:e,disableKeyboardA11y:t}){return $.createElement($.Fragment,null,$.createElement("div",{id:`${ho}-${e}`,style:xs},"Press enter or space to select a node.",!t&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),$.createElement("div",{id:`${mo}-${e}`,style:xs},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&$.createElement(Tf,{rfId:e}))}var Yt=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,r]=b.useState(!1),s=b.useRef(!1),i=b.useRef(new Set([])),[o,a]=b.useMemo(()=>{if(e!==null){const c=(Array.isArray(e)?e:[e]).filter(d=>typeof d=="string").map(d=>d.split("+")),u=c.reduce((d,m)=>d.concat(...m),[]);return[c,u]}return[[],[]]},[e]);return b.useEffect(()=>{const l=typeof document<"u"?document:null,c=(t==null?void 0:t.target)||l;if(e!==null){const u=f=>{if(s.current=f.ctrlKey||f.metaKey||f.shiftKey,(!s.current||s.current&&!t.actInsideInputWithModifier)&&cr(f))return!1;const x=bs(f.code,a);i.current.add(f[x]),ws(o,i.current,!1)&&(f.preventDefault(),r(!0))},d=f=>{if((!s.current||s.current&&!t.actInsideInputWithModifier)&&cr(f))return!1;const x=bs(f.code,a);ws(o,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(f[x]),f.key==="Meta"&&i.current.clear(),s.current=!1},m=()=>{i.current.clear(),r(!1)};return c==null||c.addEventListener("keydown",u),c==null||c.addEventListener("keyup",d),window.addEventListener("blur",m),()=>{c==null||c.removeEventListener("keydown",u),c==null||c.removeEventListener("keyup",d),window.removeEventListener("blur",m)}}},[e,r]),n};function ws(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function bs(e,t){return t.includes(e)?"code":"key"}function po(e,t,n,r){var a,l;const s=e.parentNode||e.parentId;if(!s)return n;const i=t.get(s),o=rt(i,r);return po(i,t,{x:(n.x??0)+o.x,y:(n.y??0)+o.y,z:(((a=i[ie])==null?void 0:a.z)??0)>(n.z??0)?((l=i[ie])==null?void 0:l.z)??0:n.z??0},r)}function go(e,t,n){e.forEach(r=>{var i;const s=r.parentNode||r.parentId;if(s&&!e.has(s))throw new Error(`Parent node ${s} not found`);if(s||n!=null&&n[r.id]){const{x:o,y:a,z:l}=po(r,e,{...r.position,z:((i=r[ie])==null?void 0:i.z)??0},t);r.positionAbsolute={x:o,y:a},r[ie].z=l,n!=null&&n[r.id]&&(r[ie].isParent=!0)}})}function Bn(e,t,n,r){const s=new Map,i={},o=r?1e3:0;return e.forEach(a=>{var f;const l=(we(a.zIndex)?a.zIndex:0)+(a.selected?o:0),c=t.get(a.id),u={...a,positionAbsolute:{x:a.position.x,y:a.position.y}},d=a.parentNode||a.parentId;d&&(i[d]=!0);const m=(c==null?void 0:c.type)&&(c==null?void 0:c.type)!==a.type;Object.defineProperty(u,ie,{enumerable:!1,value:{handleBounds:m||(f=c==null?void 0:c[ie])==null?void 0:f.handleBounds,z:l}}),s.set(a.id,u)}),go(s,n,i),s}function yo(e,t={}){const{getNodes:n,width:r,height:s,minZoom:i,maxZoom:o,d3Zoom:a,d3Selection:l,fitViewOnInitDone:c,fitViewOnInit:u,nodeOrigin:d}=e(),m=t.initial&&!c&&u;if(a&&l&&(m||!t.initial)){const y=n().filter(_=>{var v;const g=t.includeHiddenNodes?_.width&&_.height:!_.hidden;return(v=t.nodes)!=null&&v.length?g&&t.nodes.some(j=>j.id===_.id):g}),x=y.every(_=>_.width&&_.height);if(y.length>0&&x){const _=Mn(y,d),{x:g,y:v,zoom:j}=to(_,r,s,t.minZoom??i,t.maxZoom??o,t.padding??.1),w=De.translate(g,v).scale(j);return typeof t.duration=="number"&&t.duration>0?a.transform(Je(l,t.duration),w):a.transform(l,w),!0}}return!1}function Of(e,t){return e.forEach(n=>{const r=t.get(n.id);r&&t.set(r.id,{...r,[ie]:r[ie],selected:n.selected})}),new Map(t)}function Df(e,t){return t.map(n=>{const r=e.find(s=>s.id===n.id);return r&&(n.selected=r.selected),n})}function rn({changedNodes:e,changedEdges:t,get:n,set:r}){const{nodeInternals:s,edges:i,onNodesChange:o,onEdgesChange:a,hasDefaultNodes:l,hasDefaultEdges:c}=n();e!=null&&e.length&&(l&&r({nodeInternals:Of(e,s)}),o==null||o(e)),t!=null&&t.length&&(c&&r({edges:Df(t,i)}),a==null||a(t))}const ht=()=>{},Lf={zoomIn:ht,zoomOut:ht,zoomTo:ht,getZoom:()=>1,setViewport:ht,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:ht,fitBounds:ht,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},Pf=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),zf=()=>{const e=de(),{d3Zoom:t,d3Selection:n}=re(Pf,fe);return b.useMemo(()=>n&&t?{zoomIn:s=>t.scaleBy(Je(n,s==null?void 0:s.duration),1.2),zoomOut:s=>t.scaleBy(Je(n,s==null?void 0:s.duration),1/1.2),zoomTo:(s,i)=>t.scaleTo(Je(n,i==null?void 0:i.duration),s),getZoom:()=>e.getState().transform[2],setViewport:(s,i)=>{const[o,a,l]=e.getState().transform,c=De.translate(s.x??o,s.y??a).scale(s.zoom??l);t.transform(Je(n,i==null?void 0:i.duration),c)},getViewport:()=>{const[s,i,o]=e.getState().transform;return{x:s,y:i,zoom:o}},fitView:s=>yo(e.getState,s),setCenter:(s,i,o)=>{const{width:a,height:l,maxZoom:c}=e.getState(),u=typeof(o==null?void 0:o.zoom)<"u"?o.zoom:c,d=a/2-s*u,m=l/2-i*u,f=De.translate(d,m).scale(u);t.transform(Je(n,o==null?void 0:o.duration),f)},fitBounds:(s,i)=>{const{width:o,height:a,minZoom:l,maxZoom:c}=e.getState(),{x:u,y:d,zoom:m}=to(s,o,a,l,c,(i==null?void 0:i.padding)??.1),f=De.translate(u,d).scale(m);t.transform(Je(n,i==null?void 0:i.duration),f)},project:s=>{const{transform:i,snapToGrid:o,snapGrid:a}=e.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),dr(s,i,o,a)},screenToFlowPosition:s=>{const{transform:i,snapToGrid:o,snapGrid:a,domNode:l}=e.getState();if(!l)return s;const{x:c,y:u}=l.getBoundingClientRect(),d={x:s.x-c,y:s.y-u};return dr(d,i,o,a)},flowToScreenPosition:s=>{const{transform:i,domNode:o}=e.getState();if(!o)return s;const{x:a,y:l}=o.getBoundingClientRect(),c=Qi(s,i);return{x:c.x+a,y:c.y+l}},viewportInitialized:!0}:Lf,[t,n])};function An(){const e=zf(),t=de(),n=b.useCallback(()=>t.getState().getNodes().map(x=>({...x})),[]),r=b.useCallback(x=>t.getState().nodeInternals.get(x),[]),s=b.useCallback(()=>{const{edges:x=[]}=t.getState();return x.map(_=>({..._}))},[]),i=b.useCallback(x=>{const{edges:_=[]}=t.getState();return _.find(g=>g.id===x)},[]),o=b.useCallback(x=>{const{getNodes:_,setNodes:g,hasDefaultNodes:v,onNodesChange:j}=t.getState(),w=_(),M=typeof x=="function"?x(w):x;if(v)g(M);else if(j){const C=M.length===0?w.map(A=>({type:"remove",id:A.id})):M.map(A=>({item:A,type:"reset"}));j(C)}},[]),a=b.useCallback(x=>{const{edges:_=[],setEdges:g,hasDefaultEdges:v,onEdgesChange:j}=t.getState(),w=typeof x=="function"?x(_):x;if(v)g(w);else if(j){const M=w.length===0?_.map(C=>({type:"remove",id:C.id})):w.map(C=>({item:C,type:"reset"}));j(M)}},[]),l=b.useCallback(x=>{const _=Array.isArray(x)?x:[x],{getNodes:g,setNodes:v,hasDefaultNodes:j,onNodesChange:w}=t.getState();if(j){const C=[...g(),..._];v(C)}else if(w){const M=_.map(C=>({item:C,type:"add"}));w(M)}},[]),c=b.useCallback(x=>{const _=Array.isArray(x)?x:[x],{edges:g=[],setEdges:v,hasDefaultEdges:j,onEdgesChange:w}=t.getState();if(j)v([...g,..._]);else if(w){const M=_.map(C=>({item:C,type:"add"}));w(M)}},[]),u=b.useCallback(()=>{const{getNodes:x,edges:_=[],transform:g}=t.getState(),[v,j,w]=g;return{nodes:x().map(M=>({...M})),edges:_.map(M=>({...M})),viewport:{x:v,y:j,zoom:w}}},[]),d=b.useCallback(({nodes:x,edges:_})=>{const{nodeInternals:g,getNodes:v,edges:j,hasDefaultNodes:w,hasDefaultEdges:M,onNodesDelete:C,onEdgesDelete:A,onNodesChange:F,onEdgesChange:S}=t.getState(),O=(x||[]).map(k=>k.id),z=(_||[]).map(k=>k.id),G=v().reduce((k,E)=>{const T=E.parentNode||E.parentId,D=!O.includes(E.id)&&T&&k.find(I=>I.id===T);return(typeof E.deletable=="boolean"?E.deletable:!0)&&(O.includes(E.id)||D)&&k.push(E),k},[]),V=j.filter(k=>typeof k.deletable=="boolean"?k.deletable:!0),p=V.filter(k=>z.includes(k.id));if(G||p){const k=eo(G,V),E=[...p,...k],T=E.reduce((D,N)=>(D.includes(N.id)||D.push(N.id),D),[]);if((M||w)&&(M&&t.setState({edges:j.filter(D=>!T.includes(D.id))}),w&&(G.forEach(D=>{g.delete(D.id)}),t.setState({nodeInternals:new Map(g)}))),T.length>0&&(A==null||A(E),S&&S(T.map(D=>({id:D,type:"remove"})))),G.length>0&&(C==null||C(G),F)){const D=G.map(N=>({id:N.id,type:"remove"}));F(D)}}},[]),m=b.useCallback(x=>{const _=sf(x),g=_?null:t.getState().nodeInternals.get(x.id);return!_&&!g?[null,null,_]:[_?x:ds(g),g,_]},[]),f=b.useCallback((x,_=!0,g)=>{const[v,j,w]=m(x);return v?(g||t.getState().getNodes()).filter(M=>{if(!w&&(M.id===j.id||!M.positionAbsolute))return!1;const C=ds(M),A=lr(C,v);return _&&A>0||A>=v.width*v.height}):[]},[]),y=b.useCallback((x,_,g=!0)=>{const[v]=m(x);if(!v)return!1;const j=lr(v,_);return g&&j>0||j>=v.width*v.height},[]);return b.useMemo(()=>({...e,getNodes:n,getNode:r,getEdges:s,getEdge:i,setNodes:o,setEdges:a,addNodes:l,addEdges:c,toObject:u,deleteElements:d,getIntersectingNodes:f,isNodeIntersecting:y}),[e,n,r,s,i,o,a,l,c,u,d,f,y])}const Hf={actInsideInputWithModifier:!1};var Ff=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=de(),{deleteElements:r}=An(),s=Yt(e,Hf),i=Yt(t);b.useEffect(()=>{if(s){const{edges:o,getNodes:a}=n.getState(),l=a().filter(u=>u.selected),c=o.filter(u=>u.selected);r({nodes:l,edges:c}),n.setState({nodesSelectionActive:!1})}},[s]),b.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])};function Vf(e){const t=de();b.useEffect(()=>{let n;const r=()=>{var i,o;if(!e.current)return;const s=Nr(e.current);(s.height===0||s.width===0)&&((o=(i=t.getState()).onError)==null||o.call(i,"004",Pe.error004())),t.setState({width:s.width||500,height:s.height||500})};return r(),window.addEventListener("resize",r),e.current&&(n=new ResizeObserver(()=>r()),n.observe(e.current)),()=>{window.removeEventListener("resize",r),n&&e.current&&n.unobserve(e.current)}},[])}const Ir={position:"absolute",width:"100%",height:"100%",top:0,left:0},Bf=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,sn=e=>({x:e.x,y:e.y,zoom:e.k}),mt=(e,t)=>e.target.closest(`.${t}`),vs=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),_s=e=>{const t=e.ctrlKey&&yn()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},Gf=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),Yf=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:r,zoomOnScroll:s=!0,zoomOnPinch:i=!0,panOnScroll:o=!1,panOnScrollSpeed:a=.5,panOnScrollMode:l=tt.Free,zoomOnDoubleClick:c=!0,elementsSelectable:u,panOnDrag:d=!0,defaultViewport:m,translateExtent:f,minZoom:y,maxZoom:x,zoomActivationKeyCode:_,preventScrolling:g=!0,children:v,noWheelClassName:j,noPanClassName:w})=>{const M=b.useRef(),C=de(),A=b.useRef(!1),F=b.useRef(!1),S=b.useRef(null),O=b.useRef({x:0,y:0,zoom:0}),{d3Zoom:z,d3Selection:G,d3ZoomHandler:V,userSelectionActive:p}=re(Gf,fe),k=Yt(_),E=b.useRef(0),T=b.useRef(!1),D=b.useRef();return Vf(S),b.useEffect(()=>{if(S.current){const N=S.current.getBoundingClientRect(),I=Hi().scaleExtent([y,x]).translateExtent(f),L=xe(S.current).call(I),P=De.translate(m.x,m.y).scale(Et(m.zoom,y,x)),R=[[0,0],[N.width,N.height]],H=I.constrain()(P,R,f);I.transform(L,H),I.wheelDelta(_s),C.setState({d3Zoom:I,d3Selection:L,d3ZoomHandler:L.on("wheel.zoom"),transform:[H.x,H.y,H.k],domNode:S.current.closest(".react-flow")})}},[]),b.useEffect(()=>{G&&z&&(o&&!k&&!p?G.on("wheel.zoom",N=>{if(mt(N,j))return!1;N.preventDefault(),N.stopImmediatePropagation();const I=G.property("__zoom").k||1;if(N.ctrlKey&&i){const J=Ee(N),Q=_s(N),ee=I*Math.pow(2,Q);z.scaleTo(G,ee,J,N);return}const L=N.deltaMode===1?20:1;let P=l===tt.Vertical?0:N.deltaX*L,R=l===tt.Horizontal?0:N.deltaY*L;!yn()&&N.shiftKey&&l!==tt.Vertical&&(P=N.deltaY*L,R=0),z.translateBy(G,-(P/I)*a,-(R/I)*a,{internal:!0});const H=sn(G.property("__zoom")),{onViewportChangeStart:B,onViewportChange:X,onViewportChangeEnd:q}=C.getState();clearTimeout(D.current),T.current||(T.current=!0,t==null||t(N,H),B==null||B(H)),T.current&&(e==null||e(N,H),X==null||X(H),D.current=setTimeout(()=>{n==null||n(N,H),q==null||q(H),T.current=!1},150))},{passive:!1}):typeof V<"u"&&G.on("wheel.zoom",function(N,I){if(!g&&N.type==="wheel"&&!N.ctrlKey||mt(N,j))return null;N.preventDefault(),V.call(this,N,I)},{passive:!1}))},[p,o,l,G,z,V,k,i,g,j,t,e,n]),b.useEffect(()=>{z&&z.on("start",N=>{var P,R;if(!N.sourceEvent||N.sourceEvent.internal)return null;E.current=(P=N.sourceEvent)==null?void 0:P.button;const{onViewportChangeStart:I}=C.getState(),L=sn(N.transform);A.current=!0,O.current=L,((R=N.sourceEvent)==null?void 0:R.type)==="mousedown"&&C.setState({paneDragging:!0}),I==null||I(L),t==null||t(N.sourceEvent,L)})},[z,t]),b.useEffect(()=>{z&&(p&&!A.current?z.on("zoom",null):p||z.on("zoom",N=>{var L;const{onViewportChange:I}=C.getState();if(C.setState({transform:[N.transform.x,N.transform.y,N.transform.k]}),F.current=!!(r&&vs(d,E.current??0)),(e||I)&&!((L=N.sourceEvent)!=null&&L.internal)){const P=sn(N.transform);I==null||I(P),e==null||e(N.sourceEvent,P)}}))},[p,z,e,d,r]),b.useEffect(()=>{z&&z.on("end",N=>{if(!N.sourceEvent||N.sourceEvent.internal)return null;const{onViewportChangeEnd:I}=C.getState();if(A.current=!1,C.setState({paneDragging:!1}),r&&vs(d,E.current??0)&&!F.current&&r(N.sourceEvent),F.current=!1,(n||I)&&Bf(O.current,N.transform)){const L=sn(N.transform);O.current=L,clearTimeout(M.current),M.current=setTimeout(()=>{I==null||I(L),n==null||n(N.sourceEvent,L)},o?150:0)}})},[z,o,d,n,r]),b.useEffect(()=>{z&&z.filter(N=>{const I=k||s,L=i&&N.ctrlKey;if((d===!0||Array.isArray(d)&&d.includes(1))&&N.button===1&&N.type==="mousedown"&&(mt(N,"react-flow__node")||mt(N,"react-flow__edge")))return!0;if(!d&&!I&&!o&&!c&&!i||p||!c&&N.type==="dblclick"||mt(N,j)&&N.type==="wheel"||mt(N,w)&&(N.type!=="wheel"||o&&N.type==="wheel"&&!k)||!i&&N.ctrlKey&&N.type==="wheel"||!I&&!o&&!L&&N.type==="wheel"||!d&&(N.type==="mousedown"||N.type==="touchstart")||Array.isArray(d)&&!d.includes(N.button)&&N.type==="mousedown")return!1;const P=Array.isArray(d)&&d.includes(N.button)||!N.button||N.button<=1;return(!N.ctrlKey||N.type==="wheel")&&P})},[p,z,s,i,o,c,d,u,k]),$.createElement("div",{className:"react-flow__renderer",ref:S,style:Ir},v)},Wf=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Uf(){const{userSelectionActive:e,userSelectionRect:t}=re(Wf,fe);return e&&t?$.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}function Es(e,t){const n=t.parentNode||t.parentId,r=e.find(s=>s.id===n);if(r){const s=t.position.x+t.width-r.width,i=t.position.y+t.height-r.height;if(s>0||i>0||t.position.x<0||t.position.y<0){if(r.style={...r.style},r.style.width=r.style.width??r.width,r.style.height=r.style.height??r.height,s>0&&(r.style.width+=s),i>0&&(r.style.height+=i),t.position.x<0){const o=Math.abs(t.position.x);r.position.x=r.position.x-o,r.style.width+=o,t.position.x=0}if(t.position.y<0){const o=Math.abs(t.position.y);r.position.y=r.position.y-o,r.style.height+=o,t.position.y=0}r.width=r.style.width,r.height=r.style.height}}}function Xf(e,t){if(e.some(r=>r.type==="reset"))return e.filter(r=>r.type==="reset").map(r=>r.item);const n=e.filter(r=>r.type==="add").map(r=>r.item);return t.reduce((r,s)=>{const i=e.filter(a=>a.id===s.id);if(i.length===0)return r.push(s),r;const o={...s};for(const a of i)if(a)switch(a.type){case"select":{o.selected=a.selected;break}case"position":{typeof a.position<"u"&&(o.position=a.position),typeof a.positionAbsolute<"u"&&(o.positionAbsolute=a.positionAbsolute),typeof a.dragging<"u"&&(o.dragging=a.dragging),o.expandParent&&Es(r,o);break}case"dimensions":{typeof a.dimensions<"u"&&(o.width=a.dimensions.width,o.height=a.dimensions.height),typeof a.updateStyle<"u"&&(o.style={...o.style||{},...a.dimensions}),typeof a.resizing=="boolean"&&(o.resizing=a.resizing),o.expandParent&&Es(r,o);break}case"remove":return r}return r.push(o),r},n)}function qf(e,t){return Xf(e,t)}const Fe=(e,t)=>({id:e,type:"select",selected:t});function gt(e,t){return e.reduce((n,r)=>{const s=t.includes(r.id);return!r.selected&&s?(r.selected=!0,n.push(Fe(r.id,!0))):r.selected&&!s&&(r.selected=!1,n.push(Fe(r.id,!1))),n},[])}const Gn=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},Zf=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),xo=b.memo(({isSelecting:e,selectionMode:t=Gt.Full,panOnDrag:n,onSelectionStart:r,onSelectionEnd:s,onPaneClick:i,onPaneContextMenu:o,onPaneScroll:a,onPaneMouseEnter:l,onPaneMouseMove:c,onPaneMouseLeave:u,children:d})=>{const m=b.useRef(null),f=de(),y=b.useRef(0),x=b.useRef(0),_=b.useRef(),{userSelectionActive:g,elementsSelectable:v,dragging:j}=re(Zf,fe),w=()=>{f.setState({userSelectionActive:!1,userSelectionRect:null}),y.current=0,x.current=0},M=V=>{i==null||i(V),f.getState().resetSelectedElements(),f.setState({nodesSelectionActive:!1})},C=V=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){V.preventDefault();return}o==null||o(V)},A=a?V=>a(V):void 0,F=V=>{const{resetSelectedElements:p,domNode:k}=f.getState();if(_.current=k==null?void 0:k.getBoundingClientRect(),!v||!e||V.button!==0||V.target!==m.current||!_.current)return;const{x:E,y:T}=Ge(V,_.current);p(),f.setState({userSelectionRect:{width:0,height:0,startX:E,startY:T,x:E,y:T}}),r==null||r(V)},S=V=>{const{userSelectionRect:p,nodeInternals:k,edges:E,transform:T,onNodesChange:D,onEdgesChange:N,nodeOrigin:I,getNodes:L}=f.getState();if(!e||!_.current||!p)return;f.setState({userSelectionActive:!0,nodesSelectionActive:!1});const P=Ge(V,_.current),R=p.startX??0,H=p.startY??0,B={...p,x:P.xee.id),Q=q.map(ee=>ee.id);if(y.current!==Q.length){y.current=Q.length;const ee=gt(X,Q);ee.length&&(D==null||D(ee))}if(x.current!==J.length){x.current=J.length;const ee=gt(E,J);ee.length&&(N==null||N(ee))}f.setState({userSelectionRect:B})},O=V=>{if(V.button!==0)return;const{userSelectionRect:p}=f.getState();!g&&p&&V.target===m.current&&(M==null||M(V)),f.setState({nodesSelectionActive:y.current>0}),w(),s==null||s(V)},z=V=>{g&&(f.setState({nodesSelectionActive:y.current>0}),s==null||s(V)),w()},G=v&&(e||g);return $.createElement("div",{className:he(["react-flow__pane",{dragging:j,selection:e}]),onClick:G?void 0:Gn(M,m),onContextMenu:Gn(C,m),onWheel:Gn(A,m),onMouseEnter:G?void 0:l,onMouseDown:G?F:void 0,onMouseMove:G?S:c,onMouseUp:G?O:void 0,onMouseLeave:G?z:u,ref:m,style:Ir},d,$.createElement(Uf,null))});xo.displayName="Pane";function wo(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const r=t.get(n);return r?r.selected?!0:wo(r,t):!1}function Ns(e,t,n){let r=e;do{if(r!=null&&r.matches(t))return!0;if(r===n.current)return!1;r=r.parentElement}while(r);return!1}function Kf(e,t,n,r){return Array.from(e.values()).filter(s=>(s.selected||s.id===r)&&(!s.parentNode||s.parentId||!wo(s,e))&&(s.draggable||t&&typeof s.draggable>"u")).map(s=>{var i,o;return{id:s.id,position:s.position||{x:0,y:0},positionAbsolute:s.positionAbsolute||{x:0,y:0},distance:{x:n.x-(((i=s.positionAbsolute)==null?void 0:i.x)??0),y:n.y-(((o=s.positionAbsolute)==null?void 0:o.y)??0)},delta:{x:0,y:0},extent:s.extent,parentNode:s.parentNode||s.parentId,parentId:s.parentNode||s.parentId,width:s.width,height:s.height,expandParent:s.expandParent}})}function Qf(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function bo(e,t,n,r,s=[0,0],i){const o=Qf(e,e.extent||r);let a=o;const l=e.parentNode||e.parentId;if(e.extent==="parent"&&!e.expandParent)if(l&&e.width&&e.height){const d=n.get(l),{x:m,y:f}=rt(d,s).positionAbsolute;a=d&&we(m)&&we(f)&&we(d.width)&&we(d.height)?[[m+e.width*s[0],f+e.height*s[1]],[m+d.width-e.width+e.width*s[0],f+d.height-e.height+e.height*s[1]]]:a}else i==null||i("005",Pe.error005()),a=o;else if(e.extent&&l&&e.extent!=="parent"){const d=n.get(l),{x:m,y:f}=rt(d,s).positionAbsolute;a=[[e.extent[0][0]+m,e.extent[0][1]+f],[e.extent[1][0]+m,e.extent[1][1]+f]]}let c={x:0,y:0};if(l){const d=n.get(l);c=rt(d,s).positionAbsolute}const u=a&&a!=="parent"?Sr(t,a):t;return{position:{x:u.x-c.x,y:u.y-c.y},positionAbsolute:u}}function Yn({nodeId:e,dragItems:t,nodeInternals:n}){const r=t.map(s=>({...n.get(s.id),position:s.position,positionAbsolute:s.positionAbsolute}));return[e?r.find(s=>s.id===e):r[0],r]}const Ss=(e,t,n,r)=>{const s=t.querySelectorAll(e);if(!s||!s.length)return null;const i=Array.from(s),o=t.getBoundingClientRect(),a={x:o.width*r[0],y:o.height*r[1]};return i.map(l=>{const c=l.getBoundingClientRect();return{id:l.getAttribute("data-handleid"),position:l.getAttribute("data-handlepos"),x:(c.left-o.left-a.x)/n,y:(c.top-o.top-a.y)/n,...Nr(l)}})};function At(e,t,n){return n===void 0?n:r=>{const s=t().nodeInternals.get(e);s&&n(r,{...s})}}function hr({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:i,multiSelectionActive:o,nodeInternals:a,onError:l}=t.getState(),c=a.get(e);if(!c){l==null||l("012",Pe.error012(e));return}t.setState({nodesSelectionActive:!1}),c.selected?(n||c.selected&&o)&&(i({nodes:[c],edges:[]}),requestAnimationFrame(()=>{var u;return(u=r==null?void 0:r.current)==null?void 0:u.blur()})):s([e])}function Jf(){const e=de();return b.useCallback(({sourceEvent:n})=>{const{transform:r,snapGrid:s,snapToGrid:i}=e.getState(),o=n.touches?n.touches[0].clientX:n.clientX,a=n.touches?n.touches[0].clientY:n.clientY,l={x:(o-r[0])/r[2],y:(a-r[1])/r[2]};return{xSnapped:i?s[0]*Math.round(l.x/s[0]):l.x,ySnapped:i?s[1]*Math.round(l.y/s[1]):l.y,...l}},[])}function Wn(e){return(t,n,r)=>e==null?void 0:e(t,r)}function vo({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:i,selectNodesOnDrag:o}){const a=de(),[l,c]=b.useState(!1),u=b.useRef([]),d=b.useRef({x:null,y:null}),m=b.useRef(0),f=b.useRef(null),y=b.useRef({x:0,y:0}),x=b.useRef(null),_=b.useRef(!1),g=b.useRef(!1),v=b.useRef(!1),j=Jf();return b.useEffect(()=>{if(e!=null&&e.current){const w=xe(e.current),M=({x:F,y:S})=>{const{nodeInternals:O,onNodeDrag:z,onSelectionDrag:G,updateNodePositions:V,nodeExtent:p,snapGrid:k,snapToGrid:E,nodeOrigin:T,onError:D}=a.getState();d.current={x:F,y:S};let N=!1,I={x:0,y:0,x2:0,y2:0};if(u.current.length>1&&p){const P=Mn(u.current,T);I=Bt(P)}if(u.current=u.current.map(P=>{const R={x:F-P.distance.x,y:S-P.distance.y};E&&(R.x=k[0]*Math.round(R.x/k[0]),R.y=k[1]*Math.round(R.y/k[1]));const H=[[p[0][0],p[0][1]],[p[1][0],p[1][1]]];u.current.length>1&&p&&!P.extent&&(H[0][0]=P.positionAbsolute.x-I.x+p[0][0],H[1][0]=P.positionAbsolute.x+(P.width??0)-I.x2+p[1][0],H[0][1]=P.positionAbsolute.y-I.y+p[0][1],H[1][1]=P.positionAbsolute.y+(P.height??0)-I.y2+p[1][1]);const B=bo(P,R,O,H,T,D);return N=N||P.position.x!==B.position.x||P.position.y!==B.position.y,P.position=B.position,P.positionAbsolute=B.positionAbsolute,P}),!N)return;V(u.current,!0,!0),c(!0);const L=s?z:Wn(G);if(L&&x.current){const[P,R]=Yn({nodeId:s,dragItems:u.current,nodeInternals:O});L(x.current,P,R)}},C=()=>{if(!f.current)return;const[F,S]=Vi(y.current,f.current);if(F!==0||S!==0){const{transform:O,panBy:z}=a.getState();d.current.x=(d.current.x??0)-F/O[2],d.current.y=(d.current.y??0)-S/O[2],z({x:F,y:S})&&M(d.current)}m.current=requestAnimationFrame(C)},A=F=>{var T;const{nodeInternals:S,multiSelectionActive:O,nodesDraggable:z,unselectNodesAndEdges:G,onNodeDragStart:V,onSelectionDragStart:p}=a.getState();g.current=!0;const k=s?V:Wn(p);(!o||!i)&&!O&&s&&((T=S.get(s))!=null&&T.selected||G()),s&&i&&o&&hr({id:s,store:a,nodeRef:e});const E=j(F);if(d.current=E,u.current=Kf(S,z,E,s),k&&u.current){const[D,N]=Yn({nodeId:s,dragItems:u.current,nodeInternals:S});k(F.sourceEvent,D,N)}};if(t)w.on(".drag",null);else{const F=lu().on("start",S=>{const{domNode:O,nodeDragThreshold:z}=a.getState();z===0&&A(S),v.current=!1;const G=j(S);d.current=G,f.current=(O==null?void 0:O.getBoundingClientRect())||null,y.current=Ge(S.sourceEvent,f.current)}).on("drag",S=>{var V,p;const O=j(S),{autoPanOnNodeDrag:z,nodeDragThreshold:G}=a.getState();if(S.sourceEvent.type==="touchmove"&&S.sourceEvent.touches.length>1&&(v.current=!0),!v.current){if(!_.current&&g.current&&z&&(_.current=!0,C()),!g.current){const k=O.xSnapped-(((V=d==null?void 0:d.current)==null?void 0:V.x)??0),E=O.ySnapped-(((p=d==null?void 0:d.current)==null?void 0:p.y)??0);Math.sqrt(k*k+E*E)>G&&A(S)}(d.current.x!==O.xSnapped||d.current.y!==O.ySnapped)&&u.current&&g.current&&(x.current=S.sourceEvent,y.current=Ge(S.sourceEvent,f.current),M(O))}}).on("end",S=>{if(!(!g.current||v.current)&&(c(!1),_.current=!1,g.current=!1,cancelAnimationFrame(m.current),u.current)){const{updateNodePositions:O,nodeInternals:z,onNodeDragStop:G,onSelectionDragStop:V}=a.getState(),p=s?G:Wn(V);if(O(u.current,!1,!1),p){const[k,E]=Yn({nodeId:s,dragItems:u.current,nodeInternals:z});p(S.sourceEvent,k,E)}}}).filter(S=>{const O=S.target;return!S.button&&(!n||!Ns(O,`.${n}`,e))&&(!r||Ns(O,r,e))});return w.call(F),()=>{w.on(".drag",null)}}}},[e,t,n,r,i,a,s,o,j]),l}function _o(){const e=de();return b.useCallback(n=>{const{nodeInternals:r,nodeExtent:s,updateNodePositions:i,getNodes:o,snapToGrid:a,snapGrid:l,onError:c,nodesDraggable:u}=e.getState(),d=o().filter(v=>v.selected&&(v.draggable||u&&typeof v.draggable>"u")),m=a?l[0]:5,f=a?l[1]:5,y=n.isShiftPressed?4:1,x=n.x*m*y,_=n.y*f*y,g=d.map(v=>{if(v.positionAbsolute){const j={x:v.positionAbsolute.x+x,y:v.positionAbsolute.y+_};a&&(j.x=l[0]*Math.round(j.x/l[0]),j.y=l[1]*Math.round(j.y/l[1]));const{positionAbsolute:w,position:M}=bo(v,j,r,s,void 0,c);v.position=M,v.positionAbsolute=w}return v});i(g,!0,!1)},[])}const wt={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var It=e=>{const t=({id:n,type:r,data:s,xPos:i,yPos:o,xPosOrigin:a,yPosOrigin:l,selected:c,onClick:u,onMouseEnter:d,onMouseMove:m,onMouseLeave:f,onContextMenu:y,onDoubleClick:x,style:_,className:g,isDraggable:v,isSelectable:j,isConnectable:w,isFocusable:M,selectNodesOnDrag:C,sourcePosition:A,targetPosition:F,hidden:S,resizeObserver:O,dragHandle:z,zIndex:G,isParent:V,noDragClassName:p,noPanClassName:k,initialized:E,disableKeyboardA11y:T,ariaLabel:D,rfId:N,hasHandleBounds:I})=>{const L=de(),P=b.useRef(null),R=b.useRef(null),H=b.useRef(A),B=b.useRef(F),X=b.useRef(r),q=j||v||u||d||m||f,J=_o(),Q=At(n,L.getState,d),ee=At(n,L.getState,m),ae=At(n,L.getState,f),Y=At(n,L.getState,y),te=At(n,L.getState,x),se=Z=>{const{nodeDragThreshold:U}=L.getState();if(j&&(!C||!v||U>0)&&hr({id:n,store:L,nodeRef:P}),u){const pe=L.getState().nodeInternals.get(n);pe&&u(Z,{...pe})}},ne=Z=>{if(!cr(Z)&&!T)if(Wi.includes(Z.key)&&j){const U=Z.key==="Escape";hr({id:n,store:L,unselect:U,nodeRef:P})}else v&&c&&Object.prototype.hasOwnProperty.call(wt,Z.key)&&(L.setState({ariaLiveMessage:`Moved selected node ${Z.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~i}, y: ${~~o}`}),J({x:wt[Z.key].x,y:wt[Z.key].y,isShiftPressed:Z.shiftKey}))};b.useEffect(()=>()=>{R.current&&(O==null||O.unobserve(R.current),R.current=null)},[]),b.useEffect(()=>{if(P.current&&!S){const Z=P.current;(!E||!I||R.current!==Z)&&(R.current&&(O==null||O.unobserve(R.current)),O==null||O.observe(Z),R.current=Z)}},[S,E,I]),b.useEffect(()=>{const Z=X.current!==r,U=H.current!==A,pe=B.current!==F;P.current&&(Z||U||pe)&&(Z&&(X.current=r),U&&(H.current=A),pe&&(B.current=F),L.getState().updateNodeDimensions([{id:n,nodeElement:P.current,forceUpdate:!0}]))},[n,r,A,F]);const le=vo({nodeRef:P,disabled:S||!v,noDragClassName:p,handleSelector:z,nodeId:n,isSelectable:j,selectNodesOnDrag:C});return S?null:$.createElement("div",{className:he(["react-flow__node",`react-flow__node-${r}`,{[k]:v},g,{selected:c,selectable:j,parent:V,dragging:le}]),ref:P,style:{zIndex:G,transform:`translate(${a}px,${l}px)`,pointerEvents:q?"all":"none",visibility:E?"visible":"hidden",..._},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:Q,onMouseMove:ee,onMouseLeave:ae,onContextMenu:Y,onClick:se,onDoubleClick:te,onKeyDown:M?ne:void 0,tabIndex:M?0:void 0,role:M?"button":void 0,"aria-describedby":T?void 0:`${ho}-${N}`,"aria-label":D},$.createElement(ff,{value:n},$.createElement(e,{id:n,data:s,type:r,xPos:i,yPos:o,selected:c,isConnectable:w,sourcePosition:A,targetPosition:F,dragging:le,dragHandle:z,zIndex:G})))};return t.displayName="NodeWrapper",b.memo(t)};const eh=e=>{const t=e.getNodes().filter(n=>n.selected);return{...Mn(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function th({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=de(),{width:s,height:i,x:o,y:a,transformString:l,userSelectionActive:c}=re(eh,fe),u=_o(),d=b.useRef(null);if(b.useEffect(()=>{var y;n||(y=d.current)==null||y.focus({preventScroll:!0})},[n]),vo({nodeRef:d}),c||!s||!i)return null;const m=e?y=>{const x=r.getState().getNodes().filter(_=>_.selected);e(y,x)}:void 0,f=y=>{Object.prototype.hasOwnProperty.call(wt,y.key)&&u({x:wt[y.key].x,y:wt[y.key].y,isShiftPressed:y.shiftKey})};return $.createElement("div",{className:he(["react-flow__nodesselection","react-flow__container",t]),style:{transform:l}},$.createElement("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:m,tabIndex:n?void 0:-1,onKeyDown:n?void 0:f,style:{width:s,height:i,top:a,left:o}}))}var nh=b.memo(th);const rh=e=>e.nodesSelectionActive,Eo=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:o,deleteKeyCode:a,onMove:l,onMoveStart:c,onMoveEnd:u,selectionKeyCode:d,selectionOnDrag:m,selectionMode:f,onSelectionStart:y,onSelectionEnd:x,multiSelectionKeyCode:_,panActivationKeyCode:g,zoomActivationKeyCode:v,elementsSelectable:j,zoomOnScroll:w,zoomOnPinch:M,panOnScroll:C,panOnScrollSpeed:A,panOnScrollMode:F,zoomOnDoubleClick:S,panOnDrag:O,defaultViewport:z,translateExtent:G,minZoom:V,maxZoom:p,preventScrolling:k,onSelectionContextMenu:E,noWheelClassName:T,noPanClassName:D,disableKeyboardA11y:N})=>{const I=re(rh),L=Yt(d),P=Yt(g),R=P||O,H=P||C,B=L||m&&R!==!0;return Ff({deleteKeyCode:a,multiSelectionKeyCode:_}),$.createElement(Yf,{onMove:l,onMoveStart:c,onMoveEnd:u,onPaneContextMenu:i,elementsSelectable:j,zoomOnScroll:w,zoomOnPinch:M,panOnScroll:H,panOnScrollSpeed:A,panOnScrollMode:F,zoomOnDoubleClick:S,panOnDrag:!L&&R,defaultViewport:z,translateExtent:G,minZoom:V,maxZoom:p,zoomActivationKeyCode:v,preventScrolling:k,noWheelClassName:T,noPanClassName:D},$.createElement(xo,{onSelectionStart:y,onSelectionEnd:x,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:o,panOnDrag:R,isSelecting:!!B,selectionMode:f},e,I&&$.createElement(nh,{onSelectionContextMenu:E,noPanClassName:D,disableKeyboardA11y:N})))};Eo.displayName="FlowRenderer";var sh=b.memo(Eo);function ih(e){return re(b.useCallback(n=>e?Ji(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}function oh(e){const t={input:It(e.input||lo),default:It(e.default||fr),output:It(e.output||uo),group:It(e.group||Ar)},n={},r=Object.keys(e).filter(s=>!["input","default","output","group"].includes(s)).reduce((s,i)=>(s[i]=It(e[i]||fr),s),n);return{...t,...r}}const ah=({x:e,y:t,width:n,height:r,origin:s})=>!n||!r?{x:e,y:t}:s[0]<0||s[1]<0||s[0]>1||s[1]>1?{x:e,y:t}:{x:e-n*s[0],y:t-r*s[1]},lh=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),No=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,updateNodeDimensions:i,onError:o}=re(lh,fe),a=ih(e.onlyRenderVisibleElements),l=b.useRef(),c=b.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const u=new ResizeObserver(d=>{const m=d.map(f=>({id:f.target.getAttribute("data-id"),nodeElement:f.target,forceUpdate:!0}));i(m)});return l.current=u,u},[]);return b.useEffect(()=>()=>{var u;(u=l==null?void 0:l.current)==null||u.disconnect()},[]),$.createElement("div",{className:"react-flow__nodes",style:Ir},a.map(u=>{var M,C,A;let d=u.type||"default";e.nodeTypes[d]||(o==null||o("003",Pe.error003(d)),d="default");const m=e.nodeTypes[d]||e.nodeTypes.default,f=!!(u.draggable||t&&typeof u.draggable>"u"),y=!!(u.selectable||s&&typeof u.selectable>"u"),x=!!(u.connectable||n&&typeof u.connectable>"u"),_=!!(u.focusable||r&&typeof u.focusable>"u"),g=e.nodeExtent?Sr(u.positionAbsolute,e.nodeExtent):u.positionAbsolute,v=(g==null?void 0:g.x)??0,j=(g==null?void 0:g.y)??0,w=ah({x:v,y:j,width:u.width??0,height:u.height??0,origin:e.nodeOrigin});return $.createElement(m,{key:u.id,id:u.id,className:u.className,style:u.style,type:d,data:u.data,sourcePosition:u.sourcePosition||W.Bottom,targetPosition:u.targetPosition||W.Top,hidden:u.hidden,xPos:v,yPos:j,xPosOrigin:w.x,yPosOrigin:w.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!u.selected,isDraggable:f,isSelectable:y,isConnectable:x,isFocusable:_,resizeObserver:c,dragHandle:u.dragHandle,zIndex:((M=u[ie])==null?void 0:M.z)??0,isParent:!!((C=u[ie])!=null&&C.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!u.width&&!!u.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:u.ariaLabel,hasHandleBounds:!!((A=u[ie])!=null&&A.handleBounds)})}))};No.displayName="NodeRenderer";var ch=b.memo(No);const uh=(e,t,n)=>n===W.Left?e-t:n===W.Right?e+t:e,dh=(e,t,n)=>n===W.Top?e-t:n===W.Bottom?e+t:e,ks="react-flow__edgeupdater",js=({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:s,onMouseEnter:i,onMouseOut:o,type:a})=>$.createElement("circle",{onMouseDown:s,onMouseEnter:i,onMouseOut:o,className:he([ks,`${ks}-${a}`]),cx:uh(t,r,e),cy:dh(n,r,e),r,stroke:"transparent",fill:"transparent"}),fh=()=>!0;var pt=e=>{const t=({id:n,className:r,type:s,data:i,onClick:o,onEdgeDoubleClick:a,selected:l,animated:c,label:u,labelStyle:d,labelShowBg:m,labelBgStyle:f,labelBgPadding:y,labelBgBorderRadius:x,style:_,source:g,target:v,sourceX:j,sourceY:w,targetX:M,targetY:C,sourcePosition:A,targetPosition:F,elementsSelectable:S,hidden:O,sourceHandleId:z,targetHandleId:G,onContextMenu:V,onMouseEnter:p,onMouseMove:k,onMouseLeave:E,reconnectRadius:T,onReconnect:D,onReconnectStart:N,onReconnectEnd:I,markerEnd:L,markerStart:P,rfId:R,ariaLabel:H,isFocusable:B,isReconnectable:X,pathOptions:q,interactionWidth:J,disableKeyboardA11y:Q})=>{const ee=b.useRef(null),[ae,Y]=b.useState(!1),[te,se]=b.useState(!1),ne=de(),le=b.useMemo(()=>`url('#${ur(P,R)}')`,[P,R]),Z=b.useMemo(()=>`url('#${ur(L,R)}')`,[L,R]);if(O)return null;const U=me=>{var je;const{edges:_e,addSelectedEdges:Xe,unselectNodesAndEdges:qe,multiSelectionActive:Ze}=ne.getState(),Ie=_e.find(kt=>kt.id===n);Ie&&(S&&(ne.setState({nodesSelectionActive:!1}),Ie.selected&&Ze?(qe({nodes:[],edges:[Ie]}),(je=ee.current)==null||je.blur()):Xe([n])),o&&o(me,Ie))},pe=Mt(n,ne.getState,a),Me=Mt(n,ne.getState,V),Nt=Mt(n,ne.getState,p),at=Mt(n,ne.getState,k),lt=Mt(n,ne.getState,E),Ae=(me,_e)=>{if(me.button!==0)return;const{edges:Xe,isValidConnection:qe}=ne.getState(),Ze=_e?v:g,Ie=(_e?G:z)||null,je=_e?"target":"source",kt=qe||fh,Rn=_e,jt=Xe.find(Ke=>Ke.id===n);se(!0),N==null||N(me,jt,je);const On=Ke=>{se(!1),I==null||I(Ke,jt,je)};so({event:me,handleId:Ie,nodeId:Ze,onConnect:Ke=>D==null?void 0:D(jt,Ke),isTarget:Rn,getState:ne.getState,setState:ne.setState,isValidConnection:kt,edgeUpdaterType:je,onReconnectEnd:On})},ct=me=>Ae(me,!0),We=me=>Ae(me,!1),Ue=()=>Y(!0),ut=()=>Y(!1),dt=!S&&!o,St=me=>{var _e;if(!Q&&Wi.includes(me.key)&&S){const{unselectNodesAndEdges:Xe,addSelectedEdges:qe,edges:Ze}=ne.getState();me.key==="Escape"?((_e=ee.current)==null||_e.blur(),Xe({edges:[Ze.find(je=>je.id===n)]})):qe([n])}};return $.createElement("g",{className:he(["react-flow__edge",`react-flow__edge-${s}`,r,{selected:l,animated:c,inactive:dt,updating:ae}]),onClick:U,onDoubleClick:pe,onContextMenu:Me,onMouseEnter:Nt,onMouseMove:at,onMouseLeave:lt,onKeyDown:B?St:void 0,tabIndex:B?0:void 0,role:B?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":H===null?void 0:H||`Edge from ${g} to ${v}`,"aria-describedby":B?`${mo}-${R}`:void 0,ref:ee},!te&&$.createElement(e,{id:n,source:g,target:v,selected:l,animated:c,label:u,labelStyle:d,labelShowBg:m,labelBgStyle:f,labelBgPadding:y,labelBgBorderRadius:x,data:i,style:_,sourceX:j,sourceY:w,targetX:M,targetY:C,sourcePosition:A,targetPosition:F,sourceHandleId:z,targetHandleId:G,markerStart:le,markerEnd:Z,pathOptions:q,interactionWidth:J}),X&&$.createElement($.Fragment,null,(X==="source"||X===!0)&&$.createElement(js,{position:A,centerX:j,centerY:w,radius:T,onMouseDown:ct,onMouseEnter:Ue,onMouseOut:ut,type:"source"}),(X==="target"||X===!0)&&$.createElement(js,{position:F,centerX:M,centerY:C,radius:T,onMouseDown:We,onMouseEnter:Ue,onMouseOut:ut,type:"target"})))};return t.displayName="EdgeWrapper",b.memo(t)};function hh(e){const t={default:pt(e.default||bn),straight:pt(e.bezier||Cr),step:pt(e.step||jr),smoothstep:pt(e.step||$n),simplebezier:pt(e.simplebezier||kr)},n={},r=Object.keys(e).filter(s=>!["default","bezier"].includes(s)).reduce((s,i)=>(s[i]=pt(e[i]||bn),s),n);return{...t,...r}}function Cs(e,t,n=null){const r=((n==null?void 0:n.x)||0)+t.x,s=((n==null?void 0:n.y)||0)+t.y,i=(n==null?void 0:n.width)||t.width,o=(n==null?void 0:n.height)||t.height;switch(e){case W.Top:return{x:r+i/2,y:s};case W.Right:return{x:r+i,y:s+o/2};case W.Bottom:return{x:r+i/2,y:s+o};case W.Left:return{x:r,y:s+o/2}}}function $s(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}const mh=(e,t,n,r,s,i)=>{const o=Cs(n,e,t),a=Cs(i,r,s);return{sourceX:o.x,sourceY:o.y,targetX:a.x,targetY:a.y}};function ph({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:r,targetWidth:s,targetHeight:i,width:o,height:a,transform:l}){const c={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+n,t.x+s),y2:Math.max(e.y+r,t.y+i)};c.x===c.x2&&(c.x2+=1),c.y===c.y2&&(c.y2+=1);const u=Bt({x:(0-l[0])/l[2],y:(0-l[1])/l[2],width:o/l[2],height:a/l[2]}),d=Math.max(0,Math.min(u.x2,c.x2)-Math.max(u.x,c.x)),m=Math.max(0,Math.min(u.y2,c.y2)-Math.max(u.y,c.y));return Math.ceil(d*m)>0}function Ms(e){var r,s,i,o,a;const t=((r=e==null?void 0:e[ie])==null?void 0:r.handleBounds)||null,n=t&&(e==null?void 0:e.width)&&(e==null?void 0:e.height)&&typeof((s=e==null?void 0:e.positionAbsolute)==null?void 0:s.x)<"u"&&typeof((i=e==null?void 0:e.positionAbsolute)==null?void 0:i.y)<"u";return[{x:((o=e==null?void 0:e.positionAbsolute)==null?void 0:o.x)||0,y:((a=e==null?void 0:e.positionAbsolute)==null?void 0:a.y)||0,width:(e==null?void 0:e.width)||0,height:(e==null?void 0:e.height)||0},t,!!n]}const gh=[{level:0,isMaxLevel:!0,edges:[]}];function yh(e,t,n=!1){let r=-1;const s=e.reduce((o,a)=>{var u,d;const l=we(a.zIndex);let c=l?a.zIndex:0;if(n){const m=t.get(a.target),f=t.get(a.source),y=a.selected||(m==null?void 0:m.selected)||(f==null?void 0:f.selected),x=Math.max(((u=f==null?void 0:f[ie])==null?void 0:u.z)||0,((d=m==null?void 0:m[ie])==null?void 0:d.z)||0,1e3);c=(l?a.zIndex:0)+(y?x:0)}return o[c]?o[c].push(a):o[c]=[a],r=c>r?c:r,o},{}),i=Object.entries(s).map(([o,a])=>{const l=+o;return{edges:a,level:l,isMaxLevel:l===r}});return i.length===0?gh:i}function xh(e,t,n){const r=re(b.useCallback(s=>e?s.edges.filter(i=>{const o=t.get(i.source),a=t.get(i.target);return(o==null?void 0:o.width)&&(o==null?void 0:o.height)&&(a==null?void 0:a.width)&&(a==null?void 0:a.height)&&ph({sourcePos:o.positionAbsolute||{x:0,y:0},targetPos:a.positionAbsolute||{x:0,y:0},sourceWidth:o.width,sourceHeight:o.height,targetWidth:a.width,targetHeight:a.height,width:s.width,height:s.height,transform:s.transform})}):s.edges,[e,t]));return yh(r,t,n)}const wh=({color:e="none",strokeWidth:t=1})=>$.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),bh=({color:e="none",strokeWidth:t=1})=>$.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),As={[xn.Arrow]:wh,[xn.ArrowClosed]:bh};function vh(e){const t=de();return b.useMemo(()=>{var s,i;return Object.prototype.hasOwnProperty.call(As,e)?As[e]:((i=(s=t.getState()).onError)==null||i.call(s,"009",Pe.error009(e)),null)},[e])}const _h=({id:e,type:t,color:n,width:r=12.5,height:s=12.5,markerUnits:i="strokeWidth",strokeWidth:o,orient:a="auto-start-reverse"})=>{const l=vh(t);return l?$.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:a,refX:"0",refY:"0"},$.createElement(l,{color:n,strokeWidth:o})):null},Eh=({defaultColor:e,rfId:t})=>n=>{const r=[];return n.edges.reduce((s,i)=>([i.markerStart,i.markerEnd].forEach(o=>{if(o&&typeof o=="object"){const a=ur(o,t);r.includes(a)||(s.push({id:a,color:o.color||e,...o}),r.push(a))}}),s),[]).sort((s,i)=>s.id.localeCompare(i.id))},So=({defaultColor:e,rfId:t})=>{const n=re(b.useCallback(Eh({defaultColor:e,rfId:t}),[e,t]),(r,s)=>!(r.length!==s.length||r.some((i,o)=>i.id!==s[o].id)));return $.createElement("defs",null,n.map(r=>$.createElement(_h,{id:r.id,key:r.id,type:r.type,color:r.color,width:r.width,height:r.height,markerUnits:r.markerUnits,strokeWidth:r.strokeWidth,orient:r.orient})))};So.displayName="MarkerDefinitions";var Nh=b.memo(So);const Sh=e=>({nodesConnectable:e.nodesConnectable,edgesFocusable:e.edgesFocusable,edgesUpdatable:e.edgesUpdatable,elementsSelectable:e.elementsSelectable,width:e.width,height:e.height,connectionMode:e.connectionMode,nodeInternals:e.nodeInternals,onError:e.onError}),ko=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:r,edgeTypes:s,noPanClassName:i,onEdgeContextMenu:o,onEdgeMouseEnter:a,onEdgeMouseMove:l,onEdgeMouseLeave:c,onEdgeClick:u,onEdgeDoubleClick:d,onReconnect:m,onReconnectStart:f,onReconnectEnd:y,reconnectRadius:x,children:_,disableKeyboardA11y:g})=>{const{edgesFocusable:v,edgesUpdatable:j,elementsSelectable:w,width:M,height:C,connectionMode:A,nodeInternals:F,onError:S}=re(Sh,fe),O=xh(t,F,n);return M?$.createElement($.Fragment,null,O.map(({level:z,edges:G,isMaxLevel:V})=>$.createElement("svg",{key:z,style:{zIndex:z},width:M,height:C,className:"react-flow__edges react-flow__container"},V&&$.createElement(Nh,{defaultColor:e,rfId:r}),$.createElement("g",null,G.map(p=>{const[k,E,T]=Ms(F.get(p.source)),[D,N,I]=Ms(F.get(p.target));if(!T||!I)return null;let L=p.type||"default";s[L]||(S==null||S("011",Pe.error011(L)),L="default");const P=s[L]||s.default,R=A===it.Strict?N.target:(N.target??[]).concat(N.source??[]),H=$s(E.source,p.sourceHandle),B=$s(R,p.targetHandle),X=(H==null?void 0:H.position)||W.Bottom,q=(B==null?void 0:B.position)||W.Top,J=!!(p.focusable||v&&typeof p.focusable>"u"),Q=p.reconnectable||p.updatable,ee=typeof m<"u"&&(Q||j&&typeof Q>"u");if(!H||!B)return S==null||S("008",Pe.error008(H,p)),null;const{sourceX:ae,sourceY:Y,targetX:te,targetY:se}=mh(k,H,X,D,B,q);return $.createElement(P,{key:p.id,id:p.id,className:he([p.className,i]),type:L,data:p.data,selected:!!p.selected,animated:!!p.animated,hidden:!!p.hidden,label:p.label,labelStyle:p.labelStyle,labelShowBg:p.labelShowBg,labelBgStyle:p.labelBgStyle,labelBgPadding:p.labelBgPadding,labelBgBorderRadius:p.labelBgBorderRadius,style:p.style,source:p.source,target:p.target,sourceHandleId:p.sourceHandle,targetHandleId:p.targetHandle,markerEnd:p.markerEnd,markerStart:p.markerStart,sourceX:ae,sourceY:Y,targetX:te,targetY:se,sourcePosition:X,targetPosition:q,elementsSelectable:w,onContextMenu:o,onMouseEnter:a,onMouseMove:l,onMouseLeave:c,onClick:u,onEdgeDoubleClick:d,onReconnect:m,onReconnectStart:f,onReconnectEnd:y,reconnectRadius:x,rfId:r,ariaLabel:p.ariaLabel,isFocusable:J,isReconnectable:ee,pathOptions:"pathOptions"in p?p.pathOptions:void 0,interactionWidth:p.interactionWidth,disableKeyboardA11y:g})})))),_):null};ko.displayName="EdgeRenderer";var kh=b.memo(ko);const jh=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Ch({children:e}){const t=re(jh);return $.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function $h(e){const t=An(),n=b.useRef(!1);b.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const Mh={[W.Left]:W.Right,[W.Right]:W.Left,[W.Top]:W.Bottom,[W.Bottom]:W.Top},jo=({nodeId:e,handleType:t,style:n,type:r=Ve.Bezier,CustomComponent:s,connectionStatus:i})=>{var C,A,F;const{fromNode:o,handleId:a,toX:l,toY:c,connectionMode:u}=re(b.useCallback(S=>({fromNode:S.nodeInternals.get(e),handleId:S.connectionHandleId,toX:(S.connectionPosition.x-S.transform[0])/S.transform[2],toY:(S.connectionPosition.y-S.transform[1])/S.transform[2],connectionMode:S.connectionMode}),[e]),fe),d=(C=o==null?void 0:o[ie])==null?void 0:C.handleBounds;let m=d==null?void 0:d[t];if(u===it.Loose&&(m=m||(d==null?void 0:d[t==="source"?"target":"source"])),!o||!m)return null;const f=a?m.find(S=>S.id===a):m[0],y=f?f.x+f.width/2:(o.width??0)/2,x=f?f.y+f.height/2:o.height??0,_=(((A=o.positionAbsolute)==null?void 0:A.x)??0)+y,g=(((F=o.positionAbsolute)==null?void 0:F.y)??0)+x,v=f==null?void 0:f.position,j=v?Mh[v]:null;if(!v||!j)return null;if(s)return $.createElement(s,{connectionLineType:r,connectionLineStyle:n,fromNode:o,fromHandle:f,fromX:_,fromY:g,toX:l,toY:c,fromPosition:v,toPosition:j,connectionStatus:i});let w="";const M={sourceX:_,sourceY:g,sourcePosition:v,targetX:l,targetY:c,targetPosition:j};return r===Ve.Bezier?[w]=Ki(M):r===Ve.Step?[w]=wn({...M,borderRadius:0}):r===Ve.SmoothStep?[w]=wn(M):r===Ve.SimpleBezier?[w]=Zi(M):w=`M${_},${g} ${l},${c}`,$.createElement("path",{d:w,fill:"none",className:"react-flow__connection-path",style:n})};jo.displayName="ConnectionLine";const Ah=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function Ih({containerStyle:e,style:t,type:n,component:r}){const{nodeId:s,handleType:i,nodesConnectable:o,width:a,height:l,connectionStatus:c}=re(Ah,fe);return!(s&&i&&a&&o)?null:$.createElement("svg",{style:e,width:a,height:l,className:"react-flow__edges react-flow__connectionline react-flow__container"},$.createElement("g",{className:he(["react-flow__connection",c])},$.createElement(jo,{nodeId:s,handleType:i,style:t,type:n,CustomComponent:r,connectionStatus:c})))}function Is(e,t){return b.useRef(null),de(),b.useMemo(()=>t(e),[e])}const Co=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:r,onMoveEnd:s,onInit:i,onNodeClick:o,onEdgeClick:a,onNodeDoubleClick:l,onEdgeDoubleClick:c,onNodeMouseEnter:u,onNodeMouseMove:d,onNodeMouseLeave:m,onNodeContextMenu:f,onSelectionContextMenu:y,onSelectionStart:x,onSelectionEnd:_,connectionLineType:g,connectionLineStyle:v,connectionLineComponent:j,connectionLineContainerStyle:w,selectionKeyCode:M,selectionOnDrag:C,selectionMode:A,multiSelectionKeyCode:F,panActivationKeyCode:S,zoomActivationKeyCode:O,deleteKeyCode:z,onlyRenderVisibleElements:G,elementsSelectable:V,selectNodesOnDrag:p,defaultViewport:k,translateExtent:E,minZoom:T,maxZoom:D,preventScrolling:N,defaultMarkerColor:I,zoomOnScroll:L,zoomOnPinch:P,panOnScroll:R,panOnScrollSpeed:H,panOnScrollMode:B,zoomOnDoubleClick:X,panOnDrag:q,onPaneClick:J,onPaneMouseEnter:Q,onPaneMouseMove:ee,onPaneMouseLeave:ae,onPaneScroll:Y,onPaneContextMenu:te,onEdgeContextMenu:se,onEdgeMouseEnter:ne,onEdgeMouseMove:le,onEdgeMouseLeave:Z,onReconnect:U,onReconnectStart:pe,onReconnectEnd:Me,reconnectRadius:Nt,noDragClassName:at,noWheelClassName:lt,noPanClassName:Ae,elevateEdgesOnSelect:ct,disableKeyboardA11y:We,nodeOrigin:Ue,nodeExtent:ut,rfId:dt})=>{const St=Is(e,oh),me=Is(t,hh);return $h(i),$.createElement(sh,{onPaneClick:J,onPaneMouseEnter:Q,onPaneMouseMove:ee,onPaneMouseLeave:ae,onPaneContextMenu:te,onPaneScroll:Y,deleteKeyCode:z,selectionKeyCode:M,selectionOnDrag:C,selectionMode:A,onSelectionStart:x,onSelectionEnd:_,multiSelectionKeyCode:F,panActivationKeyCode:S,zoomActivationKeyCode:O,elementsSelectable:V,onMove:n,onMoveStart:r,onMoveEnd:s,zoomOnScroll:L,zoomOnPinch:P,zoomOnDoubleClick:X,panOnScroll:R,panOnScrollSpeed:H,panOnScrollMode:B,panOnDrag:q,defaultViewport:k,translateExtent:E,minZoom:T,maxZoom:D,onSelectionContextMenu:y,preventScrolling:N,noDragClassName:at,noWheelClassName:lt,noPanClassName:Ae,disableKeyboardA11y:We},$.createElement(Ch,null,$.createElement(kh,{edgeTypes:me,onEdgeClick:a,onEdgeDoubleClick:c,onlyRenderVisibleElements:G,onEdgeContextMenu:se,onEdgeMouseEnter:ne,onEdgeMouseMove:le,onEdgeMouseLeave:Z,onReconnect:U,onReconnectStart:pe,onReconnectEnd:Me,reconnectRadius:Nt,defaultMarkerColor:I,noPanClassName:Ae,elevateEdgesOnSelect:!!ct,disableKeyboardA11y:We,rfId:dt},$.createElement(Ih,{style:v,type:g,component:j,containerStyle:w})),$.createElement("div",{className:"react-flow__edgelabel-renderer"}),$.createElement(ch,{nodeTypes:St,onNodeClick:o,onNodeDoubleClick:l,onNodeMouseEnter:u,onNodeMouseMove:d,onNodeMouseLeave:m,onNodeContextMenu:f,selectNodesOnDrag:p,onlyRenderVisibleElements:G,noPanClassName:Ae,noDragClassName:at,disableKeyboardA11y:We,nodeOrigin:Ue,nodeExtent:ut,rfId:dt})))};Co.displayName="GraphView";var Th=b.memo(Co);const mr=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ze={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:mr,nodeExtent:mr,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:it.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:of,isValidConnection:void 0},Rh=()=>bl((e,t)=>({...ze,setNodes:n=>{const{nodeInternals:r,nodeOrigin:s,elevateNodesOnSelect:i}=t();e({nodeInternals:Bn(n,r,s,i)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:r={}}=t();e({edges:n.map(s=>({...r,...s}))})},setDefaultNodesAndEdges:(n,r)=>{const s=typeof n<"u",i=typeof r<"u",o=s?Bn(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:o,edges:i?r:[],hasDefaultNodes:s,hasDefaultEdges:i})},updateNodeDimensions:n=>{const{onNodesChange:r,nodeInternals:s,fitViewOnInit:i,fitViewOnInitDone:o,fitViewOnInitOptions:a,domNode:l,nodeOrigin:c}=t(),u=l==null?void 0:l.querySelector(".react-flow__viewport");if(!u)return;const d=window.getComputedStyle(u),{m22:m}=new window.DOMMatrixReadOnly(d.transform),f=n.reduce((x,_)=>{const g=s.get(_.id);if(g!=null&&g.hidden)s.set(g.id,{...g,[ie]:{...g[ie],handleBounds:void 0}});else if(g){const v=Nr(_.nodeElement);!!(v.width&&v.height&&(g.width!==v.width||g.height!==v.height||_.forceUpdate))&&(s.set(g.id,{...g,[ie]:{...g[ie],handleBounds:{source:Ss(".source",_.nodeElement,m,c),target:Ss(".target",_.nodeElement,m,c)}},...v}),x.push({id:g.id,type:"dimensions",dimensions:v}))}return x},[]);go(s,c);const y=o||i&&!o&&yo(t,{initial:!0,...a});e({nodeInternals:new Map(s),fitViewOnInitDone:y}),(f==null?void 0:f.length)>0&&(r==null||r(f))},updateNodePositions:(n,r=!0,s=!1)=>{const{triggerNodeChanges:i}=t(),o=n.map(a=>{const l={id:a.id,type:"position",dragging:s};return r&&(l.positionAbsolute=a.positionAbsolute,l.position=a.position),l});i(o)},triggerNodeChanges:n=>{const{onNodesChange:r,nodeInternals:s,hasDefaultNodes:i,nodeOrigin:o,getNodes:a,elevateNodesOnSelect:l}=t();if(n!=null&&n.length){if(i){const c=qf(n,a()),u=Bn(c,s,o,l);e({nodeInternals:u})}r==null||r(n)}},addSelectedNodes:n=>{const{multiSelectionActive:r,edges:s,getNodes:i}=t();let o,a=null;r?o=n.map(l=>Fe(l,!0)):(o=gt(i(),n),a=gt(s,[])),rn({changedNodes:o,changedEdges:a,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:r,edges:s,getNodes:i}=t();let o,a=null;r?o=n.map(l=>Fe(l,!0)):(o=gt(s,n),a=gt(i(),[])),rn({changedNodes:a,changedEdges:o,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:r}={})=>{const{edges:s,getNodes:i}=t(),o=n||i(),a=r||s,l=o.map(u=>(u.selected=!1,Fe(u.id,!1))),c=a.map(u=>Fe(u.id,!1));rn({changedNodes:l,changedEdges:c,get:t,set:e})},setMinZoom:n=>{const{d3Zoom:r,maxZoom:s}=t();r==null||r.scaleExtent([n,s]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:r,minZoom:s}=t();r==null||r.scaleExtent([s,n]),e({maxZoom:n})},setTranslateExtent:n=>{var r;(r=t().d3Zoom)==null||r.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:r}=t(),i=r().filter(a=>a.selected).map(a=>Fe(a.id,!1)),o=n.filter(a=>a.selected).map(a=>Fe(a.id,!1));rn({changedNodes:i,changedEdges:o,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:r}=t();r.forEach(s=>{s.positionAbsolute=Sr(s.position,n)}),e({nodeExtent:n,nodeInternals:new Map(r)})},panBy:n=>{const{transform:r,width:s,height:i,d3Zoom:o,d3Selection:a,translateExtent:l}=t();if(!o||!a||!n.x&&!n.y)return!1;const c=De.translate(r[0]+n.x,r[1]+n.y).scale(r[2]),u=[[0,0],[s,i]],d=o==null?void 0:o.constrain()(c,u,l);return o.transform(a,d),r[0]!==d.x||r[1]!==d.y||r[2]!==d.k},cancelConnection:()=>e({connectionNodeId:ze.connectionNodeId,connectionHandleId:ze.connectionHandleId,connectionHandleType:ze.connectionHandleType,connectionStatus:ze.connectionStatus,connectionStartHandle:ze.connectionStartHandle,connectionEndHandle:ze.connectionEndHandle}),reset:()=>e({...ze})}),Object.is),$o=({children:e})=>{const t=b.useRef(null);return t.current||(t.current=Rh()),$.createElement(Qd,{value:t.current},e)};$o.displayName="ReactFlowProvider";const Mo=({children:e})=>b.useContext(Cn)?$.createElement($.Fragment,null,e):$.createElement($o,null,e);Mo.displayName="ReactFlowWrapper";const Oh={input:lo,default:fr,output:uo,group:Ar},Dh={default:bn,straight:Cr,step:jr,smoothstep:$n,simplebezier:kr},Lh=[0,0],Ph=[15,15],zh={x:0,y:0,zoom:1},Hh={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},Ao=b.forwardRef(({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:i=Oh,edgeTypes:o=Dh,onNodeClick:a,onEdgeClick:l,onInit:c,onMove:u,onMoveStart:d,onMoveEnd:m,onConnect:f,onConnectStart:y,onConnectEnd:x,onClickConnectStart:_,onClickConnectEnd:g,onNodeMouseEnter:v,onNodeMouseMove:j,onNodeMouseLeave:w,onNodeContextMenu:M,onNodeDoubleClick:C,onNodeDragStart:A,onNodeDrag:F,onNodeDragStop:S,onNodesDelete:O,onEdgesDelete:z,onSelectionChange:G,onSelectionDragStart:V,onSelectionDrag:p,onSelectionDragStop:k,onSelectionContextMenu:E,onSelectionStart:T,onSelectionEnd:D,connectionMode:N=it.Strict,connectionLineType:I=Ve.Bezier,connectionLineStyle:L,connectionLineComponent:P,connectionLineContainerStyle:R,deleteKeyCode:H="Backspace",selectionKeyCode:B="Shift",selectionOnDrag:X=!1,selectionMode:q=Gt.Full,panActivationKeyCode:J="Space",multiSelectionKeyCode:Q=yn()?"Meta":"Control",zoomActivationKeyCode:ee=yn()?"Meta":"Control",snapToGrid:ae=!1,snapGrid:Y=Ph,onlyRenderVisibleElements:te=!1,selectNodesOnDrag:se=!0,nodesDraggable:ne,nodesConnectable:le,nodesFocusable:Z,nodeOrigin:U=Lh,edgesFocusable:pe,edgesUpdatable:Me,elementsSelectable:Nt,defaultViewport:at=zh,minZoom:lt=.5,maxZoom:Ae=2,translateExtent:ct=mr,preventScrolling:We=!0,nodeExtent:Ue,defaultMarkerColor:ut="#b1b1b7",zoomOnScroll:dt=!0,zoomOnPinch:St=!0,panOnScroll:me=!1,panOnScrollSpeed:_e=.5,panOnScrollMode:Xe=tt.Free,zoomOnDoubleClick:qe=!0,panOnDrag:Ze=!0,onPaneClick:Ie,onPaneMouseEnter:je,onPaneMouseMove:kt,onPaneMouseLeave:Rn,onPaneScroll:jt,onPaneContextMenu:On,children:Hr,onEdgeContextMenu:Ke,onEdgeDoubleClick:ma,onEdgeMouseEnter:pa,onEdgeMouseMove:ga,onEdgeMouseLeave:ya,onEdgeUpdate:xa,onEdgeUpdateStart:wa,onEdgeUpdateEnd:ba,onReconnect:va,onReconnectStart:_a,onReconnectEnd:Ea,reconnectRadius:Na=10,edgeUpdaterRadius:Sa=10,onNodesChange:ka,onEdgesChange:ja,noDragClassName:Ca="nodrag",noWheelClassName:$a="nowheel",noPanClassName:Fr="nopan",fitView:Ma=!1,fitViewOptions:Aa,connectOnClick:Ia=!0,attributionPosition:Ta,proOptions:Ra,defaultEdgeOptions:Oa,elevateNodesOnSelect:Da=!0,elevateEdgesOnSelect:La=!1,disableKeyboardA11y:Vr=!1,autoPanOnConnect:Pa=!0,autoPanOnNodeDrag:za=!0,connectionRadius:Ha=20,isValidConnection:Fa,onError:Va,style:Ba,id:Br,nodeDragThreshold:Ga,...Ya},Wa)=>{const Dn=Br||"1";return $.createElement("div",{...Ya,style:{...Ba,...Hh},ref:Wa,className:he(["react-flow",s]),"data-testid":"rf__wrapper",id:Br},$.createElement(Mo,null,$.createElement(Th,{onInit:c,onMove:u,onMoveStart:d,onMoveEnd:m,onNodeClick:a,onEdgeClick:l,onNodeMouseEnter:v,onNodeMouseMove:j,onNodeMouseLeave:w,onNodeContextMenu:M,onNodeDoubleClick:C,nodeTypes:i,edgeTypes:o,connectionLineType:I,connectionLineStyle:L,connectionLineComponent:P,connectionLineContainerStyle:R,selectionKeyCode:B,selectionOnDrag:X,selectionMode:q,deleteKeyCode:H,multiSelectionKeyCode:Q,panActivationKeyCode:J,zoomActivationKeyCode:ee,onlyRenderVisibleElements:te,selectNodesOnDrag:se,defaultViewport:at,translateExtent:ct,minZoom:lt,maxZoom:Ae,preventScrolling:We,zoomOnScroll:dt,zoomOnPinch:St,zoomOnDoubleClick:qe,panOnScroll:me,panOnScrollSpeed:_e,panOnScrollMode:Xe,panOnDrag:Ze,onPaneClick:Ie,onPaneMouseEnter:je,onPaneMouseMove:kt,onPaneMouseLeave:Rn,onPaneScroll:jt,onPaneContextMenu:On,onSelectionContextMenu:E,onSelectionStart:T,onSelectionEnd:D,onEdgeContextMenu:Ke,onEdgeDoubleClick:ma,onEdgeMouseEnter:pa,onEdgeMouseMove:ga,onEdgeMouseLeave:ya,onReconnect:va??xa,onReconnectStart:_a??wa,onReconnectEnd:Ea??ba,reconnectRadius:Na??Sa,defaultMarkerColor:ut,noDragClassName:Ca,noWheelClassName:$a,noPanClassName:Fr,elevateEdgesOnSelect:La,rfId:Dn,disableKeyboardA11y:Vr,nodeOrigin:U,nodeExtent:Ue}),$.createElement($f,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:f,onConnectStart:y,onConnectEnd:x,onClickConnectStart:_,onClickConnectEnd:g,nodesDraggable:ne,nodesConnectable:le,nodesFocusable:Z,edgesFocusable:pe,edgesUpdatable:Me,elementsSelectable:Nt,elevateNodesOnSelect:Da,minZoom:lt,maxZoom:Ae,nodeExtent:Ue,onNodesChange:ka,onEdgesChange:ja,snapToGrid:ae,snapGrid:Y,connectionMode:N,translateExtent:ct,connectOnClick:Ia,defaultEdgeOptions:Oa,fitView:Ma,fitViewOptions:Aa,onNodesDelete:O,onEdgesDelete:z,onNodeDragStart:A,onNodeDrag:F,onNodeDragStop:S,onSelectionDrag:p,onSelectionDragStart:V,onSelectionDragStop:k,noPanClassName:Fr,nodeOrigin:U,rfId:Dn,autoPanOnConnect:Pa,autoPanOnNodeDrag:za,onError:Va,connectionRadius:Ha,isValidConnection:Fa,nodeDragThreshold:Ga}),$.createElement(jf,{onSelectionChange:G}),Hr,$.createElement(ef,{proOptions:Ra,position:Ta}),$.createElement(Rf,{rfId:Dn,disableKeyboardA11y:Vr})))});Ao.displayName="ReactFlow";const Io=({id:e,x:t,y:n,width:r,height:s,style:i,color:o,strokeColor:a,strokeWidth:l,className:c,borderRadius:u,shapeRendering:d,onClick:m,selected:f})=>{const{background:y,backgroundColor:x}=i||{},_=o||y||x;return $.createElement("rect",{className:he(["react-flow__minimap-node",{selected:f},c]),x:t,y:n,rx:u,ry:u,width:r,height:s,fill:_,stroke:a,strokeWidth:l,shapeRendering:d,onClick:m?g=>m(g,e):void 0})};Io.displayName="MiniMapNode";var Fh=b.memo(Io);const Vh=e=>e.nodeOrigin,Bh=e=>e.getNodes().filter(t=>!t.hidden&&t.width&&t.height),Un=e=>e instanceof Function?e:()=>e;function Gh({nodeStrokeColor:e="transparent",nodeColor:t="#e2e2e2",nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s=2,nodeComponent:i=Fh,onClick:o}){const a=re(Bh,fe),l=re(Vh),c=Un(t),u=Un(e),d=Un(n),m=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return $.createElement($.Fragment,null,a.map(f=>{const{x:y,y:x}=rt(f,l).positionAbsolute;return $.createElement(i,{key:f.id,x:y,y:x,width:f.width,height:f.height,style:f.style,selected:f.selected,className:d(f),color:c(f),borderRadius:r,strokeColor:u(f),strokeWidth:s,shapeRendering:m,onClick:o,id:f.id})}))}var Yh=b.memo(Gh);const Wh=200,Uh=150,Xh=e=>{const t=e.getNodes(),n={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:n,boundingRect:t.length>0?rf(Mn(t,e.nodeOrigin),n):n,rfId:e.rfId}},qh="react-flow__minimap-desc";function To({style:e,className:t,nodeStrokeColor:n="transparent",nodeColor:r="#e2e2e2",nodeClassName:s="",nodeBorderRadius:i=5,nodeStrokeWidth:o=2,nodeComponent:a,maskColor:l="rgb(240, 240, 240, 0.6)",maskStrokeColor:c="none",maskStrokeWidth:u=1,position:d="bottom-right",onClick:m,onNodeClick:f,pannable:y=!1,zoomable:x=!1,ariaLabel:_="React Flow mini map",inversePan:g=!1,zoomStep:v=10,offsetScale:j=5}){const w=de(),M=b.useRef(null),{boundingRect:C,viewBB:A,rfId:F}=re(Xh,fe),S=(e==null?void 0:e.width)??Wh,O=(e==null?void 0:e.height)??Uh,z=C.width/S,G=C.height/O,V=Math.max(z,G),p=V*S,k=V*O,E=j*V,T=C.x-(p-C.width)/2-E,D=C.y-(k-C.height)/2-E,N=p+E*2,I=k+E*2,L=`${qh}-${F}`,P=b.useRef(0);P.current=V,b.useEffect(()=>{if(M.current){const B=xe(M.current),X=Q=>{const{transform:ee,d3Selection:ae,d3Zoom:Y}=w.getState();if(Q.sourceEvent.type!=="wheel"||!ae||!Y)return;const te=-Q.sourceEvent.deltaY*(Q.sourceEvent.deltaMode===1?.05:Q.sourceEvent.deltaMode?1:.002)*v,se=ee[2]*Math.pow(2,te);Y.scaleTo(ae,se)},q=Q=>{const{transform:ee,d3Selection:ae,d3Zoom:Y,translateExtent:te,width:se,height:ne}=w.getState();if(Q.sourceEvent.type!=="mousemove"||!ae||!Y)return;const le=P.current*Math.max(1,ee[2])*(g?-1:1),Z={x:ee[0]-Q.sourceEvent.movementX*le,y:ee[1]-Q.sourceEvent.movementY*le},U=[[0,0],[se,ne]],pe=De.translate(Z.x,Z.y).scale(ee[2]),Me=Y.constrain()(pe,U,te);Y.transform(ae,Me)},J=Hi().on("zoom",y?q:null).on("zoom.wheel",x?X:null);return B.call(J),()=>{B.on("zoom",null)}}},[y,x,g,v]);const R=m?B=>{const X=Ee(B);m(B,{x:X[0],y:X[1]})}:void 0,H=f?(B,X)=>{const q=w.getState().nodeInternals.get(X);f(B,q)}:void 0;return $.createElement(Er,{position:d,style:e,className:he(["react-flow__minimap",t]),"data-testid":"rf__minimap"},$.createElement("svg",{width:S,height:O,viewBox:`${T} ${D} ${N} ${I}`,role:"img","aria-labelledby":L,ref:M,onClick:R},_&&$.createElement("title",{id:L},_),$.createElement(Yh,{onClick:H,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:s,nodeStrokeWidth:o,nodeComponent:a}),$.createElement("path",{className:"react-flow__minimap-mask",d:`M${T-E},${D-E}h${N+E*2}v${I+E*2}h${-N-E*2}z - M${A.x},${A.y}h${A.width}v${A.height}h${-A.width}z`,fill:l,fillRule:"evenodd",stroke:c,strokeWidth:u,pointerEvents:"none"})))}To.displayName="MiniMap";var Zh=b.memo(To);function Kh(){return $.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},$.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function Qh(){return $.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},$.createElement("path",{d:"M0 0h32v4.2H0z"}))}function Jh(){return $.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},$.createElement("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"}))}function em(){return $.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},$.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"}))}function tm(){return $.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},$.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"}))}const Ot=({children:e,className:t,...n})=>$.createElement("button",{type:"button",className:he(["react-flow__controls-button",t]),...n},e);Ot.displayName="ControlButton";const nm=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),Ro=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:i,onZoomOut:o,onFitView:a,onInteractiveChange:l,className:c,children:u,position:d="bottom-left"})=>{const m=de(),[f,y]=b.useState(!1),{isInteractive:x,minZoomReached:_,maxZoomReached:g}=re(nm,fe),{zoomIn:v,zoomOut:j,fitView:w}=An();if(b.useEffect(()=>{y(!0)},[]),!f)return null;const M=()=>{v(),i==null||i()},C=()=>{j(),o==null||o()},A=()=>{w(s),a==null||a()},F=()=>{m.setState({nodesDraggable:!x,nodesConnectable:!x,elementsSelectable:!x}),l==null||l(!x)};return $.createElement(Er,{className:he(["react-flow__controls",c]),position:d,style:e,"data-testid":"rf__controls"},t&&$.createElement($.Fragment,null,$.createElement(Ot,{onClick:M,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:g},$.createElement(Kh,null)),$.createElement(Ot,{onClick:C,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:_},$.createElement(Qh,null))),n&&$.createElement(Ot,{className:"react-flow__controls-fitview",onClick:A,title:"fit view","aria-label":"fit view"},$.createElement(Jh,null)),r&&$.createElement(Ot,{className:"react-flow__controls-interactive",onClick:F,title:"toggle interactivity","aria-label":"toggle interactivity"},x?$.createElement(tm,null):$.createElement(em,null)),u)};Ro.displayName="Controls";var rm=b.memo(Ro),be;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(be||(be={}));function sm({color:e,dimensions:t,lineWidth:n}){return $.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function im({color:e,radius:t}){return $.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const om={[be.Dots]:"#91919a",[be.Lines]:"#eee",[be.Cross]:"#e2e2e2"},am={[be.Dots]:1,[be.Lines]:1,[be.Cross]:6},lm=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Oo({id:e,variant:t=be.Dots,gap:n=20,size:r,lineWidth:s=1,offset:i=2,color:o,style:a,className:l}){const c=b.useRef(null),{transform:u,patternId:d}=re(lm,fe),m=o||om[t],f=r||am[t],y=t===be.Dots,x=t===be.Cross,_=Array.isArray(n)?n:[n,n],g=[_[0]*u[2]||1,_[1]*u[2]||1],v=f*u[2],j=x?[v,v]:g,w=y?[v/i,v/i]:[j[0]/i,j[1]/i];return $.createElement("svg",{className:he(["react-flow__background",l]),style:{...a,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:c,"data-testid":"rf__background"},$.createElement("pattern",{id:d+e,x:u[0]%g[0],y:u[1]%g[1],width:g[0],height:g[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${w[0]},-${w[1]})`},y?$.createElement(im,{color:m,radius:v/i}):$.createElement(sm,{dimensions:j,color:m,lineWidth:s})),$.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${d+e})`}))}Oo.displayName="Background";var cm=b.memo(Oo);const Tr=(()=>{const e=window.location.pathname.match(/^(\/view\/[^/]+)(?:\/|$)/);return e?e[1]:""})();function Do(e){return Tr+e}async function ue(e){const t=await fetch(Do(e));if(!t.ok)throw new Error(`${e}: ${t.status} ${await t.text()}`);return await t.json()}async function Ye(e,t){const n=await fetch(Do(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await n.json();if(!n.ok)throw new Lo(r.error??`${e}: ${n.status}`,n.status);return r}class Lo extends Error{constructor(n,r){super(n);oe(this,"status");this.status=r}}const ex=e=>ue(e?`/api/model?subject_area=${encodeURIComponent(e)}`:"/api/model"),tx=()=>ue("/api/diagnostics"),Po=(e,t)=>ue(`/api/ontology/search?q=${encodeURIComponent(e)}`+(t?`&within=${encodeURIComponent(t)}`:"")),zo=()=>ue("/api/ontology/ontologies"),um=e=>ue(`/api/ontology/term?ref=${encodeURIComponent(e)}`),dm=()=>ue("/api/ontology/stack"),fm=()=>ue("/api/ontology/coverage"),nx=(e,t,n)=>Ye("/api/command",{op:e,payload:t,fingerprint:n}),hm=()=>ue("/api/git/status"),mm=()=>ue("/api/git/diff"),pm=e=>Ye("/api/git/commit",{message:e}),gm=()=>Ye("/api/git/discard",{}),ym=()=>ue("/api/decisions"),Ts=(e,t)=>Ye(`/api/decisions/${e}/verdict`,{verdict:t}),rx=(e={})=>{const t=new URLSearchParams;return e.subject_area&&t.set("subject_area",e.subject_area),e.q&&t.set("q",e.q),ue(`/api/glossary/terms?${t.toString()}`)},sx=()=>ue("/api/glossary/config"),ix=e=>Ye("/api/git/propose",e),ox=(e="HEAD")=>ue(`/api/git/diff/model?base=${encodeURIComponent(e)}`),ax=(e="HEAD")=>ue(`/api/git/classify?base=${encodeURIComponent(e)}`),lx=e=>Ye("/api/git/classify",{changes:e}),cx=e=>ue(`/api/git/conflicts?base=${encodeURIComponent(e)}`),ux=(e="")=>ue(`/api/git/context?user=${encodeURIComponent(e)}`),dx=(e="")=>ue(`/api/git/proposals?user=${encodeURIComponent(e)}`),fx=()=>ue("/api/export"),hx=(e,t)=>{const n=t?`?dialect=${encodeURIComponent(t)}`:"";return`${Tr}/api/export/${encodeURIComponent(e)}${n}`},mx=(e,t,n)=>Ye("/api/import",{format:e,content:t,dialect:n}),px=(e,t,n)=>fetch(`${Tr}/api/preview`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({changes:e,subject_area:t??""}),signal:n}).then(async r=>{if(!r.ok)throw new Lo(await r.text(),r.status);return await r.json()}),gx=()=>ue("/api/glossary/subject-areas"),yx=e=>ue(`/api/glossary/subject-area/${e}`),xx=(e,t)=>Ye(`/api/glossary/subject-area/${e}/expand`,t),xm={business_key:"🔑",surrogate_key:"#",measure:"Σ",attribute:""};function wm(e){return e??""}const Rr="__entity_source",Or="__entity_target",bm=b.memo(function({data:t,selected:n}){var g;const{entity:r,color:s,dimmed:i,highlighted:o,showTypes:a,endpointAttrs:l,highlightAttrs:c,dimAttrs:u,onHoverAttr:d}=t,m=v=>v.role==="business_key"?0:l!=null&&l.has(v.id)?1:2,f=[...r.attributes].map((v,j)=>({a:v,i:j})).sort((v,j)=>m(v.a)-m(j.a)||v.i-j.i).map(v=>v.a),y=f.filter(v=>v.role==="business_key"),x=f.filter(v=>v.role!=="business_key"),_=(v,j)=>{const w="attr-row"+(c!=null&&c.has(v.id)?" rel-hit":"")+(u!=null&&u.has(v.id)?" rel-dim":"")+(l!=null&&l.has(v.id)?" endpoint":"");return h.jsxs("div",{className:w,onMouseEnter:d?()=>d(v.id):void 0,onMouseLeave:d?()=>d(null):void 0,children:[h.jsx(Be,{id:v.id,type:"target",position:W.Left,className:"port attr-port"}),h.jsx(Be,{id:v.id,type:"source",position:W.Right,className:"port attr-port"}),h.jsx("span",{className:"attr-icon",children:xm[v.role]}),h.jsx("span",{className:"attr-name"+(j?" pk":""),children:v.name}),a&&h.jsx("span",{className:"attr-type",children:wm(v.domain)}),!v.nullable&&h.jsx("span",{className:"attr-notnull",title:"not null",children:"●"})]},v.id)};return h.jsxs("div",{className:"entity-node"+(n?" selected":"")+(i?" dimmed":"")+(o?" highlighted":""),style:{borderTopColor:s},children:[h.jsx(Be,{id:Or,type:"target",position:W.Left,className:"port"}),h.jsx(Be,{id:Rr,type:"source",position:W.Right,className:"port"}),h.jsxs("div",{className:"entity-header",children:[h.jsx("span",{className:"entity-name",title:((g=r.conceptual)==null?void 0:g.definition)??void 0,children:r.name}),h.jsxs("span",{className:"entity-badges",children:[r.pattern&&h.jsx("span",{className:"badge pattern",children:r.pattern}),(()=>{var w;const v=(((w=r.conceptual)==null?void 0:w.ontology_refs)??[]).filter(M=>M.uri);if(v.length===0)return null;const j=v.map(M=>M.uri).join(` -`);return h.jsxs("span",{className:"badge ontology",title:j,children:["⚙",v.length>1?` ${v.length}`:""]})})()]})]}),y.length>0&&h.jsx("div",{className:"attr-section keys",children:y.map(v=>_(v,!0))}),h.jsxs("div",{className:"attr-section",children:[x.map(v=>_(v,!1)),r.attributes.length===0&&h.jsx("div",{className:"attr-row empty",children:"no attributes"})]})]})}),vm=["string","integer","bigint","decimal","boolean","date","timestamp"];function _m({entity:e,doc:t,caps:n,exec:r,onClose:s,onFocusEntity:i,onAlign:o,onEditMapping:a}){var m,f,y,x,_,g,v,j,w,M,C,A,F;const l=!n.canEdit,c=e.conceptual,u=t.relationships.filter(S=>S.from.entity===e.id||S.to.entity===e.id),d=S=>{var O;return((O=t.entities.find(z=>z.id===S))==null?void 0:O.name)??S};return h.jsxs("aside",{className:"detail-panel",children:[h.jsxs("div",{className:"detail-header",children:[h.jsxs("div",{style:{flex:1},children:[h.jsx(Dt,{value:e.name,className:"entity-title-input",readOnly:l,onCommit:S=>r("rename_entity",{id:e.id,name:S})}),h.jsxs("div",{children:[h.jsx(Nm,{entity:e,doc:t,readOnly:l,exec:r}),h.jsx(km,{entity:e,readOnly:l,exec:r}),e.category&&h.jsx("span",{className:"cat-badge "+e.category.role,title:e.category.role==="supertype"?`Supertype of category "${e.category.category}"`:`Subtype in "${e.category.category}" (${e.category.materialization})`,children:e.category.role==="supertype"?"◆ supertype":"◇ subtype"})]})]}),h.jsx("button",{className:"icon-btn",onClick:s,title:"Close",children:"✕"})]}),h.jsxs("section",{children:[h.jsx("h3",{children:"Definition"}),h.jsx(Dt,{value:((m=c==null?void 0:c.definition)==null?void 0:m.trim())??"",multiline:!0,placeholder:l?"—":"add a business definition…",className:"definition-input",readOnly:l,onCommit:S=>r("set_definition",{id:e.id,definition:S})})]}),h.jsxs("section",{children:[h.jsxs("h3",{children:["Ontology",!l&&h.jsxs("span",{className:"h3-actions",children:[h.jsx("button",{className:"mini-btn",onClick:()=>o(e),children:(((f=c==null?void 0:c.ontology_refs)==null?void 0:f.length)??0)>0?"Add / re-align…":"Align…"}),(((y=c==null?void 0:c.ontology_refs)==null?void 0:y.length)??0)>0&&h.jsx("button",{className:"mini-btn danger",onClick:()=>r("clear_alignment",{id:e.id}),title:"Clear every alignment on this object",children:"Clear all"})]})]}),(c==null?void 0:c.ontology_layer)&&h.jsxs("div",{className:"kv",children:[h.jsx("span",{className:"k",children:"layer"}),h.jsx("span",{className:`chip layer-${c.ontology_layer}`,children:c.ontology_layer}),c.no_industry_equivalent&&h.jsx("span",{className:"chip",title:"reviewed: no industry equivalent",children:"no industry equivalent"})]}),h.jsx(Em,{entityId:e.id,refs:(c==null?void 0:c.ontology_refs)??[],caps:n,exec:r})]}),h.jsxs("section",{children:[h.jsxs("h3",{children:["Knowledge Graph mapping",!l&&h.jsxs("span",{className:"h3-actions",children:[h.jsx("button",{className:"mini-btn",onClick:()=>a(e),children:(x=e.term_map)!=null&&x.subject_template||(_=e.term_map)!=null&&_.class_iri?"Edit mapping…":"Map…"}),(((g=e.term_map)==null?void 0:g.subject_template)||((v=e.term_map)==null?void 0:v.class_iri))&&h.jsx("button",{className:"mini-btn danger",onClick:()=>r("clear_term_map",{id:e.id}),children:"Clear"})]})]}),(j=e.term_map)!=null&&j.subject_template||(w=e.term_map)!=null&&w.class_iri?h.jsxs(h.Fragment,{children:[((M=e.term_map)==null?void 0:M.class_iri)&&h.jsxs("div",{className:"kv",children:[h.jsx("span",{className:"k",children:"class IRI"}),h.jsx("code",{className:"v",children:e.term_map.class_iri})]}),((C=e.term_map)==null?void 0:C.subject_template)&&h.jsxs("div",{className:"kv",children:[h.jsx("span",{className:"k",children:"subject"}),h.jsx("code",{className:"v",children:e.term_map.subject_template})]})]}):h.jsxs("p",{className:"empty-hint",children:["uses the default R2RML term-map (base IRI",t.project.kg_base_iri?` ${t.project.kg_base_iri}`:""," + primary key)"]})]}),h.jsxs("section",{children:[h.jsx("h3",{children:"Stewardship"}),h.jsxs("div",{className:"kv",children:[h.jsx("span",{className:"k",children:"owner"}),h.jsx(Dt,{value:((A=c==null?void 0:c.stewardship)==null?void 0:A.owner)??"",placeholder:"—",readOnly:l,onCommit:S=>{var O;return r("set_stewardship",{id:e.id,owner:S,steward:((O=c==null?void 0:c.stewardship)==null?void 0:O.steward)??null})}})]}),h.jsxs("div",{className:"kv",children:[h.jsx("span",{className:"k",children:"steward"}),h.jsx(Dt,{value:((F=c==null?void 0:c.stewardship)==null?void 0:F.steward)??"",placeholder:"—",readOnly:l,onCommit:S=>{var O;return r("set_stewardship",{id:e.id,owner:((O=c==null?void 0:c.stewardship)==null?void 0:O.owner)??null,steward:S})}})]})]}),h.jsxs("section",{children:[h.jsxs("h3",{children:["Attributes (",e.attributes.length,")"]}),h.jsx("table",{className:"attr-table",children:h.jsx("tbody",{children:e.attributes.map(S=>h.jsx(Cm,{a:S,entity:e,doc:t,readOnly:l,exec:r},S.id))})}),!l&&h.jsx($m,{entity:e,exec:r})]}),e.key_groups&&e.key_groups.length>0&&h.jsxs("section",{children:[h.jsxs("h3",{children:["Keys (",e.key_groups.length,")"]}),e.key_groups.map(S=>{const O=S.members.map(z=>{var G;return((G=e.attributes.find(V=>V.id===z))==null?void 0:G.name)??"?"}).join(", ");return h.jsxs("div",{className:"key-row",children:[h.jsx("span",{className:"key-badge "+S.type,children:S.type.toUpperCase()}),h.jsx("span",{className:"key-name",children:S.name}),h.jsx("span",{className:"key-cols",children:O})]},S.id)})]}),e.udp&&Object.keys(e.udp).length>0&&h.jsxs("section",{children:[h.jsx("h3",{children:"Properties (UDP)"}),h.jsx("table",{className:"attr-table",children:h.jsx("tbody",{children:Object.entries(e.udp).map(([S,O])=>h.jsxs("tr",{className:"udp-row",children:[h.jsx("td",{className:"udp-key",children:S}),h.jsx("td",{className:"udp-val",children:String(O)})]},S))})})]}),u.length>0&&h.jsxs("section",{children:[h.jsxs("h3",{children:["Relationships (",u.length,")"]}),u.map(S=>{const O=S.from.entity===e.id?S.to.entity:S.from.entity;return h.jsxs("div",{className:"rel-row",children:[h.jsxs("button",{className:"rel-link",onClick:()=>i(O),children:[h.jsx("span",{className:"rel-card",children:Mm(S,e.id)}),d(O)]}),!l&&h.jsx("button",{className:"mini-btn danger",title:`delete ${S.name}`,onClick:()=>r("delete_relationship",{id:S.id}),children:"✕"})]},S.id)})]}),h.jsxs("section",{children:[h.jsx("h3",{children:"Identity"}),h.jsx("code",{className:"ulid",title:"Immutable ULID — click to copy",onClick:()=>{var S;return(S=navigator.clipboard)==null?void 0:S.writeText(e.id)},children:e.id}),!l&&h.jsx("div",{style:{marginTop:12},children:h.jsx("button",{className:"mini-btn danger",onClick:()=>{confirm(`Delete entity '${e.name}' (and its relationships)?`)&&r("delete_entity",{id:e.id,cascade:!0}).then(s)},children:"Delete entity…"})})]})]})}function Em({entityId:e,refs:t,caps:n,exec:r}){const s=!n.canEdit,i=t.filter(o=>o.uri);return i.length===0?h.jsx("p",{className:"empty-hint",children:"not aligned to any ontology term"}):h.jsx("div",{className:"ref-list",children:i.map((o,a)=>{const l=o.status==="proposed";return h.jsxs("div",{className:"ref-card"+(l?" proposed":""),children:[h.jsxs("div",{className:"ref-head",children:[h.jsx("code",{className:"ref-uri",title:o.uri??void 0,children:o.uri}),h.jsx("span",{className:"ref-status "+(l?"proposed":"accepted"),children:l?"proposed":"accepted"})]}),h.jsxs("div",{className:"ref-meta",children:[o.predicate&&h.jsx("span",{className:"ref-pill",children:o.predicate}),o.layer&&h.jsx("span",{className:`chip layer-${o.layer}`,children:o.layer}),o.resolved_via&&h.jsxs("span",{className:"ref-via",title:"resolver that found this term",children:["via ",o.resolved_via]}),typeof o.confidence=="number"&&h.jsxs("span",{className:"ref-via",children:["conf ",Math.round(o.confidence*100),"%"]})]}),!s&&h.jsxs("div",{className:"ref-actions",children:[l&&n.canArbitrate&&h.jsx("button",{className:"mini-btn",onClick:()=>r("promote_alignment",{id:e,uri:o.uri}),title:"Accept this proposed alignment (architect action)",children:"Promote"}),h.jsx("button",{className:"mini-btn danger",onClick:()=>r("clear_alignment",{id:e,uri:o.uri}),title:"Remove this alignment",children:"Remove"})]})]},`${o.uri}-${a}`)})})}function Dt({value:e,onCommit:t,readOnly:n,multiline:r=!1,placeholder:s="",className:i=""}){const[o,a]=b.useState(e);b.useEffect(()=>a(e),[e]);const l=()=>{o.trim()!==e.trim()&&t(o.trim())};return n?h.jsx("span",{className:i,children:e||s}):r?h.jsx("textarea",{className:`edit-input ${i}`,value:o,placeholder:s,rows:3,onChange:c=>a(c.target.value),onBlur:l}):h.jsx("input",{className:`edit-input ${i}`,value:o,placeholder:s,onChange:c=>a(c.target.value),onBlur:l,onKeyDown:c=>c.key==="Enter"&&c.target.blur()})}function Nm({entity:e,doc:t,readOnly:n,exec:r}){var i,o,a;const s=((o=(i=e.conceptual)==null?void 0:i.subject_area)==null?void 0:o.id)??"";return n?(a=e.conceptual)!=null&&a.subject_area?h.jsx("span",{className:"chip",children:e.conceptual.subject_area.name}):null:h.jsxs("select",{className:"chip-select",value:s,onChange:l=>r("set_subject_area",{id:e.id,subject_area:l.target.value||null}),children:[h.jsx("option",{value:"",children:"no subject area"}),t.subject_areas.map(l=>h.jsx("option",{value:l.id,children:l.name},l.id))]})}const Sm=["","scd2","hub","link","satellite","bridge"];function km({entity:e,readOnly:t,exec:n}){return t?e.pattern?h.jsx("span",{className:"chip pattern",children:e.pattern}):null:h.jsx("select",{className:"chip-select",value:e.pattern??"",onChange:r=>n("set_pattern",{id:e.id,pattern:r.target.value||null}),children:Sm.map(r=>h.jsx("option",{value:r,children:r||"no pattern"},r))})}const jm=["attribute","business_key","measure","surrogate_key"];function Cm({a:e,entity:t,doc:n,readOnly:r,exec:s}){if(r)return h.jsxs("tr",{children:[h.jsxs("td",{className:e.role==="business_key"?"pk":"",children:[e.name,e.enum_values&&e.enum_values.length>0&&h.jsx("span",{className:"enum-badge",title:`Allowed: ${e.enum_values.join(", ")}`,children:"enum"})]}),h.jsx("td",{className:"type",children:e.domain??""}),h.jsx("td",{className:"null",children:e.nullable?"":"NN"})]});const i=o=>s("update_attribute",{entity_id:t.id,attribute_id:e.id,...o});return h.jsxs("tr",{children:[h.jsxs("td",{className:e.role==="business_key"?"pk":"",children:[h.jsx(Dt,{value:e.name,readOnly:!1,onCommit:o=>i({name:o})}),e.enum_values&&e.enum_values.length>0&&h.jsx("span",{className:"enum-badge",title:`Allowed: ${e.enum_values.join(", ")}`,children:"enum"})]}),h.jsx("td",{className:"type",children:h.jsx("select",{className:"cell-select",value:e.domain??"string",onChange:o=>i({domain:o.target.value}),children:[...new Set([...vm,...n.domains??[],e.domain??"string"])].sort().map(o=>h.jsx("option",{value:o,children:o},o))})}),h.jsx("td",{children:h.jsx("select",{className:"cell-select",value:e.role,onChange:o=>i({role:o.target.value}),title:"role",children:jm.map(o=>h.jsx("option",{value:o,children:o==="business_key"?"🔑 key":o==="measure"?"Σ measure":o},o))})}),h.jsx("td",{className:"null",children:h.jsx("input",{type:"checkbox",checked:!e.nullable,title:"not null",onChange:o=>i({nullable:!o.target.checked})})}),h.jsx("td",{children:h.jsx("button",{className:"mini-btn danger",title:"delete attribute",onClick:()=>s("delete_attribute",{entity_id:t.id,attribute_id:e.id}),children:"✕"})})]})}function $m({entity:e,exec:t}){const[n,r]=b.useState(""),s=()=>{n.trim()&&t("add_attribute",{entity_id:e.id,name:n,domain:"string"}).then(()=>r(""))};return h.jsxs("div",{className:"add-attr",children:[h.jsx("input",{className:"edit-input",placeholder:"+ add attribute…",value:n,onChange:i=>r(i.target.value),onKeyDown:i=>i.key==="Enter"&&s()}),n&&h.jsx("button",{className:"mini-btn",onClick:s,children:"Add"})]})}function Mm(e,t){const n=e.from.entity===t;switch(e.cardinality){case"many_to_one":return n?"N:1 →":"1:N ←";case"one_to_many":return n?"1:N →":"N:1 ←";case"one_to_one":return"1:1";default:return"N:M"}}var Am="\0",Qe="\0",Rs="";let Im=class{constructor(t){oe(this,"_isDirected",!0);oe(this,"_isMultigraph",!1);oe(this,"_isCompound",!1);oe(this,"_label");oe(this,"_defaultNodeLabelFn",()=>{});oe(this,"_defaultEdgeLabelFn",()=>{});oe(this,"_nodes",{});oe(this,"_in",{});oe(this,"_preds",{});oe(this,"_out",{});oe(this,"_sucs",{});oe(this,"_edgeObjs",{});oe(this,"_edgeLabels",{});oe(this,"_nodeCount",0);oe(this,"_edgeCount",0);oe(this,"_parent");oe(this,"_children");t&&(this._isDirected=Object.hasOwn(t,"directed")?t.directed:!0,this._isMultigraph=Object.hasOwn(t,"multigraph")?t.multigraph:!1,this._isCompound=Object.hasOwn(t,"compound")?t.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[Qe]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(t){return this._label=t,this}graph(){return this._label}setDefaultNodeLabel(t){return this._defaultNodeLabelFn=t,typeof t!="function"&&(this._defaultNodeLabelFn=()=>t),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var t=this;return this.nodes().filter(n=>Object.keys(t._in[n]).length===0)}sinks(){var t=this;return this.nodes().filter(n=>Object.keys(t._out[n]).length===0)}setNodes(t,n){var r=arguments,s=this;return t.forEach(function(i){r.length>1?s.setNode(i,n):s.setNode(i)}),this}setNode(t,n){return Object.hasOwn(this._nodes,t)?(arguments.length>1&&(this._nodes[t]=n),this):(this._nodes[t]=arguments.length>1?n:this._defaultNodeLabelFn(t),this._isCompound&&(this._parent[t]=Qe,this._children[t]={},this._children[Qe][t]=!0),this._in[t]={},this._preds[t]={},this._out[t]={},this._sucs[t]={},++this._nodeCount,this)}node(t){return this._nodes[t]}hasNode(t){return Object.hasOwn(this._nodes,t)}removeNode(t){var n=this;if(Object.hasOwn(this._nodes,t)){var r=s=>n.removeEdge(n._edgeObjs[s]);delete this._nodes[t],this._isCompound&&(this._removeFromParentsChildList(t),delete this._parent[t],this.children(t).forEach(function(s){n.setParent(s)}),delete this._children[t]),Object.keys(this._in[t]).forEach(r),delete this._in[t],delete this._preds[t],Object.keys(this._out[t]).forEach(r),delete this._out[t],delete this._sucs[t],--this._nodeCount}return this}setParent(t,n){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(n===void 0)n=Qe;else{n+="";for(var r=n;r!==void 0;r=this.parent(r))if(r===t)throw new Error("Setting "+n+" as parent of "+t+" would create a cycle");this.setNode(n)}return this.setNode(t),this._removeFromParentsChildList(t),this._parent[t]=n,this._children[n][t]=!0,this}_removeFromParentsChildList(t){delete this._children[this._parent[t]][t]}parent(t){if(this._isCompound){var n=this._parent[t];if(n!==Qe)return n}}children(t=Qe){if(this._isCompound){var n=this._children[t];if(n)return Object.keys(n)}else{if(t===Qe)return this.nodes();if(this.hasNode(t))return[]}}predecessors(t){var n=this._preds[t];if(n)return Object.keys(n)}successors(t){var n=this._sucs[t];if(n)return Object.keys(n)}neighbors(t){var n=this.predecessors(t);if(n){const s=new Set(n);for(var r of this.successors(t))s.add(r);return Array.from(s.values())}}isLeaf(t){var n;return this.isDirected()?n=this.successors(t):n=this.neighbors(t),n.length===0}filterNodes(t){var n=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});n.setGraph(this.graph());var r=this;Object.entries(this._nodes).forEach(function([o,a]){t(o)&&n.setNode(o,a)}),Object.values(this._edgeObjs).forEach(function(o){n.hasNode(o.v)&&n.hasNode(o.w)&&n.setEdge(o,r.edge(o))});var s={};function i(o){var a=r.parent(o);return a===void 0||n.hasNode(a)?(s[o]=a,a):a in s?s[a]:i(a)}return this._isCompound&&n.nodes().forEach(o=>n.setParent(o,i(o))),n}setDefaultEdgeLabel(t){return this._defaultEdgeLabelFn=t,typeof t!="function"&&(this._defaultEdgeLabelFn=()=>t),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(t,n){var r=this,s=arguments;return t.reduce(function(i,o){return s.length>1?r.setEdge(i,o,n):r.setEdge(i,o),o}),this}setEdge(){var t,n,r,s,i=!1,o=arguments[0];typeof o=="object"&&o!==null&&"v"in o?(t=o.v,n=o.w,r=o.name,arguments.length===2&&(s=arguments[1],i=!0)):(t=o,n=arguments[1],r=arguments[3],arguments.length>2&&(s=arguments[2],i=!0)),t=""+t,n=""+n,r!==void 0&&(r=""+r);var a=Lt(this._isDirected,t,n,r);if(Object.hasOwn(this._edgeLabels,a))return i&&(this._edgeLabels[a]=s),this;if(r!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(t),this.setNode(n),this._edgeLabels[a]=i?s:this._defaultEdgeLabelFn(t,n,r);var l=Tm(this._isDirected,t,n,r);return t=l.v,n=l.w,Object.freeze(l),this._edgeObjs[a]=l,Os(this._preds[n],t),Os(this._sucs[t],n),this._in[n][a]=l,this._out[t][a]=l,this._edgeCount++,this}edge(t,n,r){var s=arguments.length===1?Xn(this._isDirected,arguments[0]):Lt(this._isDirected,t,n,r);return this._edgeLabels[s]}edgeAsObj(){const t=this.edge(...arguments);return typeof t!="object"?{label:t}:t}hasEdge(t,n,r){var s=arguments.length===1?Xn(this._isDirected,arguments[0]):Lt(this._isDirected,t,n,r);return Object.hasOwn(this._edgeLabels,s)}removeEdge(t,n,r){var s=arguments.length===1?Xn(this._isDirected,arguments[0]):Lt(this._isDirected,t,n,r),i=this._edgeObjs[s];return i&&(t=i.v,n=i.w,delete this._edgeLabels[s],delete this._edgeObjs[s],Ds(this._preds[n],t),Ds(this._sucs[t],n),delete this._in[n][s],delete this._out[t][s],this._edgeCount--),this}inEdges(t,n){var r=this._in[t];if(r){var s=Object.values(r);return n?s.filter(i=>i.v===n):s}}outEdges(t,n){var r=this._out[t];if(r){var s=Object.values(r);return n?s.filter(i=>i.w===n):s}}nodeEdges(t,n){var r=this.inEdges(t,n);if(r)return r.concat(this.outEdges(t,n))}};function Os(e,t){e[t]?e[t]++:e[t]=1}function Ds(e,t){--e[t]||delete e[t]}function Lt(e,t,n,r){var s=""+t,i=""+n;if(!e&&s>i){var o=s;s=i,i=o}return s+Rs+i+Rs+(r===void 0?Am:r)}function Tm(e,t,n,r){var s=""+t,i=""+n;if(!e&&s>i){var o=s;s=i,i=o}var a={v:s,w:i};return r&&(a.name=r),a}function Xn(e,t){return Lt(e,t.v,t.w,t.name)}var Dr=Im,Rm="2.2.4",Om={Graph:Dr,version:Rm},Dm=Dr,Lm={write:Pm,read:Fm};function Pm(e){var t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:zm(e),edges:Hm(e)};return e.graph()!==void 0&&(t.value=structuredClone(e.graph())),t}function zm(e){return e.nodes().map(function(t){var n=e.node(t),r=e.parent(t),s={v:t};return n!==void 0&&(s.value=n),r!==void 0&&(s.parent=r),s})}function Hm(e){return e.edges().map(function(t){var n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function Fm(e){var t=new Dm(e.options).setGraph(e.value);return e.nodes.forEach(function(n){t.setNode(n.v,n.value),n.parent&&t.setParent(n.v,n.parent)}),e.edges.forEach(function(n){t.setEdge({v:n.v,w:n.w,name:n.name},n.value)}),t}var Vm=Bm;function Bm(e){var t={},n=[],r;function s(i){Object.hasOwn(t,i)||(t[i]=!0,r.push(i),e.successors(i).forEach(s),e.predecessors(i).forEach(s))}return e.nodes().forEach(function(i){r=[],s(i),r.length&&n.push(r)}),n}let Gm=class{constructor(){oe(this,"_arr",[]);oe(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map(function(t){return t.key})}has(t){return Object.hasOwn(this._keyIndices,t)}priority(t){var n=this._keyIndices[t];if(n!==void 0)return this._arr[n].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(t,n){var r=this._keyIndices;if(t=String(t),!Object.hasOwn(r,t)){var s=this._arr,i=s.length;return r[t]=i,s.push({key:t,priority:n}),this._decrease(i),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key}decrease(t,n){var r=this._keyIndices[t];if(n>this._arr[r].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[r].priority+" New: "+n);this._arr[r].priority=n,this._decrease(r)}_heapify(t){var n=this._arr,r=2*t,s=r+1,i=t;r>1,!(n[s].priority1;function Um(e,t,n,r){return Xm(e,String(t),n||Wm,r||function(s){return e.outEdges(s)})}function Xm(e,t,n,r){var s={},i=new Ym,o,a,l=function(c){var u=c.v!==o?c.v:c.w,d=s[u],m=n(c),f=a.distance+m;if(m<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+c+" Weight: "+m);f0&&(o=i.removeMin(),a=s[o],a.distance!==Number.POSITIVE_INFINITY);)r(o).forEach(l);return s}var qm=Fo,Zm=Km;function Km(e,t,n){return e.nodes().reduce(function(r,s){return r[s]=qm(e,s,t,n),r},{})}var Vo=Qm;function Qm(e){var t=0,n=[],r={},s=[];function i(o){var a=r[o]={onStack:!0,lowlink:t,index:t++};if(n.push(o),e.successors(o).forEach(function(u){Object.hasOwn(r,u)?r[u].onStack&&(a.lowlink=Math.min(a.lowlink,r[u].index)):(i(u),a.lowlink=Math.min(a.lowlink,r[u].lowlink))}),a.lowlink===a.index){var l=[],c;do c=n.pop(),r[c].onStack=!1,l.push(c);while(o!==c);s.push(l)}}return e.nodes().forEach(function(o){Object.hasOwn(r,o)||i(o)}),s}var Jm=Vo,ep=tp;function tp(e){return Jm(e).filter(function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}var np=sp,rp=()=>1;function sp(e,t,n){return ip(e,t||rp,n||function(r){return e.outEdges(r)})}function ip(e,t,n){var r={},s=e.nodes();return s.forEach(function(i){r[i]={},r[i][i]={distance:0},s.forEach(function(o){i!==o&&(r[i][o]={distance:Number.POSITIVE_INFINITY})}),n(i).forEach(function(o){var a=o.v===i?o.w:o.v,l=t(o);r[i][a]={distance:l,predecessor:i}})}),s.forEach(function(i){var o=r[i];s.forEach(function(a){var l=r[a];s.forEach(function(c){var u=l[i],d=o[c],m=l[c],f=u.distance+d.distance;fe.successors(a):a=>e.neighbors(a),s=n==="post"?cp:up,i=[],o={};return t.forEach(a=>{if(!e.hasNode(a))throw new Error("Graph does not have node: "+a);s(a,r,o,i)}),i}function cp(e,t,n,r){for(var s=[[e,!1]];s.length>0;){var i=s.pop();i[1]?r.push(i[0]):Object.hasOwn(n,i[0])||(n[i[0]]=!0,s.push([i[0],!0]),Wo(t(i[0]),o=>s.push([o,!1])))}}function up(e,t,n,r){for(var s=[e];s.length>0;){var i=s.pop();Object.hasOwn(n,i)||(n[i]=!0,r.push(i),Wo(t(i),o=>s.push(o)))}}function Wo(e,t){for(var n=e.length;n--;)t(e[n],n,e);return e}var dp=Yo,fp=hp;function hp(e,t){return dp(e,t,"post")}var mp=Yo,pp=gp;function gp(e,t){return mp(e,t,"pre")}var yp=Dr,xp=Ho,wp=bp;function bp(e,t){var n=new yp,r={},s=new xp,i;function o(l){var c=l.v===i?l.w:l.v,u=s.priority(c);if(u!==void 0){var d=t(l);d0;){if(i=s.removeMin(),Object.hasOwn(r,i))n.setEdge(i,r[i]);else{if(a)throw new Error("Input graph is not connected: "+e);a=!0}e.nodeEdges(i).forEach(o)}return n}var vp={components:Vm,dijkstra:Fo,dijkstraAll:Zm,findCycles:ep,floydWarshall:np,isAcyclic:op,postorder:fp,preorder:pp,prim:wp,tarjan:Vo,topsort:Go},Ps=Om,ke={Graph:Ps.Graph,json:Lm,alg:vp,version:Ps.version};let _p=class{constructor(){let t={};t._next=t._prev=t,this._sentinel=t}dequeue(){let t=this._sentinel,n=t._prev;if(n!==t)return zs(n),n}enqueue(t){let n=this._sentinel;t._prev&&t._next&&zs(t),t._next=n._next,n._next._prev=t,n._next=t,t._prev=n}toString(){let t=[],n=this._sentinel,r=n._prev;for(;r!==n;)t.push(JSON.stringify(r,Ep)),r=r._prev;return"["+t.join(", ")+"]"}};function zs(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function Ep(e,t){if(e!=="_next"&&e!=="_prev")return t}var Np=_p;let Sp=ke.Graph,kp=Np;var jp=$p;let Cp=()=>1;function $p(e,t){if(e.nodeCount()<=1)return[];let n=Ap(e,t||Cp);return Mp(n.graph,n.buckets,n.zeroIdx).flatMap(s=>e.outEdges(s.v,s.w))}function Mp(e,t,n){let r=[],s=t[t.length-1],i=t[0],o;for(;e.nodeCount();){for(;o=i.dequeue();)qn(e,t,n,o);for(;o=s.dequeue();)qn(e,t,n,o);if(e.nodeCount()){for(let a=t.length-2;a>0;--a)if(o=t[a].dequeue(),o){r=r.concat(qn(e,t,n,o,!0));break}}}return r}function qn(e,t,n,r,s){let i=s?[]:void 0;return e.inEdges(r.v).forEach(o=>{let a=e.edge(o),l=e.node(o.v);s&&i.push({v:o.v,w:o.w}),l.out-=a,gr(t,n,l)}),e.outEdges(r.v).forEach(o=>{let a=e.edge(o),l=o.w,c=e.node(l);c.in-=a,gr(t,n,c)}),e.removeNode(r.v),i}function Ap(e,t){let n=new Sp,r=0,s=0;e.nodes().forEach(a=>{n.setNode(a,{v:a,in:0,out:0})}),e.edges().forEach(a=>{let l=n.edge(a.v,a.w)||0,c=t(a),u=l+c;n.setEdge(a.v,a.w,u),s=Math.max(s,n.node(a.v).out+=c),r=Math.max(r,n.node(a.w).in+=c)});let i=Ip(s+r+3).map(()=>new kp),o=r+1;return n.nodes().forEach(a=>{gr(i,o,n.node(a))}),{graph:n,buckets:i,zeroIdx:o}}function gr(e,t,n){n.out?n.in?e[n.out-n.in+t].enqueue(n):e[e.length-1].enqueue(n):e[0].enqueue(n)}function Ip(e){const t=[];for(let n=0;nt.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},s=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+s.weight,minlen:Math.max(r.minlen,s.minlen)})}),t}function Rp(e){let t=new Uo({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function Op(e){let t=e.nodes().map(n=>{let r={};return e.outEdges(n).forEach(s=>{r[s.w]=(r[s.w]||0)+e.edge(s).weight}),r});return Lr(e.nodes(),t)}function Dp(e){let t=e.nodes().map(n=>{let r={};return e.inEdges(n).forEach(s=>{r[s.v]=(r[s.v]||0)+e.edge(s).weight}),r});return Lr(e.nodes(),t)}function Lp(e,t){let n=e.x,r=e.y,s=t.x-n,i=t.y-r,o=e.width/2,a=e.height/2;if(!s&&!i)throw new Error("Not possible to find intersection inside of the rectangle");let l,c;return Math.abs(i)*o>Math.abs(s)*a?(i<0&&(a=-a),l=a*s/i,c=a):(s<0&&(o=-o),l=o,c=o*i/s),{x:n+l,y:r+c}}function Pp(e){let t=Qo(Zo(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),s=r.rank;s!==void 0&&(t[s][r.order]=n)}),t}function zp(e){let t=e.nodes().map(r=>{let s=e.node(r).rank;return s===void 0?Number.MAX_VALUE:s}),n=In(Math.min,t);e.nodes().forEach(r=>{let s=e.node(r);Object.hasOwn(s,"rank")&&(s.rank-=n)})}function Hp(e){let t=e.nodes().map(o=>e.node(o).rank),n=In(Math.min,t),r=[];e.nodes().forEach(o=>{let a=e.node(o).rank-n;r[a]||(r[a]=[]),r[a].push(o)});let s=0,i=e.graph().nodeRankFactor;Array.from(r).forEach((o,a)=>{o===void 0&&a%i!==0?--s:o!==void 0&&s&&o.forEach(l=>e.node(l).rank+=s)})}function Fp(e,t,n,r){let s={width:0,height:0};return arguments.length>=4&&(s.rank=n,s.order=r),Xo(e,"border",s,t)}function Vp(e,t=qo){const n=[];for(let r=0;rqo){const n=Vp(t);return e.apply(null,n.map(r=>e.apply(null,r)))}else return e.apply(null,t)}function Zo(e){const n=e.nodes().map(r=>{let s=e.node(r).rank;return s===void 0?Number.MIN_VALUE:s});return In(Math.max,n)}function Bp(e,t){let n={lhs:[],rhs:[]};return e.forEach(r=>{t(r)?n.lhs.push(r):n.rhs.push(r)}),n}function Gp(e,t){let n=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-n)+"ms")}}function Yp(e,t){return t()}let Wp=0;function Ko(e){var t=++Wp;return e+(""+t)}function Qo(e,t,n=1){t==null&&(t=e,e=0);let r=i=>itr[t]),Object.entries(e).reduce((r,[s,i])=>(r[s]=n(i,s),r),{})}function Lr(e,t){return e.reduce((n,r,s)=>(n[r]=t[s],n),{})}let qp=jp,Zp=ce.uniqueId;var Kp={run:Qp,undo:eg};function Qp(e){(e.graph().acyclicer==="greedy"?qp(e,n(e)):Jp(e)).forEach(r=>{let s=e.edge(r);e.removeEdge(r),s.forwardName=r.name,s.reversed=!0,e.setEdge(r.w,r.v,s,Zp("rev"))});function n(r){return s=>r.edge(s).weight}}function Jp(e){let t=[],n={},r={};function s(i){Object.hasOwn(r,i)||(r[i]=!0,n[i]=!0,e.outEdges(i).forEach(o=>{Object.hasOwn(n,o.w)?t.push(o):s(o.w)}),delete n[i])}return e.nodes().forEach(s),t}function eg(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}let tg=ce;var ng={run:rg,undo:ig};function rg(e){e.graph().dummyChains=[],e.edges().forEach(t=>sg(e,t))}function sg(e,t){let n=t.v,r=e.node(n).rank,s=t.w,i=e.node(s).rank,o=t.name,a=e.edge(t),l=a.labelRank;if(i===r+1)return;e.removeEdge(t);let c,u,d;for(d=0,++r;r{let n=e.node(t),r=n.edgeLabel,s;for(e.setEdge(n.edgeObj,r);n.dummy;)s=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy==="edge-label"&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=s,n=e.node(t)})}const{applyWithChunking:og}=ce;var Tn={longestPath:ag,slack:lg};function ag(e){var t={};function n(r){var s=e.node(r);if(Object.hasOwn(t,r))return s.rank;t[r]=!0;let i=e.outEdges(r).map(a=>a==null?Number.POSITIVE_INFINITY:n(a.w)-e.edge(a).minlen);var o=og(Math.min,i);return o===Number.POSITIVE_INFINITY&&(o=0),s.rank=o}e.sources().forEach(n)}function lg(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var cg=ke.Graph,vn=Tn.slack,Jo=ug;function ug(e){var t=new cg({directed:!1}),n=e.nodes()[0],r=e.nodeCount();t.setNode(n,{});for(var s,i;dg(t,e){var i=s.v,o=r===i?s.w:i;!e.hasNode(o)&&!vn(t,s)&&(e.setNode(o,{}),e.setEdge(r,o,{}),n(o))})}return e.nodes().forEach(n),e.nodeCount()}function fg(e,t){return t.edges().reduce((r,s)=>{let i=Number.POSITIVE_INFINITY;return e.hasNode(s.v)!==e.hasNode(s.w)&&(i=vn(t,s)),it.node(r).rank+=n)}var mg=Jo,Hs=Tn.slack,pg=Tn.longestPath,gg=ke.alg.preorder,yg=ke.alg.postorder,xg=ce.simplify,wg=ot;ot.initLowLimValues=zr;ot.initCutValues=Pr;ot.calcCutValue=ea;ot.leaveEdge=na;ot.enterEdge=ra;ot.exchangeEdges=sa;function ot(e){e=xg(e),pg(e);var t=mg(e);zr(t),Pr(t,e);for(var n,r;n=na(t);)r=ra(t,e,n),sa(t,e,n,r)}function Pr(e,t){var n=yg(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(r=>bg(e,t,r))}function bg(e,t,n){var r=e.node(n),s=r.parent;e.edge(n,s).cutvalue=ea(e,t,n)}function ea(e,t,n){var r=e.node(n),s=r.parent,i=!0,o=t.edge(n,s),a=0;return o||(i=!1,o=t.edge(s,n)),a=o.weight,t.nodeEdges(n).forEach(l=>{var c=l.v===n,u=c?l.w:l.v;if(u!==s){var d=c===i,m=t.edge(l).weight;if(a+=d?m:-m,_g(e,n,u)){var f=e.edge(n,u).cutvalue;a+=d?-f:f}}}),a}function zr(e,t){arguments.length<2&&(t=e.nodes()[0]),ta(e,{},1,t)}function ta(e,t,n,r,s){var i=n,o=e.node(r);return t[r]=!0,e.neighbors(r).forEach(a=>{Object.hasOwn(t,a)||(n=ta(e,t,n,a,r))}),o.low=i,o.lim=n++,s?o.parent=s:delete o.parent,n}function na(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function ra(e,t,n){var r=n.v,s=n.w;t.hasEdge(r,s)||(r=n.w,s=n.v);var i=e.node(r),o=e.node(s),a=i,l=!1;i.lim>o.lim&&(a=o,l=!0);var c=t.edges().filter(u=>l===Fs(e,e.node(u.v),a)&&l!==Fs(e,e.node(u.w),a));return c.reduce((u,d)=>Hs(t,d)!t.node(s).parent),r=gg(e,n);r=r.slice(1),r.forEach(s=>{var i=e.node(s).parent,o=t.edge(s,i),a=!1;o||(o=t.edge(i,s),a=!0),t.node(s).rank=t.node(i).rank+(a?o.minlen:-o.minlen)})}function _g(e,t,n){return e.hasEdge(t,n)}function Fs(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var Eg=Tn,ia=Eg.longestPath,Ng=Jo,Sg=wg,kg=jg;function jg(e){var t=e.graph().ranker;if(t instanceof Function)return t(e);switch(e.graph().ranker){case"network-simplex":Vs(e);break;case"tight-tree":$g(e);break;case"longest-path":Cg(e);break;case"none":break;default:Vs(e)}}var Cg=ia;function $g(e){ia(e),Ng(e)}function Vs(e){Sg(e)}var Mg=Ag;function Ag(e){let t=Tg(e);e.graph().dummyChains.forEach(n=>{let r=e.node(n),s=r.edgeObj,i=Ig(e,t,s.v,s.w),o=i.path,a=i.lca,l=0,c=o[l],u=!0;for(;n!==s.w;){if(r=e.node(n),u){for(;(c=o[l])!==a&&e.node(c).maxRanko||a>t[l].lim));for(c=l,l=r;(l=e.parent(l))!==c;)i.push(l);return{path:s.concat(i.reverse()),lca:c}}function Tg(e){let t={},n=0;function r(s){let i=n;e.children(s).forEach(r),t[s]={low:i,lim:n++}}return e.children().forEach(r),t}let _n=ce;var Rg={run:Og,cleanup:Pg};function Og(e){let t=_n.addDummyNode(e,"root",{},"_root"),n=Dg(e),r=Object.values(n),s=_n.applyWithChunking(Math.max,r)-1,i=2*s+1;e.graph().nestingRoot=t,e.edges().forEach(a=>e.edge(a).minlen*=i);let o=Lg(e)+1;e.children().forEach(a=>oa(e,t,i,o,s,n,a)),e.graph().nodeRankFactor=i}function oa(e,t,n,r,s,i,o){let a=e.children(o);if(!a.length){o!==t&&e.setEdge(t,o,{weight:0,minlen:n});return}let l=_n.addBorderNode(e,"_bt"),c=_n.addBorderNode(e,"_bb"),u=e.node(o);e.setParent(l,o),u.borderTop=l,e.setParent(c,o),u.borderBottom=c,a.forEach(d=>{oa(e,t,n,r,s,i,d);let m=e.node(d),f=m.borderTop?m.borderTop:d,y=m.borderBottom?m.borderBottom:d,x=m.borderTop?r:2*r,_=f!==y?1:s-i[o]+1;e.setEdge(l,f,{weight:x,minlen:_,nestingEdge:!0}),e.setEdge(y,c,{weight:x,minlen:_,nestingEdge:!0})}),e.parent(o)||e.setEdge(t,l,{weight:0,minlen:s+i[o]})}function Dg(e){var t={};function n(r,s){var i=e.children(r);i&&i.length&&i.forEach(o=>n(o,s+1)),t[r]=s}return e.children().forEach(r=>n(r,1)),t}function Lg(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function Pg(e){var t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(n=>{var r=e.edge(n);r.nestingEdge&&e.removeEdge(n)})}let zg=ce;var Hg=Fg;function Fg(e){function t(n){let r=e.children(n),s=e.node(n);if(r.length&&r.forEach(t),Object.hasOwn(s,"minRank")){s.borderLeft=[],s.borderRight=[];for(let i=s.minRank,o=s.maxRank+1;iGs(e.node(t))),e.edges().forEach(t=>Gs(e.edge(t)))}function Gs(e){let t=e.width;e.width=e.height,e.height=t}function Yg(e){e.nodes().forEach(t=>Zn(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);n.points.forEach(Zn),Object.hasOwn(n,"y")&&Zn(n)})}function Zn(e){e.y=-e.y}function Wg(e){e.nodes().forEach(t=>Kn(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);n.points.forEach(Kn),Object.hasOwn(n,"x")&&Kn(n)})}function Kn(e){let t=e.x;e.x=e.y,e.y=t}let Ys=ce;var Ug=Xg;function Xg(e){let t={},n=e.nodes().filter(l=>!e.children(l).length),r=n.map(l=>e.node(l).rank),s=Ys.applyWithChunking(Math.max,r),i=Ys.range(s+1).map(()=>[]);function o(l){if(t[l])return;t[l]=!0;let c=e.node(l);i[c.rank].push(l),e.successors(l).forEach(o)}return n.sort((l,c)=>e.node(l).rank-e.node(c).rank).forEach(o),i}let qg=ce.zipObject;var Zg=Kg;function Kg(e,t){let n=0;for(let r=1;ru)),s=t.flatMap(c=>e.outEdges(c).map(u=>({pos:r[u.w],weight:e.edge(u).weight})).sort((u,d)=>u.pos-d.pos)),i=1;for(;i{let u=c.pos+i;a[u]+=c.weight;let d=0;for(;u>0;)u%2&&(d+=a[u+1]),u=u-1>>1,a[u]+=c.weight;l+=c.weight*d}),l}var Jg=e0;function e0(e,t=[]){return t.map(n=>{let r=e.inEdges(n);if(r.length){let s=r.reduce((i,o)=>{let a=e.edge(o),l=e.node(o.v);return{sum:i.sum+a.weight*l.order,weight:i.weight+a.weight}},{sum:0,weight:0});return{v:n,barycenter:s.sum/s.weight,weight:s.weight}}else return{v:n}})}let t0=ce;var n0=r0;function r0(e,t){let n={};e.forEach((s,i)=>{let o=n[s.v]={indegree:0,in:[],out:[],vs:[s.v],i};s.barycenter!==void 0&&(o.barycenter=s.barycenter,o.weight=s.weight)}),t.edges().forEach(s=>{let i=n[s.v],o=n[s.w];i!==void 0&&o!==void 0&&(o.indegree++,i.out.push(n[s.w]))});let r=Object.values(n).filter(s=>!s.indegree);return s0(r)}function s0(e){let t=[];function n(s){return i=>{i.merged||(i.barycenter===void 0||s.barycenter===void 0||i.barycenter>=s.barycenter)&&i0(s,i)}}function r(s){return i=>{i.in.push(s),--i.indegree===0&&e.push(i)}}for(;e.length;){let s=e.pop();t.push(s),s.in.reverse().forEach(n(s)),s.out.forEach(r(s))}return t.filter(s=>!s.merged).map(s=>t0.pick(s,["vs","i","barycenter","weight"]))}function i0(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}let o0=ce;var a0=l0;function l0(e,t){let n=o0.partition(e,u=>Object.hasOwn(u,"barycenter")),r=n.lhs,s=n.rhs.sort((u,d)=>d.i-u.i),i=[],o=0,a=0,l=0;r.sort(c0(!!t)),l=Ws(i,s,l),r.forEach(u=>{l+=u.vs.length,i.push(u.vs),o+=u.barycenter*u.weight,a+=u.weight,l=Ws(i,s,l)});let c={vs:i.flat(!0)};return a&&(c.barycenter=o/a,c.weight=a),c}function Ws(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function c0(e){return(t,n)=>t.barycentern.barycenter?1:e?n.i-t.i:t.i-n.i}let u0=Jg,d0=n0,f0=a0;var h0=la;function la(e,t,n,r){let s=e.children(t),i=e.node(t),o=i?i.borderLeft:void 0,a=i?i.borderRight:void 0,l={};o&&(s=s.filter(m=>m!==o&&m!==a));let c=u0(e,s);c.forEach(m=>{if(e.children(m.v).length){let f=la(e,m.v,n,r);l[m.v]=f,Object.hasOwn(f,"barycenter")&&p0(m,f)}});let u=d0(c,n);m0(u,l);let d=f0(u,r);if(o&&(d.vs=[o,d.vs,a].flat(!0),e.predecessors(o).length)){let m=e.node(e.predecessors(o)[0]),f=e.node(e.predecessors(a)[0]);Object.hasOwn(d,"barycenter")||(d.barycenter=0,d.weight=0),d.barycenter=(d.barycenter*d.weight+m.order+f.order)/(d.weight+2),d.weight+=2}return d}function m0(e,t){e.forEach(n=>{n.vs=n.vs.flatMap(r=>t[r]?t[r].vs:r)})}function p0(e,t){e.barycenter!==void 0?(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight):(e.barycenter=t.barycenter,e.weight=t.weight)}let g0=ke.Graph,y0=ce;var x0=w0;function w0(e,t,n,r){r||(r=e.nodes());let s=b0(e),i=new g0({compound:!0}).setGraph({root:s}).setDefaultNodeLabel(o=>e.node(o));return r.forEach(o=>{let a=e.node(o),l=e.parent(o);(a.rank===t||a.minRank<=t&&t<=a.maxRank)&&(i.setNode(o),i.setParent(o,l||s),e[n](o).forEach(c=>{let u=c.v===o?c.w:c.v,d=i.edge(u,o),m=d!==void 0?d.weight:0;i.setEdge(u,o,{weight:e.edge(c).weight+m})}),Object.hasOwn(a,"minRank")&&i.setNode(o,{borderLeft:a.borderLeft[t],borderRight:a.borderRight[t]}))}),i}function b0(e){for(var t;e.hasNode(t=y0.uniqueId("_root")););return t}var v0=_0;function _0(e,t,n){let r={},s;n.forEach(i=>{let o=e.parent(i),a,l;for(;o;){if(a=e.parent(o),a?(l=r[a],r[a]=o):(l=s,s=o),l&&l!==o){t.setEdge(l,o);return}o=a}})}let E0=Ug,N0=Zg,S0=h0,k0=x0,j0=v0,C0=ke.Graph,on=ce;var $0=ca;function ca(e,t){if(t&&typeof t.customOrder=="function"){t.customOrder(e,ca);return}let n=on.maxRank(e),r=Us(e,on.range(1,n+1),"inEdges"),s=Us(e,on.range(n-1,-1,-1),"outEdges"),i=E0(e);if(Xs(e,i),t&&t.disableOptimalOrderHeuristic)return;let o=Number.POSITIVE_INFINITY,a;for(let l=0,c=0;c<4;++l,++c){M0(l%2?r:s,l%4>=2),i=on.buildLayerMatrix(e);let u=N0(e,i);u{r.has(i)||r.set(i,[]),r.get(i).push(o)};for(const i of e.nodes()){const o=e.node(i);if(typeof o.rank=="number"&&s(o.rank,i),typeof o.minRank=="number"&&typeof o.maxRank=="number")for(let a=o.minRank;a<=o.maxRank;a++)a!==o.rank&&s(a,i)}return t.map(function(i){return k0(e,i,n,r.get(i)||[])})}function M0(e,t){let n=new C0;e.forEach(function(r){let s=r.graph().root,i=S0(r,s,n,t);i.vs.forEach((o,a)=>r.node(o).order=a),j0(r,n,i.vs)})}function Xs(e,t){Object.values(t).forEach(n=>n.forEach((r,s)=>e.node(r).order=s))}let A0=ke.Graph,Re=ce;var I0={positionX:B0};function T0(e,t){let n={};function r(s,i){let o=0,a=0,l=s.length,c=i[i.length-1];return i.forEach((u,d)=>{let m=O0(e,u),f=m?e.node(m).order:l;(m||u===c)&&(i.slice(a,d+1).forEach(y=>{e.predecessors(y).forEach(x=>{let _=e.node(x),g=_.order;(g{u=i[d],e.node(u).dummy&&e.predecessors(u).forEach(m=>{let f=e.node(m);f.dummy&&(f.orderc)&&ua(n,m,u)})})}function s(i,o){let a=-1,l,c=0;return o.forEach((u,d)=>{if(e.node(u).dummy==="border"){let m=e.predecessors(u);m.length&&(l=e.node(m[0]).order,r(o,c,d,a,l),c=d,a=l)}r(o,c,o.length,l,i.length)}),o}return t.length&&t.reduce(s),n}function O0(e,t){if(e.node(t).dummy)return e.predecessors(t).find(n=>e.node(n).dummy)}function ua(e,t,n){if(t>n){let s=t;t=n,n=s}let r=e[t];r||(e[t]=r={}),r[n]=!0}function D0(e,t,n){if(t>n){let r=t;t=n,n=r}return!!e[t]&&Object.hasOwn(e[t],n)}function L0(e,t,n,r){let s={},i={},o={};return t.forEach(a=>{a.forEach((l,c)=>{s[l]=l,i[l]=l,o[l]=c})}),t.forEach(a=>{let l=-1;a.forEach(c=>{let u=r(c);if(u.length){u=u.sort((m,f)=>o[m]-o[f]);let d=(u.length-1)/2;for(let m=Math.floor(d),f=Math.ceil(d);m<=f;++m){let y=u[m];i[c]===c&&lMath.max(m,i[f.v]+o.edge(f)),0)}function u(d){let m=o.outEdges(d).reduce((y,x)=>Math.min(y,i[x.w]-o.edge(x)),Number.POSITIVE_INFINITY),f=e.node(d);m!==Number.POSITIVE_INFINITY&&f.borderType!==a&&(i[d]=Math.max(i[d],m))}return l(c,o.predecessors.bind(o)),l(u,o.successors.bind(o)),Object.keys(r).forEach(d=>i[d]=i[n[d]]),i}function z0(e,t,n,r){let s=new A0,i=e.graph(),o=G0(i.nodesep,i.edgesep,r);return t.forEach(a=>{let l;a.forEach(c=>{let u=n[c];if(s.setNode(u),l){var d=n[l],m=s.edge(d,u);s.setEdge(d,u,Math.max(o(e,c,l),m||0))}l=c})}),s}function H0(e,t){return Object.values(t).reduce((n,r)=>{let s=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;Object.entries(r).forEach(([a,l])=>{let c=Y0(e,a)/2;s=Math.max(l+c,s),i=Math.min(l-c,i)});const o=s-i;return o{["l","r"].forEach(o=>{let a=i+o,l=e[a];if(l===t)return;let c=Object.values(l),u=r-Re.applyWithChunking(Math.min,c);o!=="l"&&(u=s-Re.applyWithChunking(Math.max,c)),u&&(e[a]=Re.mapValues(l,d=>d+u))})})}function V0(e,t){return Re.mapValues(e.ul,(n,r)=>{if(t)return e[t.toLowerCase()][r];{let s=Object.values(e).map(i=>i[r]).sort((i,o)=>i-o);return(s[1]+s[2])/2}})}function B0(e){let t=Re.buildLayerMatrix(e),n=Object.assign(T0(e,t),R0(e,t)),r={},s;["u","d"].forEach(o=>{s=o==="u"?t:Object.values(t).reverse(),["l","r"].forEach(a=>{a==="r"&&(s=s.map(d=>Object.values(d).reverse()));let l=(o==="u"?e.predecessors:e.successors).bind(e),c=L0(e,s,n,l),u=P0(e,s,c.root,c.align,a==="r");a==="r"&&(u=Re.mapValues(u,d=>-d)),r[o+a]=u})});let i=H0(e,r);return F0(r,i),V0(r,e.graph().align)}function G0(e,t,n){return(r,s,i)=>{let o=r.node(s),a=r.node(i),l=0,c;if(l+=o.width/2,Object.hasOwn(o,"labelpos"))switch(o.labelpos.toLowerCase()){case"l":c=-o.width/2;break;case"r":c=o.width/2;break}if(c&&(l+=n?c:-c),c=0,l+=(o.dummy?t:e)/2,l+=(a.dummy?t:e)/2,l+=a.width/2,Object.hasOwn(a,"labelpos"))switch(a.labelpos.toLowerCase()){case"l":c=a.width/2;break;case"r":c=-a.width/2;break}return c&&(l+=n?c:-c),c=0,l}}function Y0(e,t){return e.node(t).width}let da=ce,W0=I0.positionX;var U0=X0;function X0(e){e=da.asNonCompoundGraph(e),q0(e),Object.entries(W0(e)).forEach(([t,n])=>e.node(t).x=n)}function q0(e){let t=da.buildLayerMatrix(e),n=e.graph().ranksep,r=0;t.forEach(s=>{const i=s.reduce((o,a)=>{const l=e.node(a).height;return o>l?o:l},0);s.forEach(o=>e.node(o).y=r+i/2),r+=i+n})}let qs=Kp,Zs=ng,Z0=kg,K0=ce.normalizeRanks,Q0=Mg,J0=ce.removeEmptyRanks,Ks=Rg,ey=Hg,Qs=Vg,ty=$0,ny=U0,ve=ce,ry=ke.Graph;var sy=iy;function iy(e,t){let n=t&&t.debugTiming?ve.time:ve.notime;n("layout",()=>{let r=n(" buildLayoutGraph",()=>py(e));n(" runLayout",()=>oy(r,n,t)),n(" updateInputGraph",()=>ay(e,r))})}function oy(e,t,n){t(" makeSpaceForEdgeLabels",()=>gy(e)),t(" removeSelfEdges",()=>Sy(e)),t(" acyclic",()=>qs.run(e)),t(" nestingGraph.run",()=>Ks.run(e)),t(" rank",()=>Z0(ve.asNonCompoundGraph(e))),t(" injectEdgeLabelProxies",()=>yy(e)),t(" removeEmptyRanks",()=>J0(e)),t(" nestingGraph.cleanup",()=>Ks.cleanup(e)),t(" normalizeRanks",()=>K0(e)),t(" assignRankMinMax",()=>xy(e)),t(" removeEdgeLabelProxies",()=>wy(e)),t(" normalize.run",()=>Zs.run(e)),t(" parentDummyChains",()=>Q0(e)),t(" addBorderSegments",()=>ey(e)),t(" order",()=>ty(e,n)),t(" insertSelfEdges",()=>ky(e)),t(" adjustCoordinateSystem",()=>Qs.adjust(e)),t(" position",()=>ny(e)),t(" positionSelfEdges",()=>jy(e)),t(" removeBorderNodes",()=>Ny(e)),t(" normalize.undo",()=>Zs.undo(e)),t(" fixupEdgeLabelCoords",()=>_y(e)),t(" undoCoordinateSystem",()=>Qs.undo(e)),t(" translateGraph",()=>by(e)),t(" assignNodeIntersects",()=>vy(e)),t(" reversePoints",()=>Ey(e)),t(" acyclic.undo",()=>qs.undo(e))}function ay(e,t){e.nodes().forEach(n=>{let r=e.node(n),s=t.node(n);r&&(r.x=s.x,r.y=s.y,r.rank=s.rank,t.children(n).length&&(r.width=s.width,r.height=s.height))}),e.edges().forEach(n=>{let r=e.edge(n),s=t.edge(n);r.points=s.points,Object.hasOwn(s,"x")&&(r.x=s.x,r.y=s.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}let ly=["nodesep","edgesep","ranksep","marginx","marginy"],cy={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},uy=["acyclicer","ranker","rankdir","align"],dy=["width","height","rank"],Js={width:0,height:0},fy=["minlen","weight","width","height","labeloffset"],hy={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},my=["labelpos"];function py(e){let t=new ry({multigraph:!0,compound:!0}),n=Jn(e.graph());return t.setGraph(Object.assign({},cy,Qn(n,ly),ve.pick(n,uy))),e.nodes().forEach(r=>{let s=Jn(e.node(r));const i=Qn(s,dy);Object.keys(Js).forEach(o=>{i[o]===void 0&&(i[o]=Js[o])}),t.setNode(r,i),t.setParent(r,e.parent(r))}),e.edges().forEach(r=>{let s=Jn(e.edge(r));t.setEdge(r,Object.assign({},hy,Qn(s,fy),ve.pick(s,my)))}),t}function gy(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{let r=e.edge(n);r.minlen*=2,r.labelpos.toLowerCase()!=="c"&&(t.rankdir==="TB"||t.rankdir==="BT"?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function yy(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let r=e.node(t.v),i={rank:(e.node(t.w).rank-r.rank)/2+r.rank,e:t};ve.addDummyNode(e,"edge-proxy",i,"_ep")}})}function xy(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function wy(e){e.nodes().forEach(t=>{let n=e.node(t);n.dummy==="edge-proxy"&&(e.edge(n.e).labelRank=n.rank,e.removeNode(t))})}function by(e){let t=Number.POSITIVE_INFINITY,n=0,r=Number.POSITIVE_INFINITY,s=0,i=e.graph(),o=i.marginx||0,a=i.marginy||0;function l(c){let u=c.x,d=c.y,m=c.width,f=c.height;t=Math.min(t,u-m/2),n=Math.max(n,u+m/2),r=Math.min(r,d-f/2),s=Math.max(s,d+f/2)}e.nodes().forEach(c=>l(e.node(c))),e.edges().forEach(c=>{let u=e.edge(c);Object.hasOwn(u,"x")&&l(u)}),t-=o,r-=a,e.nodes().forEach(c=>{let u=e.node(c);u.x-=t,u.y-=r}),e.edges().forEach(c=>{let u=e.edge(c);u.points.forEach(d=>{d.x-=t,d.y-=r}),Object.hasOwn(u,"x")&&(u.x-=t),Object.hasOwn(u,"y")&&(u.y-=r)}),i.width=n-t+o,i.height=s-r+a}function vy(e){e.edges().forEach(t=>{let n=e.edge(t),r=e.node(t.v),s=e.node(t.w),i,o;n.points?(i=n.points[0],o=n.points[n.points.length-1]):(n.points=[],i=s,o=r),n.points.unshift(ve.intersectRect(r,i)),n.points.push(ve.intersectRect(s,o))})}function _y(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,"x"))switch((n.labelpos==="l"||n.labelpos==="r")&&(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset;break}})}function Ey(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function Ny(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),s=e.node(n.borderBottom),i=e.node(n.borderLeft[n.borderLeft.length-1]),o=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(o.x-i.x),n.height=Math.abs(s.y-r.y),n.x=i.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy==="border"&&e.removeNode(t)})}function Sy(e){e.edges().forEach(t=>{if(t.v===t.w){var n=e.node(t.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function ky(e){var t=ve.buildLayerMatrix(e);t.forEach(n=>{var r=0;n.forEach((s,i)=>{var o=e.node(s);o.order=i+r,(o.selfEdges||[]).forEach(a=>{ve.addDummyNode(e,"selfedge",{width:a.label.width,height:a.label.height,rank:o.rank,order:i+ ++r,e:a.e,label:a.label},"_se")}),delete o.selfEdges})})}function jy(e){e.nodes().forEach(t=>{var n=e.node(t);if(n.dummy==="selfedge"){var r=e.node(n.e.v),s=r.x+r.width/2,i=r.y,o=n.x-s,a=r.height/2;e.setEdge(n.e,n.label),e.removeNode(t),n.label.points=[{x:s+2*o/3,y:i-a},{x:s+5*o/6,y:i-a},{x:s+o,y:i},{x:s+5*o/6,y:i+a},{x:s+2*o/3,y:i+a}],n.label.x=n.x,n.label.y=n.y}})}function Qn(e,t){return ve.mapValues(ve.pick(e,t),Number)}function Jn(e){var t={};return e&&Object.entries(e).forEach(([n,r])=>{typeof n=="string"&&(n=n.toLowerCase()),t[n]=r}),t}let Cy=ce,$y=ke.Graph;var My={debugOrdering:Ay};function Ay(e){let t=Cy.buildLayerMatrix(e),n=new $y({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(r=>{n.setNode(r,{label:r}),n.setParent(r,"layer"+e.node(r).rank)}),e.edges().forEach(r=>n.setEdge(r.v,r.w,{},r.name)),t.forEach((r,s)=>{let i="layer"+s;n.setNode(i,{rank:"same"}),r.reduce((o,a)=>(n.setEdge(o,a,{style:"invis"}),a))}),n}var Iy="1.1.8",Ty={graphlib:ke,layout:sy,debug:My,util:{time:ce.time,notime:ce.notime},version:Iy};const ei=ai(Ty),ti=264,Ry=44,Oy=26,Dy=14;function ni(e){const t=Math.max(e.attributes.length,1);return Ry+t*Oy+Dy}function ri(e,t,n){const r=new ei.graphlib.Graph;r.setGraph({rankdir:"LR",nodesep:70,ranksep:150,edgesep:30,marginx:48,marginy:48,ranker:"network-simplex"}),r.setDefaultEdgeLabel(()=>({}));for(const s of e){const i=n.get(s.id);r.setNode(s.id,{width:ti,height:i?ni(i):120})}for(const s of t)r.setEdge(s.source,s.target,{minlen:1,weight:2});return ei.layout(r),e.map(s=>{const i=r.node(s.id),o=n.get(s.id),a=o?ni(o):120;return{...s,position:{x:i.x-ti/2,y:i.y-a/2}}})}function qt({title:e,onClose:t,children:n,wide:r}){return h.jsx("div",{className:"modal-backdrop",onClick:t,children:h.jsxs("div",{className:"modal"+(r?" wide":""),onClick:s=>s.stopPropagation(),children:[h.jsxs("div",{className:"modal-header",children:[h.jsx("h2",{children:e}),h.jsx("button",{className:"icon-btn",onClick:t,children:"✕"})]}),n]})})}const Ly=["skos:exactMatch","skos:closeMatch","skos:broadMatch","skos:narrowMatch","skos:relatedMatch"],fa=["industry","core","domain","specialised"];function Py({entity:e,exec:t,onClose:n}){var w,M;const[r,s]=b.useState(((w=e.conceptual)==null?void 0:w.name)??e.name),[i,o]=b.useState([]),[a,l]=b.useState(null),[c,u]=b.useState(null),[d,m]=b.useState("skos:exactMatch"),[f,y]=b.useState(((M=e.conceptual)==null?void 0:M.ontology_layer)??"core"),[x,_]=b.useState([]),[g,v]=b.useState("");b.useEffect(()=>{zo().then(C=>_(C.ontologies)).catch(()=>{})},[]),b.useEffect(()=>{const C=setTimeout(()=>{if(!r.trim())return o([]);Po(r,g||void 0).then(A=>{o(A.results),l(A.loaded_terms)}).catch(()=>o([]))},200);return()=>clearTimeout(C)},[r,g]);const j=()=>{c&&t("set_alignment",{id:e.id,aligns_to:c.prefixed,alignment:d,layer:f,resolved_via:c.source}).then(n)};return h.jsxs(qt,{title:`Align '${e.name}' to ontology`,onClose:n,wide:!0,children:[x.length>0&&h.jsxs("div",{className:"src-picker",children:[h.jsx("button",{className:"src-chip"+(g===""?" active":""),onClick:()=>v(""),children:"all sources"}),x.map(C=>h.jsx("button",{className:"src-chip"+(g===C.id?" active":""),title:C.count!=null?`${C.count} terms`:"live resolver",onClick:()=>v(C.id),children:C.name},C.id))]}),h.jsx("input",{autoFocus:!0,className:"edit-input modal-search",placeholder:g?`Search within ${g}…`:"Search vocabulary terms…",value:r,onChange:C=>s(C.target.value)}),a===0&&x.length===0&&h.jsx("p",{className:"empty-hint",children:"No vocabulary loaded. Declare one in mdl-project.yaml's ontology_stack (or run `mdl ontology vendor fibo`)."}),h.jsxs("div",{className:"term-results",children:[i.map(C=>h.jsxs("button",{className:"term-card"+((c==null?void 0:c.iri)===C.iri?" picked":""),onClick:()=>u(C),children:[h.jsxs("div",{className:"term-head",children:[h.jsx("span",{className:"term-label",children:C.label}),h.jsxs("span",{className:"term-source",children:[C.source_kind==="glossary-term"&&h.jsx("span",{className:"kind-badge",children:"glossary"}),C.source]})]}),h.jsx("code",{className:"term-iri",children:C.prefixed}),C.definition&&h.jsx("p",{className:"term-def",children:C.definition})]},C.iri)),r&&i.length===0&&a!==0&&h.jsxs("p",{className:"empty-hint",children:["no matches for “",r,"”"]})]}),h.jsxs("div",{className:"modal-footer",children:[h.jsxs("label",{children:["predicate",h.jsx("select",{value:d,onChange:C=>m(C.target.value),children:Ly.map(C=>h.jsx("option",{children:C},C))})]}),h.jsxs("label",{children:["layer",h.jsx("select",{value:f,onChange:C=>y(C.target.value),children:fa.map(C=>h.jsx("option",{children:C},C))})]}),h.jsxs("button",{className:"primary-btn",disabled:!c,onClick:j,children:["Align",c?` to ${c.label}`:""]})]})]})}function zy({entity:e,doc:t,exec:n,onClose:r}){var w,M,C;const[s,i]=b.useState(((w=e.term_map)==null?void 0:w.subject_template)??""),[o,a]=b.useState(((M=e.term_map)==null?void 0:M.class_iri)??""),l=new Set(e.attributes.map(A=>A.name)),u=Array.from(s.matchAll(/\{([^}]+)\}/g)).map(A=>A[1]).filter(A=>!l.has(A)),d=A=>!A||A.startsWith("http://")||A.startsWith("https://")||/^[^\s:]+:[^\s:]+/.test(A),m=u.length===0&&d(o),f=()=>{n("set_term_map",{id:e.id,subject_template:s.trim()||null,class_iri:o.trim()||null}).then(r)},y=(t.project.name||"").replace(/[^0-9a-zA-Z]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()||"modelith-model",x=t.project.kg_base_iri||`urn:${y}:`,_=(C=(e.key_groups??[]).find(A=>A.type==="pk"))==null?void 0:C.members.map(A=>{var F;return(F=e.attributes.find(S=>S.id===A))==null?void 0:F.name}).filter(Boolean),g=_&&_.length?`${x}${e.id}/${_.map(A=>`{${A}}`).join("_")}`:"(blank-node: entity has no primary key)",v=o.trim()||`${x}${e.id}`,j=s.trim()||g;return h.jsxs(qt,{title:`Knowledge Graph mapping — ${e.name}`,onClose:r,wide:!0,children:[h.jsx("p",{className:"empty-hint",style:{marginBottom:14},children:"Override the R2RML term-map for this entity. Leave a field blank to use the default (project base IRI + primary key)."}),h.jsxs("div",{className:"form-row",children:[h.jsx("label",{htmlFor:"tm-class",children:"Class IRI"}),h.jsx("input",{id:"tm-class",className:"edit-input",value:o,placeholder:"https://acme.com/Customer or fibo-fnd:Party",onChange:A=>a(A.target.value)}),d(o)?h.jsxs("code",{className:"form-preview",children:["rr:class ",v]}):h.jsx("span",{className:"form-error",children:"not a valid IRI or prefix:local CURIE"})]}),h.jsxs("div",{className:"form-row",children:[h.jsx("label",{htmlFor:"tm-subject",children:"Subject template"}),h.jsx("input",{id:"tm-subject",className:"edit-input",value:s,placeholder:"https://acme.com/id/customer/{customer_id}",onChange:A=>i(A.target.value)}),u.length>0?h.jsxs("span",{className:"form-error",children:["unknown column",u.length>1?"s":"",": ",u.join(", ")]}):h.jsxs("code",{className:"form-preview",children:["rr:template ",j]}),h.jsxs("span",{className:"form-hint",children:["Wrap a column in ","{ }"," to fill it from each row, e.g."," ","{"+((_==null?void 0:_[0])??"id")+"}",". Columns:"," ",e.attributes.map(A=>A.name).join(", ")]})]}),h.jsxs("div",{className:"modal-footer",children:[h.jsx("button",{className:"mini-btn",onClick:r,children:"Cancel"}),h.jsx("button",{className:"primary-btn",disabled:!m,onClick:f,children:"Save mapping"})]})]})}function Hy({doc:e,exec:t,onClose:n,onCreated:r}){const[s,i]=b.useState(""),[o,a]=b.useState(""),[l,c]=b.useState(""),[u,d]=b.useState(""),m=()=>{s.trim()&&t("create_entity",{name:s,definition:o||null,subject_area:l||null,layer:u||null}).then(f=>{const y=f==null?void 0:f.created_id;n(),y&&r(y)})};return h.jsxs(qt,{title:"New entity",onClose:n,children:[h.jsxs("label",{className:"form-row",children:["name",h.jsx("input",{autoFocus:!0,className:"edit-input",placeholder:"e.g. custody_account",value:s,onChange:f=>i(f.target.value),onKeyDown:f=>f.key==="Enter"&&m()})]}),h.jsxs("label",{className:"form-row",children:["definition",h.jsx("textarea",{className:"edit-input",rows:2,placeholder:"business definition…",value:o,onChange:f=>a(f.target.value)})]}),h.jsxs("label",{className:"form-row",children:["subject area",h.jsxs("select",{value:l,onChange:f=>c(f.target.value),children:[h.jsx("option",{value:"",children:"none"}),e.subject_areas.map(f=>h.jsx("option",{value:f.id,children:f.name},f.id))]})]}),h.jsxs("label",{className:"form-row",children:["ontology layer",h.jsxs("select",{value:u,onChange:f=>d(f.target.value),children:[h.jsx("option",{value:"",children:"none"}),fa.map(f=>h.jsx("option",{children:f},f))]})]}),h.jsx("div",{className:"modal-footer",children:h.jsx("button",{className:"primary-btn",disabled:!s.trim(),onClick:m,children:"Create"})})]})}const ha=["many_to_one","one_to_many","one_to_one","many_to_many"];function Fy({doc:e,fromId:t,toId:n,initialFromAttr:r,initialToAttr:s,exec:i,onClose:o}){const a=e.entities.find(w=>w.id===t),l=e.entities.find(w=>w.id===n),c=b.useMemo(()=>l==null?void 0:l.attributes.find(w=>w.role==="business_key"),[l]),[u,d]=b.useState(r??""),[m,f]=b.useState(s??(c==null?void 0:c.id)??""),[y,x]=b.useState("many_to_one"),[_,g]=b.useState("mandatory");if(!a||!l)return null;const v=u==="__new__",j=()=>i("create_relationship",{from_entity:a.id,to_entity:l.id,from_attribute:v?null:u||null,to_attribute:m||null,create_from_fk:v,cardinality:y,optionality:_}).then(o);return h.jsxs(qt,{title:`${a.name} → ${l.name}`,onClose:o,children:[h.jsxs("label",{className:"form-row",children:["cardinality (",a.name," : ",l.name,")",h.jsx("select",{value:y,onChange:w=>x(w.target.value),children:ha.map(w=>h.jsx("option",{children:w},w))})]}),h.jsxs("label",{className:"form-row",children:["foreign key on ",a.name,h.jsxs("select",{value:u,onChange:w=>d(w.target.value),children:[h.jsx("option",{value:"",children:"(none)"}),h.jsxs("option",{value:"__new__",children:["➕ create column",c?` "${c.name}"`:""]}),a.attributes.map(w=>h.jsx("option",{value:w.id,children:w.name},w.id))]})]}),h.jsxs("label",{className:"form-row",children:["references on ",l.name,h.jsxs("select",{value:m,onChange:w=>f(w.target.value),children:[h.jsx("option",{value:"",children:"(none)"}),l.attributes.map(w=>h.jsxs("option",{value:w.id,children:[w.name,w.role==="business_key"?" 🔑":""]},w.id))]})]}),h.jsxs("label",{className:"form-row",children:["optionality",h.jsxs("select",{value:_,onChange:w=>g(w.target.value),children:[h.jsx("option",{children:"mandatory"}),h.jsx("option",{children:"optional"})]})]}),h.jsx("div",{className:"modal-footer",children:h.jsx("button",{className:"primary-btn",onClick:j,children:"Create relationship"})})]})}function Vy({rel:e,doc:t,exec:n,onClose:r}){const s=g=>{var v;return((v=t.entities.find(j=>j.id===g))==null?void 0:v.name)??"?"},[i,o]=b.useState(e.name),[a,l]=b.useState(e.cardinality),[c,u]=b.useState(e.optionality),[d,m]=b.useState(e.identifying),[f,y]=b.useState(!1),x=async()=>{i.trim()&&i.trim()!==e.name&&await n("rename_relationship",{id:e.id,name:i.trim()}),(a!==e.cardinality||c!==e.optionality||d!==e.identifying)&&await n("update_relationship",{id:e.id,cardinality:a,optionality:c,identifying:d}),r()},_=()=>n("delete_relationship",{id:e.id}).then(r);return h.jsxs(qt,{title:`${s(e.from.entity)} → ${s(e.to.entity)}`,onClose:r,children:[h.jsxs("label",{className:"form-row",children:["relationship name",h.jsx("input",{value:i,onChange:g=>o(g.target.value),autoFocus:!0})]}),h.jsxs("label",{className:"form-row",children:["cardinality",h.jsx("select",{value:a,onChange:g=>l(g.target.value),children:ha.map(g=>h.jsx("option",{children:g},g))})]}),h.jsxs("label",{className:"form-row",children:["optionality",h.jsxs("select",{value:c,onChange:g=>u(g.target.value),children:[h.jsx("option",{value:"mandatory",children:"mandatory"}),h.jsx("option",{value:"optional",children:"optional"})]})]}),h.jsxs("label",{className:"form-row",children:["identifying",h.jsxs("select",{value:d?"yes":"no",onChange:g=>m(g.target.value==="yes"),children:[h.jsx("option",{value:"no",children:"no — parent key is a plain reference"}),h.jsx("option",{value:"yes",children:"yes — parent key is part of the child's identity"})]})]}),h.jsxs("div",{className:"modal-footer",style:{justifyContent:"space-between"},children:[f?h.jsx("button",{className:"danger-btn",onClick:_,children:"Confirm delete"}):h.jsx("button",{className:"mini-btn danger",onClick:()=>y(!0),children:"Delete relationship"}),h.jsx("button",{className:"primary-btn",onClick:x,children:"Save"})]})]})}const By=b.memo(function({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,sourcePosition:o,targetPosition:a,data:l,selected:c}){const[u]=wn({sourceX:n,sourceY:r,sourcePosition:o,targetX:s,targetY:i,targetPosition:a,borderRadius:10}),d=l==null?void 0:l.relationship,m=(l==null?void 0:l.dimmed)??!1,f=(d==null?void 0:d.cardinality)??"many_to_one",y=(d==null?void 0:d.optionality)==="optional",x=(d==null?void 0:d.identifying)??!1,_=f==="many_to_one"||f==="many_to_many",g=f==="one_to_many"||f==="many_to_many",v="rel-edge"+(c?" selected":"")+(m?" dimmed":""),j=((l==null?void 0:l.memberCount)??0)>1,w=l==null?void 0:l.onHoverEdge;return h.jsxs("g",{className:v,children:[h.jsx("path",{id:t,className:"rel-path",d:u,fill:"none",strokeDasharray:x?void 0:"6 4"}),h.jsx("path",{d:u,fill:"none",strokeWidth:14,stroke:"transparent",onMouseEnter:w?()=>w(d.id):void 0,onMouseLeave:w?()=>w(null):void 0}),h.jsx(si,{x:n,y:r,side:o,many:_,optional:y}),h.jsx(si,{x:s,y:i,side:a,many:g,optional:!1}),(c||j)&&d&&h.jsxs("text",{className:"rel-label",x:(n+s)/2,y:(r+i)/2-8,children:[c?d.name:"",j?`${c?" ":""}(${l.memberCount})`:""]})]})});function si({x:e,y:t,side:n,many:r,optional:s}){const i=n===W.Left?-1:1,o=7,a=12,l=[];return r?l.push(h.jsx("path",{className:"rel-glyph",d:`M ${e+i*a} ${t} L ${e} ${t-o} M ${e+i*a} ${t} L ${e} ${t} M ${e+i*a} ${t} L ${e} ${t+o}`,fill:"none"},"foot")):l.push(h.jsx("line",{className:"rel-glyph",x1:e+i*(a-3),y1:t-o,x2:e+i*(a-3),y2:t+o},"one")),s?l.push(h.jsx("circle",{className:"rel-glyph ring",cx:e+i*(a+6),cy:t,r:4},"opt")):l.push(h.jsx("line",{className:"rel-glyph",x1:e+i*(a+5),y1:t-o,x2:e+i*(a+5),y2:t+o},"mand")),h.jsx(h.Fragment,{children:l})}const Gy={entity:bm},Yy={relationship:By},ii=["#e0a63a","#e8825a","#d98ba8","#c4a3e0","#7fb0d8","#7fc9a0","#e6c14a"],oi="#8a7d6a";function Wy(e,t){const n=(i,o)=>{var a;return!!o&&!!((a=t.get(i))!=null&&a.attributes.some(l=>l.id===o))},r=e.from.attributes[0],s=e.to.attributes[0];return{sourceHandle:n(e.from.entity,r)?r:Rr,targetHandle:n(e.to.entity,s)?s:Or}}function _x({doc:e,caps:t,exec:n,selectedId:r,onSelect:s,query:i="",showTypes:o=!0,onError:a,handleRef:l}){const{fitView:c}=An(),[u,d]=b.useState([]),[m,f]=b.useState([]),y=b.useRef(!1),[x,_]=b.useState(null),[g,v]=b.useState(null),[j,w]=b.useState(!1),[M,C]=b.useState(null),[A,F]=b.useState(null),[S,O]=b.useState(null),[z,G]=b.useState(null),V=!t.canEdit,p=b.useMemo(()=>{const R=new Map;return e.subject_areas.forEach((H,B)=>R.set(H.id,ii[B%ii.length])),R},[e]),k=b.useMemo(()=>{const R=new Map;return e.entities.forEach(H=>R.set(H.id,H)),R},[e]),E=b.useMemo(()=>{const R=new Map,H=(B,X)=>{if(!X.length)return;const q=R.get(B)??new Set;X.forEach(J=>q.add(J)),R.set(B,q)};for(const B of e.relationships)H(B.from.entity,B.from.attributes),H(B.to.entity,B.to.attributes);return R},[e]);b.useEffect(()=>{var ae;const R=i.trim().toLowerCase(),H=new Set;if(R)for(const Y of e.entities)(Y.name.toLowerCase()+" "+(((ae=Y.conceptual)==null?void 0:ae.name.toLowerCase())??"")+" "+Y.attributes.map(se=>se.name.toLowerCase()).join(" ")).includes(R)&&H.add(Y.id);const B=new Set;if(r){B.add(r);for(const Y of e.relationships)Y.from.entity===r&&B.add(Y.to.entity),Y.to.entity===r&&B.add(Y.from.entity)}const X=new Set,q=new Set;if(S)for(const Y of e.relationships)(Y.from.attributes.includes(S)||Y.to.attributes.includes(S))&&(X.add(Y.id),q.add(Y.from.entity),q.add(Y.to.entity));const J=new Map;if(z){const Y=e.relationships.find(te=>te.id===z);Y&&(J.set(Y.from.entity,new Set(Y.from.attributes)),J.set(Y.to.entity,new Set(Y.to.attributes)))}const Q=e.entities.map(Y=>{var le;const te=R!==""&&!H.has(Y.id),se=r!==null&&!B.has(Y.id),ne=S!==null&&!q.has(Y.id);return{id:Y.id,type:"entity",position:{x:0,y:0},data:{entity:Y,color:(le=Y.conceptual)!=null&&le.subject_area?p.get(Y.conceptual.subject_area.id)??oi:oi,dimmed:te||se||ne,highlighted:R!==""&&H.has(Y.id)||S!==null&&q.has(Y.id),showTypes:o,endpointAttrs:E.get(Y.id),highlightAttrs:J.get(Y.id),onHoverAttr:O}}}),ee=e.relationships.filter(Y=>k.has(Y.from.entity)&&k.has(Y.to.entity)).map(Y=>{const{sourceHandle:te,targetHandle:se}=Wy(Y,k),ne=r!==null&&Y.from.entity!==r&&Y.to.entity!==r,le=S!==null&&!X.has(Y.id);return{id:Y.id,source:Y.from.entity,target:Y.to.entity,sourceHandle:te,targetHandle:se,type:"relationship",data:{relationship:Y,dimmed:ne||le,memberCount:Math.max(Y.from.attributes.length,Y.to.attributes.length),onHoverEdge:G}}});d(Y=>{const te=new Map(Y.map(Z=>[Z.id,Z.position])),se=Q.every(Z=>te.has(Z.id));if(y.current&&se&&Y.length>=Q.length)return Q.map(Z=>({...Z,position:te.get(Z.id)??Z.position}));const le=ri(Q,ee,k).map(Z=>te.has(Z.id)&&y.current?{...Z,position:te.get(Z.id)}:Z);return y.current=!0,requestAnimationFrame(()=>c({padding:.15,duration:300})),le}),f(ee)},[e,i,r,o,p,k,E,S,z,c]);const T=b.useCallback(()=>{d(R=>ri(R,m,k)),requestAnimationFrame(()=>c({padding:.15,duration:300}))},[m,k,c]),D=b.useCallback(R=>{s(R),d(H=>(H.find(X=>X.id===R)&&requestAnimationFrame(()=>c({nodes:[{id:R}],padding:.4,duration:400})),H))},[c,s]);b.useImperativeHandle(l,()=>({relayout:T,fitView:()=>c({padding:.15,duration:300}),focusEntity:D,newEntity:()=>w(!0)}),[T,c,D]);const N=b.useCallback(R=>{if(V||!R.source||!R.target||R.source===R.target)return;const H=R.sourceHandle&&R.sourceHandle!==Rr?R.sourceHandle:void 0,B=R.targetHandle&&R.targetHandle!==Or?R.targetHandle:void 0;C({from:R.source,to:R.target,fromAttr:H,toAttr:B})},[V]),I=b.useCallback(async(R,H)=>{try{return await n(R,H)}catch(B){throw a==null||a(B instanceof Error?B.message:String(B)),B}},[n,a]),L=r?k.get(r)??null:null,P=e.relationships.find(R=>R.id===A)??null;return h.jsxs(h.Fragment,{children:[h.jsxs(Ao,{nodes:u,edges:m,nodeTypes:Gy,edgeTypes:Yy,onNodeClick:(R,H)=>s(H.id),onEdgeClick:(R,H)=>!V&&F(H.id),onPaneClick:()=>{s(null),F(null)},onNodeDragStop:(R,H)=>d(B=>B.map(X=>X.id===H.id?{...X,position:H.position}:X)),onConnect:N,nodesConnectable:!V,minZoom:.05,onlyRenderVisibleElements:!0,proOptions:{hideAttribution:!0},fitView:!0,children:[h.jsx(cm,{variant:be.Dots,gap:22,size:1.5,color:"#33291f"}),h.jsx(Zh,{pannable:!0,zoomable:!0,nodeColor:R=>{var H;return((H=R.data)==null?void 0:H.color)??"#5a4f42"},maskColor:"rgba(20, 17, 15, 0.75)"}),h.jsx(rm,{showInteractive:!1})]}),L&&h.jsx(_m,{entity:L,doc:e,caps:t,exec:I,onClose:()=>s(null),onFocusEntity:D,onAlign:_,onEditMapping:v}),x&&h.jsx(Py,{entity:x,exec:I,onClose:()=>_(null)}),g&&h.jsx(zy,{entity:g,doc:e,exec:I,onClose:()=>v(null)}),j&&h.jsx(Hy,{doc:e,exec:I,onClose:()=>w(!1),onCreated:D}),M&&h.jsx(Fy,{doc:e,fromId:M.from,toId:M.to,initialFromAttr:M.fromAttr,initialToAttr:M.toAttr,exec:I,onClose:()=>C(null)}),P&&h.jsx(Vy,{rel:P,doc:e,exec:I,onClose:()=>F(null)})]})}function Ex({tab:e,onClose:t,readOnly:n,refreshKey:r,onModelChanged:s,onFocusEntity:i}){return h.jsxs("aside",{className:"side-panel",children:[h.jsxs("div",{className:"detail-header",children:[h.jsxs("h2",{children:[e==="ontology"&&"Ontology",e==="layers"&&"Ontology layers",e==="changes"&&"Uncommitted changes",e==="decisions"&&"Decision ledger"]}),h.jsx("button",{className:"icon-btn",onClick:t,children:"✕"})]}),e==="ontology"&&h.jsx(Uy,{}),e==="layers"&&h.jsx(qy,{refreshKey:r,onFocusEntity:i}),e==="changes"&&h.jsx(Zy,{readOnly:n,refreshKey:r,onModelChanged:s}),e==="decisions"&&h.jsx(Ky,{readOnly:n})]})}function Uy(){const[e,t]=b.useState(""),[n,r]=b.useState([]),[s,i]=b.useState({loaded:0,vocabs:[]}),[o,a]=b.useState(null),[l,c]=b.useState([]),[u,d]=b.useState("");b.useEffect(()=>{zo().then(f=>c(f.ontologies)).catch(()=>{})},[]),b.useEffect(()=>{const f=setTimeout(()=>{Po(e||"a",u||void 0).then(y=>{r(e?y.results:[]),i({loaded:y.loaded_terms,vocabs:y.vocabularies})}).catch(()=>{})},200);return()=>clearTimeout(f)},[e,u]);const m=b.useCallback(f=>{um(f).then(a).catch(()=>{})},[]);return o?h.jsxs("div",{className:"panel-body",children:[h.jsx("button",{className:"mini-btn",onClick:()=>a(null),children:"← back"}),h.jsx("h3",{style:{marginTop:12},children:o.label}),h.jsx("code",{className:"term-iri",children:o.prefixed}),o.definition&&h.jsx("p",{className:"term-def",children:o.definition}),h.jsxs("div",{className:"kv",children:[h.jsx("span",{className:"k",children:"source"}),h.jsx("span",{className:"v",children:o.source})]}),o.broader.length>0&&h.jsxs(h.Fragment,{children:[h.jsx("h4",{children:"broader"}),o.broader.map(f=>h.jsxs("button",{className:"rel-link",onClick:()=>m(f.iri),children:["↑ ",f.label]},f.iri))]}),o.narrower.length>0&&h.jsxs(h.Fragment,{children:[h.jsx("h4",{children:"narrower"}),o.narrower.map(f=>h.jsxs("button",{className:"rel-link",onClick:()=>m(f.iri),children:["↓ ",f.label]},f.iri))]})]}):h.jsxs("div",{className:"panel-body",children:[l.length>0&&h.jsxs("div",{className:"src-picker",children:[h.jsx("button",{className:"src-chip"+(u===""?" active":""),onClick:()=>d(""),children:"all sources"}),l.map(f=>h.jsxs("button",{className:"src-chip"+(u===f.id?" active":""),title:(f.description??"")+(f.count!=null?` · ${f.count} terms`:" · live"),onClick:()=>d(f.id),children:[f.name,f.layer&&h.jsx("span",{className:`src-layer layer-${f.layer}`,children:f.layer})]},f.id))]}),h.jsx("input",{className:"edit-input",placeholder:u?`Search within ${u}…`:"Search vocabulary terms…",value:e,onChange:f=>t(f.target.value)}),h.jsx("p",{className:"meta-line",children:l.length>0?`${l.length} source${l.length>1?"s":""}: ${s.vocabs.join(", ")}`+(s.loaded>0?` · ${s.loaded} local terms indexed`:""):"no vocabulary loaded — declare ontology_stack in mdl-project.yaml or run `mdl ontology vendor fibo`"}),h.jsx("div",{className:"term-results",children:n.map(f=>h.jsxs("button",{className:"term-card",onClick:()=>m(f.prefixed),children:[h.jsxs("div",{className:"term-head",children:[h.jsx("span",{className:"term-label",children:f.label}),h.jsxs("span",{className:"term-source",children:[f.source_kind==="glossary-term"&&h.jsx("span",{className:"kind-badge",title:"glossary term",children:"glossary"}),f.source]})]}),h.jsx("code",{className:"term-iri",children:f.prefixed}),f.definition&&h.jsx("p",{className:"term-def",children:f.definition})]},f.iri))})]})}const Xy=["industry","core","domain","specialised"];function qy({refreshKey:e,onFocusEntity:t}){const[n,r]=b.useState(null),[s,i]=b.useState(null);if(b.useEffect(()=>{dm().then(r).catch(()=>{}),fm().then(i).catch(()=>{})},[e]),!n)return h.jsx("div",{className:"panel-body",children:"loading…"});const o=new Set((s==null?void 0:s.core_uncovered)??[]);return h.jsxs("div",{className:"panel-body",children:[s&&h.jsxs("div",{className:"coverage-banner"+(s.coverage_pct<100?" warn":""),children:["industry alignment coverage: ",h.jsxs("b",{children:[s.coverage_pct,"%"]})," (",s.core_with_industry,"+",s.core_exempt,"/",s.total_core," core terms)"]}),h.jsxs("div",{className:"layer-band external",children:[h.jsx("h4",{children:"industry (external vocabularies)"}),n.external_terms.length===0&&h.jsx("p",{className:"empty-hint",children:"no aligned terms yet"}),n.external_terms.map(a=>h.jsxs("div",{className:"stack-term external",title:a.definition??void 0,children:[a.label,h.jsx("span",{className:"term-source",children:a.source})]},a.iri))]}),Xy.slice(1).map(a=>h.jsxs("div",{className:"layer-band",children:[h.jsx("h4",{children:a}),(n.layers[a]??[]).length===0&&h.jsx("p",{className:"empty-hint",children:"—"}),(n.layers[a]??[]).map(l=>{var c;return h.jsxs("button",{className:"stack-term"+(o.has(l.name)?" uncovered":""),title:l.definition??void 0,onClick:()=>t(l.id),children:[l.name,(l.aligned_refs??(l.aligned_to?[l.aligned_to]:[])).map((u,d)=>h.jsxs("span",{className:"align-arrow"+(u.resolved?"":" unresolved")+(u.status==="proposed"?" proposed":""),title:u.ref+(u.resolved_via?` (via ${u.resolved_via})`:""),children:["↑ ",u.label,u.status==="proposed"?" ·prop":""]},`${u.ref}-${d}`)),!l.aligned_to&&(((c=l.aligned_refs)==null?void 0:c.length)??0)===0&&!l.no_industry_equivalent&&h.jsx("span",{className:"align-arrow missing",children:"unaligned"})]},l.id)})]},a))]})}function Zy({readOnly:e,refreshKey:t,onModelChanged:n}){const[r,s]=b.useState(null),[i,o]=b.useState(""),[a,l]=b.useState(""),[c,u]=b.useState(!1),d=b.useCallback(()=>{hm().then(s).catch(()=>s(null)),mm().then(m=>o([m.diff,...m.untracked].filter(Boolean).join(` + */var En=b,il=sl;function ol(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var al=typeof Object.is=="function"?Object.is:ol,ll=il.useSyncExternalStore,cl=En.useRef,ul=En.useEffect,dl=En.useMemo,fl=En.useDebugValue;ci.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var i=cl(null);if(i.current===null){var o={hasValue:!1,value:null};i.current=o}else o=i.current;i=dl(function(){function l(f){if(!c){if(c=!0,u=f,f=r(f),s!==void 0&&o.hasValue){var y=o.value;if(s(y,f))return d=y}return d=f}if(y=d,al(u,f))return y;var x=r(f);return s!==void 0&&s(y,x)?(u=f,y):(u=f,d=x)}var c=!1,u,d,m=n===void 0?null:n;return[function(){return l(t())},m===null?void 0:function(){return l(m())}]},[t,n,r,s]);var a=ll(e,i[0],i[1]);return ul(function(){o.hasValue=!0,o.value=a},[a]),fl(a),a};li.exports=ci;var hl=li.exports;const ml=ai(hl),pl={},Gr=e=>{let t;const n=new Set,r=(u,d)=>{const m=typeof u=="function"?u(t):u;if(!Object.is(m,t)){const f=t;t=d??(typeof m!="object"||m===null)?m:Object.assign({},t,m),n.forEach(y=>y(t,f))}},s=()=>t,l={setState:r,getState:s,getInitialState:()=>c,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(pl?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},c=t=e(r,s,l);return l},gl=e=>e?Gr(e):Gr,{useDebugValue:yl}=$,{useSyncExternalStoreWithSelector:xl}=ml,wl=e=>e;function fi(e,t=wl,n){const r=xl(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return yl(r),r}const Yr=(e,t)=>{const n=gl(e),r=(s,i=t)=>fi(n,s,i);return Object.assign(r,n),r},bl=(e,t)=>e?Yr(e,t):Yr;function fe(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,s]of e)if(!Object.is(s,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var vl={value:()=>{}};function Nn(){for(var e=0,t=arguments.length,n={},r;e=0&&(r=n.slice(s+1),n=n.slice(0,s)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}an.prototype=Nn.prototype={constructor:an,on:function(e,t){var n=this._,r=_l(e+"",n),s,i=-1,o=r.length;if(arguments.length<2){for(;++i0)for(var n=new Array(s),r=0,s,i;r=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Ur.hasOwnProperty(t)?{space:Ur[t],local:e}:e}function Nl(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===er&&t.documentElement.namespaceURI===er?t.createElement(e):t.createElementNS(n,e)}}function Sl(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function hi(e){var t=Sn(e);return(t.local?Sl:Nl)(t)}function kl(){}function yr(e){return e==null?kl:function(){return this.querySelector(e)}}function jl(e){typeof e!="function"&&(e=yr(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s=j&&(j=v+1);!(M=_[j])&&++j=0;)(o=r[s])&&(i&&o.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(o,i),i=o);return this}function Ql(e){e||(e=Jl);function t(d,m){return d&&m?e(d.__data__,m.__data__):!d-!m}for(var n=this._groups,r=n.length,s=new Array(r),i=0;it?1:e>=t?0:NaN}function ec(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function tc(){return Array.from(this)}function nc(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?hc:typeof t=="function"?pc:mc)(e,t,n??"")):vt(this.node(),e)}function vt(e,t){return e.style.getPropertyValue(t)||xi(e).getComputedStyle(e,null).getPropertyValue(t)}function yc(e){return function(){delete this[e]}}function xc(e,t){return function(){this[e]=t}}function wc(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function bc(e,t){return arguments.length>1?this.each((t==null?yc:typeof t=="function"?wc:xc)(e,t)):this.node()[e]}function wi(e){return e.trim().split(/^|\s+/)}function xr(e){return e.classList||new bi(e)}function bi(e){this._node=e,this._names=wi(e.getAttribute("class")||"")}bi.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function vi(e,t){for(var n=xr(e),r=-1,s=t.length;++r=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function Xc(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,s=t.length,i;n()=>e;function tr(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:i,x:o,y:a,dx:l,dy:c,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:u}})}tr.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function su(e){return!e.ctrlKey&&!e.button}function iu(){return this.parentNode}function ou(e,t){return t??{x:e.x,y:e.y}}function au(){return navigator.maxTouchPoints||"ontouchstart"in this}function lu(){var e=su,t=iu,n=ou,r=au,s={},i=Nn("start","drag","end"),o=0,a,l,c,u,d=0;function m(w){w.on("mousedown.drag",f).filter(r).on("touchstart.drag",_).on("touchmove.drag",g,ru).on("touchend.drag touchcancel.drag",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function f(w,M){if(!(u||!e.call(this,w,M))){var C=j(this,t.call(this,w,M),w,M,"mouse");C&&(xe(w.view).on("mousemove.drag",y,Pt).on("mouseup.drag",x,Pt),Si(w.view),Pn(w),c=!1,a=w.clientX,l=w.clientY,C("start",w))}}function y(w){if(yt(w),!c){var M=w.clientX-a,C=w.clientY-l;c=M*M+C*C>d}s.mouse("drag",w)}function x(w){xe(w.view).on("mousemove.drag mouseup.drag",null),ki(w.view,c),yt(w),s.mouse("end",w)}function _(w,M){if(e.call(this,w,M)){var C=w.changedTouches,A=t.call(this,w,M),F=C.length,S,O;for(S=0;S>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Kt(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Kt(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=uu.exec(e))?new ge(t[1],t[2],t[3],1):(t=du.exec(e))?new ge(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=fu.exec(e))?Kt(t[1],t[2],t[3],t[4]):(t=hu.exec(e))?Kt(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=mu.exec(e))?es(t[1],t[2]/100,t[3]/100,1):(t=pu.exec(e))?es(t[1],t[2]/100,t[3]/100,t[4]):Xr.hasOwnProperty(e)?Kr(Xr[e]):e==="transparent"?new ge(NaN,NaN,NaN,0):null}function Kr(e){return new ge(e>>16&255,e>>8&255,e&255,1)}function Kt(e,t,n,r){return r<=0&&(e=t=n=NaN),new ge(e,t,n,r)}function xu(e){return e instanceof Ut||(e=Ft(e)),e?(e=e.rgb(),new ge(e.r,e.g,e.b,e.opacity)):new ge}function nr(e,t,n,r){return arguments.length===1?xu(e):new ge(e,t,n,r??1)}function ge(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}wr(ge,nr,ji(Ut,{brighter(e){return e=e==null?fn:Math.pow(fn,e),new ge(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?zt:Math.pow(zt,e),new ge(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ge(nt(this.r),nt(this.g),nt(this.b),hn(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Qr,formatHex:Qr,formatHex8:wu,formatRgb:Jr,toString:Jr}));function Qr(){return`#${et(this.r)}${et(this.g)}${et(this.b)}`}function wu(){return`#${et(this.r)}${et(this.g)}${et(this.b)}${et((isNaN(this.opacity)?1:this.opacity)*255)}`}function Jr(){const e=hn(this.opacity);return`${e===1?"rgb(":"rgba("}${nt(this.r)}, ${nt(this.g)}, ${nt(this.b)}${e===1?")":`, ${e})`}`}function hn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function nt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function et(e){return e=nt(e),(e<16?"0":"")+e.toString(16)}function es(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Ne(e,t,n,r)}function Ci(e){if(e instanceof Ne)return new Ne(e.h,e.s,e.l,e.opacity);if(e instanceof Ut||(e=Ft(e)),!e)return new Ne;if(e instanceof Ne)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,s=Math.min(t,n,r),i=Math.max(t,n,r),o=NaN,a=i-s,l=(i+s)/2;return a?(t===i?o=(n-r)/a+(n0&&l<1?0:o,new Ne(o,a,l,e.opacity)}function bu(e,t,n,r){return arguments.length===1?Ci(e):new Ne(e,t,n,r??1)}function Ne(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}wr(Ne,bu,ji(Ut,{brighter(e){return e=e==null?fn:Math.pow(fn,e),new Ne(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?zt:Math.pow(zt,e),new Ne(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,s=2*n-r;return new ge(zn(e>=240?e-240:e+120,s,r),zn(e,s,r),zn(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new Ne(ts(this.h),Qt(this.s),Qt(this.l),hn(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=hn(this.opacity);return`${e===1?"hsl(":"hsla("}${ts(this.h)}, ${Qt(this.s)*100}%, ${Qt(this.l)*100}%${e===1?")":`, ${e})`}`}}));function ts(e){return e=(e||0)%360,e<0?e+360:e}function Qt(e){return Math.max(0,Math.min(1,e||0))}function zn(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const $i=e=>()=>e;function vu(e,t){return function(n){return e+n*t}}function _u(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function Eu(e){return(e=+e)==1?Mi:function(t,n){return n-t?_u(t,n,e):$i(isNaN(t)?n:t)}}function Mi(e,t){var n=t-e;return n?vu(e,n):$i(isNaN(e)?t:e)}const ns=function e(t){var n=Eu(t);function r(s,i){var o=n((s=nr(s)).r,(i=nr(i)).r),a=n(s.g,i.g),l=n(s.b,i.b),c=Mi(s.opacity,i.opacity);return function(u){return s.r=o(u),s.g=a(u),s.b=l(u),s.opacity=c(u),s+""}}return r.gamma=e,r}(1);function He(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var rr=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Hn=new RegExp(rr.source,"g");function Nu(e){return function(){return e}}function Su(e){return function(t){return e(t)+""}}function ku(e,t){var n=rr.lastIndex=Hn.lastIndex=0,r,s,i,o=-1,a=[],l=[];for(e=e+"",t=t+"";(r=rr.exec(e))&&(s=Hn.exec(t));)(i=s.index)>n&&(i=t.slice(n,i),a[o]?a[o]+=i:a[++o]=i),(r=r[0])===(s=s[0])?a[o]?a[o]+=s:a[++o]=s:(a[++o]=null,l.push({i:o,x:He(r,s)})),n=Hn.lastIndex;return n180?u+=360:u-c>180&&(c+=360),m.push({i:d.push(s(d)+"rotate(",null,r)-2,x:He(c,u)})):u&&d.push(s(d)+"rotate("+u+r)}function a(c,u,d,m){c!==u?m.push({i:d.push(s(d)+"skewX(",null,r)-2,x:He(c,u)}):u&&d.push(s(d)+"skewX("+u+r)}function l(c,u,d,m,f,y){if(c!==d||u!==m){var x=f.push(s(f)+"scale(",null,",",null,")");y.push({i:x-4,x:He(c,d)},{i:x-2,x:He(u,m)})}else(d!==1||m!==1)&&f.push(s(f)+"scale("+d+","+m+")")}return function(c,u){var d=[],m=[];return c=e(c),u=e(u),i(c.translateX,c.translateY,u.translateX,u.translateY,d,m),o(c.rotate,u.rotate,d,m),a(c.skewX,u.skewX,d,m),l(c.scaleX,c.scaleY,u.scaleX,u.scaleY,d,m),c=u=null,function(f){for(var y=-1,x=m.length,_;++y=0&&e._call.call(void 0,t),e=e._next;--_t}function is(){st=(pn=Vt.now())+kn,_t=Tt=0;try{Du()}finally{_t=0,Pu(),st=0}}function Lu(){var e=Vt.now(),t=e-pn;t>Ti&&(kn-=t,pn=e)}function Pu(){for(var e,t=mn,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:mn=n);Rt=e,ir(r)}function ir(e){if(!_t){Tt&&(Tt=clearTimeout(Tt));var t=e-st;t>24?(e<1/0&&(Tt=setTimeout(is,e-Vt.now()-kn)),Ct&&(Ct=clearInterval(Ct))):(Ct||(pn=Vt.now(),Ct=setInterval(Lu,Ti)),_t=1,Ri(is))}}function os(e,t,n){var r=new gn;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var zu=Nn("start","end","cancel","interrupt"),Hu=[],Di=0,as=1,or=2,ln=3,ls=4,ar=5,cn=6;function jn(e,t,n,r,s,i){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;Fu(e,n,{name:t,index:r,group:s,on:zu,tween:Hu,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Di})}function vr(e,t){var n=Se(e,t);if(n.state>Di)throw new Error("too late; already scheduled");return n}function $e(e,t){var n=Se(e,t);if(n.state>ln)throw new Error("too late; already running");return n}function Se(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Fu(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=Oi(i,0,n.time);function i(c){n.state=as,n.timer.restart(o,n.delay,n.time),n.delay<=c&&o(c-n.delay)}function o(c){var u,d,m,f;if(n.state!==as)return l();for(u in r)if(f=r[u],f.name===n.name){if(f.state===ln)return os(o);f.state===ls?(f.state=cn,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete r[u]):+uor&&r.state=0&&(t=t.slice(0,n)),!t||t==="start"})}function yd(e,t,n){var r,s,i=gd(t)?vr:$e;return function(){var o=i(this,e),a=o.on;a!==r&&(s=(r=a).copy()).on(t,n),o.on=s}}function xd(e,t){var n=this._id;return arguments.length<2?Se(this.node(),n).on.on(e):this.each(yd(n,e,t))}function wd(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function bd(){return this.on("end.remove",wd(this._id))}function vd(e){var t=this._name,n=this._id;typeof e!="function"&&(e=yr(e));for(var r=this._groups,s=r.length,i=new Array(s),o=0;o()=>e;function Wd(e,{sourceEvent:t,target:n,transform:r,dispatch:s}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:s}})}function Oe(e,t,n){this.k=e,this.x=t,this.y=n}Oe.prototype={constructor:Oe,scale:function(e){return e===1?this:new Oe(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Oe(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var De=new Oe(1,0,0);Oe.prototype;function Fn(e){e.stopImmediatePropagation()}function $t(e){e.preventDefault(),e.stopImmediatePropagation()}function Ud(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Xd(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function cs(){return this.__zoom||De}function qd(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Zd(){return navigator.maxTouchPoints||"ontouchstart"in this}function Kd(e,t,n){var r=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(s>r?(r+s)/2:Math.min(0,r)||Math.max(0,s),o>i?(i+o)/2:Math.min(0,i)||Math.max(0,o))}function Hi(){var e=Ud,t=Xd,n=Kd,r=qd,s=Zd,i=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],a=250,l=Ru,c=Nn("start","zoom","end"),u,d,m,f=500,y=150,x=0,_=10;function g(p){p.property("__zoom",cs).on("wheel.zoom",F,{passive:!1}).on("mousedown.zoom",S).on("dblclick.zoom",O).filter(s).on("touchstart.zoom",z).on("touchmove.zoom",G).on("touchend.zoom touchcancel.zoom",V).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}g.transform=function(p,k,E,T){var D=p.selection?p.selection():p;D.property("__zoom",cs),p!==D?M(p,k,E,T):D.interrupt().each(function(){C(this,arguments).event(T).start().zoom(null,typeof k=="function"?k.apply(this,arguments):k).end()})},g.scaleBy=function(p,k,E,T){g.scaleTo(p,function(){var D=this.__zoom.k,N=typeof k=="function"?k.apply(this,arguments):k;return D*N},E,T)},g.scaleTo=function(p,k,E,T){g.transform(p,function(){var D=t.apply(this,arguments),N=this.__zoom,I=E==null?w(D):typeof E=="function"?E.apply(this,arguments):E,L=N.invert(I),P=typeof k=="function"?k.apply(this,arguments):k;return n(j(v(N,P),I,L),D,o)},E,T)},g.translateBy=function(p,k,E,T){g.transform(p,function(){return n(this.__zoom.translate(typeof k=="function"?k.apply(this,arguments):k,typeof E=="function"?E.apply(this,arguments):E),t.apply(this,arguments),o)},null,T)},g.translateTo=function(p,k,E,T,D){g.transform(p,function(){var N=t.apply(this,arguments),I=this.__zoom,L=T==null?w(N):typeof T=="function"?T.apply(this,arguments):T;return n(De.translate(L[0],L[1]).scale(I.k).translate(typeof k=="function"?-k.apply(this,arguments):-k,typeof E=="function"?-E.apply(this,arguments):-E),N,o)},T,D)};function v(p,k){return k=Math.max(i[0],Math.min(i[1],k)),k===p.k?p:new Oe(k,p.x,p.y)}function j(p,k,E){var T=k[0]-E[0]*p.k,D=k[1]-E[1]*p.k;return T===p.x&&D===p.y?p:new Oe(p.k,T,D)}function w(p){return[(+p[0][0]+ +p[1][0])/2,(+p[0][1]+ +p[1][1])/2]}function M(p,k,E,T){p.on("start.zoom",function(){C(this,arguments).event(T).start()}).on("interrupt.zoom end.zoom",function(){C(this,arguments).event(T).end()}).tween("zoom",function(){var D=this,N=arguments,I=C(D,N).event(T),L=t.apply(D,N),P=E==null?w(L):typeof E=="function"?E.apply(D,N):E,R=Math.max(L[1][0]-L[0][0],L[1][1]-L[0][1]),H=D.__zoom,B=typeof k=="function"?k.apply(D,N):k,X=l(H.invert(P).concat(R/H.k),B.invert(P).concat(R/B.k));return function(q){if(q===1)q=B;else{var J=X(q),Q=R/J[2];q=new Oe(Q,P[0]-J[0]*Q,P[1]-J[1]*Q)}I.zoom(null,q)}})}function C(p,k,E){return!E&&p.__zooming||new A(p,k)}function A(p,k){this.that=p,this.args=k,this.active=0,this.sourceEvent=null,this.extent=t.apply(p,k),this.taps=0}A.prototype={event:function(p){return p&&(this.sourceEvent=p),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(p,k){return this.mouse&&p!=="mouse"&&(this.mouse[1]=k.invert(this.mouse[0])),this.touch0&&p!=="touch"&&(this.touch0[1]=k.invert(this.touch0[0])),this.touch1&&p!=="touch"&&(this.touch1[1]=k.invert(this.touch1[0])),this.that.__zoom=k,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(p){var k=xe(this.that).datum();c.call(p,this.that,new Wd(p,{sourceEvent:this.sourceEvent,target:g,transform:this.that.__zoom,dispatch:c}),k)}};function F(p,...k){if(!e.apply(this,arguments))return;var E=C(this,k).event(p),T=this.__zoom,D=Math.max(i[0],Math.min(i[1],T.k*Math.pow(2,r.apply(this,arguments)))),N=Ee(p);if(E.wheel)(E.mouse[0][0]!==N[0]||E.mouse[0][1]!==N[1])&&(E.mouse[1]=T.invert(E.mouse[0]=N)),clearTimeout(E.wheel);else{if(T.k===D)return;E.mouse=[N,T.invert(N)],un(this),E.start()}$t(p),E.wheel=setTimeout(I,y),E.zoom("mouse",n(j(v(T,D),E.mouse[0],E.mouse[1]),E.extent,o));function I(){E.wheel=null,E.end()}}function S(p,...k){if(m||!e.apply(this,arguments))return;var E=p.currentTarget,T=C(this,k,!0).event(p),D=xe(p.view).on("mousemove.zoom",P,!0).on("mouseup.zoom",R,!0),N=Ee(p,E),I=p.clientX,L=p.clientY;Si(p.view),Fn(p),T.mouse=[N,this.__zoom.invert(N)],un(this),T.start();function P(H){if($t(H),!T.moved){var B=H.clientX-I,X=H.clientY-L;T.moved=B*B+X*X>x}T.event(H).zoom("mouse",n(j(T.that.__zoom,T.mouse[0]=Ee(H,E),T.mouse[1]),T.extent,o))}function R(H){D.on("mousemove.zoom mouseup.zoom",null),ki(H.view,T.moved),$t(H),T.event(H).end()}}function O(p,...k){if(e.apply(this,arguments)){var E=this.__zoom,T=Ee(p.changedTouches?p.changedTouches[0]:p,this),D=E.invert(T),N=E.k*(p.shiftKey?.5:2),I=n(j(v(E,N),T,D),t.apply(this,k),o);$t(p),a>0?xe(this).transition().duration(a).call(M,I,T,p):xe(this).call(g.transform,I,T,p)}}function z(p,...k){if(e.apply(this,arguments)){var E=p.touches,T=E.length,D=C(this,k,p.changedTouches.length===T).event(p),N,I,L,P;for(Fn(p),I=0;I"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,t)=>`Couldn't create edge for ${e?"target":"source"} handle id: "${e?t.targetHandle:t.sourceHandle}", edge id: ${t.id}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`},Fi=Pe.error001();function re(e,t){const n=b.useContext(Cn);if(n===null)throw new Error(Fi);return fi(n,e,t)}const de=()=>{const e=b.useContext(Cn);if(e===null)throw new Error(Fi);return b.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},Jd=e=>e.userSelectionActive?"none":"all";function Er({position:e,children:t,className:n,style:r,...s}){const i=re(Jd),o=`${e}`.split("-");return $.createElement("div",{className:he(["react-flow__panel",n,...o]),style:{...r,pointerEvents:i},...s},t)}function ef({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:$.createElement(Er,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},$.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const tf=({x:e,y:t,label:n,labelStyle:r={},labelShowBg:s=!0,labelBgStyle:i={},labelBgPadding:o=[2,4],labelBgBorderRadius:a=2,children:l,className:c,...u})=>{const d=b.useRef(null),[m,f]=b.useState({x:0,y:0,width:0,height:0}),y=he(["react-flow__edge-textwrapper",c]);return b.useEffect(()=>{if(d.current){const x=d.current.getBBox();f({x:x.x,y:x.y,width:x.width,height:x.height})}},[n]),typeof n>"u"||!n?null:$.createElement("g",{transform:`translate(${e-m.width/2} ${t-m.height/2})`,className:y,visibility:m.width?"visible":"hidden",...u},s&&$.createElement("rect",{width:m.width+2*o[0],x:-o[0],y:-o[1],height:m.height+2*o[1],className:"react-flow__edge-textbg",style:i,rx:a,ry:a}),$.createElement("text",{className:"react-flow__edge-text",y:m.height/2,dy:"0.3em",ref:d,style:r},n),l)};var nf=b.memo(tf);const Nr=e=>({width:e.offsetWidth,height:e.offsetHeight}),Et=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Sr=(e={x:0,y:0},t)=>({x:Et(e.x,t[0][0],t[1][0]),y:Et(e.y,t[0][1],t[1][1])}),us=(e,t,n)=>en?-Et(Math.abs(e-n),1,50)/50:0,Vi=(e,t)=>{const n=us(e.x,35,t.width-35)*20,r=us(e.y,35,t.height-35)*20;return[n,r]},Bi=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},Gi=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Bt=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Yi=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),ds=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),rf=(e,t)=>Yi(Gi(Bt(e),Bt(t))),lr=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},sf=e=>we(e.width)&&we(e.height)&&we(e.x)&&we(e.y),we=e=>!isNaN(e)&&isFinite(e),ie=Symbol.for("internals"),Wi=["Enter"," ","Escape"],of=(e,t)=>{},af=e=>"nativeEvent"in e;function cr(e){var s,i;const t=af(e)?e.nativeEvent:e,n=((i=(s=t.composedPath)==null?void 0:s.call(t))==null?void 0:i[0])||e.target;return["INPUT","SELECT","TEXTAREA"].includes(n==null?void 0:n.nodeName)||(n==null?void 0:n.hasAttribute("contenteditable"))||!!(n!=null&&n.closest(".nokey"))}const Ui=e=>"clientX"in e,Ge=(e,t)=>{var i,o;const n=Ui(e),r=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,s=n?e.clientY:(o=e.touches)==null?void 0:o[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:s-((t==null?void 0:t.top)??0)}},yn=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},Xt=({id:e,path:t,labelX:n,labelY:r,label:s,labelStyle:i,labelShowBg:o,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,style:u,markerEnd:d,markerStart:m,interactionWidth:f=20})=>$.createElement($.Fragment,null,$.createElement("path",{id:e,style:u,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:d,markerStart:m}),f&&$.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:f,className:"react-flow__edge-interaction"}),s&&we(n)&&we(r)?$.createElement(nf,{x:n,y:r,label:s,labelStyle:i,labelShowBg:o,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c}):null);Xt.displayName="BaseEdge";function Mt(e,t,n){return n===void 0?n:r=>{const s=t().edges.find(i=>i.id===e);s&&n(r,{...s})}}function Xi({sourceX:e,sourceY:t,targetX:n,targetY:r}){const s=Math.abs(n-e)/2,i=n{const[_,g,v]=Zi({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:r,targetPosition:i});return $.createElement(Xt,{path:_,labelX:g,labelY:v,label:o,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:d,style:m,markerEnd:f,markerStart:y,interactionWidth:x})});kr.displayName="SimpleBezierEdge";const hs={[U.Left]:{x:-1,y:0},[U.Right]:{x:1,y:0},[U.Top]:{x:0,y:-1},[U.Bottom]:{x:0,y:1}},lf=({source:e,sourcePosition:t=U.Bottom,target:n})=>t===U.Left||t===U.Right?e.xMath.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function cf({source:e,sourcePosition:t=U.Bottom,target:n,targetPosition:r=U.Top,center:s,offset:i}){const o=hs[t],a=hs[r],l={x:e.x+o.x*i,y:e.y+o.y*i},c={x:n.x+a.x*i,y:n.y+a.y*i},u=lf({source:l,sourcePosition:t,target:c}),d=u.x!==0?"x":"y",m=u[d];let f=[],y,x;const _={x:0,y:0},g={x:0,y:0},[v,j,w,M]=Xi({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(o[d]*a[d]===-1){y=s.x??v,x=s.y??j;const A=[{x:y,y:l.y},{x:y,y:c.y}],F=[{x:l.x,y:x},{x:c.x,y:x}];o[d]===m?f=d==="x"?A:F:f=d==="x"?F:A}else{const A=[{x:l.x,y:c.y}],F=[{x:c.x,y:l.y}];if(d==="x"?f=o.x===m?F:A:f=o.y===m?A:F,t===r){const V=Math.abs(e[d]-n[d]);if(V<=i){const p=Math.min(i-1,i-V);o[d]===m?_[d]=(l[d]>e[d]?-1:1)*p:g[d]=(c[d]>n[d]?-1:1)*p}}if(t!==r){const V=d==="x"?"y":"x",p=o[d]===a[V],k=l[V]>c[V],E=l[V]=G?(y=(S.x+O.x)/2,x=f[0].y):(y=f[0].x,x=(S.y+O.y)/2)}return[[e,{x:l.x+_.x,y:l.y+_.y},...f,{x:c.x+g.x,y:c.y+g.y},n],y,x,w,M]}function uf(e,t,n,r){const s=Math.min(ms(e,t)/2,ms(t,n)/2,r),{x:i,y:o}=t;if(e.x===i&&i===n.x||e.y===o&&o===n.y)return`L${i} ${o}`;if(e.y===o){const c=e.x{let j="";return v>0&&v{const[g,v,j]=wn({sourceX:e,sourceY:t,sourcePosition:d,targetX:n,targetY:r,targetPosition:m,borderRadius:x==null?void 0:x.borderRadius,offset:x==null?void 0:x.offset});return $.createElement(Xt,{path:g,labelX:v,labelY:j,label:s,labelStyle:i,labelShowBg:o,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,style:u,markerEnd:f,markerStart:y,interactionWidth:_})});$n.displayName="SmoothStepEdge";const jr=b.memo(e=>{var t;return $.createElement($n,{...e,pathOptions:b.useMemo(()=>{var n;return{borderRadius:0,offset:(n=e.pathOptions)==null?void 0:n.offset}},[(t=e.pathOptions)==null?void 0:t.offset])})});jr.displayName="StepEdge";function df({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,i,o,a]=Xi({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,i,o,a]}const Cr=b.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:s,labelStyle:i,labelShowBg:o,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,style:u,markerEnd:d,markerStart:m,interactionWidth:f})=>{const[y,x,_]=df({sourceX:e,sourceY:t,targetX:n,targetY:r});return $.createElement(Xt,{path:y,labelX:x,labelY:_,label:s,labelStyle:i,labelShowBg:o,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,style:u,markerEnd:d,markerStart:m,interactionWidth:f})});Cr.displayName="StraightEdge";function tn(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function ps({pos:e,x1:t,y1:n,x2:r,y2:s,c:i}){switch(e){case U.Left:return[t-tn(t-r,i),n];case U.Right:return[t+tn(r-t,i),n];case U.Top:return[t,n-tn(n-s,i)];case U.Bottom:return[t,n+tn(s-n,i)]}}function Ki({sourceX:e,sourceY:t,sourcePosition:n=U.Bottom,targetX:r,targetY:s,targetPosition:i=U.Top,curvature:o=.25}){const[a,l]=ps({pos:n,x1:e,y1:t,x2:r,y2:s,c:o}),[c,u]=ps({pos:i,x1:r,y1:s,x2:e,y2:t,c:o}),[d,m,f,y]=qi({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:a,sourceControlY:l,targetControlX:c,targetControlY:u});return[`M${e},${t} C${a},${l} ${c},${u} ${r},${s}`,d,m,f,y]}const bn=b.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:s=U.Bottom,targetPosition:i=U.Top,label:o,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:d,style:m,markerEnd:f,markerStart:y,pathOptions:x,interactionWidth:_})=>{const[g,v,j]=Ki({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:r,targetPosition:i,curvature:x==null?void 0:x.curvature});return $.createElement(Xt,{path:g,labelX:v,labelY:j,label:o,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:d,style:m,markerEnd:f,markerStart:y,interactionWidth:_})});bn.displayName="BezierEdge";const $r=b.createContext(null),ff=$r.Provider;$r.Consumer;const hf=()=>b.useContext($r),mf=e=>"id"in e&&"source"in e&&"target"in e,pf=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`reactflow__edge-${e}${t||""}-${n}${r||""}`,ur=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`,gf=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),yf=(e,t)=>{if(!e.source||!e.target)return t;let n;return mf(e)?n={...e}:n={...e,id:pf(e)},gf(n,t)?t:t.concat(n)},dr=({x:e,y:t},[n,r,s],i,[o,a])=>{const l={x:(e-n)/s,y:(t-r)/s};return i?{x:o*Math.round(l.x/o),y:a*Math.round(l.y/a)}:l},Qi=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r}),rt=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(e.width??0)*t[0],r=(e.height??0)*t[1],s={x:e.position.x-n,y:e.position.y-r};return{...s,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-r}:s}},Mn=(e,t=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,s)=>{const{x:i,y:o}=rt(s,t).positionAbsolute;return Gi(r,Bt({x:i,y:o,width:s.width||0,height:s.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Yi(n)},Ji=(e,t,[n,r,s]=[0,0,1],i=!1,o=!1,a=[0,0])=>{const l={x:(t.x-n)/s,y:(t.y-r)/s,width:t.width/s,height:t.height/s},c=[];return e.forEach(u=>{const{width:d,height:m,selectable:f=!0,hidden:y=!1}=u;if(o&&!f||y)return!1;const{positionAbsolute:x}=rt(u,a),_={x:x.x,y:x.y,width:d||0,height:m||0},g=lr(l,_),v=typeof d>"u"||typeof m>"u"||d===null||m===null,j=i&&g>0,w=(d||0)*(m||0);(v||j||g>=w||u.dragging)&&c.push(u)}),c},eo=(e,t)=>{const n=e.map(r=>r.id);return t.filter(r=>n.includes(r.source)||n.includes(r.target))},to=(e,t,n,r,s,i=.1)=>{const o=t/(e.width*(1+i)),a=n/(e.height*(1+i)),l=Math.min(o,a),c=Et(l,r,s),u=e.x+e.width/2,d=e.y+e.height/2,m=t/2-u*c,f=n/2-d*c;return{x:m,y:f,zoom:c}},Je=(e,t=0)=>e.transition().duration(t);function gs(e,t,n,r){return(t[n]||[]).reduce((s,i)=>{var o,a;return`${e.id}-${i.id}-${n}`!==r&&s.push({id:i.id||null,type:n,nodeId:e.id,x:(((o=e.positionAbsolute)==null?void 0:o.x)??0)+i.x+i.width/2,y:(((a=e.positionAbsolute)==null?void 0:a.y)??0)+i.y+i.height/2}),s},[])}function xf(e,t,n,r,s,i){const{x:o,y:a}=Ge(e),c=t.elementsFromPoint(o,a).find(y=>y.classList.contains("react-flow__handle"));if(c){const y=c.getAttribute("data-nodeid");if(y){const x=Mr(void 0,c),_=c.getAttribute("data-handleid"),g=i({nodeId:y,id:_,type:x});if(g){const v=s.find(j=>j.nodeId===y&&j.type===x&&j.id===_);return{handle:{id:_,type:x,nodeId:y,x:(v==null?void 0:v.x)||n.x,y:(v==null?void 0:v.y)||n.y},validHandleResult:g}}}}let u=[],d=1/0;if(s.forEach(y=>{const x=Math.sqrt((y.x-n.x)**2+(y.y-n.y)**2);if(x<=r){const _=i(y);x<=d&&(xy.isValid),f=u.some(({handle:y})=>y.type==="target");return u.find(({handle:y,validHandleResult:x})=>f?y.type==="target":m?x.isValid:!0)||u[0]}const wf={source:null,target:null,sourceHandle:null,targetHandle:null},no=()=>({handleDomNode:null,isValid:!1,connection:wf,endHandle:null});function ro(e,t,n,r,s,i,o){const a=s==="target",l=o.querySelector(`.react-flow__handle[data-id="${e==null?void 0:e.nodeId}-${e==null?void 0:e.id}-${e==null?void 0:e.type}"]`),c={...no(),handleDomNode:l};if(l){const u=Mr(void 0,l),d=l.getAttribute("data-nodeid"),m=l.getAttribute("data-handleid"),f=l.classList.contains("connectable"),y=l.classList.contains("connectableend"),x={source:a?d:n,sourceHandle:a?m:r,target:a?n:d,targetHandle:a?r:m};c.connection=x,f&&y&&(t===it.Strict?a&&u==="source"||!a&&u==="target":d!==n||m!==r)&&(c.endHandle={nodeId:d,handleId:m,type:u},c.isValid=i(x))}return c}function bf({nodes:e,nodeId:t,handleId:n,handleType:r}){return e.reduce((s,i)=>{if(i[ie]){const{handleBounds:o}=i[ie];let a=[],l=[];o&&(a=gs(i,o,"source",`${t}-${n}-${r}`),l=gs(i,o,"target",`${t}-${n}-${r}`)),s.push(...a,...l)}return s},[])}function Mr(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function Vn(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function vf(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function so({event:e,handleId:t,nodeId:n,onConnect:r,isTarget:s,getState:i,setState:o,isValidConnection:a,edgeUpdaterType:l,onReconnectEnd:c}){const u=Bi(e.target),{connectionMode:d,domNode:m,autoPanOnConnect:f,connectionRadius:y,onConnectStart:x,panBy:_,getNodes:g,cancelConnection:v}=i();let j=0,w;const{x:M,y:C}=Ge(e),A=u==null?void 0:u.elementFromPoint(M,C),F=Mr(l,A),S=m==null?void 0:m.getBoundingClientRect();if(!S||!F)return;let O,z=Ge(e,S),G=!1,V=null,p=!1,k=null;const E=bf({nodes:g(),nodeId:n,handleId:t,handleType:F}),T=()=>{if(!f)return;const[I,L]=Vi(z,S);_({x:I,y:L}),j=requestAnimationFrame(T)};o({connectionPosition:z,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:F,connectionStartHandle:{nodeId:n,handleId:t,type:F},connectionEndHandle:null}),x==null||x(e,{nodeId:n,handleId:t,handleType:F});function D(I){const{transform:L}=i();z=Ge(I,S);const{handle:P,validHandleResult:R}=xf(I,u,dr(z,L,!1,[1,1]),y,E,H=>ro(H,d,n,t,s?"target":"source",a,u));if(w=P,G||(T(),G=!0),k=R.handleDomNode,V=R.connection,p=R.isValid,o({connectionPosition:w&&p?Qi({x:w.x,y:w.y},L):z,connectionStatus:vf(!!w,p),connectionEndHandle:R.endHandle}),!w&&!p&&!k)return Vn(O);V.source!==V.target&&k&&(Vn(O),O=k,k.classList.add("connecting","react-flow__handle-connecting"),k.classList.toggle("valid",p),k.classList.toggle("react-flow__handle-valid",p))}function N(I){var L,P;(w||k)&&V&&p&&(r==null||r(V)),(P=(L=i()).onConnectEnd)==null||P.call(L,I),l&&(c==null||c(I)),Vn(O),v(),cancelAnimationFrame(j),G=!1,p=!1,V=null,k=null,u.removeEventListener("mousemove",D),u.removeEventListener("mouseup",N),u.removeEventListener("touchmove",D),u.removeEventListener("touchend",N)}u.addEventListener("mousemove",D),u.addEventListener("mouseup",N),u.addEventListener("touchmove",D),u.addEventListener("touchend",N)}const ys=()=>!0,_f=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),Ef=(e,t,n)=>r=>{const{connectionStartHandle:s,connectionEndHandle:i,connectionClickStartHandle:o}=r;return{connecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.handleId)===t&&(s==null?void 0:s.type)===n||(i==null?void 0:i.nodeId)===e&&(i==null?void 0:i.handleId)===t&&(i==null?void 0:i.type)===n,clickConnecting:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.handleId)===t&&(o==null?void 0:o.type)===n}},io=b.forwardRef(({type:e="source",position:t=U.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:i=!0,id:o,onConnect:a,children:l,className:c,onMouseDown:u,onTouchStart:d,...m},f)=>{var S,O;const y=o||null,x=e==="target",_=de(),g=hf(),{connectOnClick:v,noPanClassName:j}=re(_f,fe),{connecting:w,clickConnecting:M}=re(Ef(g,y,e),fe);g||(O=(S=_.getState()).onError)==null||O.call(S,"010",Pe.error010());const C=z=>{const{defaultEdgeOptions:G,onConnect:V,hasDefaultEdges:p}=_.getState(),k={...G,...z};if(p){const{edges:E,setEdges:T}=_.getState();T(yf(k,E))}V==null||V(k),a==null||a(k)},A=z=>{if(!g)return;const G=Ui(z);s&&(G&&z.button===0||!G)&&so({event:z,handleId:y,nodeId:g,onConnect:C,isTarget:x,getState:_.getState,setState:_.setState,isValidConnection:n||_.getState().isValidConnection||ys}),G?u==null||u(z):d==null||d(z)},F=z=>{const{onClickConnectStart:G,onClickConnectEnd:V,connectionClickStartHandle:p,connectionMode:k,isValidConnection:E}=_.getState();if(!g||!p&&!s)return;if(!p){G==null||G(z,{nodeId:g,handleId:y,handleType:e}),_.setState({connectionClickStartHandle:{nodeId:g,type:e,handleId:y}});return}const T=Bi(z.target),D=n||E||ys,{connection:N,isValid:I}=ro({nodeId:g,id:y,type:e},k,p.nodeId,p.handleId||null,p.type,D,T);I&&C(N),V==null||V(z),_.setState({connectionClickStartHandle:null})};return $.createElement("div",{"data-handleid":y,"data-nodeid":g,"data-handlepos":t,"data-id":`${g}-${y}-${e}`,className:he(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",j,c,{source:!x,target:x,connectable:r,connectablestart:s,connectableend:i,connecting:M,connectionindicator:r&&(s&&!w||i&&w)}]),onMouseDown:A,onTouchStart:A,onClick:v?F:void 0,ref:f,...m},l)});io.displayName="Handle";var Be=b.memo(io);const oo=({data:e,isConnectable:t,targetPosition:n=U.Top,sourcePosition:r=U.Bottom})=>$.createElement($.Fragment,null,$.createElement(Be,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,$.createElement(Be,{type:"source",position:r,isConnectable:t}));oo.displayName="DefaultNode";var fr=b.memo(oo);const ao=({data:e,isConnectable:t,sourcePosition:n=U.Bottom})=>$.createElement($.Fragment,null,e==null?void 0:e.label,$.createElement(Be,{type:"source",position:n,isConnectable:t}));ao.displayName="InputNode";var lo=b.memo(ao);const co=({data:e,isConnectable:t,targetPosition:n=U.Top})=>$.createElement($.Fragment,null,$.createElement(Be,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label);co.displayName="OutputNode";var uo=b.memo(co);const Ar=()=>null;Ar.displayName="GroupNode";const Nf=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected).map(t=>({...t}))}),nn=e=>e.id;function Sf(e,t){return fe(e.selectedNodes.map(nn),t.selectedNodes.map(nn))&&fe(e.selectedEdges.map(nn),t.selectedEdges.map(nn))}const fo=b.memo(({onSelectionChange:e})=>{const t=de(),{selectedNodes:n,selectedEdges:r}=re(Nf,Sf);return b.useEffect(()=>{const s={nodes:n,edges:r};e==null||e(s),t.getState().onSelectionChange.forEach(i=>i(s))},[n,r,e]),null});fo.displayName="SelectionListener";const kf=e=>!!e.onSelectionChange;function jf({onSelectionChange:e}){const t=re(kf);return e||t?$.createElement(fo,{onSelectionChange:e}):null}const Cf=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset});function ft(e,t){b.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function Z(e,t,n){b.useEffect(()=>{typeof t<"u"&&n({[e]:t})},[t])}const $f=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:s,onConnectStart:i,onConnectEnd:o,onClickConnectStart:a,onClickConnectEnd:l,nodesDraggable:c,nodesConnectable:u,nodesFocusable:d,edgesFocusable:m,edgesUpdatable:f,elevateNodesOnSelect:y,minZoom:x,maxZoom:_,nodeExtent:g,onNodesChange:v,onEdgesChange:j,elementsSelectable:w,connectionMode:M,snapGrid:C,snapToGrid:A,translateExtent:F,connectOnClick:S,defaultEdgeOptions:O,fitView:z,fitViewOptions:G,onNodesDelete:V,onEdgesDelete:p,onNodeDrag:k,onNodeDragStart:E,onNodeDragStop:T,onSelectionDrag:D,onSelectionDragStart:N,onSelectionDragStop:I,noPanClassName:L,nodeOrigin:P,rfId:R,autoPanOnConnect:H,autoPanOnNodeDrag:B,onError:X,connectionRadius:q,isValidConnection:J,nodeDragThreshold:Q})=>{const{setNodes:K,setEdges:ae,setDefaultNodesAndEdges:se,setMinZoom:Y,setMaxZoom:ne,setTranslateExtent:te,setNodeExtent:le,reset:ee}=re(Cf,fe),W=de();return b.useEffect(()=>{const pe=r==null?void 0:r.map(Me=>({...Me,...O}));return se(n,pe),()=>{ee()}},[]),Z("defaultEdgeOptions",O,W.setState),Z("connectionMode",M,W.setState),Z("onConnect",s,W.setState),Z("onConnectStart",i,W.setState),Z("onConnectEnd",o,W.setState),Z("onClickConnectStart",a,W.setState),Z("onClickConnectEnd",l,W.setState),Z("nodesDraggable",c,W.setState),Z("nodesConnectable",u,W.setState),Z("nodesFocusable",d,W.setState),Z("edgesFocusable",m,W.setState),Z("edgesUpdatable",f,W.setState),Z("elementsSelectable",w,W.setState),Z("elevateNodesOnSelect",y,W.setState),Z("snapToGrid",A,W.setState),Z("snapGrid",C,W.setState),Z("onNodesChange",v,W.setState),Z("onEdgesChange",j,W.setState),Z("connectOnClick",S,W.setState),Z("fitViewOnInit",z,W.setState),Z("fitViewOnInitOptions",G,W.setState),Z("onNodesDelete",V,W.setState),Z("onEdgesDelete",p,W.setState),Z("onNodeDrag",k,W.setState),Z("onNodeDragStart",E,W.setState),Z("onNodeDragStop",T,W.setState),Z("onSelectionDrag",D,W.setState),Z("onSelectionDragStart",N,W.setState),Z("onSelectionDragStop",I,W.setState),Z("noPanClassName",L,W.setState),Z("nodeOrigin",P,W.setState),Z("rfId",R,W.setState),Z("autoPanOnConnect",H,W.setState),Z("autoPanOnNodeDrag",B,W.setState),Z("onError",X,W.setState),Z("connectionRadius",q,W.setState),Z("isValidConnection",J,W.setState),Z("nodeDragThreshold",Q,W.setState),ft(e,K),ft(t,ae),ft(x,Y),ft(_,ne),ft(F,te),ft(g,le),null},xs={display:"none"},Mf={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},ho="react-flow__node-desc",mo="react-flow__edge-desc",Af="react-flow__aria-live",If=e=>e.ariaLiveMessage;function Tf({rfId:e}){const t=re(If);return $.createElement("div",{id:`${Af}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Mf},t)}function Rf({rfId:e,disableKeyboardA11y:t}){return $.createElement($.Fragment,null,$.createElement("div",{id:`${ho}-${e}`,style:xs},"Press enter or space to select a node.",!t&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),$.createElement("div",{id:`${mo}-${e}`,style:xs},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&$.createElement(Tf,{rfId:e}))}var Yt=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,r]=b.useState(!1),s=b.useRef(!1),i=b.useRef(new Set([])),[o,a]=b.useMemo(()=>{if(e!==null){const c=(Array.isArray(e)?e:[e]).filter(d=>typeof d=="string").map(d=>d.split("+")),u=c.reduce((d,m)=>d.concat(...m),[]);return[c,u]}return[[],[]]},[e]);return b.useEffect(()=>{const l=typeof document<"u"?document:null,c=(t==null?void 0:t.target)||l;if(e!==null){const u=f=>{if(s.current=f.ctrlKey||f.metaKey||f.shiftKey,(!s.current||s.current&&!t.actInsideInputWithModifier)&&cr(f))return!1;const x=bs(f.code,a);i.current.add(f[x]),ws(o,i.current,!1)&&(f.preventDefault(),r(!0))},d=f=>{if((!s.current||s.current&&!t.actInsideInputWithModifier)&&cr(f))return!1;const x=bs(f.code,a);ws(o,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(f[x]),f.key==="Meta"&&i.current.clear(),s.current=!1},m=()=>{i.current.clear(),r(!1)};return c==null||c.addEventListener("keydown",u),c==null||c.addEventListener("keyup",d),window.addEventListener("blur",m),()=>{c==null||c.removeEventListener("keydown",u),c==null||c.removeEventListener("keyup",d),window.removeEventListener("blur",m)}}},[e,r]),n};function ws(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function bs(e,t){return t.includes(e)?"code":"key"}function po(e,t,n,r){var a,l;const s=e.parentNode||e.parentId;if(!s)return n;const i=t.get(s),o=rt(i,r);return po(i,t,{x:(n.x??0)+o.x,y:(n.y??0)+o.y,z:(((a=i[ie])==null?void 0:a.z)??0)>(n.z??0)?((l=i[ie])==null?void 0:l.z)??0:n.z??0},r)}function go(e,t,n){e.forEach(r=>{var i;const s=r.parentNode||r.parentId;if(s&&!e.has(s))throw new Error(`Parent node ${s} not found`);if(s||n!=null&&n[r.id]){const{x:o,y:a,z:l}=po(r,e,{...r.position,z:((i=r[ie])==null?void 0:i.z)??0},t);r.positionAbsolute={x:o,y:a},r[ie].z=l,n!=null&&n[r.id]&&(r[ie].isParent=!0)}})}function Bn(e,t,n,r){const s=new Map,i={},o=r?1e3:0;return e.forEach(a=>{var f;const l=(we(a.zIndex)?a.zIndex:0)+(a.selected?o:0),c=t.get(a.id),u={...a,positionAbsolute:{x:a.position.x,y:a.position.y}},d=a.parentNode||a.parentId;d&&(i[d]=!0);const m=(c==null?void 0:c.type)&&(c==null?void 0:c.type)!==a.type;Object.defineProperty(u,ie,{enumerable:!1,value:{handleBounds:m||(f=c==null?void 0:c[ie])==null?void 0:f.handleBounds,z:l}}),s.set(a.id,u)}),go(s,n,i),s}function yo(e,t={}){const{getNodes:n,width:r,height:s,minZoom:i,maxZoom:o,d3Zoom:a,d3Selection:l,fitViewOnInitDone:c,fitViewOnInit:u,nodeOrigin:d}=e(),m=t.initial&&!c&&u;if(a&&l&&(m||!t.initial)){const y=n().filter(_=>{var v;const g=t.includeHiddenNodes?_.width&&_.height:!_.hidden;return(v=t.nodes)!=null&&v.length?g&&t.nodes.some(j=>j.id===_.id):g}),x=y.every(_=>_.width&&_.height);if(y.length>0&&x){const _=Mn(y,d),{x:g,y:v,zoom:j}=to(_,r,s,t.minZoom??i,t.maxZoom??o,t.padding??.1),w=De.translate(g,v).scale(j);return typeof t.duration=="number"&&t.duration>0?a.transform(Je(l,t.duration),w):a.transform(l,w),!0}}return!1}function Of(e,t){return e.forEach(n=>{const r=t.get(n.id);r&&t.set(r.id,{...r,[ie]:r[ie],selected:n.selected})}),new Map(t)}function Df(e,t){return t.map(n=>{const r=e.find(s=>s.id===n.id);return r&&(n.selected=r.selected),n})}function rn({changedNodes:e,changedEdges:t,get:n,set:r}){const{nodeInternals:s,edges:i,onNodesChange:o,onEdgesChange:a,hasDefaultNodes:l,hasDefaultEdges:c}=n();e!=null&&e.length&&(l&&r({nodeInternals:Of(e,s)}),o==null||o(e)),t!=null&&t.length&&(c&&r({edges:Df(t,i)}),a==null||a(t))}const ht=()=>{},Lf={zoomIn:ht,zoomOut:ht,zoomTo:ht,getZoom:()=>1,setViewport:ht,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:ht,fitBounds:ht,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},Pf=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),zf=()=>{const e=de(),{d3Zoom:t,d3Selection:n}=re(Pf,fe);return b.useMemo(()=>n&&t?{zoomIn:s=>t.scaleBy(Je(n,s==null?void 0:s.duration),1.2),zoomOut:s=>t.scaleBy(Je(n,s==null?void 0:s.duration),1/1.2),zoomTo:(s,i)=>t.scaleTo(Je(n,i==null?void 0:i.duration),s),getZoom:()=>e.getState().transform[2],setViewport:(s,i)=>{const[o,a,l]=e.getState().transform,c=De.translate(s.x??o,s.y??a).scale(s.zoom??l);t.transform(Je(n,i==null?void 0:i.duration),c)},getViewport:()=>{const[s,i,o]=e.getState().transform;return{x:s,y:i,zoom:o}},fitView:s=>yo(e.getState,s),setCenter:(s,i,o)=>{const{width:a,height:l,maxZoom:c}=e.getState(),u=typeof(o==null?void 0:o.zoom)<"u"?o.zoom:c,d=a/2-s*u,m=l/2-i*u,f=De.translate(d,m).scale(u);t.transform(Je(n,o==null?void 0:o.duration),f)},fitBounds:(s,i)=>{const{width:o,height:a,minZoom:l,maxZoom:c}=e.getState(),{x:u,y:d,zoom:m}=to(s,o,a,l,c,(i==null?void 0:i.padding)??.1),f=De.translate(u,d).scale(m);t.transform(Je(n,i==null?void 0:i.duration),f)},project:s=>{const{transform:i,snapToGrid:o,snapGrid:a}=e.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),dr(s,i,o,a)},screenToFlowPosition:s=>{const{transform:i,snapToGrid:o,snapGrid:a,domNode:l}=e.getState();if(!l)return s;const{x:c,y:u}=l.getBoundingClientRect(),d={x:s.x-c,y:s.y-u};return dr(d,i,o,a)},flowToScreenPosition:s=>{const{transform:i,domNode:o}=e.getState();if(!o)return s;const{x:a,y:l}=o.getBoundingClientRect(),c=Qi(s,i);return{x:c.x+a,y:c.y+l}},viewportInitialized:!0}:Lf,[t,n])};function An(){const e=zf(),t=de(),n=b.useCallback(()=>t.getState().getNodes().map(x=>({...x})),[]),r=b.useCallback(x=>t.getState().nodeInternals.get(x),[]),s=b.useCallback(()=>{const{edges:x=[]}=t.getState();return x.map(_=>({..._}))},[]),i=b.useCallback(x=>{const{edges:_=[]}=t.getState();return _.find(g=>g.id===x)},[]),o=b.useCallback(x=>{const{getNodes:_,setNodes:g,hasDefaultNodes:v,onNodesChange:j}=t.getState(),w=_(),M=typeof x=="function"?x(w):x;if(v)g(M);else if(j){const C=M.length===0?w.map(A=>({type:"remove",id:A.id})):M.map(A=>({item:A,type:"reset"}));j(C)}},[]),a=b.useCallback(x=>{const{edges:_=[],setEdges:g,hasDefaultEdges:v,onEdgesChange:j}=t.getState(),w=typeof x=="function"?x(_):x;if(v)g(w);else if(j){const M=w.length===0?_.map(C=>({type:"remove",id:C.id})):w.map(C=>({item:C,type:"reset"}));j(M)}},[]),l=b.useCallback(x=>{const _=Array.isArray(x)?x:[x],{getNodes:g,setNodes:v,hasDefaultNodes:j,onNodesChange:w}=t.getState();if(j){const C=[...g(),..._];v(C)}else if(w){const M=_.map(C=>({item:C,type:"add"}));w(M)}},[]),c=b.useCallback(x=>{const _=Array.isArray(x)?x:[x],{edges:g=[],setEdges:v,hasDefaultEdges:j,onEdgesChange:w}=t.getState();if(j)v([...g,..._]);else if(w){const M=_.map(C=>({item:C,type:"add"}));w(M)}},[]),u=b.useCallback(()=>{const{getNodes:x,edges:_=[],transform:g}=t.getState(),[v,j,w]=g;return{nodes:x().map(M=>({...M})),edges:_.map(M=>({...M})),viewport:{x:v,y:j,zoom:w}}},[]),d=b.useCallback(({nodes:x,edges:_})=>{const{nodeInternals:g,getNodes:v,edges:j,hasDefaultNodes:w,hasDefaultEdges:M,onNodesDelete:C,onEdgesDelete:A,onNodesChange:F,onEdgesChange:S}=t.getState(),O=(x||[]).map(k=>k.id),z=(_||[]).map(k=>k.id),G=v().reduce((k,E)=>{const T=E.parentNode||E.parentId,D=!O.includes(E.id)&&T&&k.find(I=>I.id===T);return(typeof E.deletable=="boolean"?E.deletable:!0)&&(O.includes(E.id)||D)&&k.push(E),k},[]),V=j.filter(k=>typeof k.deletable=="boolean"?k.deletable:!0),p=V.filter(k=>z.includes(k.id));if(G||p){const k=eo(G,V),E=[...p,...k],T=E.reduce((D,N)=>(D.includes(N.id)||D.push(N.id),D),[]);if((M||w)&&(M&&t.setState({edges:j.filter(D=>!T.includes(D.id))}),w&&(G.forEach(D=>{g.delete(D.id)}),t.setState({nodeInternals:new Map(g)}))),T.length>0&&(A==null||A(E),S&&S(T.map(D=>({id:D,type:"remove"})))),G.length>0&&(C==null||C(G),F)){const D=G.map(N=>({id:N.id,type:"remove"}));F(D)}}},[]),m=b.useCallback(x=>{const _=sf(x),g=_?null:t.getState().nodeInternals.get(x.id);return!_&&!g?[null,null,_]:[_?x:ds(g),g,_]},[]),f=b.useCallback((x,_=!0,g)=>{const[v,j,w]=m(x);return v?(g||t.getState().getNodes()).filter(M=>{if(!w&&(M.id===j.id||!M.positionAbsolute))return!1;const C=ds(M),A=lr(C,v);return _&&A>0||A>=v.width*v.height}):[]},[]),y=b.useCallback((x,_,g=!0)=>{const[v]=m(x);if(!v)return!1;const j=lr(v,_);return g&&j>0||j>=v.width*v.height},[]);return b.useMemo(()=>({...e,getNodes:n,getNode:r,getEdges:s,getEdge:i,setNodes:o,setEdges:a,addNodes:l,addEdges:c,toObject:u,deleteElements:d,getIntersectingNodes:f,isNodeIntersecting:y}),[e,n,r,s,i,o,a,l,c,u,d,f,y])}const Hf={actInsideInputWithModifier:!1};var Ff=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=de(),{deleteElements:r}=An(),s=Yt(e,Hf),i=Yt(t);b.useEffect(()=>{if(s){const{edges:o,getNodes:a}=n.getState(),l=a().filter(u=>u.selected),c=o.filter(u=>u.selected);r({nodes:l,edges:c}),n.setState({nodesSelectionActive:!1})}},[s]),b.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])};function Vf(e){const t=de();b.useEffect(()=>{let n;const r=()=>{var i,o;if(!e.current)return;const s=Nr(e.current);(s.height===0||s.width===0)&&((o=(i=t.getState()).onError)==null||o.call(i,"004",Pe.error004())),t.setState({width:s.width||500,height:s.height||500})};return r(),window.addEventListener("resize",r),e.current&&(n=new ResizeObserver(()=>r()),n.observe(e.current)),()=>{window.removeEventListener("resize",r),n&&e.current&&n.unobserve(e.current)}},[])}const Ir={position:"absolute",width:"100%",height:"100%",top:0,left:0},Bf=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,sn=e=>({x:e.x,y:e.y,zoom:e.k}),mt=(e,t)=>e.target.closest(`.${t}`),vs=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),_s=e=>{const t=e.ctrlKey&&yn()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},Gf=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),Yf=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:r,zoomOnScroll:s=!0,zoomOnPinch:i=!0,panOnScroll:o=!1,panOnScrollSpeed:a=.5,panOnScrollMode:l=tt.Free,zoomOnDoubleClick:c=!0,elementsSelectable:u,panOnDrag:d=!0,defaultViewport:m,translateExtent:f,minZoom:y,maxZoom:x,zoomActivationKeyCode:_,preventScrolling:g=!0,children:v,noWheelClassName:j,noPanClassName:w})=>{const M=b.useRef(),C=de(),A=b.useRef(!1),F=b.useRef(!1),S=b.useRef(null),O=b.useRef({x:0,y:0,zoom:0}),{d3Zoom:z,d3Selection:G,d3ZoomHandler:V,userSelectionActive:p}=re(Gf,fe),k=Yt(_),E=b.useRef(0),T=b.useRef(!1),D=b.useRef();return Vf(S),b.useEffect(()=>{if(S.current){const N=S.current.getBoundingClientRect(),I=Hi().scaleExtent([y,x]).translateExtent(f),L=xe(S.current).call(I),P=De.translate(m.x,m.y).scale(Et(m.zoom,y,x)),R=[[0,0],[N.width,N.height]],H=I.constrain()(P,R,f);I.transform(L,H),I.wheelDelta(_s),C.setState({d3Zoom:I,d3Selection:L,d3ZoomHandler:L.on("wheel.zoom"),transform:[H.x,H.y,H.k],domNode:S.current.closest(".react-flow")})}},[]),b.useEffect(()=>{G&&z&&(o&&!k&&!p?G.on("wheel.zoom",N=>{if(mt(N,j))return!1;N.preventDefault(),N.stopImmediatePropagation();const I=G.property("__zoom").k||1;if(N.ctrlKey&&i){const J=Ee(N),Q=_s(N),K=I*Math.pow(2,Q);z.scaleTo(G,K,J,N);return}const L=N.deltaMode===1?20:1;let P=l===tt.Vertical?0:N.deltaX*L,R=l===tt.Horizontal?0:N.deltaY*L;!yn()&&N.shiftKey&&l!==tt.Vertical&&(P=N.deltaY*L,R=0),z.translateBy(G,-(P/I)*a,-(R/I)*a,{internal:!0});const H=sn(G.property("__zoom")),{onViewportChangeStart:B,onViewportChange:X,onViewportChangeEnd:q}=C.getState();clearTimeout(D.current),T.current||(T.current=!0,t==null||t(N,H),B==null||B(H)),T.current&&(e==null||e(N,H),X==null||X(H),D.current=setTimeout(()=>{n==null||n(N,H),q==null||q(H),T.current=!1},150))},{passive:!1}):typeof V<"u"&&G.on("wheel.zoom",function(N,I){if(!g&&N.type==="wheel"&&!N.ctrlKey||mt(N,j))return null;N.preventDefault(),V.call(this,N,I)},{passive:!1}))},[p,o,l,G,z,V,k,i,g,j,t,e,n]),b.useEffect(()=>{z&&z.on("start",N=>{var P,R;if(!N.sourceEvent||N.sourceEvent.internal)return null;E.current=(P=N.sourceEvent)==null?void 0:P.button;const{onViewportChangeStart:I}=C.getState(),L=sn(N.transform);A.current=!0,O.current=L,((R=N.sourceEvent)==null?void 0:R.type)==="mousedown"&&C.setState({paneDragging:!0}),I==null||I(L),t==null||t(N.sourceEvent,L)})},[z,t]),b.useEffect(()=>{z&&(p&&!A.current?z.on("zoom",null):p||z.on("zoom",N=>{var L;const{onViewportChange:I}=C.getState();if(C.setState({transform:[N.transform.x,N.transform.y,N.transform.k]}),F.current=!!(r&&vs(d,E.current??0)),(e||I)&&!((L=N.sourceEvent)!=null&&L.internal)){const P=sn(N.transform);I==null||I(P),e==null||e(N.sourceEvent,P)}}))},[p,z,e,d,r]),b.useEffect(()=>{z&&z.on("end",N=>{if(!N.sourceEvent||N.sourceEvent.internal)return null;const{onViewportChangeEnd:I}=C.getState();if(A.current=!1,C.setState({paneDragging:!1}),r&&vs(d,E.current??0)&&!F.current&&r(N.sourceEvent),F.current=!1,(n||I)&&Bf(O.current,N.transform)){const L=sn(N.transform);O.current=L,clearTimeout(M.current),M.current=setTimeout(()=>{I==null||I(L),n==null||n(N.sourceEvent,L)},o?150:0)}})},[z,o,d,n,r]),b.useEffect(()=>{z&&z.filter(N=>{const I=k||s,L=i&&N.ctrlKey;if((d===!0||Array.isArray(d)&&d.includes(1))&&N.button===1&&N.type==="mousedown"&&(mt(N,"react-flow__node")||mt(N,"react-flow__edge")))return!0;if(!d&&!I&&!o&&!c&&!i||p||!c&&N.type==="dblclick"||mt(N,j)&&N.type==="wheel"||mt(N,w)&&(N.type!=="wheel"||o&&N.type==="wheel"&&!k)||!i&&N.ctrlKey&&N.type==="wheel"||!I&&!o&&!L&&N.type==="wheel"||!d&&(N.type==="mousedown"||N.type==="touchstart")||Array.isArray(d)&&!d.includes(N.button)&&N.type==="mousedown")return!1;const P=Array.isArray(d)&&d.includes(N.button)||!N.button||N.button<=1;return(!N.ctrlKey||N.type==="wheel")&&P})},[p,z,s,i,o,c,d,u,k]),$.createElement("div",{className:"react-flow__renderer",ref:S,style:Ir},v)},Wf=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Uf(){const{userSelectionActive:e,userSelectionRect:t}=re(Wf,fe);return e&&t?$.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}function Es(e,t){const n=t.parentNode||t.parentId,r=e.find(s=>s.id===n);if(r){const s=t.position.x+t.width-r.width,i=t.position.y+t.height-r.height;if(s>0||i>0||t.position.x<0||t.position.y<0){if(r.style={...r.style},r.style.width=r.style.width??r.width,r.style.height=r.style.height??r.height,s>0&&(r.style.width+=s),i>0&&(r.style.height+=i),t.position.x<0){const o=Math.abs(t.position.x);r.position.x=r.position.x-o,r.style.width+=o,t.position.x=0}if(t.position.y<0){const o=Math.abs(t.position.y);r.position.y=r.position.y-o,r.style.height+=o,t.position.y=0}r.width=r.style.width,r.height=r.style.height}}}function Xf(e,t){if(e.some(r=>r.type==="reset"))return e.filter(r=>r.type==="reset").map(r=>r.item);const n=e.filter(r=>r.type==="add").map(r=>r.item);return t.reduce((r,s)=>{const i=e.filter(a=>a.id===s.id);if(i.length===0)return r.push(s),r;const o={...s};for(const a of i)if(a)switch(a.type){case"select":{o.selected=a.selected;break}case"position":{typeof a.position<"u"&&(o.position=a.position),typeof a.positionAbsolute<"u"&&(o.positionAbsolute=a.positionAbsolute),typeof a.dragging<"u"&&(o.dragging=a.dragging),o.expandParent&&Es(r,o);break}case"dimensions":{typeof a.dimensions<"u"&&(o.width=a.dimensions.width,o.height=a.dimensions.height),typeof a.updateStyle<"u"&&(o.style={...o.style||{},...a.dimensions}),typeof a.resizing=="boolean"&&(o.resizing=a.resizing),o.expandParent&&Es(r,o);break}case"remove":return r}return r.push(o),r},n)}function qf(e,t){return Xf(e,t)}const Fe=(e,t)=>({id:e,type:"select",selected:t});function gt(e,t){return e.reduce((n,r)=>{const s=t.includes(r.id);return!r.selected&&s?(r.selected=!0,n.push(Fe(r.id,!0))):r.selected&&!s&&(r.selected=!1,n.push(Fe(r.id,!1))),n},[])}const Gn=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},Zf=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),xo=b.memo(({isSelecting:e,selectionMode:t=Gt.Full,panOnDrag:n,onSelectionStart:r,onSelectionEnd:s,onPaneClick:i,onPaneContextMenu:o,onPaneScroll:a,onPaneMouseEnter:l,onPaneMouseMove:c,onPaneMouseLeave:u,children:d})=>{const m=b.useRef(null),f=de(),y=b.useRef(0),x=b.useRef(0),_=b.useRef(),{userSelectionActive:g,elementsSelectable:v,dragging:j}=re(Zf,fe),w=()=>{f.setState({userSelectionActive:!1,userSelectionRect:null}),y.current=0,x.current=0},M=V=>{i==null||i(V),f.getState().resetSelectedElements(),f.setState({nodesSelectionActive:!1})},C=V=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){V.preventDefault();return}o==null||o(V)},A=a?V=>a(V):void 0,F=V=>{const{resetSelectedElements:p,domNode:k}=f.getState();if(_.current=k==null?void 0:k.getBoundingClientRect(),!v||!e||V.button!==0||V.target!==m.current||!_.current)return;const{x:E,y:T}=Ge(V,_.current);p(),f.setState({userSelectionRect:{width:0,height:0,startX:E,startY:T,x:E,y:T}}),r==null||r(V)},S=V=>{const{userSelectionRect:p,nodeInternals:k,edges:E,transform:T,onNodesChange:D,onEdgesChange:N,nodeOrigin:I,getNodes:L}=f.getState();if(!e||!_.current||!p)return;f.setState({userSelectionActive:!0,nodesSelectionActive:!1});const P=Ge(V,_.current),R=p.startX??0,H=p.startY??0,B={...p,x:P.xK.id),Q=q.map(K=>K.id);if(y.current!==Q.length){y.current=Q.length;const K=gt(X,Q);K.length&&(D==null||D(K))}if(x.current!==J.length){x.current=J.length;const K=gt(E,J);K.length&&(N==null||N(K))}f.setState({userSelectionRect:B})},O=V=>{if(V.button!==0)return;const{userSelectionRect:p}=f.getState();!g&&p&&V.target===m.current&&(M==null||M(V)),f.setState({nodesSelectionActive:y.current>0}),w(),s==null||s(V)},z=V=>{g&&(f.setState({nodesSelectionActive:y.current>0}),s==null||s(V)),w()},G=v&&(e||g);return $.createElement("div",{className:he(["react-flow__pane",{dragging:j,selection:e}]),onClick:G?void 0:Gn(M,m),onContextMenu:Gn(C,m),onWheel:Gn(A,m),onMouseEnter:G?void 0:l,onMouseDown:G?F:void 0,onMouseMove:G?S:c,onMouseUp:G?O:void 0,onMouseLeave:G?z:u,ref:m,style:Ir},d,$.createElement(Uf,null))});xo.displayName="Pane";function wo(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const r=t.get(n);return r?r.selected?!0:wo(r,t):!1}function Ns(e,t,n){let r=e;do{if(r!=null&&r.matches(t))return!0;if(r===n.current)return!1;r=r.parentElement}while(r);return!1}function Kf(e,t,n,r){return Array.from(e.values()).filter(s=>(s.selected||s.id===r)&&(!s.parentNode||s.parentId||!wo(s,e))&&(s.draggable||t&&typeof s.draggable>"u")).map(s=>{var i,o;return{id:s.id,position:s.position||{x:0,y:0},positionAbsolute:s.positionAbsolute||{x:0,y:0},distance:{x:n.x-(((i=s.positionAbsolute)==null?void 0:i.x)??0),y:n.y-(((o=s.positionAbsolute)==null?void 0:o.y)??0)},delta:{x:0,y:0},extent:s.extent,parentNode:s.parentNode||s.parentId,parentId:s.parentNode||s.parentId,width:s.width,height:s.height,expandParent:s.expandParent}})}function Qf(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function bo(e,t,n,r,s=[0,0],i){const o=Qf(e,e.extent||r);let a=o;const l=e.parentNode||e.parentId;if(e.extent==="parent"&&!e.expandParent)if(l&&e.width&&e.height){const d=n.get(l),{x:m,y:f}=rt(d,s).positionAbsolute;a=d&&we(m)&&we(f)&&we(d.width)&&we(d.height)?[[m+e.width*s[0],f+e.height*s[1]],[m+d.width-e.width+e.width*s[0],f+d.height-e.height+e.height*s[1]]]:a}else i==null||i("005",Pe.error005()),a=o;else if(e.extent&&l&&e.extent!=="parent"){const d=n.get(l),{x:m,y:f}=rt(d,s).positionAbsolute;a=[[e.extent[0][0]+m,e.extent[0][1]+f],[e.extent[1][0]+m,e.extent[1][1]+f]]}let c={x:0,y:0};if(l){const d=n.get(l);c=rt(d,s).positionAbsolute}const u=a&&a!=="parent"?Sr(t,a):t;return{position:{x:u.x-c.x,y:u.y-c.y},positionAbsolute:u}}function Yn({nodeId:e,dragItems:t,nodeInternals:n}){const r=t.map(s=>({...n.get(s.id),position:s.position,positionAbsolute:s.positionAbsolute}));return[e?r.find(s=>s.id===e):r[0],r]}const Ss=(e,t,n,r)=>{const s=t.querySelectorAll(e);if(!s||!s.length)return null;const i=Array.from(s),o=t.getBoundingClientRect(),a={x:o.width*r[0],y:o.height*r[1]};return i.map(l=>{const c=l.getBoundingClientRect();return{id:l.getAttribute("data-handleid"),position:l.getAttribute("data-handlepos"),x:(c.left-o.left-a.x)/n,y:(c.top-o.top-a.y)/n,...Nr(l)}})};function At(e,t,n){return n===void 0?n:r=>{const s=t().nodeInternals.get(e);s&&n(r,{...s})}}function hr({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:i,multiSelectionActive:o,nodeInternals:a,onError:l}=t.getState(),c=a.get(e);if(!c){l==null||l("012",Pe.error012(e));return}t.setState({nodesSelectionActive:!1}),c.selected?(n||c.selected&&o)&&(i({nodes:[c],edges:[]}),requestAnimationFrame(()=>{var u;return(u=r==null?void 0:r.current)==null?void 0:u.blur()})):s([e])}function Jf(){const e=de();return b.useCallback(({sourceEvent:n})=>{const{transform:r,snapGrid:s,snapToGrid:i}=e.getState(),o=n.touches?n.touches[0].clientX:n.clientX,a=n.touches?n.touches[0].clientY:n.clientY,l={x:(o-r[0])/r[2],y:(a-r[1])/r[2]};return{xSnapped:i?s[0]*Math.round(l.x/s[0]):l.x,ySnapped:i?s[1]*Math.round(l.y/s[1]):l.y,...l}},[])}function Wn(e){return(t,n,r)=>e==null?void 0:e(t,r)}function vo({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:i,selectNodesOnDrag:o}){const a=de(),[l,c]=b.useState(!1),u=b.useRef([]),d=b.useRef({x:null,y:null}),m=b.useRef(0),f=b.useRef(null),y=b.useRef({x:0,y:0}),x=b.useRef(null),_=b.useRef(!1),g=b.useRef(!1),v=b.useRef(!1),j=Jf();return b.useEffect(()=>{if(e!=null&&e.current){const w=xe(e.current),M=({x:F,y:S})=>{const{nodeInternals:O,onNodeDrag:z,onSelectionDrag:G,updateNodePositions:V,nodeExtent:p,snapGrid:k,snapToGrid:E,nodeOrigin:T,onError:D}=a.getState();d.current={x:F,y:S};let N=!1,I={x:0,y:0,x2:0,y2:0};if(u.current.length>1&&p){const P=Mn(u.current,T);I=Bt(P)}if(u.current=u.current.map(P=>{const R={x:F-P.distance.x,y:S-P.distance.y};E&&(R.x=k[0]*Math.round(R.x/k[0]),R.y=k[1]*Math.round(R.y/k[1]));const H=[[p[0][0],p[0][1]],[p[1][0],p[1][1]]];u.current.length>1&&p&&!P.extent&&(H[0][0]=P.positionAbsolute.x-I.x+p[0][0],H[1][0]=P.positionAbsolute.x+(P.width??0)-I.x2+p[1][0],H[0][1]=P.positionAbsolute.y-I.y+p[0][1],H[1][1]=P.positionAbsolute.y+(P.height??0)-I.y2+p[1][1]);const B=bo(P,R,O,H,T,D);return N=N||P.position.x!==B.position.x||P.position.y!==B.position.y,P.position=B.position,P.positionAbsolute=B.positionAbsolute,P}),!N)return;V(u.current,!0,!0),c(!0);const L=s?z:Wn(G);if(L&&x.current){const[P,R]=Yn({nodeId:s,dragItems:u.current,nodeInternals:O});L(x.current,P,R)}},C=()=>{if(!f.current)return;const[F,S]=Vi(y.current,f.current);if(F!==0||S!==0){const{transform:O,panBy:z}=a.getState();d.current.x=(d.current.x??0)-F/O[2],d.current.y=(d.current.y??0)-S/O[2],z({x:F,y:S})&&M(d.current)}m.current=requestAnimationFrame(C)},A=F=>{var T;const{nodeInternals:S,multiSelectionActive:O,nodesDraggable:z,unselectNodesAndEdges:G,onNodeDragStart:V,onSelectionDragStart:p}=a.getState();g.current=!0;const k=s?V:Wn(p);(!o||!i)&&!O&&s&&((T=S.get(s))!=null&&T.selected||G()),s&&i&&o&&hr({id:s,store:a,nodeRef:e});const E=j(F);if(d.current=E,u.current=Kf(S,z,E,s),k&&u.current){const[D,N]=Yn({nodeId:s,dragItems:u.current,nodeInternals:S});k(F.sourceEvent,D,N)}};if(t)w.on(".drag",null);else{const F=lu().on("start",S=>{const{domNode:O,nodeDragThreshold:z}=a.getState();z===0&&A(S),v.current=!1;const G=j(S);d.current=G,f.current=(O==null?void 0:O.getBoundingClientRect())||null,y.current=Ge(S.sourceEvent,f.current)}).on("drag",S=>{var V,p;const O=j(S),{autoPanOnNodeDrag:z,nodeDragThreshold:G}=a.getState();if(S.sourceEvent.type==="touchmove"&&S.sourceEvent.touches.length>1&&(v.current=!0),!v.current){if(!_.current&&g.current&&z&&(_.current=!0,C()),!g.current){const k=O.xSnapped-(((V=d==null?void 0:d.current)==null?void 0:V.x)??0),E=O.ySnapped-(((p=d==null?void 0:d.current)==null?void 0:p.y)??0);Math.sqrt(k*k+E*E)>G&&A(S)}(d.current.x!==O.xSnapped||d.current.y!==O.ySnapped)&&u.current&&g.current&&(x.current=S.sourceEvent,y.current=Ge(S.sourceEvent,f.current),M(O))}}).on("end",S=>{if(!(!g.current||v.current)&&(c(!1),_.current=!1,g.current=!1,cancelAnimationFrame(m.current),u.current)){const{updateNodePositions:O,nodeInternals:z,onNodeDragStop:G,onSelectionDragStop:V}=a.getState(),p=s?G:Wn(V);if(O(u.current,!1,!1),p){const[k,E]=Yn({nodeId:s,dragItems:u.current,nodeInternals:z});p(S.sourceEvent,k,E)}}}).filter(S=>{const O=S.target;return!S.button&&(!n||!Ns(O,`.${n}`,e))&&(!r||Ns(O,r,e))});return w.call(F),()=>{w.on(".drag",null)}}}},[e,t,n,r,i,a,s,o,j]),l}function _o(){const e=de();return b.useCallback(n=>{const{nodeInternals:r,nodeExtent:s,updateNodePositions:i,getNodes:o,snapToGrid:a,snapGrid:l,onError:c,nodesDraggable:u}=e.getState(),d=o().filter(v=>v.selected&&(v.draggable||u&&typeof v.draggable>"u")),m=a?l[0]:5,f=a?l[1]:5,y=n.isShiftPressed?4:1,x=n.x*m*y,_=n.y*f*y,g=d.map(v=>{if(v.positionAbsolute){const j={x:v.positionAbsolute.x+x,y:v.positionAbsolute.y+_};a&&(j.x=l[0]*Math.round(j.x/l[0]),j.y=l[1]*Math.round(j.y/l[1]));const{positionAbsolute:w,position:M}=bo(v,j,r,s,void 0,c);v.position=M,v.positionAbsolute=w}return v});i(g,!0,!1)},[])}const wt={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var It=e=>{const t=({id:n,type:r,data:s,xPos:i,yPos:o,xPosOrigin:a,yPosOrigin:l,selected:c,onClick:u,onMouseEnter:d,onMouseMove:m,onMouseLeave:f,onContextMenu:y,onDoubleClick:x,style:_,className:g,isDraggable:v,isSelectable:j,isConnectable:w,isFocusable:M,selectNodesOnDrag:C,sourcePosition:A,targetPosition:F,hidden:S,resizeObserver:O,dragHandle:z,zIndex:G,isParent:V,noDragClassName:p,noPanClassName:k,initialized:E,disableKeyboardA11y:T,ariaLabel:D,rfId:N,hasHandleBounds:I})=>{const L=de(),P=b.useRef(null),R=b.useRef(null),H=b.useRef(A),B=b.useRef(F),X=b.useRef(r),q=j||v||u||d||m||f,J=_o(),Q=At(n,L.getState,d),K=At(n,L.getState,m),ae=At(n,L.getState,f),se=At(n,L.getState,y),Y=At(n,L.getState,x),ne=ee=>{const{nodeDragThreshold:W}=L.getState();if(j&&(!C||!v||W>0)&&hr({id:n,store:L,nodeRef:P}),u){const pe=L.getState().nodeInternals.get(n);pe&&u(ee,{...pe})}},te=ee=>{if(!cr(ee)&&!T)if(Wi.includes(ee.key)&&j){const W=ee.key==="Escape";hr({id:n,store:L,unselect:W,nodeRef:P})}else v&&c&&Object.prototype.hasOwnProperty.call(wt,ee.key)&&(L.setState({ariaLiveMessage:`Moved selected node ${ee.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~i}, y: ${~~o}`}),J({x:wt[ee.key].x,y:wt[ee.key].y,isShiftPressed:ee.shiftKey}))};b.useEffect(()=>()=>{R.current&&(O==null||O.unobserve(R.current),R.current=null)},[]),b.useEffect(()=>{if(P.current&&!S){const ee=P.current;(!E||!I||R.current!==ee)&&(R.current&&(O==null||O.unobserve(R.current)),O==null||O.observe(ee),R.current=ee)}},[S,E,I]),b.useEffect(()=>{const ee=X.current!==r,W=H.current!==A,pe=B.current!==F;P.current&&(ee||W||pe)&&(ee&&(X.current=r),W&&(H.current=A),pe&&(B.current=F),L.getState().updateNodeDimensions([{id:n,nodeElement:P.current,forceUpdate:!0}]))},[n,r,A,F]);const le=vo({nodeRef:P,disabled:S||!v,noDragClassName:p,handleSelector:z,nodeId:n,isSelectable:j,selectNodesOnDrag:C});return S?null:$.createElement("div",{className:he(["react-flow__node",`react-flow__node-${r}`,{[k]:v},g,{selected:c,selectable:j,parent:V,dragging:le}]),ref:P,style:{zIndex:G,transform:`translate(${a}px,${l}px)`,pointerEvents:q?"all":"none",visibility:E?"visible":"hidden",..._},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:Q,onMouseMove:K,onMouseLeave:ae,onContextMenu:se,onClick:ne,onDoubleClick:Y,onKeyDown:M?te:void 0,tabIndex:M?0:void 0,role:M?"button":void 0,"aria-describedby":T?void 0:`${ho}-${N}`,"aria-label":D},$.createElement(ff,{value:n},$.createElement(e,{id:n,data:s,type:r,xPos:i,yPos:o,selected:c,isConnectable:w,sourcePosition:A,targetPosition:F,dragging:le,dragHandle:z,zIndex:G})))};return t.displayName="NodeWrapper",b.memo(t)};const eh=e=>{const t=e.getNodes().filter(n=>n.selected);return{...Mn(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function th({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=de(),{width:s,height:i,x:o,y:a,transformString:l,userSelectionActive:c}=re(eh,fe),u=_o(),d=b.useRef(null);if(b.useEffect(()=>{var y;n||(y=d.current)==null||y.focus({preventScroll:!0})},[n]),vo({nodeRef:d}),c||!s||!i)return null;const m=e?y=>{const x=r.getState().getNodes().filter(_=>_.selected);e(y,x)}:void 0,f=y=>{Object.prototype.hasOwnProperty.call(wt,y.key)&&u({x:wt[y.key].x,y:wt[y.key].y,isShiftPressed:y.shiftKey})};return $.createElement("div",{className:he(["react-flow__nodesselection","react-flow__container",t]),style:{transform:l}},$.createElement("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:m,tabIndex:n?void 0:-1,onKeyDown:n?void 0:f,style:{width:s,height:i,top:a,left:o}}))}var nh=b.memo(th);const rh=e=>e.nodesSelectionActive,Eo=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:o,deleteKeyCode:a,onMove:l,onMoveStart:c,onMoveEnd:u,selectionKeyCode:d,selectionOnDrag:m,selectionMode:f,onSelectionStart:y,onSelectionEnd:x,multiSelectionKeyCode:_,panActivationKeyCode:g,zoomActivationKeyCode:v,elementsSelectable:j,zoomOnScroll:w,zoomOnPinch:M,panOnScroll:C,panOnScrollSpeed:A,panOnScrollMode:F,zoomOnDoubleClick:S,panOnDrag:O,defaultViewport:z,translateExtent:G,minZoom:V,maxZoom:p,preventScrolling:k,onSelectionContextMenu:E,noWheelClassName:T,noPanClassName:D,disableKeyboardA11y:N})=>{const I=re(rh),L=Yt(d),P=Yt(g),R=P||O,H=P||C,B=L||m&&R!==!0;return Ff({deleteKeyCode:a,multiSelectionKeyCode:_}),$.createElement(Yf,{onMove:l,onMoveStart:c,onMoveEnd:u,onPaneContextMenu:i,elementsSelectable:j,zoomOnScroll:w,zoomOnPinch:M,panOnScroll:H,panOnScrollSpeed:A,panOnScrollMode:F,zoomOnDoubleClick:S,panOnDrag:!L&&R,defaultViewport:z,translateExtent:G,minZoom:V,maxZoom:p,zoomActivationKeyCode:v,preventScrolling:k,noWheelClassName:T,noPanClassName:D},$.createElement(xo,{onSelectionStart:y,onSelectionEnd:x,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:o,panOnDrag:R,isSelecting:!!B,selectionMode:f},e,I&&$.createElement(nh,{onSelectionContextMenu:E,noPanClassName:D,disableKeyboardA11y:N})))};Eo.displayName="FlowRenderer";var sh=b.memo(Eo);function ih(e){return re(b.useCallback(n=>e?Ji(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}function oh(e){const t={input:It(e.input||lo),default:It(e.default||fr),output:It(e.output||uo),group:It(e.group||Ar)},n={},r=Object.keys(e).filter(s=>!["input","default","output","group"].includes(s)).reduce((s,i)=>(s[i]=It(e[i]||fr),s),n);return{...t,...r}}const ah=({x:e,y:t,width:n,height:r,origin:s})=>!n||!r?{x:e,y:t}:s[0]<0||s[1]<0||s[0]>1||s[1]>1?{x:e,y:t}:{x:e-n*s[0],y:t-r*s[1]},lh=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),No=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,updateNodeDimensions:i,onError:o}=re(lh,fe),a=ih(e.onlyRenderVisibleElements),l=b.useRef(),c=b.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const u=new ResizeObserver(d=>{const m=d.map(f=>({id:f.target.getAttribute("data-id"),nodeElement:f.target,forceUpdate:!0}));i(m)});return l.current=u,u},[]);return b.useEffect(()=>()=>{var u;(u=l==null?void 0:l.current)==null||u.disconnect()},[]),$.createElement("div",{className:"react-flow__nodes",style:Ir},a.map(u=>{var M,C,A;let d=u.type||"default";e.nodeTypes[d]||(o==null||o("003",Pe.error003(d)),d="default");const m=e.nodeTypes[d]||e.nodeTypes.default,f=!!(u.draggable||t&&typeof u.draggable>"u"),y=!!(u.selectable||s&&typeof u.selectable>"u"),x=!!(u.connectable||n&&typeof u.connectable>"u"),_=!!(u.focusable||r&&typeof u.focusable>"u"),g=e.nodeExtent?Sr(u.positionAbsolute,e.nodeExtent):u.positionAbsolute,v=(g==null?void 0:g.x)??0,j=(g==null?void 0:g.y)??0,w=ah({x:v,y:j,width:u.width??0,height:u.height??0,origin:e.nodeOrigin});return $.createElement(m,{key:u.id,id:u.id,className:u.className,style:u.style,type:d,data:u.data,sourcePosition:u.sourcePosition||U.Bottom,targetPosition:u.targetPosition||U.Top,hidden:u.hidden,xPos:v,yPos:j,xPosOrigin:w.x,yPosOrigin:w.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!u.selected,isDraggable:f,isSelectable:y,isConnectable:x,isFocusable:_,resizeObserver:c,dragHandle:u.dragHandle,zIndex:((M=u[ie])==null?void 0:M.z)??0,isParent:!!((C=u[ie])!=null&&C.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!u.width&&!!u.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:u.ariaLabel,hasHandleBounds:!!((A=u[ie])!=null&&A.handleBounds)})}))};No.displayName="NodeRenderer";var ch=b.memo(No);const uh=(e,t,n)=>n===U.Left?e-t:n===U.Right?e+t:e,dh=(e,t,n)=>n===U.Top?e-t:n===U.Bottom?e+t:e,ks="react-flow__edgeupdater",js=({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:s,onMouseEnter:i,onMouseOut:o,type:a})=>$.createElement("circle",{onMouseDown:s,onMouseEnter:i,onMouseOut:o,className:he([ks,`${ks}-${a}`]),cx:uh(t,r,e),cy:dh(n,r,e),r,stroke:"transparent",fill:"transparent"}),fh=()=>!0;var pt=e=>{const t=({id:n,className:r,type:s,data:i,onClick:o,onEdgeDoubleClick:a,selected:l,animated:c,label:u,labelStyle:d,labelShowBg:m,labelBgStyle:f,labelBgPadding:y,labelBgBorderRadius:x,style:_,source:g,target:v,sourceX:j,sourceY:w,targetX:M,targetY:C,sourcePosition:A,targetPosition:F,elementsSelectable:S,hidden:O,sourceHandleId:z,targetHandleId:G,onContextMenu:V,onMouseEnter:p,onMouseMove:k,onMouseLeave:E,reconnectRadius:T,onReconnect:D,onReconnectStart:N,onReconnectEnd:I,markerEnd:L,markerStart:P,rfId:R,ariaLabel:H,isFocusable:B,isReconnectable:X,pathOptions:q,interactionWidth:J,disableKeyboardA11y:Q})=>{const K=b.useRef(null),[ae,se]=b.useState(!1),[Y,ne]=b.useState(!1),te=de(),le=b.useMemo(()=>`url('#${ur(P,R)}')`,[P,R]),ee=b.useMemo(()=>`url('#${ur(L,R)}')`,[L,R]);if(O)return null;const W=me=>{var je;const{edges:_e,addSelectedEdges:Xe,unselectNodesAndEdges:qe,multiSelectionActive:Ze}=te.getState(),Ie=_e.find(kt=>kt.id===n);Ie&&(S&&(te.setState({nodesSelectionActive:!1}),Ie.selected&&Ze?(qe({nodes:[],edges:[Ie]}),(je=K.current)==null||je.blur()):Xe([n])),o&&o(me,Ie))},pe=Mt(n,te.getState,a),Me=Mt(n,te.getState,V),Nt=Mt(n,te.getState,p),at=Mt(n,te.getState,k),lt=Mt(n,te.getState,E),Ae=(me,_e)=>{if(me.button!==0)return;const{edges:Xe,isValidConnection:qe}=te.getState(),Ze=_e?v:g,Ie=(_e?G:z)||null,je=_e?"target":"source",kt=qe||fh,Rn=_e,jt=Xe.find(Ke=>Ke.id===n);ne(!0),N==null||N(me,jt,je);const On=Ke=>{ne(!1),I==null||I(Ke,jt,je)};so({event:me,handleId:Ie,nodeId:Ze,onConnect:Ke=>D==null?void 0:D(jt,Ke),isTarget:Rn,getState:te.getState,setState:te.setState,isValidConnection:kt,edgeUpdaterType:je,onReconnectEnd:On})},ct=me=>Ae(me,!0),We=me=>Ae(me,!1),Ue=()=>se(!0),ut=()=>se(!1),dt=!S&&!o,St=me=>{var _e;if(!Q&&Wi.includes(me.key)&&S){const{unselectNodesAndEdges:Xe,addSelectedEdges:qe,edges:Ze}=te.getState();me.key==="Escape"?((_e=K.current)==null||_e.blur(),Xe({edges:[Ze.find(je=>je.id===n)]})):qe([n])}};return $.createElement("g",{className:he(["react-flow__edge",`react-flow__edge-${s}`,r,{selected:l,animated:c,inactive:dt,updating:ae}]),onClick:W,onDoubleClick:pe,onContextMenu:Me,onMouseEnter:Nt,onMouseMove:at,onMouseLeave:lt,onKeyDown:B?St:void 0,tabIndex:B?0:void 0,role:B?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":H===null?void 0:H||`Edge from ${g} to ${v}`,"aria-describedby":B?`${mo}-${R}`:void 0,ref:K},!Y&&$.createElement(e,{id:n,source:g,target:v,selected:l,animated:c,label:u,labelStyle:d,labelShowBg:m,labelBgStyle:f,labelBgPadding:y,labelBgBorderRadius:x,data:i,style:_,sourceX:j,sourceY:w,targetX:M,targetY:C,sourcePosition:A,targetPosition:F,sourceHandleId:z,targetHandleId:G,markerStart:le,markerEnd:ee,pathOptions:q,interactionWidth:J}),X&&$.createElement($.Fragment,null,(X==="source"||X===!0)&&$.createElement(js,{position:A,centerX:j,centerY:w,radius:T,onMouseDown:ct,onMouseEnter:Ue,onMouseOut:ut,type:"source"}),(X==="target"||X===!0)&&$.createElement(js,{position:F,centerX:M,centerY:C,radius:T,onMouseDown:We,onMouseEnter:Ue,onMouseOut:ut,type:"target"})))};return t.displayName="EdgeWrapper",b.memo(t)};function hh(e){const t={default:pt(e.default||bn),straight:pt(e.bezier||Cr),step:pt(e.step||jr),smoothstep:pt(e.step||$n),simplebezier:pt(e.simplebezier||kr)},n={},r=Object.keys(e).filter(s=>!["default","bezier"].includes(s)).reduce((s,i)=>(s[i]=pt(e[i]||bn),s),n);return{...t,...r}}function Cs(e,t,n=null){const r=((n==null?void 0:n.x)||0)+t.x,s=((n==null?void 0:n.y)||0)+t.y,i=(n==null?void 0:n.width)||t.width,o=(n==null?void 0:n.height)||t.height;switch(e){case U.Top:return{x:r+i/2,y:s};case U.Right:return{x:r+i,y:s+o/2};case U.Bottom:return{x:r+i/2,y:s+o};case U.Left:return{x:r,y:s+o/2}}}function $s(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}const mh=(e,t,n,r,s,i)=>{const o=Cs(n,e,t),a=Cs(i,r,s);return{sourceX:o.x,sourceY:o.y,targetX:a.x,targetY:a.y}};function ph({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:r,targetWidth:s,targetHeight:i,width:o,height:a,transform:l}){const c={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+n,t.x+s),y2:Math.max(e.y+r,t.y+i)};c.x===c.x2&&(c.x2+=1),c.y===c.y2&&(c.y2+=1);const u=Bt({x:(0-l[0])/l[2],y:(0-l[1])/l[2],width:o/l[2],height:a/l[2]}),d=Math.max(0,Math.min(u.x2,c.x2)-Math.max(u.x,c.x)),m=Math.max(0,Math.min(u.y2,c.y2)-Math.max(u.y,c.y));return Math.ceil(d*m)>0}function Ms(e){var r,s,i,o,a;const t=((r=e==null?void 0:e[ie])==null?void 0:r.handleBounds)||null,n=t&&(e==null?void 0:e.width)&&(e==null?void 0:e.height)&&typeof((s=e==null?void 0:e.positionAbsolute)==null?void 0:s.x)<"u"&&typeof((i=e==null?void 0:e.positionAbsolute)==null?void 0:i.y)<"u";return[{x:((o=e==null?void 0:e.positionAbsolute)==null?void 0:o.x)||0,y:((a=e==null?void 0:e.positionAbsolute)==null?void 0:a.y)||0,width:(e==null?void 0:e.width)||0,height:(e==null?void 0:e.height)||0},t,!!n]}const gh=[{level:0,isMaxLevel:!0,edges:[]}];function yh(e,t,n=!1){let r=-1;const s=e.reduce((o,a)=>{var u,d;const l=we(a.zIndex);let c=l?a.zIndex:0;if(n){const m=t.get(a.target),f=t.get(a.source),y=a.selected||(m==null?void 0:m.selected)||(f==null?void 0:f.selected),x=Math.max(((u=f==null?void 0:f[ie])==null?void 0:u.z)||0,((d=m==null?void 0:m[ie])==null?void 0:d.z)||0,1e3);c=(l?a.zIndex:0)+(y?x:0)}return o[c]?o[c].push(a):o[c]=[a],r=c>r?c:r,o},{}),i=Object.entries(s).map(([o,a])=>{const l=+o;return{edges:a,level:l,isMaxLevel:l===r}});return i.length===0?gh:i}function xh(e,t,n){const r=re(b.useCallback(s=>e?s.edges.filter(i=>{const o=t.get(i.source),a=t.get(i.target);return(o==null?void 0:o.width)&&(o==null?void 0:o.height)&&(a==null?void 0:a.width)&&(a==null?void 0:a.height)&&ph({sourcePos:o.positionAbsolute||{x:0,y:0},targetPos:a.positionAbsolute||{x:0,y:0},sourceWidth:o.width,sourceHeight:o.height,targetWidth:a.width,targetHeight:a.height,width:s.width,height:s.height,transform:s.transform})}):s.edges,[e,t]));return yh(r,t,n)}const wh=({color:e="none",strokeWidth:t=1})=>$.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),bh=({color:e="none",strokeWidth:t=1})=>$.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),As={[xn.Arrow]:wh,[xn.ArrowClosed]:bh};function vh(e){const t=de();return b.useMemo(()=>{var s,i;return Object.prototype.hasOwnProperty.call(As,e)?As[e]:((i=(s=t.getState()).onError)==null||i.call(s,"009",Pe.error009(e)),null)},[e])}const _h=({id:e,type:t,color:n,width:r=12.5,height:s=12.5,markerUnits:i="strokeWidth",strokeWidth:o,orient:a="auto-start-reverse"})=>{const l=vh(t);return l?$.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:a,refX:"0",refY:"0"},$.createElement(l,{color:n,strokeWidth:o})):null},Eh=({defaultColor:e,rfId:t})=>n=>{const r=[];return n.edges.reduce((s,i)=>([i.markerStart,i.markerEnd].forEach(o=>{if(o&&typeof o=="object"){const a=ur(o,t);r.includes(a)||(s.push({id:a,color:o.color||e,...o}),r.push(a))}}),s),[]).sort((s,i)=>s.id.localeCompare(i.id))},So=({defaultColor:e,rfId:t})=>{const n=re(b.useCallback(Eh({defaultColor:e,rfId:t}),[e,t]),(r,s)=>!(r.length!==s.length||r.some((i,o)=>i.id!==s[o].id)));return $.createElement("defs",null,n.map(r=>$.createElement(_h,{id:r.id,key:r.id,type:r.type,color:r.color,width:r.width,height:r.height,markerUnits:r.markerUnits,strokeWidth:r.strokeWidth,orient:r.orient})))};So.displayName="MarkerDefinitions";var Nh=b.memo(So);const Sh=e=>({nodesConnectable:e.nodesConnectable,edgesFocusable:e.edgesFocusable,edgesUpdatable:e.edgesUpdatable,elementsSelectable:e.elementsSelectable,width:e.width,height:e.height,connectionMode:e.connectionMode,nodeInternals:e.nodeInternals,onError:e.onError}),ko=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:r,edgeTypes:s,noPanClassName:i,onEdgeContextMenu:o,onEdgeMouseEnter:a,onEdgeMouseMove:l,onEdgeMouseLeave:c,onEdgeClick:u,onEdgeDoubleClick:d,onReconnect:m,onReconnectStart:f,onReconnectEnd:y,reconnectRadius:x,children:_,disableKeyboardA11y:g})=>{const{edgesFocusable:v,edgesUpdatable:j,elementsSelectable:w,width:M,height:C,connectionMode:A,nodeInternals:F,onError:S}=re(Sh,fe),O=xh(t,F,n);return M?$.createElement($.Fragment,null,O.map(({level:z,edges:G,isMaxLevel:V})=>$.createElement("svg",{key:z,style:{zIndex:z},width:M,height:C,className:"react-flow__edges react-flow__container"},V&&$.createElement(Nh,{defaultColor:e,rfId:r}),$.createElement("g",null,G.map(p=>{const[k,E,T]=Ms(F.get(p.source)),[D,N,I]=Ms(F.get(p.target));if(!T||!I)return null;let L=p.type||"default";s[L]||(S==null||S("011",Pe.error011(L)),L="default");const P=s[L]||s.default,R=A===it.Strict?N.target:(N.target??[]).concat(N.source??[]),H=$s(E.source,p.sourceHandle),B=$s(R,p.targetHandle),X=(H==null?void 0:H.position)||U.Bottom,q=(B==null?void 0:B.position)||U.Top,J=!!(p.focusable||v&&typeof p.focusable>"u"),Q=p.reconnectable||p.updatable,K=typeof m<"u"&&(Q||j&&typeof Q>"u");if(!H||!B)return S==null||S("008",Pe.error008(H,p)),null;const{sourceX:ae,sourceY:se,targetX:Y,targetY:ne}=mh(k,H,X,D,B,q);return $.createElement(P,{key:p.id,id:p.id,className:he([p.className,i]),type:L,data:p.data,selected:!!p.selected,animated:!!p.animated,hidden:!!p.hidden,label:p.label,labelStyle:p.labelStyle,labelShowBg:p.labelShowBg,labelBgStyle:p.labelBgStyle,labelBgPadding:p.labelBgPadding,labelBgBorderRadius:p.labelBgBorderRadius,style:p.style,source:p.source,target:p.target,sourceHandleId:p.sourceHandle,targetHandleId:p.targetHandle,markerEnd:p.markerEnd,markerStart:p.markerStart,sourceX:ae,sourceY:se,targetX:Y,targetY:ne,sourcePosition:X,targetPosition:q,elementsSelectable:w,onContextMenu:o,onMouseEnter:a,onMouseMove:l,onMouseLeave:c,onClick:u,onEdgeDoubleClick:d,onReconnect:m,onReconnectStart:f,onReconnectEnd:y,reconnectRadius:x,rfId:r,ariaLabel:p.ariaLabel,isFocusable:J,isReconnectable:K,pathOptions:"pathOptions"in p?p.pathOptions:void 0,interactionWidth:p.interactionWidth,disableKeyboardA11y:g})})))),_):null};ko.displayName="EdgeRenderer";var kh=b.memo(ko);const jh=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Ch({children:e}){const t=re(jh);return $.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function $h(e){const t=An(),n=b.useRef(!1);b.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const Mh={[U.Left]:U.Right,[U.Right]:U.Left,[U.Top]:U.Bottom,[U.Bottom]:U.Top},jo=({nodeId:e,handleType:t,style:n,type:r=Ve.Bezier,CustomComponent:s,connectionStatus:i})=>{var C,A,F;const{fromNode:o,handleId:a,toX:l,toY:c,connectionMode:u}=re(b.useCallback(S=>({fromNode:S.nodeInternals.get(e),handleId:S.connectionHandleId,toX:(S.connectionPosition.x-S.transform[0])/S.transform[2],toY:(S.connectionPosition.y-S.transform[1])/S.transform[2],connectionMode:S.connectionMode}),[e]),fe),d=(C=o==null?void 0:o[ie])==null?void 0:C.handleBounds;let m=d==null?void 0:d[t];if(u===it.Loose&&(m=m||(d==null?void 0:d[t==="source"?"target":"source"])),!o||!m)return null;const f=a?m.find(S=>S.id===a):m[0],y=f?f.x+f.width/2:(o.width??0)/2,x=f?f.y+f.height/2:o.height??0,_=(((A=o.positionAbsolute)==null?void 0:A.x)??0)+y,g=(((F=o.positionAbsolute)==null?void 0:F.y)??0)+x,v=f==null?void 0:f.position,j=v?Mh[v]:null;if(!v||!j)return null;if(s)return $.createElement(s,{connectionLineType:r,connectionLineStyle:n,fromNode:o,fromHandle:f,fromX:_,fromY:g,toX:l,toY:c,fromPosition:v,toPosition:j,connectionStatus:i});let w="";const M={sourceX:_,sourceY:g,sourcePosition:v,targetX:l,targetY:c,targetPosition:j};return r===Ve.Bezier?[w]=Ki(M):r===Ve.Step?[w]=wn({...M,borderRadius:0}):r===Ve.SmoothStep?[w]=wn(M):r===Ve.SimpleBezier?[w]=Zi(M):w=`M${_},${g} ${l},${c}`,$.createElement("path",{d:w,fill:"none",className:"react-flow__connection-path",style:n})};jo.displayName="ConnectionLine";const Ah=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function Ih({containerStyle:e,style:t,type:n,component:r}){const{nodeId:s,handleType:i,nodesConnectable:o,width:a,height:l,connectionStatus:c}=re(Ah,fe);return!(s&&i&&a&&o)?null:$.createElement("svg",{style:e,width:a,height:l,className:"react-flow__edges react-flow__connectionline react-flow__container"},$.createElement("g",{className:he(["react-flow__connection",c])},$.createElement(jo,{nodeId:s,handleType:i,style:t,type:n,CustomComponent:r,connectionStatus:c})))}function Is(e,t){return b.useRef(null),de(),b.useMemo(()=>t(e),[e])}const Co=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:r,onMoveEnd:s,onInit:i,onNodeClick:o,onEdgeClick:a,onNodeDoubleClick:l,onEdgeDoubleClick:c,onNodeMouseEnter:u,onNodeMouseMove:d,onNodeMouseLeave:m,onNodeContextMenu:f,onSelectionContextMenu:y,onSelectionStart:x,onSelectionEnd:_,connectionLineType:g,connectionLineStyle:v,connectionLineComponent:j,connectionLineContainerStyle:w,selectionKeyCode:M,selectionOnDrag:C,selectionMode:A,multiSelectionKeyCode:F,panActivationKeyCode:S,zoomActivationKeyCode:O,deleteKeyCode:z,onlyRenderVisibleElements:G,elementsSelectable:V,selectNodesOnDrag:p,defaultViewport:k,translateExtent:E,minZoom:T,maxZoom:D,preventScrolling:N,defaultMarkerColor:I,zoomOnScroll:L,zoomOnPinch:P,panOnScroll:R,panOnScrollSpeed:H,panOnScrollMode:B,zoomOnDoubleClick:X,panOnDrag:q,onPaneClick:J,onPaneMouseEnter:Q,onPaneMouseMove:K,onPaneMouseLeave:ae,onPaneScroll:se,onPaneContextMenu:Y,onEdgeContextMenu:ne,onEdgeMouseEnter:te,onEdgeMouseMove:le,onEdgeMouseLeave:ee,onReconnect:W,onReconnectStart:pe,onReconnectEnd:Me,reconnectRadius:Nt,noDragClassName:at,noWheelClassName:lt,noPanClassName:Ae,elevateEdgesOnSelect:ct,disableKeyboardA11y:We,nodeOrigin:Ue,nodeExtent:ut,rfId:dt})=>{const St=Is(e,oh),me=Is(t,hh);return $h(i),$.createElement(sh,{onPaneClick:J,onPaneMouseEnter:Q,onPaneMouseMove:K,onPaneMouseLeave:ae,onPaneContextMenu:Y,onPaneScroll:se,deleteKeyCode:z,selectionKeyCode:M,selectionOnDrag:C,selectionMode:A,onSelectionStart:x,onSelectionEnd:_,multiSelectionKeyCode:F,panActivationKeyCode:S,zoomActivationKeyCode:O,elementsSelectable:V,onMove:n,onMoveStart:r,onMoveEnd:s,zoomOnScroll:L,zoomOnPinch:P,zoomOnDoubleClick:X,panOnScroll:R,panOnScrollSpeed:H,panOnScrollMode:B,panOnDrag:q,defaultViewport:k,translateExtent:E,minZoom:T,maxZoom:D,onSelectionContextMenu:y,preventScrolling:N,noDragClassName:at,noWheelClassName:lt,noPanClassName:Ae,disableKeyboardA11y:We},$.createElement(Ch,null,$.createElement(kh,{edgeTypes:me,onEdgeClick:a,onEdgeDoubleClick:c,onlyRenderVisibleElements:G,onEdgeContextMenu:ne,onEdgeMouseEnter:te,onEdgeMouseMove:le,onEdgeMouseLeave:ee,onReconnect:W,onReconnectStart:pe,onReconnectEnd:Me,reconnectRadius:Nt,defaultMarkerColor:I,noPanClassName:Ae,elevateEdgesOnSelect:!!ct,disableKeyboardA11y:We,rfId:dt},$.createElement(Ih,{style:v,type:g,component:j,containerStyle:w})),$.createElement("div",{className:"react-flow__edgelabel-renderer"}),$.createElement(ch,{nodeTypes:St,onNodeClick:o,onNodeDoubleClick:l,onNodeMouseEnter:u,onNodeMouseMove:d,onNodeMouseLeave:m,onNodeContextMenu:f,selectNodesOnDrag:p,onlyRenderVisibleElements:G,noPanClassName:Ae,noDragClassName:at,disableKeyboardA11y:We,nodeOrigin:Ue,nodeExtent:ut,rfId:dt})))};Co.displayName="GraphView";var Th=b.memo(Co);const mr=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ze={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:mr,nodeExtent:mr,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:it.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:of,isValidConnection:void 0},Rh=()=>bl((e,t)=>({...ze,setNodes:n=>{const{nodeInternals:r,nodeOrigin:s,elevateNodesOnSelect:i}=t();e({nodeInternals:Bn(n,r,s,i)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:r={}}=t();e({edges:n.map(s=>({...r,...s}))})},setDefaultNodesAndEdges:(n,r)=>{const s=typeof n<"u",i=typeof r<"u",o=s?Bn(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:o,edges:i?r:[],hasDefaultNodes:s,hasDefaultEdges:i})},updateNodeDimensions:n=>{const{onNodesChange:r,nodeInternals:s,fitViewOnInit:i,fitViewOnInitDone:o,fitViewOnInitOptions:a,domNode:l,nodeOrigin:c}=t(),u=l==null?void 0:l.querySelector(".react-flow__viewport");if(!u)return;const d=window.getComputedStyle(u),{m22:m}=new window.DOMMatrixReadOnly(d.transform),f=n.reduce((x,_)=>{const g=s.get(_.id);if(g!=null&&g.hidden)s.set(g.id,{...g,[ie]:{...g[ie],handleBounds:void 0}});else if(g){const v=Nr(_.nodeElement);!!(v.width&&v.height&&(g.width!==v.width||g.height!==v.height||_.forceUpdate))&&(s.set(g.id,{...g,[ie]:{...g[ie],handleBounds:{source:Ss(".source",_.nodeElement,m,c),target:Ss(".target",_.nodeElement,m,c)}},...v}),x.push({id:g.id,type:"dimensions",dimensions:v}))}return x},[]);go(s,c);const y=o||i&&!o&&yo(t,{initial:!0,...a});e({nodeInternals:new Map(s),fitViewOnInitDone:y}),(f==null?void 0:f.length)>0&&(r==null||r(f))},updateNodePositions:(n,r=!0,s=!1)=>{const{triggerNodeChanges:i}=t(),o=n.map(a=>{const l={id:a.id,type:"position",dragging:s};return r&&(l.positionAbsolute=a.positionAbsolute,l.position=a.position),l});i(o)},triggerNodeChanges:n=>{const{onNodesChange:r,nodeInternals:s,hasDefaultNodes:i,nodeOrigin:o,getNodes:a,elevateNodesOnSelect:l}=t();if(n!=null&&n.length){if(i){const c=qf(n,a()),u=Bn(c,s,o,l);e({nodeInternals:u})}r==null||r(n)}},addSelectedNodes:n=>{const{multiSelectionActive:r,edges:s,getNodes:i}=t();let o,a=null;r?o=n.map(l=>Fe(l,!0)):(o=gt(i(),n),a=gt(s,[])),rn({changedNodes:o,changedEdges:a,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:r,edges:s,getNodes:i}=t();let o,a=null;r?o=n.map(l=>Fe(l,!0)):(o=gt(s,n),a=gt(i(),[])),rn({changedNodes:a,changedEdges:o,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:r}={})=>{const{edges:s,getNodes:i}=t(),o=n||i(),a=r||s,l=o.map(u=>(u.selected=!1,Fe(u.id,!1))),c=a.map(u=>Fe(u.id,!1));rn({changedNodes:l,changedEdges:c,get:t,set:e})},setMinZoom:n=>{const{d3Zoom:r,maxZoom:s}=t();r==null||r.scaleExtent([n,s]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:r,minZoom:s}=t();r==null||r.scaleExtent([s,n]),e({maxZoom:n})},setTranslateExtent:n=>{var r;(r=t().d3Zoom)==null||r.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:r}=t(),i=r().filter(a=>a.selected).map(a=>Fe(a.id,!1)),o=n.filter(a=>a.selected).map(a=>Fe(a.id,!1));rn({changedNodes:i,changedEdges:o,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:r}=t();r.forEach(s=>{s.positionAbsolute=Sr(s.position,n)}),e({nodeExtent:n,nodeInternals:new Map(r)})},panBy:n=>{const{transform:r,width:s,height:i,d3Zoom:o,d3Selection:a,translateExtent:l}=t();if(!o||!a||!n.x&&!n.y)return!1;const c=De.translate(r[0]+n.x,r[1]+n.y).scale(r[2]),u=[[0,0],[s,i]],d=o==null?void 0:o.constrain()(c,u,l);return o.transform(a,d),r[0]!==d.x||r[1]!==d.y||r[2]!==d.k},cancelConnection:()=>e({connectionNodeId:ze.connectionNodeId,connectionHandleId:ze.connectionHandleId,connectionHandleType:ze.connectionHandleType,connectionStatus:ze.connectionStatus,connectionStartHandle:ze.connectionStartHandle,connectionEndHandle:ze.connectionEndHandle}),reset:()=>e({...ze})}),Object.is),$o=({children:e})=>{const t=b.useRef(null);return t.current||(t.current=Rh()),$.createElement(Qd,{value:t.current},e)};$o.displayName="ReactFlowProvider";const Mo=({children:e})=>b.useContext(Cn)?$.createElement($.Fragment,null,e):$.createElement($o,null,e);Mo.displayName="ReactFlowWrapper";const Oh={input:lo,default:fr,output:uo,group:Ar},Dh={default:bn,straight:Cr,step:jr,smoothstep:$n,simplebezier:kr},Lh=[0,0],Ph=[15,15],zh={x:0,y:0,zoom:1},Hh={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},Ao=b.forwardRef(({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:i=Oh,edgeTypes:o=Dh,onNodeClick:a,onEdgeClick:l,onInit:c,onMove:u,onMoveStart:d,onMoveEnd:m,onConnect:f,onConnectStart:y,onConnectEnd:x,onClickConnectStart:_,onClickConnectEnd:g,onNodeMouseEnter:v,onNodeMouseMove:j,onNodeMouseLeave:w,onNodeContextMenu:M,onNodeDoubleClick:C,onNodeDragStart:A,onNodeDrag:F,onNodeDragStop:S,onNodesDelete:O,onEdgesDelete:z,onSelectionChange:G,onSelectionDragStart:V,onSelectionDrag:p,onSelectionDragStop:k,onSelectionContextMenu:E,onSelectionStart:T,onSelectionEnd:D,connectionMode:N=it.Strict,connectionLineType:I=Ve.Bezier,connectionLineStyle:L,connectionLineComponent:P,connectionLineContainerStyle:R,deleteKeyCode:H="Backspace",selectionKeyCode:B="Shift",selectionOnDrag:X=!1,selectionMode:q=Gt.Full,panActivationKeyCode:J="Space",multiSelectionKeyCode:Q=yn()?"Meta":"Control",zoomActivationKeyCode:K=yn()?"Meta":"Control",snapToGrid:ae=!1,snapGrid:se=Ph,onlyRenderVisibleElements:Y=!1,selectNodesOnDrag:ne=!0,nodesDraggable:te,nodesConnectable:le,nodesFocusable:ee,nodeOrigin:W=Lh,edgesFocusable:pe,edgesUpdatable:Me,elementsSelectable:Nt,defaultViewport:at=zh,minZoom:lt=.5,maxZoom:Ae=2,translateExtent:ct=mr,preventScrolling:We=!0,nodeExtent:Ue,defaultMarkerColor:ut="#b1b1b7",zoomOnScroll:dt=!0,zoomOnPinch:St=!0,panOnScroll:me=!1,panOnScrollSpeed:_e=.5,panOnScrollMode:Xe=tt.Free,zoomOnDoubleClick:qe=!0,panOnDrag:Ze=!0,onPaneClick:Ie,onPaneMouseEnter:je,onPaneMouseMove:kt,onPaneMouseLeave:Rn,onPaneScroll:jt,onPaneContextMenu:On,children:Hr,onEdgeContextMenu:Ke,onEdgeDoubleClick:ma,onEdgeMouseEnter:pa,onEdgeMouseMove:ga,onEdgeMouseLeave:ya,onEdgeUpdate:xa,onEdgeUpdateStart:wa,onEdgeUpdateEnd:ba,onReconnect:va,onReconnectStart:_a,onReconnectEnd:Ea,reconnectRadius:Na=10,edgeUpdaterRadius:Sa=10,onNodesChange:ka,onEdgesChange:ja,noDragClassName:Ca="nodrag",noWheelClassName:$a="nowheel",noPanClassName:Fr="nopan",fitView:Ma=!1,fitViewOptions:Aa,connectOnClick:Ia=!0,attributionPosition:Ta,proOptions:Ra,defaultEdgeOptions:Oa,elevateNodesOnSelect:Da=!0,elevateEdgesOnSelect:La=!1,disableKeyboardA11y:Vr=!1,autoPanOnConnect:Pa=!0,autoPanOnNodeDrag:za=!0,connectionRadius:Ha=20,isValidConnection:Fa,onError:Va,style:Ba,id:Br,nodeDragThreshold:Ga,...Ya},Wa)=>{const Dn=Br||"1";return $.createElement("div",{...Ya,style:{...Ba,...Hh},ref:Wa,className:he(["react-flow",s]),"data-testid":"rf__wrapper",id:Br},$.createElement(Mo,null,$.createElement(Th,{onInit:c,onMove:u,onMoveStart:d,onMoveEnd:m,onNodeClick:a,onEdgeClick:l,onNodeMouseEnter:v,onNodeMouseMove:j,onNodeMouseLeave:w,onNodeContextMenu:M,onNodeDoubleClick:C,nodeTypes:i,edgeTypes:o,connectionLineType:I,connectionLineStyle:L,connectionLineComponent:P,connectionLineContainerStyle:R,selectionKeyCode:B,selectionOnDrag:X,selectionMode:q,deleteKeyCode:H,multiSelectionKeyCode:Q,panActivationKeyCode:J,zoomActivationKeyCode:K,onlyRenderVisibleElements:Y,selectNodesOnDrag:ne,defaultViewport:at,translateExtent:ct,minZoom:lt,maxZoom:Ae,preventScrolling:We,zoomOnScroll:dt,zoomOnPinch:St,zoomOnDoubleClick:qe,panOnScroll:me,panOnScrollSpeed:_e,panOnScrollMode:Xe,panOnDrag:Ze,onPaneClick:Ie,onPaneMouseEnter:je,onPaneMouseMove:kt,onPaneMouseLeave:Rn,onPaneScroll:jt,onPaneContextMenu:On,onSelectionContextMenu:E,onSelectionStart:T,onSelectionEnd:D,onEdgeContextMenu:Ke,onEdgeDoubleClick:ma,onEdgeMouseEnter:pa,onEdgeMouseMove:ga,onEdgeMouseLeave:ya,onReconnect:va??xa,onReconnectStart:_a??wa,onReconnectEnd:Ea??ba,reconnectRadius:Na??Sa,defaultMarkerColor:ut,noDragClassName:Ca,noWheelClassName:$a,noPanClassName:Fr,elevateEdgesOnSelect:La,rfId:Dn,disableKeyboardA11y:Vr,nodeOrigin:W,nodeExtent:Ue}),$.createElement($f,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:f,onConnectStart:y,onConnectEnd:x,onClickConnectStart:_,onClickConnectEnd:g,nodesDraggable:te,nodesConnectable:le,nodesFocusable:ee,edgesFocusable:pe,edgesUpdatable:Me,elementsSelectable:Nt,elevateNodesOnSelect:Da,minZoom:lt,maxZoom:Ae,nodeExtent:Ue,onNodesChange:ka,onEdgesChange:ja,snapToGrid:ae,snapGrid:se,connectionMode:N,translateExtent:ct,connectOnClick:Ia,defaultEdgeOptions:Oa,fitView:Ma,fitViewOptions:Aa,onNodesDelete:O,onEdgesDelete:z,onNodeDragStart:A,onNodeDrag:F,onNodeDragStop:S,onSelectionDrag:p,onSelectionDragStart:V,onSelectionDragStop:k,noPanClassName:Fr,nodeOrigin:W,rfId:Dn,autoPanOnConnect:Pa,autoPanOnNodeDrag:za,onError:Va,connectionRadius:Ha,isValidConnection:Fa,nodeDragThreshold:Ga}),$.createElement(jf,{onSelectionChange:G}),Hr,$.createElement(ef,{proOptions:Ra,position:Ta}),$.createElement(Rf,{rfId:Dn,disableKeyboardA11y:Vr})))});Ao.displayName="ReactFlow";const Io=({id:e,x:t,y:n,width:r,height:s,style:i,color:o,strokeColor:a,strokeWidth:l,className:c,borderRadius:u,shapeRendering:d,onClick:m,selected:f})=>{const{background:y,backgroundColor:x}=i||{},_=o||y||x;return $.createElement("rect",{className:he(["react-flow__minimap-node",{selected:f},c]),x:t,y:n,rx:u,ry:u,width:r,height:s,fill:_,stroke:a,strokeWidth:l,shapeRendering:d,onClick:m?g=>m(g,e):void 0})};Io.displayName="MiniMapNode";var Fh=b.memo(Io);const Vh=e=>e.nodeOrigin,Bh=e=>e.getNodes().filter(t=>!t.hidden&&t.width&&t.height),Un=e=>e instanceof Function?e:()=>e;function Gh({nodeStrokeColor:e="transparent",nodeColor:t="#e2e2e2",nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s=2,nodeComponent:i=Fh,onClick:o}){const a=re(Bh,fe),l=re(Vh),c=Un(t),u=Un(e),d=Un(n),m=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return $.createElement($.Fragment,null,a.map(f=>{const{x:y,y:x}=rt(f,l).positionAbsolute;return $.createElement(i,{key:f.id,x:y,y:x,width:f.width,height:f.height,style:f.style,selected:f.selected,className:d(f),color:c(f),borderRadius:r,strokeColor:u(f),strokeWidth:s,shapeRendering:m,onClick:o,id:f.id})}))}var Yh=b.memo(Gh);const Wh=200,Uh=150,Xh=e=>{const t=e.getNodes(),n={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:n,boundingRect:t.length>0?rf(Mn(t,e.nodeOrigin),n):n,rfId:e.rfId}},qh="react-flow__minimap-desc";function To({style:e,className:t,nodeStrokeColor:n="transparent",nodeColor:r="#e2e2e2",nodeClassName:s="",nodeBorderRadius:i=5,nodeStrokeWidth:o=2,nodeComponent:a,maskColor:l="rgb(240, 240, 240, 0.6)",maskStrokeColor:c="none",maskStrokeWidth:u=1,position:d="bottom-right",onClick:m,onNodeClick:f,pannable:y=!1,zoomable:x=!1,ariaLabel:_="React Flow mini map",inversePan:g=!1,zoomStep:v=10,offsetScale:j=5}){const w=de(),M=b.useRef(null),{boundingRect:C,viewBB:A,rfId:F}=re(Xh,fe),S=(e==null?void 0:e.width)??Wh,O=(e==null?void 0:e.height)??Uh,z=C.width/S,G=C.height/O,V=Math.max(z,G),p=V*S,k=V*O,E=j*V,T=C.x-(p-C.width)/2-E,D=C.y-(k-C.height)/2-E,N=p+E*2,I=k+E*2,L=`${qh}-${F}`,P=b.useRef(0);P.current=V,b.useEffect(()=>{if(M.current){const B=xe(M.current),X=Q=>{const{transform:K,d3Selection:ae,d3Zoom:se}=w.getState();if(Q.sourceEvent.type!=="wheel"||!ae||!se)return;const Y=-Q.sourceEvent.deltaY*(Q.sourceEvent.deltaMode===1?.05:Q.sourceEvent.deltaMode?1:.002)*v,ne=K[2]*Math.pow(2,Y);se.scaleTo(ae,ne)},q=Q=>{const{transform:K,d3Selection:ae,d3Zoom:se,translateExtent:Y,width:ne,height:te}=w.getState();if(Q.sourceEvent.type!=="mousemove"||!ae||!se)return;const le=P.current*Math.max(1,K[2])*(g?-1:1),ee={x:K[0]-Q.sourceEvent.movementX*le,y:K[1]-Q.sourceEvent.movementY*le},W=[[0,0],[ne,te]],pe=De.translate(ee.x,ee.y).scale(K[2]),Me=se.constrain()(pe,W,Y);se.transform(ae,Me)},J=Hi().on("zoom",y?q:null).on("zoom.wheel",x?X:null);return B.call(J),()=>{B.on("zoom",null)}}},[y,x,g,v]);const R=m?B=>{const X=Ee(B);m(B,{x:X[0],y:X[1]})}:void 0,H=f?(B,X)=>{const q=w.getState().nodeInternals.get(X);f(B,q)}:void 0;return $.createElement(Er,{position:d,style:e,className:he(["react-flow__minimap",t]),"data-testid":"rf__minimap"},$.createElement("svg",{width:S,height:O,viewBox:`${T} ${D} ${N} ${I}`,role:"img","aria-labelledby":L,ref:M,onClick:R},_&&$.createElement("title",{id:L},_),$.createElement(Yh,{onClick:H,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:s,nodeStrokeWidth:o,nodeComponent:a}),$.createElement("path",{className:"react-flow__minimap-mask",d:`M${T-E},${D-E}h${N+E*2}v${I+E*2}h${-N-E*2}z + M${A.x},${A.y}h${A.width}v${A.height}h${-A.width}z`,fill:l,fillRule:"evenodd",stroke:c,strokeWidth:u,pointerEvents:"none"})))}To.displayName="MiniMap";var Zh=b.memo(To);function Kh(){return $.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},$.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function Qh(){return $.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},$.createElement("path",{d:"M0 0h32v4.2H0z"}))}function Jh(){return $.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},$.createElement("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"}))}function em(){return $.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},$.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"}))}function tm(){return $.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},$.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"}))}const Ot=({children:e,className:t,...n})=>$.createElement("button",{type:"button",className:he(["react-flow__controls-button",t]),...n},e);Ot.displayName="ControlButton";const nm=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),Ro=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:i,onZoomOut:o,onFitView:a,onInteractiveChange:l,className:c,children:u,position:d="bottom-left"})=>{const m=de(),[f,y]=b.useState(!1),{isInteractive:x,minZoomReached:_,maxZoomReached:g}=re(nm,fe),{zoomIn:v,zoomOut:j,fitView:w}=An();if(b.useEffect(()=>{y(!0)},[]),!f)return null;const M=()=>{v(),i==null||i()},C=()=>{j(),o==null||o()},A=()=>{w(s),a==null||a()},F=()=>{m.setState({nodesDraggable:!x,nodesConnectable:!x,elementsSelectable:!x}),l==null||l(!x)};return $.createElement(Er,{className:he(["react-flow__controls",c]),position:d,style:e,"data-testid":"rf__controls"},t&&$.createElement($.Fragment,null,$.createElement(Ot,{onClick:M,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:g},$.createElement(Kh,null)),$.createElement(Ot,{onClick:C,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:_},$.createElement(Qh,null))),n&&$.createElement(Ot,{className:"react-flow__controls-fitview",onClick:A,title:"fit view","aria-label":"fit view"},$.createElement(Jh,null)),r&&$.createElement(Ot,{className:"react-flow__controls-interactive",onClick:F,title:"toggle interactivity","aria-label":"toggle interactivity"},x?$.createElement(tm,null):$.createElement(em,null)),u)};Ro.displayName="Controls";var rm=b.memo(Ro),be;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(be||(be={}));function sm({color:e,dimensions:t,lineWidth:n}){return $.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function im({color:e,radius:t}){return $.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const om={[be.Dots]:"#91919a",[be.Lines]:"#eee",[be.Cross]:"#e2e2e2"},am={[be.Dots]:1,[be.Lines]:1,[be.Cross]:6},lm=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Oo({id:e,variant:t=be.Dots,gap:n=20,size:r,lineWidth:s=1,offset:i=2,color:o,style:a,className:l}){const c=b.useRef(null),{transform:u,patternId:d}=re(lm,fe),m=o||om[t],f=r||am[t],y=t===be.Dots,x=t===be.Cross,_=Array.isArray(n)?n:[n,n],g=[_[0]*u[2]||1,_[1]*u[2]||1],v=f*u[2],j=x?[v,v]:g,w=y?[v/i,v/i]:[j[0]/i,j[1]/i];return $.createElement("svg",{className:he(["react-flow__background",l]),style:{...a,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:c,"data-testid":"rf__background"},$.createElement("pattern",{id:d+e,x:u[0]%g[0],y:u[1]%g[1],width:g[0],height:g[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${w[0]},-${w[1]})`},y?$.createElement(im,{color:m,radius:v/i}):$.createElement(sm,{dimensions:j,color:m,lineWidth:s})),$.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${d+e})`}))}Oo.displayName="Background";var cm=b.memo(Oo);const Tr=(()=>{const e=window.location.pathname.match(/^(\/view\/[^/]+)(?:\/|$)/);return e?e[1]:""})();function Do(e){return Tr+e}async function ue(e){const t=await fetch(Do(e));if(!t.ok)throw new Error(`${e}: ${t.status} ${await t.text()}`);return await t.json()}async function Ye(e,t){const n=await fetch(Do(e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await n.json();if(!n.ok)throw new Lo(r.error??`${e}: ${n.status}`,n.status);return r}class Lo extends Error{constructor(n,r){super(n);oe(this,"status");this.status=r}}const ex=e=>ue(e?`/api/model?subject_area=${encodeURIComponent(e)}`:"/api/model"),tx=()=>ue("/api/diagnostics"),Po=(e,t)=>ue(`/api/ontology/search?q=${encodeURIComponent(e)}`+(t?`&within=${encodeURIComponent(t)}`:"")),zo=()=>ue("/api/ontology/ontologies"),um=e=>ue(`/api/ontology/term?ref=${encodeURIComponent(e)}`),dm=()=>ue("/api/ontology/stack"),fm=()=>ue("/api/ontology/coverage"),nx=(e,t,n)=>Ye("/api/command",{op:e,payload:t,fingerprint:n}),hm=()=>ue("/api/git/status"),mm=()=>ue("/api/git/diff"),pm=e=>Ye("/api/git/commit",{message:e}),gm=()=>Ye("/api/git/discard",{}),ym=()=>ue("/api/decisions"),Ts=(e,t)=>Ye(`/api/decisions/${e}/verdict`,{verdict:t}),rx=(e={})=>{const t=new URLSearchParams;return e.subject_area&&t.set("subject_area",e.subject_area),e.q&&t.set("q",e.q),ue(`/api/glossary/terms?${t.toString()}`)},sx=()=>ue("/api/glossary/config"),ix=e=>Ye("/api/git/propose",e),ox=(e="HEAD")=>ue(`/api/git/diff/model?base=${encodeURIComponent(e)}`),ax=(e="HEAD")=>ue(`/api/git/classify?base=${encodeURIComponent(e)}`),lx=e=>Ye("/api/git/classify",{changes:e}),cx=e=>ue(`/api/git/conflicts?base=${encodeURIComponent(e)}`),ux=(e="")=>ue(`/api/git/context?user=${encodeURIComponent(e)}`),dx=(e="")=>ue(`/api/git/proposals?user=${encodeURIComponent(e)}`),fx=()=>ue("/api/export"),hx=(e,t)=>{const n=t?`?dialect=${encodeURIComponent(t)}`:"";return`${Tr}/api/export/${encodeURIComponent(e)}${n}`},mx=(e,t,n)=>Ye("/api/import",{format:e,content:t,dialect:n}),px=(e,t,n)=>fetch(`${Tr}/api/preview`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({changes:e,subject_area:t??""}),signal:n}).then(async r=>{if(!r.ok)throw new Lo(await r.text(),r.status);return await r.json()}),gx=()=>ue("/api/glossary/subject-areas"),yx=e=>ue(`/api/glossary/subject-area/${e}`),xx=(e,t)=>Ye(`/api/glossary/subject-area/${e}/expand`,t),xm={business_key:"🔑",surrogate_key:"#",measure:"Σ",attribute:""};function wm(e){return e??""}const Rr="__entity_source",Or="__entity_target",bm=b.memo(function({data:t,selected:n}){var g;const{entity:r,color:s,dimmed:i,highlighted:o,showTypes:a,endpointAttrs:l,highlightAttrs:c,dimAttrs:u,onHoverAttr:d}=t,m=v=>v.role==="business_key"?0:l!=null&&l.has(v.id)?1:2,f=[...r.attributes].map((v,j)=>({a:v,i:j})).sort((v,j)=>m(v.a)-m(j.a)||v.i-j.i).map(v=>v.a),y=f.filter(v=>v.role==="business_key"),x=f.filter(v=>v.role!=="business_key"),_=(v,j)=>{const w="attr-row"+(c!=null&&c.has(v.id)?" rel-hit":"")+(u!=null&&u.has(v.id)?" rel-dim":"")+(l!=null&&l.has(v.id)?" endpoint":"");return h.jsxs("div",{className:w,onMouseEnter:d?()=>d(v.id):void 0,onMouseLeave:d?()=>d(null):void 0,children:[h.jsx(Be,{id:v.id,type:"target",position:U.Left,className:"port attr-port"}),h.jsx(Be,{id:v.id,type:"source",position:U.Right,className:"port attr-port"}),h.jsx("span",{className:"attr-icon",children:xm[v.role]}),h.jsx("span",{className:"attr-name"+(j?" pk":""),children:v.name}),a&&h.jsx("span",{className:"attr-type",children:wm(v.domain)}),!v.nullable&&h.jsx("span",{className:"attr-notnull",title:"not null",children:"●"})]},v.id)};return h.jsxs("div",{className:"entity-node"+(n?" selected":"")+(i?" dimmed":"")+(o?" highlighted":""),style:{borderTopColor:s},children:[h.jsx(Be,{id:Or,type:"target",position:U.Left,className:"port"}),h.jsx(Be,{id:Rr,type:"source",position:U.Right,className:"port"}),h.jsxs("div",{className:"entity-header",children:[h.jsx("span",{className:"entity-name",title:((g=r.conceptual)==null?void 0:g.definition)??void 0,children:r.name}),h.jsxs("span",{className:"entity-badges",children:[r.pattern&&h.jsx("span",{className:"badge pattern",children:r.pattern}),(()=>{var w;const v=(((w=r.conceptual)==null?void 0:w.ontology_refs)??[]).filter(M=>M.uri);if(v.length===0)return null;const j=v.map(M=>M.uri).join(` +`);return h.jsxs("span",{className:"badge ontology",title:j,children:["⚙",v.length>1?` ${v.length}`:""]})})()]})]}),y.length>0&&h.jsx("div",{className:"attr-section keys",children:y.map(v=>_(v,!0))}),h.jsxs("div",{className:"attr-section",children:[x.map(v=>_(v,!1)),r.attributes.length===0&&h.jsx("div",{className:"attr-row empty",children:"no attributes"})]})]})}),vm=["string","integer","bigint","decimal","boolean","date","timestamp"];function _m({entity:e,doc:t,caps:n,exec:r,onClose:s,onFocusEntity:i,onAlign:o,onEditMapping:a}){var m,f,y,x,_,g,v,j,w,M,C,A,F;const l=!n.canEdit,c=e.conceptual,u=t.relationships.filter(S=>S.from.entity===e.id||S.to.entity===e.id),d=S=>{var O;return((O=t.entities.find(z=>z.id===S))==null?void 0:O.name)??S};return h.jsxs("aside",{className:"detail-panel",children:[h.jsxs("div",{className:"detail-header",children:[h.jsxs("div",{style:{flex:1},children:[h.jsx(Dt,{value:e.name,className:"entity-title-input",readOnly:l,onCommit:S=>r("rename_entity",{id:e.id,name:S})}),h.jsxs("div",{children:[h.jsx(Nm,{entity:e,doc:t,readOnly:l,exec:r}),h.jsx(km,{entity:e,readOnly:l,exec:r}),e.category&&h.jsx("span",{className:"cat-badge "+e.category.role,title:e.category.role==="supertype"?`Supertype of category "${e.category.category}"`:`Subtype in "${e.category.category}" (${e.category.materialization})`,children:e.category.role==="supertype"?"◆ supertype":"◇ subtype"})]})]}),h.jsx("button",{className:"icon-btn",onClick:s,title:"Close",children:"✕"})]}),h.jsxs("section",{children:[h.jsx("h3",{children:"Definition"}),h.jsx(Dt,{value:((m=c==null?void 0:c.definition)==null?void 0:m.trim())??"",multiline:!0,placeholder:l?"—":"add a business definition…",className:"definition-input",readOnly:l,onCommit:S=>r("set_definition",{id:e.id,definition:S})})]}),h.jsxs("section",{children:[h.jsxs("h3",{children:["Ontology",!l&&h.jsxs("span",{className:"h3-actions",children:[h.jsx("button",{className:"mini-btn",onClick:()=>o(e),children:(((f=c==null?void 0:c.ontology_refs)==null?void 0:f.length)??0)>0?"Add / re-align…":"Align…"}),(((y=c==null?void 0:c.ontology_refs)==null?void 0:y.length)??0)>0&&h.jsx("button",{className:"mini-btn danger",onClick:()=>r("clear_alignment",{id:e.id}),title:"Clear every alignment on this object",children:"Clear all"})]})]}),(c==null?void 0:c.ontology_layer)&&h.jsxs("div",{className:"kv",children:[h.jsx("span",{className:"k",children:"layer"}),h.jsx("span",{className:`chip layer-${c.ontology_layer}`,children:c.ontology_layer}),c.no_industry_equivalent&&h.jsx("span",{className:"chip",title:"reviewed: no industry equivalent",children:"no industry equivalent"})]}),h.jsx(Em,{entityId:e.id,refs:(c==null?void 0:c.ontology_refs)??[],caps:n,exec:r})]}),h.jsxs("section",{children:[h.jsxs("h3",{children:["Knowledge Graph mapping",!l&&h.jsxs("span",{className:"h3-actions",children:[h.jsx("button",{className:"mini-btn",onClick:()=>a(e),children:(x=e.term_map)!=null&&x.subject_template||(_=e.term_map)!=null&&_.class_iri?"Edit mapping…":"Map…"}),(((g=e.term_map)==null?void 0:g.subject_template)||((v=e.term_map)==null?void 0:v.class_iri))&&h.jsx("button",{className:"mini-btn danger",onClick:()=>r("clear_term_map",{id:e.id}),children:"Clear"})]})]}),(j=e.term_map)!=null&&j.subject_template||(w=e.term_map)!=null&&w.class_iri?h.jsxs(h.Fragment,{children:[((M=e.term_map)==null?void 0:M.class_iri)&&h.jsxs("div",{className:"kv",children:[h.jsx("span",{className:"k",children:"class IRI"}),h.jsx("code",{className:"v",children:e.term_map.class_iri})]}),((C=e.term_map)==null?void 0:C.subject_template)&&h.jsxs("div",{className:"kv",children:[h.jsx("span",{className:"k",children:"subject"}),h.jsx("code",{className:"v",children:e.term_map.subject_template})]})]}):h.jsxs("p",{className:"empty-hint",children:["uses the default R2RML term-map (base IRI",t.project.kg_base_iri?` ${t.project.kg_base_iri}`:""," + primary key)"]})]}),h.jsxs("section",{children:[h.jsx("h3",{children:"Stewardship"}),h.jsxs("div",{className:"kv",children:[h.jsx("span",{className:"k",children:"owner"}),h.jsx(Dt,{value:((A=c==null?void 0:c.stewardship)==null?void 0:A.owner)??"",placeholder:"—",readOnly:l,onCommit:S=>{var O;return r("set_stewardship",{id:e.id,owner:S,steward:((O=c==null?void 0:c.stewardship)==null?void 0:O.steward)??null})}})]}),h.jsxs("div",{className:"kv",children:[h.jsx("span",{className:"k",children:"steward"}),h.jsx(Dt,{value:((F=c==null?void 0:c.stewardship)==null?void 0:F.steward)??"",placeholder:"—",readOnly:l,onCommit:S=>{var O;return r("set_stewardship",{id:e.id,owner:((O=c==null?void 0:c.stewardship)==null?void 0:O.owner)??null,steward:S})}})]})]}),h.jsxs("section",{children:[h.jsxs("h3",{children:["Attributes (",e.attributes.length,")"]}),h.jsx("table",{className:"attr-table",children:h.jsx("tbody",{children:e.attributes.map(S=>h.jsx(Cm,{a:S,entity:e,doc:t,readOnly:l,exec:r},S.id))})}),!l&&h.jsx($m,{entity:e,exec:r})]}),e.key_groups&&e.key_groups.length>0&&h.jsxs("section",{children:[h.jsxs("h3",{children:["Keys (",e.key_groups.length,")"]}),e.key_groups.map(S=>{const O=S.members.map(z=>{var G;return((G=e.attributes.find(V=>V.id===z))==null?void 0:G.name)??"?"}).join(", ");return h.jsxs("div",{className:"key-row",children:[h.jsx("span",{className:"key-badge "+S.type,children:S.type.toUpperCase()}),h.jsx("span",{className:"key-name",children:S.name}),h.jsx("span",{className:"key-cols",children:O})]},S.id)})]}),e.udp&&Object.keys(e.udp).length>0&&h.jsxs("section",{children:[h.jsx("h3",{children:"Properties (UDP)"}),h.jsx("table",{className:"attr-table",children:h.jsx("tbody",{children:Object.entries(e.udp).map(([S,O])=>h.jsxs("tr",{className:"udp-row",children:[h.jsx("td",{className:"udp-key",children:S}),h.jsx("td",{className:"udp-val",children:String(O)})]},S))})})]}),u.length>0&&h.jsxs("section",{children:[h.jsxs("h3",{children:["Relationships (",u.length,")"]}),u.map(S=>{const O=S.from.entity===e.id?S.to.entity:S.from.entity;return h.jsxs("div",{className:"rel-row",children:[h.jsxs("button",{className:"rel-link",onClick:()=>i(O),children:[h.jsx("span",{className:"rel-card",children:Mm(S,e.id)}),d(O)]}),!l&&h.jsx("button",{className:"mini-btn danger",title:`delete ${S.name}`,onClick:()=>r("delete_relationship",{id:S.id}),children:"✕"})]},S.id)})]}),h.jsxs("section",{children:[h.jsx("h3",{children:"Identity"}),h.jsx("code",{className:"ulid",title:"Immutable ULID — click to copy",onClick:()=>{var S;return(S=navigator.clipboard)==null?void 0:S.writeText(e.id)},children:e.id}),!l&&h.jsx("div",{style:{marginTop:12},children:h.jsx("button",{className:"mini-btn danger",onClick:()=>{confirm(`Delete entity '${e.name}' (and its relationships)?`)&&r("delete_entity",{id:e.id,cascade:!0}).then(s)},children:"Delete entity…"})})]})]})}function Em({entityId:e,refs:t,caps:n,exec:r}){const s=!n.canEdit,i=t.filter(o=>o.uri);return i.length===0?h.jsx("p",{className:"empty-hint",children:"not aligned to any ontology term"}):h.jsx("div",{className:"ref-list",children:i.map((o,a)=>{const l=o.status==="proposed";return h.jsxs("div",{className:"ref-card"+(l?" proposed":""),children:[h.jsxs("div",{className:"ref-head",children:[h.jsx("code",{className:"ref-uri",title:o.uri??void 0,children:o.uri}),h.jsx("span",{className:"ref-status "+(l?"proposed":"accepted"),children:l?"proposed":"accepted"})]}),h.jsxs("div",{className:"ref-meta",children:[o.predicate&&h.jsx("span",{className:"ref-pill",children:o.predicate}),o.layer&&h.jsx("span",{className:`chip layer-${o.layer}`,children:o.layer}),o.resolved_via&&h.jsxs("span",{className:"ref-via",title:"resolver that found this term",children:["via ",o.resolved_via]}),typeof o.confidence=="number"&&h.jsxs("span",{className:"ref-via",children:["conf ",Math.round(o.confidence*100),"%"]})]}),!s&&h.jsxs("div",{className:"ref-actions",children:[l&&n.canArbitrate&&h.jsx("button",{className:"mini-btn",onClick:()=>r("promote_alignment",{id:e,uri:o.uri}),title:"Accept this proposed alignment (architect action)",children:"Promote"}),h.jsx("button",{className:"mini-btn danger",onClick:()=>r("clear_alignment",{id:e,uri:o.uri}),title:"Remove this alignment",children:"Remove"})]})]},`${o.uri}-${a}`)})})}function Dt({value:e,onCommit:t,readOnly:n,multiline:r=!1,placeholder:s="",className:i=""}){const[o,a]=b.useState(e);b.useEffect(()=>a(e),[e]);const l=()=>{o.trim()!==e.trim()&&t(o.trim())};return n?h.jsx("span",{className:i,children:e||s}):r?h.jsx("textarea",{className:`edit-input ${i}`,value:o,placeholder:s,rows:3,onChange:c=>a(c.target.value),onBlur:l}):h.jsx("input",{className:`edit-input ${i}`,value:o,placeholder:s,onChange:c=>a(c.target.value),onBlur:l,onKeyDown:c=>c.key==="Enter"&&c.target.blur()})}function Nm({entity:e,doc:t,readOnly:n,exec:r}){var i,o,a;const s=((o=(i=e.conceptual)==null?void 0:i.subject_area)==null?void 0:o.id)??"";return n?(a=e.conceptual)!=null&&a.subject_area?h.jsx("span",{className:"chip",children:e.conceptual.subject_area.name}):null:h.jsxs("select",{className:"chip-select",value:s,onChange:l=>r("set_subject_area",{id:e.id,subject_area:l.target.value||null}),children:[h.jsx("option",{value:"",children:"no subject area"}),t.subject_areas.map(l=>h.jsx("option",{value:l.id,children:l.name},l.id))]})}const Sm=["","scd2","hub","link","satellite","bridge"];function km({entity:e,readOnly:t,exec:n}){return t?e.pattern?h.jsx("span",{className:"chip pattern",children:e.pattern}):null:h.jsx("select",{className:"chip-select",value:e.pattern??"",onChange:r=>n("set_pattern",{id:e.id,pattern:r.target.value||null}),children:Sm.map(r=>h.jsx("option",{value:r,children:r||"no pattern"},r))})}const jm=["attribute","business_key","measure","surrogate_key"];function Cm({a:e,entity:t,doc:n,readOnly:r,exec:s}){if(r)return h.jsxs("tr",{children:[h.jsxs("td",{className:e.role==="business_key"?"pk":"",children:[e.name,e.enum_values&&e.enum_values.length>0&&h.jsx("span",{className:"enum-badge",title:`Allowed: ${e.enum_values.join(", ")}`,children:"enum"})]}),h.jsx("td",{className:"type",children:e.domain??""}),h.jsx("td",{className:"null",children:e.nullable?"":"NN"})]});const i=o=>s("update_attribute",{entity_id:t.id,attribute_id:e.id,...o});return h.jsxs("tr",{children:[h.jsxs("td",{className:e.role==="business_key"?"pk":"",children:[h.jsx(Dt,{value:e.name,readOnly:!1,onCommit:o=>i({name:o})}),e.enum_values&&e.enum_values.length>0&&h.jsx("span",{className:"enum-badge",title:`Allowed: ${e.enum_values.join(", ")}`,children:"enum"})]}),h.jsx("td",{className:"type",children:h.jsx("select",{className:"cell-select",value:e.domain??"string",onChange:o=>i({domain:o.target.value}),children:[...new Set([...vm,...n.domains??[],e.domain??"string"])].sort().map(o=>h.jsx("option",{value:o,children:o},o))})}),h.jsx("td",{children:h.jsx("select",{className:"cell-select",value:e.role,onChange:o=>i({role:o.target.value}),title:"role",children:jm.map(o=>h.jsx("option",{value:o,children:o==="business_key"?"🔑 key":o==="measure"?"Σ measure":o},o))})}),h.jsx("td",{className:"null",children:h.jsx("input",{type:"checkbox",checked:!e.nullable,title:"not null",onChange:o=>i({nullable:!o.target.checked})})}),h.jsx("td",{children:h.jsx("button",{className:"mini-btn danger",title:"delete attribute",onClick:()=>s("delete_attribute",{entity_id:t.id,attribute_id:e.id}),children:"✕"})})]})}function $m({entity:e,exec:t}){const[n,r]=b.useState(""),s=()=>{n.trim()&&t("add_attribute",{entity_id:e.id,name:n,domain:"string"}).then(()=>r(""))};return h.jsxs("div",{className:"add-attr",children:[h.jsx("input",{className:"edit-input",placeholder:"+ add attribute…",value:n,onChange:i=>r(i.target.value),onKeyDown:i=>i.key==="Enter"&&s()}),n&&h.jsx("button",{className:"mini-btn",onClick:s,children:"Add"})]})}function Mm(e,t){const n=e.from.entity===t;switch(e.cardinality){case"many_to_one":return n?"N:1 →":"1:N ←";case"one_to_many":return n?"1:N →":"N:1 ←";case"one_to_one":return"1:1";default:return"N:M"}}var Am="\0",Qe="\0",Rs="";let Im=class{constructor(t){oe(this,"_isDirected",!0);oe(this,"_isMultigraph",!1);oe(this,"_isCompound",!1);oe(this,"_label");oe(this,"_defaultNodeLabelFn",()=>{});oe(this,"_defaultEdgeLabelFn",()=>{});oe(this,"_nodes",{});oe(this,"_in",{});oe(this,"_preds",{});oe(this,"_out",{});oe(this,"_sucs",{});oe(this,"_edgeObjs",{});oe(this,"_edgeLabels",{});oe(this,"_nodeCount",0);oe(this,"_edgeCount",0);oe(this,"_parent");oe(this,"_children");t&&(this._isDirected=Object.hasOwn(t,"directed")?t.directed:!0,this._isMultigraph=Object.hasOwn(t,"multigraph")?t.multigraph:!1,this._isCompound=Object.hasOwn(t,"compound")?t.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[Qe]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(t){return this._label=t,this}graph(){return this._label}setDefaultNodeLabel(t){return this._defaultNodeLabelFn=t,typeof t!="function"&&(this._defaultNodeLabelFn=()=>t),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var t=this;return this.nodes().filter(n=>Object.keys(t._in[n]).length===0)}sinks(){var t=this;return this.nodes().filter(n=>Object.keys(t._out[n]).length===0)}setNodes(t,n){var r=arguments,s=this;return t.forEach(function(i){r.length>1?s.setNode(i,n):s.setNode(i)}),this}setNode(t,n){return Object.hasOwn(this._nodes,t)?(arguments.length>1&&(this._nodes[t]=n),this):(this._nodes[t]=arguments.length>1?n:this._defaultNodeLabelFn(t),this._isCompound&&(this._parent[t]=Qe,this._children[t]={},this._children[Qe][t]=!0),this._in[t]={},this._preds[t]={},this._out[t]={},this._sucs[t]={},++this._nodeCount,this)}node(t){return this._nodes[t]}hasNode(t){return Object.hasOwn(this._nodes,t)}removeNode(t){var n=this;if(Object.hasOwn(this._nodes,t)){var r=s=>n.removeEdge(n._edgeObjs[s]);delete this._nodes[t],this._isCompound&&(this._removeFromParentsChildList(t),delete this._parent[t],this.children(t).forEach(function(s){n.setParent(s)}),delete this._children[t]),Object.keys(this._in[t]).forEach(r),delete this._in[t],delete this._preds[t],Object.keys(this._out[t]).forEach(r),delete this._out[t],delete this._sucs[t],--this._nodeCount}return this}setParent(t,n){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(n===void 0)n=Qe;else{n+="";for(var r=n;r!==void 0;r=this.parent(r))if(r===t)throw new Error("Setting "+n+" as parent of "+t+" would create a cycle");this.setNode(n)}return this.setNode(t),this._removeFromParentsChildList(t),this._parent[t]=n,this._children[n][t]=!0,this}_removeFromParentsChildList(t){delete this._children[this._parent[t]][t]}parent(t){if(this._isCompound){var n=this._parent[t];if(n!==Qe)return n}}children(t=Qe){if(this._isCompound){var n=this._children[t];if(n)return Object.keys(n)}else{if(t===Qe)return this.nodes();if(this.hasNode(t))return[]}}predecessors(t){var n=this._preds[t];if(n)return Object.keys(n)}successors(t){var n=this._sucs[t];if(n)return Object.keys(n)}neighbors(t){var n=this.predecessors(t);if(n){const s=new Set(n);for(var r of this.successors(t))s.add(r);return Array.from(s.values())}}isLeaf(t){var n;return this.isDirected()?n=this.successors(t):n=this.neighbors(t),n.length===0}filterNodes(t){var n=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});n.setGraph(this.graph());var r=this;Object.entries(this._nodes).forEach(function([o,a]){t(o)&&n.setNode(o,a)}),Object.values(this._edgeObjs).forEach(function(o){n.hasNode(o.v)&&n.hasNode(o.w)&&n.setEdge(o,r.edge(o))});var s={};function i(o){var a=r.parent(o);return a===void 0||n.hasNode(a)?(s[o]=a,a):a in s?s[a]:i(a)}return this._isCompound&&n.nodes().forEach(o=>n.setParent(o,i(o))),n}setDefaultEdgeLabel(t){return this._defaultEdgeLabelFn=t,typeof t!="function"&&(this._defaultEdgeLabelFn=()=>t),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(t,n){var r=this,s=arguments;return t.reduce(function(i,o){return s.length>1?r.setEdge(i,o,n):r.setEdge(i,o),o}),this}setEdge(){var t,n,r,s,i=!1,o=arguments[0];typeof o=="object"&&o!==null&&"v"in o?(t=o.v,n=o.w,r=o.name,arguments.length===2&&(s=arguments[1],i=!0)):(t=o,n=arguments[1],r=arguments[3],arguments.length>2&&(s=arguments[2],i=!0)),t=""+t,n=""+n,r!==void 0&&(r=""+r);var a=Lt(this._isDirected,t,n,r);if(Object.hasOwn(this._edgeLabels,a))return i&&(this._edgeLabels[a]=s),this;if(r!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(t),this.setNode(n),this._edgeLabels[a]=i?s:this._defaultEdgeLabelFn(t,n,r);var l=Tm(this._isDirected,t,n,r);return t=l.v,n=l.w,Object.freeze(l),this._edgeObjs[a]=l,Os(this._preds[n],t),Os(this._sucs[t],n),this._in[n][a]=l,this._out[t][a]=l,this._edgeCount++,this}edge(t,n,r){var s=arguments.length===1?Xn(this._isDirected,arguments[0]):Lt(this._isDirected,t,n,r);return this._edgeLabels[s]}edgeAsObj(){const t=this.edge(...arguments);return typeof t!="object"?{label:t}:t}hasEdge(t,n,r){var s=arguments.length===1?Xn(this._isDirected,arguments[0]):Lt(this._isDirected,t,n,r);return Object.hasOwn(this._edgeLabels,s)}removeEdge(t,n,r){var s=arguments.length===1?Xn(this._isDirected,arguments[0]):Lt(this._isDirected,t,n,r),i=this._edgeObjs[s];return i&&(t=i.v,n=i.w,delete this._edgeLabels[s],delete this._edgeObjs[s],Ds(this._preds[n],t),Ds(this._sucs[t],n),delete this._in[n][s],delete this._out[t][s],this._edgeCount--),this}inEdges(t,n){var r=this._in[t];if(r){var s=Object.values(r);return n?s.filter(i=>i.v===n):s}}outEdges(t,n){var r=this._out[t];if(r){var s=Object.values(r);return n?s.filter(i=>i.w===n):s}}nodeEdges(t,n){var r=this.inEdges(t,n);if(r)return r.concat(this.outEdges(t,n))}};function Os(e,t){e[t]?e[t]++:e[t]=1}function Ds(e,t){--e[t]||delete e[t]}function Lt(e,t,n,r){var s=""+t,i=""+n;if(!e&&s>i){var o=s;s=i,i=o}return s+Rs+i+Rs+(r===void 0?Am:r)}function Tm(e,t,n,r){var s=""+t,i=""+n;if(!e&&s>i){var o=s;s=i,i=o}var a={v:s,w:i};return r&&(a.name=r),a}function Xn(e,t){return Lt(e,t.v,t.w,t.name)}var Dr=Im,Rm="2.2.4",Om={Graph:Dr,version:Rm},Dm=Dr,Lm={write:Pm,read:Fm};function Pm(e){var t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:zm(e),edges:Hm(e)};return e.graph()!==void 0&&(t.value=structuredClone(e.graph())),t}function zm(e){return e.nodes().map(function(t){var n=e.node(t),r=e.parent(t),s={v:t};return n!==void 0&&(s.value=n),r!==void 0&&(s.parent=r),s})}function Hm(e){return e.edges().map(function(t){var n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function Fm(e){var t=new Dm(e.options).setGraph(e.value);return e.nodes.forEach(function(n){t.setNode(n.v,n.value),n.parent&&t.setParent(n.v,n.parent)}),e.edges.forEach(function(n){t.setEdge({v:n.v,w:n.w,name:n.name},n.value)}),t}var Vm=Bm;function Bm(e){var t={},n=[],r;function s(i){Object.hasOwn(t,i)||(t[i]=!0,r.push(i),e.successors(i).forEach(s),e.predecessors(i).forEach(s))}return e.nodes().forEach(function(i){r=[],s(i),r.length&&n.push(r)}),n}let Gm=class{constructor(){oe(this,"_arr",[]);oe(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map(function(t){return t.key})}has(t){return Object.hasOwn(this._keyIndices,t)}priority(t){var n=this._keyIndices[t];if(n!==void 0)return this._arr[n].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(t,n){var r=this._keyIndices;if(t=String(t),!Object.hasOwn(r,t)){var s=this._arr,i=s.length;return r[t]=i,s.push({key:t,priority:n}),this._decrease(i),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key}decrease(t,n){var r=this._keyIndices[t];if(n>this._arr[r].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[r].priority+" New: "+n);this._arr[r].priority=n,this._decrease(r)}_heapify(t){var n=this._arr,r=2*t,s=r+1,i=t;r>1,!(n[s].priority1;function Um(e,t,n,r){return Xm(e,String(t),n||Wm,r||function(s){return e.outEdges(s)})}function Xm(e,t,n,r){var s={},i=new Ym,o,a,l=function(c){var u=c.v!==o?c.v:c.w,d=s[u],m=n(c),f=a.distance+m;if(m<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+c+" Weight: "+m);f0&&(o=i.removeMin(),a=s[o],a.distance!==Number.POSITIVE_INFINITY);)r(o).forEach(l);return s}var qm=Fo,Zm=Km;function Km(e,t,n){return e.nodes().reduce(function(r,s){return r[s]=qm(e,s,t,n),r},{})}var Vo=Qm;function Qm(e){var t=0,n=[],r={},s=[];function i(o){var a=r[o]={onStack:!0,lowlink:t,index:t++};if(n.push(o),e.successors(o).forEach(function(u){Object.hasOwn(r,u)?r[u].onStack&&(a.lowlink=Math.min(a.lowlink,r[u].index)):(i(u),a.lowlink=Math.min(a.lowlink,r[u].lowlink))}),a.lowlink===a.index){var l=[],c;do c=n.pop(),r[c].onStack=!1,l.push(c);while(o!==c);s.push(l)}}return e.nodes().forEach(function(o){Object.hasOwn(r,o)||i(o)}),s}var Jm=Vo,ep=tp;function tp(e){return Jm(e).filter(function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}var np=sp,rp=()=>1;function sp(e,t,n){return ip(e,t||rp,n||function(r){return e.outEdges(r)})}function ip(e,t,n){var r={},s=e.nodes();return s.forEach(function(i){r[i]={},r[i][i]={distance:0},s.forEach(function(o){i!==o&&(r[i][o]={distance:Number.POSITIVE_INFINITY})}),n(i).forEach(function(o){var a=o.v===i?o.w:o.v,l=t(o);r[i][a]={distance:l,predecessor:i}})}),s.forEach(function(i){var o=r[i];s.forEach(function(a){var l=r[a];s.forEach(function(c){var u=l[i],d=o[c],m=l[c],f=u.distance+d.distance;fe.successors(a):a=>e.neighbors(a),s=n==="post"?cp:up,i=[],o={};return t.forEach(a=>{if(!e.hasNode(a))throw new Error("Graph does not have node: "+a);s(a,r,o,i)}),i}function cp(e,t,n,r){for(var s=[[e,!1]];s.length>0;){var i=s.pop();i[1]?r.push(i[0]):Object.hasOwn(n,i[0])||(n[i[0]]=!0,s.push([i[0],!0]),Wo(t(i[0]),o=>s.push([o,!1])))}}function up(e,t,n,r){for(var s=[e];s.length>0;){var i=s.pop();Object.hasOwn(n,i)||(n[i]=!0,r.push(i),Wo(t(i),o=>s.push(o)))}}function Wo(e,t){for(var n=e.length;n--;)t(e[n],n,e);return e}var dp=Yo,fp=hp;function hp(e,t){return dp(e,t,"post")}var mp=Yo,pp=gp;function gp(e,t){return mp(e,t,"pre")}var yp=Dr,xp=Ho,wp=bp;function bp(e,t){var n=new yp,r={},s=new xp,i;function o(l){var c=l.v===i?l.w:l.v,u=s.priority(c);if(u!==void 0){var d=t(l);d0;){if(i=s.removeMin(),Object.hasOwn(r,i))n.setEdge(i,r[i]);else{if(a)throw new Error("Input graph is not connected: "+e);a=!0}e.nodeEdges(i).forEach(o)}return n}var vp={components:Vm,dijkstra:Fo,dijkstraAll:Zm,findCycles:ep,floydWarshall:np,isAcyclic:op,postorder:fp,preorder:pp,prim:wp,tarjan:Vo,topsort:Go},Ps=Om,ke={Graph:Ps.Graph,json:Lm,alg:vp,version:Ps.version};let _p=class{constructor(){let t={};t._next=t._prev=t,this._sentinel=t}dequeue(){let t=this._sentinel,n=t._prev;if(n!==t)return zs(n),n}enqueue(t){let n=this._sentinel;t._prev&&t._next&&zs(t),t._next=n._next,n._next._prev=t,n._next=t,t._prev=n}toString(){let t=[],n=this._sentinel,r=n._prev;for(;r!==n;)t.push(JSON.stringify(r,Ep)),r=r._prev;return"["+t.join(", ")+"]"}};function zs(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function Ep(e,t){if(e!=="_next"&&e!=="_prev")return t}var Np=_p;let Sp=ke.Graph,kp=Np;var jp=$p;let Cp=()=>1;function $p(e,t){if(e.nodeCount()<=1)return[];let n=Ap(e,t||Cp);return Mp(n.graph,n.buckets,n.zeroIdx).flatMap(s=>e.outEdges(s.v,s.w))}function Mp(e,t,n){let r=[],s=t[t.length-1],i=t[0],o;for(;e.nodeCount();){for(;o=i.dequeue();)qn(e,t,n,o);for(;o=s.dequeue();)qn(e,t,n,o);if(e.nodeCount()){for(let a=t.length-2;a>0;--a)if(o=t[a].dequeue(),o){r=r.concat(qn(e,t,n,o,!0));break}}}return r}function qn(e,t,n,r,s){let i=s?[]:void 0;return e.inEdges(r.v).forEach(o=>{let a=e.edge(o),l=e.node(o.v);s&&i.push({v:o.v,w:o.w}),l.out-=a,gr(t,n,l)}),e.outEdges(r.v).forEach(o=>{let a=e.edge(o),l=o.w,c=e.node(l);c.in-=a,gr(t,n,c)}),e.removeNode(r.v),i}function Ap(e,t){let n=new Sp,r=0,s=0;e.nodes().forEach(a=>{n.setNode(a,{v:a,in:0,out:0})}),e.edges().forEach(a=>{let l=n.edge(a.v,a.w)||0,c=t(a),u=l+c;n.setEdge(a.v,a.w,u),s=Math.max(s,n.node(a.v).out+=c),r=Math.max(r,n.node(a.w).in+=c)});let i=Ip(s+r+3).map(()=>new kp),o=r+1;return n.nodes().forEach(a=>{gr(i,o,n.node(a))}),{graph:n,buckets:i,zeroIdx:o}}function gr(e,t,n){n.out?n.in?e[n.out-n.in+t].enqueue(n):e[e.length-1].enqueue(n):e[0].enqueue(n)}function Ip(e){const t=[];for(let n=0;nt.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},s=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+s.weight,minlen:Math.max(r.minlen,s.minlen)})}),t}function Rp(e){let t=new Uo({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function Op(e){let t=e.nodes().map(n=>{let r={};return e.outEdges(n).forEach(s=>{r[s.w]=(r[s.w]||0)+e.edge(s).weight}),r});return Lr(e.nodes(),t)}function Dp(e){let t=e.nodes().map(n=>{let r={};return e.inEdges(n).forEach(s=>{r[s.v]=(r[s.v]||0)+e.edge(s).weight}),r});return Lr(e.nodes(),t)}function Lp(e,t){let n=e.x,r=e.y,s=t.x-n,i=t.y-r,o=e.width/2,a=e.height/2;if(!s&&!i)throw new Error("Not possible to find intersection inside of the rectangle");let l,c;return Math.abs(i)*o>Math.abs(s)*a?(i<0&&(a=-a),l=a*s/i,c=a):(s<0&&(o=-o),l=o,c=o*i/s),{x:n+l,y:r+c}}function Pp(e){let t=Qo(Zo(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),s=r.rank;s!==void 0&&(t[s][r.order]=n)}),t}function zp(e){let t=e.nodes().map(r=>{let s=e.node(r).rank;return s===void 0?Number.MAX_VALUE:s}),n=In(Math.min,t);e.nodes().forEach(r=>{let s=e.node(r);Object.hasOwn(s,"rank")&&(s.rank-=n)})}function Hp(e){let t=e.nodes().map(o=>e.node(o).rank),n=In(Math.min,t),r=[];e.nodes().forEach(o=>{let a=e.node(o).rank-n;r[a]||(r[a]=[]),r[a].push(o)});let s=0,i=e.graph().nodeRankFactor;Array.from(r).forEach((o,a)=>{o===void 0&&a%i!==0?--s:o!==void 0&&s&&o.forEach(l=>e.node(l).rank+=s)})}function Fp(e,t,n,r){let s={width:0,height:0};return arguments.length>=4&&(s.rank=n,s.order=r),Xo(e,"border",s,t)}function Vp(e,t=qo){const n=[];for(let r=0;rqo){const n=Vp(t);return e.apply(null,n.map(r=>e.apply(null,r)))}else return e.apply(null,t)}function Zo(e){const n=e.nodes().map(r=>{let s=e.node(r).rank;return s===void 0?Number.MIN_VALUE:s});return In(Math.max,n)}function Bp(e,t){let n={lhs:[],rhs:[]};return e.forEach(r=>{t(r)?n.lhs.push(r):n.rhs.push(r)}),n}function Gp(e,t){let n=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-n)+"ms")}}function Yp(e,t){return t()}let Wp=0;function Ko(e){var t=++Wp;return e+(""+t)}function Qo(e,t,n=1){t==null&&(t=e,e=0);let r=i=>itr[t]),Object.entries(e).reduce((r,[s,i])=>(r[s]=n(i,s),r),{})}function Lr(e,t){return e.reduce((n,r,s)=>(n[r]=t[s],n),{})}let qp=jp,Zp=ce.uniqueId;var Kp={run:Qp,undo:eg};function Qp(e){(e.graph().acyclicer==="greedy"?qp(e,n(e)):Jp(e)).forEach(r=>{let s=e.edge(r);e.removeEdge(r),s.forwardName=r.name,s.reversed=!0,e.setEdge(r.w,r.v,s,Zp("rev"))});function n(r){return s=>r.edge(s).weight}}function Jp(e){let t=[],n={},r={};function s(i){Object.hasOwn(r,i)||(r[i]=!0,n[i]=!0,e.outEdges(i).forEach(o=>{Object.hasOwn(n,o.w)?t.push(o):s(o.w)}),delete n[i])}return e.nodes().forEach(s),t}function eg(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}let tg=ce;var ng={run:rg,undo:ig};function rg(e){e.graph().dummyChains=[],e.edges().forEach(t=>sg(e,t))}function sg(e,t){let n=t.v,r=e.node(n).rank,s=t.w,i=e.node(s).rank,o=t.name,a=e.edge(t),l=a.labelRank;if(i===r+1)return;e.removeEdge(t);let c,u,d;for(d=0,++r;r{let n=e.node(t),r=n.edgeLabel,s;for(e.setEdge(n.edgeObj,r);n.dummy;)s=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy==="edge-label"&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=s,n=e.node(t)})}const{applyWithChunking:og}=ce;var Tn={longestPath:ag,slack:lg};function ag(e){var t={};function n(r){var s=e.node(r);if(Object.hasOwn(t,r))return s.rank;t[r]=!0;let i=e.outEdges(r).map(a=>a==null?Number.POSITIVE_INFINITY:n(a.w)-e.edge(a).minlen);var o=og(Math.min,i);return o===Number.POSITIVE_INFINITY&&(o=0),s.rank=o}e.sources().forEach(n)}function lg(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var cg=ke.Graph,vn=Tn.slack,Jo=ug;function ug(e){var t=new cg({directed:!1}),n=e.nodes()[0],r=e.nodeCount();t.setNode(n,{});for(var s,i;dg(t,e){var i=s.v,o=r===i?s.w:i;!e.hasNode(o)&&!vn(t,s)&&(e.setNode(o,{}),e.setEdge(r,o,{}),n(o))})}return e.nodes().forEach(n),e.nodeCount()}function fg(e,t){return t.edges().reduce((r,s)=>{let i=Number.POSITIVE_INFINITY;return e.hasNode(s.v)!==e.hasNode(s.w)&&(i=vn(t,s)),it.node(r).rank+=n)}var mg=Jo,Hs=Tn.slack,pg=Tn.longestPath,gg=ke.alg.preorder,yg=ke.alg.postorder,xg=ce.simplify,wg=ot;ot.initLowLimValues=zr;ot.initCutValues=Pr;ot.calcCutValue=ea;ot.leaveEdge=na;ot.enterEdge=ra;ot.exchangeEdges=sa;function ot(e){e=xg(e),pg(e);var t=mg(e);zr(t),Pr(t,e);for(var n,r;n=na(t);)r=ra(t,e,n),sa(t,e,n,r)}function Pr(e,t){var n=yg(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(r=>bg(e,t,r))}function bg(e,t,n){var r=e.node(n),s=r.parent;e.edge(n,s).cutvalue=ea(e,t,n)}function ea(e,t,n){var r=e.node(n),s=r.parent,i=!0,o=t.edge(n,s),a=0;return o||(i=!1,o=t.edge(s,n)),a=o.weight,t.nodeEdges(n).forEach(l=>{var c=l.v===n,u=c?l.w:l.v;if(u!==s){var d=c===i,m=t.edge(l).weight;if(a+=d?m:-m,_g(e,n,u)){var f=e.edge(n,u).cutvalue;a+=d?-f:f}}}),a}function zr(e,t){arguments.length<2&&(t=e.nodes()[0]),ta(e,{},1,t)}function ta(e,t,n,r,s){var i=n,o=e.node(r);return t[r]=!0,e.neighbors(r).forEach(a=>{Object.hasOwn(t,a)||(n=ta(e,t,n,a,r))}),o.low=i,o.lim=n++,s?o.parent=s:delete o.parent,n}function na(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function ra(e,t,n){var r=n.v,s=n.w;t.hasEdge(r,s)||(r=n.w,s=n.v);var i=e.node(r),o=e.node(s),a=i,l=!1;i.lim>o.lim&&(a=o,l=!0);var c=t.edges().filter(u=>l===Fs(e,e.node(u.v),a)&&l!==Fs(e,e.node(u.w),a));return c.reduce((u,d)=>Hs(t,d)!t.node(s).parent),r=gg(e,n);r=r.slice(1),r.forEach(s=>{var i=e.node(s).parent,o=t.edge(s,i),a=!1;o||(o=t.edge(i,s),a=!0),t.node(s).rank=t.node(i).rank+(a?o.minlen:-o.minlen)})}function _g(e,t,n){return e.hasEdge(t,n)}function Fs(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var Eg=Tn,ia=Eg.longestPath,Ng=Jo,Sg=wg,kg=jg;function jg(e){var t=e.graph().ranker;if(t instanceof Function)return t(e);switch(e.graph().ranker){case"network-simplex":Vs(e);break;case"tight-tree":$g(e);break;case"longest-path":Cg(e);break;case"none":break;default:Vs(e)}}var Cg=ia;function $g(e){ia(e),Ng(e)}function Vs(e){Sg(e)}var Mg=Ag;function Ag(e){let t=Tg(e);e.graph().dummyChains.forEach(n=>{let r=e.node(n),s=r.edgeObj,i=Ig(e,t,s.v,s.w),o=i.path,a=i.lca,l=0,c=o[l],u=!0;for(;n!==s.w;){if(r=e.node(n),u){for(;(c=o[l])!==a&&e.node(c).maxRanko||a>t[l].lim));for(c=l,l=r;(l=e.parent(l))!==c;)i.push(l);return{path:s.concat(i.reverse()),lca:c}}function Tg(e){let t={},n=0;function r(s){let i=n;e.children(s).forEach(r),t[s]={low:i,lim:n++}}return e.children().forEach(r),t}let _n=ce;var Rg={run:Og,cleanup:Pg};function Og(e){let t=_n.addDummyNode(e,"root",{},"_root"),n=Dg(e),r=Object.values(n),s=_n.applyWithChunking(Math.max,r)-1,i=2*s+1;e.graph().nestingRoot=t,e.edges().forEach(a=>e.edge(a).minlen*=i);let o=Lg(e)+1;e.children().forEach(a=>oa(e,t,i,o,s,n,a)),e.graph().nodeRankFactor=i}function oa(e,t,n,r,s,i,o){let a=e.children(o);if(!a.length){o!==t&&e.setEdge(t,o,{weight:0,minlen:n});return}let l=_n.addBorderNode(e,"_bt"),c=_n.addBorderNode(e,"_bb"),u=e.node(o);e.setParent(l,o),u.borderTop=l,e.setParent(c,o),u.borderBottom=c,a.forEach(d=>{oa(e,t,n,r,s,i,d);let m=e.node(d),f=m.borderTop?m.borderTop:d,y=m.borderBottom?m.borderBottom:d,x=m.borderTop?r:2*r,_=f!==y?1:s-i[o]+1;e.setEdge(l,f,{weight:x,minlen:_,nestingEdge:!0}),e.setEdge(y,c,{weight:x,minlen:_,nestingEdge:!0})}),e.parent(o)||e.setEdge(t,l,{weight:0,minlen:s+i[o]})}function Dg(e){var t={};function n(r,s){var i=e.children(r);i&&i.length&&i.forEach(o=>n(o,s+1)),t[r]=s}return e.children().forEach(r=>n(r,1)),t}function Lg(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function Pg(e){var t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(n=>{var r=e.edge(n);r.nestingEdge&&e.removeEdge(n)})}let zg=ce;var Hg=Fg;function Fg(e){function t(n){let r=e.children(n),s=e.node(n);if(r.length&&r.forEach(t),Object.hasOwn(s,"minRank")){s.borderLeft=[],s.borderRight=[];for(let i=s.minRank,o=s.maxRank+1;iGs(e.node(t))),e.edges().forEach(t=>Gs(e.edge(t)))}function Gs(e){let t=e.width;e.width=e.height,e.height=t}function Yg(e){e.nodes().forEach(t=>Zn(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);n.points.forEach(Zn),Object.hasOwn(n,"y")&&Zn(n)})}function Zn(e){e.y=-e.y}function Wg(e){e.nodes().forEach(t=>Kn(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);n.points.forEach(Kn),Object.hasOwn(n,"x")&&Kn(n)})}function Kn(e){let t=e.x;e.x=e.y,e.y=t}let Ys=ce;var Ug=Xg;function Xg(e){let t={},n=e.nodes().filter(l=>!e.children(l).length),r=n.map(l=>e.node(l).rank),s=Ys.applyWithChunking(Math.max,r),i=Ys.range(s+1).map(()=>[]);function o(l){if(t[l])return;t[l]=!0;let c=e.node(l);i[c.rank].push(l),e.successors(l).forEach(o)}return n.sort((l,c)=>e.node(l).rank-e.node(c).rank).forEach(o),i}let qg=ce.zipObject;var Zg=Kg;function Kg(e,t){let n=0;for(let r=1;ru)),s=t.flatMap(c=>e.outEdges(c).map(u=>({pos:r[u.w],weight:e.edge(u).weight})).sort((u,d)=>u.pos-d.pos)),i=1;for(;i{let u=c.pos+i;a[u]+=c.weight;let d=0;for(;u>0;)u%2&&(d+=a[u+1]),u=u-1>>1,a[u]+=c.weight;l+=c.weight*d}),l}var Jg=e0;function e0(e,t=[]){return t.map(n=>{let r=e.inEdges(n);if(r.length){let s=r.reduce((i,o)=>{let a=e.edge(o),l=e.node(o.v);return{sum:i.sum+a.weight*l.order,weight:i.weight+a.weight}},{sum:0,weight:0});return{v:n,barycenter:s.sum/s.weight,weight:s.weight}}else return{v:n}})}let t0=ce;var n0=r0;function r0(e,t){let n={};e.forEach((s,i)=>{let o=n[s.v]={indegree:0,in:[],out:[],vs:[s.v],i};s.barycenter!==void 0&&(o.barycenter=s.barycenter,o.weight=s.weight)}),t.edges().forEach(s=>{let i=n[s.v],o=n[s.w];i!==void 0&&o!==void 0&&(o.indegree++,i.out.push(n[s.w]))});let r=Object.values(n).filter(s=>!s.indegree);return s0(r)}function s0(e){let t=[];function n(s){return i=>{i.merged||(i.barycenter===void 0||s.barycenter===void 0||i.barycenter>=s.barycenter)&&i0(s,i)}}function r(s){return i=>{i.in.push(s),--i.indegree===0&&e.push(i)}}for(;e.length;){let s=e.pop();t.push(s),s.in.reverse().forEach(n(s)),s.out.forEach(r(s))}return t.filter(s=>!s.merged).map(s=>t0.pick(s,["vs","i","barycenter","weight"]))}function i0(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}let o0=ce;var a0=l0;function l0(e,t){let n=o0.partition(e,u=>Object.hasOwn(u,"barycenter")),r=n.lhs,s=n.rhs.sort((u,d)=>d.i-u.i),i=[],o=0,a=0,l=0;r.sort(c0(!!t)),l=Ws(i,s,l),r.forEach(u=>{l+=u.vs.length,i.push(u.vs),o+=u.barycenter*u.weight,a+=u.weight,l=Ws(i,s,l)});let c={vs:i.flat(!0)};return a&&(c.barycenter=o/a,c.weight=a),c}function Ws(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function c0(e){return(t,n)=>t.barycentern.barycenter?1:e?n.i-t.i:t.i-n.i}let u0=Jg,d0=n0,f0=a0;var h0=la;function la(e,t,n,r){let s=e.children(t),i=e.node(t),o=i?i.borderLeft:void 0,a=i?i.borderRight:void 0,l={};o&&(s=s.filter(m=>m!==o&&m!==a));let c=u0(e,s);c.forEach(m=>{if(e.children(m.v).length){let f=la(e,m.v,n,r);l[m.v]=f,Object.hasOwn(f,"barycenter")&&p0(m,f)}});let u=d0(c,n);m0(u,l);let d=f0(u,r);if(o&&(d.vs=[o,d.vs,a].flat(!0),e.predecessors(o).length)){let m=e.node(e.predecessors(o)[0]),f=e.node(e.predecessors(a)[0]);Object.hasOwn(d,"barycenter")||(d.barycenter=0,d.weight=0),d.barycenter=(d.barycenter*d.weight+m.order+f.order)/(d.weight+2),d.weight+=2}return d}function m0(e,t){e.forEach(n=>{n.vs=n.vs.flatMap(r=>t[r]?t[r].vs:r)})}function p0(e,t){e.barycenter!==void 0?(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight):(e.barycenter=t.barycenter,e.weight=t.weight)}let g0=ke.Graph,y0=ce;var x0=w0;function w0(e,t,n,r){r||(r=e.nodes());let s=b0(e),i=new g0({compound:!0}).setGraph({root:s}).setDefaultNodeLabel(o=>e.node(o));return r.forEach(o=>{let a=e.node(o),l=e.parent(o);(a.rank===t||a.minRank<=t&&t<=a.maxRank)&&(i.setNode(o),i.setParent(o,l||s),e[n](o).forEach(c=>{let u=c.v===o?c.w:c.v,d=i.edge(u,o),m=d!==void 0?d.weight:0;i.setEdge(u,o,{weight:e.edge(c).weight+m})}),Object.hasOwn(a,"minRank")&&i.setNode(o,{borderLeft:a.borderLeft[t],borderRight:a.borderRight[t]}))}),i}function b0(e){for(var t;e.hasNode(t=y0.uniqueId("_root")););return t}var v0=_0;function _0(e,t,n){let r={},s;n.forEach(i=>{let o=e.parent(i),a,l;for(;o;){if(a=e.parent(o),a?(l=r[a],r[a]=o):(l=s,s=o),l&&l!==o){t.setEdge(l,o);return}o=a}})}let E0=Ug,N0=Zg,S0=h0,k0=x0,j0=v0,C0=ke.Graph,on=ce;var $0=ca;function ca(e,t){if(t&&typeof t.customOrder=="function"){t.customOrder(e,ca);return}let n=on.maxRank(e),r=Us(e,on.range(1,n+1),"inEdges"),s=Us(e,on.range(n-1,-1,-1),"outEdges"),i=E0(e);if(Xs(e,i),t&&t.disableOptimalOrderHeuristic)return;let o=Number.POSITIVE_INFINITY,a;for(let l=0,c=0;c<4;++l,++c){M0(l%2?r:s,l%4>=2),i=on.buildLayerMatrix(e);let u=N0(e,i);u{r.has(i)||r.set(i,[]),r.get(i).push(o)};for(const i of e.nodes()){const o=e.node(i);if(typeof o.rank=="number"&&s(o.rank,i),typeof o.minRank=="number"&&typeof o.maxRank=="number")for(let a=o.minRank;a<=o.maxRank;a++)a!==o.rank&&s(a,i)}return t.map(function(i){return k0(e,i,n,r.get(i)||[])})}function M0(e,t){let n=new C0;e.forEach(function(r){let s=r.graph().root,i=S0(r,s,n,t);i.vs.forEach((o,a)=>r.node(o).order=a),j0(r,n,i.vs)})}function Xs(e,t){Object.values(t).forEach(n=>n.forEach((r,s)=>e.node(r).order=s))}let A0=ke.Graph,Re=ce;var I0={positionX:B0};function T0(e,t){let n={};function r(s,i){let o=0,a=0,l=s.length,c=i[i.length-1];return i.forEach((u,d)=>{let m=O0(e,u),f=m?e.node(m).order:l;(m||u===c)&&(i.slice(a,d+1).forEach(y=>{e.predecessors(y).forEach(x=>{let _=e.node(x),g=_.order;(g{u=i[d],e.node(u).dummy&&e.predecessors(u).forEach(m=>{let f=e.node(m);f.dummy&&(f.orderc)&&ua(n,m,u)})})}function s(i,o){let a=-1,l,c=0;return o.forEach((u,d)=>{if(e.node(u).dummy==="border"){let m=e.predecessors(u);m.length&&(l=e.node(m[0]).order,r(o,c,d,a,l),c=d,a=l)}r(o,c,o.length,l,i.length)}),o}return t.length&&t.reduce(s),n}function O0(e,t){if(e.node(t).dummy)return e.predecessors(t).find(n=>e.node(n).dummy)}function ua(e,t,n){if(t>n){let s=t;t=n,n=s}let r=e[t];r||(e[t]=r={}),r[n]=!0}function D0(e,t,n){if(t>n){let r=t;t=n,n=r}return!!e[t]&&Object.hasOwn(e[t],n)}function L0(e,t,n,r){let s={},i={},o={};return t.forEach(a=>{a.forEach((l,c)=>{s[l]=l,i[l]=l,o[l]=c})}),t.forEach(a=>{let l=-1;a.forEach(c=>{let u=r(c);if(u.length){u=u.sort((m,f)=>o[m]-o[f]);let d=(u.length-1)/2;for(let m=Math.floor(d),f=Math.ceil(d);m<=f;++m){let y=u[m];i[c]===c&&lMath.max(m,i[f.v]+o.edge(f)),0)}function u(d){let m=o.outEdges(d).reduce((y,x)=>Math.min(y,i[x.w]-o.edge(x)),Number.POSITIVE_INFINITY),f=e.node(d);m!==Number.POSITIVE_INFINITY&&f.borderType!==a&&(i[d]=Math.max(i[d],m))}return l(c,o.predecessors.bind(o)),l(u,o.successors.bind(o)),Object.keys(r).forEach(d=>i[d]=i[n[d]]),i}function z0(e,t,n,r){let s=new A0,i=e.graph(),o=G0(i.nodesep,i.edgesep,r);return t.forEach(a=>{let l;a.forEach(c=>{let u=n[c];if(s.setNode(u),l){var d=n[l],m=s.edge(d,u);s.setEdge(d,u,Math.max(o(e,c,l),m||0))}l=c})}),s}function H0(e,t){return Object.values(t).reduce((n,r)=>{let s=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;Object.entries(r).forEach(([a,l])=>{let c=Y0(e,a)/2;s=Math.max(l+c,s),i=Math.min(l-c,i)});const o=s-i;return o{["l","r"].forEach(o=>{let a=i+o,l=e[a];if(l===t)return;let c=Object.values(l),u=r-Re.applyWithChunking(Math.min,c);o!=="l"&&(u=s-Re.applyWithChunking(Math.max,c)),u&&(e[a]=Re.mapValues(l,d=>d+u))})})}function V0(e,t){return Re.mapValues(e.ul,(n,r)=>{if(t)return e[t.toLowerCase()][r];{let s=Object.values(e).map(i=>i[r]).sort((i,o)=>i-o);return(s[1]+s[2])/2}})}function B0(e){let t=Re.buildLayerMatrix(e),n=Object.assign(T0(e,t),R0(e,t)),r={},s;["u","d"].forEach(o=>{s=o==="u"?t:Object.values(t).reverse(),["l","r"].forEach(a=>{a==="r"&&(s=s.map(d=>Object.values(d).reverse()));let l=(o==="u"?e.predecessors:e.successors).bind(e),c=L0(e,s,n,l),u=P0(e,s,c.root,c.align,a==="r");a==="r"&&(u=Re.mapValues(u,d=>-d)),r[o+a]=u})});let i=H0(e,r);return F0(r,i),V0(r,e.graph().align)}function G0(e,t,n){return(r,s,i)=>{let o=r.node(s),a=r.node(i),l=0,c;if(l+=o.width/2,Object.hasOwn(o,"labelpos"))switch(o.labelpos.toLowerCase()){case"l":c=-o.width/2;break;case"r":c=o.width/2;break}if(c&&(l+=n?c:-c),c=0,l+=(o.dummy?t:e)/2,l+=(a.dummy?t:e)/2,l+=a.width/2,Object.hasOwn(a,"labelpos"))switch(a.labelpos.toLowerCase()){case"l":c=a.width/2;break;case"r":c=-a.width/2;break}return c&&(l+=n?c:-c),c=0,l}}function Y0(e,t){return e.node(t).width}let da=ce,W0=I0.positionX;var U0=X0;function X0(e){e=da.asNonCompoundGraph(e),q0(e),Object.entries(W0(e)).forEach(([t,n])=>e.node(t).x=n)}function q0(e){let t=da.buildLayerMatrix(e),n=e.graph().ranksep,r=0;t.forEach(s=>{const i=s.reduce((o,a)=>{const l=e.node(a).height;return o>l?o:l},0);s.forEach(o=>e.node(o).y=r+i/2),r+=i+n})}let qs=Kp,Zs=ng,Z0=kg,K0=ce.normalizeRanks,Q0=Mg,J0=ce.removeEmptyRanks,Ks=Rg,ey=Hg,Qs=Vg,ty=$0,ny=U0,ve=ce,ry=ke.Graph;var sy=iy;function iy(e,t){let n=t&&t.debugTiming?ve.time:ve.notime;n("layout",()=>{let r=n(" buildLayoutGraph",()=>py(e));n(" runLayout",()=>oy(r,n,t)),n(" updateInputGraph",()=>ay(e,r))})}function oy(e,t,n){t(" makeSpaceForEdgeLabels",()=>gy(e)),t(" removeSelfEdges",()=>Sy(e)),t(" acyclic",()=>qs.run(e)),t(" nestingGraph.run",()=>Ks.run(e)),t(" rank",()=>Z0(ve.asNonCompoundGraph(e))),t(" injectEdgeLabelProxies",()=>yy(e)),t(" removeEmptyRanks",()=>J0(e)),t(" nestingGraph.cleanup",()=>Ks.cleanup(e)),t(" normalizeRanks",()=>K0(e)),t(" assignRankMinMax",()=>xy(e)),t(" removeEdgeLabelProxies",()=>wy(e)),t(" normalize.run",()=>Zs.run(e)),t(" parentDummyChains",()=>Q0(e)),t(" addBorderSegments",()=>ey(e)),t(" order",()=>ty(e,n)),t(" insertSelfEdges",()=>ky(e)),t(" adjustCoordinateSystem",()=>Qs.adjust(e)),t(" position",()=>ny(e)),t(" positionSelfEdges",()=>jy(e)),t(" removeBorderNodes",()=>Ny(e)),t(" normalize.undo",()=>Zs.undo(e)),t(" fixupEdgeLabelCoords",()=>_y(e)),t(" undoCoordinateSystem",()=>Qs.undo(e)),t(" translateGraph",()=>by(e)),t(" assignNodeIntersects",()=>vy(e)),t(" reversePoints",()=>Ey(e)),t(" acyclic.undo",()=>qs.undo(e))}function ay(e,t){e.nodes().forEach(n=>{let r=e.node(n),s=t.node(n);r&&(r.x=s.x,r.y=s.y,r.rank=s.rank,t.children(n).length&&(r.width=s.width,r.height=s.height))}),e.edges().forEach(n=>{let r=e.edge(n),s=t.edge(n);r.points=s.points,Object.hasOwn(s,"x")&&(r.x=s.x,r.y=s.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}let ly=["nodesep","edgesep","ranksep","marginx","marginy"],cy={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},uy=["acyclicer","ranker","rankdir","align"],dy=["width","height","rank"],Js={width:0,height:0},fy=["minlen","weight","width","height","labeloffset"],hy={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},my=["labelpos"];function py(e){let t=new ry({multigraph:!0,compound:!0}),n=Jn(e.graph());return t.setGraph(Object.assign({},cy,Qn(n,ly),ve.pick(n,uy))),e.nodes().forEach(r=>{let s=Jn(e.node(r));const i=Qn(s,dy);Object.keys(Js).forEach(o=>{i[o]===void 0&&(i[o]=Js[o])}),t.setNode(r,i),t.setParent(r,e.parent(r))}),e.edges().forEach(r=>{let s=Jn(e.edge(r));t.setEdge(r,Object.assign({},hy,Qn(s,fy),ve.pick(s,my)))}),t}function gy(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{let r=e.edge(n);r.minlen*=2,r.labelpos.toLowerCase()!=="c"&&(t.rankdir==="TB"||t.rankdir==="BT"?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function yy(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let r=e.node(t.v),i={rank:(e.node(t.w).rank-r.rank)/2+r.rank,e:t};ve.addDummyNode(e,"edge-proxy",i,"_ep")}})}function xy(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function wy(e){e.nodes().forEach(t=>{let n=e.node(t);n.dummy==="edge-proxy"&&(e.edge(n.e).labelRank=n.rank,e.removeNode(t))})}function by(e){let t=Number.POSITIVE_INFINITY,n=0,r=Number.POSITIVE_INFINITY,s=0,i=e.graph(),o=i.marginx||0,a=i.marginy||0;function l(c){let u=c.x,d=c.y,m=c.width,f=c.height;t=Math.min(t,u-m/2),n=Math.max(n,u+m/2),r=Math.min(r,d-f/2),s=Math.max(s,d+f/2)}e.nodes().forEach(c=>l(e.node(c))),e.edges().forEach(c=>{let u=e.edge(c);Object.hasOwn(u,"x")&&l(u)}),t-=o,r-=a,e.nodes().forEach(c=>{let u=e.node(c);u.x-=t,u.y-=r}),e.edges().forEach(c=>{let u=e.edge(c);u.points.forEach(d=>{d.x-=t,d.y-=r}),Object.hasOwn(u,"x")&&(u.x-=t),Object.hasOwn(u,"y")&&(u.y-=r)}),i.width=n-t+o,i.height=s-r+a}function vy(e){e.edges().forEach(t=>{let n=e.edge(t),r=e.node(t.v),s=e.node(t.w),i,o;n.points?(i=n.points[0],o=n.points[n.points.length-1]):(n.points=[],i=s,o=r),n.points.unshift(ve.intersectRect(r,i)),n.points.push(ve.intersectRect(s,o))})}function _y(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,"x"))switch((n.labelpos==="l"||n.labelpos==="r")&&(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset;break}})}function Ey(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function Ny(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),s=e.node(n.borderBottom),i=e.node(n.borderLeft[n.borderLeft.length-1]),o=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(o.x-i.x),n.height=Math.abs(s.y-r.y),n.x=i.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy==="border"&&e.removeNode(t)})}function Sy(e){e.edges().forEach(t=>{if(t.v===t.w){var n=e.node(t.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function ky(e){var t=ve.buildLayerMatrix(e);t.forEach(n=>{var r=0;n.forEach((s,i)=>{var o=e.node(s);o.order=i+r,(o.selfEdges||[]).forEach(a=>{ve.addDummyNode(e,"selfedge",{width:a.label.width,height:a.label.height,rank:o.rank,order:i+ ++r,e:a.e,label:a.label},"_se")}),delete o.selfEdges})})}function jy(e){e.nodes().forEach(t=>{var n=e.node(t);if(n.dummy==="selfedge"){var r=e.node(n.e.v),s=r.x+r.width/2,i=r.y,o=n.x-s,a=r.height/2;e.setEdge(n.e,n.label),e.removeNode(t),n.label.points=[{x:s+2*o/3,y:i-a},{x:s+5*o/6,y:i-a},{x:s+o,y:i},{x:s+5*o/6,y:i+a},{x:s+2*o/3,y:i+a}],n.label.x=n.x,n.label.y=n.y}})}function Qn(e,t){return ve.mapValues(ve.pick(e,t),Number)}function Jn(e){var t={};return e&&Object.entries(e).forEach(([n,r])=>{typeof n=="string"&&(n=n.toLowerCase()),t[n]=r}),t}let Cy=ce,$y=ke.Graph;var My={debugOrdering:Ay};function Ay(e){let t=Cy.buildLayerMatrix(e),n=new $y({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(r=>{n.setNode(r,{label:r}),n.setParent(r,"layer"+e.node(r).rank)}),e.edges().forEach(r=>n.setEdge(r.v,r.w,{},r.name)),t.forEach((r,s)=>{let i="layer"+s;n.setNode(i,{rank:"same"}),r.reduce((o,a)=>(n.setEdge(o,a,{style:"invis"}),a))}),n}var Iy="1.1.8",Ty={graphlib:ke,layout:sy,debug:My,util:{time:ce.time,notime:ce.notime},version:Iy};const ei=ai(Ty),ti=264,Ry=44,Oy=26,Dy=14;function ni(e){const t=Math.max(e.attributes.length,1);return Ry+t*Oy+Dy}function ri(e,t,n){const r=new ei.graphlib.Graph;r.setGraph({rankdir:"LR",nodesep:70,ranksep:150,edgesep:30,marginx:48,marginy:48,ranker:"network-simplex"}),r.setDefaultEdgeLabel(()=>({}));for(const s of e){const i=n.get(s.id);r.setNode(s.id,{width:ti,height:i?ni(i):120})}for(const s of t)r.setEdge(s.source,s.target,{minlen:1,weight:2});return ei.layout(r),e.map(s=>{const i=r.node(s.id),o=n.get(s.id),a=o?ni(o):120;return{...s,position:{x:i.x-ti/2,y:i.y-a/2}}})}function qt({title:e,onClose:t,children:n,wide:r}){return h.jsx("div",{className:"modal-backdrop",onClick:t,children:h.jsxs("div",{className:"modal"+(r?" wide":""),onClick:s=>s.stopPropagation(),children:[h.jsxs("div",{className:"modal-header",children:[h.jsx("h2",{children:e}),h.jsx("button",{className:"icon-btn",onClick:t,children:"✕"})]}),n]})})}const Ly=["skos:exactMatch","skos:closeMatch","skos:broadMatch","skos:narrowMatch","skos:relatedMatch"],fa=["industry","core","domain","specialised"];function Py({entity:e,exec:t,onClose:n}){var w,M;const[r,s]=b.useState(((w=e.conceptual)==null?void 0:w.name)??e.name),[i,o]=b.useState([]),[a,l]=b.useState(null),[c,u]=b.useState(null),[d,m]=b.useState("skos:exactMatch"),[f,y]=b.useState(((M=e.conceptual)==null?void 0:M.ontology_layer)??"core"),[x,_]=b.useState([]),[g,v]=b.useState("");b.useEffect(()=>{zo().then(C=>_(C.ontologies)).catch(()=>{})},[]),b.useEffect(()=>{const C=setTimeout(()=>{if(!r.trim())return o([]);Po(r,g||void 0).then(A=>{o(A.results),l(A.loaded_terms)}).catch(()=>o([]))},200);return()=>clearTimeout(C)},[r,g]);const j=()=>{c&&t("set_alignment",{id:e.id,aligns_to:c.prefixed,alignment:d,layer:f,resolved_via:c.source}).then(n)};return h.jsxs(qt,{title:`Align '${e.name}' to ontology`,onClose:n,wide:!0,children:[x.length>0&&h.jsxs("div",{className:"src-picker",children:[h.jsx("button",{className:"src-chip"+(g===""?" active":""),onClick:()=>v(""),children:"all sources"}),x.map(C=>h.jsx("button",{className:"src-chip"+(g===C.id?" active":""),title:C.count!=null?`${C.count} terms`:"live resolver",onClick:()=>v(C.id),children:C.name},C.id))]}),h.jsx("input",{autoFocus:!0,className:"edit-input modal-search",placeholder:g?`Search within ${g}…`:"Search vocabulary terms…",value:r,onChange:C=>s(C.target.value)}),a===0&&x.length===0&&h.jsx("p",{className:"empty-hint",children:"No vocabulary loaded. Declare one in mdl-project.yaml's ontology_stack (or run `mdl ontology vendor fibo`)."}),h.jsxs("div",{className:"term-results",children:[i.map(C=>h.jsxs("button",{className:"term-card"+((c==null?void 0:c.iri)===C.iri?" picked":""),onClick:()=>u(C),children:[h.jsxs("div",{className:"term-head",children:[h.jsx("span",{className:"term-label",children:C.label}),h.jsxs("span",{className:"term-source",children:[C.source_kind==="glossary-term"&&h.jsx("span",{className:"kind-badge",children:"glossary"}),C.source]})]}),h.jsx("code",{className:"term-iri",children:C.prefixed}),C.definition&&h.jsx("p",{className:"term-def",children:C.definition})]},C.iri)),r&&i.length===0&&a!==0&&h.jsxs("p",{className:"empty-hint",children:["no matches for “",r,"”"]})]}),h.jsxs("div",{className:"modal-footer",children:[h.jsxs("label",{children:["predicate",h.jsx("select",{value:d,onChange:C=>m(C.target.value),children:Ly.map(C=>h.jsx("option",{children:C},C))})]}),h.jsxs("label",{children:["layer",h.jsx("select",{value:f,onChange:C=>y(C.target.value),children:fa.map(C=>h.jsx("option",{children:C},C))})]}),h.jsxs("button",{className:"primary-btn",disabled:!c,onClick:j,children:["Align",c?` to ${c.label}`:""]})]})]})}function zy({entity:e,doc:t,exec:n,onClose:r}){var w,M,C;const[s,i]=b.useState(((w=e.term_map)==null?void 0:w.subject_template)??""),[o,a]=b.useState(((M=e.term_map)==null?void 0:M.class_iri)??""),l=new Set(e.attributes.map(A=>A.name)),u=Array.from(s.matchAll(/\{([^}]+)\}/g)).map(A=>A[1]).filter(A=>!l.has(A)),d=A=>!A||A.startsWith("http://")||A.startsWith("https://")||/^[^\s:]+:[^\s:]+/.test(A),m=u.length===0&&d(o),f=()=>{n("set_term_map",{id:e.id,subject_template:s.trim()||null,class_iri:o.trim()||null}).then(r)},y=(t.project.name||"").replace(/[^0-9a-zA-Z]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()||"modelith-model",x=t.project.kg_base_iri||`urn:${y}:`,_=(C=(e.key_groups??[]).find(A=>A.type==="pk"))==null?void 0:C.members.map(A=>{var F;return(F=e.attributes.find(S=>S.id===A))==null?void 0:F.name}).filter(Boolean),g=_&&_.length?`${x}${e.id}/${_.map(A=>`{${A}}`).join("_")}`:"(blank-node: entity has no primary key)",v=o.trim()||`${x}${e.id}`,j=s.trim()||g;return h.jsxs(qt,{title:`Knowledge Graph mapping — ${e.name}`,onClose:r,wide:!0,children:[h.jsx("p",{className:"empty-hint",style:{marginBottom:14},children:"Override the R2RML term-map for this entity. Leave a field blank to use the default (project base IRI + primary key)."}),h.jsxs("div",{className:"form-row",children:[h.jsx("label",{htmlFor:"tm-class",children:"Class IRI"}),h.jsx("input",{id:"tm-class",className:"edit-input",value:o,placeholder:"https://acme.com/Customer or fibo-fnd:Party",onChange:A=>a(A.target.value)}),d(o)?h.jsxs("code",{className:"form-preview",children:["rr:class ",v]}):h.jsx("span",{className:"form-error",children:"not a valid IRI or prefix:local CURIE"})]}),h.jsxs("div",{className:"form-row",children:[h.jsx("label",{htmlFor:"tm-subject",children:"Subject template"}),h.jsx("input",{id:"tm-subject",className:"edit-input",value:s,placeholder:"https://acme.com/id/customer/{customer_id}",onChange:A=>i(A.target.value)}),u.length>0?h.jsxs("span",{className:"form-error",children:["unknown column",u.length>1?"s":"",": ",u.join(", ")]}):h.jsxs("code",{className:"form-preview",children:["rr:template ",j]}),h.jsxs("span",{className:"form-hint",children:["Wrap a column in ","{ }"," to fill it from each row, e.g."," ","{"+((_==null?void 0:_[0])??"id")+"}",". Columns:"," ",e.attributes.map(A=>A.name).join(", ")]})]}),h.jsxs("div",{className:"modal-footer",children:[h.jsx("button",{className:"mini-btn",onClick:r,children:"Cancel"}),h.jsx("button",{className:"primary-btn",disabled:!m,onClick:f,children:"Save mapping"})]})]})}function Hy({doc:e,exec:t,onClose:n,onCreated:r}){const[s,i]=b.useState(""),[o,a]=b.useState(""),[l,c]=b.useState(""),[u,d]=b.useState(""),m=()=>{s.trim()&&t("create_entity",{name:s,definition:o||null,subject_area:l||null,layer:u||null}).then(f=>{const y=f==null?void 0:f.created_id;n(),y&&r(y)})};return h.jsxs(qt,{title:"New entity",onClose:n,children:[h.jsxs("label",{className:"form-row",children:["name",h.jsx("input",{autoFocus:!0,className:"edit-input",placeholder:"e.g. custody_account",value:s,onChange:f=>i(f.target.value),onKeyDown:f=>f.key==="Enter"&&m()})]}),h.jsxs("label",{className:"form-row",children:["definition",h.jsx("textarea",{className:"edit-input",rows:2,placeholder:"business definition…",value:o,onChange:f=>a(f.target.value)})]}),h.jsxs("label",{className:"form-row",children:["subject area",h.jsxs("select",{value:l,onChange:f=>c(f.target.value),children:[h.jsx("option",{value:"",children:"none"}),e.subject_areas.map(f=>h.jsx("option",{value:f.id,children:f.name},f.id))]})]}),h.jsxs("label",{className:"form-row",children:["ontology layer",h.jsxs("select",{value:u,onChange:f=>d(f.target.value),children:[h.jsx("option",{value:"",children:"none"}),fa.map(f=>h.jsx("option",{children:f},f))]})]}),h.jsx("div",{className:"modal-footer",children:h.jsx("button",{className:"primary-btn",disabled:!s.trim(),onClick:m,children:"Create"})})]})}const ha=["many_to_one","one_to_many","one_to_one","many_to_many"];function Fy({doc:e,fromId:t,toId:n,initialFromAttr:r,initialToAttr:s,exec:i,onClose:o}){const a=e.entities.find(w=>w.id===t),l=e.entities.find(w=>w.id===n),c=b.useMemo(()=>l==null?void 0:l.attributes.find(w=>w.role==="business_key"),[l]),[u,d]=b.useState(r??""),[m,f]=b.useState(s??(c==null?void 0:c.id)??""),[y,x]=b.useState("many_to_one"),[_,g]=b.useState("mandatory");if(!a||!l)return null;const v=u==="__new__",j=()=>i("create_relationship",{from_entity:a.id,to_entity:l.id,from_attribute:v?null:u||null,to_attribute:m||null,create_from_fk:v,cardinality:y,optionality:_}).then(o);return h.jsxs(qt,{title:`${a.name} → ${l.name}`,onClose:o,children:[h.jsxs("label",{className:"form-row",children:["cardinality (",a.name," : ",l.name,")",h.jsx("select",{value:y,onChange:w=>x(w.target.value),children:ha.map(w=>h.jsx("option",{children:w},w))})]}),h.jsxs("label",{className:"form-row",children:["foreign key on ",a.name,h.jsxs("select",{value:u,onChange:w=>d(w.target.value),children:[h.jsx("option",{value:"",children:"(none)"}),h.jsxs("option",{value:"__new__",children:["➕ create column",c?` "${c.name}"`:""]}),a.attributes.map(w=>h.jsx("option",{value:w.id,children:w.name},w.id))]})]}),h.jsxs("label",{className:"form-row",children:["references on ",l.name,h.jsxs("select",{value:m,onChange:w=>f(w.target.value),children:[h.jsx("option",{value:"",children:"(none)"}),l.attributes.map(w=>h.jsxs("option",{value:w.id,children:[w.name,w.role==="business_key"?" 🔑":""]},w.id))]})]}),h.jsxs("label",{className:"form-row",children:["optionality",h.jsxs("select",{value:_,onChange:w=>g(w.target.value),children:[h.jsx("option",{children:"mandatory"}),h.jsx("option",{children:"optional"})]})]}),h.jsx("div",{className:"modal-footer",children:h.jsx("button",{className:"primary-btn",onClick:j,children:"Create relationship"})})]})}function Vy({rel:e,doc:t,exec:n,onClose:r}){const s=g=>{var v;return((v=t.entities.find(j=>j.id===g))==null?void 0:v.name)??"?"},[i,o]=b.useState(e.name),[a,l]=b.useState(e.cardinality),[c,u]=b.useState(e.optionality),[d,m]=b.useState(e.identifying),[f,y]=b.useState(!1),x=async()=>{i.trim()&&i.trim()!==e.name&&await n("rename_relationship",{id:e.id,name:i.trim()}),(a!==e.cardinality||c!==e.optionality||d!==e.identifying)&&await n("update_relationship",{id:e.id,cardinality:a,optionality:c,identifying:d}),r()},_=()=>n("delete_relationship",{id:e.id}).then(r);return h.jsxs(qt,{title:`${s(e.from.entity)} → ${s(e.to.entity)}`,onClose:r,children:[h.jsxs("label",{className:"form-row",children:["relationship name",h.jsx("input",{value:i,onChange:g=>o(g.target.value),autoFocus:!0})]}),h.jsxs("label",{className:"form-row",children:["cardinality",h.jsx("select",{value:a,onChange:g=>l(g.target.value),children:ha.map(g=>h.jsx("option",{children:g},g))})]}),h.jsxs("label",{className:"form-row",children:["optionality",h.jsxs("select",{value:c,onChange:g=>u(g.target.value),children:[h.jsx("option",{value:"mandatory",children:"mandatory"}),h.jsx("option",{value:"optional",children:"optional"})]})]}),h.jsxs("label",{className:"form-row",children:["identifying",h.jsxs("select",{value:d?"yes":"no",onChange:g=>m(g.target.value==="yes"),children:[h.jsx("option",{value:"no",children:"no — parent key is a plain reference"}),h.jsx("option",{value:"yes",children:"yes — parent key is part of the child's identity"})]})]}),h.jsxs("div",{className:"modal-footer",style:{justifyContent:"space-between"},children:[f?h.jsx("button",{className:"danger-btn",onClick:_,children:"Confirm delete"}):h.jsx("button",{className:"mini-btn danger",onClick:()=>y(!0),children:"Delete relationship"}),h.jsx("button",{className:"primary-btn",onClick:x,children:"Save"})]})]})}const By=b.memo(function({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,sourcePosition:o,targetPosition:a,data:l,selected:c}){const[u]=wn({sourceX:n,sourceY:r,sourcePosition:o,targetX:s,targetY:i,targetPosition:a,borderRadius:10}),d=l==null?void 0:l.relationship,m=(l==null?void 0:l.dimmed)??!1,f=(d==null?void 0:d.cardinality)??"many_to_one",y=(d==null?void 0:d.optionality)==="optional",x=(d==null?void 0:d.identifying)??!1,_=f==="many_to_one"||f==="many_to_many",g=f==="one_to_many"||f==="many_to_many",v="rel-edge"+(c?" selected":"")+(m?" dimmed":""),j=((l==null?void 0:l.memberCount)??0)>1,w=l==null?void 0:l.onHoverEdge;return h.jsxs("g",{className:v,children:[h.jsx("path",{id:t,className:"rel-path",d:u,fill:"none",strokeDasharray:x?void 0:"6 4"}),h.jsx("path",{d:u,fill:"none",strokeWidth:14,stroke:"transparent",onMouseEnter:w?()=>w(d.id):void 0,onMouseLeave:w?()=>w(null):void 0}),h.jsx(si,{x:n,y:r,side:o,many:_,optional:y}),h.jsx(si,{x:s,y:i,side:a,many:g,optional:!1}),(c||j)&&d&&h.jsxs("text",{className:"rel-label",x:(n+s)/2,y:(r+i)/2-8,children:[c?d.name:"",j?`${c?" ":""}(${l.memberCount})`:""]})]})});function si({x:e,y:t,side:n,many:r,optional:s}){const i=n===U.Left?-1:1,o=7,a=12,l=[];return r?l.push(h.jsx("path",{className:"rel-glyph",d:`M ${e+i*a} ${t} L ${e} ${t-o} M ${e+i*a} ${t} L ${e} ${t} M ${e+i*a} ${t} L ${e} ${t+o}`,fill:"none"},"foot")):l.push(h.jsx("line",{className:"rel-glyph",x1:e+i*(a-3),y1:t-o,x2:e+i*(a-3),y2:t+o},"one")),s?l.push(h.jsx("circle",{className:"rel-glyph ring",cx:e+i*(a+6),cy:t,r:4},"opt")):l.push(h.jsx("line",{className:"rel-glyph",x1:e+i*(a+5),y1:t-o,x2:e+i*(a+5),y2:t+o},"mand")),h.jsx(h.Fragment,{children:l})}const Gy={entity:bm},Yy={relationship:By},ii=["#e0a63a","#e8825a","#d98ba8","#c4a3e0","#7fb0d8","#7fc9a0","#e6c14a"],oi="#8a7d6a";function Wy(e,t){const n=(i,o)=>{var a;return!!o&&!!((a=t.get(i))!=null&&a.attributes.some(l=>l.id===o))},r=e.from.attributes[0],s=e.to.attributes[0];return{sourceHandle:n(e.from.entity,r)?r:Rr,targetHandle:n(e.to.entity,s)?s:Or}}function _x({doc:e,caps:t,exec:n,selectedId:r,onSelect:s,query:i="",showTypes:o=!0,onError:a,handleRef:l}){const{fitView:c}=An(),[u,d]=b.useState([]),[m,f]=b.useState([]),y=b.useRef(!1),[x,_]=b.useState(null),[g,v]=b.useState(null),[j,w]=b.useState(!1),[M,C]=b.useState(null),[A,F]=b.useState(null),[S,O]=b.useState(null),[z,G]=b.useState(null),V=!t.canEdit,p=b.useMemo(()=>{const R=new Map;return e.subject_areas.forEach((H,B)=>R.set(H.id,ii[B%ii.length])),R},[e]),k=b.useMemo(()=>{const R=new Map;return e.entities.forEach(H=>R.set(H.id,H)),R},[e]),E=b.useMemo(()=>{const R=new Map,H=(B,X)=>{if(!X.length)return;const q=R.get(B)??new Set;X.forEach(J=>q.add(J)),R.set(B,q)};for(const B of e.relationships)H(B.from.entity,B.from.attributes),H(B.to.entity,B.to.attributes);return R},[e]);b.useEffect(()=>{var se;const R=i.trim().toLowerCase(),H=new Set;if(R)for(const Y of e.entities)(Y.name.toLowerCase()+" "+(((se=Y.conceptual)==null?void 0:se.name.toLowerCase())??"")+" "+Y.attributes.map(te=>te.name.toLowerCase()).join(" ")).includes(R)&&H.add(Y.id);const B=new Set;if(r){B.add(r);for(const Y of e.relationships)Y.from.entity===r&&B.add(Y.to.entity),Y.to.entity===r&&B.add(Y.from.entity)}const X=new Set,q=new Set,J=new Map,Q=(Y,ne)=>{if(!ne.length)return;const te=J.get(Y)??new Set;ne.forEach(le=>te.add(le)),J.set(Y,te)};if(S)for(const Y of e.relationships)(Y.from.attributes.includes(S)||Y.to.attributes.includes(S))&&(X.add(Y.id),q.add(Y.from.entity),q.add(Y.to.entity),Q(Y.from.entity,Y.from.attributes),Q(Y.to.entity,Y.to.attributes));if(z){const Y=e.relationships.find(ne=>ne.id===z);Y&&(Q(Y.from.entity,Y.from.attributes),Q(Y.to.entity,Y.to.attributes))}const K=e.entities.map(Y=>{var ee;const ne=R!==""&&!H.has(Y.id),te=r!==null&&!B.has(Y.id),le=S!==null&&!q.has(Y.id);return{id:Y.id,type:"entity",position:{x:0,y:0},data:{entity:Y,color:(ee=Y.conceptual)!=null&&ee.subject_area?p.get(Y.conceptual.subject_area.id)??oi:oi,dimmed:ne||te||le,highlighted:R!==""&&H.has(Y.id)||S!==null&&q.has(Y.id),showTypes:o,endpointAttrs:E.get(Y.id),highlightAttrs:J.get(Y.id),onHoverAttr:O}}}),ae=e.relationships.filter(Y=>k.has(Y.from.entity)&&k.has(Y.to.entity)).map(Y=>{const{sourceHandle:ne,targetHandle:te}=Wy(Y,k),le=r!==null&&Y.from.entity!==r&&Y.to.entity!==r,ee=S!==null&&!X.has(Y.id);return{id:Y.id,source:Y.from.entity,target:Y.to.entity,sourceHandle:ne,targetHandle:te,type:"relationship",data:{relationship:Y,dimmed:le||ee,memberCount:Math.max(Y.from.attributes.length,Y.to.attributes.length),onHoverEdge:G}}});d(Y=>{const ne=new Map(Y.map(W=>[W.id,W.position])),te=K.every(W=>ne.has(W.id));if(y.current&&te&&Y.length>=K.length)return K.map(W=>({...W,position:ne.get(W.id)??W.position}));const ee=ri(K,ae,k).map(W=>ne.has(W.id)&&y.current?{...W,position:ne.get(W.id)}:W);return y.current=!0,requestAnimationFrame(()=>c({padding:.15,duration:300})),ee}),f(ae)},[e,i,r,o,p,k,E,S,z,c]);const T=b.useCallback(()=>{d(R=>ri(R,m,k)),requestAnimationFrame(()=>c({padding:.15,duration:300}))},[m,k,c]),D=b.useCallback(R=>{s(R),d(H=>(H.find(X=>X.id===R)&&requestAnimationFrame(()=>c({nodes:[{id:R}],padding:.4,duration:400})),H))},[c,s]);b.useImperativeHandle(l,()=>({relayout:T,fitView:()=>c({padding:.15,duration:300}),focusEntity:D,newEntity:()=>w(!0)}),[T,c,D]);const N=b.useCallback(R=>{if(V||!R.source||!R.target||R.source===R.target)return;const H=R.sourceHandle&&R.sourceHandle!==Rr?R.sourceHandle:void 0,B=R.targetHandle&&R.targetHandle!==Or?R.targetHandle:void 0;C({from:R.source,to:R.target,fromAttr:H,toAttr:B})},[V]),I=b.useCallback(async(R,H)=>{try{return await n(R,H)}catch(B){throw a==null||a(B instanceof Error?B.message:String(B)),B}},[n,a]),L=r?k.get(r)??null:null,P=e.relationships.find(R=>R.id===A)??null;return h.jsxs(h.Fragment,{children:[h.jsxs(Ao,{nodes:u,edges:m,nodeTypes:Gy,edgeTypes:Yy,onNodeClick:(R,H)=>s(H.id),onEdgeClick:(R,H)=>!V&&F(H.id),onPaneClick:()=>{s(null),F(null)},onNodeDragStop:(R,H)=>d(B=>B.map(X=>X.id===H.id?{...X,position:H.position}:X)),onConnect:N,nodesConnectable:!V,minZoom:.05,onlyRenderVisibleElements:!0,proOptions:{hideAttribution:!0},fitView:!0,children:[h.jsx(cm,{variant:be.Dots,gap:22,size:1.5,color:"#33291f"}),h.jsx(Zh,{pannable:!0,zoomable:!0,nodeColor:R=>{var H;return((H=R.data)==null?void 0:H.color)??"#5a4f42"},maskColor:"rgba(20, 17, 15, 0.75)"}),h.jsx(rm,{showInteractive:!1})]}),L&&h.jsx(_m,{entity:L,doc:e,caps:t,exec:I,onClose:()=>s(null),onFocusEntity:D,onAlign:_,onEditMapping:v}),x&&h.jsx(Py,{entity:x,exec:I,onClose:()=>_(null)}),g&&h.jsx(zy,{entity:g,doc:e,exec:I,onClose:()=>v(null)}),j&&h.jsx(Hy,{doc:e,exec:I,onClose:()=>w(!1),onCreated:D}),M&&h.jsx(Fy,{doc:e,fromId:M.from,toId:M.to,initialFromAttr:M.fromAttr,initialToAttr:M.toAttr,exec:I,onClose:()=>C(null)}),P&&h.jsx(Vy,{rel:P,doc:e,exec:I,onClose:()=>F(null)})]})}function Ex({tab:e,onClose:t,readOnly:n,refreshKey:r,onModelChanged:s,onFocusEntity:i}){return h.jsxs("aside",{className:"side-panel",children:[h.jsxs("div",{className:"detail-header",children:[h.jsxs("h2",{children:[e==="ontology"&&"Ontology",e==="layers"&&"Ontology layers",e==="changes"&&"Uncommitted changes",e==="decisions"&&"Decision ledger"]}),h.jsx("button",{className:"icon-btn",onClick:t,children:"✕"})]}),e==="ontology"&&h.jsx(Uy,{}),e==="layers"&&h.jsx(qy,{refreshKey:r,onFocusEntity:i}),e==="changes"&&h.jsx(Zy,{readOnly:n,refreshKey:r,onModelChanged:s}),e==="decisions"&&h.jsx(Ky,{readOnly:n})]})}function Uy(){const[e,t]=b.useState(""),[n,r]=b.useState([]),[s,i]=b.useState({loaded:0,vocabs:[]}),[o,a]=b.useState(null),[l,c]=b.useState([]),[u,d]=b.useState("");b.useEffect(()=>{zo().then(f=>c(f.ontologies)).catch(()=>{})},[]),b.useEffect(()=>{const f=setTimeout(()=>{Po(e||"a",u||void 0).then(y=>{r(e?y.results:[]),i({loaded:y.loaded_terms,vocabs:y.vocabularies})}).catch(()=>{})},200);return()=>clearTimeout(f)},[e,u]);const m=b.useCallback(f=>{um(f).then(a).catch(()=>{})},[]);return o?h.jsxs("div",{className:"panel-body",children:[h.jsx("button",{className:"mini-btn",onClick:()=>a(null),children:"← back"}),h.jsx("h3",{style:{marginTop:12},children:o.label}),h.jsx("code",{className:"term-iri",children:o.prefixed}),o.definition&&h.jsx("p",{className:"term-def",children:o.definition}),h.jsxs("div",{className:"kv",children:[h.jsx("span",{className:"k",children:"source"}),h.jsx("span",{className:"v",children:o.source})]}),o.broader.length>0&&h.jsxs(h.Fragment,{children:[h.jsx("h4",{children:"broader"}),o.broader.map(f=>h.jsxs("button",{className:"rel-link",onClick:()=>m(f.iri),children:["↑ ",f.label]},f.iri))]}),o.narrower.length>0&&h.jsxs(h.Fragment,{children:[h.jsx("h4",{children:"narrower"}),o.narrower.map(f=>h.jsxs("button",{className:"rel-link",onClick:()=>m(f.iri),children:["↓ ",f.label]},f.iri))]})]}):h.jsxs("div",{className:"panel-body",children:[l.length>0&&h.jsxs("div",{className:"src-picker",children:[h.jsx("button",{className:"src-chip"+(u===""?" active":""),onClick:()=>d(""),children:"all sources"}),l.map(f=>h.jsxs("button",{className:"src-chip"+(u===f.id?" active":""),title:(f.description??"")+(f.count!=null?` · ${f.count} terms`:" · live"),onClick:()=>d(f.id),children:[f.name,f.layer&&h.jsx("span",{className:`src-layer layer-${f.layer}`,children:f.layer})]},f.id))]}),h.jsx("input",{className:"edit-input",placeholder:u?`Search within ${u}…`:"Search vocabulary terms…",value:e,onChange:f=>t(f.target.value)}),h.jsx("p",{className:"meta-line",children:l.length>0?`${l.length} source${l.length>1?"s":""}: ${s.vocabs.join(", ")}`+(s.loaded>0?` · ${s.loaded} local terms indexed`:""):"no vocabulary loaded — declare ontology_stack in mdl-project.yaml or run `mdl ontology vendor fibo`"}),h.jsx("div",{className:"term-results",children:n.map(f=>h.jsxs("button",{className:"term-card",onClick:()=>m(f.prefixed),children:[h.jsxs("div",{className:"term-head",children:[h.jsx("span",{className:"term-label",children:f.label}),h.jsxs("span",{className:"term-source",children:[f.source_kind==="glossary-term"&&h.jsx("span",{className:"kind-badge",title:"glossary term",children:"glossary"}),f.source]})]}),h.jsx("code",{className:"term-iri",children:f.prefixed}),f.definition&&h.jsx("p",{className:"term-def",children:f.definition})]},f.iri))})]})}const Xy=["industry","core","domain","specialised"];function qy({refreshKey:e,onFocusEntity:t}){const[n,r]=b.useState(null),[s,i]=b.useState(null);if(b.useEffect(()=>{dm().then(r).catch(()=>{}),fm().then(i).catch(()=>{})},[e]),!n)return h.jsx("div",{className:"panel-body",children:"loading…"});const o=new Set((s==null?void 0:s.core_uncovered)??[]);return h.jsxs("div",{className:"panel-body",children:[s&&h.jsxs("div",{className:"coverage-banner"+(s.coverage_pct<100?" warn":""),children:["industry alignment coverage: ",h.jsxs("b",{children:[s.coverage_pct,"%"]})," (",s.core_with_industry,"+",s.core_exempt,"/",s.total_core," core terms)"]}),h.jsxs("div",{className:"layer-band external",children:[h.jsx("h4",{children:"industry (external vocabularies)"}),n.external_terms.length===0&&h.jsx("p",{className:"empty-hint",children:"no aligned terms yet"}),n.external_terms.map(a=>h.jsxs("div",{className:"stack-term external",title:a.definition??void 0,children:[a.label,h.jsx("span",{className:"term-source",children:a.source})]},a.iri))]}),Xy.slice(1).map(a=>h.jsxs("div",{className:"layer-band",children:[h.jsx("h4",{children:a}),(n.layers[a]??[]).length===0&&h.jsx("p",{className:"empty-hint",children:"—"}),(n.layers[a]??[]).map(l=>{var c;return h.jsxs("button",{className:"stack-term"+(o.has(l.name)?" uncovered":""),title:l.definition??void 0,onClick:()=>t(l.id),children:[l.name,(l.aligned_refs??(l.aligned_to?[l.aligned_to]:[])).map((u,d)=>h.jsxs("span",{className:"align-arrow"+(u.resolved?"":" unresolved")+(u.status==="proposed"?" proposed":""),title:u.ref+(u.resolved_via?` (via ${u.resolved_via})`:""),children:["↑ ",u.label,u.status==="proposed"?" ·prop":""]},`${u.ref}-${d}`)),!l.aligned_to&&(((c=l.aligned_refs)==null?void 0:c.length)??0)===0&&!l.no_industry_equivalent&&h.jsx("span",{className:"align-arrow missing",children:"unaligned"})]},l.id)})]},a))]})}function Zy({readOnly:e,refreshKey:t,onModelChanged:n}){const[r,s]=b.useState(null),[i,o]=b.useState(""),[a,l]=b.useState(""),[c,u]=b.useState(!1),d=b.useCallback(()=>{hm().then(s).catch(()=>s(null)),mm().then(m=>o([m.diff,...m.untracked].filter(Boolean).join(` `))).catch(()=>o(""))},[]);return b.useEffect(d,[d,t]),r!=null&&r.git?r.clean?h.jsx("div",{className:"panel-body ok",children:"✓ working tree clean"}):h.jsxs("div",{className:"panel-body",children:[h.jsx("ul",{className:"dirty-list",children:r.dirty.map(m=>h.jsxs("li",{children:[h.jsx("code",{className:"dirty-state",children:m.state})," ",m.path]},m.path))}),h.jsx("pre",{className:"diff-view",children:i.split(` `).map((m,f)=>h.jsx("span",{className:m.startsWith("+")&&!m.startsWith("+++")?"diff-add":m.startsWith("-")&&!m.startsWith("---")?"diff-del":m.startsWith("@@")?"diff-hunk":"",children:m+` diff --git a/packages/server/src/mdl_server/static/assets/styles-D49vPB68.css b/packages/server/src/mdl_server/static/assets/styles-D49vPB68.css new file mode 100644 index 0000000..9976f7d --- /dev/null +++ b/packages/server/src/mdl_server/static/assets/styles-D49vPB68.css @@ -0,0 +1 @@ +.react-flow{direction:ltr}.react-flow__container{position:absolute;width:100%;height:100%;top:0;left:0}.react-flow__pane{z-index:1;cursor:-webkit-grab;cursor:grab}.react-flow__pane.selection{cursor:pointer}.react-flow__pane.dragging{cursor:-webkit-grabbing;cursor:grabbing}.react-flow__viewport{transform-origin:0 0;z-index:2;pointer-events:none}.react-flow__renderer{z-index:4}.react-flow__selection{z-index:6}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible{outline:none}.react-flow .react-flow__edges{pointer-events:none;overflow:visible}.react-flow__edge-path,.react-flow__connection-path{stroke:#b1b1b7;stroke-width:1;fill:none}.react-flow__edge{pointer-events:visibleStroke;cursor:pointer}.react-flow__edge.animated path{stroke-dasharray:5;-webkit-animation:dashdraw .5s linear infinite;animation:dashdraw .5s linear infinite}.react-flow__edge.animated path.react-flow__edge-interaction{stroke-dasharray:none;-webkit-animation:none;animation:none}.react-flow__edge.inactive{pointer-events:none}.react-flow__edge.selected,.react-flow__edge:focus,.react-flow__edge:focus-visible{outline:none}.react-flow__edge.selected .react-flow__edge-path,.react-flow__edge:focus .react-flow__edge-path,.react-flow__edge:focus-visible .react-flow__edge-path{stroke:#555}.react-flow__edge-textwrapper{pointer-events:all}.react-flow__edge-textbg{fill:#fff}.react-flow__edge .react-flow__edge-text{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__connection{pointer-events:none}.react-flow__connection .animated{stroke-dasharray:5;-webkit-animation:dashdraw .5s linear infinite;animation:dashdraw .5s linear infinite}.react-flow__connectionline{z-index:1001}.react-flow__nodes{pointer-events:none;transform-origin:0 0}.react-flow__node{position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:all;transform-origin:0 0;box-sizing:border-box;cursor:-webkit-grab;cursor:grab}.react-flow__node.dragging{cursor:-webkit-grabbing;cursor:grabbing}.react-flow__nodesselection{z-index:3;transform-origin:left top;pointer-events:none}.react-flow__nodesselection-rect{position:absolute;pointer-events:all;cursor:-webkit-grab;cursor:grab}.react-flow__handle{position:absolute;pointer-events:none;min-width:5px;min-height:5px;width:6px;height:6px;background:#1a192b;border:1px solid white;border-radius:100%}.react-flow__handle.connectionindicator{pointer-events:all;cursor:crosshair}.react-flow__handle-bottom{top:auto;left:50%;bottom:-4px;transform:translate(-50%)}.react-flow__handle-top{left:50%;top:-4px;transform:translate(-50%)}.react-flow__handle-left{top:50%;left:-4px;transform:translateY(-50%)}.react-flow__handle-right{right:-4px;top:50%;transform:translateY(-50%)}.react-flow__edgeupdater{cursor:move;pointer-events:all}.react-flow__panel{position:absolute;z-index:5;margin:15px}.react-flow__panel.top{top:0}.react-flow__panel.bottom{bottom:0}.react-flow__panel.left{left:0}.react-flow__panel.right{right:0}.react-flow__panel.center{left:50%;transform:translate(-50%)}.react-flow__attribution{font-size:10px;background:#ffffff80;padding:2px 3px;margin:0}.react-flow__attribution a{text-decoration:none;color:#999}@-webkit-keyframes dashdraw{0%{stroke-dashoffset:10}}@keyframes dashdraw{0%{stroke-dashoffset:10}}.react-flow__edgelabel-renderer{position:absolute;width:100%;height:100%;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__edge.updating .react-flow__edge-path{stroke:#777}.react-flow__edge-text{font-size:10px}.react-flow__node.selectable:focus,.react-flow__node.selectable:focus-visible{outline:none}.react-flow__node-default,.react-flow__node-input,.react-flow__node-output,.react-flow__node-group{padding:10px;border-radius:3px;width:150px;font-size:12px;color:#222;text-align:center;border-width:1px;border-style:solid;border-color:#1a192b;background-color:#fff}.react-flow__node-default.selectable:hover,.react-flow__node-input.selectable:hover,.react-flow__node-output.selectable:hover,.react-flow__node-group.selectable:hover{box-shadow:0 1px 4px 1px #00000014}.react-flow__node-default.selectable.selected,.react-flow__node-default.selectable:focus,.react-flow__node-default.selectable:focus-visible,.react-flow__node-input.selectable.selected,.react-flow__node-input.selectable:focus,.react-flow__node-input.selectable:focus-visible,.react-flow__node-output.selectable.selected,.react-flow__node-output.selectable:focus,.react-flow__node-output.selectable:focus-visible,.react-flow__node-group.selectable.selected,.react-flow__node-group.selectable:focus,.react-flow__node-group.selectable:focus-visible{box-shadow:0 0 0 .5px #1a192b}.react-flow__node-group{background-color:#f0f0f040}.react-flow__nodesselection-rect,.react-flow__selection{background:#0059dc14;border:1px dotted rgba(0,89,220,.8)}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible,.react-flow__selection:focus,.react-flow__selection:focus-visible{outline:none}.react-flow__controls{box-shadow:0 0 2px 1px #00000014}.react-flow__controls-button{border:none;background:#fefefe;border-bottom:1px solid #eee;box-sizing:content-box;display:flex;justify-content:center;align-items:center;width:16px;height:16px;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none;padding:5px}.react-flow__controls-button:hover{background:#f4f4f4}.react-flow__controls-button svg{width:100%;max-width:12px;max-height:12px}.react-flow__controls-button:disabled{pointer-events:none}.react-flow__controls-button:disabled svg{fill-opacity:.4}.react-flow__minimap{background-color:#fff}.react-flow__minimap svg{display:block}.react-flow__resize-control{position:absolute}.react-flow__resize-control.left,.react-flow__resize-control.right{cursor:ew-resize}.react-flow__resize-control.top,.react-flow__resize-control.bottom{cursor:ns-resize}.react-flow__resize-control.top.left,.react-flow__resize-control.bottom.right{cursor:nwse-resize}.react-flow__resize-control.bottom.left,.react-flow__resize-control.top.right{cursor:nesw-resize}.react-flow__resize-control.handle{width:4px;height:4px;border:1px solid #fff;border-radius:1px;background-color:#3367d9;transform:translate(-50%,-50%)}.react-flow__resize-control.handle.left{left:0;top:50%}.react-flow__resize-control.handle.right{left:100%;top:50%}.react-flow__resize-control.handle.top{left:50%;top:0}.react-flow__resize-control.handle.bottom{left:50%;top:100%}.react-flow__resize-control.handle.top.left,.react-flow__resize-control.handle.bottom.left{left:0}.react-flow__resize-control.handle.top.right,.react-flow__resize-control.handle.bottom.right{left:100%}.react-flow__resize-control.line{border-color:#3367d9;border-width:0;border-style:solid}.react-flow__resize-control.line.left,.react-flow__resize-control.line.right{width:1px;transform:translate(-50%);top:0;height:100%}.react-flow__resize-control.line.left{left:0;border-left-width:1px}.react-flow__resize-control.line.right{left:100%;border-right-width:1px}.react-flow__resize-control.line.top,.react-flow__resize-control.line.bottom{height:1px;transform:translateY(-50%);left:0;width:100%}.react-flow__resize-control.line.top{top:0;border-top-width:1px}.react-flow__resize-control.line.bottom{border-bottom-width:1px;top:100%}:root{--bg: #14110f;--bg-raised: #1c1815;--bg-card: #221d19;--border: #33291f;--border-strong: #4a3c2c;--text: #ece6dd;--text-dim: #a89a86;--accent: #e0a63a;--accent-soft: rgba(224, 166, 58, .15);--accent-ink: #241a08;--pk: #f2c14e;--err: #f0857a;--warn: #e6a94a;--ok: #6cbf73;--font: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;--mono: "SF Mono", ui-monospace, "Cascadia Code", Menlo, monospace}*{box-sizing:border-box}html,body,#root{height:100%;margin:0}body{font-family:var(--font);background:var(--bg);color:var(--text)}.app{display:flex;flex-direction:column;height:100%}.canvas-wrap{flex:1;position:relative;min-height:0}.react-flow{background:var(--bg)}.topbar{display:flex;align-items:center;gap:16px;padding:10px 16px;background:var(--bg-raised);border-bottom:1px solid var(--border);z-index:10}.brand{display:flex;align-items:baseline;gap:8px;white-space:nowrap}.logo{color:var(--accent);font-size:18px}.brand-name{font-weight:700;letter-spacing:.02em}.project-name{color:var(--text-dim);font-size:13px}.search{flex:0 1 340px;padding:7px 12px;border-radius:8px;border:1px solid var(--border);background:var(--bg-card);color:var(--text);font-size:13px;outline:none}.search:focus{border-color:var(--accent)}.legend{display:flex;gap:12px;flex-wrap:wrap;font-size:12px;color:var(--text-dim)}.legend-item{display:inline-flex;align-items:center;gap:5px}.swatch{width:10px;height:10px;border-radius:3px;display:inline-block}.stats{margin-left:auto;display:flex;gap:12px;font-size:12px;color:var(--text-dim)}.diag-chip{padding:2px 8px;border-radius:99px;font-weight:600}.diag-chip.ok{background:#34d39926;color:var(--ok)}.diag-chip.warn{background:#fbbf2426;color:var(--warn)}.diag-chip.err{background:#f8717126;color:var(--err)}.actions{display:flex;gap:6px}.tool-btn{padding:6px 10px;border-radius:8px;border:1px solid var(--border);background:var(--bg-card);color:var(--text-dim);cursor:pointer;font-size:13px}.tool-btn:hover{color:var(--text);border-color:var(--border-strong)}.tool-btn.active{color:var(--accent);border-color:var(--accent)}.entity-node{width:264px;background:var(--bg-card);border:1px solid var(--border);border-top:3px solid var(--accent);border-radius:10px;overflow:hidden;box-shadow:0 4px 18px #00000059;font-size:12px;transition:opacity .15s,box-shadow .15s,border-color .15s}.entity-node.selected{border-color:var(--accent);box-shadow:0 0 0 2px var(--accent),0 8px 24px #00000080}.entity-node.highlighted{box-shadow:0 0 0 2px var(--pk),0 8px 24px #00000080}.entity-node.dimmed{opacity:.18}.entity-header{display:flex;align-items:center;justify-content:space-between;padding:10px 12px;background:#ffffff08;border-bottom:1px solid var(--border)}.entity-name{font-weight:700;font-size:13px;letter-spacing:.01em}.entity-badges{display:flex;gap:4px}.badge{font-size:10px;padding:1px 6px;border-radius:99px;background:var(--accent-soft);color:var(--accent);text-transform:uppercase;letter-spacing:.05em}.badge.ontology{background:#93c5fd1f;color:#93c5fd}.attr-section{padding:4px 0}.attr-section.keys{border-bottom:1px solid var(--border);background:#fcd34d0a}.attr-row{display:flex;align-items:center;gap:6px;padding:3px 12px;height:26px;line-height:20px;position:relative}.attr-row.empty{color:var(--text-dim);font-style:italic}.attr-row.rel-hit{background:var(--accent-soft);box-shadow:inset 2px 0 0 var(--accent)}.attr-row.rel-hit .attr-name{color:var(--accent);font-weight:600}.attr-row.rel-dim{opacity:.35}.attr-row.endpoint .attr-name{font-style:normal}.attr-port{width:8px!important;height:8px!important;opacity:0;top:50%!important}.attr-port.react-flow__handle-left{left:-5px!important}.attr-port.react-flow__handle-right{right:-5px!important}.entity-node:hover .attr-port{opacity:.5}.attr-row:hover .attr-port{opacity:1!important;background:var(--accent)!important}.attr-icon{width:14px;text-align:center;font-size:10px;flex:none}.attr-name{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.attr-name.pk{color:var(--pk);font-weight:600}.attr-type{color:var(--text-dim);font-family:var(--mono);font-size:10px;flex:none}.attr-notnull{color:var(--text-dim);font-size:8px;flex:none}.port{width:11px!important;height:11px!important;background:var(--border-strong)!important;border:2px solid var(--bg)!important;opacity:.55;transition:transform .12s ease,background .12s ease,opacity .12s ease}.entity-node:hover .port{opacity:1;background:var(--accent)!important;transform:scale(1.25);box-shadow:0 0 0 4px var(--accent-soft);cursor:crosshair}.port:hover{transform:scale(1.6)!important;cursor:crosshair}.entity-node:hover{border-color:var(--accent);box-shadow:0 0 0 1px #e0a63a40}.react-flow__connectionline .react-flow__edge-path,.react-flow__connection-path{stroke:var(--accent)!important;stroke-width:2!important}.rel-path{stroke:var(--border-strong);stroke-width:1.6}.rel-edge{cursor:pointer}.rel-glyph{stroke:var(--border-strong);stroke-width:1.6;fill:none}.rel-glyph.ring{fill:var(--bg)}.rel-edge:hover .rel-path,.rel-edge.selected .rel-path,.rel-edge:hover .rel-glyph,.rel-edge.selected .rel-glyph{stroke:var(--accent)}.rel-edge.dimmed{opacity:.12}.rel-label{fill:var(--text);font-size:11px;text-anchor:middle;paint-order:stroke;stroke:var(--bg);stroke-width:4px}.detail-panel{position:absolute;top:12px;right:12px;bottom:12px;width:340px;background:var(--bg-raised);border:1px solid var(--border);border-radius:14px;padding:18px;overflow-y:auto;z-index:9;box-shadow:0 12px 40px #00000080}.detail-header{display:flex;justify-content:space-between;align-items:flex-start}.detail-header h2{margin:0 0 6px;font-size:18px}.icon-btn{background:none;border:none;color:var(--text-dim);cursor:pointer;font-size:14px}.icon-btn:hover{color:var(--text)}.definition{color:var(--text-dim);font-size:13px;line-height:1.5}.detail-panel section{margin-top:18px}.detail-panel h3{margin:0 0 8px;font-size:11px;text-transform:uppercase;letter-spacing:.08em;color:var(--text-dim)}.kv{display:flex;gap:8px;margin:4px 0;font-size:12px;align-items:baseline}.kv .k{color:var(--text-dim);min-width:72px}.kv .v{word-break:break-all}.chip{display:inline-block;font-size:11px;padding:2px 8px;margin:2px 4px 2px 0;border-radius:99px;background:#94a3b81f;color:var(--text-dim)}.chip.pattern{background:var(--accent-soft);color:var(--accent)}.chip.layer-industry{background:#93c5fd26;color:#93c5fd}.chip.layer-core{background:var(--accent-soft);color:var(--accent)}.chip.layer-domain{background:#f0abfc26;color:#f0abfc}.chip.layer-specialised{background:#fcd34d26;color:var(--pk)}.cat-badge{font-size:10px;font-weight:700;margin-left:6px;padding:2px 8px;border-radius:5px;cursor:help}.cat-badge.supertype{background:#a78bfa2e;color:#a78bfa}.cat-badge.subtype{background:var(--accent-soft);color:var(--accent)}.udp-row td{padding:3px 6px;border-bottom:1px solid var(--border);font-size:12px}.udp-key{color:var(--text-dim);font-family:var(--mono);font-size:11px}.udp-val{color:var(--text)}.enum-badge{font-size:8px;font-weight:700;margin-left:6px;padding:1px 5px;border-radius:4px;background:#a78bfa2e;color:#a78bfa;vertical-align:middle;cursor:help}.key-row{display:flex;align-items:center;gap:8px;padding:4px 0;font-size:12px}.key-badge{font-size:9px;font-weight:700;padding:2px 6px;border-radius:5px;background:#94a3b826;color:var(--text-dim);flex:none}.key-badge.pk{background:#fcd34d2e;color:var(--pk)}.key-badge.unique,.key-badge.alternate{background:var(--accent-soft);color:var(--accent)}.key-name{font-weight:600}.key-cols{color:var(--text-dim);font-family:var(--mono);font-size:11px}.attr-table{width:100%;border-collapse:collapse;font-size:12px;table-layout:auto}.attr-table td{padding:4px 6px;border-bottom:1px solid var(--border)}.attr-table td:first-child{width:100%}.attr-table td:first-child .edit-input{min-width:120px}.attr-table td.pk{color:var(--pk);font-weight:600}.attr-table td.type{color:var(--text-dim);font-family:var(--mono);font-size:11px}.attr-table td.null{color:var(--text-dim);font-size:10px;text-align:right}.rel-link{display:flex;gap:8px;align-items:center;width:100%;background:var(--bg-card);border:1px solid var(--border);border-radius:8px;color:var(--text);padding:7px 10px;margin:4px 0;cursor:pointer;font-size:12px;text-align:left}.rel-link:hover{border-color:var(--accent)}.rel-card{color:var(--text-dim);font-family:var(--mono);font-size:11px}.ulid{font-family:var(--mono);font-size:11px;color:var(--text-dim);cursor:copy;word-break:break-all}.ulid:hover{color:var(--accent)}.splash{height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;color:var(--text-dim)}.splash.error pre{background:var(--bg-card);padding:12px 16px;border-radius:8px;max-width:640px;overflow:auto;color:var(--err);font-size:12px}.react-flow__minimap{background:var(--bg-raised)!important;border-radius:10px}.react-flow__controls{border-radius:10px;overflow:hidden;box-shadow:none!important}.react-flow__controls-button{background:var(--bg-raised)!important;border-bottom:1px solid var(--border)!important;fill:var(--text-dim)!important}.react-flow__controls-button:hover{fill:var(--text)!important}.edit-input{width:100%;padding:6px 9px;border-radius:7px;font-size:12px;border:1px solid var(--border);background:var(--bg-card);color:var(--text);font-family:var(--font);outline:none}.edit-input:focus{border-color:var(--accent)}.entity-title-input{font-size:17px;font-weight:700;background:transparent;border-color:transparent;padding-left:0}.entity-title-input:hover,.entity-title-input:focus{border-color:var(--border);background:var(--bg-card);padding-left:9px}.definition-input{color:var(--text-dim);line-height:1.5;resize:vertical}.chip-select,.cell-select{font-size:11px;padding:2px 6px;margin:2px 6px 2px 0;border-radius:99px;background:#94a3b81f;color:var(--text-dim);border:1px solid transparent;outline:none}.chip-select:hover,.cell-select:hover{border-color:var(--border-strong);color:var(--text)}.cell-select{border-radius:6px;background:transparent;max-width:110px}.mini-btn{font-size:11px;padding:3px 9px;border-radius:7px;cursor:pointer;border:1px solid var(--border);background:var(--bg-card);color:var(--text-dim)}.mini-btn:hover{color:var(--accent);border-color:var(--accent)}.mini-btn.danger:hover{color:var(--err);border-color:var(--err)}.h3-actions{float:right;display:inline-flex;gap:6px}.empty-hint{color:var(--text-dim);font-size:12px;font-style:italic}.add-attr{display:flex;gap:6px;margin-top:8px}.rel-row{display:flex;gap:6px;align-items:center}.rel-row .rel-link{flex:1}.tool-btn.primary{color:var(--accent);border-color:#e0a63a66;font-weight:600}.tool-btn.badged:after{content:"●";color:var(--warn);margin-left:4px;font-size:8px;vertical-align:super}.divider{width:1px;background:var(--border);margin:0 4px;align-self:stretch}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;background:#05080db3;z-index:50;display:flex;align-items:center;justify-content:center}.modal{width:440px;max-height:80vh;overflow-y:auto;background:var(--bg-raised);border:1px solid var(--border-strong);border-radius:14px;padding:20px;box-shadow:0 24px 80px #0009}.modal.wide{width:600px}.modal-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:14px}.modal-header h2{margin:0;font-size:16px}.modal-search{margin-bottom:10px}.modal-footer{display:flex;gap:10px;justify-content:flex-end;align-items:center;margin-top:14px}.modal-footer label{font-size:11px;color:var(--text-dim);display:flex;flex-direction:column;gap:3px}.modal-footer select,.form-row select{background:var(--bg-card);color:var(--text);border:1px solid var(--border);border-radius:7px;padding:5px 8px;font-size:12px}.primary-btn{padding:8px 16px;border-radius:8px;border:none;cursor:pointer;background:var(--accent);color:var(--accent-ink);font-weight:700;font-size:13px}.primary-btn:disabled{opacity:.4;cursor:default}.danger-btn{padding:8px 16px;border-radius:8px;border:1px solid var(--err);cursor:pointer;background:#f8717124;color:var(--err);font-weight:700;font-size:13px}.form-row{display:flex;flex-direction:column;gap:4px;margin-bottom:14px;font-size:12px;color:var(--text-dim)}.form-row>label{font-weight:600;letter-spacing:.02em;text-transform:uppercase;font-size:10px}.form-error{color:var(--err);font-size:11px}.form-preview{color:var(--text-dim);font-size:11px;word-break:break-all;opacity:.85}.form-preview:before{content:""}.form-hint{color:var(--text-dim);font-size:11px;font-style:italic;opacity:.75;word-break:break-word}.term-results{display:flex;flex-direction:column;gap:8px;max-height:44vh;overflow-y:auto}.term-card{text-align:left;background:var(--bg-card);border:1px solid var(--border);border-radius:10px;padding:10px 12px;cursor:pointer;color:var(--text)}.term-card:hover{border-color:var(--border-strong)}.term-card.picked{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}.term-head{display:flex;justify-content:space-between;align-items:baseline}.term-label{font-weight:600;font-size:13px}.term-source{font-size:10px;color:var(--text-dim);text-transform:uppercase;letter-spacing:.06em}.term-iri{font-size:10px;color:var(--accent);display:block;margin:2px 0;word-break:break-all}.term-def{font-size:11px;color:var(--text-dim);margin:4px 0 0;line-height:1.45}.kind-badge{font-size:8px;padding:1px 5px;margin-right:6px;border-radius:999px;background:#f0abfc26;color:#f0abfc;letter-spacing:.04em}.src-picker{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:10px}.src-chip{display:inline-flex;align-items:center;gap:5px;font-size:11px;padding:3px 9px;border-radius:999px;background:var(--bg);border:1px solid var(--border);color:var(--text-dim);cursor:pointer}.src-chip:hover{border-color:var(--border-strong);color:var(--text)}.src-chip.active{border-color:var(--accent);color:var(--accent);background:var(--accent-soft)}.src-layer{font-size:8px;padding:0 5px;border-radius:999px;text-transform:uppercase;letter-spacing:.04em}.side-panel{position:absolute;top:12px;right:12px;bottom:12px;width:380px;background:var(--bg-raised);border:1px solid var(--border);border-radius:14px;padding:18px;overflow-y:auto;z-index:9;box-shadow:0 12px 40px #00000080}.side-panel h2{margin:0;font-size:16px}.side-panel h4{margin:10px 0 6px;font-size:10px;text-transform:uppercase;letter-spacing:.08em;color:var(--text-dim)}.panel-body{margin-top:12px}.panel-body.ok{color:var(--ok)}.meta-line{font-size:10px;color:var(--text-dim);margin:6px 0 10px}.coverage-banner{font-size:12px;padding:8px 12px;border-radius:9px;margin-bottom:12px;background:#34d3991a;color:var(--ok)}.coverage-banner.warn{background:#fbbf241a;color:var(--warn)}.layer-band{border:1px dashed var(--border);border-radius:10px;padding:8px 12px 10px;margin-bottom:10px}.layer-band.external{border-style:solid;background:#93c5fd0a}.stack-term{display:flex;justify-content:space-between;align-items:baseline;gap:8px;width:100%;background:var(--bg-card);border:1px solid var(--border);color:var(--text);border-radius:7px;padding:5px 10px;margin:4px 0;font-size:12px;cursor:pointer;text-align:left}div.stack-term{cursor:default}.stack-term:hover{border-color:var(--border-strong)}.stack-term.uncovered{border-color:var(--err)}.align-arrow{font-size:10px;color:var(--accent);white-space:nowrap}.align-arrow.unresolved{color:var(--warn)}.align-arrow.missing{color:var(--err);font-style:italic}.align-arrow.proposed{color:var(--warn);font-style:italic}.ref-list{display:flex;flex-direction:column;gap:6px;margin-top:4px}.ref-card{border:1px solid var(--border);border-radius:8px;padding:6px 8px;background:var(--bg)}.ref-card.proposed{border-color:var(--warn)}.ref-head{display:flex;align-items:baseline;gap:8px;justify-content:space-between}.ref-uri{font-family:var(--mono);font-size:12px;word-break:break-all}.ref-status{font-size:9px;text-transform:uppercase;letter-spacing:.04em}.ref-status.accepted{color:var(--accent)}.ref-status.proposed{color:var(--warn)}.ref-meta{display:flex;flex-wrap:wrap;align-items:center;gap:6px;margin-top:5px}.ref-pill{font-size:10px;padding:1px 6px;border-radius:999px;background:var(--accent-soft);color:var(--accent)}.ref-via{font-size:10px;color:var(--text-dim)}.ref-actions{display:flex;gap:6px;margin-top:6px}.dirty-list{list-style:none;padding:0;margin:0 0 10px;font-size:12px}.dirty-list li{padding:2px 0}.dirty-state{color:var(--warn);margin-right:6px;font-family:var(--mono)}.diff-view{background:var(--bg);border:1px solid var(--border);border-radius:9px;padding:10px;font-size:10.5px;line-height:1.5;overflow:auto;max-height:42vh;font-family:var(--mono);white-space:pre;margin-bottom:10px}.diff-add{color:var(--ok)}.diff-del{color:var(--err)}.diff-hunk{color:#93c5fd}.decision{border:1px solid var(--border);border-radius:9px;padding:8px 12px;margin-bottom:8px}.decision.accepted{opacity:.65}.decision.rejected{opacity:.45}.decision-head{display:flex;gap:6px;align-items:center}.decision-mark{font-weight:700}.decision-subject{font-size:12px;margin:6px 0}.decision-actions{display:flex;gap:6px}.toast{position:absolute;bottom:20px;left:50%;transform:translate(-50%);background:var(--bg-raised);border:1px solid var(--warn);color:var(--text);border-radius:10px;padding:10px 18px;font-size:12px;z-index:60;box-shadow:0 10px 30px #00000080} diff --git a/packages/server/src/mdl_server/static/index.html b/packages/server/src/mdl_server/static/index.html index c8bdc35..0529974 100644 --- a/packages/server/src/mdl_server/static/index.html +++ b/packages/server/src/mdl_server/static/index.html @@ -4,10 +4,10 @@ Modelith - + - - + +
diff --git a/packages/server/src/mdl_server/static/sme.html b/packages/server/src/mdl_server/static/sme.html index 3399be6..8b1f32d 100644 --- a/packages/server/src/mdl_server/static/sme.html +++ b/packages/server/src/mdl_server/static/sme.html @@ -4,10 +4,10 @@ Modelith Glossary - + - - + +