diff --git a/canvas/src/EntityNode.tsx b/canvas/src/EntityNode.tsx index 5dd4136..1144b5e 100644 --- a/canvas/src/EntityNode.tsx +++ b/canvas/src/EntityNode.tsx @@ -1,6 +1,6 @@ import { memo } from "react"; import { Handle, Position, type NodeProps } from "reactflow"; -import type { Entity } from "./types"; +import type { AttributeRow, Entity } from "./types"; export interface EntityNodeData { entity: Entity; @@ -8,6 +8,14 @@ export interface EntityNodeData { dimmed: boolean; // search-filtered out highlighted: boolean; // search hit / selected neighbourhood showTypes: boolean; + /** attribute ULIDs that are an endpoint of some relationship (issue #5): pinned + * near the top so the anchored edges stay meaningful on tall cards */ + endpointAttrs?: Set; + /** rows to emphasise / mute while hovering an attribute or an edge (issue #5) */ + highlightAttrs?: Set; + dimAttrs?: Set; + /** hover an attribute row -> the canvas highlights the relationships it joins */ + onHoverAttr?: (attrId: string | null) => void; } const ROLE_ICON: Record = { @@ -21,10 +29,67 @@ function typeLabel(domain: string | null): string { return domain ?? ""; } +/** Stable per-attribute handle ids. Both a source and a target handle share the + * attribute's ULID — React Flow requires uniqueness only PER TYPE, and an edge + * disambiguates via sourceHandle vs targetHandle. The entity-level fallback + * handles use reserved ids that can never collide with a ULID. */ +export const ENTITY_SOURCE_HANDLE = "__entity_source"; +export const ENTITY_TARGET_HANDLE = "__entity_target"; + export const EntityNode = memo(function EntityNode({ data, selected }: NodeProps) { - const { entity, color, dimmed, highlighted, showTypes } = data; - const keys = entity.attributes.filter((a) => a.role === "business_key"); - const rest = entity.attributes.filter((a) => a.role !== "business_key"); + const { + entity, + color, + dimmed, + highlighted, + showTypes, + endpointAttrs, + highlightAttrs, + dimAttrs, + onHoverAttr, + } = data; + + // business keys first (unchanged), then FK/relationship endpoints, then the rest — + // so the attributes edges anchor to stay visible near the header (issue #5 pinning). + const rank = (a: AttributeRow): number => { + if (a.role === "business_key") return 0; + if (endpointAttrs?.has(a.id)) return 1; + return 2; + }; + const ordered = [...entity.attributes] + .map((a, i) => ({ a, i })) + .sort((x, y) => rank(x.a) - rank(y.a) || x.i - y.i) // stable within a rank + .map((x) => x.a); + const keys = ordered.filter((a) => a.role === "business_key"); + const rest = ordered.filter((a) => a.role !== "business_key"); + + const row = (a: AttributeRow, pk: boolean) => { + const cls = + "attr-row" + + (highlightAttrs?.has(a.id) ? " rel-hit" : "") + + (dimAttrs?.has(a.id) ? " rel-dim" : "") + + (endpointAttrs?.has(a.id) ? " endpoint" : ""); + return ( +
onHoverAttr(a.id) : undefined} + onMouseLeave={onHoverAttr ? () => onHoverAttr(null) : undefined} + > + {/* per-row connection points — anchor edges to the concrete column */} + + + {ROLE_ICON[a.role]} + {a.name} + {showTypes && {typeLabel(a.domain)}} + {!a.nullable && ( + + {"●"} + + )} +
+ ); + }; return (
- - + {/* Entity-level fallback handles for relationships with no attribute mapping. + Explicit ids so an edge can target them and they never clash with a row. */} + +
@@ -59,28 +126,10 @@ export const EntityNode = memo(function EntityNode({ data, selected }: NodeProps
- {keys.length > 0 && ( -
- {keys.map((a) => ( -
- {ROLE_ICON[a.role]} - {a.name} - {showTypes && {typeLabel(a.domain)}} - {!a.nullable && {"●"}} -
- ))} -
- )} + {keys.length > 0 &&
{keys.map((a) => row(a, true))}
}
- {rest.map((a) => ( -
- {ROLE_ICON[a.role]} - {a.name} - {showTypes && {typeLabel(a.domain)}} - {!a.nullable && {"●"}} -
- ))} + {rest.map((a) => row(a, false))} {entity.attributes.length === 0 &&
no attributes
}
diff --git a/canvas/src/ModelCanvas.tsx b/canvas/src/ModelCanvas.tsx index 0050eeb..9a84801 100644 --- a/canvas/src/ModelCanvas.tsx +++ b/canvas/src/ModelCanvas.tsx @@ -15,7 +15,12 @@ import ReactFlow, { // whichever shell mounts it to import this is how the modeler app ended up with an // unpositioned minimap sprawled across the canvas. import "reactflow/dist/style.css"; -import { EntityNode, type EntityNodeData } from "./EntityNode"; +import { + ENTITY_SOURCE_HANDLE, + ENTITY_TARGET_HANDLE, + EntityNode, + type EntityNodeData, +} from "./EntityNode"; import type { Capabilities, Exec } from "./exec"; import { Inspector } from "./Inspector"; import { layoutGraph } from "./layout"; @@ -31,6 +36,27 @@ const edgeTypes: EdgeTypes = { relationship: RelationshipEdge }; export const PALETTE = ["#e0a63a", "#e8825a", "#d98ba8", "#c4a3e0", "#7fb0d8", "#7fc9a0", "#e6c14a"]; export const NO_SA_COLOR = "#8a7d6a"; +/** Which React Flow handle each end of a relationship anchors to (issue #5). + * + * Per end: if the relationship maps to an attribute that actually exists on that + * entity, anchor the line to that attribute's row handle; otherwise fall back to the + * entity-level header handle, so an unmapped relationship still renders exactly as it + * did before. Composite keys anchor to the FIRST member and carry a member count on + * the edge (one line, IDEF1X-style, not N overlapping crow's-feet). */ +export function anchorFor( + r: { from: { entity: string; attributes: string[] }; to: { entity: string; attributes: string[] } }, + entityIndex: Map, +): { sourceHandle: string; targetHandle: string } { + const resolves = (entityId: string, attrId: string | undefined): boolean => + !!attrId && !!entityIndex.get(entityId)?.attributes.some((a) => a.id === attrId); + const fromAttr = r.from.attributes[0]; + const toAttr = r.to.attributes[0]; + return { + sourceHandle: resolves(r.from.entity, fromAttr) ? fromAttr : ENTITY_SOURCE_HANDLE, + targetHandle: resolves(r.to.entity, toAttr) ? toAttr : ENTITY_TARGET_HANDLE, + }; +} + /** Imperative handle for the things a shell needs to drive from its own chrome * (the toolbar's re-layout and fit buttons, and focus-by-id from search). */ export interface ModelCanvasHandle { @@ -84,8 +110,17 @@ export function ModelCanvas({ const [alignFor, setAlignFor] = useState(null); const [mapFor, setMapFor] = useState(null); const [newEntityOpen, setNewEntityOpen] = useState(false); - const [relDraft, setRelDraft] = useState<{ from: string; to: string } | null>(null); + const [relDraft, setRelDraft] = useState<{ + from: string; + to: string; + fromAttr?: string; + toAttr?: string; + } | null>(null); const [relEdit, setRelEdit] = useState(null); + // hover state for attribute-level relationship highlighting (issue #5). Transient + // and canvas-local; it feeds the existing dimmed/highlighted computation. + const [hoveredAttr, setHoveredAttr] = useState(null); + const [hoveredEdge, setHoveredEdge] = useState(null); const readOnly = !caps.canEdit; @@ -101,6 +136,23 @@ export function ModelCanvas({ return m; }, [doc]); + // entity id -> the set of its attribute ULIDs that are an endpoint of some + // relationship, for pinning them near the header (issue #5). Built once per model. + const endpointAttrsByEntity = useMemo(() => { + const m = new Map>(); + const add = (entity: string, attrs: string[]) => { + if (!attrs.length) return; + const s = m.get(entity) ?? new Set(); + attrs.forEach((a) => s.add(a)); + m.set(entity, s); + }; + for (const r of doc.relationships) { + add(r.from.entity, r.from.attributes); + add(r.to.entity, r.to.attributes); + } + return m; + }, [doc]); + useEffect(() => { const q = query.trim().toLowerCase(); const matches = new Set(); @@ -124,34 +176,80 @@ export function ModelCanvas({ } } - const newNodes: Node[] = doc.entities.map((e) => ({ - id: e.id, - type: "entity", - position: { x: 0, y: 0 }, - data: { - entity: e, - color: e.conceptual?.subject_area - ? saColors.get(e.conceptual.subject_area.id) ?? NO_SA_COLOR - : NO_SA_COLOR, - dimmed: (q !== "" && !matches.has(e.id)) || (selectedId !== null && !neighbours.has(e.id)), - highlighted: q !== "" && matches.has(e.id), - showTypes, - }, - })); + // --- attribute-level hover (issue #5) ------------------------------------- + // Which relationships does the hovered attribute participate in, and which + // attribute rows does the hovered edge connect? Both feed the dimmed/highlighted + // flags below rather than a parallel highlight system. + const relsForAttr = new Set(); // relationship ids touching hoveredAttr + const entsForAttr = new Set(); // entities on those relationships + 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); + } + } + } + // 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)); + } + } + + const newNodes: Node[] = doc.entities.map((e) => { + const searchDim = q !== "" && !matches.has(e.id); + const neighbourDim = selectedId !== null && !neighbours.has(e.id); + // when hovering an attribute, dim entities not on any of its relationships + const hoverDim = hoveredAttr !== null && !entsForAttr.has(e.id); + return { + id: e.id, + type: "entity", + position: { x: 0, y: 0 }, + data: { + entity: e, + color: e.conceptual?.subject_area + ? saColors.get(e.conceptual.subject_area.id) ?? NO_SA_COLOR + : NO_SA_COLOR, + dimmed: searchDim || neighbourDim || hoverDim, + highlighted: + (q !== "" && matches.has(e.id)) || (hoveredAttr !== null && entsForAttr.has(e.id)), + showTypes, + endpointAttrs: endpointAttrsByEntity.get(e.id), + highlightAttrs: hitAttrsByEntity.get(e.id), + onHoverAttr: setHoveredAttr, + }, + }; + }); const newEdges: Edge[] = doc.relationships .filter((r) => entityIndex.has(r.from.entity) && entityIndex.has(r.to.entity)) - .map((r) => ({ - id: r.id, - source: r.from.entity, - target: r.to.entity, - type: "relationship", - data: { - relationship: r, - dimmed: - selectedId !== null && r.from.entity !== selectedId && r.to.entity !== selectedId, - }, - })); + .map((r) => { + const { sourceHandle, targetHandle } = anchorFor(r, entityIndex); + // dim: search/select context, OR (when hovering an attribute) any edge that + // attribute is not part of. + const selectDim = + selectedId !== null && r.from.entity !== selectedId && r.to.entity !== selectedId; + const hoverDim = hoveredAttr !== null && !relsForAttr.has(r.id); + return { + id: r.id, + source: r.from.entity, + target: r.to.entity, + sourceHandle, + targetHandle, + type: "relationship", + data: { + relationship: r, + dimmed: selectDim || hoverDim, + memberCount: Math.max(r.from.attributes.length, r.to.attributes.length), + onHoverEdge: setHoveredEdge, + }, + }; + }); setNodes((prev) => { const posById = new Map(prev.map((n) => [n.id, n.position])); @@ -169,7 +267,18 @@ export function ModelCanvas({ return merged; }); setEdges(newEdges); - }, [doc, query, selectedId, showTypes, saColors, entityIndex, fitView]); + }, [ + doc, + query, + selectedId, + showTypes, + saColors, + entityIndex, + endpointAttrsByEntity, + hoveredAttr, + hoveredEdge, + fitView, + ]); const relayout = useCallback(() => { setNodes((prev) => layoutGraph(prev, edges, entityIndex)); @@ -202,7 +311,19 @@ export function ModelCanvas({ const onConnect = useCallback( (conn: Connection) => { if (readOnly || !conn.source || !conn.target || conn.source === conn.target) return; - setRelDraft({ from: conn.source, to: conn.target }); + // A drag from one column to another (issue #5) carries the attribute ULIDs as + // the handle ids; the entity-level fallback handles are reserved sentinels. + // Prefill the relationship modal with them so drawing column→column proposes + // the FK directly, while keeping the confirm step (cardinality/optionality). + const fromAttr = + conn.sourceHandle && conn.sourceHandle !== ENTITY_SOURCE_HANDLE + ? conn.sourceHandle + : undefined; + const toAttr = + conn.targetHandle && conn.targetHandle !== ENTITY_TARGET_HANDLE + ? conn.targetHandle + : undefined; + setRelDraft({ from: conn.source, to: conn.target, fromAttr, toAttr }); }, [readOnly], ); @@ -294,6 +415,8 @@ export function ModelCanvas({ doc={doc} fromId={relDraft.from} toId={relDraft.to} + initialFromAttr={relDraft.fromAttr} + initialToAttr={relDraft.toAttr} exec={guardedExec} onClose={() => setRelDraft(null)} /> diff --git a/canvas/src/RelationshipEdge.tsx b/canvas/src/RelationshipEdge.tsx index 5a4d526..24c3842 100644 --- a/canvas/src/RelationshipEdge.tsx +++ b/canvas/src/RelationshipEdge.tsx @@ -5,6 +5,10 @@ import type { Relationship } from "./types"; export interface RelationshipEdgeData { relationship: Relationship; dimmed: boolean; + /** number of paired columns; >1 means a composite key drawn as one line (issue #5) */ + memberCount?: number; + /** hover the line -> the canvas highlights both endpoint attribute rows */ + onHoverEdge?: (relId: string | null) => void; } /** @@ -50,6 +54,8 @@ export const RelationshipEdge = memo(function RelationshipEdge({ const tgtMany = cardinality === "one_to_many" || cardinality === "many_to_many"; const cls = "rel-edge" + (selected ? " selected" : "") + (dimmed ? " dimmed" : ""); + const composite = (data?.memberCount ?? 0) > 1; + const onHover = data?.onHoverEdge; return ( @@ -61,12 +67,20 @@ export const RelationshipEdge = memo(function RelationshipEdge({ strokeDasharray={identifying ? undefined : "6 4"} /> {/* wider invisible path for easier hover/click */} - + onHover(rel!.id) : undefined} + onMouseLeave={onHover ? () => onHover(null) : undefined} + /> - {selected && rel && ( + {(selected || composite) && rel && ( - {rel.name} + {selected ? rel.name : ""} + {composite ? `${selected ? " " : ""}(${data!.memberCount})` : ""} )} diff --git a/canvas/src/modals.tsx b/canvas/src/modals.tsx index 20d39ba..0bd8e22 100644 --- a/canvas/src/modals.tsx +++ b/canvas/src/modals.tsx @@ -382,12 +382,18 @@ export function RelModal({ doc, fromId, toId, + initialFromAttr, + initialToAttr, exec, onClose, }: { doc: ModelDoc; fromId: string; toId: string; + /** columns the user dragged between (issue #5); prefills the picker so a + * column→column drag proposes the FK directly */ + initialFromAttr?: string; + initialToAttr?: string; exec: Exec; onClose: () => void; }) { @@ -397,8 +403,8 @@ export function RelModal({ () => to?.attributes.find((a) => a.role === "business_key"), [to], ); - const [fromAttr, setFromAttr] = useState(""); - const [toAttr, setToAttr] = useState(toBk?.id ?? ""); + const [fromAttr, setFromAttr] = useState(initialFromAttr ?? ""); + const [toAttr, setToAttr] = useState(initialToAttr ?? toBk?.id ?? ""); const [cardinality, setCardinality] = useState("many_to_one"); const [optionality, setOptionality] = useState("mandatory"); if (!from || !to) return null; diff --git a/canvas/src/styles.css b/canvas/src/styles.css index 6a474f7..893c035 100644 --- a/canvas/src/styles.css +++ b/canvas/src/styles.css @@ -90,8 +90,24 @@ body { font-family: var(--font); background: var(--bg); color: var(--text); } .attr-row { display: flex; align-items: center; gap: 6px; padding: 3px 12px; height: 26px; line-height: 20px; + position: relative; /* so the per-attribute handles anchor to THIS row (issue #5) */ } .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); } +.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 + rows aren't peppered with dots at rest but afford a column→column link. */ +.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: 0.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; } diff --git a/packages/server/src/mdl_server/static/assets/ModelDiagram-DmGsnZ_X.js b/packages/server/src/mdl_server/static/assets/ModelDiagram-Koy1MoG4.js similarity index 97% rename from packages/server/src/mdl_server/static/assets/ModelDiagram-DmGsnZ_X.js rename to packages/server/src/mdl_server/static/assets/ModelDiagram-Koy1MoG4.js index 42de4be..a05861c 100644 --- a/packages/server/src/mdl_server/static/assets/ModelDiagram-DmGsnZ_X.js +++ b/packages/server/src/mdl_server/static/assets/ModelDiagram-Koy1MoG4.js @@ -1 +1 @@ -import{r,j as s}from"./client-DOmNpTln.js";import{f as T,r as _,t as O,u as R,E as D,B as P,C as z,v as A}from"./styles-Cp8yHIFV.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,E]=r.useState(null),[h,w]=r.useState(!0);r.useEffect(()=>{g(null),T(u).then(g).catch(n=>E(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])),b=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=b?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:!!(b&&!o),highlighted:e.id===m,showTypes:h}}}),x=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,x,p),edges:x}},[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=>w(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,r as _,t as O,u as R,E as D,B as P,C as z,v as A}from"./styles-DnEKfty_.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,E]=r.useState(null),[h,w]=r.useState(!0);r.useEffect(()=>{g(null),T(u).then(g).catch(n=>E(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])),b=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=b?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:!!(b&&!o),highlighted:e.id===m,showTypes:h}}}),x=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,x,p),edges:x}},[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=>w(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-DKFrx98H.js b/packages/server/src/mdl_server/static/assets/main-5oRIcN4I.js similarity index 98% rename from packages/server/src/mdl_server/static/assets/main-DKFrx98H.js rename to packages/server/src/mdl_server/static/assets/main-5oRIcN4I.js index 337c399..a61537a 100644 --- a/packages/server/src/mdl_server/static/assets/main-DKFrx98H.js +++ b/packages/server/src/mdl_server/static/assets/main-5oRIcN4I.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-Cp8yHIFV.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-DnEKfty_.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-CnDkXpN4.js b/packages/server/src/mdl_server/static/assets/sme-CcTJsTti.js similarity index 99% rename from packages/server/src/mdl_server/static/assets/sme-CnDkXpN4.js rename to packages/server/src/mdl_server/static/assets/sme-CcTJsTti.js index 27a9cf1..837de7b 100644 --- a/packages/server/src/mdl_server/static/assets/sme-CnDkXpN4.js +++ b/packages/server/src/mdl_server/static/assets/sme-CcTJsTti.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ModelDiagram-DmGsnZ_X.js","assets/client-DOmNpTln.js","assets/styles-Cp8yHIFV.js","assets/styles-CgxFEJWy.css"])))=>i.map(i=>d[i]); -import{r as n,j as e,c as Ee,R as $e}from"./client-DOmNpTln.js";import{p as pe,b as je,c as xe,d as be,e as fe,R as Re,M as Me,O as De,L as Pe,h as Oe,i as Ie,A as Te,j as Be,k as Le,l as Fe,o as ze,s as qe,f as le,m as We,n as Ge,q as He}from"./styles-Cp8yHIFV.js";/* empty css */const Ve="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function ce(s,t){let a="";for(let c=0;c>=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 c of t)a=a<<8n|BigInt(c);return ce(s,10)+ce(a,16)}const Ke={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 Ue(s,t){const a=Ke[s];if(!a)return t;const c={...t};for(const r of a)c[r]||(c[r]=ge());return c}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??"",c=t.attribute_id??"";return c?`${s}:${a}:${c}`:`${s}:${a}`}function Ye({subjectArea:s,describe:t}){const[a,c]=n.useState([]),[r,x]=n.useState(null),[i,l]=n.useState(!1),d=n.useRef(null),w=n.useCallback(async(m,f)=>{f=Ue(m,f),m==="set_alignment"&&f.status===void 0&&(f={...f,status:"proposed"});const S=ve(m,f),{label:$,before:L,after:_}=t(m,f);return c(C=>{const A=C.filter(k=>k.key!==S);if(m.startsWith("delete_")){const k=f.id??f.entity_id;if(k&&C.some(g=>g.op.startsWith("create_")&&g.payload.id===k))return A.filter(g=>g.payload.id!==k)}return[...A,{op:m,payload:f,label:$,before:L,after:_,key:S}]}),{ok:!0,fingerprint:"",created_id:f.id??null,diagnostics:[]}},[t]);n.useEffect(()=>{if(!a.length){x(null);return}const m=setTimeout(()=>{var S;(S=d.current)==null||S.abort();const f=new AbortController;d.current=f,l(!0),pe(a.map($=>({op:$.op,payload:$.payload})),s,f.signal).then(x).catch($=>{$.name!=="AbortError"&&x(null)}).finally(()=>l(!1))},250);return()=>clearTimeout(m)},[a,s]);const p=n.useCallback(m=>{c(f=>f.filter(S=>S.key!==m))},[]),b=n.useCallback(()=>c([]),[]);return n.useMemo(()=>({pending:a,previewDoc:(r==null?void 0:r.model)??null,previewDiff:(r==null?void 0:r.diff)??null,diagnostics:(r==null?void 0:r.diagnostics)??[],failure:r&&r.failed_index!==null?{index:r.failed_index,error:r.error??"invalid change"}:null,busy:i,exec:w,drop:p,clear:b}),[a,r,i,w,p,b])}function Je(s){const t=new Map;for(const c of s)for(const r of["id","conceptual_id","from_fk_id"]){const x=c.payload[r];c.op.startsWith("create_")&&typeof x=="string"&&t.set(x,c.key)}if(!t.size)return new Set;const a=new Set;for(const c of s)if(!c.op.startsWith("create_"))for(const r of Object.values(c.payload))typeof r=="string"&&t.has(r)&&(a.add(c.key),a.add(t.get(r)));return a}function Qe({user:s}){const[t,a]=n.useState(null);return n.useEffect(()=>{je(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 Xe({exec:s,canEdit:t,stagedMembers:a}){const[c,r]=n.useState([]),[x,i]=n.useState(""),[l,d]=n.useState(null),[w,p]=n.useState(""),[b,m]=n.useState(new Set),[f,S]=n.useState("ancestors"),[$,L]=n.useState(1),[_,C]=n.useState(null),[A,k]=n.useState(new Set),[N,g]=n.useState(null);n.useEffect(()=>{xe().then(o=>{r(o.subject_areas),i(y=>{var R;return y||((R=o.subject_areas[0])==null?void 0:R.id)||""})}).catch(o=>g(String(o)))},[]),n.useEffect(()=>{x&&(C(null),m(new Set),be(x).then(d).catch(o=>g(String(o))))},[x]);const M=n.useMemo(()=>a[x]??(l==null?void 0:l.members)??[],[a,x,l]),E=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]),I=w.trim().toLowerCase(),T=o=>!I||o.name.toLowerCase().includes(I),h=n.useMemo(()=>new Set(M),[M]),D=n.useMemo(()=>M.map(o=>E.get(o)).filter(o=>!!o&&T(o)),[M,E,I]),F=n.useMemo(()=>[...E.values()].filter(o=>!h.has(o.id)&&T(o)),[E,h,I]),P=n.useCallback(o=>{if(!l)return;const y=o.filter(q=>!(l.members??[]).includes(q)).length,R=(l.members??[]).filter(q=>!o.includes(q)).length;s("set_subject_area_members",{id:l.id,members:o,__label:`${l.name}: ${o.length} objects (+${y} −${R})`})},[l,s]),z=(o,y)=>{const R=y?[...M,...o.filter(q=>!h.has(q))]:M.filter(q=>!o.includes(q));P(R),m(new Set)},W=(o,y,R)=>{const q=new Set(o);q.has(y)?q.delete(y):q.add(y),R(q)},U=()=>{if(!l)return;const o=b.size?[...b]:M;if(!o.length){g("add an object first, or select one to expand from");return}g(null),fe(l.id,{seeds:o,direction:f,levels:$}).then(y=>{C(y.hops),k(new Set(y.added))}).catch(y=>g(String(y)))},K=()=>{z([...A],!0),C(null)};if(N&&!l)return e.jsx("p",{className:"sme-splash error",children:N});if(!c.length)return e.jsx("p",{className:"sme-placeholder",children:"No subject areas yet."});const j=((l==null?void 0:l.inconsistent)??[]).filter(o=>!h.has(o));return e.jsxs("div",{className:"sa-editor",children:[e.jsx("nav",{className:"sme-nav",children:c.map(o=>e.jsxs("button",{className:"sme-sa"+(o.id===x?" active":""),onClick:()=>i(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:w,onChange:o=>p(o.target.value)})]}),j.length>0&&t&&e.jsxs("div",{className:"sa-nudge",children:[j.length," object",j.length>1?"s are":" is"," homed in this area but not included.",e.jsxs("button",{className:"sme-link",onClick:()=>z(j,!0),children:["Add ",j.length>1?"them all":"it"]})]}),e.jsxs("div",{className:"sa-panes",children:[e.jsx(Q,{title:`Available (${F.length})`,rows:F,picked:b,onToggle:o=>W(b,o,m),homedHere:(l==null?void 0:l.homed_here)??[]}),e.jsxs("div",{className:"sa-controls",children:[e.jsx("button",{className:"sme-secondary",disabled:!t||!b.size,onClick:()=>z([...b].filter(o=>!h.has(o)),!0),title:"Add the selected objects",children:"→"}),e.jsx("button",{className:"sme-secondary",disabled:!t||!F.length,onClick:()=>z(F.map(o=>o.id),!0),title:"Add everything matching the filter",children:"»"}),e.jsx("button",{className:"sme-secondary",disabled:!t||!b.size,onClick:()=>z([...b].filter(o=>h.has(o)),!1),title:"Remove the selected objects",children:"←"}),e.jsx("button",{className:"sme-secondary",disabled:!t||!D.length,onClick:()=>z(D.map(o=>o.id),!1),title:"Remove everything matching the filter",children:"«"})]}),e.jsx(Q,{title:`Included (${D.length})`,rows:D,picked:b,onToggle:o=>W(b,o,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:f,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:$,onChange:o=>L(Math.max(1,Math.min(10,Number(o.target.value))))})]}),e.jsx("button",{className:"sme-secondary",onClick:U,disabled:!t,children:"Preview"})]}),N&&e.jsx("p",{className:"sme-error-line",children:N}),_&&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:A.has(o.id),onChange:()=>W(A,o.id,k)}),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:()=>C(null),children:"Cancel"}),e.jsxs("button",{className:"sme-primary",onClick:K,disabled:!A.size,children:["Add ",A.size," object",A.size===1?"":"s"]})]})]})]})]})]})}function Q({title:s,rows:t,picked:a,onToggle:c,homedHere:r}){const x=n.useMemo(()=>new Set(r),[r]);return e.jsxs("div",{className:"sa-pane",children:[e.jsx("h3",{children:s}),e.jsxs("ul",{children:[t.map(i=>e.jsxs("li",{className:"sa-row"+(a.has(i.id)?" picked":""),onClick:()=>c(i.id),children:[e.jsx("input",{type:"checkbox",readOnly:!0,checked:a.has(i.id)}),e.jsx("span",{className:"sa-row-name",children:i.name}),x.has(i.id)?e.jsx("span",{className:"sme-badge",children:"home"}):e.jsx("span",{className:"sme-badge borrowed",children:"borrowed"})]},i.id)),!t.length&&e.jsx("li",{className:"sme-empty",children:"nothing here"})]})]})}function Ze({onCreate:s,onClose:t}){const[a,c]=n.useState(""),[r,x]=n.useState(""),[i,l]=n.useState([]),[d,w]=n.useState([]),[p,b]=n.useState(new Set),[m,f]=n.useState(""),[S,$]=n.useState("ancestors"),[L,_]=n.useState(1),[C,A]=n.useState(null),[k,N]=n.useState(new Set),[g,M]=n.useState(""),[E,I]=n.useState(null);n.useEffect(()=>{xe().then(j=>{const o=j.subject_areas[0];if(o)return M(o.id),be(o.id).then(y=>l([...y.included,...y.available]))}).catch(j=>I(String(j)))},[]);const T=n.useMemo(()=>new Set(d),[d]),h=m.trim().toLowerCase(),D=j=>!h||j.name.toLowerCase().includes(h),F=n.useMemo(()=>d.map(j=>i.find(o=>o.id===j)).filter(j=>!!j&&D(j)),[d,i,h]),P=n.useMemo(()=>i.filter(j=>!T.has(j.id)&&D(j)),[i,T,h]),z=(j,o)=>{w(y=>o?[...y,...j.filter(R=>!y.includes(R))]:y.filter(R=>!j.includes(R))),b(new Set)},W=(j,o,y)=>{const R=new Set(j);R.has(o)?R.delete(o):R.add(o),y(R)},U=()=>{const j=p.size?[...p]:d;if(!j.length){I("pick an object to expand from first");return}g&&(I(null),fe(g,{seeds:j,direction:S,levels:L}).then(o=>{const y=o.hops.filter(R=>!T.has(R.id));A(y),N(new Set(y.map(R=>R.id)))}).catch(o=>I(String(o))))},K=()=>{a.trim()&&s(a.trim(),r.trim(),d)};return e.jsx("div",{className:"sme-modal-backdrop",onClick:t,children:e.jsxs("div",{className:"sme-modal sa-modal",onClick:j=>j.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:j=>c(j.target.value),onKeyDown:j=>j.key==="Enter"&&d.length===0&&K()})]}),e.jsxs("label",{className:"sme-field",children:[e.jsx("span",{children:"Definition (optional)"}),e.jsx("input",{value:r,placeholder:"what this view is for",onChange:j=>x(j.target.value)})]})]}),e.jsx("input",{className:"sme-search sa-filter",type:"search",placeholder:"Filter both lists…",value:m,onChange:j=>f(j.target.value)}),e.jsxs("div",{className:"sa-panes",children:[e.jsx(Q,{title:`Available (${P.length})`,rows:P,picked:p,onToggle:j=>W(p,j,b),homedHere:[]}),e.jsxs("div",{className:"sa-controls",children:[e.jsx("button",{className:"sme-secondary",disabled:!p.size,onClick:()=>z([...p].filter(j=>!T.has(j)),!0),title:"Add the selected objects",children:"→"}),e.jsx("button",{className:"sme-secondary",disabled:!P.length,onClick:()=>z(P.map(j=>j.id),!0),title:"Add everything matching the filter",children:"»"}),e.jsx("button",{className:"sme-secondary",disabled:!p.size,onClick:()=>z([...p].filter(j=>T.has(j)),!1),title:"Remove the selected objects",children:"←"}),e.jsx("button",{className:"sme-secondary",disabled:!F.length,onClick:()=>z(F.map(j=>j.id),!1),title:"Remove everything matching the filter",children:"«"})]}),e.jsx(Q,{title:`Included (${F.length})`,rows:F,picked:p,onToggle:j=>W(p,j,b),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:j=>$(j.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:L,onChange:j=>_(Math.max(1,Math.min(10,Number(j.target.value))))})]}),e.jsx("button",{className:"sme-secondary",onClick:U,children:"Preview"})]}),C&&e.jsxs("div",{className:"sa-hops",children:[C.length===0&&e.jsx("p",{className:"sme-muted",children:"nothing new to add"}),C.map(j=>e.jsxs("label",{className:"sa-hop",children:[e.jsx("input",{type:"checkbox",checked:k.has(j.id),onChange:()=>W(k,j.id,N)}),e.jsx("span",{className:"sa-hop-name",children:j.name}),e.jsxs("span",{className:"sa-hop-why",children:["via ",j.via_name," · ",j.direction.replace(/s$/,""),", level ",j.level]})]},j.id)),C.length>0&&e.jsxs("div",{className:"sa-hop-actions",children:[e.jsx("button",{className:"sme-secondary",onClick:()=>A(null),children:"Cancel"}),e.jsxs("button",{className:"sme-primary",disabled:!k.size,onClick:()=>{z([...k],!0),A(null)},children:["Add ",k.size]})]})]})]}),E&&e.jsx("p",{className:"sme-error-line",children:E}),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:K,children:["Create",d.length>0&&` with ${d.length} object${d.length===1?"":"s"}`]})]})]})})}const es=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 ss({doc:s,subjectArea:t,onSubjectArea:a,exec:c,canEdit:r,direct:x=!1,onSelectEntity:i,busy:l}){var k;const[d,w]=n.useState(null),[p,b]=n.useState(null),[m,f]=n.useState(!1),[S,$]=n.useState(null),[L]=n.useState(""),_=n.useRef(null),C=n.useMemo(()=>({canEdit:r,mode:x?"direct":"staged",allow:x?void 0:es,canArbitrate:x,canCommit:x}),[r,x]),A=n.useCallback(N=>{w(N),N&&(i==null||i(N))},[i]);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"}),r&&e.jsx("button",{className:"sme-nav-add",title:"New subject area",onClick:()=>f(!0),children:"+"})]}),e.jsxs("button",{className:"sme-sa"+(t===""?" active":""),onClick:()=>a(""),children:["Whole model",e.jsx("span",{className:"sme-sa-count",children:((k=s.counts)==null?void 0:k.entities_total)??s.entities.length})]}),s.subject_areas.map(N=>e.jsxs("button",{className:"sme-sa"+(t===N.id?" active":""),onClick:()=>a(N.id),title:N.definition??void 0,children:[N.name,e.jsx("span",{className:"sme-sa-count",children:N.member_count??0})]},N.id))]}),m&&e.jsx(Ze,{onClose:()=>f(!1),onCreate:(N,g,M)=>{const E=ge();c("create_subject_area",{name:N,...g?{definition:g}:{},id:E}),M.length&&c("set_subject_area_members",{id:E,members:M}),f(!1),a(E)}}),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"]}),r&&e.jsx("button",{className:"erd-action",onClick:()=>{var N;return(N=_.current)==null?void 0:N.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"+(p==="ontology"?" on":""),onClick:()=>b(N=>N==="ontology"?null:"ontology"),children:"Ontology"}),e.jsx("button",{className:"erd-action ghost"+(p==="layers"?" on":""),onClick:()=>b(N=>N==="layers"?null:"layers"),children:"Layers"})]}),l&&e.jsx("span",{className:"erd-busy",children:"updating…"}),!r&&e.jsx("span",{className:"sme-chip",children:"read-only"}),S&&e.jsx("span",{className:"erd-error",children:S})]}),e.jsxs("div",{className:"erd-canvas canvas-wrap",children:[e.jsx(Re,{children:e.jsx(Me,{doc:s,caps:C,exec:c,selectedId:d,onSelect:A,query:L,onError:$,handleRef:_})}),p&&e.jsxs("aside",{className:"side-panel",children:[e.jsxs("div",{className:"detail-header",children:[e.jsx("h2",{children:p==="ontology"?"Ontology":"Ontology layers"}),e.jsx("button",{className:"icon-btn",onClick:()=>b(null),children:"✕"})]}),p==="ontology"?e.jsx(De,{}):e.jsx(Pe,{refreshKey:0,onFocusEntity:N=>{var g;b(null),(g=_.current)==null||g.focusEntity(N)}})]})]})]})]})}function ns({user:s,onView:t}){const[a,c]=n.useState(null),[r,x]=n.useState(null);if(n.useEffect(()=>{Oe(s).then(c).catch(l=>x(String(l)))},[s]),r)return e.jsx("p",{className:"sme-splash error",children:r});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 i=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:[i," 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(ts,{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 as(s,t){var a,c;return s.merged?{kind:"accepted",text:"✅ Accepted"}:s.pushed?t&&((a=s.pr)==null?void 0:a.state)==="CLOSED"?{kind:"declined",text:"✖ Declined"}:t&&((c=s.pr)==null?void 0:c.reviews)==="CHANGES_REQUESTED"?{kind:"changes",text:"💬 Changes requested"}:{kind:"awaiting",text:"⏳ Awaiting review"}:{kind:"local",text:"📥 Saved locally"}}function ts({p:s,gh:t,onView:a}){const c=as(s,t);return e.jsxs("div",{className:"pr-card"+(c.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 "+c.kind,children:c.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 rs({changes:s,routeAdvice:t,identity:a,user:c,onUser:r,onDrop:x,onClose:i,onProposed:l}){const d=!!(a&&a.source!=="anonymous"),[w,p]=n.useState(c||(localStorage.getItem("mdl.sme.user")??"")),[b,m]=n.useState(s.length===1?`Update ${s[0].label.toLowerCase()}`:"Glossary updates"),[f,S]=n.useState(""),[$,L]=n.useState(!1),_=Ne($?f:b),[C,A]=n.useState(""),[k,N]=n.useState(!1),[g,M]=n.useState(null),[E,I]=n.useState(null),T=()=>{!d&&!w.trim()||(d||(localStorage.setItem("mdl.sme.user",w.trim()),r==null||r(w.trim())),N(!0),I(null),Ie({user:d?"":w.trim(),slug:_,title:b,body:C.trim(),changes:s.map(h=>({op:h.op,payload:h.payload}))}).then(M).catch(h=>I(h instanceof Te?h.message:String(h))).finally(()=>N(!1)))};return g!=null&&g.ok?e.jsx("div",{className:"sme-modal-backdrop",onClick:()=>l(g),children:e.jsxs("div",{className:"sme-modal",onClick:h=>h.stopPropagation(),children:[e.jsx("h2",{children:"✓ Sent for review"}),e.jsx("p",{children:g.message}),g.pr_url&&e.jsx("p",{children:e.jsx("a",{href:g.pr_url,target:"_blank",rel:"noreferrer",children:"View pull request →"})}),g.compare_url&&e.jsx("p",{children:e.jsx("a",{href:g.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:g.branch}),". A steward will review it."]}),e.jsx("div",{className:"sme-modal-foot",children:e.jsx("button",{className:"sme-primary",onClick:()=>l(g),children:"Done"})})]})}):e.jsx("div",{className:"sme-modal-backdrop",onClick:i,children:e.jsxs("div",{className:"sme-modal",onClick:h=>h.stopPropagation(),children:[e.jsxs("div",{className:"sme-card-head",children:[e.jsx("h2",{children:"Submit for review"}),e.jsx("button",{className:"sme-secondary",onClick:i,children:"✕"})]}),e.jsx("h3",{children:"Your changes"}),e.jsx("ul",{className:"sme-diff",children:s.map((h,D)=>e.jsxs("li",{children:[e.jsxs("div",{className:"sme-diff-head",children:[e.jsx("b",{children:h.label}),e.jsx("button",{className:"sme-link danger",onClick:()=>x(D),children:"discard"})]}),e.jsx("div",{className:"sme-diff-before",children:h.before}),e.jsx("div",{className:"sme-diff-after",children:h.after})]},D))}),d?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:w,onChange:h=>p(h.target.value),placeholder:"e.g. a.hough"})]}),e.jsxs("label",{className:"sme-field",children:[e.jsx("span",{children:"Title"}),e.jsx("input",{value:b,onChange:h=>m(h.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:$?f:_,onChange:h=>{L(!0),S(h.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:C,onChange:h=>A(h.target.value)})]}),e.jsx(is,{cl:t,user:d?a.name:w,changeSlug:_}),E&&e.jsx("p",{className:"sme-error-line",children:E}),e.jsxs("div",{className:"sme-modal-foot",children:[e.jsx("button",{className:"sme-secondary",onClick:i,children:"Keep editing"}),e.jsx("button",{className:"sme-primary",disabled:k||!d&&!w.trim()||s.length===0,onClick:T,children:k?"Submitting…":"Submit for review"})]})]})})}function is({cl:s,user:t,changeSlug:a}){if(!(s!=null&&s.primary))return null;const c=s.reviewers_actual??s.reviewers,r=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"," ",c.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/",r,"/",a||"…"]})]}),e.jsxs("div",{className:"row",children:[e.jsx("span",{className:"k",children:"Reviewers"}),e.jsx("span",{children:c.join(", ")})]})]})]})}function Ne(s){return s.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"change"}const ls="modulepreload",cs=function(s){return"/"+s},oe={},os=function(t,a,c){let r=Promise.resolve();if(a&&a.length>0){document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),l=(i==null?void 0:i.nonce)||(i==null?void 0:i.getAttribute("nonce"));r=Promise.allSettled(a.map(d=>{if(d=cs(d),d in oe)return;oe[d]=!0;const w=d.endsWith(".css"),p=w?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${p}`))return;const b=document.createElement("link");if(b.rel=w?"stylesheet":ls,w||(b.as="script"),b.crossOrigin="",b.href=d,l&&b.setAttribute("nonce",l),document.head.appendChild(b),w)return new Promise((m,f)=>{b.addEventListener("load",m),b.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${d}`)))})}))}function x(i){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=i,window.dispatchEvent(l),!l.defaultPrevented)throw i}return r.then(i=>{for(const l of i||[])l.status==="rejected"&&x(l.reason);return t().catch(x)})};function ds({diff:s,selectable:t,selected:a,onToggle:c}){var l;const[r,x]=n.useState(((l=s.objects[0])==null?void 0:l.ulid)??null),i=n.useMemo(()=>s.objects.find(d=>d.ulid===r)??s.objects[0]??null,[s,r]);return s.objects.length?e.jsxs("div",{className:"rv-body",children:[e.jsx("div",{className:"rv-list",children:s.objects.map(d=>e.jsx(ms,{obj:d,active:d.ulid===((i==null?void 0:i.ulid)??""),checked:(a==null?void 0:a.has(d.ulid))??!0,selectable:t,onSelect:()=>x(d.ulid),onToggle:()=>c==null?void 0:c(d.ulid)},d.ulid))}),e.jsx("div",{className:"rv-detail",children:i&&e.jsx(us,{obj:i})})]}):e.jsxs("p",{className:"sme-placeholder",children:["No model changes against ",s.base.label,"."]})}function hs(s){return s.renamed?"renamed":s.severity==="breaking"?"breaking":s.change}function ms({obj:s,active:t,checked:a,selectable:c,onSelect:r,onToggle:x}){return e.jsxs("div",{className:"rv-obj"+(t?" active":""),onClick:r,children:[e.jsxs("div",{className:"rv-obj-head",children:[c&&e.jsx("input",{type:"checkbox",checked:a,onClick:i=>i.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"&&"⚠ ",hs(s)]})]}),e.jsxs("ul",{className:"rv-obj-fields",children:[s.fields.map((i,l)=>e.jsx("li",{children:i.label},i.field+l)),s.children.flatMap(i=>i.fields.map((l,d)=>e.jsxs("li",{children:[l.label,": ",i.name_before??i.name_after]},i.ulid+d)))]})]})}function us({obj:s}){const t=s.children.flatMap(a=>a.fields.map(c=>({field:c,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,c)=>e.jsx(de,{f:a},a.field+c)),t.map(({field:a,on:c},r)=>e.jsx(de,{f:a,on:c},"c"+r)),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 de({f:s,on:t}){var c,r,x;const a=t?`${s.label}: ${t}`:s.label;if((c=s.breaks)!=null&&c.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(i=>e.jsxs("li",{children:[e.jsxs("span",{className:"m",children:["→ ",i.name]}),e.jsxs("span",{className:"p",children:[i.target," · ",i.materialization]})]},i.name))})]})]});if(s.kind==="definition_changed"){const i=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:me(i,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:me(l,i,"ins")})]})]})]})}if(Array.isArray(s.before)||Array.isArray(s.after)){const i=new Set(((r=s.before)==null?void 0:r.map(String))??[]),l=new Set(((x=s.after)==null?void 0:x.map(String))??[]),d=[...l].filter(p=>!i.has(p)),w=[...i].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:[d.map(p=>e.jsxs("span",{className:"rv-chip-add",children:["+ ",p]},"a"+p)),w.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:he(s.before)}),e.jsx("span",{className:"arrow",children:"→"}),e.jsx("span",{className:"to",children:he(s.after)})]})]})}function he(s){return s==null||s===""?"—":typeof s=="boolean"?s?"yes":"no":typeof s=="object"?JSON.stringify(s):String(s)}function me(s,t,a){const c=s.split(/(\s+)/),r=t.split(/(\s+)/),x=m=>m.toLowerCase().replace(/[.,;:]/g,""),i=c.length,l=r.length,d=Array.from({length:i+1},()=>new Array(l+1).fill(0));for(let m=i-1;m>=0;m--)for(let f=l-1;f>=0;f--)d[m][f]=x(c[m])===x(r[f])?d[m+1][f+1]+1:Math.max(d[m+1][f],d[m][f+1]);const w=new Set;let p=0,b=0;for(;p=d[p][b+1]?p++:b++;return c.map((m,f)=>!m.trim()||w.has(f)?e.jsx("span",{children:m},f):a==="del"?e.jsx("del",{children:m},f):e.jsx("ins",{children:m},f))}const ps=n.lazy(()=>os(()=>import("./ModelDiagram-DmGsnZ_X.js"),__vite__mapDeps([0,1,2,3])).then(s=>({default:s.ModelDiagram})));function js({stagedDiff:s,stagedRoute:t,user:a,onBack:c,onSubmit:r,excluded:x,onToggleObject:i,selectable:l}){const[d,w]=n.useState(null),[p,b]=n.useState(null),[m,f]=n.useState(null),[S,$]=n.useState(null),[L,_]=n.useState(null),[C,A]=n.useState("changes"),k=n.useCallback(()=>{je(a).then(g=>{$(g);const M=g.base_branch??"main";s?w(s):Be("HEAD").then(E=>E.ok?w(E):_(E.error??"could not read the model")).catch(E=>_(String(E))),t?b(t):Le("HEAD").then(b).catch(()=>{}),Fe(M).then(f).catch(()=>{})}).catch(g=>_(String(g)))},[a,s,t]);if(n.useEffect(k,[k]),L)return e.jsxs("div",{className:"rv-shell",children:[e.jsx(ue,{onBack:c,diff:null}),e.jsx("p",{className:"sme-splash error",children:e.jsx("pre",{children:L})})]});if(!d)return e.jsx("div",{className:"sme-splash",children:"◮ reading your changes…"});const N=new Set(d.objects.map(g=>g.ulid).filter(g=>!x.has(g)));return e.jsxs("div",{className:"rv-shell",children:[e.jsx(ue,{onBack:c,diff:d,tab:C,onTab:A}),C==="changes"?e.jsx(ds,{diff:d,selectable:l,selected:N,onToggle:i}):e.jsx(n.Suspense,{fallback:e.jsx("div",{className:"sme-splash",children:"◮ drawing the model…"}),children:e.jsx(ps,{severityByUlid:xs(d)})}),e.jsxs("div",{className:"rv-foot",children:[e.jsx(bs,{cl:p}),e.jsx(fs,{conf:m,ctx:S}),e.jsxs("div",{className:"rv-actions",children:[e.jsx("button",{className:"sme-secondary",onClick:c,children:"Keep editing"}),e.jsx("button",{className:"sme-primary",disabled:!d.objects.length||(S?!S.can_propose:!1),title:S&&!S.can_propose?"the working tree has uncommitted changes":"",onClick:()=>r(p),children:"Submit for review →"})]})]})]})}function xs(s){const t=new Map;for(const a of s.objects)t.set(a.ulid,a.severity);return t}function ue({onBack:s,diff:t,tab:a,onTab:c}){const r=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"}),r&&e.jsxs("div",{className:"rv-sub",children:[r.objects," object",r.objects===1?"":"s"," ·"," ",(r.breaking??0)+(r.additive??0)+(r.cosmetic??0)," changes",(t==null?void 0:t.has_breaking)&&e.jsxs("span",{className:"warn",children:[" · ⚠ ",r.breaking," breaking"]})," · comparing to ",e.jsx("code",{children:t==null?void 0:t.base.label})]})]}),c&&e.jsxs("div",{className:"rv-tabs",children:[e.jsxs("button",{className:"rv-tab"+(a==="changes"?" active":""),onClick:()=>c("changes"),children:["Changes ",(t==null?void 0:t.objects.length)??0]}),e.jsx("button",{className:"rv-tab"+(a==="diagram"?" active":""),onClick:()=>c("diagram"),children:"Diagram"})]})]})}function bs({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 fs({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 gs({term:s,canEdit:t,pendingCount:a,onEdit:c}){var r,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}),((r=s.subject_area)==null?void 0:r.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:c,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(i=>e.jsx("span",{className:"sme-chip",children:i},i))})]}),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(i=>e.jsxs("li",{children:[e.jsx("span",{className:"sme-usage-model",children:i.logical_entity}),i.unmanaged&&e.jsx("span",{className:"sme-badge",children:"engineer-owned"}),i.physical.length>0&&e.jsx("span",{className:"sme-usage-phys",children:i.physical.map(l=>l.name).join(", ")})]},i.logical_id))})]})]})}function vs({term:s,pending:t,onStage:a,onDone:c,catalogOwned:r=[],catalog:x=null}){var M,E,I,T;const i=h=>r.includes(h),l=h=>t.find(D=>D.label===h),d=(h,D)=>{const F=l(h);return F?F.after:D},[w,p]=n.useState(d("Definition",s.definition??"")),[b,m]=n.useState(s.synonyms),[f,S]=n.useState(""),[$,L]=n.useState(((M=s.stewardship)==null?void 0:M.owner)??""),[_,C]=n.useState(((E=s.stewardship)==null?void 0:E.steward)??""),A=()=>{w.trim()!==(s.definition??"").trim()&&a({op:"set_definition",payload:{id:s.id,definition:w.trim()},label:"Definition",before:s.definition??"(none)",after:w.trim()||"(none)"})},k=(h,D)=>{var F,P;a({op:"set_stewardship",payload:{id:s.id,owner:h||null,steward:D||null},label:"Stewardship",before:`owner: ${((F=s.stewardship)==null?void 0:F.owner)??"—"} · steward: ${((P=s.stewardship)==null?void 0:P.steward)??"—"}`,after:`owner: ${h||"—"} · steward: ${D||"—"}`})},N=h=>{m(h),a({op:"update_synonyms",payload:{id:s.id,synonyms:h},label:"Also called",before:s.synonyms.join(", ")||"(none)",after:h.join(", ")||"(none)"})},g=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:c,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."]}),(i("definition")||i("synonyms")||i("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"}),i("definition")?e.jsx("p",{className:"sme-readonly-value",children:s.definition??"—"}):e.jsx("textarea",{rows:4,value:w,onChange:h=>p(h.target.value),onBlur:A,placeholder:"A plain-language business definition…"})]}),e.jsxs("label",{className:"sme-field",children:[e.jsx("span",{children:"Also called (synonyms)"}),i("synonyms")?e.jsx("div",{className:"sme-syn-row",children:s.synonyms.length?s.synonyms.map(h=>e.jsx("span",{className:"sme-chip",children:h},h)):e.jsx("span",{className:"sme-muted",children:"none"})}):e.jsxs("div",{className:"sme-syn-row",children:[b.map(h=>e.jsxs("span",{className:"sme-chip removable",onClick:()=>N(b.filter(D=>D!==h)),children:[h," ✕"]},h)),e.jsx("input",{value:f,placeholder:"add + Enter",onChange:h=>S(h.target.value),onKeyDown:h=>{h.key==="Enter"&&f.trim()&&(N([...b,f.trim()]),S(""))}})]})]}),!g&&(i("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:((I=s.stewardship)==null?void 0:I.owner)??"—"})]}),e.jsxs("label",{className:"sme-field",children:[e.jsx("span",{children:"Steward"}),e.jsx("p",{className:"sme-readonly-value",children:((T=s.stewardship)==null?void 0:T.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:$,onChange:h=>L(h.target.value),onBlur:()=>k($,_)})]}),e.jsxs("label",{className:"sme-field",children:[e.jsx("span",{children:"Steward"}),e.jsx("input",{value:_,onChange:h=>C(h.target.value),onBlur:()=>k($,_)})]})]})),e.jsx(ys,{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 Ns=["skos:exactMatch","skos:closeMatch","skos:broadMatch","skos:narrowMatch"];function ys({term:s,onStage:t}){var b;const[a,c]=n.useState(!1),[r,x]=n.useState(s.name),[i,l]=n.useState([]),[d,w]=n.useState("skos:closeMatch"),p=m=>{x(m),ze(m).then(f=>l(f.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:r,onChange:m=>p(m.target.value),placeholder:"Search standards…",autoFocus:!0}),e.jsx("div",{className:"sme-align-results",children:i.map(m=>e.jsxs("button",{className:"sme-align-card",onClick:()=>{var f;t({op:"set_alignment",payload:{id:s.id,aligns_to:m.prefixed,alignment:d,status:"proposed"},label:"Standard mapping",before:((f=s.ontology)==null?void 0:f.aligns_to)??"(none)",after:`${m.prefixed} (${d}, proposed)`}),c(!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:d,onChange:m=>w(m.target.value),children:Ns.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:[(b=s.ontology)!=null&&b.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:()=>c(!0),children:"Propose a mapping…"})]})]})}function ws(){const[s,t]=n.useState(null),[a,c]=n.useState(!0),[r,x]=n.useState(null),[i,l]=n.useState(""),[d,w]=n.useState(null),[p,b]=n.useState(""),[m,f]=n.useState(""),[S,$]=n.useState(null),[L,_]=n.useState(!1),[C,A]=n.useState([]),[k,N]=n.useState(!1),[g,M]=n.useState(window.location.hash==="#proposals"?"proposals":"browse"),[E,I]=n.useState(new Set),[T,h]=n.useState(()=>localStorage.getItem("mdl.sme.user")??""),[D,F]=n.useState(null),[P,z]=n.useState(null),[W,U]=n.useState(!1),[K,j]=n.useState(null),o=n.useCallback((u,v)=>{var ae;const O=J=>{var te;const H=P==null?void 0:P.entities.find(re=>{var ie;return re.id===J||((ie=re.conceptual)==null?void 0:ie.id)===J});return((te=H==null?void 0:H.conceptual)==null?void 0:te.name)??(H==null?void 0:H.name)??"object"},B=O(v.id??v.entity_id);switch(u){case"create_entity":return{label:`New entity: ${v.name}`,before:"—",after:String(v.name??"")};case"create_relationship":return{label:`New relationship: ${O(v.from_entity)} → ${O(v.to_entity)}`,before:"—",after:String(v.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:[v.cardinality,v.optionality,v.identifying?"identifying":""].filter(Boolean).join(", ")};case"set_definition":return{label:`Definition: ${B}`,before:"",after:String(v.definition??"")};case"add_attribute":return{label:`Attribute added to ${B}`,before:"—",after:String(v.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(v)};case"rename_entity":return{label:`Renamed ${B}`,before:B,after:String(v.name??"")};case"set_subject_area":return{label:`Subject area: ${B}`,before:"",after:String(v.subject_area??"none")};case"set_stewardship":return{label:`Stewardship: ${B}`,before:"",after:String(v.steward??"")};case"set_subject_area_members":{const J=v.__label,H=((ae=v.members)==null?void 0:ae.length)??0;return{label:J??"Subject area members",before:"",after:`${H} object${H===1?"":"s"}`}}case"set_alignment":return{label:`Alignment: ${B}`,before:"",after:String(v.aligns_to??"")};default:return{label:`${u.replace(/_/g," ")}: ${B}`,before:"",after:""}}},[P]),y=Ye({subjectArea:p,describe:o}),R=n.useCallback(async(u,v)=>{const O=(P==null?void 0:P.fingerprint)??"",B=await qe(u,v,O);return await le(p||void 0).then(z),B},[P,p]),q=n.useMemo(()=>{const u={};for(const v of y.pending)v.op==="set_subject_area_members"&&(u[v.payload.id]=v.payload.members??[]);return u},[y.pending]),G=n.useMemo(()=>[...C,...y.pending],[C,y.pending]),[ye,X]=n.useState(null),[we,Z]=n.useState(null);n.useEffect(()=>{if(!G.length){X(null),Z(null);return}const u=new AbortController,v=G.map(O=>({op:O.op,payload:O.payload}));return pe(v,p||void 0,u.signal).then(O=>X(O.diff??null)).catch(O=>{O.name!=="AbortError"&&X(null)}),We(v).then(Z).catch(()=>Z(null)),()=>u.abort()},[G,p]);const Se=n.useMemo(()=>Je(G),[G]).size{M(u),window.location.hash=u==="browse"?"":`#${u}`},[]);n.useEffect(()=>{const u=()=>{const v=window.location.hash;M(v==="#proposals"?"proposals":v==="#review"?"review":v==="#model"?"model":v==="#areas"?"areas":"browse")};return u(),window.addEventListener("hashchange",u),()=>window.removeEventListener("hashchange",u)},[]);const ee=n.useCallback(()=>{Ge({subject_area:p,q:m}).then(t).catch(u=>w(String(u)))},[p,m]);n.useEffect(ee,[ee]),n.useEffect(()=>{le(p||void 0).then(u=>{c(u.read_only),l(u.project.name),z(u),U(!!u.direct),F(u.identity??null),u.identity&&u.identity.source!=="anonymous"&&u.identity.name&&h(u.identity.name)}).catch(()=>{}),He().then(x).catch(()=>{})},[p]);const se=n.useMemo(()=>(s==null?void 0:s.terms.find(u=>u.id===S))??null,[s,S]),_e=n.useCallback(u=>{const v=u.key??ve(u.op,u.payload);A(O=>[...O.filter(B=>B.key!==v),{...u,key:v}])},[]),ke=u=>A(v=>v.filter((O,B)=>B!==u)),Ce=()=>{A([]),N(!1),_(!1),ee()};if(d)return e.jsxs("div",{className:"sme-splash error",children:[e.jsx("h1",{children:"◮ Glossary"}),e.jsx("pre",{children:d}),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=(r==null?void 0:r.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:i}),a&&e.jsx("span",{className:"sme-chip",children:"read-only"}),Ae&&e.jsxs("span",{className:"sme-chip catalog",title:`Definitions are mastered in ${r==null?void 0:r.catalog_name}`,children:["mirrors ",r==null?void 0:r.catalog_name]})]}),e.jsx("input",{className:"sme-search",type:"search",placeholder:"Search terms & definitions…",value:m,onChange:u=>f(u.target.value)}),e.jsxs("nav",{className:"sme-tabs",children:[e.jsx("button",{className:"sme-tab"+(g==="browse"?" active":""),onClick:()=>V("browse"),children:"Terms"}),e.jsx("button",{className:"sme-tab"+(g==="model"?" active":""),onClick:()=>V("model"),children:"Model"}),e.jsx("button",{className:"sme-tab"+(g==="areas"?" active":""),onClick:()=>V("areas"),children:"Subject areas"}),e.jsx("button",{className:"sme-tab"+(g==="proposals"?" active":""),onClick:()=>V("proposals"),children:"My proposals"})]}),G.length>0&&e.jsxs("button",{className:"sme-tray",onClick:()=>V("review"),children:[G.length," change",G.length>1?"s":""," · Review →"]})]}),g==="browse"&&e.jsx(Qe,{user:T}),g==="review"?e.jsx(js,{stagedDiff:ye,stagedRoute:we,user:T,selectable:Se,excluded:E,onToggleObject:u=>I(v=>{const O=new Set(v);return O.has(u)?O.delete(u):O.add(u),O}),onBack:()=>V("browse"),onSubmit:u=>{j(u),N(!0)}}):g==="model"?y.previewDoc??P?e.jsx(ss,{doc:y.previewDoc??P,subjectArea:p,onSubjectArea:b,exec:W?R:y.exec,canEdit:Y,direct:W,busy:y.busy}):e.jsx("div",{className:"sme-splash",children:"◮ loading the model…"}):g==="areas"?e.jsx(Xe,{exec:y.exec,canEdit:Y,stagedMembers:q}):g==="proposals"?e.jsx(ns,{user:T,onView:()=>V("review")}):e.jsxs("div",{className:"sme-body",children:[e.jsxs("nav",{className:"sme-nav",children:[e.jsx("button",{className:"sme-sa"+(p===""?" active":""),onClick:()=>b(""),children:"All subject areas"}),s.subject_areas.map(u=>e.jsx("button",{className:"sme-sa"+(p===u.id?" active":""),onClick:()=>b(u.id),title:u.definition??void 0,children:u.name},u.id))]}),e.jsxs("ul",{className:"sme-list",children:[s.terms.map(u=>{var v;return e.jsxs("li",{className:"sme-list-item"+(u.id===S?" active":""),onClick:()=>{$(u.id),_(!1)},children:[e.jsx("span",{className:"sme-term-name",children:u.name}),u.kind==="term"&&e.jsx("span",{className:"sme-kind",children:"term"}),((v=u.ontology)==null?void 0:v.status)==="proposed"&&e.jsx("span",{className:"sme-badge proposed",title:"alignment awaiting architect",children:"proposed"}),e.jsx("span",{className:"sme-term-def",children:u.definition??"no definition yet"})]},u.id)}),s.terms.length===0&&e.jsx("li",{className:"sme-empty",children:"no terms match"})]}),e.jsx("section",{className:"sme-detail",children:se?L&&Y?e.jsx(vs,{term:se,pending:C,onStage:_e,onDone:()=>_(!1),catalogOwned:ne,catalog:r?{name:r.catalog_name,url:r.catalog_url}:null}):e.jsx(gs,{term:se,canEdit:Y,pendingCount:C.length,onEdit:()=>_(!0)}):e.jsx("div",{className:"sme-placeholder",children:"Select a term to see its definition."})})]}),k&&e.jsx(rs,{changes:G,routeAdvice:K,identity:D,user:T,onUser:u=>{h(u),localStorage.setItem("mdl.sme.user",u)},onDrop:ke,onClose:()=>N(!1),onProposed:()=>{Ce(),y.clear(),I(new Set),V("proposals")}})]})}Ee.createRoot(document.getElementById("root")).render(e.jsx($e.StrictMode,{children:e.jsx(ws,{})})); +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ModelDiagram-Koy1MoG4.js","assets/client-DOmNpTln.js","assets/styles-DnEKfty_.js","assets/styles-B4bhxAsE.css"])))=>i.map(i=>d[i]); +import{r as n,j as e,c as Ee,R as $e}from"./client-DOmNpTln.js";import{p as pe,b as je,c as xe,d as be,e as fe,R as Re,M as Me,O as De,L as Pe,h as Oe,i as Ie,A as Te,j as Be,k as Le,l as Fe,o as ze,s as qe,f as le,m as We,n as Ge,q as He}from"./styles-DnEKfty_.js";/* empty css */const Ve="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function ce(s,t){let a="";for(let c=0;c>=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 c of t)a=a<<8n|BigInt(c);return ce(s,10)+ce(a,16)}const Ke={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 Ue(s,t){const a=Ke[s];if(!a)return t;const c={...t};for(const r of a)c[r]||(c[r]=ge());return c}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??"",c=t.attribute_id??"";return c?`${s}:${a}:${c}`:`${s}:${a}`}function Ye({subjectArea:s,describe:t}){const[a,c]=n.useState([]),[r,x]=n.useState(null),[i,l]=n.useState(!1),d=n.useRef(null),w=n.useCallback(async(m,f)=>{f=Ue(m,f),m==="set_alignment"&&f.status===void 0&&(f={...f,status:"proposed"});const S=ve(m,f),{label:$,before:L,after:_}=t(m,f);return c(C=>{const A=C.filter(k=>k.key!==S);if(m.startsWith("delete_")){const k=f.id??f.entity_id;if(k&&C.some(g=>g.op.startsWith("create_")&&g.payload.id===k))return A.filter(g=>g.payload.id!==k)}return[...A,{op:m,payload:f,label:$,before:L,after:_,key:S}]}),{ok:!0,fingerprint:"",created_id:f.id??null,diagnostics:[]}},[t]);n.useEffect(()=>{if(!a.length){x(null);return}const m=setTimeout(()=>{var S;(S=d.current)==null||S.abort();const f=new AbortController;d.current=f,l(!0),pe(a.map($=>({op:$.op,payload:$.payload})),s,f.signal).then(x).catch($=>{$.name!=="AbortError"&&x(null)}).finally(()=>l(!1))},250);return()=>clearTimeout(m)},[a,s]);const p=n.useCallback(m=>{c(f=>f.filter(S=>S.key!==m))},[]),b=n.useCallback(()=>c([]),[]);return n.useMemo(()=>({pending:a,previewDoc:(r==null?void 0:r.model)??null,previewDiff:(r==null?void 0:r.diff)??null,diagnostics:(r==null?void 0:r.diagnostics)??[],failure:r&&r.failed_index!==null?{index:r.failed_index,error:r.error??"invalid change"}:null,busy:i,exec:w,drop:p,clear:b}),[a,r,i,w,p,b])}function Je(s){const t=new Map;for(const c of s)for(const r of["id","conceptual_id","from_fk_id"]){const x=c.payload[r];c.op.startsWith("create_")&&typeof x=="string"&&t.set(x,c.key)}if(!t.size)return new Set;const a=new Set;for(const c of s)if(!c.op.startsWith("create_"))for(const r of Object.values(c.payload))typeof r=="string"&&t.has(r)&&(a.add(c.key),a.add(t.get(r)));return a}function Qe({user:s}){const[t,a]=n.useState(null);return n.useEffect(()=>{je(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 Xe({exec:s,canEdit:t,stagedMembers:a}){const[c,r]=n.useState([]),[x,i]=n.useState(""),[l,d]=n.useState(null),[w,p]=n.useState(""),[b,m]=n.useState(new Set),[f,S]=n.useState("ancestors"),[$,L]=n.useState(1),[_,C]=n.useState(null),[A,k]=n.useState(new Set),[N,g]=n.useState(null);n.useEffect(()=>{xe().then(o=>{r(o.subject_areas),i(y=>{var R;return y||((R=o.subject_areas[0])==null?void 0:R.id)||""})}).catch(o=>g(String(o)))},[]),n.useEffect(()=>{x&&(C(null),m(new Set),be(x).then(d).catch(o=>g(String(o))))},[x]);const M=n.useMemo(()=>a[x]??(l==null?void 0:l.members)??[],[a,x,l]),E=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]),I=w.trim().toLowerCase(),T=o=>!I||o.name.toLowerCase().includes(I),h=n.useMemo(()=>new Set(M),[M]),D=n.useMemo(()=>M.map(o=>E.get(o)).filter(o=>!!o&&T(o)),[M,E,I]),F=n.useMemo(()=>[...E.values()].filter(o=>!h.has(o.id)&&T(o)),[E,h,I]),P=n.useCallback(o=>{if(!l)return;const y=o.filter(q=>!(l.members??[]).includes(q)).length,R=(l.members??[]).filter(q=>!o.includes(q)).length;s("set_subject_area_members",{id:l.id,members:o,__label:`${l.name}: ${o.length} objects (+${y} −${R})`})},[l,s]),z=(o,y)=>{const R=y?[...M,...o.filter(q=>!h.has(q))]:M.filter(q=>!o.includes(q));P(R),m(new Set)},W=(o,y,R)=>{const q=new Set(o);q.has(y)?q.delete(y):q.add(y),R(q)},U=()=>{if(!l)return;const o=b.size?[...b]:M;if(!o.length){g("add an object first, or select one to expand from");return}g(null),fe(l.id,{seeds:o,direction:f,levels:$}).then(y=>{C(y.hops),k(new Set(y.added))}).catch(y=>g(String(y)))},K=()=>{z([...A],!0),C(null)};if(N&&!l)return e.jsx("p",{className:"sme-splash error",children:N});if(!c.length)return e.jsx("p",{className:"sme-placeholder",children:"No subject areas yet."});const j=((l==null?void 0:l.inconsistent)??[]).filter(o=>!h.has(o));return e.jsxs("div",{className:"sa-editor",children:[e.jsx("nav",{className:"sme-nav",children:c.map(o=>e.jsxs("button",{className:"sme-sa"+(o.id===x?" active":""),onClick:()=>i(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:w,onChange:o=>p(o.target.value)})]}),j.length>0&&t&&e.jsxs("div",{className:"sa-nudge",children:[j.length," object",j.length>1?"s are":" is"," homed in this area but not included.",e.jsxs("button",{className:"sme-link",onClick:()=>z(j,!0),children:["Add ",j.length>1?"them all":"it"]})]}),e.jsxs("div",{className:"sa-panes",children:[e.jsx(Q,{title:`Available (${F.length})`,rows:F,picked:b,onToggle:o=>W(b,o,m),homedHere:(l==null?void 0:l.homed_here)??[]}),e.jsxs("div",{className:"sa-controls",children:[e.jsx("button",{className:"sme-secondary",disabled:!t||!b.size,onClick:()=>z([...b].filter(o=>!h.has(o)),!0),title:"Add the selected objects",children:"→"}),e.jsx("button",{className:"sme-secondary",disabled:!t||!F.length,onClick:()=>z(F.map(o=>o.id),!0),title:"Add everything matching the filter",children:"»"}),e.jsx("button",{className:"sme-secondary",disabled:!t||!b.size,onClick:()=>z([...b].filter(o=>h.has(o)),!1),title:"Remove the selected objects",children:"←"}),e.jsx("button",{className:"sme-secondary",disabled:!t||!D.length,onClick:()=>z(D.map(o=>o.id),!1),title:"Remove everything matching the filter",children:"«"})]}),e.jsx(Q,{title:`Included (${D.length})`,rows:D,picked:b,onToggle:o=>W(b,o,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:f,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:$,onChange:o=>L(Math.max(1,Math.min(10,Number(o.target.value))))})]}),e.jsx("button",{className:"sme-secondary",onClick:U,disabled:!t,children:"Preview"})]}),N&&e.jsx("p",{className:"sme-error-line",children:N}),_&&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:A.has(o.id),onChange:()=>W(A,o.id,k)}),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:()=>C(null),children:"Cancel"}),e.jsxs("button",{className:"sme-primary",onClick:K,disabled:!A.size,children:["Add ",A.size," object",A.size===1?"":"s"]})]})]})]})]})]})}function Q({title:s,rows:t,picked:a,onToggle:c,homedHere:r}){const x=n.useMemo(()=>new Set(r),[r]);return e.jsxs("div",{className:"sa-pane",children:[e.jsx("h3",{children:s}),e.jsxs("ul",{children:[t.map(i=>e.jsxs("li",{className:"sa-row"+(a.has(i.id)?" picked":""),onClick:()=>c(i.id),children:[e.jsx("input",{type:"checkbox",readOnly:!0,checked:a.has(i.id)}),e.jsx("span",{className:"sa-row-name",children:i.name}),x.has(i.id)?e.jsx("span",{className:"sme-badge",children:"home"}):e.jsx("span",{className:"sme-badge borrowed",children:"borrowed"})]},i.id)),!t.length&&e.jsx("li",{className:"sme-empty",children:"nothing here"})]})]})}function Ze({onCreate:s,onClose:t}){const[a,c]=n.useState(""),[r,x]=n.useState(""),[i,l]=n.useState([]),[d,w]=n.useState([]),[p,b]=n.useState(new Set),[m,f]=n.useState(""),[S,$]=n.useState("ancestors"),[L,_]=n.useState(1),[C,A]=n.useState(null),[k,N]=n.useState(new Set),[g,M]=n.useState(""),[E,I]=n.useState(null);n.useEffect(()=>{xe().then(j=>{const o=j.subject_areas[0];if(o)return M(o.id),be(o.id).then(y=>l([...y.included,...y.available]))}).catch(j=>I(String(j)))},[]);const T=n.useMemo(()=>new Set(d),[d]),h=m.trim().toLowerCase(),D=j=>!h||j.name.toLowerCase().includes(h),F=n.useMemo(()=>d.map(j=>i.find(o=>o.id===j)).filter(j=>!!j&&D(j)),[d,i,h]),P=n.useMemo(()=>i.filter(j=>!T.has(j.id)&&D(j)),[i,T,h]),z=(j,o)=>{w(y=>o?[...y,...j.filter(R=>!y.includes(R))]:y.filter(R=>!j.includes(R))),b(new Set)},W=(j,o,y)=>{const R=new Set(j);R.has(o)?R.delete(o):R.add(o),y(R)},U=()=>{const j=p.size?[...p]:d;if(!j.length){I("pick an object to expand from first");return}g&&(I(null),fe(g,{seeds:j,direction:S,levels:L}).then(o=>{const y=o.hops.filter(R=>!T.has(R.id));A(y),N(new Set(y.map(R=>R.id)))}).catch(o=>I(String(o))))},K=()=>{a.trim()&&s(a.trim(),r.trim(),d)};return e.jsx("div",{className:"sme-modal-backdrop",onClick:t,children:e.jsxs("div",{className:"sme-modal sa-modal",onClick:j=>j.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:j=>c(j.target.value),onKeyDown:j=>j.key==="Enter"&&d.length===0&&K()})]}),e.jsxs("label",{className:"sme-field",children:[e.jsx("span",{children:"Definition (optional)"}),e.jsx("input",{value:r,placeholder:"what this view is for",onChange:j=>x(j.target.value)})]})]}),e.jsx("input",{className:"sme-search sa-filter",type:"search",placeholder:"Filter both lists…",value:m,onChange:j=>f(j.target.value)}),e.jsxs("div",{className:"sa-panes",children:[e.jsx(Q,{title:`Available (${P.length})`,rows:P,picked:p,onToggle:j=>W(p,j,b),homedHere:[]}),e.jsxs("div",{className:"sa-controls",children:[e.jsx("button",{className:"sme-secondary",disabled:!p.size,onClick:()=>z([...p].filter(j=>!T.has(j)),!0),title:"Add the selected objects",children:"→"}),e.jsx("button",{className:"sme-secondary",disabled:!P.length,onClick:()=>z(P.map(j=>j.id),!0),title:"Add everything matching the filter",children:"»"}),e.jsx("button",{className:"sme-secondary",disabled:!p.size,onClick:()=>z([...p].filter(j=>T.has(j)),!1),title:"Remove the selected objects",children:"←"}),e.jsx("button",{className:"sme-secondary",disabled:!F.length,onClick:()=>z(F.map(j=>j.id),!1),title:"Remove everything matching the filter",children:"«"})]}),e.jsx(Q,{title:`Included (${F.length})`,rows:F,picked:p,onToggle:j=>W(p,j,b),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:j=>$(j.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:L,onChange:j=>_(Math.max(1,Math.min(10,Number(j.target.value))))})]}),e.jsx("button",{className:"sme-secondary",onClick:U,children:"Preview"})]}),C&&e.jsxs("div",{className:"sa-hops",children:[C.length===0&&e.jsx("p",{className:"sme-muted",children:"nothing new to add"}),C.map(j=>e.jsxs("label",{className:"sa-hop",children:[e.jsx("input",{type:"checkbox",checked:k.has(j.id),onChange:()=>W(k,j.id,N)}),e.jsx("span",{className:"sa-hop-name",children:j.name}),e.jsxs("span",{className:"sa-hop-why",children:["via ",j.via_name," · ",j.direction.replace(/s$/,""),", level ",j.level]})]},j.id)),C.length>0&&e.jsxs("div",{className:"sa-hop-actions",children:[e.jsx("button",{className:"sme-secondary",onClick:()=>A(null),children:"Cancel"}),e.jsxs("button",{className:"sme-primary",disabled:!k.size,onClick:()=>{z([...k],!0),A(null)},children:["Add ",k.size]})]})]})]}),E&&e.jsx("p",{className:"sme-error-line",children:E}),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:K,children:["Create",d.length>0&&` with ${d.length} object${d.length===1?"":"s"}`]})]})]})})}const es=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 ss({doc:s,subjectArea:t,onSubjectArea:a,exec:c,canEdit:r,direct:x=!1,onSelectEntity:i,busy:l}){var k;const[d,w]=n.useState(null),[p,b]=n.useState(null),[m,f]=n.useState(!1),[S,$]=n.useState(null),[L]=n.useState(""),_=n.useRef(null),C=n.useMemo(()=>({canEdit:r,mode:x?"direct":"staged",allow:x?void 0:es,canArbitrate:x,canCommit:x}),[r,x]),A=n.useCallback(N=>{w(N),N&&(i==null||i(N))},[i]);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"}),r&&e.jsx("button",{className:"sme-nav-add",title:"New subject area",onClick:()=>f(!0),children:"+"})]}),e.jsxs("button",{className:"sme-sa"+(t===""?" active":""),onClick:()=>a(""),children:["Whole model",e.jsx("span",{className:"sme-sa-count",children:((k=s.counts)==null?void 0:k.entities_total)??s.entities.length})]}),s.subject_areas.map(N=>e.jsxs("button",{className:"sme-sa"+(t===N.id?" active":""),onClick:()=>a(N.id),title:N.definition??void 0,children:[N.name,e.jsx("span",{className:"sme-sa-count",children:N.member_count??0})]},N.id))]}),m&&e.jsx(Ze,{onClose:()=>f(!1),onCreate:(N,g,M)=>{const E=ge();c("create_subject_area",{name:N,...g?{definition:g}:{},id:E}),M.length&&c("set_subject_area_members",{id:E,members:M}),f(!1),a(E)}}),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"]}),r&&e.jsx("button",{className:"erd-action",onClick:()=>{var N;return(N=_.current)==null?void 0:N.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"+(p==="ontology"?" on":""),onClick:()=>b(N=>N==="ontology"?null:"ontology"),children:"Ontology"}),e.jsx("button",{className:"erd-action ghost"+(p==="layers"?" on":""),onClick:()=>b(N=>N==="layers"?null:"layers"),children:"Layers"})]}),l&&e.jsx("span",{className:"erd-busy",children:"updating…"}),!r&&e.jsx("span",{className:"sme-chip",children:"read-only"}),S&&e.jsx("span",{className:"erd-error",children:S})]}),e.jsxs("div",{className:"erd-canvas canvas-wrap",children:[e.jsx(Re,{children:e.jsx(Me,{doc:s,caps:C,exec:c,selectedId:d,onSelect:A,query:L,onError:$,handleRef:_})}),p&&e.jsxs("aside",{className:"side-panel",children:[e.jsxs("div",{className:"detail-header",children:[e.jsx("h2",{children:p==="ontology"?"Ontology":"Ontology layers"}),e.jsx("button",{className:"icon-btn",onClick:()=>b(null),children:"✕"})]}),p==="ontology"?e.jsx(De,{}):e.jsx(Pe,{refreshKey:0,onFocusEntity:N=>{var g;b(null),(g=_.current)==null||g.focusEntity(N)}})]})]})]})]})}function ns({user:s,onView:t}){const[a,c]=n.useState(null),[r,x]=n.useState(null);if(n.useEffect(()=>{Oe(s).then(c).catch(l=>x(String(l)))},[s]),r)return e.jsx("p",{className:"sme-splash error",children:r});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 i=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:[i," 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(ts,{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 as(s,t){var a,c;return s.merged?{kind:"accepted",text:"✅ Accepted"}:s.pushed?t&&((a=s.pr)==null?void 0:a.state)==="CLOSED"?{kind:"declined",text:"✖ Declined"}:t&&((c=s.pr)==null?void 0:c.reviews)==="CHANGES_REQUESTED"?{kind:"changes",text:"💬 Changes requested"}:{kind:"awaiting",text:"⏳ Awaiting review"}:{kind:"local",text:"📥 Saved locally"}}function ts({p:s,gh:t,onView:a}){const c=as(s,t);return e.jsxs("div",{className:"pr-card"+(c.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 "+c.kind,children:c.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 rs({changes:s,routeAdvice:t,identity:a,user:c,onUser:r,onDrop:x,onClose:i,onProposed:l}){const d=!!(a&&a.source!=="anonymous"),[w,p]=n.useState(c||(localStorage.getItem("mdl.sme.user")??"")),[b,m]=n.useState(s.length===1?`Update ${s[0].label.toLowerCase()}`:"Glossary updates"),[f,S]=n.useState(""),[$,L]=n.useState(!1),_=Ne($?f:b),[C,A]=n.useState(""),[k,N]=n.useState(!1),[g,M]=n.useState(null),[E,I]=n.useState(null),T=()=>{!d&&!w.trim()||(d||(localStorage.setItem("mdl.sme.user",w.trim()),r==null||r(w.trim())),N(!0),I(null),Ie({user:d?"":w.trim(),slug:_,title:b,body:C.trim(),changes:s.map(h=>({op:h.op,payload:h.payload}))}).then(M).catch(h=>I(h instanceof Te?h.message:String(h))).finally(()=>N(!1)))};return g!=null&&g.ok?e.jsx("div",{className:"sme-modal-backdrop",onClick:()=>l(g),children:e.jsxs("div",{className:"sme-modal",onClick:h=>h.stopPropagation(),children:[e.jsx("h2",{children:"✓ Sent for review"}),e.jsx("p",{children:g.message}),g.pr_url&&e.jsx("p",{children:e.jsx("a",{href:g.pr_url,target:"_blank",rel:"noreferrer",children:"View pull request →"})}),g.compare_url&&e.jsx("p",{children:e.jsx("a",{href:g.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:g.branch}),". A steward will review it."]}),e.jsx("div",{className:"sme-modal-foot",children:e.jsx("button",{className:"sme-primary",onClick:()=>l(g),children:"Done"})})]})}):e.jsx("div",{className:"sme-modal-backdrop",onClick:i,children:e.jsxs("div",{className:"sme-modal",onClick:h=>h.stopPropagation(),children:[e.jsxs("div",{className:"sme-card-head",children:[e.jsx("h2",{children:"Submit for review"}),e.jsx("button",{className:"sme-secondary",onClick:i,children:"✕"})]}),e.jsx("h3",{children:"Your changes"}),e.jsx("ul",{className:"sme-diff",children:s.map((h,D)=>e.jsxs("li",{children:[e.jsxs("div",{className:"sme-diff-head",children:[e.jsx("b",{children:h.label}),e.jsx("button",{className:"sme-link danger",onClick:()=>x(D),children:"discard"})]}),e.jsx("div",{className:"sme-diff-before",children:h.before}),e.jsx("div",{className:"sme-diff-after",children:h.after})]},D))}),d?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:w,onChange:h=>p(h.target.value),placeholder:"e.g. a.hough"})]}),e.jsxs("label",{className:"sme-field",children:[e.jsx("span",{children:"Title"}),e.jsx("input",{value:b,onChange:h=>m(h.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:$?f:_,onChange:h=>{L(!0),S(h.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:C,onChange:h=>A(h.target.value)})]}),e.jsx(is,{cl:t,user:d?a.name:w,changeSlug:_}),E&&e.jsx("p",{className:"sme-error-line",children:E}),e.jsxs("div",{className:"sme-modal-foot",children:[e.jsx("button",{className:"sme-secondary",onClick:i,children:"Keep editing"}),e.jsx("button",{className:"sme-primary",disabled:k||!d&&!w.trim()||s.length===0,onClick:T,children:k?"Submitting…":"Submit for review"})]})]})})}function is({cl:s,user:t,changeSlug:a}){if(!(s!=null&&s.primary))return null;const c=s.reviewers_actual??s.reviewers,r=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"," ",c.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/",r,"/",a||"…"]})]}),e.jsxs("div",{className:"row",children:[e.jsx("span",{className:"k",children:"Reviewers"}),e.jsx("span",{children:c.join(", ")})]})]})]})}function Ne(s){return s.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"change"}const ls="modulepreload",cs=function(s){return"/"+s},oe={},os=function(t,a,c){let r=Promise.resolve();if(a&&a.length>0){document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),l=(i==null?void 0:i.nonce)||(i==null?void 0:i.getAttribute("nonce"));r=Promise.allSettled(a.map(d=>{if(d=cs(d),d in oe)return;oe[d]=!0;const w=d.endsWith(".css"),p=w?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${p}`))return;const b=document.createElement("link");if(b.rel=w?"stylesheet":ls,w||(b.as="script"),b.crossOrigin="",b.href=d,l&&b.setAttribute("nonce",l),document.head.appendChild(b),w)return new Promise((m,f)=>{b.addEventListener("load",m),b.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${d}`)))})}))}function x(i){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=i,window.dispatchEvent(l),!l.defaultPrevented)throw i}return r.then(i=>{for(const l of i||[])l.status==="rejected"&&x(l.reason);return t().catch(x)})};function ds({diff:s,selectable:t,selected:a,onToggle:c}){var l;const[r,x]=n.useState(((l=s.objects[0])==null?void 0:l.ulid)??null),i=n.useMemo(()=>s.objects.find(d=>d.ulid===r)??s.objects[0]??null,[s,r]);return s.objects.length?e.jsxs("div",{className:"rv-body",children:[e.jsx("div",{className:"rv-list",children:s.objects.map(d=>e.jsx(ms,{obj:d,active:d.ulid===((i==null?void 0:i.ulid)??""),checked:(a==null?void 0:a.has(d.ulid))??!0,selectable:t,onSelect:()=>x(d.ulid),onToggle:()=>c==null?void 0:c(d.ulid)},d.ulid))}),e.jsx("div",{className:"rv-detail",children:i&&e.jsx(us,{obj:i})})]}):e.jsxs("p",{className:"sme-placeholder",children:["No model changes against ",s.base.label,"."]})}function hs(s){return s.renamed?"renamed":s.severity==="breaking"?"breaking":s.change}function ms({obj:s,active:t,checked:a,selectable:c,onSelect:r,onToggle:x}){return e.jsxs("div",{className:"rv-obj"+(t?" active":""),onClick:r,children:[e.jsxs("div",{className:"rv-obj-head",children:[c&&e.jsx("input",{type:"checkbox",checked:a,onClick:i=>i.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"&&"⚠ ",hs(s)]})]}),e.jsxs("ul",{className:"rv-obj-fields",children:[s.fields.map((i,l)=>e.jsx("li",{children:i.label},i.field+l)),s.children.flatMap(i=>i.fields.map((l,d)=>e.jsxs("li",{children:[l.label,": ",i.name_before??i.name_after]},i.ulid+d)))]})]})}function us({obj:s}){const t=s.children.flatMap(a=>a.fields.map(c=>({field:c,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,c)=>e.jsx(de,{f:a},a.field+c)),t.map(({field:a,on:c},r)=>e.jsx(de,{f:a,on:c},"c"+r)),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 de({f:s,on:t}){var c,r,x;const a=t?`${s.label}: ${t}`:s.label;if((c=s.breaks)!=null&&c.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(i=>e.jsxs("li",{children:[e.jsxs("span",{className:"m",children:["→ ",i.name]}),e.jsxs("span",{className:"p",children:[i.target," · ",i.materialization]})]},i.name))})]})]});if(s.kind==="definition_changed"){const i=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:me(i,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:me(l,i,"ins")})]})]})]})}if(Array.isArray(s.before)||Array.isArray(s.after)){const i=new Set(((r=s.before)==null?void 0:r.map(String))??[]),l=new Set(((x=s.after)==null?void 0:x.map(String))??[]),d=[...l].filter(p=>!i.has(p)),w=[...i].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:[d.map(p=>e.jsxs("span",{className:"rv-chip-add",children:["+ ",p]},"a"+p)),w.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:he(s.before)}),e.jsx("span",{className:"arrow",children:"→"}),e.jsx("span",{className:"to",children:he(s.after)})]})]})}function he(s){return s==null||s===""?"—":typeof s=="boolean"?s?"yes":"no":typeof s=="object"?JSON.stringify(s):String(s)}function me(s,t,a){const c=s.split(/(\s+)/),r=t.split(/(\s+)/),x=m=>m.toLowerCase().replace(/[.,;:]/g,""),i=c.length,l=r.length,d=Array.from({length:i+1},()=>new Array(l+1).fill(0));for(let m=i-1;m>=0;m--)for(let f=l-1;f>=0;f--)d[m][f]=x(c[m])===x(r[f])?d[m+1][f+1]+1:Math.max(d[m+1][f],d[m][f+1]);const w=new Set;let p=0,b=0;for(;p=d[p][b+1]?p++:b++;return c.map((m,f)=>!m.trim()||w.has(f)?e.jsx("span",{children:m},f):a==="del"?e.jsx("del",{children:m},f):e.jsx("ins",{children:m},f))}const ps=n.lazy(()=>os(()=>import("./ModelDiagram-Koy1MoG4.js"),__vite__mapDeps([0,1,2,3])).then(s=>({default:s.ModelDiagram})));function js({stagedDiff:s,stagedRoute:t,user:a,onBack:c,onSubmit:r,excluded:x,onToggleObject:i,selectable:l}){const[d,w]=n.useState(null),[p,b]=n.useState(null),[m,f]=n.useState(null),[S,$]=n.useState(null),[L,_]=n.useState(null),[C,A]=n.useState("changes"),k=n.useCallback(()=>{je(a).then(g=>{$(g);const M=g.base_branch??"main";s?w(s):Be("HEAD").then(E=>E.ok?w(E):_(E.error??"could not read the model")).catch(E=>_(String(E))),t?b(t):Le("HEAD").then(b).catch(()=>{}),Fe(M).then(f).catch(()=>{})}).catch(g=>_(String(g)))},[a,s,t]);if(n.useEffect(k,[k]),L)return e.jsxs("div",{className:"rv-shell",children:[e.jsx(ue,{onBack:c,diff:null}),e.jsx("p",{className:"sme-splash error",children:e.jsx("pre",{children:L})})]});if(!d)return e.jsx("div",{className:"sme-splash",children:"◮ reading your changes…"});const N=new Set(d.objects.map(g=>g.ulid).filter(g=>!x.has(g)));return e.jsxs("div",{className:"rv-shell",children:[e.jsx(ue,{onBack:c,diff:d,tab:C,onTab:A}),C==="changes"?e.jsx(ds,{diff:d,selectable:l,selected:N,onToggle:i}):e.jsx(n.Suspense,{fallback:e.jsx("div",{className:"sme-splash",children:"◮ drawing the model…"}),children:e.jsx(ps,{severityByUlid:xs(d)})}),e.jsxs("div",{className:"rv-foot",children:[e.jsx(bs,{cl:p}),e.jsx(fs,{conf:m,ctx:S}),e.jsxs("div",{className:"rv-actions",children:[e.jsx("button",{className:"sme-secondary",onClick:c,children:"Keep editing"}),e.jsx("button",{className:"sme-primary",disabled:!d.objects.length||(S?!S.can_propose:!1),title:S&&!S.can_propose?"the working tree has uncommitted changes":"",onClick:()=>r(p),children:"Submit for review →"})]})]})]})}function xs(s){const t=new Map;for(const a of s.objects)t.set(a.ulid,a.severity);return t}function ue({onBack:s,diff:t,tab:a,onTab:c}){const r=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"}),r&&e.jsxs("div",{className:"rv-sub",children:[r.objects," object",r.objects===1?"":"s"," ·"," ",(r.breaking??0)+(r.additive??0)+(r.cosmetic??0)," changes",(t==null?void 0:t.has_breaking)&&e.jsxs("span",{className:"warn",children:[" · ⚠ ",r.breaking," breaking"]})," · comparing to ",e.jsx("code",{children:t==null?void 0:t.base.label})]})]}),c&&e.jsxs("div",{className:"rv-tabs",children:[e.jsxs("button",{className:"rv-tab"+(a==="changes"?" active":""),onClick:()=>c("changes"),children:["Changes ",(t==null?void 0:t.objects.length)??0]}),e.jsx("button",{className:"rv-tab"+(a==="diagram"?" active":""),onClick:()=>c("diagram"),children:"Diagram"})]})]})}function bs({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 fs({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 gs({term:s,canEdit:t,pendingCount:a,onEdit:c}){var r,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}),((r=s.subject_area)==null?void 0:r.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:c,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(i=>e.jsx("span",{className:"sme-chip",children:i},i))})]}),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(i=>e.jsxs("li",{children:[e.jsx("span",{className:"sme-usage-model",children:i.logical_entity}),i.unmanaged&&e.jsx("span",{className:"sme-badge",children:"engineer-owned"}),i.physical.length>0&&e.jsx("span",{className:"sme-usage-phys",children:i.physical.map(l=>l.name).join(", ")})]},i.logical_id))})]})]})}function vs({term:s,pending:t,onStage:a,onDone:c,catalogOwned:r=[],catalog:x=null}){var M,E,I,T;const i=h=>r.includes(h),l=h=>t.find(D=>D.label===h),d=(h,D)=>{const F=l(h);return F?F.after:D},[w,p]=n.useState(d("Definition",s.definition??"")),[b,m]=n.useState(s.synonyms),[f,S]=n.useState(""),[$,L]=n.useState(((M=s.stewardship)==null?void 0:M.owner)??""),[_,C]=n.useState(((E=s.stewardship)==null?void 0:E.steward)??""),A=()=>{w.trim()!==(s.definition??"").trim()&&a({op:"set_definition",payload:{id:s.id,definition:w.trim()},label:"Definition",before:s.definition??"(none)",after:w.trim()||"(none)"})},k=(h,D)=>{var F,P;a({op:"set_stewardship",payload:{id:s.id,owner:h||null,steward:D||null},label:"Stewardship",before:`owner: ${((F=s.stewardship)==null?void 0:F.owner)??"—"} · steward: ${((P=s.stewardship)==null?void 0:P.steward)??"—"}`,after:`owner: ${h||"—"} · steward: ${D||"—"}`})},N=h=>{m(h),a({op:"update_synonyms",payload:{id:s.id,synonyms:h},label:"Also called",before:s.synonyms.join(", ")||"(none)",after:h.join(", ")||"(none)"})},g=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:c,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."]}),(i("definition")||i("synonyms")||i("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"}),i("definition")?e.jsx("p",{className:"sme-readonly-value",children:s.definition??"—"}):e.jsx("textarea",{rows:4,value:w,onChange:h=>p(h.target.value),onBlur:A,placeholder:"A plain-language business definition…"})]}),e.jsxs("label",{className:"sme-field",children:[e.jsx("span",{children:"Also called (synonyms)"}),i("synonyms")?e.jsx("div",{className:"sme-syn-row",children:s.synonyms.length?s.synonyms.map(h=>e.jsx("span",{className:"sme-chip",children:h},h)):e.jsx("span",{className:"sme-muted",children:"none"})}):e.jsxs("div",{className:"sme-syn-row",children:[b.map(h=>e.jsxs("span",{className:"sme-chip removable",onClick:()=>N(b.filter(D=>D!==h)),children:[h," ✕"]},h)),e.jsx("input",{value:f,placeholder:"add + Enter",onChange:h=>S(h.target.value),onKeyDown:h=>{h.key==="Enter"&&f.trim()&&(N([...b,f.trim()]),S(""))}})]})]}),!g&&(i("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:((I=s.stewardship)==null?void 0:I.owner)??"—"})]}),e.jsxs("label",{className:"sme-field",children:[e.jsx("span",{children:"Steward"}),e.jsx("p",{className:"sme-readonly-value",children:((T=s.stewardship)==null?void 0:T.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:$,onChange:h=>L(h.target.value),onBlur:()=>k($,_)})]}),e.jsxs("label",{className:"sme-field",children:[e.jsx("span",{children:"Steward"}),e.jsx("input",{value:_,onChange:h=>C(h.target.value),onBlur:()=>k($,_)})]})]})),e.jsx(ys,{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 Ns=["skos:exactMatch","skos:closeMatch","skos:broadMatch","skos:narrowMatch"];function ys({term:s,onStage:t}){var b;const[a,c]=n.useState(!1),[r,x]=n.useState(s.name),[i,l]=n.useState([]),[d,w]=n.useState("skos:closeMatch"),p=m=>{x(m),ze(m).then(f=>l(f.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:r,onChange:m=>p(m.target.value),placeholder:"Search standards…",autoFocus:!0}),e.jsx("div",{className:"sme-align-results",children:i.map(m=>e.jsxs("button",{className:"sme-align-card",onClick:()=>{var f;t({op:"set_alignment",payload:{id:s.id,aligns_to:m.prefixed,alignment:d,status:"proposed"},label:"Standard mapping",before:((f=s.ontology)==null?void 0:f.aligns_to)??"(none)",after:`${m.prefixed} (${d}, proposed)`}),c(!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:d,onChange:m=>w(m.target.value),children:Ns.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:[(b=s.ontology)!=null&&b.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:()=>c(!0),children:"Propose a mapping…"})]})]})}function ws(){const[s,t]=n.useState(null),[a,c]=n.useState(!0),[r,x]=n.useState(null),[i,l]=n.useState(""),[d,w]=n.useState(null),[p,b]=n.useState(""),[m,f]=n.useState(""),[S,$]=n.useState(null),[L,_]=n.useState(!1),[C,A]=n.useState([]),[k,N]=n.useState(!1),[g,M]=n.useState(window.location.hash==="#proposals"?"proposals":"browse"),[E,I]=n.useState(new Set),[T,h]=n.useState(()=>localStorage.getItem("mdl.sme.user")??""),[D,F]=n.useState(null),[P,z]=n.useState(null),[W,U]=n.useState(!1),[K,j]=n.useState(null),o=n.useCallback((u,v)=>{var ae;const O=J=>{var te;const H=P==null?void 0:P.entities.find(re=>{var ie;return re.id===J||((ie=re.conceptual)==null?void 0:ie.id)===J});return((te=H==null?void 0:H.conceptual)==null?void 0:te.name)??(H==null?void 0:H.name)??"object"},B=O(v.id??v.entity_id);switch(u){case"create_entity":return{label:`New entity: ${v.name}`,before:"—",after:String(v.name??"")};case"create_relationship":return{label:`New relationship: ${O(v.from_entity)} → ${O(v.to_entity)}`,before:"—",after:String(v.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:[v.cardinality,v.optionality,v.identifying?"identifying":""].filter(Boolean).join(", ")};case"set_definition":return{label:`Definition: ${B}`,before:"",after:String(v.definition??"")};case"add_attribute":return{label:`Attribute added to ${B}`,before:"—",after:String(v.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(v)};case"rename_entity":return{label:`Renamed ${B}`,before:B,after:String(v.name??"")};case"set_subject_area":return{label:`Subject area: ${B}`,before:"",after:String(v.subject_area??"none")};case"set_stewardship":return{label:`Stewardship: ${B}`,before:"",after:String(v.steward??"")};case"set_subject_area_members":{const J=v.__label,H=((ae=v.members)==null?void 0:ae.length)??0;return{label:J??"Subject area members",before:"",after:`${H} object${H===1?"":"s"}`}}case"set_alignment":return{label:`Alignment: ${B}`,before:"",after:String(v.aligns_to??"")};default:return{label:`${u.replace(/_/g," ")}: ${B}`,before:"",after:""}}},[P]),y=Ye({subjectArea:p,describe:o}),R=n.useCallback(async(u,v)=>{const O=(P==null?void 0:P.fingerprint)??"",B=await qe(u,v,O);return await le(p||void 0).then(z),B},[P,p]),q=n.useMemo(()=>{const u={};for(const v of y.pending)v.op==="set_subject_area_members"&&(u[v.payload.id]=v.payload.members??[]);return u},[y.pending]),G=n.useMemo(()=>[...C,...y.pending],[C,y.pending]),[ye,X]=n.useState(null),[we,Z]=n.useState(null);n.useEffect(()=>{if(!G.length){X(null),Z(null);return}const u=new AbortController,v=G.map(O=>({op:O.op,payload:O.payload}));return pe(v,p||void 0,u.signal).then(O=>X(O.diff??null)).catch(O=>{O.name!=="AbortError"&&X(null)}),We(v).then(Z).catch(()=>Z(null)),()=>u.abort()},[G,p]);const Se=n.useMemo(()=>Je(G),[G]).size{M(u),window.location.hash=u==="browse"?"":`#${u}`},[]);n.useEffect(()=>{const u=()=>{const v=window.location.hash;M(v==="#proposals"?"proposals":v==="#review"?"review":v==="#model"?"model":v==="#areas"?"areas":"browse")};return u(),window.addEventListener("hashchange",u),()=>window.removeEventListener("hashchange",u)},[]);const ee=n.useCallback(()=>{Ge({subject_area:p,q:m}).then(t).catch(u=>w(String(u)))},[p,m]);n.useEffect(ee,[ee]),n.useEffect(()=>{le(p||void 0).then(u=>{c(u.read_only),l(u.project.name),z(u),U(!!u.direct),F(u.identity??null),u.identity&&u.identity.source!=="anonymous"&&u.identity.name&&h(u.identity.name)}).catch(()=>{}),He().then(x).catch(()=>{})},[p]);const se=n.useMemo(()=>(s==null?void 0:s.terms.find(u=>u.id===S))??null,[s,S]),_e=n.useCallback(u=>{const v=u.key??ve(u.op,u.payload);A(O=>[...O.filter(B=>B.key!==v),{...u,key:v}])},[]),ke=u=>A(v=>v.filter((O,B)=>B!==u)),Ce=()=>{A([]),N(!1),_(!1),ee()};if(d)return e.jsxs("div",{className:"sme-splash error",children:[e.jsx("h1",{children:"◮ Glossary"}),e.jsx("pre",{children:d}),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=(r==null?void 0:r.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:i}),a&&e.jsx("span",{className:"sme-chip",children:"read-only"}),Ae&&e.jsxs("span",{className:"sme-chip catalog",title:`Definitions are mastered in ${r==null?void 0:r.catalog_name}`,children:["mirrors ",r==null?void 0:r.catalog_name]})]}),e.jsx("input",{className:"sme-search",type:"search",placeholder:"Search terms & definitions…",value:m,onChange:u=>f(u.target.value)}),e.jsxs("nav",{className:"sme-tabs",children:[e.jsx("button",{className:"sme-tab"+(g==="browse"?" active":""),onClick:()=>V("browse"),children:"Terms"}),e.jsx("button",{className:"sme-tab"+(g==="model"?" active":""),onClick:()=>V("model"),children:"Model"}),e.jsx("button",{className:"sme-tab"+(g==="areas"?" active":""),onClick:()=>V("areas"),children:"Subject areas"}),e.jsx("button",{className:"sme-tab"+(g==="proposals"?" active":""),onClick:()=>V("proposals"),children:"My proposals"})]}),G.length>0&&e.jsxs("button",{className:"sme-tray",onClick:()=>V("review"),children:[G.length," change",G.length>1?"s":""," · Review →"]})]}),g==="browse"&&e.jsx(Qe,{user:T}),g==="review"?e.jsx(js,{stagedDiff:ye,stagedRoute:we,user:T,selectable:Se,excluded:E,onToggleObject:u=>I(v=>{const O=new Set(v);return O.has(u)?O.delete(u):O.add(u),O}),onBack:()=>V("browse"),onSubmit:u=>{j(u),N(!0)}}):g==="model"?y.previewDoc??P?e.jsx(ss,{doc:y.previewDoc??P,subjectArea:p,onSubjectArea:b,exec:W?R:y.exec,canEdit:Y,direct:W,busy:y.busy}):e.jsx("div",{className:"sme-splash",children:"◮ loading the model…"}):g==="areas"?e.jsx(Xe,{exec:y.exec,canEdit:Y,stagedMembers:q}):g==="proposals"?e.jsx(ns,{user:T,onView:()=>V("review")}):e.jsxs("div",{className:"sme-body",children:[e.jsxs("nav",{className:"sme-nav",children:[e.jsx("button",{className:"sme-sa"+(p===""?" active":""),onClick:()=>b(""),children:"All subject areas"}),s.subject_areas.map(u=>e.jsx("button",{className:"sme-sa"+(p===u.id?" active":""),onClick:()=>b(u.id),title:u.definition??void 0,children:u.name},u.id))]}),e.jsxs("ul",{className:"sme-list",children:[s.terms.map(u=>{var v;return e.jsxs("li",{className:"sme-list-item"+(u.id===S?" active":""),onClick:()=>{$(u.id),_(!1)},children:[e.jsx("span",{className:"sme-term-name",children:u.name}),u.kind==="term"&&e.jsx("span",{className:"sme-kind",children:"term"}),((v=u.ontology)==null?void 0:v.status)==="proposed"&&e.jsx("span",{className:"sme-badge proposed",title:"alignment awaiting architect",children:"proposed"}),e.jsx("span",{className:"sme-term-def",children:u.definition??"no definition yet"})]},u.id)}),s.terms.length===0&&e.jsx("li",{className:"sme-empty",children:"no terms match"})]}),e.jsx("section",{className:"sme-detail",children:se?L&&Y?e.jsx(vs,{term:se,pending:C,onStage:_e,onDone:()=>_(!1),catalogOwned:ne,catalog:r?{name:r.catalog_name,url:r.catalog_url}:null}):e.jsx(gs,{term:se,canEdit:Y,pendingCount:C.length,onEdit:()=>_(!0)}):e.jsx("div",{className:"sme-placeholder",children:"Select a term to see its definition."})})]}),k&&e.jsx(rs,{changes:G,routeAdvice:K,identity:D,user:T,onUser:u=>{h(u),localStorage.setItem("mdl.sme.user",u)},onDrop:ke,onClose:()=>N(!1),onProposed:()=>{Ce(),y.clear(),I(new Set),V("proposals")}})]})}Ee.createRoot(document.getElementById("root")).render(e.jsx($e.StrictMode,{children:e.jsx(ws,{})})); diff --git a/packages/server/src/mdl_server/static/assets/styles-B4bhxAsE.css b/packages/server/src/mdl_server/static/assets/styles-B4bhxAsE.css new file mode 100644 index 0000000..c99b6a1 --- /dev/null +++ b/packages/server/src/mdl_server/static/assets/styles-B4bhxAsE.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)}.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-CgxFEJWy.css b/packages/server/src/mdl_server/static/assets/styles-CgxFEJWy.css deleted file mode 100644 index f746ecb..0000000 --- a/packages/server/src/mdl_server/static/assets/styles-CgxFEJWy.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}.attr-row.empty{color:var(--text-dim);font-style:italic}.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-Cp8yHIFV.js b/packages/server/src/mdl_server/static/assets/styles-Cp8yHIFV.js deleted file mode 100644 index 96e23f0..0000000 --- a/packages/server/src/mdl_server/static/assets/styles-Cp8yHIFV.js +++ /dev/null @@ -1,23 +0,0 @@ -var Ua=Object.defineProperty;var Xa=(e,t,n)=>t in e?Ua(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var re=(e,t,n)=>Xa(e,typeof t!="symbol"?t+"":t,n);import{r as w,g as oi,R as C,j as h}from"./client-DOmNpTln.js";function ue(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?nl:tl;ui.useSyncExternalStore=wt.useSyncExternalStore!==void 0?wt.useSyncExternalStore:rl;ci.exports=ui;var sl=ci.exports;/** - * @license React - * use-sync-external-store-shim/with-selector.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var En=w,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;li.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};ai.exports=li;var hl=ai.exports;const ml=oi(hl),pl={},Hr=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?Hr(e):Hr,{useDebugValue:yl}=C,{useSyncExternalStoreWithSelector:xl}=ml,wl=e=>e;function di(e,t=wl,n){const r=xl(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return yl(r),r}const Vr=(e,t)=>{const n=gl(e),r=(s,i=t)=>di(n,s,i);return Object.assign(r,n),r},bl=(e,t)=>e?Vr(e,t):Vr;function le(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)),Gr.hasOwnProperty(t)?{space:Gr[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 fi(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=M&&(M=b+1);!(T=_[M])&&++M=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??"")):bt(this.node(),e)}function bt(e,t){return e.style.getPropertyValue(t)||yi(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 xi(e){return e.trim().split(/^|\s+/)}function xr(e){return e.classList||new wi(e)}function wi(e){this._node=e,this._names=xi(e.getAttribute("class")||"")}wi.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 bi(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(E){E.on("mousedown.drag",f).filter(r).on("touchstart.drag",_).on("touchmove.drag",g,ru).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function f(E,T){if(!(u||!e.call(this,E,T))){var j=M(this,t.call(this,E,T),E,T,"mouse");j&&(xe(E.view).on("mousemove.drag",y,Pt).on("mouseup.drag",x,Pt),Ni(E.view),Pn(E),c=!1,a=E.clientX,l=E.clientY,j("start",E))}}function y(E){if(gt(E),!c){var T=E.clientX-a,j=E.clientY-l;c=T*T+j*j>d}s.mouse("drag",E)}function x(E){xe(E.view).on("mousemove.drag mouseup.drag",null),Si(E.view,c),gt(E),s.mouse("end",E)}function _(E,T){if(e.call(this,E,T)){var j=E.changedTouches,I=t.call(this,E,T),F=j.length,S,D;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 pe(t[1],t[2],t[3],1):(t=du.exec(e))?new pe(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))?Kr(t[1],t[2]/100,t[3]/100,1):(t=pu.exec(e))?Kr(t[1],t[2]/100,t[3]/100,t[4]):Yr.hasOwnProperty(e)?Xr(Yr[e]):e==="transparent"?new pe(NaN,NaN,NaN,0):null}function Xr(e){return new pe(e>>16&255,e>>8&255,e&255,1)}function Kt(e,t,n,r){return r<=0&&(e=t=n=NaN),new pe(e,t,n,r)}function xu(e){return e instanceof Ut||(e=Ht(e)),e?(e=e.rgb(),new pe(e.r,e.g,e.b,e.opacity)):new pe}function nr(e,t,n,r){return arguments.length===1?xu(e):new pe(e,t,n,r??1)}function pe(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}wr(pe,nr,ki(Ut,{brighter(e){return e=e==null?fn:Math.pow(fn,e),new pe(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?zt:Math.pow(zt,e),new pe(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new pe(et(this.r),et(this.g),et(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:Zr,toString:Zr}));function qr(){return`#${Qe(this.r)}${Qe(this.g)}${Qe(this.b)}`}function wu(){return`#${Qe(this.r)}${Qe(this.g)}${Qe(this.b)}${Qe((isNaN(this.opacity)?1:this.opacity)*255)}`}function Zr(){const e=hn(this.opacity);return`${e===1?"rgb(":"rgba("}${et(this.r)}, ${et(this.g)}, ${et(this.b)}${e===1?")":`, ${e})`}`}function hn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function et(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Qe(e){return e=et(e),(e<16?"0":"")+e.toString(16)}function Kr(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 ji(e){if(e instanceof Ne)return new Ne(e.h,e.s,e.l,e.opacity);if(e instanceof Ut||(e=Ht(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?ji(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,ki(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 pe(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(Qr(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("}${Qr(this.h)}, ${Qt(this.s)*100}%, ${Qt(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Qr(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 Ci=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?$i:function(t,n){return n-t?_u(t,n,e):Ci(isNaN(t)?n:t)}}function $i(e,t){var n=t-e;return n?vu(e,n):Ci(isNaN(e)?t:e)}const Jr=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=$i(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 Fe(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var rr=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Fn=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=Fn.lastIndex=0,r,s,i,o=-1,a=[],l=[];for(e=e+"",t=t+"";(r=rr.exec(e))&&(s=Fn.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:Fe(r,s)})),n=Fn.lastIndex;return n180?u+=360:u-c>180&&(c+=360),m.push({i:d.push(s(d)+"rotate(",null,r)-2,x:Fe(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:Fe(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:Fe(c,d)},{i:x-2,x:Fe(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;--vt}function ns(){nt=(pn=Vt.now())+kn,vt=Tt=0;try{Du()}finally{vt=0,Pu(),nt=0}}function Lu(){var e=Vt.now(),t=e-pn;t>Ii&&(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(!vt){Tt&&(Tt=clearTimeout(Tt));var t=e-nt;t>24?(e<1/0&&(Tt=setTimeout(ns,e-Vt.now()-kn)),Ct&&(Ct=clearInterval(Ct))):(Ct||(pn=Vt.now(),Ct=setInterval(Lu,Ii)),vt=1,Ti(ns))}}function rs(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"),Fu=[],Oi=0,ss=1,or=2,ln=3,is=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;Hu(e,n,{name:t,index:r,group:s,on:zu,tween:Fu,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Oi})}function vr(e,t){var n=Se(e,t);if(n.state>Oi)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 Hu(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=Ri(i,0,n.time);function i(c){n.state=ss,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!==ss)return l();for(u in r)if(f=r[u],f.name===n.name){if(f.state===ln)return rs(o);f.state===is?(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 Hn(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 os(){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 zi(){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",os).on("wheel.zoom",F,{passive:!1}).on("mousedown.zoom",S).on("dblclick.zoom",D).filter(s).on("touchstart.zoom",L).on("touchmove.zoom",V).on("touchend.zoom touchcancel.zoom",H).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}g.transform=function(p,k,N,R){var $=p.selection?p.selection():p;$.property("__zoom",os),p!==$?T(p,k,N,R):$.interrupt().each(function(){j(this,arguments).event(R).start().zoom(null,typeof k=="function"?k.apply(this,arguments):k).end()})},g.scaleBy=function(p,k,N,R){g.scaleTo(p,function(){var $=this.__zoom.k,v=typeof k=="function"?k.apply(this,arguments):k;return $*v},N,R)},g.scaleTo=function(p,k,N,R){g.transform(p,function(){var $=t.apply(this,arguments),v=this.__zoom,A=N==null?E($):typeof N=="function"?N.apply(this,arguments):N,O=v.invert(A),z=typeof k=="function"?k.apply(this,arguments):k;return n(M(b(v,z),A,O),$,o)},N,R)},g.translateBy=function(p,k,N,R){g.transform(p,function(){return n(this.__zoom.translate(typeof k=="function"?k.apply(this,arguments):k,typeof N=="function"?N.apply(this,arguments):N),t.apply(this,arguments),o)},null,R)},g.translateTo=function(p,k,N,R,$){g.transform(p,function(){var v=t.apply(this,arguments),A=this.__zoom,O=R==null?E(v):typeof R=="function"?R.apply(this,arguments):R;return n(De.translate(O[0],O[1]).scale(A.k).translate(typeof k=="function"?-k.apply(this,arguments):-k,typeof N=="function"?-N.apply(this,arguments):-N),v,o)},R,$)};function b(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 M(p,k,N){var R=k[0]-N[0]*p.k,$=k[1]-N[1]*p.k;return R===p.x&&$===p.y?p:new Oe(p.k,R,$)}function E(p){return[(+p[0][0]+ +p[1][0])/2,(+p[0][1]+ +p[1][1])/2]}function T(p,k,N,R){p.on("start.zoom",function(){j(this,arguments).event(R).start()}).on("interrupt.zoom end.zoom",function(){j(this,arguments).event(R).end()}).tween("zoom",function(){var $=this,v=arguments,A=j($,v).event(R),O=t.apply($,v),z=N==null?E(O):typeof N=="function"?N.apply($,v):N,B=Math.max(O[1][0]-O[0][0],O[1][1]-O[0][1]),P=$.__zoom,G=typeof k=="function"?k.apply($,v):k,X=l(P.invert(z).concat(B/P.k),G.invert(z).concat(B/G.k));return function(Z){if(Z===1)Z=G;else{var Q=X(Z),U=B/Q[2];Z=new Oe(U,z[0]-Q[0]*U,z[1]-Q[1]*U)}A.zoom(null,Z)}})}function j(p,k,N){return!N&&p.__zooming||new I(p,k)}function I(p,k){this.that=p,this.args=k,this.active=0,this.sourceEvent=null,this.extent=t.apply(p,k),this.taps=0}I.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 N=j(this,k).event(p),R=this.__zoom,$=Math.max(i[0],Math.min(i[1],R.k*Math.pow(2,r.apply(this,arguments)))),v=Ee(p);if(N.wheel)(N.mouse[0][0]!==v[0]||N.mouse[0][1]!==v[1])&&(N.mouse[1]=R.invert(N.mouse[0]=v)),clearTimeout(N.wheel);else{if(R.k===$)return;N.mouse=[v,R.invert(v)],un(this),N.start()}$t(p),N.wheel=setTimeout(A,y),N.zoom("mouse",n(M(b(R,$),N.mouse[0],N.mouse[1]),N.extent,o));function A(){N.wheel=null,N.end()}}function S(p,...k){if(m||!e.apply(this,arguments))return;var N=p.currentTarget,R=j(this,k,!0).event(p),$=xe(p.view).on("mousemove.zoom",z,!0).on("mouseup.zoom",B,!0),v=Ee(p,N),A=p.clientX,O=p.clientY;Ni(p.view),Hn(p),R.mouse=[v,this.__zoom.invert(v)],un(this),R.start();function z(P){if($t(P),!R.moved){var G=P.clientX-A,X=P.clientY-O;R.moved=G*G+X*X>x}R.event(P).zoom("mouse",n(M(R.that.__zoom,R.mouse[0]=Ee(P,N),R.mouse[1]),R.extent,o))}function B(P){$.on("mousemove.zoom mouseup.zoom",null),Si(P.view,R.moved),$t(P),R.event(P).end()}}function D(p,...k){if(e.apply(this,arguments)){var N=this.__zoom,R=Ee(p.changedTouches?p.changedTouches[0]:p,this),$=N.invert(R),v=N.k*(p.shiftKey?.5:2),A=n(M(b(N,v),R,$),t.apply(this,k),o);$t(p),a>0?xe(this).transition().duration(a).call(T,A,R,p):xe(this).call(g.transform,A,R,p)}}function L(p,...k){if(e.apply(this,arguments)){var N=p.touches,R=N.length,$=j(this,k,p.changedTouches.length===R).event(p),v,A,O,z;for(Hn(p),A=0;A"[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 ee(e,t){const n=w.useContext(Cn);if(n===null)throw new Error(Fi);return di(n,e,t)}const oe=()=>{const e=w.useContext(Cn);if(e===null)throw new Error(Fi);return w.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=ee(Jd),o=`${e}`.split("-");return C.createElement("div",{className:ue(["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:C.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"},C.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=w.useRef(null),[m,f]=w.useState({x:0,y:0,width:0,height:0}),y=ue(["react-flow__edge-textwrapper",c]);return w.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:C.createElement("g",{transform:`translate(${e-m.width/2} ${t-m.height/2})`,className:y,visibility:m.width?"visible":"hidden",...u},s&&C.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}),C.createElement("text",{className:"react-flow__edge-text",y:m.height/2,dy:"0.3em",ref:d,style:r},n),l)};var nf=w.memo(tf);const Nr=e=>({width:e.offsetWidth,height:e.offsetHeight}),_t=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Sr=(e={x:0,y:0},t)=>({x:_t(e.x,t[0][0],t[1][0]),y:_t(e.y,t[0][1],t[1][1])}),as=(e,t,n)=>en?-_t(Math.abs(e-n),1,50)/50:0,Hi=(e,t)=>{const n=as(e.x,35,t.width-35)*20,r=as(e.y,35,t.height-35)*20;return[n,r]},Vi=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},Bi=(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}),Gi=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),ls=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),rf=(e,t)=>Gi(Bi(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),te=Symbol.for("internals"),Yi=["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 Wi=e=>"clientX"in e,Be=(e,t)=>{var i,o;const n=Wi(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})=>C.createElement(C.Fragment,null,C.createElement("path",{id:e,style:u,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:d,markerStart:m}),f&&C.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:f,className:"react-flow__edge-interaction"}),s&&we(n)&&we(r)?C.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 Ui({sourceX:e,sourceY:t,targetX:n,targetY:r}){const s=Math.abs(n-e)/2,i=n{const[_,g,b]=qi({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:r,targetPosition:i});return C.createElement(Xt,{path:_,labelX:g,labelY:b,label:o,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:d,style:m,markerEnd:f,markerStart:y,interactionWidth:x})});kr.displayName="SimpleBezierEdge";const us={[Y.Left]:{x:-1,y:0},[Y.Right]:{x:1,y:0},[Y.Top]:{x:0,y:-1},[Y.Bottom]:{x:0,y:1}},lf=({source:e,sourcePosition:t=Y.Bottom,target:n})=>t===Y.Left||t===Y.Right?e.xMath.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function cf({source:e,sourcePosition:t=Y.Bottom,target:n,targetPosition:r=Y.Top,center:s,offset:i}){const o=us[t],a=us[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},[b,M,E,T]=Ui({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(o[d]*a[d]===-1){y=s.x??b,x=s.y??M;const I=[{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"?I:F:f=d==="x"?F:I}else{const I=[{x:l.x,y:c.y}],F=[{x:c.x,y:l.y}];if(d==="x"?f=o.x===m?F:I:f=o.y===m?I:F,t===r){const H=Math.abs(e[d]-n[d]);if(H<=i){const p=Math.min(i-1,i-H);o[d]===m?_[d]=(l[d]>e[d]?-1:1)*p:g[d]=(c[d]>n[d]?-1:1)*p}}if(t!==r){const H=d==="x"?"y":"x",p=o[d]===a[H],k=l[H]>c[H],N=l[H]=V?(y=(S.x+D.x)/2,x=f[0].y):(y=f[0].x,x=(S.y+D.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,E,T]}function uf(e,t,n,r){const s=Math.min(ds(e,t)/2,ds(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 M="";return b>0&&b{const[g,b,M]=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 C.createElement(Xt,{path:g,labelX:b,labelY:M,label:s,labelStyle:i,labelShowBg:o,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,style:u,markerEnd:f,markerStart:y,interactionWidth:_})});$n.displayName="SmoothStepEdge";const jr=w.memo(e=>{var t;return C.createElement($n,{...e,pathOptions:w.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]=Ui({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,i,o,a]}const Cr=w.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 C.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 fs({pos:e,x1:t,y1:n,x2:r,y2:s,c:i}){switch(e){case Y.Left:return[t-tn(t-r,i),n];case Y.Right:return[t+tn(r-t,i),n];case Y.Top:return[t,n-tn(n-s,i)];case Y.Bottom:return[t,n+tn(s-n,i)]}}function Zi({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:r,targetY:s,targetPosition:i=Y.Top,curvature:o=.25}){const[a,l]=fs({pos:n,x1:e,y1:t,x2:r,y2:s,c:o}),[c,u]=fs({pos:i,x1:r,y1:s,x2:e,y2:t,c:o}),[d,m,f,y]=Xi({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=w.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:s=Y.Bottom,targetPosition:i=Y.Top,label:o,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:d,style:m,markerEnd:f,markerStart:y,pathOptions:x,interactionWidth:_})=>{const[g,b,M]=Zi({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:r,targetPosition:i,curvature:x==null?void 0:x.curvature});return C.createElement(Xt,{path:g,labelX:b,labelY:M,label:o,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:d,style:m,markerEnd:f,markerStart:y,interactionWidth:_})});bn.displayName="BezierEdge";const $r=w.createContext(null),ff=$r.Provider;$r.Consumer;const hf=()=>w.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},Ki=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r}),tt=(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}=tt(s,t).positionAbsolute;return Bi(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 Gi(n)},Qi=(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}=tt(u,a),_={x:x.x,y:x.y,width:d||0,height:m||0},g=lr(l,_),b=typeof d>"u"||typeof m>"u"||d===null||m===null,M=i&&g>0,E=(d||0)*(m||0);(b||M||g>=E||u.dragging)&&c.push(u)}),c},Ji=(e,t)=>{const n=e.map(r=>r.id);return t.filter(r=>n.includes(r.source)||n.includes(r.target))},eo=(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=_t(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}},Ke=(e,t=0)=>e.transition().duration(t);function hs(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}=Be(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 b=s.find(M=>M.nodeId===y&&M.type===x&&M.id===_);return{handle:{id:_,type:x,nodeId:y,x:(b==null?void 0:b.x)||n.x,y:(b==null?void 0:b.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},to=()=>({handleDomNode:null,isValid:!1,connection:wf,endHandle:null});function no(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={...to(),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===rt.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[te]){const{handleBounds:o}=i[te];let a=[],l=[];o&&(a=hs(i,o,"source",`${t}-${n}-${r}`),l=hs(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 ro({event:e,handleId:t,nodeId:n,onConnect:r,isTarget:s,getState:i,setState:o,isValidConnection:a,edgeUpdaterType:l,onReconnectEnd:c}){const u=Vi(e.target),{connectionMode:d,domNode:m,autoPanOnConnect:f,connectionRadius:y,onConnectStart:x,panBy:_,getNodes:g,cancelConnection:b}=i();let M=0,E;const{x:T,y:j}=Be(e),I=u==null?void 0:u.elementFromPoint(T,j),F=Mr(l,I),S=m==null?void 0:m.getBoundingClientRect();if(!S||!F)return;let D,L=Be(e,S),V=!1,H=null,p=!1,k=null;const N=bf({nodes:g(),nodeId:n,handleId:t,handleType:F}),R=()=>{if(!f)return;const[A,O]=Hi(L,S);_({x:A,y:O}),M=requestAnimationFrame(R)};o({connectionPosition:L,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 $(A){const{transform:O}=i();L=Be(A,S);const{handle:z,validHandleResult:B}=xf(A,u,dr(L,O,!1,[1,1]),y,N,P=>no(P,d,n,t,s?"target":"source",a,u));if(E=z,V||(R(),V=!0),k=B.handleDomNode,H=B.connection,p=B.isValid,o({connectionPosition:E&&p?Ki({x:E.x,y:E.y},O):L,connectionStatus:vf(!!E,p),connectionEndHandle:B.endHandle}),!E&&!p&&!k)return Vn(D);H.source!==H.target&&k&&(Vn(D),D=k,k.classList.add("connecting","react-flow__handle-connecting"),k.classList.toggle("valid",p),k.classList.toggle("react-flow__handle-valid",p))}function v(A){var O,z;(E||k)&&H&&p&&(r==null||r(H)),(z=(O=i()).onConnectEnd)==null||z.call(O,A),l&&(c==null||c(A)),Vn(D),b(),cancelAnimationFrame(M),V=!1,p=!1,H=null,k=null,u.removeEventListener("mousemove",$),u.removeEventListener("mouseup",v),u.removeEventListener("touchmove",$),u.removeEventListener("touchend",v)}u.addEventListener("mousemove",$),u.addEventListener("mouseup",v),u.addEventListener("touchmove",$),u.addEventListener("touchend",v)}const ms=()=>!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}},so=w.forwardRef(({type:e="source",position:t=Y.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,D;const y=o||null,x=e==="target",_=oe(),g=hf(),{connectOnClick:b,noPanClassName:M}=ee(_f,le),{connecting:E,clickConnecting:T}=ee(Ef(g,y,e),le);g||(D=(S=_.getState()).onError)==null||D.call(S,"010",Pe.error010());const j=L=>{const{defaultEdgeOptions:V,onConnect:H,hasDefaultEdges:p}=_.getState(),k={...V,...L};if(p){const{edges:N,setEdges:R}=_.getState();R(yf(k,N))}H==null||H(k),a==null||a(k)},I=L=>{if(!g)return;const V=Wi(L);s&&(V&&L.button===0||!V)&&ro({event:L,handleId:y,nodeId:g,onConnect:j,isTarget:x,getState:_.getState,setState:_.setState,isValidConnection:n||_.getState().isValidConnection||ms}),V?u==null||u(L):d==null||d(L)},F=L=>{const{onClickConnectStart:V,onClickConnectEnd:H,connectionClickStartHandle:p,connectionMode:k,isValidConnection:N}=_.getState();if(!g||!p&&!s)return;if(!p){V==null||V(L,{nodeId:g,handleId:y,handleType:e}),_.setState({connectionClickStartHandle:{nodeId:g,type:e,handleId:y}});return}const R=Vi(L.target),$=n||N||ms,{connection:v,isValid:A}=no({nodeId:g,id:y,type:e},k,p.nodeId,p.handleId||null,p.type,$,R);A&&j(v),H==null||H(L),_.setState({connectionClickStartHandle:null})};return C.createElement("div",{"data-handleid":y,"data-nodeid":g,"data-handlepos":t,"data-id":`${g}-${y}-${e}`,className:ue(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",M,c,{source:!x,target:x,connectable:r,connectablestart:s,connectableend:i,connecting:T,connectionindicator:r&&(s&&!E||i&&E)}]),onMouseDown:I,onTouchStart:I,onClick:b?F:void 0,ref:f,...m},l)});so.displayName="Handle";var Et=w.memo(so);const io=({data:e,isConnectable:t,targetPosition:n=Y.Top,sourcePosition:r=Y.Bottom})=>C.createElement(C.Fragment,null,C.createElement(Et,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,C.createElement(Et,{type:"source",position:r,isConnectable:t}));io.displayName="DefaultNode";var fr=w.memo(io);const oo=({data:e,isConnectable:t,sourcePosition:n=Y.Bottom})=>C.createElement(C.Fragment,null,e==null?void 0:e.label,C.createElement(Et,{type:"source",position:n,isConnectable:t}));oo.displayName="InputNode";var ao=w.memo(oo);const lo=({data:e,isConnectable:t,targetPosition:n=Y.Top})=>C.createElement(C.Fragment,null,C.createElement(Et,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label);lo.displayName="OutputNode";var co=w.memo(lo);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 le(e.selectedNodes.map(nn),t.selectedNodes.map(nn))&&le(e.selectedEdges.map(nn),t.selectedEdges.map(nn))}const uo=w.memo(({onSelectionChange:e})=>{const t=oe(),{selectedNodes:n,selectedEdges:r}=ee(Nf,Sf);return w.useEffect(()=>{const s={nodes:n,edges:r};e==null||e(s),t.getState().onSelectionChange.forEach(i=>i(s))},[n,r,e]),null});uo.displayName="SelectionListener";const kf=e=>!!e.onSelectionChange;function jf({onSelectionChange:e}){const t=ee(kf);return e||t?C.createElement(uo,{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 dt(e,t){w.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function q(e,t,n){w.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:b,onEdgesChange:M,elementsSelectable:E,connectionMode:T,snapGrid:j,snapToGrid:I,translateExtent:F,connectOnClick:S,defaultEdgeOptions:D,fitView:L,fitViewOptions:V,onNodesDelete:H,onEdgesDelete:p,onNodeDrag:k,onNodeDragStart:N,onNodeDragStop:R,onSelectionDrag:$,onSelectionDragStart:v,onSelectionDragStop:A,noPanClassName:O,nodeOrigin:z,rfId:B,autoPanOnConnect:P,autoPanOnNodeDrag:G,onError:X,connectionRadius:Z,isValidConnection:Q,nodeDragThreshold:U})=>{const{setNodes:K,setEdges:ce,setDefaultNodesAndEdges:ie,setMinZoom:he,setMaxZoom:de,setTranslateExtent:ne,setNodeExtent:ge,reset:J}=ee(Cf,le),W=oe();return w.useEffect(()=>{const me=r==null?void 0:r.map(Me=>({...Me,...D}));return ie(n,me),()=>{J()}},[]),q("defaultEdgeOptions",D,W.setState),q("connectionMode",T,W.setState),q("onConnect",s,W.setState),q("onConnectStart",i,W.setState),q("onConnectEnd",o,W.setState),q("onClickConnectStart",a,W.setState),q("onClickConnectEnd",l,W.setState),q("nodesDraggable",c,W.setState),q("nodesConnectable",u,W.setState),q("nodesFocusable",d,W.setState),q("edgesFocusable",m,W.setState),q("edgesUpdatable",f,W.setState),q("elementsSelectable",E,W.setState),q("elevateNodesOnSelect",y,W.setState),q("snapToGrid",I,W.setState),q("snapGrid",j,W.setState),q("onNodesChange",b,W.setState),q("onEdgesChange",M,W.setState),q("connectOnClick",S,W.setState),q("fitViewOnInit",L,W.setState),q("fitViewOnInitOptions",V,W.setState),q("onNodesDelete",H,W.setState),q("onEdgesDelete",p,W.setState),q("onNodeDrag",k,W.setState),q("onNodeDragStart",N,W.setState),q("onNodeDragStop",R,W.setState),q("onSelectionDrag",$,W.setState),q("onSelectionDragStart",v,W.setState),q("onSelectionDragStop",A,W.setState),q("noPanClassName",O,W.setState),q("nodeOrigin",z,W.setState),q("rfId",B,W.setState),q("autoPanOnConnect",P,W.setState),q("autoPanOnNodeDrag",G,W.setState),q("onError",X,W.setState),q("connectionRadius",Z,W.setState),q("isValidConnection",Q,W.setState),q("nodeDragThreshold",U,W.setState),dt(e,K),dt(t,ce),dt(x,he),dt(_,de),dt(F,ne),dt(g,ge),null},ps={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%)"},fo="react-flow__node-desc",ho="react-flow__edge-desc",Af="react-flow__aria-live",If=e=>e.ariaLiveMessage;function Tf({rfId:e}){const t=ee(If);return C.createElement("div",{id:`${Af}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Mf},t)}function Rf({rfId:e,disableKeyboardA11y:t}){return C.createElement(C.Fragment,null,C.createElement("div",{id:`${fo}-${e}`,style:ps},"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."," "),C.createElement("div",{id:`${ho}-${e}`,style:ps},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&C.createElement(Tf,{rfId:e}))}var Yt=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,r]=w.useState(!1),s=w.useRef(!1),i=w.useRef(new Set([])),[o,a]=w.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 w.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=ys(f.code,a);i.current.add(f[x]),gs(o,i.current,!1)&&(f.preventDefault(),r(!0))},d=f=>{if((!s.current||s.current&&!t.actInsideInputWithModifier)&&cr(f))return!1;const x=ys(f.code,a);gs(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 gs(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function ys(e,t){return t.includes(e)?"code":"key"}function mo(e,t,n,r){var a,l;const s=e.parentNode||e.parentId;if(!s)return n;const i=t.get(s),o=tt(i,r);return mo(i,t,{x:(n.x??0)+o.x,y:(n.y??0)+o.y,z:(((a=i[te])==null?void 0:a.z)??0)>(n.z??0)?((l=i[te])==null?void 0:l.z)??0:n.z??0},r)}function po(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}=mo(r,e,{...r.position,z:((i=r[te])==null?void 0:i.z)??0},t);r.positionAbsolute={x:o,y:a},r[te].z=l,n!=null&&n[r.id]&&(r[te].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,te,{enumerable:!1,value:{handleBounds:m||(f=c==null?void 0:c[te])==null?void 0:f.handleBounds,z:l}}),s.set(a.id,u)}),po(s,n,i),s}function go(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 b;const g=t.includeHiddenNodes?_.width&&_.height:!_.hidden;return(b=t.nodes)!=null&&b.length?g&&t.nodes.some(M=>M.id===_.id):g}),x=y.every(_=>_.width&&_.height);if(y.length>0&&x){const _=Mn(y,d),{x:g,y:b,zoom:M}=eo(_,r,s,t.minZoom??i,t.maxZoom??o,t.padding??.1),E=De.translate(g,b).scale(M);return typeof t.duration=="number"&&t.duration>0?a.transform(Ke(l,t.duration),E):a.transform(l,E),!0}}return!1}function Of(e,t){return e.forEach(n=>{const r=t.get(n.id);r&&t.set(r.id,{...r,[te]:r[te],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 ft=()=>{},Lf={zoomIn:ft,zoomOut:ft,zoomTo:ft,getZoom:()=>1,setViewport:ft,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:ft,fitBounds:ft,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},Pf=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),zf=()=>{const e=oe(),{d3Zoom:t,d3Selection:n}=ee(Pf,le);return w.useMemo(()=>n&&t?{zoomIn:s=>t.scaleBy(Ke(n,s==null?void 0:s.duration),1.2),zoomOut:s=>t.scaleBy(Ke(n,s==null?void 0:s.duration),1/1.2),zoomTo:(s,i)=>t.scaleTo(Ke(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(Ke(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=>go(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(Ke(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}=eo(s,o,a,l,c,(i==null?void 0:i.padding)??.1),f=De.translate(u,d).scale(m);t.transform(Ke(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=Ki(s,i);return{x:c.x+a,y:c.y+l}},viewportInitialized:!0}:Lf,[t,n])};function An(){const e=zf(),t=oe(),n=w.useCallback(()=>t.getState().getNodes().map(x=>({...x})),[]),r=w.useCallback(x=>t.getState().nodeInternals.get(x),[]),s=w.useCallback(()=>{const{edges:x=[]}=t.getState();return x.map(_=>({..._}))},[]),i=w.useCallback(x=>{const{edges:_=[]}=t.getState();return _.find(g=>g.id===x)},[]),o=w.useCallback(x=>{const{getNodes:_,setNodes:g,hasDefaultNodes:b,onNodesChange:M}=t.getState(),E=_(),T=typeof x=="function"?x(E):x;if(b)g(T);else if(M){const j=T.length===0?E.map(I=>({type:"remove",id:I.id})):T.map(I=>({item:I,type:"reset"}));M(j)}},[]),a=w.useCallback(x=>{const{edges:_=[],setEdges:g,hasDefaultEdges:b,onEdgesChange:M}=t.getState(),E=typeof x=="function"?x(_):x;if(b)g(E);else if(M){const T=E.length===0?_.map(j=>({type:"remove",id:j.id})):E.map(j=>({item:j,type:"reset"}));M(T)}},[]),l=w.useCallback(x=>{const _=Array.isArray(x)?x:[x],{getNodes:g,setNodes:b,hasDefaultNodes:M,onNodesChange:E}=t.getState();if(M){const j=[...g(),..._];b(j)}else if(E){const T=_.map(j=>({item:j,type:"add"}));E(T)}},[]),c=w.useCallback(x=>{const _=Array.isArray(x)?x:[x],{edges:g=[],setEdges:b,hasDefaultEdges:M,onEdgesChange:E}=t.getState();if(M)b([...g,..._]);else if(E){const T=_.map(j=>({item:j,type:"add"}));E(T)}},[]),u=w.useCallback(()=>{const{getNodes:x,edges:_=[],transform:g}=t.getState(),[b,M,E]=g;return{nodes:x().map(T=>({...T})),edges:_.map(T=>({...T})),viewport:{x:b,y:M,zoom:E}}},[]),d=w.useCallback(({nodes:x,edges:_})=>{const{nodeInternals:g,getNodes:b,edges:M,hasDefaultNodes:E,hasDefaultEdges:T,onNodesDelete:j,onEdgesDelete:I,onNodesChange:F,onEdgesChange:S}=t.getState(),D=(x||[]).map(k=>k.id),L=(_||[]).map(k=>k.id),V=b().reduce((k,N)=>{const R=N.parentNode||N.parentId,$=!D.includes(N.id)&&R&&k.find(A=>A.id===R);return(typeof N.deletable=="boolean"?N.deletable:!0)&&(D.includes(N.id)||$)&&k.push(N),k},[]),H=M.filter(k=>typeof k.deletable=="boolean"?k.deletable:!0),p=H.filter(k=>L.includes(k.id));if(V||p){const k=Ji(V,H),N=[...p,...k],R=N.reduce(($,v)=>($.includes(v.id)||$.push(v.id),$),[]);if((T||E)&&(T&&t.setState({edges:M.filter($=>!R.includes($.id))}),E&&(V.forEach($=>{g.delete($.id)}),t.setState({nodeInternals:new Map(g)}))),R.length>0&&(I==null||I(N),S&&S(R.map($=>({id:$,type:"remove"})))),V.length>0&&(j==null||j(V),F)){const $=V.map(v=>({id:v.id,type:"remove"}));F($)}}},[]),m=w.useCallback(x=>{const _=sf(x),g=_?null:t.getState().nodeInternals.get(x.id);return!_&&!g?[null,null,_]:[_?x:ls(g),g,_]},[]),f=w.useCallback((x,_=!0,g)=>{const[b,M,E]=m(x);return b?(g||t.getState().getNodes()).filter(T=>{if(!E&&(T.id===M.id||!T.positionAbsolute))return!1;const j=ls(T),I=lr(j,b);return _&&I>0||I>=b.width*b.height}):[]},[]),y=w.useCallback((x,_,g=!0)=>{const[b]=m(x);if(!b)return!1;const M=lr(b,_);return g&&M>0||M>=b.width*b.height},[]);return w.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 Ff={actInsideInputWithModifier:!1};var Hf=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=oe(),{deleteElements:r}=An(),s=Yt(e,Ff),i=Yt(t);w.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]),w.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])};function Vf(e){const t=oe();w.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}),ht=(e,t)=>e.target.closest(`.${t}`),xs=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),ws=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=Je.Free,zoomOnDoubleClick:c=!0,elementsSelectable:u,panOnDrag:d=!0,defaultViewport:m,translateExtent:f,minZoom:y,maxZoom:x,zoomActivationKeyCode:_,preventScrolling:g=!0,children:b,noWheelClassName:M,noPanClassName:E})=>{const T=w.useRef(),j=oe(),I=w.useRef(!1),F=w.useRef(!1),S=w.useRef(null),D=w.useRef({x:0,y:0,zoom:0}),{d3Zoom:L,d3Selection:V,d3ZoomHandler:H,userSelectionActive:p}=ee(Gf,le),k=Yt(_),N=w.useRef(0),R=w.useRef(!1),$=w.useRef();return Vf(S),w.useEffect(()=>{if(S.current){const v=S.current.getBoundingClientRect(),A=zi().scaleExtent([y,x]).translateExtent(f),O=xe(S.current).call(A),z=De.translate(m.x,m.y).scale(_t(m.zoom,y,x)),B=[[0,0],[v.width,v.height]],P=A.constrain()(z,B,f);A.transform(O,P),A.wheelDelta(ws),j.setState({d3Zoom:A,d3Selection:O,d3ZoomHandler:O.on("wheel.zoom"),transform:[P.x,P.y,P.k],domNode:S.current.closest(".react-flow")})}},[]),w.useEffect(()=>{V&&L&&(o&&!k&&!p?V.on("wheel.zoom",v=>{if(ht(v,M))return!1;v.preventDefault(),v.stopImmediatePropagation();const A=V.property("__zoom").k||1;if(v.ctrlKey&&i){const Q=Ee(v),U=ws(v),K=A*Math.pow(2,U);L.scaleTo(V,K,Q,v);return}const O=v.deltaMode===1?20:1;let z=l===Je.Vertical?0:v.deltaX*O,B=l===Je.Horizontal?0:v.deltaY*O;!yn()&&v.shiftKey&&l!==Je.Vertical&&(z=v.deltaY*O,B=0),L.translateBy(V,-(z/A)*a,-(B/A)*a,{internal:!0});const P=sn(V.property("__zoom")),{onViewportChangeStart:G,onViewportChange:X,onViewportChangeEnd:Z}=j.getState();clearTimeout($.current),R.current||(R.current=!0,t==null||t(v,P),G==null||G(P)),R.current&&(e==null||e(v,P),X==null||X(P),$.current=setTimeout(()=>{n==null||n(v,P),Z==null||Z(P),R.current=!1},150))},{passive:!1}):typeof H<"u"&&V.on("wheel.zoom",function(v,A){if(!g&&v.type==="wheel"&&!v.ctrlKey||ht(v,M))return null;v.preventDefault(),H.call(this,v,A)},{passive:!1}))},[p,o,l,V,L,H,k,i,g,M,t,e,n]),w.useEffect(()=>{L&&L.on("start",v=>{var z,B;if(!v.sourceEvent||v.sourceEvent.internal)return null;N.current=(z=v.sourceEvent)==null?void 0:z.button;const{onViewportChangeStart:A}=j.getState(),O=sn(v.transform);I.current=!0,D.current=O,((B=v.sourceEvent)==null?void 0:B.type)==="mousedown"&&j.setState({paneDragging:!0}),A==null||A(O),t==null||t(v.sourceEvent,O)})},[L,t]),w.useEffect(()=>{L&&(p&&!I.current?L.on("zoom",null):p||L.on("zoom",v=>{var O;const{onViewportChange:A}=j.getState();if(j.setState({transform:[v.transform.x,v.transform.y,v.transform.k]}),F.current=!!(r&&xs(d,N.current??0)),(e||A)&&!((O=v.sourceEvent)!=null&&O.internal)){const z=sn(v.transform);A==null||A(z),e==null||e(v.sourceEvent,z)}}))},[p,L,e,d,r]),w.useEffect(()=>{L&&L.on("end",v=>{if(!v.sourceEvent||v.sourceEvent.internal)return null;const{onViewportChangeEnd:A}=j.getState();if(I.current=!1,j.setState({paneDragging:!1}),r&&xs(d,N.current??0)&&!F.current&&r(v.sourceEvent),F.current=!1,(n||A)&&Bf(D.current,v.transform)){const O=sn(v.transform);D.current=O,clearTimeout(T.current),T.current=setTimeout(()=>{A==null||A(O),n==null||n(v.sourceEvent,O)},o?150:0)}})},[L,o,d,n,r]),w.useEffect(()=>{L&&L.filter(v=>{const A=k||s,O=i&&v.ctrlKey;if((d===!0||Array.isArray(d)&&d.includes(1))&&v.button===1&&v.type==="mousedown"&&(ht(v,"react-flow__node")||ht(v,"react-flow__edge")))return!0;if(!d&&!A&&!o&&!c&&!i||p||!c&&v.type==="dblclick"||ht(v,M)&&v.type==="wheel"||ht(v,E)&&(v.type!=="wheel"||o&&v.type==="wheel"&&!k)||!i&&v.ctrlKey&&v.type==="wheel"||!A&&!o&&!O&&v.type==="wheel"||!d&&(v.type==="mousedown"||v.type==="touchstart")||Array.isArray(d)&&!d.includes(v.button)&&v.type==="mousedown")return!1;const z=Array.isArray(d)&&d.includes(v.button)||!v.button||v.button<=1;return(!v.ctrlKey||v.type==="wheel")&&z})},[p,L,s,i,o,c,d,u,k]),C.createElement("div",{className:"react-flow__renderer",ref:S,style:Ir},b)},Wf=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Uf(){const{userSelectionActive:e,userSelectionRect:t}=ee(Wf,le);return e&&t?C.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 bs(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&&bs(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&&bs(r,o);break}case"remove":return r}return r.push(o),r},n)}function qf(e,t){return Xf(e,t)}const He=(e,t)=>({id:e,type:"select",selected:t});function pt(e,t){return e.reduce((n,r)=>{const s=t.includes(r.id);return!r.selected&&s?(r.selected=!0,n.push(He(r.id,!0))):r.selected&&!s&&(r.selected=!1,n.push(He(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}),yo=w.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=w.useRef(null),f=oe(),y=w.useRef(0),x=w.useRef(0),_=w.useRef(),{userSelectionActive:g,elementsSelectable:b,dragging:M}=ee(Zf,le),E=()=>{f.setState({userSelectionActive:!1,userSelectionRect:null}),y.current=0,x.current=0},T=H=>{i==null||i(H),f.getState().resetSelectedElements(),f.setState({nodesSelectionActive:!1})},j=H=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){H.preventDefault();return}o==null||o(H)},I=a?H=>a(H):void 0,F=H=>{const{resetSelectedElements:p,domNode:k}=f.getState();if(_.current=k==null?void 0:k.getBoundingClientRect(),!b||!e||H.button!==0||H.target!==m.current||!_.current)return;const{x:N,y:R}=Be(H,_.current);p(),f.setState({userSelectionRect:{width:0,height:0,startX:N,startY:R,x:N,y:R}}),r==null||r(H)},S=H=>{const{userSelectionRect:p,nodeInternals:k,edges:N,transform:R,onNodesChange:$,onEdgesChange:v,nodeOrigin:A,getNodes:O}=f.getState();if(!e||!_.current||!p)return;f.setState({userSelectionActive:!0,nodesSelectionActive:!1});const z=Be(H,_.current),B=p.startX??0,P=p.startY??0,G={...p,x:z.xK.id),U=Z.map(K=>K.id);if(y.current!==U.length){y.current=U.length;const K=pt(X,U);K.length&&($==null||$(K))}if(x.current!==Q.length){x.current=Q.length;const K=pt(N,Q);K.length&&(v==null||v(K))}f.setState({userSelectionRect:G})},D=H=>{if(H.button!==0)return;const{userSelectionRect:p}=f.getState();!g&&p&&H.target===m.current&&(T==null||T(H)),f.setState({nodesSelectionActive:y.current>0}),E(),s==null||s(H)},L=H=>{g&&(f.setState({nodesSelectionActive:y.current>0}),s==null||s(H)),E()},V=b&&(e||g);return C.createElement("div",{className:ue(["react-flow__pane",{dragging:M,selection:e}]),onClick:V?void 0:Gn(T,m),onContextMenu:Gn(j,m),onWheel:Gn(I,m),onMouseEnter:V?void 0:l,onMouseDown:V?F:void 0,onMouseMove:V?S:c,onMouseUp:V?D:void 0,onMouseLeave:V?L:u,ref:m,style:Ir},d,C.createElement(Uf,null))});yo.displayName="Pane";function xo(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const r=t.get(n);return r?r.selected?!0:xo(r,t):!1}function vs(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||!xo(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 wo(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}=tt(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}=tt(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=tt(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 _s=(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=oe();return w.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 bo({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:i,selectNodesOnDrag:o}){const a=oe(),[l,c]=w.useState(!1),u=w.useRef([]),d=w.useRef({x:null,y:null}),m=w.useRef(0),f=w.useRef(null),y=w.useRef({x:0,y:0}),x=w.useRef(null),_=w.useRef(!1),g=w.useRef(!1),b=w.useRef(!1),M=Jf();return w.useEffect(()=>{if(e!=null&&e.current){const E=xe(e.current),T=({x:F,y:S})=>{const{nodeInternals:D,onNodeDrag:L,onSelectionDrag:V,updateNodePositions:H,nodeExtent:p,snapGrid:k,snapToGrid:N,nodeOrigin:R,onError:$}=a.getState();d.current={x:F,y:S};let v=!1,A={x:0,y:0,x2:0,y2:0};if(u.current.length>1&&p){const z=Mn(u.current,R);A=Bt(z)}if(u.current=u.current.map(z=>{const B={x:F-z.distance.x,y:S-z.distance.y};N&&(B.x=k[0]*Math.round(B.x/k[0]),B.y=k[1]*Math.round(B.y/k[1]));const P=[[p[0][0],p[0][1]],[p[1][0],p[1][1]]];u.current.length>1&&p&&!z.extent&&(P[0][0]=z.positionAbsolute.x-A.x+p[0][0],P[1][0]=z.positionAbsolute.x+(z.width??0)-A.x2+p[1][0],P[0][1]=z.positionAbsolute.y-A.y+p[0][1],P[1][1]=z.positionAbsolute.y+(z.height??0)-A.y2+p[1][1]);const G=wo(z,B,D,P,R,$);return v=v||z.position.x!==G.position.x||z.position.y!==G.position.y,z.position=G.position,z.positionAbsolute=G.positionAbsolute,z}),!v)return;H(u.current,!0,!0),c(!0);const O=s?L:Wn(V);if(O&&x.current){const[z,B]=Yn({nodeId:s,dragItems:u.current,nodeInternals:D});O(x.current,z,B)}},j=()=>{if(!f.current)return;const[F,S]=Hi(y.current,f.current);if(F!==0||S!==0){const{transform:D,panBy:L}=a.getState();d.current.x=(d.current.x??0)-F/D[2],d.current.y=(d.current.y??0)-S/D[2],L({x:F,y:S})&&T(d.current)}m.current=requestAnimationFrame(j)},I=F=>{var R;const{nodeInternals:S,multiSelectionActive:D,nodesDraggable:L,unselectNodesAndEdges:V,onNodeDragStart:H,onSelectionDragStart:p}=a.getState();g.current=!0;const k=s?H:Wn(p);(!o||!i)&&!D&&s&&((R=S.get(s))!=null&&R.selected||V()),s&&i&&o&&hr({id:s,store:a,nodeRef:e});const N=M(F);if(d.current=N,u.current=Kf(S,L,N,s),k&&u.current){const[$,v]=Yn({nodeId:s,dragItems:u.current,nodeInternals:S});k(F.sourceEvent,$,v)}};if(t)E.on(".drag",null);else{const F=lu().on("start",S=>{const{domNode:D,nodeDragThreshold:L}=a.getState();L===0&&I(S),b.current=!1;const V=M(S);d.current=V,f.current=(D==null?void 0:D.getBoundingClientRect())||null,y.current=Be(S.sourceEvent,f.current)}).on("drag",S=>{var H,p;const D=M(S),{autoPanOnNodeDrag:L,nodeDragThreshold:V}=a.getState();if(S.sourceEvent.type==="touchmove"&&S.sourceEvent.touches.length>1&&(b.current=!0),!b.current){if(!_.current&&g.current&&L&&(_.current=!0,j()),!g.current){const k=D.xSnapped-(((H=d==null?void 0:d.current)==null?void 0:H.x)??0),N=D.ySnapped-(((p=d==null?void 0:d.current)==null?void 0:p.y)??0);Math.sqrt(k*k+N*N)>V&&I(S)}(d.current.x!==D.xSnapped||d.current.y!==D.ySnapped)&&u.current&&g.current&&(x.current=S.sourceEvent,y.current=Be(S.sourceEvent,f.current),T(D))}}).on("end",S=>{if(!(!g.current||b.current)&&(c(!1),_.current=!1,g.current=!1,cancelAnimationFrame(m.current),u.current)){const{updateNodePositions:D,nodeInternals:L,onNodeDragStop:V,onSelectionDragStop:H}=a.getState(),p=s?V:Wn(H);if(D(u.current,!1,!1),p){const[k,N]=Yn({nodeId:s,dragItems:u.current,nodeInternals:L});p(S.sourceEvent,k,N)}}}).filter(S=>{const D=S.target;return!S.button&&(!n||!vs(D,`.${n}`,e))&&(!r||vs(D,r,e))});return E.call(F),()=>{E.on(".drag",null)}}}},[e,t,n,r,i,a,s,o,M]),l}function vo(){const e=oe();return w.useCallback(n=>{const{nodeInternals:r,nodeExtent:s,updateNodePositions:i,getNodes:o,snapToGrid:a,snapGrid:l,onError:c,nodesDraggable:u}=e.getState(),d=o().filter(b=>b.selected&&(b.draggable||u&&typeof b.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(b=>{if(b.positionAbsolute){const M={x:b.positionAbsolute.x+x,y:b.positionAbsolute.y+_};a&&(M.x=l[0]*Math.round(M.x/l[0]),M.y=l[1]*Math.round(M.y/l[1]));const{positionAbsolute:E,position:T}=wo(b,M,r,s,void 0,c);b.position=T,b.positionAbsolute=E}return b});i(g,!0,!1)},[])}const xt={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:b,isSelectable:M,isConnectable:E,isFocusable:T,selectNodesOnDrag:j,sourcePosition:I,targetPosition:F,hidden:S,resizeObserver:D,dragHandle:L,zIndex:V,isParent:H,noDragClassName:p,noPanClassName:k,initialized:N,disableKeyboardA11y:R,ariaLabel:$,rfId:v,hasHandleBounds:A})=>{const O=oe(),z=w.useRef(null),B=w.useRef(null),P=w.useRef(I),G=w.useRef(F),X=w.useRef(r),Z=M||b||u||d||m||f,Q=vo(),U=At(n,O.getState,d),K=At(n,O.getState,m),ce=At(n,O.getState,f),ie=At(n,O.getState,y),he=At(n,O.getState,x),de=J=>{const{nodeDragThreshold:W}=O.getState();if(M&&(!j||!b||W>0)&&hr({id:n,store:O,nodeRef:z}),u){const me=O.getState().nodeInternals.get(n);me&&u(J,{...me})}},ne=J=>{if(!cr(J)&&!R)if(Yi.includes(J.key)&&M){const W=J.key==="Escape";hr({id:n,store:O,unselect:W,nodeRef:z})}else b&&c&&Object.prototype.hasOwnProperty.call(xt,J.key)&&(O.setState({ariaLiveMessage:`Moved selected node ${J.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~i}, y: ${~~o}`}),Q({x:xt[J.key].x,y:xt[J.key].y,isShiftPressed:J.shiftKey}))};w.useEffect(()=>()=>{B.current&&(D==null||D.unobserve(B.current),B.current=null)},[]),w.useEffect(()=>{if(z.current&&!S){const J=z.current;(!N||!A||B.current!==J)&&(B.current&&(D==null||D.unobserve(B.current)),D==null||D.observe(J),B.current=J)}},[S,N,A]),w.useEffect(()=>{const J=X.current!==r,W=P.current!==I,me=G.current!==F;z.current&&(J||W||me)&&(J&&(X.current=r),W&&(P.current=I),me&&(G.current=F),O.getState().updateNodeDimensions([{id:n,nodeElement:z.current,forceUpdate:!0}]))},[n,r,I,F]);const ge=bo({nodeRef:z,disabled:S||!b,noDragClassName:p,handleSelector:L,nodeId:n,isSelectable:M,selectNodesOnDrag:j});return S?null:C.createElement("div",{className:ue(["react-flow__node",`react-flow__node-${r}`,{[k]:b},g,{selected:c,selectable:M,parent:H,dragging:ge}]),ref:z,style:{zIndex:V,transform:`translate(${a}px,${l}px)`,pointerEvents:Z?"all":"none",visibility:N?"visible":"hidden",..._},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:U,onMouseMove:K,onMouseLeave:ce,onContextMenu:ie,onClick:de,onDoubleClick:he,onKeyDown:T?ne:void 0,tabIndex:T?0:void 0,role:T?"button":void 0,"aria-describedby":R?void 0:`${fo}-${v}`,"aria-label":$},C.createElement(ff,{value:n},C.createElement(e,{id:n,data:s,type:r,xPos:i,yPos:o,selected:c,isConnectable:E,sourcePosition:I,targetPosition:F,dragging:ge,dragHandle:L,zIndex:V})))};return t.displayName="NodeWrapper",w.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=oe(),{width:s,height:i,x:o,y:a,transformString:l,userSelectionActive:c}=ee(eh,le),u=vo(),d=w.useRef(null);if(w.useEffect(()=>{var y;n||(y=d.current)==null||y.focus({preventScroll:!0})},[n]),bo({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(xt,y.key)&&u({x:xt[y.key].x,y:xt[y.key].y,isShiftPressed:y.shiftKey})};return C.createElement("div",{className:ue(["react-flow__nodesselection","react-flow__container",t]),style:{transform:l}},C.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=w.memo(th);const rh=e=>e.nodesSelectionActive,_o=({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:b,elementsSelectable:M,zoomOnScroll:E,zoomOnPinch:T,panOnScroll:j,panOnScrollSpeed:I,panOnScrollMode:F,zoomOnDoubleClick:S,panOnDrag:D,defaultViewport:L,translateExtent:V,minZoom:H,maxZoom:p,preventScrolling:k,onSelectionContextMenu:N,noWheelClassName:R,noPanClassName:$,disableKeyboardA11y:v})=>{const A=ee(rh),O=Yt(d),z=Yt(g),B=z||D,P=z||j,G=O||m&&B!==!0;return Hf({deleteKeyCode:a,multiSelectionKeyCode:_}),C.createElement(Yf,{onMove:l,onMoveStart:c,onMoveEnd:u,onPaneContextMenu:i,elementsSelectable:M,zoomOnScroll:E,zoomOnPinch:T,panOnScroll:P,panOnScrollSpeed:I,panOnScrollMode:F,zoomOnDoubleClick:S,panOnDrag:!O&&B,defaultViewport:L,translateExtent:V,minZoom:H,maxZoom:p,zoomActivationKeyCode:b,preventScrolling:k,noWheelClassName:R,noPanClassName:$},C.createElement(yo,{onSelectionStart:y,onSelectionEnd:x,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:o,panOnDrag:B,isSelecting:!!G,selectionMode:f},e,A&&C.createElement(nh,{onSelectionContextMenu:N,noPanClassName:$,disableKeyboardA11y:v})))};_o.displayName="FlowRenderer";var sh=w.memo(_o);function ih(e){return ee(w.useCallback(n=>e?Qi(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||ao),default:It(e.default||fr),output:It(e.output||co),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}),Eo=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,updateNodeDimensions:i,onError:o}=ee(lh,le),a=ih(e.onlyRenderVisibleElements),l=w.useRef(),c=w.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 w.useEffect(()=>()=>{var u;(u=l==null?void 0:l.current)==null||u.disconnect()},[]),C.createElement("div",{className:"react-flow__nodes",style:Ir},a.map(u=>{var T,j,I;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,b=(g==null?void 0:g.x)??0,M=(g==null?void 0:g.y)??0,E=ah({x:b,y:M,width:u.width??0,height:u.height??0,origin:e.nodeOrigin});return C.createElement(m,{key:u.id,id:u.id,className:u.className,style:u.style,type:d,data:u.data,sourcePosition:u.sourcePosition||Y.Bottom,targetPosition:u.targetPosition||Y.Top,hidden:u.hidden,xPos:b,yPos:M,xPosOrigin:E.x,yPosOrigin:E.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:((T=u[te])==null?void 0:T.z)??0,isParent:!!((j=u[te])!=null&&j.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!u.width&&!!u.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:u.ariaLabel,hasHandleBounds:!!((I=u[te])!=null&&I.handleBounds)})}))};Eo.displayName="NodeRenderer";var ch=w.memo(Eo);const uh=(e,t,n)=>n===Y.Left?e-t:n===Y.Right?e+t:e,dh=(e,t,n)=>n===Y.Top?e-t:n===Y.Bottom?e+t:e,Es="react-flow__edgeupdater",Ns=({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:s,onMouseEnter:i,onMouseOut:o,type:a})=>C.createElement("circle",{onMouseDown:s,onMouseEnter:i,onMouseOut:o,className:ue([Es,`${Es}-${a}`]),cx:uh(t,r,e),cy:dh(n,r,e),r,stroke:"transparent",fill:"transparent"}),fh=()=>!0;var mt=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:b,sourceX:M,sourceY:E,targetX:T,targetY:j,sourcePosition:I,targetPosition:F,elementsSelectable:S,hidden:D,sourceHandleId:L,targetHandleId:V,onContextMenu:H,onMouseEnter:p,onMouseMove:k,onMouseLeave:N,reconnectRadius:R,onReconnect:$,onReconnectStart:v,onReconnectEnd:A,markerEnd:O,markerStart:z,rfId:B,ariaLabel:P,isFocusable:G,isReconnectable:X,pathOptions:Z,interactionWidth:Q,disableKeyboardA11y:U})=>{const K=w.useRef(null),[ce,ie]=w.useState(!1),[he,de]=w.useState(!1),ne=oe(),ge=w.useMemo(()=>`url('#${ur(z,B)}')`,[z,B]),J=w.useMemo(()=>`url('#${ur(O,B)}')`,[O,B]);if(D)return null;const W=fe=>{var je;const{edges:_e,addSelectedEdges:We,unselectNodesAndEdges:Ue,multiSelectionActive:Xe}=ne.getState(),Ie=_e.find(kt=>kt.id===n);Ie&&(S&&(ne.setState({nodesSelectionActive:!1}),Ie.selected&&Xe?(Ue({nodes:[],edges:[Ie]}),(je=K.current)==null||je.blur()):We([n])),o&&o(fe,Ie))},me=Mt(n,ne.getState,a),Me=Mt(n,ne.getState,H),Nt=Mt(n,ne.getState,p),ot=Mt(n,ne.getState,k),at=Mt(n,ne.getState,N),Ae=(fe,_e)=>{if(fe.button!==0)return;const{edges:We,isValidConnection:Ue}=ne.getState(),Xe=_e?b:g,Ie=(_e?V:L)||null,je=_e?"target":"source",kt=Ue||fh,Rn=_e,jt=We.find(qe=>qe.id===n);de(!0),v==null||v(fe,jt,je);const On=qe=>{de(!1),A==null||A(qe,jt,je)};ro({event:fe,handleId:Ie,nodeId:Xe,onConnect:qe=>$==null?void 0:$(jt,qe),isTarget:Rn,getState:ne.getState,setState:ne.setState,isValidConnection:kt,edgeUpdaterType:je,onReconnectEnd:On})},lt=fe=>Ae(fe,!0),Ge=fe=>Ae(fe,!1),Ye=()=>ie(!0),ct=()=>ie(!1),ut=!S&&!o,St=fe=>{var _e;if(!U&&Yi.includes(fe.key)&&S){const{unselectNodesAndEdges:We,addSelectedEdges:Ue,edges:Xe}=ne.getState();fe.key==="Escape"?((_e=K.current)==null||_e.blur(),We({edges:[Xe.find(je=>je.id===n)]})):Ue([n])}};return C.createElement("g",{className:ue(["react-flow__edge",`react-flow__edge-${s}`,r,{selected:l,animated:c,inactive:ut,updating:ce}]),onClick:W,onDoubleClick:me,onContextMenu:Me,onMouseEnter:Nt,onMouseMove:ot,onMouseLeave:at,onKeyDown:G?St:void 0,tabIndex:G?0:void 0,role:G?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":P===null?void 0:P||`Edge from ${g} to ${b}`,"aria-describedby":G?`${ho}-${B}`:void 0,ref:K},!he&&C.createElement(e,{id:n,source:g,target:b,selected:l,animated:c,label:u,labelStyle:d,labelShowBg:m,labelBgStyle:f,labelBgPadding:y,labelBgBorderRadius:x,data:i,style:_,sourceX:M,sourceY:E,targetX:T,targetY:j,sourcePosition:I,targetPosition:F,sourceHandleId:L,targetHandleId:V,markerStart:ge,markerEnd:J,pathOptions:Z,interactionWidth:Q}),X&&C.createElement(C.Fragment,null,(X==="source"||X===!0)&&C.createElement(Ns,{position:I,centerX:M,centerY:E,radius:R,onMouseDown:lt,onMouseEnter:Ye,onMouseOut:ct,type:"source"}),(X==="target"||X===!0)&&C.createElement(Ns,{position:F,centerX:T,centerY:j,radius:R,onMouseDown:Ge,onMouseEnter:Ye,onMouseOut:ct,type:"target"})))};return t.displayName="EdgeWrapper",w.memo(t)};function hh(e){const t={default:mt(e.default||bn),straight:mt(e.bezier||Cr),step:mt(e.step||jr),smoothstep:mt(e.step||$n),simplebezier:mt(e.simplebezier||kr)},n={},r=Object.keys(e).filter(s=>!["default","bezier"].includes(s)).reduce((s,i)=>(s[i]=mt(e[i]||bn),s),n);return{...t,...r}}function Ss(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 Y.Top:return{x:r+i/2,y:s};case Y.Right:return{x:r+i,y:s+o/2};case Y.Bottom:return{x:r+i/2,y:s+o};case Y.Left:return{x:r,y:s+o/2}}}function ks(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=Ss(n,e,t),a=Ss(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 js(e){var r,s,i,o,a;const t=((r=e==null?void 0:e[te])==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[te])==null?void 0:u.z)||0,((d=m==null?void 0:m[te])==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=ee(w.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})=>C.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})=>C.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),Cs={[xn.Arrow]:wh,[xn.ArrowClosed]:bh};function vh(e){const t=oe();return w.useMemo(()=>{var s,i;return Object.prototype.hasOwnProperty.call(Cs,e)?Cs[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?C.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"},C.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))},No=({defaultColor:e,rfId:t})=>{const n=ee(w.useCallback(Eh({defaultColor:e,rfId:t}),[e,t]),(r,s)=>!(r.length!==s.length||r.some((i,o)=>i.id!==s[o].id)));return C.createElement("defs",null,n.map(r=>C.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})))};No.displayName="MarkerDefinitions";var Nh=w.memo(No);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}),So=({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:b,edgesUpdatable:M,elementsSelectable:E,width:T,height:j,connectionMode:I,nodeInternals:F,onError:S}=ee(Sh,le),D=xh(t,F,n);return T?C.createElement(C.Fragment,null,D.map(({level:L,edges:V,isMaxLevel:H})=>C.createElement("svg",{key:L,style:{zIndex:L},width:T,height:j,className:"react-flow__edges react-flow__container"},H&&C.createElement(Nh,{defaultColor:e,rfId:r}),C.createElement("g",null,V.map(p=>{const[k,N,R]=js(F.get(p.source)),[$,v,A]=js(F.get(p.target));if(!R||!A)return null;let O=p.type||"default";s[O]||(S==null||S("011",Pe.error011(O)),O="default");const z=s[O]||s.default,B=I===rt.Strict?v.target:(v.target??[]).concat(v.source??[]),P=ks(N.source,p.sourceHandle),G=ks(B,p.targetHandle),X=(P==null?void 0:P.position)||Y.Bottom,Z=(G==null?void 0:G.position)||Y.Top,Q=!!(p.focusable||b&&typeof p.focusable>"u"),U=p.reconnectable||p.updatable,K=typeof m<"u"&&(U||M&&typeof U>"u");if(!P||!G)return S==null||S("008",Pe.error008(P,p)),null;const{sourceX:ce,sourceY:ie,targetX:he,targetY:de}=mh(k,P,X,$,G,Z);return C.createElement(z,{key:p.id,id:p.id,className:ue([p.className,i]),type:O,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:ce,sourceY:ie,targetX:he,targetY:de,sourcePosition:X,targetPosition:Z,elementsSelectable:E,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:Q,isReconnectable:K,pathOptions:"pathOptions"in p?p.pathOptions:void 0,interactionWidth:p.interactionWidth,disableKeyboardA11y:g})})))),_):null};So.displayName="EdgeRenderer";var kh=w.memo(So);const jh=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Ch({children:e}){const t=ee(jh);return C.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function $h(e){const t=An(),n=w.useRef(!1);w.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const Mh={[Y.Left]:Y.Right,[Y.Right]:Y.Left,[Y.Top]:Y.Bottom,[Y.Bottom]:Y.Top},ko=({nodeId:e,handleType:t,style:n,type:r=Ve.Bezier,CustomComponent:s,connectionStatus:i})=>{var j,I,F;const{fromNode:o,handleId:a,toX:l,toY:c,connectionMode:u}=ee(w.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]),le),d=(j=o==null?void 0:o[te])==null?void 0:j.handleBounds;let m=d==null?void 0:d[t];if(u===rt.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,_=(((I=o.positionAbsolute)==null?void 0:I.x)??0)+y,g=(((F=o.positionAbsolute)==null?void 0:F.y)??0)+x,b=f==null?void 0:f.position,M=b?Mh[b]:null;if(!b||!M)return null;if(s)return C.createElement(s,{connectionLineType:r,connectionLineStyle:n,fromNode:o,fromHandle:f,fromX:_,fromY:g,toX:l,toY:c,fromPosition:b,toPosition:M,connectionStatus:i});let E="";const T={sourceX:_,sourceY:g,sourcePosition:b,targetX:l,targetY:c,targetPosition:M};return r===Ve.Bezier?[E]=Zi(T):r===Ve.Step?[E]=wn({...T,borderRadius:0}):r===Ve.SmoothStep?[E]=wn(T):r===Ve.SimpleBezier?[E]=qi(T):E=`M${_},${g} ${l},${c}`,C.createElement("path",{d:E,fill:"none",className:"react-flow__connection-path",style:n})};ko.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}=ee(Ah,le);return!(s&&i&&a&&o)?null:C.createElement("svg",{style:e,width:a,height:l,className:"react-flow__edges react-flow__connectionline react-flow__container"},C.createElement("g",{className:ue(["react-flow__connection",c])},C.createElement(ko,{nodeId:s,handleType:i,style:t,type:n,CustomComponent:r,connectionStatus:c})))}function $s(e,t){return w.useRef(null),oe(),w.useMemo(()=>t(e),[e])}const jo=({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:b,connectionLineComponent:M,connectionLineContainerStyle:E,selectionKeyCode:T,selectionOnDrag:j,selectionMode:I,multiSelectionKeyCode:F,panActivationKeyCode:S,zoomActivationKeyCode:D,deleteKeyCode:L,onlyRenderVisibleElements:V,elementsSelectable:H,selectNodesOnDrag:p,defaultViewport:k,translateExtent:N,minZoom:R,maxZoom:$,preventScrolling:v,defaultMarkerColor:A,zoomOnScroll:O,zoomOnPinch:z,panOnScroll:B,panOnScrollSpeed:P,panOnScrollMode:G,zoomOnDoubleClick:X,panOnDrag:Z,onPaneClick:Q,onPaneMouseEnter:U,onPaneMouseMove:K,onPaneMouseLeave:ce,onPaneScroll:ie,onPaneContextMenu:he,onEdgeContextMenu:de,onEdgeMouseEnter:ne,onEdgeMouseMove:ge,onEdgeMouseLeave:J,onReconnect:W,onReconnectStart:me,onReconnectEnd:Me,reconnectRadius:Nt,noDragClassName:ot,noWheelClassName:at,noPanClassName:Ae,elevateEdgesOnSelect:lt,disableKeyboardA11y:Ge,nodeOrigin:Ye,nodeExtent:ct,rfId:ut})=>{const St=$s(e,oh),fe=$s(t,hh);return $h(i),C.createElement(sh,{onPaneClick:Q,onPaneMouseEnter:U,onPaneMouseMove:K,onPaneMouseLeave:ce,onPaneContextMenu:he,onPaneScroll:ie,deleteKeyCode:L,selectionKeyCode:T,selectionOnDrag:j,selectionMode:I,onSelectionStart:x,onSelectionEnd:_,multiSelectionKeyCode:F,panActivationKeyCode:S,zoomActivationKeyCode:D,elementsSelectable:H,onMove:n,onMoveStart:r,onMoveEnd:s,zoomOnScroll:O,zoomOnPinch:z,zoomOnDoubleClick:X,panOnScroll:B,panOnScrollSpeed:P,panOnScrollMode:G,panOnDrag:Z,defaultViewport:k,translateExtent:N,minZoom:R,maxZoom:$,onSelectionContextMenu:y,preventScrolling:v,noDragClassName:ot,noWheelClassName:at,noPanClassName:Ae,disableKeyboardA11y:Ge},C.createElement(Ch,null,C.createElement(kh,{edgeTypes:fe,onEdgeClick:a,onEdgeDoubleClick:c,onlyRenderVisibleElements:V,onEdgeContextMenu:de,onEdgeMouseEnter:ne,onEdgeMouseMove:ge,onEdgeMouseLeave:J,onReconnect:W,onReconnectStart:me,onReconnectEnd:Me,reconnectRadius:Nt,defaultMarkerColor:A,noPanClassName:Ae,elevateEdgesOnSelect:!!lt,disableKeyboardA11y:Ge,rfId:ut},C.createElement(Ih,{style:b,type:g,component:M,containerStyle:E})),C.createElement("div",{className:"react-flow__edgelabel-renderer"}),C.createElement(ch,{nodeTypes:St,onNodeClick:o,onNodeDoubleClick:l,onNodeMouseEnter:u,onNodeMouseMove:d,onNodeMouseLeave:m,onNodeContextMenu:f,selectNodesOnDrag:p,onlyRenderVisibleElements:V,noPanClassName:Ae,noDragClassName:ot,disableKeyboardA11y:Ge,nodeOrigin:Ye,nodeExtent:ct,rfId:ut})))};jo.displayName="GraphView";var Th=w.memo(jo);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:rt.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,[te]:{...g[te],handleBounds:void 0}});else if(g){const b=Nr(_.nodeElement);!!(b.width&&b.height&&(g.width!==b.width||g.height!==b.height||_.forceUpdate))&&(s.set(g.id,{...g,[te]:{...g[te],handleBounds:{source:_s(".source",_.nodeElement,m,c),target:_s(".target",_.nodeElement,m,c)}},...b}),x.push({id:g.id,type:"dimensions",dimensions:b}))}return x},[]);po(s,c);const y=o||i&&!o&&go(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=>He(l,!0)):(o=pt(i(),n),a=pt(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=>He(l,!0)):(o=pt(s,n),a=pt(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,He(u.id,!1))),c=a.map(u=>He(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=>He(a.id,!1)),o=n.filter(a=>a.selected).map(a=>He(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),Co=({children:e})=>{const t=w.useRef(null);return t.current||(t.current=Rh()),C.createElement(Qd,{value:t.current},e)};Co.displayName="ReactFlowProvider";const $o=({children:e})=>w.useContext(Cn)?C.createElement(C.Fragment,null,e):C.createElement(Co,null,e);$o.displayName="ReactFlowWrapper";const Oh={input:ao,default:fr,output:co,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},Fh={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},Mo=w.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:b,onNodeMouseMove:M,onNodeMouseLeave:E,onNodeContextMenu:T,onNodeDoubleClick:j,onNodeDragStart:I,onNodeDrag:F,onNodeDragStop:S,onNodesDelete:D,onEdgesDelete:L,onSelectionChange:V,onSelectionDragStart:H,onSelectionDrag:p,onSelectionDragStop:k,onSelectionContextMenu:N,onSelectionStart:R,onSelectionEnd:$,connectionMode:v=rt.Strict,connectionLineType:A=Ve.Bezier,connectionLineStyle:O,connectionLineComponent:z,connectionLineContainerStyle:B,deleteKeyCode:P="Backspace",selectionKeyCode:G="Shift",selectionOnDrag:X=!1,selectionMode:Z=Gt.Full,panActivationKeyCode:Q="Space",multiSelectionKeyCode:U=yn()?"Meta":"Control",zoomActivationKeyCode:K=yn()?"Meta":"Control",snapToGrid:ce=!1,snapGrid:ie=Ph,onlyRenderVisibleElements:he=!1,selectNodesOnDrag:de=!0,nodesDraggable:ne,nodesConnectable:ge,nodesFocusable:J,nodeOrigin:W=Lh,edgesFocusable:me,edgesUpdatable:Me,elementsSelectable:Nt,defaultViewport:ot=zh,minZoom:at=.5,maxZoom:Ae=2,translateExtent:lt=mr,preventScrolling:Ge=!0,nodeExtent:Ye,defaultMarkerColor:ct="#b1b1b7",zoomOnScroll:ut=!0,zoomOnPinch:St=!0,panOnScroll:fe=!1,panOnScrollSpeed:_e=.5,panOnScrollMode:We=Je.Free,zoomOnDoubleClick:Ue=!0,panOnDrag:Xe=!0,onPaneClick:Ie,onPaneMouseEnter:je,onPaneMouseMove:kt,onPaneMouseLeave:Rn,onPaneScroll:jt,onPaneContextMenu:On,children:Lr,onEdgeContextMenu:qe,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:Pr="nopan",fitView:Ma=!1,fitViewOptions:Aa,connectOnClick:Ia=!0,attributionPosition:Ta,proOptions:Ra,defaultEdgeOptions:Oa,elevateNodesOnSelect:Da=!0,elevateEdgesOnSelect:La=!1,disableKeyboardA11y:zr=!1,autoPanOnConnect:Pa=!0,autoPanOnNodeDrag:za=!0,connectionRadius:Fa=20,isValidConnection:Ha,onError:Va,style:Ba,id:Fr,nodeDragThreshold:Ga,...Ya},Wa)=>{const Dn=Fr||"1";return C.createElement("div",{...Ya,style:{...Ba,...Fh},ref:Wa,className:ue(["react-flow",s]),"data-testid":"rf__wrapper",id:Fr},C.createElement($o,null,C.createElement(Th,{onInit:c,onMove:u,onMoveStart:d,onMoveEnd:m,onNodeClick:a,onEdgeClick:l,onNodeMouseEnter:b,onNodeMouseMove:M,onNodeMouseLeave:E,onNodeContextMenu:T,onNodeDoubleClick:j,nodeTypes:i,edgeTypes:o,connectionLineType:A,connectionLineStyle:O,connectionLineComponent:z,connectionLineContainerStyle:B,selectionKeyCode:G,selectionOnDrag:X,selectionMode:Z,deleteKeyCode:P,multiSelectionKeyCode:U,panActivationKeyCode:Q,zoomActivationKeyCode:K,onlyRenderVisibleElements:he,selectNodesOnDrag:de,defaultViewport:ot,translateExtent:lt,minZoom:at,maxZoom:Ae,preventScrolling:Ge,zoomOnScroll:ut,zoomOnPinch:St,zoomOnDoubleClick:Ue,panOnScroll:fe,panOnScrollSpeed:_e,panOnScrollMode:We,panOnDrag:Xe,onPaneClick:Ie,onPaneMouseEnter:je,onPaneMouseMove:kt,onPaneMouseLeave:Rn,onPaneScroll:jt,onPaneContextMenu:On,onSelectionContextMenu:N,onSelectionStart:R,onSelectionEnd:$,onEdgeContextMenu:qe,onEdgeDoubleClick:ma,onEdgeMouseEnter:pa,onEdgeMouseMove:ga,onEdgeMouseLeave:ya,onReconnect:va??xa,onReconnectStart:_a??wa,onReconnectEnd:Ea??ba,reconnectRadius:Na??Sa,defaultMarkerColor:ct,noDragClassName:Ca,noWheelClassName:$a,noPanClassName:Pr,elevateEdgesOnSelect:La,rfId:Dn,disableKeyboardA11y:zr,nodeOrigin:W,nodeExtent:Ye}),C.createElement($f,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:f,onConnectStart:y,onConnectEnd:x,onClickConnectStart:_,onClickConnectEnd:g,nodesDraggable:ne,nodesConnectable:ge,nodesFocusable:J,edgesFocusable:me,edgesUpdatable:Me,elementsSelectable:Nt,elevateNodesOnSelect:Da,minZoom:at,maxZoom:Ae,nodeExtent:Ye,onNodesChange:ka,onEdgesChange:ja,snapToGrid:ce,snapGrid:ie,connectionMode:v,translateExtent:lt,connectOnClick:Ia,defaultEdgeOptions:Oa,fitView:Ma,fitViewOptions:Aa,onNodesDelete:D,onEdgesDelete:L,onNodeDragStart:I,onNodeDrag:F,onNodeDragStop:S,onSelectionDrag:p,onSelectionDragStart:H,onSelectionDragStop:k,noPanClassName:Pr,nodeOrigin:W,rfId:Dn,autoPanOnConnect:Pa,autoPanOnNodeDrag:za,onError:Va,connectionRadius:Fa,isValidConnection:Ha,nodeDragThreshold:Ga}),C.createElement(jf,{onSelectionChange:V}),Lr,C.createElement(ef,{proOptions:Ra,position:Ta}),C.createElement(Rf,{rfId:Dn,disableKeyboardA11y:zr})))});Mo.displayName="ReactFlow";const Ao=({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 C.createElement("rect",{className:ue(["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})};Ao.displayName="MiniMapNode";var Hh=w.memo(Ao);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=Hh,onClick:o}){const a=ee(Bh,le),l=ee(Vh),c=Un(t),u=Un(e),d=Un(n),m=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return C.createElement(C.Fragment,null,a.map(f=>{const{x:y,y:x}=tt(f,l).positionAbsolute;return C.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=w.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 Io({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:b=10,offsetScale:M=5}){const E=oe(),T=w.useRef(null),{boundingRect:j,viewBB:I,rfId:F}=ee(Xh,le),S=(e==null?void 0:e.width)??Wh,D=(e==null?void 0:e.height)??Uh,L=j.width/S,V=j.height/D,H=Math.max(L,V),p=H*S,k=H*D,N=M*H,R=j.x-(p-j.width)/2-N,$=j.y-(k-j.height)/2-N,v=p+N*2,A=k+N*2,O=`${qh}-${F}`,z=w.useRef(0);z.current=H,w.useEffect(()=>{if(T.current){const G=xe(T.current),X=U=>{const{transform:K,d3Selection:ce,d3Zoom:ie}=E.getState();if(U.sourceEvent.type!=="wheel"||!ce||!ie)return;const he=-U.sourceEvent.deltaY*(U.sourceEvent.deltaMode===1?.05:U.sourceEvent.deltaMode?1:.002)*b,de=K[2]*Math.pow(2,he);ie.scaleTo(ce,de)},Z=U=>{const{transform:K,d3Selection:ce,d3Zoom:ie,translateExtent:he,width:de,height:ne}=E.getState();if(U.sourceEvent.type!=="mousemove"||!ce||!ie)return;const ge=z.current*Math.max(1,K[2])*(g?-1:1),J={x:K[0]-U.sourceEvent.movementX*ge,y:K[1]-U.sourceEvent.movementY*ge},W=[[0,0],[de,ne]],me=De.translate(J.x,J.y).scale(K[2]),Me=ie.constrain()(me,W,he);ie.transform(ce,Me)},Q=zi().on("zoom",y?Z:null).on("zoom.wheel",x?X:null);return G.call(Q),()=>{G.on("zoom",null)}}},[y,x,g,b]);const B=m?G=>{const X=Ee(G);m(G,{x:X[0],y:X[1]})}:void 0,P=f?(G,X)=>{const Z=E.getState().nodeInternals.get(X);f(G,Z)}:void 0;return C.createElement(Er,{position:d,style:e,className:ue(["react-flow__minimap",t]),"data-testid":"rf__minimap"},C.createElement("svg",{width:S,height:D,viewBox:`${R} ${$} ${v} ${A}`,role:"img","aria-labelledby":O,ref:T,onClick:B},_&&C.createElement("title",{id:O},_),C.createElement(Yh,{onClick:P,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:s,nodeStrokeWidth:o,nodeComponent:a}),C.createElement("path",{className:"react-flow__minimap-mask",d:`M${R-N},${$-N}h${v+N*2}v${A+N*2}h${-v-N*2}z - M${I.x},${I.y}h${I.width}v${I.height}h${-I.width}z`,fill:l,fillRule:"evenodd",stroke:c,strokeWidth:u,pointerEvents:"none"})))}Io.displayName="MiniMap";var Zh=w.memo(Io);function Kh(){return C.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},C.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function Qh(){return C.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},C.createElement("path",{d:"M0 0h32v4.2H0z"}))}function Jh(){return C.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},C.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 C.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},C.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 C.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},C.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})=>C.createElement("button",{type:"button",className:ue(["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}),To=({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=oe(),[f,y]=w.useState(!1),{isInteractive:x,minZoomReached:_,maxZoomReached:g}=ee(nm,le),{zoomIn:b,zoomOut:M,fitView:E}=An();if(w.useEffect(()=>{y(!0)},[]),!f)return null;const T=()=>{b(),i==null||i()},j=()=>{M(),o==null||o()},I=()=>{E(s),a==null||a()},F=()=>{m.setState({nodesDraggable:!x,nodesConnectable:!x,elementsSelectable:!x}),l==null||l(!x)};return C.createElement(Er,{className:ue(["react-flow__controls",c]),position:d,style:e,"data-testid":"rf__controls"},t&&C.createElement(C.Fragment,null,C.createElement(Ot,{onClick:T,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:g},C.createElement(Kh,null)),C.createElement(Ot,{onClick:j,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:_},C.createElement(Qh,null))),n&&C.createElement(Ot,{className:"react-flow__controls-fitview",onClick:I,title:"fit view","aria-label":"fit view"},C.createElement(Jh,null)),r&&C.createElement(Ot,{className:"react-flow__controls-interactive",onClick:F,title:"toggle interactivity","aria-label":"toggle interactivity"},x?C.createElement(tm,null):C.createElement(em,null)),u)};To.displayName="Controls";var rm=w.memo(To),be;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(be||(be={}));function sm({color:e,dimensions:t,lineWidth:n}){return C.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 C.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 Ro({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=w.useRef(null),{transform:u,patternId:d}=ee(lm,le),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],b=f*u[2],M=x?[b,b]:g,E=y?[b/i,b/i]:[M[0]/i,M[1]/i];return C.createElement("svg",{className:ue(["react-flow__background",l]),style:{...a,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:c,"data-testid":"rf__background"},C.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(-${E[0]},-${E[1]})`},y?C.createElement(im,{color:m,radius:b/i}):C.createElement(sm,{dimensions:M,color:m,lineWidth:s})),C.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${d+e})`}))}Ro.displayName="Background";var cm=w.memo(Ro);const Oo=(()=>{const e=window.location.pathname.match(/^(\/view\/[^/]+)(?:\/|$)/);return e?e[1]:""})();function Do(e){return Oo+e}async function ae(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 st(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);re(this,"status");this.status=r}}const Ky=e=>ae(e?`/api/model?subject_area=${encodeURIComponent(e)}`:"/api/model"),Qy=()=>ae("/api/diagnostics"),Po=(e,t)=>ae(`/api/ontology/search?q=${encodeURIComponent(e)}`+(t?`&within=${encodeURIComponent(t)}`:"")),zo=()=>ae("/api/ontology/ontologies"),um=e=>ae(`/api/ontology/term?ref=${encodeURIComponent(e)}`),dm=()=>ae("/api/ontology/stack"),fm=()=>ae("/api/ontology/coverage"),Jy=(e,t,n)=>st("/api/command",{op:e,payload:t,fingerprint:n}),hm=()=>ae("/api/git/status"),mm=()=>ae("/api/git/diff"),pm=e=>st("/api/git/commit",{message:e}),gm=()=>st("/api/git/discard",{}),ym=()=>ae("/api/decisions"),Ms=(e,t)=>st(`/api/decisions/${e}/verdict`,{verdict:t}),ex=(e={})=>{const t=new URLSearchParams;return e.subject_area&&t.set("subject_area",e.subject_area),e.q&&t.set("q",e.q),ae(`/api/glossary/terms?${t.toString()}`)},tx=()=>ae("/api/glossary/config"),nx=e=>st("/api/git/propose",e),rx=(e="HEAD")=>ae(`/api/git/diff/model?base=${encodeURIComponent(e)}`),sx=(e="HEAD")=>ae(`/api/git/classify?base=${encodeURIComponent(e)}`),ix=e=>st("/api/git/classify",{changes:e}),ox=e=>ae(`/api/git/conflicts?base=${encodeURIComponent(e)}`),ax=(e="")=>ae(`/api/git/context?user=${encodeURIComponent(e)}`),lx=(e="")=>ae(`/api/git/proposals?user=${encodeURIComponent(e)}`),cx=(e,t,n)=>fetch(`${Oo}/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()}),ux=()=>ae("/api/glossary/subject-areas"),dx=e=>ae(`/api/glossary/subject-area/${e}`),fx=(e,t)=>st(`/api/glossary/subject-area/${e}/expand`,t),As={business_key:"🔑",surrogate_key:"#",measure:"Σ",attribute:""};function Is(e){return e??""}const xm=w.memo(function({data:t,selected:n}){var u;const{entity:r,color:s,dimmed:i,highlighted:o,showTypes:a}=t,l=r.attributes.filter(d=>d.role==="business_key"),c=r.attributes.filter(d=>d.role!=="business_key");return h.jsxs("div",{className:"entity-node"+(n?" selected":"")+(i?" dimmed":"")+(o?" highlighted":""),style:{borderTopColor:s},children:[h.jsx(Et,{type:"target",position:Y.Left,className:"port"}),h.jsx(Et,{type:"source",position:Y.Right,className:"port"}),h.jsxs("div",{className:"entity-header",children:[h.jsx("span",{className:"entity-name",title:((u=r.conceptual)==null?void 0:u.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 f;const d=(((f=r.conceptual)==null?void 0:f.ontology_refs)??[]).filter(y=>y.uri);if(d.length===0)return null;const m=d.map(y=>y.uri).join(` -`);return h.jsxs("span",{className:"badge ontology",title:m,children:["⚙",d.length>1?` ${d.length}`:""]})})()]})]}),l.length>0&&h.jsx("div",{className:"attr-section keys",children:l.map(d=>h.jsxs("div",{className:"attr-row",children:[h.jsx("span",{className:"attr-icon",children:As[d.role]}),h.jsx("span",{className:"attr-name pk",children:d.name}),a&&h.jsx("span",{className:"attr-type",children:Is(d.domain)}),!d.nullable&&h.jsx("span",{className:"attr-notnull",title:"not null",children:"●"})]},d.id))}),h.jsxs("div",{className:"attr-section",children:[c.map(d=>h.jsxs("div",{className:"attr-row",children:[h.jsx("span",{className:"attr-icon",children:As[d.role]}),h.jsx("span",{className:"attr-name",children:d.name}),a&&h.jsx("span",{className:"attr-type",children:Is(d.domain)}),!d.nullable&&h.jsx("span",{className:"attr-notnull",title:"not null",children:"●"})]},d.id)),r.attributes.length===0&&h.jsx("div",{className:"attr-row empty",children:"no attributes"})]})]})}),wm=["string","integer","bigint","decimal","boolean","date","timestamp"];function bm({entity:e,doc:t,caps:n,exec:r,onClose:s,onFocusEntity:i,onAlign:o,onEditMapping:a}){var m,f,y,x,_,g,b,M,E,T,j,I,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 D;return((D=t.entities.find(L=>L.id===S))==null?void 0:D.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(_m,{entity:e,doc:t,readOnly:l,exec:r}),h.jsx(Nm,{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(vm,{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)||((b=e.term_map)==null?void 0:b.class_iri))&&h.jsx("button",{className:"mini-btn danger",onClick:()=>r("clear_term_map",{id:e.id}),children:"Clear"})]})]}),(M=e.term_map)!=null&&M.subject_template||(E=e.term_map)!=null&&E.class_iri?h.jsxs(h.Fragment,{children:[((T=e.term_map)==null?void 0:T.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})]}),((j=e.term_map)==null?void 0:j.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:((I=c==null?void 0:c.stewardship)==null?void 0:I.owner)??"",placeholder:"—",readOnly:l,onCommit:S=>{var D;return r("set_stewardship",{id:e.id,owner:S,steward:((D=c==null?void 0:c.stewardship)==null?void 0:D.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 D;return r("set_stewardship",{id:e.id,owner:((D=c==null?void 0:c.stewardship)==null?void 0:D.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(km,{a:S,entity:e,doc:t,readOnly:l,exec:r},S.id))})}),!l&&h.jsx(jm,{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 D=S.members.map(L=>{var V;return((V=e.attributes.find(H=>H.id===L))==null?void 0:V.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:D})]},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,D])=>h.jsxs("tr",{className:"udp-row",children:[h.jsx("td",{className:"udp-key",children:S}),h.jsx("td",{className:"udp-val",children:String(D)})]},S))})})]}),u.length>0&&h.jsxs("section",{children:[h.jsxs("h3",{children:["Relationships (",u.length,")"]}),u.map(S=>{const D=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(D),children:[h.jsx("span",{className:"rel-card",children:Cm(S,e.id)}),d(D)]}),!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 vm({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]=w.useState(e);w.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 _m({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 Em=["","scd2","hub","link","satellite","bridge"];function Nm({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:Em.map(r=>h.jsx("option",{value:r,children:r||"no pattern"},r))})}const Sm=["attribute","business_key","measure","surrogate_key"];function km({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([...wm,...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:Sm.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 jm({entity:e,exec:t}){const[n,r]=w.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 Cm(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 $m="\0",Ze="\0",Ts="";let Mm=class{constructor(t){re(this,"_isDirected",!0);re(this,"_isMultigraph",!1);re(this,"_isCompound",!1);re(this,"_label");re(this,"_defaultNodeLabelFn",()=>{});re(this,"_defaultEdgeLabelFn",()=>{});re(this,"_nodes",{});re(this,"_in",{});re(this,"_preds",{});re(this,"_out",{});re(this,"_sucs",{});re(this,"_edgeObjs",{});re(this,"_edgeLabels",{});re(this,"_nodeCount",0);re(this,"_edgeCount",0);re(this,"_parent");re(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[Ze]={})}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]=Ze,this._children[t]={},this._children[Ze][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=Ze;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!==Ze)return n}}children(t=Ze){if(this._isCompound){var n=this._children[t];if(n)return Object.keys(n)}else{if(t===Ze)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=Am(this._isDirected,t,n,r);return t=l.v,n=l.w,Object.freeze(l),this._edgeObjs[a]=l,Rs(this._preds[n],t),Rs(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],Os(this._preds[n],t),Os(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 Rs(e,t){e[t]?e[t]++:e[t]=1}function Os(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+Ts+i+Ts+(r===void 0?$m:r)}function Am(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 Tr=Mm,Im="2.2.4",Tm={Graph:Tr,version:Im},Rm=Tr,Om={write:Dm,read:zm};function Dm(e){var t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:Lm(e),edges:Pm(e)};return e.graph()!==void 0&&(t.value=structuredClone(e.graph())),t}function Lm(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 Pm(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 zm(e){var t=new Rm(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 Fm=Hm;function Hm(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 Vm=class{constructor(){re(this,"_arr",[]);re(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 Ym(e,t,n,r){return Wm(e,String(t),n||Gm,r||function(s){return e.outEdges(s)})}function Wm(e,t,n,r){var s={},i=new Bm,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 Um=Ho,Xm=qm;function qm(e,t,n){return e.nodes().reduce(function(r,s){return r[s]=Um(e,s,t,n),r},{})}var Vo=Zm;function Zm(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 Km=Vo,Qm=Jm;function Jm(e){return Km(e).filter(function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}var ep=np,tp=()=>1;function np(e,t,n){return rp(e,t||tp,n||function(r){return e.outEdges(r)})}function rp(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"?ap:lp,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 ap(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 lp(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 cp=Yo,up=dp;function dp(e,t){return cp(e,t,"post")}var fp=Yo,hp=mp;function mp(e,t){return fp(e,t,"pre")}var pp=Tr,gp=Fo,yp=xp;function xp(e,t){var n=new pp,r={},s=new gp,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 wp={components:Fm,dijkstra:Ho,dijkstraAll:Xm,findCycles:Qm,floydWarshall:ep,isAcyclic:sp,postorder:up,preorder:hp,prim:yp,tarjan:Vo,topsort:Go},Ls=Tm,ke={Graph:Ls.Graph,json:Om,alg:wp,version:Ls.version};let bp=class{constructor(){let t={};t._next=t._prev=t,this._sentinel=t}dequeue(){let t=this._sentinel,n=t._prev;if(n!==t)return Ps(n),n}enqueue(t){let n=this._sentinel;t._prev&&t._next&&Ps(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,vp)),r=r._prev;return"["+t.join(", ")+"]"}};function Ps(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function vp(e,t){if(e!=="_next"&&e!=="_prev")return t}var _p=bp;let Ep=ke.Graph,Np=_p;var Sp=jp;let kp=()=>1;function jp(e,t){if(e.nodeCount()<=1)return[];let n=$p(e,t||kp);return Cp(n.graph,n.buckets,n.zeroIdx).flatMap(s=>e.outEdges(s.v,s.w))}function Cp(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 $p(e,t){let n=new Ep,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=Mp(s+r+3).map(()=>new Np),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 Mp(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 Ip(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 Tp(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 Rr(e.nodes(),t)}function Rp(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 Rr(e.nodes(),t)}function Op(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 Dp(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 Lp(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 Pp(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 zp(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 Fp(e,t=qo){const n=[];for(let r=0;rqo){const n=Fp(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 Hp(e,t){let n={lhs:[],rhs:[]};return e.forEach(r=>{t(r)?n.lhs.push(r):n.rhs.push(r)}),n}function Vp(e,t){let n=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-n)+"ms")}}function Bp(e,t){return t()}let Gp=0;function Ko(e){var t=++Gp;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 Rr(e,t){return e.reduce((n,r,s)=>(n[r]=t[s],n),{})}let Up=Sp,Xp=se.uniqueId;var qp={run:Zp,undo:Qp};function Zp(e){(e.graph().acyclicer==="greedy"?Up(e,n(e)):Kp(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,Xp("rev"))});function n(r){return s=>r.edge(s).weight}}function Kp(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 Qp(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 Jp=se;var eg={run:tg,undo:rg};function tg(e){e.graph().dummyChains=[],e.edges().forEach(t=>ng(e,t))}function ng(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:sg}=se;var Tn={longestPath:ig,slack:og};function ig(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=sg(Math.min,i);return o===Number.POSITIVE_INFINITY&&(o=0),s.rank=o}e.sources().forEach(n)}function og(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var ag=ke.Graph,vn=Tn.slack,Jo=lg;function lg(e){var t=new ag({directed:!1}),n=e.nodes()[0],r=e.nodeCount();t.setNode(n,{});for(var s,i;cg(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 ug(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 fg=Jo,zs=Tn.slack,hg=Tn.longestPath,mg=ke.alg.preorder,pg=ke.alg.postorder,gg=se.simplify,yg=it;it.initLowLimValues=Dr;it.initCutValues=Or;it.calcCutValue=ea;it.leaveEdge=na;it.enterEdge=ra;it.exchangeEdges=sa;function it(e){e=gg(e),hg(e);var t=fg(e);Dr(t),Or(t,e);for(var n,r;n=na(t);)r=ra(t,e,n),sa(t,e,n,r)}function Or(e,t){var n=pg(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(r=>xg(e,t,r))}function xg(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,bg(e,n,u)){var f=e.edge(n,u).cutvalue;a+=d?-f:f}}}),a}function Dr(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)=>zs(t,d)!t.node(s).parent),r=mg(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 bg(e,t,n){return e.hasEdge(t,n)}function Fs(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var vg=Tn,ia=vg.longestPath,_g=Jo,Eg=yg,Ng=Sg;function Sg(e){var t=e.graph().ranker;if(t instanceof Function)return t(e);switch(e.graph().ranker){case"network-simplex":Hs(e);break;case"tight-tree":jg(e);break;case"longest-path":kg(e);break;case"none":break;default:Hs(e)}}var kg=ia;function jg(e){ia(e),_g(e)}function Hs(e){Eg(e)}var Cg=$g;function $g(e){let t=Ag(e);e.graph().dummyChains.forEach(n=>{let r=e.node(n),s=r.edgeObj,i=Mg(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 Ag(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=se;var Ig={run:Tg,cleanup:Dg};function Tg(e){let t=_n.addDummyNode(e,"root",{},"_root"),n=Rg(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=Og(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 Rg(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 Og(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function Dg(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 Lg=se;var Pg=zg;function zg(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;iBs(e.node(t))),e.edges().forEach(t=>Bs(e.edge(t)))}function Bs(e){let t=e.width;e.width=e.height,e.height=t}function Bg(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 Gg(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 Gs=se;var Yg=Wg;function Wg(e){let t={},n=e.nodes().filter(l=>!e.children(l).length),r=n.map(l=>e.node(l).rank),s=Gs.applyWithChunking(Math.max,r),i=Gs.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 Ug=se.zipObject;var Xg=qg;function qg(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 Kg=Qg;function Qg(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 Jg=se;var e0=t0;function t0(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 n0(r)}function n0(e){let t=[];function n(s){return i=>{i.merged||(i.barycenter===void 0||s.barycenter===void 0||i.barycenter>=s.barycenter)&&r0(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=>Jg.pick(s,["vs","i","barycenter","weight"]))}function r0(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 s0=se;var i0=o0;function o0(e,t){let n=s0.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(a0(!!t)),l=Ys(i,s,l),r.forEach(u=>{l+=u.vs.length,i.push(u.vs),o+=u.barycenter*u.weight,a+=u.weight,l=Ys(i,s,l)});let c={vs:i.flat(!0)};return a&&(c.barycenter=o/a,c.weight=a),c}function Ys(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 a0(e){return(t,n)=>t.barycentern.barycenter?1:e?n.i-t.i:t.i-n.i}let l0=Kg,c0=e0,u0=i0;var d0=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=l0(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")&&h0(m,f)}});let u=c0(c,n);f0(u,l);let d=u0(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 f0(e,t){e.forEach(n=>{n.vs=n.vs.flatMap(r=>t[r]?t[r].vs:r)})}function h0(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 m0=ke.Graph,p0=se;var g0=y0;function y0(e,t,n,r){r||(r=e.nodes());let s=x0(e),i=new m0({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 x0(e){for(var t;e.hasNode(t=p0.uniqueId("_root")););return t}var w0=b0;function b0(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 v0=Yg,_0=Xg,E0=d0,N0=g0,S0=w0,k0=ke.Graph,on=se;var j0=ca;function ca(e,t){if(t&&typeof t.customOrder=="function"){t.customOrder(e,ca);return}let n=on.maxRank(e),r=Ws(e,on.range(1,n+1),"inEdges"),s=Ws(e,on.range(n-1,-1,-1),"outEdges"),i=v0(e);if(Us(e,i),t&&t.disableOptimalOrderHeuristic)return;let o=Number.POSITIVE_INFINITY,a;for(let l=0,c=0;c<4;++l,++c){C0(l%2?r:s,l%4>=2),i=on.buildLayerMatrix(e);let u=_0(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 N0(e,i,n,r.get(i)||[])})}function C0(e,t){let n=new k0;e.forEach(function(r){let s=r.graph().root,i=E0(r,s,n,t);i.vs.forEach((o,a)=>r.node(o).order=a),S0(r,n,i.vs)})}function Us(e,t){Object.values(t).forEach(n=>n.forEach((r,s)=>e.node(r).order=s))}let $0=ke.Graph,Re=se;var M0={positionX:H0};function A0(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=T0(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 T0(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 R0(e,t,n){if(t>n){let r=t;t=n,n=r}return!!e[t]&&Object.hasOwn(e[t],n)}function O0(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 L0(e,t,n,r){let s=new $0,i=e.graph(),o=V0(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 P0(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=B0(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 F0(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 H0(e){let t=Re.buildLayerMatrix(e),n=Object.assign(A0(e,t),I0(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=O0(e,s,n,l),u=D0(e,s,c.root,c.align,a==="r");a==="r"&&(u=Re.mapValues(u,d=>-d)),r[o+a]=u})});let i=P0(e,r);return z0(r,i),F0(r,e.graph().align)}function V0(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 B0(e,t){return e.node(t).width}let da=se,G0=M0.positionX;var Y0=W0;function W0(e){e=da.asNonCompoundGraph(e),U0(e),Object.entries(G0(e)).forEach(([t,n])=>e.node(t).x=n)}function U0(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 Xs=qp,qs=eg,X0=Ng,q0=se.normalizeRanks,Z0=Cg,K0=se.removeEmptyRanks,Zs=Ig,Q0=Pg,Ks=Fg,J0=j0,ey=Y0,ve=se,ty=ke.Graph;var ny=ry;function ry(e,t){let n=t&&t.debugTiming?ve.time:ve.notime;n("layout",()=>{let r=n(" buildLayoutGraph",()=>hy(e));n(" runLayout",()=>sy(r,n,t)),n(" updateInputGraph",()=>iy(e,r))})}function sy(e,t,n){t(" makeSpaceForEdgeLabels",()=>my(e)),t(" removeSelfEdges",()=>Ey(e)),t(" acyclic",()=>Xs.run(e)),t(" nestingGraph.run",()=>Zs.run(e)),t(" rank",()=>X0(ve.asNonCompoundGraph(e))),t(" injectEdgeLabelProxies",()=>py(e)),t(" removeEmptyRanks",()=>K0(e)),t(" nestingGraph.cleanup",()=>Zs.cleanup(e)),t(" normalizeRanks",()=>q0(e)),t(" assignRankMinMax",()=>gy(e)),t(" removeEdgeLabelProxies",()=>yy(e)),t(" normalize.run",()=>qs.run(e)),t(" parentDummyChains",()=>Z0(e)),t(" addBorderSegments",()=>Q0(e)),t(" order",()=>J0(e,n)),t(" insertSelfEdges",()=>Ny(e)),t(" adjustCoordinateSystem",()=>Ks.adjust(e)),t(" position",()=>ey(e)),t(" positionSelfEdges",()=>Sy(e)),t(" removeBorderNodes",()=>_y(e)),t(" normalize.undo",()=>qs.undo(e)),t(" fixupEdgeLabelCoords",()=>by(e)),t(" undoCoordinateSystem",()=>Ks.undo(e)),t(" translateGraph",()=>xy(e)),t(" assignNodeIntersects",()=>wy(e)),t(" reversePoints",()=>vy(e)),t(" acyclic.undo",()=>Xs.undo(e))}function iy(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 oy=["nodesep","edgesep","ranksep","marginx","marginy"],ay={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},ly=["acyclicer","ranker","rankdir","align"],cy=["width","height","rank"],Qs={width:0,height:0},uy=["minlen","weight","width","height","labeloffset"],dy={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},fy=["labelpos"];function hy(e){let t=new ty({multigraph:!0,compound:!0}),n=Jn(e.graph());return t.setGraph(Object.assign({},ay,Qn(n,oy),ve.pick(n,ly))),e.nodes().forEach(r=>{let s=Jn(e.node(r));const i=Qn(s,cy);Object.keys(Qs).forEach(o=>{i[o]===void 0&&(i[o]=Qs[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({},dy,Qn(s,uy),ve.pick(s,fy)))}),t}function my(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 py(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 gy(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 yy(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 xy(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 wy(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 by(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 vy(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function _y(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 Ey(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 Ny(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 Sy(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 ky=se,jy=ke.Graph;var Cy={debugOrdering:$y};function $y(e){let t=ky.buildLayerMatrix(e),n=new jy({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 My="1.1.8",Ay={graphlib:ke,layout:ny,debug:Cy,util:{time:se.time,notime:se.notime},version:My};const Js=oi(Ay),ei=264,Iy=44,Ty=26,Ry=14;function ti(e){const t=Math.max(e.attributes.length,1);return Iy+t*Ty+Ry}function ni(e,t,n){const r=new Js.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:ei,height:i?ti(i):120})}for(const s of t)r.setEdge(s.source,s.target,{minlen:1,weight:2});return Js.layout(r),e.map(s=>{const i=r.node(s.id),o=n.get(s.id),a=o?ti(o):120;return{...s,position:{x:i.x-ei/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 Oy=["skos:exactMatch","skos:closeMatch","skos:broadMatch","skos:narrowMatch","skos:relatedMatch"],fa=["industry","core","domain","specialised"];function Dy({entity:e,exec:t,onClose:n}){var E,T;const[r,s]=w.useState(((E=e.conceptual)==null?void 0:E.name)??e.name),[i,o]=w.useState([]),[a,l]=w.useState(null),[c,u]=w.useState(null),[d,m]=w.useState("skos:exactMatch"),[f,y]=w.useState(((T=e.conceptual)==null?void 0:T.ontology_layer)??"core"),[x,_]=w.useState([]),[g,b]=w.useState("");w.useEffect(()=>{zo().then(j=>_(j.ontologies)).catch(()=>{})},[]),w.useEffect(()=>{const j=setTimeout(()=>{if(!r.trim())return o([]);Po(r,g||void 0).then(I=>{o(I.results),l(I.loaded_terms)}).catch(()=>o([]))},200);return()=>clearTimeout(j)},[r,g]);const M=()=>{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:()=>b(""),children:"all sources"}),x.map(j=>h.jsx("button",{className:"src-chip"+(g===j.id?" active":""),title:j.count!=null?`${j.count} terms`:"live resolver",onClick:()=>b(j.id),children:j.name},j.id))]}),h.jsx("input",{autoFocus:!0,className:"edit-input modal-search",placeholder:g?`Search within ${g}…`:"Search vocabulary terms…",value:r,onChange:j=>s(j.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(j=>h.jsxs("button",{className:"term-card"+((c==null?void 0:c.iri)===j.iri?" picked":""),onClick:()=>u(j),children:[h.jsxs("div",{className:"term-head",children:[h.jsx("span",{className:"term-label",children:j.label}),h.jsxs("span",{className:"term-source",children:[j.source_kind==="glossary-term"&&h.jsx("span",{className:"kind-badge",children:"glossary"}),j.source]})]}),h.jsx("code",{className:"term-iri",children:j.prefixed}),j.definition&&h.jsx("p",{className:"term-def",children:j.definition})]},j.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:j=>m(j.target.value),children:Oy.map(j=>h.jsx("option",{children:j},j))})]}),h.jsxs("label",{children:["layer",h.jsx("select",{value:f,onChange:j=>y(j.target.value),children:fa.map(j=>h.jsx("option",{children:j},j))})]}),h.jsxs("button",{className:"primary-btn",disabled:!c,onClick:M,children:["Align",c?` to ${c.label}`:""]})]})]})}function Ly({entity:e,doc:t,exec:n,onClose:r}){var E,T,j;const[s,i]=w.useState(((E=e.term_map)==null?void 0:E.subject_template)??""),[o,a]=w.useState(((T=e.term_map)==null?void 0:T.class_iri)??""),l=new Set(e.attributes.map(I=>I.name)),u=Array.from(s.matchAll(/\{([^}]+)\}/g)).map(I=>I[1]).filter(I=>!l.has(I)),d=I=>!I||I.startsWith("http://")||I.startsWith("https://")||/^[^\s:]+:[^\s:]+/.test(I),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}:`,_=(j=(e.key_groups??[]).find(I=>I.type==="pk"))==null?void 0:j.members.map(I=>{var F;return(F=e.attributes.find(S=>S.id===I))==null?void 0:F.name}).filter(Boolean),g=_&&_.length?`${x}${e.id}/${_.map(I=>`{${I}}`).join("_")}`:"(blank-node: entity has no primary key)",b=o.trim()||`${x}${e.id}`,M=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:I=>a(I.target.value)}),d(o)?h.jsxs("code",{className:"form-preview",children:["rr:class ",b]}):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:I=>i(I.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 ",M]}),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(I=>I.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 Py({doc:e,exec:t,onClose:n,onCreated:r}){const[s,i]=w.useState(""),[o,a]=w.useState(""),[l,c]=w.useState(""),[u,d]=w.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 zy({doc:e,fromId:t,toId:n,exec:r,onClose:s}){const i=e.entities.find(b=>b.id===t),o=e.entities.find(b=>b.id===n),a=w.useMemo(()=>o==null?void 0:o.attributes.find(b=>b.role==="business_key"),[o]),[l,c]=w.useState(""),[u,d]=w.useState((a==null?void 0:a.id)??""),[m,f]=w.useState("many_to_one"),[y,x]=w.useState("mandatory");if(!i||!o)return null;const _=l==="__new__",g=()=>r("create_relationship",{from_entity:i.id,to_entity:o.id,from_attribute:_?null:l||null,to_attribute:u||null,create_from_fk:_,cardinality:m,optionality:y}).then(s);return h.jsxs(qt,{title:`${i.name} → ${o.name}`,onClose:s,children:[h.jsxs("label",{className:"form-row",children:["cardinality (",i.name," : ",o.name,")",h.jsx("select",{value:m,onChange:b=>f(b.target.value),children:ha.map(b=>h.jsx("option",{children:b},b))})]}),h.jsxs("label",{className:"form-row",children:["foreign key on ",i.name,h.jsxs("select",{value:l,onChange:b=>c(b.target.value),children:[h.jsx("option",{value:"",children:"(none)"}),h.jsxs("option",{value:"__new__",children:["➕ create column",a?` "${a.name}"`:""]}),i.attributes.map(b=>h.jsx("option",{value:b.id,children:b.name},b.id))]})]}),h.jsxs("label",{className:"form-row",children:["references on ",o.name,h.jsxs("select",{value:u,onChange:b=>d(b.target.value),children:[h.jsx("option",{value:"",children:"(none)"}),o.attributes.map(b=>h.jsxs("option",{value:b.id,children:[b.name,b.role==="business_key"?" 🔑":""]},b.id))]})]}),h.jsxs("label",{className:"form-row",children:["optionality",h.jsxs("select",{value:y,onChange:b=>x(b.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:g,children:"Create relationship"})})]})}function Fy({rel:e,doc:t,exec:n,onClose:r}){const s=g=>{var b;return((b=t.entities.find(M=>M.id===g))==null?void 0:b.name)??"?"},[i,o]=w.useState(e.name),[a,l]=w.useState(e.cardinality),[c,u]=w.useState(e.optionality),[d,m]=w.useState(e.identifying),[f,y]=w.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 Hy=w.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",b="rel-edge"+(c?" selected":"")+(m?" dimmed":"");return h.jsxs("g",{className:b,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"}),h.jsx(ri,{x:n,y:r,side:o,many:_,optional:y}),h.jsx(ri,{x:s,y:i,side:a,many:g,optional:!1}),c&&d&&h.jsx("text",{className:"rel-label",x:(n+s)/2,y:(r+i)/2-8,children:d.name})]})});function ri({x:e,y:t,side:n,many:r,optional:s}){const i=n===Y.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 Vy={entity:xm},By={relationship:Hy},si=["#e0a63a","#e8825a","#d98ba8","#c4a3e0","#7fb0d8","#7fc9a0","#e6c14a"],ii="#8a7d6a";function gx({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]=w.useState([]),[m,f]=w.useState([]),y=w.useRef(!1),[x,_]=w.useState(null),[g,b]=w.useState(null),[M,E]=w.useState(!1),[T,j]=w.useState(null),[I,F]=w.useState(null),S=!t.canEdit,D=w.useMemo(()=>{const $=new Map;return e.subject_areas.forEach((v,A)=>$.set(v.id,si[A%si.length])),$},[e]),L=w.useMemo(()=>{const $=new Map;return e.entities.forEach(v=>$.set(v.id,v)),$},[e]);w.useEffect(()=>{var B;const $=i.trim().toLowerCase(),v=new Set;if($)for(const P of e.entities)(P.name.toLowerCase()+" "+(((B=P.conceptual)==null?void 0:B.name.toLowerCase())??"")+" "+P.attributes.map(X=>X.name.toLowerCase()).join(" ")).includes($)&&v.add(P.id);const A=new Set;if(r){A.add(r);for(const P of e.relationships)P.from.entity===r&&A.add(P.to.entity),P.to.entity===r&&A.add(P.from.entity)}const O=e.entities.map(P=>{var G;return{id:P.id,type:"entity",position:{x:0,y:0},data:{entity:P,color:(G=P.conceptual)!=null&&G.subject_area?D.get(P.conceptual.subject_area.id)??ii:ii,dimmed:$!==""&&!v.has(P.id)||r!==null&&!A.has(P.id),highlighted:$!==""&&v.has(P.id),showTypes:o}}}),z=e.relationships.filter(P=>L.has(P.from.entity)&&L.has(P.to.entity)).map(P=>({id:P.id,source:P.from.entity,target:P.to.entity,type:"relationship",data:{relationship:P,dimmed:r!==null&&P.from.entity!==r&&P.to.entity!==r}}));d(P=>{const G=new Map(P.map(U=>[U.id,U.position])),X=O.every(U=>G.has(U.id));if(y.current&&X&&P.length>=O.length)return O.map(U=>({...U,position:G.get(U.id)??U.position}));const Q=ni(O,z,L).map(U=>G.has(U.id)&&y.current?{...U,position:G.get(U.id)}:U);return y.current=!0,requestAnimationFrame(()=>c({padding:.15,duration:300})),Q}),f(z)},[e,i,r,o,D,L,c]);const V=w.useCallback(()=>{d($=>ni($,m,L)),requestAnimationFrame(()=>c({padding:.15,duration:300}))},[m,L,c]),H=w.useCallback($=>{s($),d(v=>(v.find(O=>O.id===$)&&requestAnimationFrame(()=>c({nodes:[{id:$}],padding:.4,duration:400})),v))},[c,s]);w.useImperativeHandle(l,()=>({relayout:V,fitView:()=>c({padding:.15,duration:300}),focusEntity:H,newEntity:()=>E(!0)}),[V,c,H]);const p=w.useCallback($=>{S||!$.source||!$.target||$.source===$.target||j({from:$.source,to:$.target})},[S]),k=w.useCallback(async($,v)=>{try{return await n($,v)}catch(A){throw a==null||a(A instanceof Error?A.message:String(A)),A}},[n,a]),N=r?L.get(r)??null:null,R=e.relationships.find($=>$.id===I)??null;return h.jsxs(h.Fragment,{children:[h.jsxs(Mo,{nodes:u,edges:m,nodeTypes:Vy,edgeTypes:By,onNodeClick:($,v)=>s(v.id),onEdgeClick:($,v)=>!S&&F(v.id),onPaneClick:()=>{s(null),F(null)},onNodeDragStop:($,v)=>d(A=>A.map(O=>O.id===v.id?{...O,position:v.position}:O)),onConnect:p,nodesConnectable:!S,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:$=>{var v;return((v=$.data)==null?void 0:v.color)??"#5a4f42"},maskColor:"rgba(20, 17, 15, 0.75)"}),h.jsx(rm,{showInteractive:!1})]}),N&&h.jsx(bm,{entity:N,doc:e,caps:t,exec:k,onClose:()=>s(null),onFocusEntity:H,onAlign:_,onEditMapping:b}),x&&h.jsx(Dy,{entity:x,exec:k,onClose:()=>_(null)}),g&&h.jsx(Ly,{entity:g,doc:e,exec:k,onClose:()=>b(null)}),M&&h.jsx(Py,{doc:e,exec:k,onClose:()=>E(!1),onCreated:H}),T&&h.jsx(zy,{doc:e,fromId:T.from,toId:T.to,exec:k,onClose:()=>j(null)}),R&&h.jsx(Fy,{rel:R,doc:e,exec:k,onClose:()=>F(null)})]})}function yx({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(Gy,{}),e==="layers"&&h.jsx(Wy,{refreshKey:r,onFocusEntity:i}),e==="changes"&&h.jsx(Uy,{readOnly:n,refreshKey:r,onModelChanged:s}),e==="decisions"&&h.jsx(Xy,{readOnly:n})]})}function Gy(){const[e,t]=w.useState(""),[n,r]=w.useState([]),[s,i]=w.useState({loaded:0,vocabs:[]}),[o,a]=w.useState(null),[l,c]=w.useState([]),[u,d]=w.useState("");w.useEffect(()=>{zo().then(f=>c(f.ontologies)).catch(()=>{})},[]),w.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=w.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 Yy=["industry","core","domain","specialised"];function Wy({refreshKey:e,onFocusEntity:t}){const[n,r]=w.useState(null),[s,i]=w.useState(null);if(w.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))]}),Yy.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 Uy({readOnly:e,refreshKey:t,onModelChanged:n}){const[r,s]=w.useState(null),[i,o]=w.useState(""),[a,l]=w.useState(""),[c,u]=w.useState(!1),d=w.useCallback(()=>{hm().then(s).catch(()=>s(null)),mm().then(m=>o([m.diff,...m.untracked].filter(Boolean).join(` - -`))).catch(()=>o(""))},[]);return w.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+` -`},f))}),!e&&h.jsxs(h.Fragment,{children:[h.jsx("input",{className:"edit-input",placeholder:"commit message…",value:a,onChange:m=>l(m.target.value)}),h.jsxs("div",{className:"modal-footer",children:[h.jsx("button",{className:"mini-btn danger",disabled:c,onClick:()=>{confirm("Discard ALL uncommitted model changes?")&&(u(!0),gm().then(()=>{u(!1),d(),n()}))},children:"Discard all"}),h.jsx("button",{className:"primary-btn",disabled:c||!a.trim(),onClick:()=>{u(!0),pm(a).then(()=>{u(!1),l(""),d()})},children:"Commit"})]})]})]}):h.jsx("div",{className:"panel-body",children:"model directory is not in a git repo"})}function Xy({readOnly:e}){const[t,n]=w.useState([]),r=w.useCallback(()=>{ym().then(i=>n(i.decisions)).catch(()=>n([]))},[]);if(w.useEffect(r,[r]),t.length===0)return h.jsx("div",{className:"panel-body",children:"no recorded decisions (run `mdl reverse` to propose)"});const s={accepted:"✓",rejected:"✗",proposed:"?"};return h.jsx("div",{className:"panel-body",children:t.map(i=>h.jsxs("div",{className:"decision "+i.verdict,children:[h.jsxs("div",{className:"decision-head",children:[h.jsx("span",{className:"decision-mark",children:s[i.verdict]}),h.jsx("span",{className:"chip",children:i.confidence}),h.jsx("span",{className:"chip",children:i.signal})]}),h.jsx("p",{className:"decision-subject",children:i.subject}),!e&&i.verdict==="proposed"&&h.jsxs("div",{className:"decision-actions",children:[h.jsx("button",{className:"mini-btn",onClick:()=>Ms(i.signal_key,"accepted").then(r),children:"Accept"}),h.jsx("button",{className:"mini-btn danger",onClick:()=>Ms(i.signal_key,"rejected").then(r),children:"Reject"})]})]},i.signal_key))})}export{Lo as A,cm as B,rm as C,xm as E,Wy as L,gx as M,Gy as O,si as P,Co as R,yx as S,Qy as a,ax as b,ux as c,dx as d,fx as e,Ky as f,hm as g,lx as h,nx as i,rx as j,sx as k,ox as l,ix as m,ex as n,Po as o,cx as p,tx as q,ni as r,Jy as s,Mo as t,Hy as u,Zh as v}; diff --git a/packages/server/src/mdl_server/static/assets/styles-DnEKfty_.js b/packages/server/src/mdl_server/static/assets/styles-DnEKfty_.js new file mode 100644 index 0000000..28edb79 --- /dev/null +++ b/packages/server/src/mdl_server/static/assets/styles-DnEKfty_.js @@ -0,0 +1,23 @@ +var Ua=Object.defineProperty;var Xa=(e,t,n)=>t in e?Ua(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var oe=(e,t,n)=>Xa(e,typeof t!="symbol"?t+"":t,n);import{r as b,g as oi,R as $,j as h}from"./client-DOmNpTln.js";function he(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?nl:tl;ui.useSyncExternalStore=bt.useSyncExternalStore!==void 0?bt.useSyncExternalStore:rl;ci.exports=ui;var sl=ci.exports;/** + * @license React + * use-sync-external-store-shim/with-selector.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * 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;li.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};ai.exports=li;var hl=ai.exports;const ml=oi(hl),pl={},Br=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?Br(e):Br,{useDebugValue:yl}=$,{useSyncExternalStoreWithSelector:xl}=ml,wl=e=>e;function di(e,t=wl,n){const r=xl(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return yl(r),r}const Gr=(e,t)=>{const n=gl(e),r=(s,i=t)=>di(n,s,i);return Object.assign(r,n),r},bl=(e,t)=>e?Gr(e,t):Gr;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)),Wr.hasOwnProperty(t)?{space:Wr[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 fi(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)||yi(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 xi(e){return e.trim().split(/^|\s+/)}function xr(e){return e.classList||new wi(e)}function wi(e){this._node=e,this._names=xi(e.getAttribute("class")||"")}wi.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 bi(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),Ni(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),Si(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))?Jr(t[1],t[2]/100,t[3]/100,1):(t=pu.exec(e))?Jr(t[1],t[2]/100,t[3]/100,t[4]):Ur.hasOwnProperty(e)?Zr(Ur[e]):e==="transparent"?new ge(NaN,NaN,NaN,0):null}function Zr(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,ki(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(tt(this.r),tt(this.g),tt(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:Kr,formatHex:Kr,formatHex8:wu,formatRgb:Qr,toString:Qr}));function Kr(){return`#${Je(this.r)}${Je(this.g)}${Je(this.b)}`}function wu(){return`#${Je(this.r)}${Je(this.g)}${Je(this.b)}${Je((isNaN(this.opacity)?1:this.opacity)*255)}`}function Qr(){const e=hn(this.opacity);return`${e===1?"rgb(":"rgba("}${tt(this.r)}, ${tt(this.g)}, ${tt(this.b)}${e===1?")":`, ${e})`}`}function hn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function tt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Je(e){return e=tt(e),(e<16?"0":"")+e.toString(16)}function Jr(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 ji(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?ji(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,ki(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(es(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("}${es(this.h)}, ${Qt(this.s)*100}%, ${Qt(this.l)*100}%${e===1?")":`, ${e})`}`}}));function es(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 Ci=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?$i:function(t,n){return n-t?_u(t,n,e):Ci(isNaN(t)?n:t)}}function $i(e,t){var n=t-e;return n?vu(e,n):Ci(isNaN(e)?t:e)}const ts=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=$i(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 ss(){rt=(pn=Vt.now())+kn,_t=Tt=0;try{Du()}finally{_t=0,Pu(),rt=0}}function Lu(){var e=Vt.now(),t=e-pn;t>Ii&&(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-rt;t>24?(e<1/0&&(Tt=setTimeout(ss,e-Vt.now()-kn)),Ct&&(Ct=clearInterval(Ct))):(Ct||(pn=Vt.now(),Ct=setInterval(Lu,Ii)),_t=1,Ti(ss))}}function is(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=[],Oi=0,os=1,or=2,ln=3,as=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:Oi})}function vr(e,t){var n=Se(e,t);if(n.state>Oi)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=Ri(i,0,n.time);function i(c){n.state=os,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!==os)return l();for(u in r)if(f=r[u],f.name===n.name){if(f.state===ln)return is(o);f.state===as?(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 ls(){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 zi(){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",ls).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",ls),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;Ni(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),Si(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.`},Hi=Pe.error001();function re(e,t){const n=b.useContext(Cn);if(n===null)throw new Error(Hi);return di(n,e,t)}const ue=()=>{const e=b.useContext(Cn);if(e===null)throw new Error(Hi);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])}),cs=(e,t,n)=>en?-Et(Math.abs(e-n),1,50)/50:0,Fi=(e,t)=>{const n=cs(e.x,35,t.width-35)*20,r=cs(e.y,35,t.height-35)*20;return[n,r]},Vi=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},Bi=(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}),Gi=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),us=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),rf=(e,t)=>Gi(Bi(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"),Yi=["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 Wi=e=>"clientX"in e,Ge=(e,t)=>{var i,o;const n=Wi(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 Ui({sourceX:e,sourceY:t,targetX:n,targetY:r}){const s=Math.abs(n-e)/2,i=n{const[_,g,v]=qi({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 fs={[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=fs[t],a=fs[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]=Ui({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(hs(e,t)/2,hs(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]=Ui({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 ms({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 Zi({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:r,targetY:s,targetPosition:i=W.Top,curvature:o=.25}){const[a,l]=ms({pos:n,x1:e,y1:t,x2:r,y2:s,c:o}),[c,u]=ms({pos:i,x1:r,y1:s,x2:e,y2:t,c:o}),[d,m,f,y]=Xi({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]=Zi({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},Ki=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r}),nt=(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}=nt(s,t).positionAbsolute;return Bi(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 Gi(n)},Qi=(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}=nt(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},Ji=(e,t)=>{const n=e.map(r=>r.id);return t.filter(r=>n.includes(r.source)||n.includes(r.target))},eo=(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}},Qe=(e,t=0)=>e.transition().duration(t);function ps(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},to=()=>({handleDomNode:null,isValid:!1,connection:wf,endHandle:null});function no(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={...to(),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===st.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=ps(i,o,"source",`${t}-${n}-${r}`),l=ps(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 ro({event:e,handleId:t,nodeId:n,onConnect:r,isTarget:s,getState:i,setState:o,isValidConnection:a,edgeUpdaterType:l,onReconnectEnd:c}){const u=Vi(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]=Fi(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=>no(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?Ki({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 gs=()=>!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}},so=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",_=ue(),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=Wi(z);s&&(G&&z.button===0||!G)&&ro({event:z,handleId:y,nodeId:g,onConnect:C,isTarget:x,getState:_.getState,setState:_.setState,isValidConnection:n||_.getState().isValidConnection||gs}),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=Vi(z.target),D=n||E||gs,{connection:N,isValid:I}=no({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)});so.displayName="Handle";var Be=b.memo(so);const io=({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}));io.displayName="DefaultNode";var fr=b.memo(io);const oo=({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}));oo.displayName="InputNode";var ao=b.memo(oo);const lo=({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);lo.displayName="OutputNode";var co=b.memo(lo);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 uo=b.memo(({onSelectionChange:e})=>{const t=ue(),{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});uo.displayName="SelectionListener";const kf=e=>!!e.onSelectionChange;function jf({onSelectionChange:e}){const t=re(kf);return e||t?$.createElement(uo,{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=ue();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},ys={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%)"},fo="react-flow__node-desc",ho="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:`${fo}-${e}`,style:ys},"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:`${ho}-${e}`,style:ys},"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=ws(f.code,a);i.current.add(f[x]),xs(o,i.current,!1)&&(f.preventDefault(),r(!0))},d=f=>{if((!s.current||s.current&&!t.actInsideInputWithModifier)&&cr(f))return!1;const x=ws(f.code,a);xs(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 xs(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function ws(e,t){return t.includes(e)?"code":"key"}function mo(e,t,n,r){var a,l;const s=e.parentNode||e.parentId;if(!s)return n;const i=t.get(s),o=nt(i,r);return mo(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 po(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}=mo(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)}),po(s,n,i),s}function go(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}=eo(_,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(Qe(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=ue(),{d3Zoom:t,d3Selection:n}=re(Pf,fe);return b.useMemo(()=>n&&t?{zoomIn:s=>t.scaleBy(Qe(n,s==null?void 0:s.duration),1.2),zoomOut:s=>t.scaleBy(Qe(n,s==null?void 0:s.duration),1/1.2),zoomTo:(s,i)=>t.scaleTo(Qe(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(Qe(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=>go(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(Qe(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}=eo(s,o,a,l,c,(i==null?void 0:i.padding)??.1),f=De.translate(u,d).scale(m);t.transform(Qe(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=Ki(s,i);return{x:c.x+a,y:c.y+l}},viewportInitialized:!0}:Lf,[t,n])};function An(){const e=zf(),t=ue(),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=Ji(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:us(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=us(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=ue(),{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=ue();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}`),bs=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),vs=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=et.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=ue(),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=zi().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(vs),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=vs(N),ee=I*Math.pow(2,Q);z.scaleTo(G,ee,J,N);return}const L=N.deltaMode===1?20:1;let P=l===et.Vertical?0:N.deltaX*L,R=l===et.Horizontal?0:N.deltaY*L;!yn()&&N.shiftKey&&l!==et.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&&bs(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&&bs(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 _s(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&&_s(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&&_s(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}),yo=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=ue(),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))});yo.displayName="Pane";function xo(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const r=t.get(n);return r?r.selected?!0:xo(r,t):!1}function Es(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||!xo(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 wo(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}=nt(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}=nt(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=nt(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 Ns=(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=ue();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 bo({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:i,selectNodesOnDrag:o}){const a=ue(),[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=wo(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]=Fi(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||!Es(O,`.${n}`,e))&&(!r||Es(O,r,e))});return w.call(F),()=>{w.on(".drag",null)}}}},[e,t,n,r,i,a,s,o,j]),l}function vo(){const e=ue();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}=wo(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=ue(),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=vo(),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(Yi.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=bo({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:`${fo}-${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=ue(),{width:s,height:i,x:o,y:a,transformString:l,userSelectionActive:c}=re(eh,fe),u=vo(),d=b.useRef(null);if(b.useEffect(()=>{var y;n||(y=d.current)==null||y.focus({preventScroll:!0})},[n]),bo({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,_o=({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(yo,{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})))};_o.displayName="FlowRenderer";var sh=b.memo(_o);function ih(e){return re(b.useCallback(n=>e?Qi(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||ao),default:It(e.default||fr),output:It(e.output||co),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}),Eo=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)})}))};Eo.displayName="NodeRenderer";var ch=b.memo(Eo);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,Ss="react-flow__edgeupdater",ks=({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([Ss,`${Ss}-${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=ue(),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:Ue,unselectNodesAndEdges:Xe,multiSelectionActive:qe}=ne.getState(),Ie=_e.find(kt=>kt.id===n);Ie&&(S&&(ne.setState({nodesSelectionActive:!1}),Ie.selected&&qe?(Xe({nodes:[],edges:[Ie]}),(je=ee.current)==null||je.blur()):Ue([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:Ue,isValidConnection:Xe}=ne.getState(),qe=_e?v:g,Ie=(_e?G:z)||null,je=_e?"target":"source",kt=Xe||fh,Rn=_e,jt=Ue.find(Ze=>Ze.id===n);se(!0),N==null||N(me,jt,je);const On=Ze=>{se(!1),I==null||I(Ze,jt,je)};ro({event:me,handleId:Ie,nodeId:qe,onConnect:Ze=>D==null?void 0:D(jt,Ze),isTarget:Rn,getState:ne.getState,setState:ne.setState,isValidConnection:kt,edgeUpdaterType:je,onReconnectEnd:On})},ct=me=>Ae(me,!0),Ye=me=>Ae(me,!1),We=()=>Y(!0),ut=()=>Y(!1),dt=!S&&!o,St=me=>{var _e;if(!Q&&Yi.includes(me.key)&&S){const{unselectNodesAndEdges:Ue,addSelectedEdges:Xe,edges:qe}=ne.getState();me.key==="Escape"?((_e=ee.current)==null||_e.blur(),Ue({edges:[qe.find(je=>je.id===n)]})):Xe([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?`${ho}-${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(ks,{position:A,centerX:j,centerY:w,radius:T,onMouseDown:ct,onMouseEnter:We,onMouseOut:ut,type:"source"}),(X==="target"||X===!0)&&$.createElement(ks,{position:F,centerX:M,centerY:C,radius:T,onMouseDown:Ye,onMouseEnter:We,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 js(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 Cs(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=js(n,e,t),a=js(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 $s(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"}),Ms={[xn.Arrow]:wh,[xn.ArrowClosed]:bh};function vh(e){const t=ue();return b.useMemo(()=>{var s,i;return Object.prototype.hasOwnProperty.call(Ms,e)?Ms[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))},No=({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})))};No.displayName="MarkerDefinitions";var Nh=b.memo(No);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}),So=({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]=$s(F.get(p.source)),[D,N,I]=$s(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===st.Strict?N.target:(N.target??[]).concat(N.source??[]),H=Cs(E.source,p.sourceHandle),B=Cs(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};So.displayName="EdgeRenderer";var kh=b.memo(So);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},ko=({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===st.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]=Zi(M):r===Ve.Step?[w]=wn({...M,borderRadius:0}):r===Ve.SmoothStep?[w]=wn(M):r===Ve.SimpleBezier?[w]=qi(M):w=`M${_},${g} ${l},${c}`,$.createElement("path",{d:w,fill:"none",className:"react-flow__connection-path",style:n})};ko.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(ko,{nodeId:s,handleType:i,style:t,type:n,CustomComponent:r,connectionStatus:c})))}function As(e,t){return b.useRef(null),ue(),b.useMemo(()=>t(e),[e])}const jo=({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:Ye,nodeOrigin:We,nodeExtent:ut,rfId:dt})=>{const St=As(e,oh),me=As(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:Ye},$.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:Ye,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:Ye,nodeOrigin:We,nodeExtent:ut,rfId:dt})))};jo.displayName="GraphView";var Th=b.memo(jo);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:st.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:Ns(".source",_.nodeElement,m,c),target:Ns(".target",_.nodeElement,m,c)}},...v}),x.push({id:g.id,type:"dimensions",dimensions:v}))}return x},[]);po(s,c);const y=o||i&&!o&&go(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),Co=({children:e})=>{const t=b.useRef(null);return t.current||(t.current=Rh()),$.createElement(Qd,{value:t.current},e)};Co.displayName="ReactFlowProvider";const $o=({children:e})=>b.useContext(Cn)?$.createElement($.Fragment,null,e):$.createElement(Co,null,e);$o.displayName="ReactFlowWrapper";const Oh={input:ao,default:fr,output:co,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},Mo=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=st.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:Ye=!0,nodeExtent:We,defaultMarkerColor:ut="#b1b1b7",zoomOnScroll:dt=!0,zoomOnPinch:St=!0,panOnScroll:me=!1,panOnScrollSpeed:_e=.5,panOnScrollMode:Ue=et.Free,zoomOnDoubleClick:Xe=!0,panOnDrag:qe=!0,onPaneClick:Ie,onPaneMouseEnter:je,onPaneMouseMove:kt,onPaneMouseLeave:Rn,onPaneScroll:jt,onPaneContextMenu:On,children:zr,onEdgeContextMenu:Ze,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:Hr="nopan",fitView:Ma=!1,fitViewOptions:Aa,connectOnClick:Ia=!0,attributionPosition:Ta,proOptions:Ra,defaultEdgeOptions:Oa,elevateNodesOnSelect:Da=!0,elevateEdgesOnSelect:La=!1,disableKeyboardA11y:Fr=!1,autoPanOnConnect:Pa=!0,autoPanOnNodeDrag:za=!0,connectionRadius:Ha=20,isValidConnection:Fa,onError:Va,style:Ba,id:Vr,nodeDragThreshold:Ga,...Ya},Wa)=>{const Dn=Vr||"1";return $.createElement("div",{...Ya,style:{...Ba,...Hh},ref:Wa,className:he(["react-flow",s]),"data-testid":"rf__wrapper",id:Vr},$.createElement($o,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:Ye,zoomOnScroll:dt,zoomOnPinch:St,zoomOnDoubleClick:Xe,panOnScroll:me,panOnScrollSpeed:_e,panOnScrollMode:Ue,panOnDrag:qe,onPaneClick:Ie,onPaneMouseEnter:je,onPaneMouseMove:kt,onPaneMouseLeave:Rn,onPaneScroll:jt,onPaneContextMenu:On,onSelectionContextMenu:E,onSelectionStart:T,onSelectionEnd:D,onEdgeContextMenu:Ze,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:Hr,elevateEdgesOnSelect:La,rfId:Dn,disableKeyboardA11y:Fr,nodeOrigin:U,nodeExtent:We}),$.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:We,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:Hr,nodeOrigin:U,rfId:Dn,autoPanOnConnect:Pa,autoPanOnNodeDrag:za,onError:Va,connectionRadius:Ha,isValidConnection:Fa,nodeDragThreshold:Ga}),$.createElement(jf,{onSelectionChange:G}),zr,$.createElement(ef,{proOptions:Ra,position:Ta}),$.createElement(Rf,{rfId:Dn,disableKeyboardA11y:Fr})))});Mo.displayName="ReactFlow";const Ao=({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})};Ao.displayName="MiniMapNode";var Fh=b.memo(Ao);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}=nt(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 Io({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=ue(),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=zi().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"})))}Io.displayName="MiniMap";var Zh=b.memo(Io);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}),To=({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=ue(),[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)};To.displayName="Controls";var rm=b.memo(To),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 Ro({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})`}))}Ro.displayName="Background";var cm=b.memo(Ro);const Oo=(()=>{const e=window.location.pathname.match(/^(\/view\/[^/]+)(?:\/|$)/);return e?e[1]:""})();function Do(e){return Oo+e}async function de(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 it(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=>de(e?`/api/model?subject_area=${encodeURIComponent(e)}`:"/api/model"),tx=()=>de("/api/diagnostics"),Po=(e,t)=>de(`/api/ontology/search?q=${encodeURIComponent(e)}`+(t?`&within=${encodeURIComponent(t)}`:"")),zo=()=>de("/api/ontology/ontologies"),um=e=>de(`/api/ontology/term?ref=${encodeURIComponent(e)}`),dm=()=>de("/api/ontology/stack"),fm=()=>de("/api/ontology/coverage"),nx=(e,t,n)=>it("/api/command",{op:e,payload:t,fingerprint:n}),hm=()=>de("/api/git/status"),mm=()=>de("/api/git/diff"),pm=e=>it("/api/git/commit",{message:e}),gm=()=>it("/api/git/discard",{}),ym=()=>de("/api/decisions"),Is=(e,t)=>it(`/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),de(`/api/glossary/terms?${t.toString()}`)},sx=()=>de("/api/glossary/config"),ix=e=>it("/api/git/propose",e),ox=(e="HEAD")=>de(`/api/git/diff/model?base=${encodeURIComponent(e)}`),ax=(e="HEAD")=>de(`/api/git/classify?base=${encodeURIComponent(e)}`),lx=e=>it("/api/git/classify",{changes:e}),cx=e=>de(`/api/git/conflicts?base=${encodeURIComponent(e)}`),ux=(e="")=>de(`/api/git/context?user=${encodeURIComponent(e)}`),dx=(e="")=>de(`/api/git/proposals?user=${encodeURIComponent(e)}`),fx=(e,t,n)=>fetch(`${Oo}/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()}),hx=()=>de("/api/glossary/subject-areas"),mx=e=>de(`/api/glossary/subject-area/${e}`),px=(e,t)=>it(`/api/glossary/subject-area/${e}/expand`,t),xm={business_key:"🔑",surrogate_key:"#",measure:"Σ",attribute:""};function wm(e){return e??""}const Tr="__entity_source",Rr="__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:Rr,type:"target",position:W.Left,className:"port"}),h.jsx(Be,{id:Tr,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",Ke="\0",Ts="";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[Ke]={})}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]=Ke,this._children[t]={},this._children[Ke][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=Ke;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!==Ke)return n}}children(t=Ke){if(this._isCompound){var n=this._children[t];if(n)return Object.keys(n)}else{if(t===Ke)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,Rs(this._preds[n],t),Rs(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],Os(this._preds[n],t),Os(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 Rs(e,t){e[t]?e[t]++:e[t]=1}function Os(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+Ts+i+Ts+(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 Or=Im,Rm="2.2.4",Om={Graph:Or,version:Rm},Dm=Or,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=Or,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},Ls=Om,ke={Graph:Ls.Graph,json:Lm,alg:vp,version:Ls.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 Ps(n),n}enqueue(t){let n=this._sentinel;t._prev&&t._next&&Ps(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 Ps(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 Dr(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 Dr(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 Dr(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,zs=Tn.slack,pg=Tn.longestPath,gg=ke.alg.preorder,yg=ke.alg.postorder,xg=ce.simplify,wg=ot;ot.initLowLimValues=Pr;ot.initCutValues=Lr;ot.calcCutValue=ea;ot.leaveEdge=na;ot.enterEdge=ra;ot.exchangeEdges=sa;function ot(e){e=xg(e),pg(e);var t=mg(e);Pr(t),Lr(t,e);for(var n,r;n=na(t);)r=ra(t,e,n),sa(t,e,n,r)}function Lr(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 Pr(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===Hs(e,e.node(u.v),a)&&l!==Hs(e,e.node(u.w),a));return c.reduce((u,d)=>zs(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 Hs(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":Fs(e);break;case"tight-tree":$g(e);break;case"longest-path":Cg(e);break;case"none":break;default:Fs(e)}}var Cg=ia;function $g(e){ia(e),Ng(e)}function Fs(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;iBs(e.node(t))),e.edges().forEach(t=>Bs(e.edge(t)))}function Bs(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 Gs=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=Gs.applyWithChunking(Math.max,r),i=Gs.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=Ys(i,s,l),r.forEach(u=>{l+=u.vs.length,i.push(u.vs),o+=u.barycenter*u.weight,a+=u.weight,l=Ys(i,s,l)});let c={vs:i.flat(!0)};return a&&(c.barycenter=o/a,c.weight=a),c}function Ys(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=Ws(e,on.range(1,n+1),"inEdges"),s=Ws(e,on.range(n-1,-1,-1),"outEdges"),i=E0(e);if(Us(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 Us(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 Xs=Kp,qs=ng,Z0=kg,K0=ce.normalizeRanks,Q0=Mg,J0=ce.removeEmptyRanks,Zs=Rg,ey=Hg,Ks=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",()=>Xs.run(e)),t(" nestingGraph.run",()=>Zs.run(e)),t(" rank",()=>Z0(ve.asNonCompoundGraph(e))),t(" injectEdgeLabelProxies",()=>yy(e)),t(" removeEmptyRanks",()=>J0(e)),t(" nestingGraph.cleanup",()=>Zs.cleanup(e)),t(" normalizeRanks",()=>K0(e)),t(" assignRankMinMax",()=>xy(e)),t(" removeEdgeLabelProxies",()=>wy(e)),t(" normalize.run",()=>qs.run(e)),t(" parentDummyChains",()=>Q0(e)),t(" addBorderSegments",()=>ey(e)),t(" order",()=>ty(e,n)),t(" insertSelfEdges",()=>ky(e)),t(" adjustCoordinateSystem",()=>Ks.adjust(e)),t(" position",()=>ny(e)),t(" positionSelfEdges",()=>jy(e)),t(" removeBorderNodes",()=>Ny(e)),t(" normalize.undo",()=>qs.undo(e)),t(" fixupEdgeLabelCoords",()=>_y(e)),t(" undoCoordinateSystem",()=>Ks.undo(e)),t(" translateGraph",()=>by(e)),t(" assignNodeIntersects",()=>vy(e)),t(" reversePoints",()=>Ey(e)),t(" acyclic.undo",()=>Xs.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"],Qs={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(Qs).forEach(o=>{i[o]===void 0&&(i[o]=Qs[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 Js=oi(Ty),ei=264,Ry=44,Oy=26,Dy=14;function ti(e){const t=Math.max(e.attributes.length,1);return Ry+t*Oy+Dy}function ni(e,t,n){const r=new Js.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:ei,height:i?ti(i):120})}for(const s of t)r.setEdge(s.source,s.target,{minlen:1,weight:2});return Js.layout(r),e.map(s=>{const i=r.node(s.id),o=n.get(s.id),a=o?ti(o):120;return{...s,position:{x:i.x-ei/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(ri,{x:n,y:r,side:o,many:_,optional:y}),h.jsx(ri,{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 ri({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},si=["#e0a63a","#e8825a","#d98ba8","#c4a3e0","#7fb0d8","#7fc9a0","#e6c14a"],ii="#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:Tr,targetHandle:n(e.to.entity,s)?s:Rr}}function wx({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,si[B%si.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)??ii:ii,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=ni(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=>ni(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!==Tr?R.sourceHandle:void 0,B=R.targetHandle&&R.targetHandle!==Rr?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(Mo,{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 bx({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+` +`},f))}),!e&&h.jsxs(h.Fragment,{children:[h.jsx("input",{className:"edit-input",placeholder:"commit message…",value:a,onChange:m=>l(m.target.value)}),h.jsxs("div",{className:"modal-footer",children:[h.jsx("button",{className:"mini-btn danger",disabled:c,onClick:()=>{confirm("Discard ALL uncommitted model changes?")&&(u(!0),gm().then(()=>{u(!1),d(),n()}))},children:"Discard all"}),h.jsx("button",{className:"primary-btn",disabled:c||!a.trim(),onClick:()=>{u(!0),pm(a).then(()=>{u(!1),l(""),d()})},children:"Commit"})]})]})]}):h.jsx("div",{className:"panel-body",children:"model directory is not in a git repo"})}function Ky({readOnly:e}){const[t,n]=b.useState([]),r=b.useCallback(()=>{ym().then(i=>n(i.decisions)).catch(()=>n([]))},[]);if(b.useEffect(r,[r]),t.length===0)return h.jsx("div",{className:"panel-body",children:"no recorded decisions (run `mdl reverse` to propose)"});const s={accepted:"✓",rejected:"✗",proposed:"?"};return h.jsx("div",{className:"panel-body",children:t.map(i=>h.jsxs("div",{className:"decision "+i.verdict,children:[h.jsxs("div",{className:"decision-head",children:[h.jsx("span",{className:"decision-mark",children:s[i.verdict]}),h.jsx("span",{className:"chip",children:i.confidence}),h.jsx("span",{className:"chip",children:i.signal})]}),h.jsx("p",{className:"decision-subject",children:i.subject}),!e&&i.verdict==="proposed"&&h.jsxs("div",{className:"decision-actions",children:[h.jsx("button",{className:"mini-btn",onClick:()=>Is(i.signal_key,"accepted").then(r),children:"Accept"}),h.jsx("button",{className:"mini-btn danger",onClick:()=>Is(i.signal_key,"rejected").then(r),children:"Reject"})]})]},i.signal_key))})}export{Lo as A,cm as B,rm as C,bm as E,qy as L,wx as M,Uy as O,si as P,Co as R,bx as S,tx as a,ux as b,hx as c,mx as d,px as e,ex as f,hm as g,dx as h,ix as i,ox as j,ax as k,cx as l,lx as m,rx as n,Po as o,fx as p,sx as q,ni as r,nx as s,Mo as t,By as u,Zh as v}; diff --git a/packages/server/src/mdl_server/static/index.html b/packages/server/src/mdl_server/static/index.html index dfcd2fa..7a16a8f 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 1f215ff..fea0be0 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 - + - - + +