@aranzatech/diagrams-bpmn 0.2.4 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/{catalog-m8fHIiKH.d.cts → catalog-CZsXqhL9.d.cts} +1 -1
  2. package/dist/{catalog-DIBySQqA.d.ts → catalog-Clz8sN9x.d.ts} +1 -1
  3. package/dist/{chunk-33AR3PXF.js → chunk-L64NM77A.js} +290 -20
  4. package/dist/chunk-L64NM77A.js.map +1 -0
  5. package/dist/{chunk-QOGZITWB.js → chunk-M46UDUN3.js} +2 -2
  6. package/dist/{chunk-QOGZITWB.js.map → chunk-M46UDUN3.js.map} +1 -1
  7. package/dist/{chunk-7MKU37XQ.js → chunk-XTUYPA3E.js} +191 -15
  8. package/dist/chunk-XTUYPA3E.js.map +1 -0
  9. package/dist/elements/index.d.cts +3 -3
  10. package/dist/elements/index.d.ts +3 -3
  11. package/dist/index.cjs +477 -241
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.cts +5 -5
  14. package/dist/index.d.ts +5 -5
  15. package/dist/index.js +3 -4
  16. package/dist/modeling/index.cjs +197 -10
  17. package/dist/modeling/index.cjs.map +1 -1
  18. package/dist/modeling/index.d.cts +103 -7
  19. package/dist/modeling/index.d.ts +103 -7
  20. package/dist/modeling/index.js +1 -1
  21. package/dist/simulation/index.cjs.map +1 -1
  22. package/dist/simulation/index.d.cts +36 -0
  23. package/dist/simulation/index.d.ts +36 -0
  24. package/dist/simulation/index.js +1 -1
  25. package/dist/{types-DznxZxpV.d.cts → types-BPqNeIU-.d.cts} +63 -1
  26. package/dist/{types-DznxZxpV.d.ts → types-BPqNeIU-.d.ts} +63 -1
  27. package/dist/{types-BxjCV2oX.d.ts → types-D0Flgue2.d.ts} +11 -2
  28. package/dist/{types-vVi5T7qj.d.cts → types-exnfq24-.d.cts} +11 -2
  29. package/dist/validation/index.cjs.map +1 -1
  30. package/dist/validation/index.d.cts +7 -2
  31. package/dist/validation/index.d.ts +7 -2
  32. package/dist/validation/index.js +224 -3
  33. package/dist/validation/index.js.map +1 -1
  34. package/dist/xml/index.cjs +287 -20
  35. package/dist/xml/index.cjs.map +1 -1
  36. package/dist/xml/index.d.cts +18 -2
  37. package/dist/xml/index.d.ts +18 -2
  38. package/dist/xml/index.js +1 -1
  39. package/package.json +2 -2
  40. package/dist/chunk-33AR3PXF.js.map +0 -1
  41. package/dist/chunk-7MKU37XQ.js.map +0 -1
  42. package/dist/chunk-ZFGQVLHB.js +0 -226
  43. package/dist/chunk-ZFGQVLHB.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aranzatech/diagrams-bpmn",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "BPMN 2.0 elements, nodes, edges, XML import/export, token simulation",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -68,7 +68,7 @@
68
68
  "deploy:npm": "npm install && npm run build && npm publish --access public"
69
69
  },
70
70
  "dependencies": {
71
- "@aranzatech/diagrams-core": "^0.2.2",
71
+ "@aranzatech/diagrams-core": "^0.2.4",
72
72
  "bpmn-moddle": "^10.0.0"
73
73
  },
74
74
  "peerDependencies": {
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/xml/mapper.ts","../src/xml/importer.ts","../src/xml/exporter.ts"],"names":["laneSet","BpmnModdle"],"mappings":";;;;AAIO,IAAM,sBAAA,GAAsE;AAAA,EACjF,iBAAA,EAA6B,YAAA;AAAA,EAC7B,eAAA,EAA6B,UAAA;AAAA,EAC7B,6BAAA,EAA+B,wBAAA;AAAA,EAC/B,6BAAA,EAA+B,wBAAA;AAAA,EAC/B,oBAAA,EAA6B,eAAA;AAAA,EAC7B,WAAA,EAA6B,MAAA;AAAA,EAC7B,eAAA,EAA6B,UAAA;AAAA,EAC7B,kBAAA,EAA6B,aAAA;AAAA,EAC7B,iBAAA,EAA6B,YAAA;AAAA,EAC7B,iBA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,MAAM,MAAA,CAAO,MAAM,WAAA,EAAa;AAAA,IAC9C,MAAA,EAAQ,KAAK,MAAA,IAAU;AAAA,GACxB,CAAA;AAED,EAAA,OAAO,GAAA;AACT","file":"chunk-33AR3PXF.js","sourcesContent":["import type { BpmnElementType, BpmnEdgeType, EventTrigger } from \"../elements/types\";\n\n// ─── BPMN moddle $type → our BpmnElementType ─────────────────────────────────\n\nexport const MODDLE_TO_ELEMENT_TYPE: Record<string, BpmnElementType | undefined> = {\n \"bpmn:StartEvent\": \"StartEvent\",\n \"bpmn:EndEvent\": \"EndEvent\",\n \"bpmn:IntermediateCatchEvent\": \"IntermediateCatchEvent\",\n \"bpmn:IntermediateThrowEvent\": \"IntermediateThrowEvent\",\n \"bpmn:BoundaryEvent\": \"BoundaryEvent\",\n \"bpmn:Task\": \"Task\",\n \"bpmn:UserTask\": \"UserTask\",\n \"bpmn:ServiceTask\": \"ServiceTask\",\n \"bpmn:ScriptTask\": \"ScriptTask\",\n \"bpmn:ManualTask\": \"ManualTask\",\n \"bpmn:BusinessRuleTask\": \"BusinessRuleTask\",\n \"bpmn:ReceiveTask\": \"ReceiveTask\",\n \"bpmn:SendTask\": \"SendTask\",\n \"bpmn:CallActivity\": \"CallActivity\",\n \"bpmn:ExclusiveGateway\": \"ExclusiveGateway\",\n \"bpmn:InclusiveGateway\": \"InclusiveGateway\",\n \"bpmn:ParallelGateway\": \"ParallelGateway\",\n \"bpmn:EventBasedGateway\": \"EventBasedGateway\",\n \"bpmn:ComplexGateway\": \"ComplexGateway\",\n \"bpmn:SubProcess\": \"SubProcess\",\n \"bpmn:AdHocSubProcess\": \"AdHocSubProcess\",\n \"bpmn:Transaction\": \"Transaction\",\n \"bpmn:TextAnnotation\": \"Annotation\",\n \"bpmn:Group\": \"Group\",\n \"bpmn:DataObject\": \"DataObject\",\n \"bpmn:DataObjectReference\": \"DataObjectReference\",\n \"bpmn:DataInput\": \"DataInput\",\n \"bpmn:DataOutput\": \"DataOutput\",\n \"bpmn:DataStore\": \"DataStore\",\n \"bpmn:DataStoreReference\": \"DataStoreReference\",\n \"bpmn:Conversation\": \"Conversation\",\n \"bpmn:SubConversation\": \"SubConversation\",\n \"bpmn:CallConversation\": \"CallConversation\",\n \"bpmn:ChoreographyTask\": \"ChoreographyTask\",\n \"bpmn:SubChoreography\": \"SubChoreography\",\n \"bpmn:CallChoreography\": \"CallChoreography\",\n \"bpmn:Lane\": \"Lane\",\n};\n\n// ─── Our BpmnElementType → canonical bpmn: type ──────────────────────────────\n\nexport const ELEMENT_TYPE_TO_MODDLE: Partial<Record<BpmnElementType, string>> = {\n StartEvent: \"bpmn:StartEvent\",\n EndEvent: \"bpmn:EndEvent\",\n IntermediateCatchEvent: \"bpmn:IntermediateCatchEvent\",\n IntermediateThrowEvent: \"bpmn:IntermediateThrowEvent\",\n BoundaryEvent: \"bpmn:BoundaryEvent\",\n Task: \"bpmn:Task\",\n UserTask: \"bpmn:UserTask\",\n ServiceTask: \"bpmn:ServiceTask\",\n ScriptTask: \"bpmn:ScriptTask\",\n ManualTask: \"bpmn:ManualTask\",\n BusinessRuleTask: \"bpmn:BusinessRuleTask\",\n ReceiveTask: \"bpmn:ReceiveTask\",\n SendTask: \"bpmn:SendTask\",\n CallActivity: \"bpmn:CallActivity\",\n ExclusiveGateway: \"bpmn:ExclusiveGateway\",\n InclusiveGateway: \"bpmn:InclusiveGateway\",\n ParallelGateway: \"bpmn:ParallelGateway\",\n EventBasedGateway: \"bpmn:EventBasedGateway\",\n ComplexGateway: \"bpmn:ComplexGateway\",\n SubProcess: \"bpmn:SubProcess\",\n Transaction: \"bpmn:Transaction\",\n EventSubProcess: \"bpmn:SubProcess\",\n AdHocSubProcess: \"bpmn:AdHocSubProcess\",\n Pool: \"bpmn:Participant\",\n Lane: \"bpmn:Lane\",\n Annotation: \"bpmn:TextAnnotation\",\n Group: \"bpmn:Group\",\n DataObject: \"bpmn:DataObject\",\n DataObjectReference: \"bpmn:DataObjectReference\",\n DataInput: \"bpmn:DataInput\",\n DataOutput: \"bpmn:DataOutput\",\n DataStore: \"bpmn:DataStore\",\n DataStoreReference: \"bpmn:DataStoreReference\",\n Conversation: \"bpmn:Conversation\",\n SubConversation: \"bpmn:SubConversation\",\n CallConversation: \"bpmn:CallConversation\",\n ChoreographyTask: \"bpmn:ChoreographyTask\",\n SubChoreography: \"bpmn:SubChoreography\",\n CallChoreography: \"bpmn:CallChoreography\",\n};\n\n// ─── Edge type mappings ───────────────────────────────────────────────────────\n\nexport const MODDLE_TO_EDGE_TYPE: Record<string, BpmnEdgeType | undefined> = {\n \"bpmn:SequenceFlow\": \"sequenceFlow\",\n \"bpmn:MessageFlow\": \"messageFlow\",\n \"bpmn:Association\": \"association\",\n \"bpmn:DataInputAssociation\": \"dataAssociation\",\n \"bpmn:DataOutputAssociation\": \"dataAssociation\",\n \"bpmn:ConversationLink\": \"conversationLink\",\n};\n\nexport const EDGE_TYPE_TO_MODDLE: Record<BpmnEdgeType, string> = {\n sequenceFlow: \"bpmn:SequenceFlow\",\n messageFlow: \"bpmn:MessageFlow\",\n association: \"bpmn:Association\",\n dataAssociation: \"bpmn:DataInputAssociation\",\n conversationLink:\"bpmn:ConversationLink\",\n};\n\n// ─── Event definition type → trigger ─────────────────────────────────────────\n\nexport const EVENT_DEF_TO_TRIGGER: Record<string, EventTrigger> = {\n \"bpmn:MessageEventDefinition\": \"message\",\n \"bpmn:TimerEventDefinition\": \"timer\",\n \"bpmn:EscalationEventDefinition\": \"escalation\",\n \"bpmn:ConditionalEventDefinition\": \"conditional\",\n \"bpmn:ErrorEventDefinition\": \"error\",\n \"bpmn:CancelEventDefinition\": \"cancel\",\n \"bpmn:CompensateEventDefinition\": \"compensation\",\n \"bpmn:SignalEventDefinition\": \"signal\",\n \"bpmn:LinkEventDefinition\": \"link\",\n \"bpmn:TerminateEventDefinition\": \"terminate\",\n};\n\nexport const TRIGGER_TO_EVENT_DEF: Partial<Record<EventTrigger, string>> = {\n message: \"bpmn:MessageEventDefinition\",\n timer: \"bpmn:TimerEventDefinition\",\n escalation: \"bpmn:EscalationEventDefinition\",\n conditional: \"bpmn:ConditionalEventDefinition\",\n error: \"bpmn:ErrorEventDefinition\",\n cancel: \"bpmn:CancelEventDefinition\",\n compensation: \"bpmn:CompensateEventDefinition\",\n signal: \"bpmn:SignalEventDefinition\",\n link: \"bpmn:LinkEventDefinition\",\n terminate: \"bpmn:TerminateEventDefinition\",\n};\n","import { BpmnModdle, type ModdleElement } from \"bpmn-moddle\";\nimport { BPMN_ELEMENT_CATALOG } from \"../elements/catalog\";\nimport type { BpmnElementType, BpmnEdgeType, BpmnNodeData, BpmnEdgeData, EventTrigger, SubProcessVariant } from \"../elements/types\";\nimport type { BpmnRFNode, BpmnRFEdge, BpmnImportResult } from \"./types\";\nimport {\n MODDLE_TO_ELEMENT_TYPE,\n MODDLE_TO_EDGE_TYPE,\n EVENT_DEF_TO_TRIGGER,\n} from \"./mapper\";\n\n// ─── Internal helpers ─────────────────────────────────────────────────────────\n\ninterface ShapeInfo {\n x: number;\n y: number;\n width: number;\n height: number;\n isExpanded?: boolean;\n}\n\ntype ShapeMap = Map<string, ShapeInfo>;\ntype WaypointMap = Map<string, Array<{ x: number; y: number }>>;\n\nfunction asElements(v: unknown): ModdleElement[] {\n return Array.isArray(v) ? (v as ModdleElement[]) : [];\n}\n\nfunction asString(v: unknown): string | undefined {\n return typeof v === \"string\" && v.trim() ? v.trim() : undefined;\n}\n\nfunction extractDocumentation(el: ModdleElement): string | undefined {\n const [doc] = asElements(el.documentation);\n return asString(doc?.text);\n}\n\n// ─── Extract BPMNDI shape/edge positions ─────────────────────────────────────\n\nfunction extractDiagramInfo(definitions: ModdleElement): {\n shapes: ShapeMap;\n waypoints: WaypointMap;\n} {\n const shapes: ShapeMap = new Map();\n const waypoints: WaypointMap = new Map();\n\n for (const diagram of asElements(definitions.diagrams)) {\n const plane = diagram.plane as ModdleElement | undefined;\n if (!plane) continue;\n\n for (const el of asElements(plane.planeElement)) {\n const bpmnEl = el.bpmnElement as ModdleElement | undefined;\n if (!bpmnEl?.id) continue;\n const id = bpmnEl.id as string;\n\n if (el.$type === \"bpmndi:BPMNShape\") {\n const b = el.bounds as { x: number; y: number; width: number; height: number } | undefined;\n if (b) {\n shapes.set(id, {\n x: b.x,\n y: b.y,\n width: b.width,\n height: b.height,\n ...(typeof el.isExpanded === \"boolean\" ? { isExpanded: el.isExpanded as boolean } : {}),\n });\n }\n } else if (el.$type === \"bpmndi:BPMNEdge\") {\n const pts = (el.waypoint ?? []) as Array<{ x: number; y: number }>;\n if (pts.length) waypoints.set(id, pts);\n }\n }\n }\n\n return { shapes, waypoints };\n}\n\n// ─── Lane membership (flowNodeId → laneId) ───────────────────────────────────\n\nfunction extractLaneMembership(process: ModdleElement): Map<string, string> {\n const map = new Map<string, string>();\n\n function walkLaneSet(laneSet: ModdleElement) {\n for (const lane of asElements(laneSet.lanes)) {\n const laneId = lane.id as string | undefined;\n if (!laneId) continue;\n for (const ref of asElements(lane.flowNodeRef)) {\n if (ref.id) map.set(ref.id as string, laneId);\n }\n const child = lane.childLaneSet as ModdleElement | undefined;\n if (child) walkLaneSet(child);\n }\n }\n\n const laneSet = process.laneSet as ModdleElement | undefined;\n if (laneSet) walkLaneSet(laneSet);\n return map;\n}\n\n// ─── Event trigger from eventDefinitions ─────────────────────────────────────\n\nfunction extractTrigger(el: ModdleElement): EventTrigger | undefined {\n const defs = asElements(el.eventDefinitions);\n if (defs.length === 0) return undefined;\n if (defs.length > 1) return el.$type.includes(\"Parallel\") ? \"parallelMultiple\" : \"multiple\";\n return EVENT_DEF_TO_TRIGGER[defs[0].$type];\n}\n\n// ─── SubProcessVariant from moddle type / properties ─────────────────────────\n\nfunction extractSubProcessVariant(el: ModdleElement): SubProcessVariant | undefined {\n if (el.$type === \"bpmn:Transaction\") return \"transaction\";\n if (el.$type === \"bpmn:AdHocSubProcess\") return \"adhoc\";\n if (el.$type === \"bpmn:SubProcess\" && el.triggeredByEvent === true) return \"event\";\n if (el.triggeredByEvent === true) return \"event\";\n return \"embedded\";\n}\n\n// ─── Walk a flowElements list, producing nodes and edges ─────────────────────\n\ninterface WalkContext {\n shapes: ShapeMap;\n waypoints: WaypointMap;\n laneMembership: Map<string, string>;\n warnings: string[];\n autoX: { value: number };\n}\n\nfunction walkFlowElements(\n elements: ModdleElement[],\n parentId: string | undefined,\n ctx: WalkContext,\n nodes: BpmnRFNode[],\n edges: BpmnRFEdge[],\n) {\n for (const el of elements) {\n const { $type, id } = el;\n if (!id) continue;\n\n const edgeType = MODDLE_TO_EDGE_TYPE[$type];\n if (edgeType !== undefined) {\n buildEdge(el, edgeType, ctx, edges);\n continue;\n }\n\n // Lane nodes are handled separately via laneMembership\n if ($type === \"bpmn:LaneSet\") continue;\n\n const elementType =\n $type === \"bpmn:SubProcess\" && el.triggeredByEvent === true\n ? \"EventSubProcess\"\n : MODDLE_TO_ELEMENT_TYPE[$type];\n if (!elementType) {\n ctx.warnings.push(`Unknown element type \"${$type}\" (id=${id as string}) — skipped.`);\n continue;\n }\n\n buildNode(el, elementType, parentId, ctx, nodes);\n\n // Recurse into subprocess children\n if ($type === \"bpmn:SubProcess\" || $type === \"bpmn:Transaction\" || $type === \"bpmn:AdHocSubProcess\") {\n const children = asElements(el.flowElements);\n const laneMembership = extractLaneMembership(el);\n walkFlowElements(children, id as string, { ...ctx, laneMembership }, nodes, edges);\n }\n }\n}\n\nfunction buildNode(\n el: ModdleElement,\n elementType: BpmnElementType,\n parentId: string | undefined,\n ctx: WalkContext,\n nodes: BpmnRFNode[],\n) {\n const id = el.id as string;\n const meta = BPMN_ELEMENT_CATALOG[elementType];\n const shape = ctx.shapes.get(id);\n\n // Position: use BPMNDI if available, otherwise auto-grid\n const x = shape?.x ?? ctx.autoX.value;\n const y = shape?.y ?? 100;\n if (!shape) ctx.autoX.value += (meta?.defaultWidth ?? 120) + 20;\n\n const label = asString(el.name);\n const documentation = extractDocumentation(el);\n const trigger = extractTrigger(el);\n const isNonInterrupting = el.cancelActivity === false;\n const attachedToRef = (el.attachedToRef as ModdleElement | undefined)?.id as string | undefined;\n\n const data: BpmnNodeData = {\n elementType,\n ...(label ? { label } : {}),\n ...(documentation ? { documentation } : {}),\n ...(trigger ? { trigger } : {}),\n ...(isNonInterrupting ? { isNonInterrupting: true } : {}),\n ...(attachedToRef ? { attachedToRef } : {}),\n };\n\n // SubProcess variant\n if (elementType === \"SubProcess\" || elementType === \"Transaction\" || elementType === \"EventSubProcess\" || elementType === \"AdHocSubProcess\") {\n const variant = extractSubProcessVariant(el);\n if (variant) data.subProcessVariant = variant;\n const isExpanded = shape?.isExpanded ?? true;\n data.isExpanded = isExpanded;\n }\n\n // Determine effective parentId: lane membership overrides process-level parent\n const laneId = ctx.laneMembership.get(id);\n const effectiveParentId = attachedToRef ?? laneId ?? parentId;\n\n const node: BpmnRFNode = {\n id,\n type: elementType,\n position: { x, y },\n data,\n width: shape?.width ?? meta?.defaultWidth,\n height: shape?.height ?? meta?.defaultHeight,\n ...(effectiveParentId ? { parentId: effectiveParentId } : {}),\n };\n\n nodes.push(node);\n}\n\nfunction buildEdge(\n el: ModdleElement,\n edgeType: BpmnEdgeType,\n ctx: WalkContext,\n edges: BpmnRFEdge[],\n) {\n const id = el.id as string;\n const source = (el.sourceRef as ModdleElement | undefined)?.id as string | undefined;\n const target = (el.targetRef as ModdleElement | undefined)?.id as string | undefined;\n\n if (!source || !target) {\n ctx.warnings.push(`Edge \"${id}\" missing source or target — skipped.`);\n return;\n }\n\n const label = asString(el.name);\n const documentation = extractDocumentation(el);\n const condExpr = el.conditionExpression as { body?: string } | undefined;\n\n const data: BpmnEdgeData = {\n edgeType,\n ...(label ? { label } : {}),\n ...(documentation ? { documentation } : {}),\n ...(condExpr?.body ? { conditionExpression: condExpr.body } : {}),\n };\n\n const waypoints = ctx.waypoints.get(id);\n if (waypoints?.length) data.routingPoints = waypoints;\n\n edges.push({ id, type: edgeType, source, target, data });\n}\n\n// ─── Handle Collaboration: Participants → Pool nodes ──────────────────────────\n\nfunction handleCollaboration(\n collaboration: ModdleElement,\n ctx: WalkContext,\n nodes: BpmnRFNode[],\n edges: BpmnRFEdge[],\n) {\n // Participants become Pool nodes\n for (const participant of asElements(collaboration.participants)) {\n const id = participant.id as string | undefined;\n if (!id) continue;\n const label = asString(participant.name);\n const shape = ctx.shapes.get(id);\n\n const poolNode: BpmnRFNode = {\n id,\n type: \"Pool\",\n position: { x: shape?.x ?? 0, y: shape?.y ?? 0 },\n data: { elementType: \"Pool\", ...(label ? { label } : {}) },\n width: shape?.width ?? 600,\n height: shape?.height ?? 200,\n };\n nodes.push(poolNode);\n\n // Walk the referenced process, assigning pool as parent\n const processRef = participant.processRef as ModdleElement | undefined;\n if (processRef) {\n const laneMembership = extractLaneMembership(processRef);\n walkFlowElements(\n asElements(processRef.flowElements),\n id,\n { ...ctx, laneMembership },\n nodes,\n edges,\n );\n\n // Add Lane nodes\n const laneSet = processRef.laneSet as ModdleElement | undefined;\n if (laneSet) {\n addLaneNodes(laneSet, id, ctx, nodes);\n }\n }\n }\n\n // Message flows\n for (const mf of asElements(collaboration.messageFlows)) {\n buildEdge(mf, \"messageFlow\", ctx, edges);\n }\n\n // Conversation links\n for (const cl of asElements(collaboration.conversationLinks)) {\n buildEdge(cl, \"conversationLink\", ctx, edges);\n }\n}\n\nfunction addLaneNodes(\n laneSet: ModdleElement,\n poolId: string,\n ctx: WalkContext,\n nodes: BpmnRFNode[],\n) {\n for (const lane of asElements(laneSet.lanes)) {\n const id = lane.id as string | undefined;\n if (!id) continue;\n const label = asString(lane.name);\n const shape = ctx.shapes.get(id);\n\n nodes.push({\n id,\n type: \"Lane\",\n position: { x: shape?.x ?? 30, y: shape?.y ?? 0 },\n data: { elementType: \"Lane\", ...(label ? { label } : {}) },\n width: shape?.width ?? 570,\n height: shape?.height ?? 120,\n parentId: poolId,\n });\n\n const child = lane.childLaneSet as ModdleElement | undefined;\n if (child) addLaneNodes(child, poolId, ctx, nodes);\n }\n}\n\n// ─── Public: parseBpmnXml ─────────────────────────────────────────────────────\n\nexport async function parseBpmnXml(xml: string): Promise<BpmnImportResult> {\n const moddle = new BpmnModdle();\n const warnings: string[] = [];\n\n let rootElement: ModdleElement;\n try {\n const result = await moddle.fromXML(xml);\n rootElement = result.rootElement;\n for (const w of result.warnings) warnings.push(w.message);\n } catch (err) {\n throw new Error(`Failed to parse BPMN XML: ${String(err)}`);\n }\n\n const nodes: BpmnRFNode[] = [];\n const edges: BpmnRFEdge[] = [];\n\n const { shapes, waypoints } = extractDiagramInfo(rootElement);\n const ctx: WalkContext = {\n shapes,\n waypoints,\n laneMembership: new Map(),\n warnings,\n autoX: { value: 50 },\n };\n\n for (const rootEl of asElements(rootElement.rootElements)) {\n if (rootEl.$type === \"bpmn:Collaboration\") {\n handleCollaboration(rootEl, ctx, nodes, edges);\n } else if (rootEl.$type === \"bpmn:Process\") {\n const laneMembership = extractLaneMembership(rootEl);\n const laneSet = rootEl.laneSet as ModdleElement | undefined;\n if (laneSet) addLaneNodes(laneSet, \"\", ctx, nodes);\n walkFlowElements(\n asElements(rootEl.flowElements),\n undefined,\n { ...ctx, laneMembership },\n nodes,\n edges,\n );\n }\n }\n\n const defaultFlowById = new Set<string>();\n const nodeIds = new Set(nodes.map((node) => node.id));\n for (const rootEl of asElements(rootElement.rootElements)) {\n collectDefaultFlows(rootEl, defaultFlowById);\n }\n\n const normalizedEdges: BpmnRFEdge[] = edges.map((edge) => {\n if (!defaultFlowById.has(edge.id)) return edge;\n const data: BpmnEdgeData = {\n edgeType: edge.data?.edgeType ?? (edge.type as BpmnEdgeType),\n ...(edge.data ?? {}),\n isDefault: true,\n };\n return { ...edge, data };\n });\n\n return {\n nodes: normalizeChildPositions(nodes, nodeIds),\n edges: normalizedEdges,\n warnings,\n };\n}\n\nfunction collectDefaultFlows(el: ModdleElement, defaultFlowById: Set<string>): void {\n const defaultRef = el.default as ModdleElement | undefined;\n if (defaultRef?.id) defaultFlowById.add(defaultRef.id as string);\n\n for (const child of asElements(el.rootElements)) collectDefaultFlows(child, defaultFlowById);\n for (const child of asElements(el.flowElements)) collectDefaultFlows(child, defaultFlowById);\n}\n\nfunction normalizeChildPositions(nodes: BpmnRFNode[], nodeIds: Set<string>): BpmnRFNode[] {\n const absoluteById = new Map(nodes.map((node) => [node.id, node.position]));\n\n return nodes.map((node) => {\n if (!node.parentId || !nodeIds.has(node.parentId)) return node;\n const parentPosition = absoluteById.get(node.parentId);\n if (!parentPosition) return node;\n\n return {\n ...node,\n position: {\n x: node.position.x - parentPosition.x,\n y: node.position.y - parentPosition.y,\n },\n };\n });\n}\n","import { BpmnModdle, type ModdleElement } from \"bpmn-moddle\";\nimport { BPMN_ELEMENT_CATALOG } from \"../elements/catalog\";\nimport type { BpmnRFNode, BpmnRFEdge, BpmnExportOptions } from \"./types\";\nimport {\n ELEMENT_TYPE_TO_MODDLE,\n EDGE_TYPE_TO_MODDLE,\n TRIGGER_TO_EVENT_DEF,\n} from \"./mapper\";\n\n// ─── Helpers ──────────────────────────────────────────────────────────────────\n\nfunction uid(prefix: string, id: string): string {\n return `${prefix}_${id}`;\n}\n\nfunction asNodes(nodes: BpmnRFNode[], types: string[]): BpmnRFNode[] {\n return nodes.filter((n) => types.includes(n.data.elementType));\n}\n\n// ─── Build BPMN semantic model ────────────────────────────────────────────────\n\nfunction buildSemanticModel(\n moddle: BpmnModdle,\n nodes: BpmnRFNode[],\n edges: BpmnRFEdge[],\n opts: BpmnExportOptions,\n): ModdleElement {\n const defId = opts.id ?? \"Definitions_1\";\n const defName = opts.name;\n\n // Collect pool nodes → Collaboration + Participants\n const poolNodes = asNodes(nodes, [\"Pool\"]);\n const laneNodes = asNodes(nodes, [\"Lane\"]);\n const isCollaboration = poolNodes.length > 0;\n\n const definitions = moddle.create(\"bpmn:Definitions\", {\n id: defId,\n targetNamespace: \"http://bpmn.io/schema/bpmn\",\n ...(defName ? { name: defName } : {}),\n });\n // Flowable namespace: bpmn-moddle serializes xmlns:* from the element's own namespace map.\n // Injected via the moddle descriptor when a full Flowable extension is loaded.\n // For now, individual elements declare their own flowable:* attributes via $attrs.\n\n const rootElements: ModdleElement[] = [];\n\n if (isCollaboration) {\n const participants: ModdleElement[] = [];\n const processes: ModdleElement[] = [];\n\n for (const pool of poolNodes) {\n const processId = `Process_${pool.id}`;\n const process = buildProcess(moddle, nodes, edges, pool.id, laneNodes, processId);\n processes.push(process);\n\n const participant = moddle.create(\"bpmn:Participant\", {\n id: pool.id,\n name: pool.data.label ?? \"\",\n processRef: process,\n });\n participants.push(participant);\n }\n\n // Message flows and conversation links belong to collaboration\n const messageFlowEdges = edges.filter((e) => e.data?.edgeType === \"messageFlow\");\n const conversationLinkEdges = edges.filter((e) => e.data?.edgeType === \"conversationLink\");\n\n const messageFlows = messageFlowEdges.map((e) =>\n moddle.create(\"bpmn:MessageFlow\", {\n id: e.id,\n name: e.data?.label ?? \"\",\n sourceRef: { id: e.source },\n targetRef: { id: e.target },\n }),\n );\n\n const conversationLinks = conversationLinkEdges.map((e) =>\n moddle.create(\"bpmn:ConversationLink\", {\n id: e.id,\n sourceRef: { id: e.source },\n targetRef: { id: e.target },\n }),\n );\n\n const collaboration = moddle.create(\"bpmn:Collaboration\", {\n id: `Collaboration_${defId}`,\n participants,\n messageFlows,\n conversationLinks,\n });\n\n rootElements.push(collaboration, ...processes);\n } else {\n // Single process — no collaboration\n const process = buildProcess(moddle, nodes, edges, undefined, laneNodes, \"Process_1\");\n rootElements.push(process);\n }\n\n (definitions as Record<string, unknown>).rootElements = rootElements;\n return definitions;\n}\n\n// Build a bpmn:Process element containing flow nodes and sequence flows\nfunction buildProcess(\n moddle: BpmnModdle,\n allNodes: BpmnRFNode[],\n allEdges: BpmnRFEdge[],\n poolId: string | undefined,\n laneNodes: BpmnRFNode[],\n processId: string,\n): ModdleElement {\n // Collect flow nodes that belong to this pool (or all if no pools)\n const subProcessIds = new Set(\n allNodes\n .filter((n) =>\n n.data.elementType === \"SubProcess\" ||\n n.data.elementType === \"Transaction\" ||\n n.data.elementType === \"EventSubProcess\" ||\n n.data.elementType === \"AdHocSubProcess\",\n )\n .map((n) => n.id),\n );\n const isInsideSubProcess = (node: BpmnRFNode) => {\n let parentId = node.parentId;\n while (parentId) {\n if (subProcessIds.has(parentId)) return true;\n parentId = allNodes.find((candidate) => candidate.id === parentId)?.parentId;\n }\n return false;\n };\n\n const belongsToPool = (node: BpmnRFNode): boolean => {\n let parentId = node.parentId;\n while (parentId) {\n if (parentId === poolId) return true;\n parentId = allNodes.find((candidate) => candidate.id === parentId)?.parentId;\n }\n return false;\n };\n\n const myNodes = (poolId\n ? allNodes.filter((n) => belongsToPool(n))\n : allNodes.filter((n) => n.data.elementType !== \"Pool\" && n.data.elementType !== \"Lane\"))\n .filter((n) => !isInsideSubProcess(n));\n\n const myLanes = laneNodes.filter((l) => (poolId ? l.parentId === poolId : true));\n\n // Build flow elements\n const flowElements: ModdleElement[] = [];\n\n for (const node of myNodes) {\n const el = buildFlowElement(moddle, node, allNodes, allEdges);\n if (el) flowElements.push(el);\n }\n\n // Sequence flows and associations\n const myNodeIds = new Set(myNodes.map((n) => n.id));\n const myEdges = allEdges.filter(\n (e) =>\n (e.data?.edgeType === \"sequenceFlow\" ||\n e.data?.edgeType === \"association\" ||\n e.data?.edgeType === \"dataAssociation\") &&\n myNodeIds.has(e.source) &&\n myNodeIds.has(e.target),\n );\n\n for (const edge of myEdges) {\n const edgeMeta = buildEdgeElement(moddle, edge);\n if (edgeMeta) flowElements.push(edgeMeta);\n }\n\n const elementById = new Map(\n flowElements\n .filter((element) => typeof element.id === \"string\")\n .map((element) => [element.id as string, element]),\n );\n for (const edge of myEdges) {\n if (!edge.data?.isDefault) continue;\n const sourceElement = elementById.get(edge.source);\n const edgeElement = elementById.get(edge.id);\n if (sourceElement && edgeElement) {\n (sourceElement as Record<string, unknown>).default = edgeElement;\n }\n }\n\n const process = moddle.create(\"bpmn:Process\", {\n id: processId,\n isExecutable: true,\n flowElements,\n });\n\n // Lane set\n if (myLanes.length > 0) {\n const laneElements = myLanes.map((l) =>\n moddle.create(\"bpmn:Lane\", {\n id: l.id,\n name: l.data.label ?? \"\",\n flowNodeRef: myNodes\n .filter((n) => n.parentId === l.id)\n .map((n) => ({ id: n.id })),\n }),\n );\n (process as Record<string, unknown>).laneSet = moddle.create(\"bpmn:LaneSet\", {\n id: `LaneSet_${processId}`,\n lanes: laneElements,\n });\n }\n\n return process;\n}\n\nfunction buildFlowElement(\n moddle: BpmnModdle,\n node: BpmnRFNode,\n allNodes: BpmnRFNode[],\n allEdges: BpmnRFEdge[],\n): ModdleElement | null {\n const { elementType, label, trigger } = node.data;\n\n // Pools and Lanes are handled in buildProcess / collaboration\n if (elementType === \"Pool\" || elementType === \"Lane\") return null;\n\n const moddleType = ELEMENT_TYPE_TO_MODDLE[elementType];\n if (!moddleType) return null;\n\n const attrs: Record<string, unknown> = {\n id: node.id,\n name: label ?? \"\",\n };\n\n if (node.data.documentation) {\n attrs.documentation = [\n moddle.create(\"bpmn:Documentation\", { text: node.data.documentation }),\n ];\n }\n\n // Event definitions\n if (trigger && trigger !== \"none\") {\n const defType = TRIGGER_TO_EVENT_DEF[trigger];\n if (defType) {\n attrs.eventDefinitions = [moddle.create(defType, { id: uid(\"EventDef\", node.id) })];\n }\n }\n\n if (elementType === \"BoundaryEvent\") {\n attrs.attachedToRef = { id: node.data.attachedToRef ?? node.parentId };\n attrs.cancelActivity = node.data.isNonInterrupting ? false : true;\n }\n\n const isSubProcess =\n elementType === \"SubProcess\" ||\n elementType === \"Transaction\" ||\n elementType === \"EventSubProcess\" ||\n elementType === \"AdHocSubProcess\";\n\n if (isSubProcess) {\n attrs.flowElements = buildNestedFlowElements(moddle, node, allNodes, allEdges);\n if (elementType === \"EventSubProcess\" || node.data.subProcessVariant === \"event\") {\n attrs.triggeredByEvent = true;\n }\n }\n\n const element = moddle.create(moddleType, attrs);\n\n return element;\n}\n\nfunction buildNestedFlowElements(\n moddle: BpmnModdle,\n parent: BpmnRFNode,\n allNodes: BpmnRFNode[],\n allEdges: BpmnRFEdge[],\n): ModdleElement[] {\n const childNodes = allNodes.filter((node) => node.parentId === parent.id);\n const childNodeIds = new Set(childNodes.map((node) => node.id));\n const flowElements: ModdleElement[] = [];\n\n for (const child of childNodes) {\n const element = buildFlowElement(moddle, child, allNodes, allEdges);\n if (element) flowElements.push(element);\n }\n\n for (const edge of allEdges) {\n if (!childNodeIds.has(edge.source) || !childNodeIds.has(edge.target)) continue;\n const element = buildEdgeElement(moddle, edge);\n if (element) flowElements.push(element);\n }\n\n return flowElements;\n}\n\nfunction buildEdgeElement(moddle: BpmnModdle, edge: BpmnRFEdge): ModdleElement | null {\n if (!edge.data) return null;\n const moddleType = EDGE_TYPE_TO_MODDLE[edge.data.edgeType];\n if (!moddleType) return null;\n\n const attrs: Record<string, unknown> = {\n id: edge.id,\n name: edge.data.label ?? \"\",\n sourceRef: { id: edge.source },\n targetRef: { id: edge.target },\n };\n\n if (edge.data.documentation) {\n attrs.documentation = [\n moddle.create(\"bpmn:Documentation\", { text: edge.data.documentation }),\n ];\n }\n\n if (edge.data.conditionExpression) {\n attrs.conditionExpression = moddle.create(\"bpmn:FormalExpression\", {\n body: edge.data.conditionExpression,\n });\n }\n\n return moddle.create(moddleType, attrs);\n}\n\n// ─── Build BPMNDI (diagram interchange / layout) ─────────────────────────────\n\nfunction buildBpmnDI(\n moddle: BpmnModdle,\n definitions: ModdleElement,\n nodes: BpmnRFNode[],\n edges: BpmnRFEdge[],\n): void {\n const shapes: ModdleElement[] = [];\n const edgeShapes: ModdleElement[] = [];\n\n const absolutePositionById = buildAbsolutePositionMap(nodes);\n\n for (const node of nodes) {\n const meta = BPMN_ELEMENT_CATALOG[node.data.elementType];\n const w = node.width ?? meta?.defaultWidth ?? 120;\n const h = node.height ?? meta?.defaultHeight ?? 60;\n\n const bounds = moddle.create(\"dc:Bounds\", {\n x: absolutePositionById.get(node.id)?.x ?? node.position.x,\n y: absolutePositionById.get(node.id)?.y ?? node.position.y,\n width: w,\n height: h,\n });\n\n const shape = moddle.create(\"bpmndi:BPMNShape\", {\n id: uid(\"BPMNShape\", node.id),\n bpmnElement: { id: node.id },\n bounds,\n });\n\n if (node.data.isExpanded !== undefined) {\n (shape as Record<string, unknown>).isExpanded = node.data.isExpanded;\n }\n\n shapes.push(shape);\n }\n\n for (const edge of edges) {\n const waypoints = resolveEdgeWaypoints(edge, nodes, absolutePositionById).map((p) =>\n moddle.create(\"dc:Point\", { x: p.x, y: p.y }),\n );\n\n edgeShapes.push(\n moddle.create(\"bpmndi:BPMNEdge\", {\n id: uid(\"BPMNEdge\", edge.id),\n bpmnElement: { id: edge.id },\n waypoint: waypoints,\n }),\n );\n }\n\n // Find the main process / collaboration element\n const rootEls = (definitions as Record<string, unknown>).rootElements as ModdleElement[] | undefined;\n const planeElement = rootEls?.[0];\n\n const plane = moddle.create(\"bpmndi:BPMNPlane\", {\n id: \"BPMNPlane_1\",\n bpmnElement: planeElement ?? { id: \"unknown\" },\n planeElement: [...shapes, ...edgeShapes],\n });\n\n const diagram = moddle.create(\"bpmndi:BPMNDiagram\", {\n id: \"BPMNDiagram_1\",\n plane,\n });\n\n (definitions as Record<string, unknown>).diagrams = [diagram];\n}\n\nfunction resolveEdgeWaypoints(\n edge: BpmnRFEdge,\n nodes: BpmnRFNode[],\n absolutePositionById: Map<string, { x: number; y: number }>,\n): Array<{ x: number; y: number }> {\n if (edge.data?.routingPoints && edge.data.routingPoints.length >= 2) {\n return edge.data.routingPoints;\n }\n\n const source = nodes.find((node) => node.id === edge.source);\n const target = nodes.find((node) => node.id === edge.target);\n if (!source || !target) return [];\n\n const sourceMeta = BPMN_ELEMENT_CATALOG[source.data.elementType];\n const targetMeta = BPMN_ELEMENT_CATALOG[target.data.elementType];\n const sourcePosition = absolutePositionById.get(source.id) ?? source.position;\n const targetPosition = absolutePositionById.get(target.id) ?? target.position;\n return [\n {\n x: sourcePosition.x + (source.width ?? sourceMeta.defaultWidth) / 2,\n y: sourcePosition.y + (source.height ?? sourceMeta.defaultHeight) / 2,\n },\n {\n x: targetPosition.x + (target.width ?? targetMeta.defaultWidth) / 2,\n y: targetPosition.y + (target.height ?? targetMeta.defaultHeight) / 2,\n },\n ];\n}\n\nfunction buildAbsolutePositionMap(nodes: BpmnRFNode[]): Map<string, { x: number; y: number }> {\n const nodeById = new Map(nodes.map((node) => [node.id, node]));\n const absoluteById = new Map<string, { x: number; y: number }>();\n\n function resolve(node: BpmnRFNode): { x: number; y: number } {\n const cached = absoluteById.get(node.id);\n if (cached) return cached;\n\n const parent = node.parentId ? nodeById.get(node.parentId) : undefined;\n const parentPosition = parent ? resolve(parent) : { x: 0, y: 0 };\n const absolute = {\n x: parentPosition.x + node.position.x,\n y: parentPosition.y + node.position.y,\n };\n absoluteById.set(node.id, absolute);\n return absolute;\n }\n\n for (const node of nodes) resolve(node);\n return absoluteById;\n}\n\n// ─── Public: serializeBpmnXml ─────────────────────────────────────────────────\n\nexport async function serializeBpmnXml(\n nodes: BpmnRFNode[],\n edges: BpmnRFEdge[],\n opts: BpmnExportOptions = {},\n): Promise<string> {\n const moddle = new BpmnModdle();\n\n const definitions = buildSemanticModel(moddle, nodes, edges, opts);\n buildBpmnDI(moddle, definitions, nodes, edges);\n\n const { xml } = await moddle.toXML(definitions, {\n format: opts.format ?? true,\n });\n\n return xml;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/modeling/index.ts"],"names":[],"mappings":";;;;;AAyIO,SAAS,eAAe,OAAA,EAA4C;AACzE,EAAA,MAAM,IAAA,GAAO,kBAAA,CAAmB,OAAA,CAAQ,WAAW,CAAA;AACnD,EAAA,MAAM,IAAA,GAAO,oBAAA,CAAqB,OAAA,CAAQ,WAAW,CAAA;AACrD,EAAA,MAAM,WAAA,GAAc,OAAA,CAAQ,IAAA,EAAM,WAAA,IAAe,IAAA,CAAK,WAAA;AACtD,EAAA,MAAM,UAAA,GAAa,yBAAA,CAA0B,OAAA,CAAQ,WAAW,CAAA;AAChE,EAAA,OAAO;AAAA,IACL,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A,MAAM,QAAA,GAAW,qBAA6C,IAAI,CAAA;AAClE,EAAA,IAAI,QAAA,CAAS,WAAA,IAAe,QAAA,CAAS,WAAA,KAAgB,MAAA,EAAQ;AAC3D,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,4CAAA,EAA+C,QAAA,CAAS,WAAW,CAAA,EAAA,CAAI,CAAA;AAAA,EACzF;AACA,EAAA,OAAO,QAAA;AACT;AAEO,SAAS,uBAAuB,IAAA,EAAgC;AACrE,EAAA,MAAM,QAAA,GAAW,yBAAyB,IAAI,CAAA;AAC9C,EAAA,OAAO,kBAAA,CAA2C,IAAA,CAAK,SAAA,CAAU,QAAQ,CAAC,CAAA;AAC5E;AAEO,SAAS,cAAA,CACd,OACA,OAAA,EAC2C;AAC3C,EAAA,OAAO,cAAA,CAAe,OAAO,OAAO,CAAA;AACtC;AAEO,SAAS,eAAA,CACd,KAAA,EACA,QAAA,EACA,OAAA,GAA2C,EAAC,EACD;AAC3C,EAAA,OAAO,eAAA,CAAgB,KAAA,EAAO,QAAA,EAAU,OAAO,CAAA;AACjD","file":"chunk-7MKU37XQ.js","sourcesContent":["import {\n addNode,\n connectNodes,\n copyElements,\n createModelingRules,\n createSelectionState,\n executeCommand,\n executeCommands,\n findContainingNode,\n getNode,\n getNodeAbsolutePosition,\n getNodeCenterPosition,\n getNodeSize,\n getOutgoingEdges,\n getIncomingEdges,\n normalizeDiagramState,\n pasteElements,\n patchEdge,\n patchNode,\n removeElements,\n replaceNode,\n reparentNode,\n resizeNode,\n setSelection,\n toRelativeNodePosition,\n type CommandStackState,\n type ClipboardState,\n type ConnectionValidator,\n type DiagramCommand,\n type DiagramState,\n type ModelingRules,\n type SelectionState,\n} from \"@aranzatech/diagrams-core\";\nimport {\n createDiagramDocument,\n deserializeDiagram,\n parseDiagramDocument,\n serializeDiagram,\n type CreateDiagramDocumentOptions,\n type DiagramDocument,\n} from \"@aranzatech/diagrams-core/serialization\";\nimport {\n BPMN_ELEMENT_CATALOG,\n getBpmnElementSize,\n isBpmnElementResizable,\n} from \"../elements/catalog\";\nimport {\n acceptsBoundaryEvents,\n getHandlePolicy,\n isDataType,\n isEventType,\n isGatewayType,\n} from \"../elements/guards\";\nimport type { BpmnElementType, BpmnEdgeData, BpmnEdgeType, BpmnNodeData } from \"../elements/types\";\nimport type { BpmnRFEdge, BpmnRFNode } from \"../xml/types\";\n\nexport { getBpmnElementSize, isBpmnElementResizable } from \"../elements/catalog\";\n\nexport type BpmnDiagramState = DiagramState<BpmnRFNode, BpmnRFEdge>;\nexport type BpmnClipboardState = ClipboardState<BpmnRFNode, BpmnRFEdge>;\nexport type BpmnDiagramDocument = DiagramDocument<BpmnRFNode, BpmnRFEdge>;\n\nexport interface CreateBpmnNodeOptions {\n id: string;\n elementType: BpmnElementType;\n position: { x: number; y: number };\n label?: string;\n parentId?: string;\n width?: number;\n height?: number;\n data?: Partial<BpmnNodeData>;\n}\n\nexport interface ConnectBpmnOptions {\n id?: string;\n source: string;\n target: string;\n edgeType?: BpmnEdgeType;\n label?: string;\n sourceHandle?: string | null;\n targetHandle?: string | null;\n data?: Partial<BpmnEdgeData>;\n}\n\nexport interface ReplaceBpmnNodeOptions {\n id: string;\n elementType: BpmnElementType;\n label?: string;\n data?: Partial<BpmnNodeData>;\n width?: number;\n height?: number;\n}\n\nexport interface ReparentBpmnNodeOptions {\n id: string;\n parentId?: string;\n position?: { x: number; y: number };\n}\n\nexport interface FindBpmnContainerAtOptions {\n position: { x: number; y: number };\n excludeId?: string;\n}\n\nexport interface ReparentBpmnNodeAtPositionOptions {\n id: string;\n position: { x: number; y: number };\n}\n\nexport interface ResizeBpmnNodeOptions {\n id: string;\n width?: number;\n height?: number;\n}\n\nexport interface ReorderBpmnLaneOptions {\n poolId: string;\n laneId: string;\n index: number;\n}\n\nexport interface MoveBpmnLaneOptions {\n poolId: string;\n laneId: string;\n position: { x: number; y: number };\n}\n\nexport interface RouteBpmnEdgeOptions {\n id: string;\n routingPoints: Array<{ x: number; y: number }>;\n}\n\nexport interface PasteBpmnOptions {\n offset?: { x: number; y: number };\n position?: { x: number; y: number };\n}\n\nexport function createBpmnNode(options: CreateBpmnNodeOptions): BpmnRFNode {\n const size = getBpmnElementSize(options.elementType);\n const meta = BPMN_ELEMENT_CATALOG[options.elementType];\n const orientation = options.data?.orientation ?? meta.orientation;\n const dragHandle = getBpmnDragHandleSelector(options.elementType);\n return {\n id: options.id,\n type: options.elementType,\n position: options.position,\n data: {\n elementType: options.elementType,\n orientation,\n ...(options.label ? { label: options.label } : {}),\n ...(options.data ?? {}),\n },\n width: options.width ?? size.width,\n height: options.height ?? size.height,\n zIndex: getBpmnNodeZIndex(options.elementType),\n ...(options.parentId ? { parentId: options.parentId } : {}),\n ...(options.elementType === \"Lane\" && options.parentId ? { extent: \"parent\" as const } : {}),\n ...(dragHandle ? { dragHandle } : {}),\n };\n}\n\nexport function getBpmnNodeZIndex(elementType: BpmnElementType): number {\n if (elementType === \"Pool\") return 0;\n if (elementType === \"Lane\") return 1;\n if (elementType === \"BoundaryEvent\") return 4;\n return 3;\n}\n\nexport function withBpmnNodeZIndexes(\n nodes: BpmnRFNode[],\n): BpmnRFNode[] {\n return nodes.map((node) => {\n const zIndex = getBpmnNodeZIndex(node.data.elementType);\n return node.zIndex === zIndex ? node : { ...node, zIndex };\n });\n}\n\nexport const BPMN_POOL_LANE_LAYOUT = {\n poolHeaderSize: 30,\n laneHeaderSize: 24,\n laneGap: 0,\n verticalPoolHeaderSize: 28,\n minLaneSize: 96,\n} as const;\n\nexport function getBpmnDragHandleSelector(\n elementType: BpmnElementType,\n): string | undefined {\n if (elementType === \"Pool\") return \".pool-drag-handle\";\n if (elementType === \"Lane\") return \".lane-drag-handle\";\n return undefined;\n}\n\nexport const BPMN_SELECTION_STYLE = {\n nodeOutline: \"#2563eb\",\n edgeStroke: \"#2563eb\",\n handleFill: \"#ffffff\",\n handleStroke: \"#2563eb\",\n resizeHandleSize: 8,\n routingPointRadius: 5,\n} as const;\n\nexport const BPMN_ROUTABLE_EDGE_TYPES = [\n \"sequenceFlow\",\n \"messageFlow\",\n \"association\",\n \"dataAssociation\",\n \"conversationLink\",\n] satisfies BpmnEdgeType[];\n\nexport interface BpmnConnectionRule {\n edgeType: BpmnEdgeType;\n sourceCategories: Array<BpmnRFNode[\"data\"][\"elementType\"] | \"flowNode\" | \"data\" | \"artifact\" | \"conversation\">;\n targetCategories: Array<BpmnRFNode[\"data\"][\"elementType\"] | \"flowNode\" | \"data\" | \"artifact\" | \"conversation\">;\n allowSameParent?: boolean;\n allowDifferentParent?: boolean;\n}\n\nexport const BPMN_EDGE_CONNECTION_RULES: Record<BpmnEdgeType, BpmnConnectionRule> = {\n sequenceFlow: {\n edgeType: \"sequenceFlow\",\n sourceCategories: [\"flowNode\"],\n targetCategories: [\"flowNode\"],\n allowSameParent: true,\n allowDifferentParent: false,\n },\n messageFlow: {\n edgeType: \"messageFlow\",\n sourceCategories: [\"flowNode\"],\n targetCategories: [\"flowNode\"],\n allowSameParent: false,\n allowDifferentParent: true,\n },\n association: {\n edgeType: \"association\",\n sourceCategories: [\"flowNode\", \"artifact\", \"data\"],\n targetCategories: [\"flowNode\", \"artifact\", \"data\"],\n allowSameParent: true,\n allowDifferentParent: true,\n },\n dataAssociation: {\n edgeType: \"dataAssociation\",\n sourceCategories: [\"flowNode\", \"data\"],\n targetCategories: [\"flowNode\", \"data\"],\n allowSameParent: true,\n allowDifferentParent: true,\n },\n conversationLink: {\n edgeType: \"conversationLink\",\n sourceCategories: [\"conversation\", \"flowNode\"],\n targetCategories: [\"conversation\", \"flowNode\"],\n allowSameParent: true,\n allowDifferentParent: true,\n },\n};\n\nexport function inferBpmnEdgeType(\n state: BpmnDiagramState,\n sourceId: string,\n targetId: string,\n): BpmnEdgeType {\n const source = getNode(state, sourceId);\n const target = getNode(state, targetId);\n if (!source || !target) return \"sequenceFlow\";\n\n if (isDataType(source.data.elementType) || isDataType(target.data.elementType)) {\n return \"dataAssociation\";\n }\n if (\n source.data.elementType === \"Annotation\" ||\n target.data.elementType === \"Annotation\" ||\n source.data.elementType === \"Group\" ||\n target.data.elementType === \"Group\"\n ) {\n return \"association\";\n }\n if (\n source.data.elementType === \"Conversation\" ||\n source.data.elementType === \"SubConversation\" ||\n source.data.elementType === \"CallConversation\" ||\n target.data.elementType === \"Conversation\" ||\n target.data.elementType === \"SubConversation\" ||\n target.data.elementType === \"CallConversation\"\n ) {\n return \"conversationLink\";\n }\n if (source.parentId && target.parentId && source.parentId !== target.parentId) {\n return \"messageFlow\";\n }\n return \"sequenceFlow\";\n}\n\nfunction canUseSequenceFlow(type: BpmnElementType): boolean {\n const meta = BPMN_ELEMENT_CATALOG[type];\n return (\n meta.handlePolicy !== \"none\" &&\n !isDataType(type) &&\n type !== \"Annotation\" &&\n type !== \"Group\" &&\n meta.category !== \"conversation\"\n );\n}\n\nfunction matchesConnectionCategory(\n type: BpmnElementType,\n categories: BpmnConnectionRule[\"sourceCategories\"],\n): boolean {\n return categories.some((category) => {\n if (category === type) return true;\n if (category === \"flowNode\") return canUseSequenceFlow(type);\n if (category === \"data\") return isDataType(type);\n if (category === \"artifact\") return type === \"Annotation\" || type === \"Group\";\n if (category === \"conversation\") return BPMN_ELEMENT_CATALOG[type].category === \"conversation\";\n return false;\n });\n}\n\nexport function isBpmnEdgeRoutingEditable(edgeType: BpmnEdgeType): boolean {\n return BPMN_ROUTABLE_EDGE_TYPES.includes(edgeType);\n}\n\nexport function isBpmnProcessNode(type: BpmnElementType): boolean {\n return (\n isEventType(type) ||\n isGatewayType(type) ||\n type.includes(\"Task\") ||\n type === \"CallActivity\" ||\n type === \"SubProcess\" ||\n type === \"Transaction\" ||\n type === \"EventSubProcess\" ||\n type === \"AdHocSubProcess\"\n );\n}\n\nexport function canContainBpmnElement(\n parentType: BpmnElementType | undefined,\n childType: BpmnElementType,\n): true | string {\n if (!parentType) return true;\n if (parentType === \"Pool\") {\n return childType === \"Lane\" || isBpmnProcessNode(childType)\n ? true\n : \"Pools can contain lanes or BPMN process nodes.\";\n }\n if (parentType === \"Lane\") {\n return isBpmnProcessNode(childType)\n ? true\n : \"Lanes can only contain BPMN process nodes.\";\n }\n if (\n parentType === \"SubProcess\" ||\n parentType === \"Transaction\" ||\n parentType === \"EventSubProcess\" ||\n parentType === \"AdHocSubProcess\"\n ) {\n return isBpmnProcessNode(childType)\n ? true\n : \"Subprocesses can only contain BPMN process nodes.\";\n }\n return `${parentType} cannot contain BPMN child elements.`;\n}\n\nfunction getDirectBpmnChildren(\n state: BpmnDiagramState,\n parentId: string,\n): BpmnRFNode[] {\n return state.nodes.filter((node) => node.parentId === parentId);\n}\n\nexport function getBpmnPoolLanes(\n state: BpmnDiagramState,\n poolId: string,\n): BpmnRFNode[] {\n return getDirectBpmnChildren(state, poolId).filter(\n (node) => node.data.elementType === \"Lane\",\n );\n}\n\nfunction getNodeDimension(node: BpmnRFNode, axis: \"width\" | \"height\"): number {\n return node[axis] ?? node.measured?.[axis] ?? getBpmnElementSize(node.data.elementType)[axis];\n}\n\nfunction getBpmnLaneOrderPosition(\n lane: BpmnRFNode,\n orientation: \"horizontal\" | \"vertical\",\n): number {\n const size = getBpmnNodeSize(lane);\n return orientation === \"vertical\"\n ? lane.position.x + size.width / 2\n : lane.position.y + size.height / 2;\n}\n\nfunction resizeHorizontalBpmnLanes(lanes: BpmnRFNode[], pool: BpmnRFNode): BpmnRFNode[] {\n const poolSize = getBpmnNodeSize(pool);\n const laneWidth = Math.max(BPMN_POOL_LANE_LAYOUT.minLaneSize, poolSize.width - BPMN_POOL_LANE_LAYOUT.poolHeaderSize);\n const laneHeight = Math.max(BPMN_POOL_LANE_LAYOUT.minLaneSize, poolSize.height / Math.max(1, lanes.length));\n return lanes.map((lane, index) => ({\n ...lane,\n position: { x: BPMN_POOL_LANE_LAYOUT.poolHeaderSize, y: index * laneHeight },\n width: laneWidth,\n height: laneHeight,\n parentId: pool.id,\n extent: \"parent\" as const,\n zIndex: getBpmnNodeZIndex(\"Lane\"),\n data: { ...lane.data, orientation: \"horizontal\", laneIndex: index },\n }));\n}\n\nfunction resizeVerticalBpmnLanes(lanes: BpmnRFNode[], pool: BpmnRFNode): BpmnRFNode[] {\n const poolSize = getBpmnNodeSize(pool);\n const laneWidth = Math.max(BPMN_POOL_LANE_LAYOUT.minLaneSize, poolSize.width / Math.max(1, lanes.length));\n const laneHeight = Math.max(BPMN_POOL_LANE_LAYOUT.minLaneSize, poolSize.height - BPMN_POOL_LANE_LAYOUT.verticalPoolHeaderSize);\n return lanes.map((lane, index) => ({\n ...lane,\n position: { x: index * laneWidth, y: BPMN_POOL_LANE_LAYOUT.verticalPoolHeaderSize },\n width: laneWidth,\n height: laneHeight,\n parentId: pool.id,\n extent: \"parent\" as const,\n zIndex: getBpmnNodeZIndex(\"Lane\"),\n data: { ...lane.data, orientation: \"vertical\", laneIndex: index },\n }));\n}\n\nexport function layoutBpmnPoolLaneNodes(\n nodes: BpmnRFNode[],\n poolId: string,\n): BpmnRFNode[] {\n const pool = nodes.find((node) => node.id === poolId && node.data.elementType === \"Pool\");\n if (!pool) return nodes;\n\n const orientation = pool.data.orientation === \"vertical\" ? \"vertical\" : \"horizontal\";\n const lanes = nodes\n .filter((node) => node.parentId === pool.id && node.data.elementType === \"Lane\")\n .sort((a, b) => {\n const aIndex = typeof a.data.laneIndex === \"number\" ? a.data.laneIndex : undefined;\n const bIndex = typeof b.data.laneIndex === \"number\" ? b.data.laneIndex : undefined;\n if (aIndex !== undefined || bIndex !== undefined) return (aIndex ?? 0) - (bIndex ?? 0);\n return getBpmnLaneOrderPosition(a, orientation) - getBpmnLaneOrderPosition(b, orientation);\n });\n\n if (lanes.length === 0) return withBpmnNodeZIndexes(nodes);\n\n const laneMap = new Map(\n (orientation === \"vertical\" ? resizeVerticalBpmnLanes(lanes, pool) : resizeHorizontalBpmnLanes(lanes, pool))\n .map((lane) => [lane.id, lane]),\n );\n\n return withBpmnNodeZIndexes(nodes.map((node) => laneMap.get(node.id) ?? node));\n}\n\nexport function reorderBpmnLaneAfterDrop(\n nodes: BpmnRFNode[],\n laneId: string,\n): BpmnRFNode[] {\n const lane = nodes.find((node) => node.id === laneId && node.data.elementType === \"Lane\");\n if (!lane?.parentId) return nodes;\n\n const pool = nodes.find((node) => node.id === lane.parentId && node.data.elementType === \"Pool\");\n if (!pool) return nodes;\n\n const orientation = pool.data.orientation === \"vertical\" ? \"vertical\" : \"horizontal\";\n const lanes = nodes\n .filter((node) => node.parentId === pool.id && node.data.elementType === \"Lane\")\n .sort((a, b) => getBpmnLaneOrderPosition(a, orientation) - getBpmnLaneOrderPosition(b, orientation));\n\n const moved = lanes.find((candidate) => candidate.id === lane.id);\n if (!moved) return layoutBpmnPoolLaneNodes(nodes, pool.id);\n\n const withoutMoved = lanes.filter((candidate) => candidate.id !== lane.id);\n const movedCenter = getBpmnLaneOrderPosition(lane, orientation);\n const insertIndex = withoutMoved.findIndex(\n (candidate) => movedCenter < getBpmnLaneOrderPosition(candidate, orientation),\n );\n const ordered = [...withoutMoved];\n ordered.splice(insertIndex === -1 ? ordered.length : insertIndex, 0, moved);\n\n const orderedMap = new Map(ordered.map((candidate, index) => [candidate.id, index]));\n const sortedByDrop = nodes.map((node) => {\n if (node.parentId !== pool.id || node.data.elementType !== \"Lane\") return node;\n return { ...node, data: { ...node.data, laneIndex: orderedMap.get(node.id) ?? 0 } };\n });\n\n return layoutBpmnPoolLaneNodes(sortedByDrop, pool.id);\n}\n\nexport function getBpmnNodeSize(node: BpmnRFNode): { width: number; height: number } {\n return getNodeSize(node, getBpmnElementSize(node.data.elementType));\n}\n\nexport function getBpmnNodeAbsolutePosition(\n state: BpmnDiagramState,\n nodeOrId: BpmnRFNode | string,\n): { x: number; y: number } | undefined {\n const nodeId = typeof nodeOrId === \"string\" ? nodeOrId : nodeOrId.id;\n return getNodeAbsolutePosition(state, nodeId);\n}\n\nexport function toBpmnRelativePosition(\n state: BpmnDiagramState,\n absolutePosition: { x: number; y: number },\n parentOrId: BpmnRFNode | string,\n): { x: number; y: number } {\n return toRelativeNodePosition(state, absolutePosition, parentOrId);\n}\n\nconst BPMN_CONTAINER_PRIORITY: BpmnElementType[] = [\n \"Lane\",\n \"SubProcess\",\n \"EventSubProcess\",\n \"Transaction\",\n \"AdHocSubProcess\",\n \"Pool\",\n];\n\nexport function findBpmnContainerAt(\n state: BpmnDiagramState,\n options: FindBpmnContainerAtOptions,\n): BpmnRFNode | undefined {\n return findContainingNode(state, {\n point: options.position,\n excludeId: options.excludeId,\n fallbackSize: (node) => getBpmnElementSize(node.data.elementType),\n predicate: (node) => BPMN_CONTAINER_PRIORITY.includes(node.data.elementType),\n sort: (a, b) => {\n const aPriority = BPMN_CONTAINER_PRIORITY.indexOf(a.data.elementType);\n const bPriority = BPMN_CONTAINER_PRIORITY.indexOf(b.data.elementType);\n if (aPriority !== bPriority) return aPriority - bPriority;\n const aSize = getBpmnNodeSize(a);\n const bSize = getBpmnNodeSize(b);\n return aSize.width * aSize.height - bSize.width * bSize.height;\n },\n });\n}\n\nexport function getBpmnNodeCenter(\n node: BpmnRFNode,\n absolutePosition: { x: number; y: number },\n): { x: number; y: number } {\n return getNodeCenterPosition(absolutePosition, getBpmnNodeSize(node));\n}\n\nfunction resolvePoolLaneDirection(pool: BpmnRFNode): \"horizontal\" | \"vertical\" {\n return pool.data.orientation === \"vertical\" ? \"horizontal\" : \"vertical\";\n}\n\nexport function getBpmnLaneIndexAtPosition(\n state: BpmnDiagramState,\n poolId: string,\n position: { x: number; y: number },\n): number {\n const pool = getNode(state, poolId);\n if (!pool) return 0;\n const lanes = getBpmnPoolLanes(state, poolId);\n const direction = resolvePoolLaneDirection(pool);\n const axis = direction === \"vertical\" ? \"y\" : \"x\";\n const sizeKey = direction === \"vertical\" ? \"height\" : \"width\";\n\n for (let index = 0; index < lanes.length; index += 1) {\n const lane = lanes[index];\n const midpoint = lane.position[axis] + getNodeDimension(lane, sizeKey) / 2;\n if (position[axis] < midpoint) return index;\n }\n return lanes.length;\n}\n\nfunction sortBpmnLanes(\n state: BpmnDiagramState,\n poolId: string,\n laneId: string,\n index: number,\n): BpmnDiagramState {\n const lanes = getBpmnPoolLanes(state, poolId);\n const currentIndex = lanes.findIndex((lane) => lane.id === laneId);\n if (currentIndex < 0) return state;\n\n const orderedIds = lanes.map((lane) => lane.id);\n const [moved] = orderedIds.splice(currentIndex, 1);\n orderedIds.splice(Math.max(0, Math.min(index, orderedIds.length)), 0, moved);\n const order = new Map(orderedIds.map((id, laneIndex) => [id, laneIndex]));\n\n return {\n ...state,\n nodes: [...state.nodes].sort((a, b) => {\n const aOrder = order.get(a.id);\n const bOrder = order.get(b.id);\n if (aOrder === undefined && bOrder === undefined) return 0;\n if (aOrder === undefined) return -1;\n if (bOrder === undefined) return 1;\n return aOrder - bOrder;\n }),\n };\n}\n\nexport function layoutBpmnPoolLanes(\n state: BpmnDiagramState,\n poolId: string,\n): BpmnDiagramState {\n const pool = getNode(state, poolId);\n if (!pool) return state;\n const poolSize = getBpmnElementSize(\"Pool\");\n const direction = resolvePoolLaneDirection(pool);\n const lanes = getBpmnPoolLanes(state, poolId);\n let cursor = direction === \"vertical\" ? BPMN_POOL_LANE_LAYOUT.poolHeaderSize : 0;\n\n let next = state;\n for (const lane of lanes) {\n const laneSize = getBpmnElementSize(\"Lane\");\n const width =\n direction === \"vertical\"\n ? Math.max(poolSize.minWidth - BPMN_POOL_LANE_LAYOUT.poolHeaderSize, lane.width ?? laneSize.width)\n : lane.width ?? laneSize.width;\n const height =\n direction === \"vertical\"\n ? lane.height ?? laneSize.height\n : Math.max(poolSize.minHeight - BPMN_POOL_LANE_LAYOUT.poolHeaderSize, lane.height ?? laneSize.height);\n next = patchNode(next, lane.id, {\n position: direction === \"vertical\" ? { x: BPMN_POOL_LANE_LAYOUT.poolHeaderSize, y: cursor } : { x: cursor, y: BPMN_POOL_LANE_LAYOUT.poolHeaderSize },\n width,\n height,\n data: { orientation: pool.data.orientation ?? \"horizontal\" },\n });\n cursor += (direction === \"vertical\" ? height : width) + BPMN_POOL_LANE_LAYOUT.laneGap;\n }\n\n const minWidth =\n direction === \"vertical\"\n ? poolSize.minWidth\n : Math.max(poolSize.minWidth, cursor);\n const minHeight =\n direction === \"vertical\"\n ? Math.max(poolSize.minHeight, cursor)\n : poolSize.minHeight;\n return resizeNode(next, poolId, { width: minWidth, height: minHeight } as Parameters<typeof resizeNode<BpmnRFNode, BpmnRFEdge>>[2]);\n}\n\nexport function reorderBpmnLane(\n state: BpmnDiagramState,\n options: ReorderBpmnLaneOptions,\n): BpmnDiagramState {\n return layoutBpmnPoolLanes(\n sortBpmnLanes(state, options.poolId, options.laneId, options.index),\n options.poolId,\n );\n}\n\nexport function validateBpmnConnectionForEdgeType(\n state: BpmnDiagramState,\n edgeType: BpmnEdgeType,\n source: BpmnRFNode,\n target: BpmnRFNode,\n): true | string {\n const rule = BPMN_EDGE_CONNECTION_RULES[edgeType];\n if (!matchesConnectionCategory(source.data.elementType, rule.sourceCategories)) {\n return `${edgeType} cannot start from ${source.data.elementType}.`;\n }\n if (!matchesConnectionCategory(target.data.elementType, rule.targetCategories)) {\n return `${edgeType} cannot target ${target.data.elementType}.`;\n }\n const sameParent = (source.parentId ?? null) === (target.parentId ?? null);\n if (sameParent && rule.allowSameParent === false) {\n return `${edgeType} must connect BPMN elements in different participants/scopes.`;\n }\n if (!sameParent && rule.allowDifferentParent === false) {\n return `${edgeType} must stay inside the same BPMN participant/scope.`;\n }\n if (edgeType === \"sequenceFlow\") {\n if (source.data.elementType === \"EndEvent\") return \"End events cannot have outgoing sequence flows.\";\n if (target.data.elementType === \"StartEvent\") return \"Start events cannot have incoming sequence flows.\";\n return validateEdgeCardinality(state, edgeType, source, target);\n }\n return true;\n}\n\nfunction validateEdgeCardinality(\n state: BpmnDiagramState,\n edgeType: BpmnEdgeType,\n source: BpmnRFNode,\n target: BpmnRFNode,\n): true | string {\n if (edgeType !== \"sequenceFlow\") return true;\n\n const sourceMax = BPMN_ELEMENT_CATALOG[source.data.elementType].maxOutgoing;\n const targetMax = BPMN_ELEMENT_CATALOG[target.data.elementType].maxIncoming;\n const outgoing = getOutgoingEdges(state, source.id).filter(\n (edge) => edge.data?.edgeType === \"sequenceFlow\",\n );\n const incoming = getIncomingEdges(state, target.id).filter(\n (edge) => edge.data?.edgeType === \"sequenceFlow\",\n );\n\n if (sourceMax !== undefined && outgoing.length >= sourceMax) {\n return `${source.data.elementType} cannot have more than ${sourceMax} outgoing sequence flow(s).`;\n }\n if (targetMax !== undefined && incoming.length >= targetMax) {\n return `${target.data.elementType} cannot have more than ${targetMax} incoming sequence flow(s).`;\n }\n return true;\n}\n\nexport const bpmnConnectionValidators: Array<\n ConnectionValidator<BpmnRFNode, BpmnRFEdge>\n> = [\n ({ state, source, target }) => {\n if (source.id === target.id) return \"BPMN self-connections are not allowed.\";\n const edgeType = inferBpmnEdgeType(state, source.id, target.id);\n\n if (getHandlePolicy(source.data.elementType) === \"none\" || getHandlePolicy(target.data.elementType) === \"none\") {\n return \"Elements without BPMN connection handles cannot be directly connected.\";\n }\n\n if (edgeType === \"sequenceFlow\") {\n return validateBpmnConnectionForEdgeType(state, edgeType, source, target);\n }\n\n return validateBpmnConnectionForEdgeType(state, edgeType, source, target);\n },\n];\n\nexport const BPMN_MODELING_RULES: ModelingRules<BpmnRFNode, BpmnRFEdge> =\n createModelingRules({\n connect: [\n ({ state, source, target }) => {\n if (!source || !target) return false;\n for (const validator of bpmnConnectionValidators) {\n const result = validator({\n state,\n source,\n target,\n existingEdges: state.edges,\n });\n if (result !== true) return result;\n }\n return true;\n },\n ],\n drop: [\n ({ node, parent }) => {\n if (!node || !parent) return true;\n if (node.data.elementType === \"BoundaryEvent\") {\n return acceptsBoundaryEvents(parent.data.elementType)\n ? true\n : \"Boundary events can only be attached to tasks or subprocesses.\";\n }\n return canContainBpmnElement(parent.data.elementType, node.data.elementType);\n },\n ],\n reparent: [\n ({ node, parent }) => {\n if (!node || !parent) return true;\n if (node.data.elementType === \"BoundaryEvent\") {\n return acceptsBoundaryEvents(parent.data.elementType)\n ? true\n : \"Boundary events can only be reparented to tasks or subprocesses.\";\n }\n return canContainBpmnElement(parent?.data.elementType, node.data.elementType);\n },\n ],\n delete: [() => true],\n resize: [\n ({ node }) =>\n !node || isBpmnElementResizable(node.data.elementType)\n ? true\n : `${node.data.elementType} is not resizable in BPMN.`,\n ],\n });\n\nexport function createBpmnNodeCommand(\n options: CreateBpmnNodeOptions,\n): DiagramCommand<BpmnRFNode, BpmnRFEdge> {\n return {\n id: `bpmn.createNode.${options.id}`,\n label: `Create ${options.elementType}`,\n execute: (state) => addNode(state, createBpmnNode(options)),\n };\n}\n\nexport function connectBpmnCommand(\n options: ConnectBpmnOptions,\n): DiagramCommand<BpmnRFNode, BpmnRFEdge> {\n return {\n id: `bpmn.connect.${options.id ?? `${options.source}-${options.target}`}`,\n label: \"Connect BPMN elements\",\n execute: (state) => {\n const edgeType = options.edgeType ?? inferBpmnEdgeType(state, options.source, options.target);\n const source = getNode(state, options.source);\n const target = getNode(state, options.target);\n if (!source) throw new Error(`Source node \"${options.source}\" does not exist.`);\n if (!target) throw new Error(`Target node \"${options.target}\" does not exist.`);\n const validation = validateBpmnConnectionForEdgeType(state, edgeType, source, target);\n if (validation !== true) throw new Error(validation);\n return connectNodes(\n state,\n {\n source: options.source,\n target: options.target,\n type: edgeType,\n ...(options.sourceHandle !== undefined\n ? { sourceHandle: options.sourceHandle }\n : {}),\n ...(options.targetHandle !== undefined\n ? { targetHandle: options.targetHandle }\n : {}),\n ...(options.id ? { id: options.id } : {}),\n data: {\n edgeType,\n ...(options.label ? { label: options.label } : {}),\n ...(options.data ?? {}),\n },\n },\n [],\n );\n },\n };\n}\n\nexport function attachBoundaryEventCommand(\n boundaryId: string,\n hostId: string,\n): DiagramCommand<BpmnRFNode, BpmnRFEdge> {\n return {\n id: `bpmn.attachBoundary.${boundaryId}.${hostId}`,\n label: \"Attach boundary event\",\n execute: (state) => {\n const host = getNode(state, hostId);\n if (!host || !acceptsBoundaryEvents(host.data.elementType)) {\n throw new Error(`Element \"${hostId}\" cannot host boundary events.`);\n }\n const boundary = getNode(state, boundaryId);\n if (!boundary || boundary.data.elementType !== \"BoundaryEvent\") {\n throw new Error(`Element \"${boundaryId}\" is not a boundary event.`);\n }\n const reparented = reparentNode(state, boundaryId, { parentId: hostId });\n return patchNode(reparented, boundaryId, {\n data: { attachedToRef: hostId },\n });\n },\n };\n}\n\nexport function replaceBpmnNodeCommand(\n options: ReplaceBpmnNodeOptions,\n): DiagramCommand<BpmnRFNode, BpmnRFEdge> {\n return {\n id: `bpmn.replaceNode.${options.id}.${options.elementType}`,\n label: `Replace with ${options.elementType}`,\n execute: (state) => {\n const current = getNode(state, options.id);\n if (!current) throw new Error(`Element \"${options.id}\" does not exist.`);\n const meta = BPMN_ELEMENT_CATALOG[options.elementType];\n return replaceNode(state, options.id, {\n ...current,\n type: options.elementType,\n width: options.width ?? current.width ?? meta.defaultWidth,\n height: options.height ?? current.height ?? meta.defaultHeight,\n data: {\n ...current.data,\n elementType: options.elementType,\n ...(options.label ? { label: options.label } : {}),\n ...(options.data ?? {}),\n },\n });\n },\n };\n}\n\nexport function reparentBpmnNodeCommand(\n options: ReparentBpmnNodeOptions,\n): DiagramCommand<BpmnRFNode, BpmnRFEdge> {\n return {\n id: `bpmn.reparent.${options.id}.${options.parentId ?? \"root\"}`,\n label: \"Reparent BPMN element\",\n execute: (state) => {\n const node = getNode(state, options.id);\n const parent = options.parentId ? getNode(state, options.parentId) : undefined;\n if (!node) throw new Error(`Element \"${options.id}\" does not exist.`);\n if (parent && node.data.elementType === \"BoundaryEvent\" && !acceptsBoundaryEvents(parent.data.elementType)) {\n throw new Error(\"Boundary events can only be reparented to tasks or subprocesses.\");\n }\n const containment = canContainBpmnElement(parent?.data.elementType, node.data.elementType);\n if (containment !== true) throw new Error(containment);\n const reparented = reparentNode(state, options.id, {\n ...(options.parentId !== undefined ? { parentId: options.parentId } : {}),\n ...(options.position ? { position: options.position } : {}),\n });\n return parent?.data.elementType === \"Pool\" && node.data.elementType === \"Lane\"\n ? layoutBpmnPoolLanes(reparented, parent.id)\n : reparented;\n },\n };\n}\n\nexport function reparentBpmnNodeAtPosition(\n state: BpmnDiagramState,\n options: ReparentBpmnNodeAtPositionOptions,\n): BpmnDiagramState {\n const node = getNode(state, options.id);\n if (!node) throw new Error(`Element \"${options.id}\" does not exist.`);\n\n const hitPoint = getBpmnNodeCenter(node, options.position);\n const parent = isBpmnProcessNode(node.data.elementType)\n ? findBpmnContainerAt(state, { position: hitPoint, excludeId: node.id })\n : undefined;\n const containment = canContainBpmnElement(parent?.data.elementType, node.data.elementType);\n if (containment !== true) throw new Error(containment);\n\n const nextPosition = parent\n ? toBpmnRelativePosition(state, options.position, parent)\n : options.position;\n return reparentNode(state, node.id, {\n ...(parent ? { parentId: parent.id } : { parentId: undefined }),\n position: nextPosition,\n });\n}\n\nexport function resizeBpmnNodeCommand(\n options: ResizeBpmnNodeOptions,\n): DiagramCommand<BpmnRFNode, BpmnRFEdge> {\n return {\n id: `bpmn.resize.${options.id}`,\n label: \"Resize BPMN element\",\n execute: (state) => {\n const node = getNode(state, options.id);\n if (!node) throw new Error(`Element \"${options.id}\" does not exist.`);\n const size = getBpmnElementSize(node.data.elementType);\n if (!size.resizable) {\n throw new Error(`${node.data.elementType} is not resizable in BPMN.`);\n }\n return resizeNode(state, options.id, {\n width:\n options.width === undefined\n ? undefined\n : Math.max(size.minWidth, options.width),\n height:\n options.height === undefined\n ? undefined\n : Math.max(size.minHeight, options.height),\n } as Parameters<typeof resizeNode<BpmnRFNode, BpmnRFEdge>>[2]);\n },\n };\n}\n\nexport function reorderBpmnLaneCommand(\n options: ReorderBpmnLaneOptions,\n): DiagramCommand<BpmnRFNode, BpmnRFEdge> {\n return {\n id: `bpmn.reorderLane.${options.poolId}.${options.laneId}`,\n label: \"Reorder BPMN lane\",\n execute: (state) => {\n const pool = getNode(state, options.poolId);\n const lane = getNode(state, options.laneId);\n if (!pool || pool.data.elementType !== \"Pool\") {\n throw new Error(`Element \"${options.poolId}\" is not a pool.`);\n }\n if (!lane || lane.data.elementType !== \"Lane\" || lane.parentId !== options.poolId) {\n throw new Error(`Element \"${options.laneId}\" is not a lane in pool \"${options.poolId}\".`);\n }\n return reorderBpmnLane(state, options);\n },\n };\n}\n\nexport function moveBpmnLaneCommand(\n options: MoveBpmnLaneOptions,\n): DiagramCommand<BpmnRFNode, BpmnRFEdge> {\n return {\n id: `bpmn.moveLane.${options.poolId}.${options.laneId}`,\n label: \"Move BPMN lane\",\n execute: (state) =>\n reorderBpmnLane(state, {\n poolId: options.poolId,\n laneId: options.laneId,\n index: getBpmnLaneIndexAtPosition(state, options.poolId, options.position),\n }),\n };\n}\n\nexport function routeBpmnEdgeCommand(\n options: RouteBpmnEdgeOptions,\n): DiagramCommand<BpmnRFNode, BpmnRFEdge> {\n return {\n id: `bpmn.routeEdge.${options.id}`,\n label: \"Route BPMN edge\",\n execute: (state) => {\n const edge = state.edges.find((item) => item.id === options.id);\n if (!edge) throw new Error(`Edge \"${options.id}\" does not exist.`);\n const edgeType = edge.data?.edgeType;\n if (!edgeType || !isBpmnEdgeRoutingEditable(edgeType)) {\n throw new Error(`${edgeType ?? \"edge\"} routing points cannot be edited.`);\n }\n return patchEdge(state, options.id, {\n data: { routingPoints: options.routingPoints },\n } as Parameters<typeof patchEdge<BpmnRFNode, BpmnRFEdge>>[2]);\n },\n };\n}\n\nexport function deleteBpmnElementsCommand(\n ids: string[],\n): DiagramCommand<BpmnRFNode, BpmnRFEdge> {\n return {\n id: `bpmn.delete.${ids.join(\".\")}`,\n label: \"Delete BPMN elements\",\n execute: (state) => removeElements(state, ids),\n };\n}\n\nexport function copyBpmnElements(\n state: BpmnDiagramState,\n selection?: SelectionState,\n): BpmnClipboardState {\n return copyElements(state, selection);\n}\n\nexport function pasteBpmnElementsCommand(\n clipboard: BpmnClipboardState,\n options: PasteBpmnOptions = {},\n): DiagramCommand<BpmnRFNode, BpmnRFEdge> {\n return {\n id: \"bpmn.paste\",\n label: \"Paste BPMN elements\",\n execute: (state) => pasteElements(state, clipboard, options),\n };\n}\n\nexport function selectBpmnElementsCommand(\n selection: SelectionState,\n): DiagramCommand<BpmnRFNode, BpmnRFEdge> {\n return {\n id: \"bpmn.select\",\n label: \"Select BPMN elements\",\n execute: (state) => setSelection(state, createSelectionState(selection.nodeIds, selection.edgeIds)),\n };\n}\n\nexport function createBpmnDiagramDocument(\n state: BpmnDiagramState,\n options: Omit<CreateDiagramDocumentOptions, \"diagramType\"> = {},\n): BpmnDiagramDocument {\n return createDiagramDocument(normalizeDiagramState(state), {\n ...options,\n diagramType: \"bpmn\",\n });\n}\n\nexport function serializeBpmnDiagram(\n state: BpmnDiagramState,\n options: Omit<CreateDiagramDocumentOptions, \"diagramType\"> = {},\n): string {\n return serializeDiagram(normalizeDiagramState(state), {\n ...options,\n diagramType: \"bpmn\",\n });\n}\n\nexport function parseBpmnDiagramDocument(json: string): BpmnDiagramDocument {\n const document = parseDiagramDocument<BpmnRFNode, BpmnRFEdge>(json);\n if (document.diagramType && document.diagramType !== \"bpmn\") {\n throw new Error(`Expected a BPMN diagram document, received \"${document.diagramType}\".`);\n }\n return document;\n}\n\nexport function deserializeBpmnDiagram(json: string): BpmnDiagramState {\n const document = parseBpmnDiagramDocument(json);\n return deserializeDiagram<BpmnRFNode, BpmnRFEdge>(JSON.stringify(document));\n}\n\nexport function runBpmnCommand(\n stack: CommandStackState<BpmnRFNode, BpmnRFEdge>,\n command: DiagramCommand<BpmnRFNode, BpmnRFEdge>,\n): CommandStackState<BpmnRFNode, BpmnRFEdge> {\n return executeCommand(stack, command);\n}\n\nexport function runBpmnCommands(\n stack: CommandStackState<BpmnRFNode, BpmnRFEdge>,\n commands: Array<DiagramCommand<BpmnRFNode, BpmnRFEdge>>,\n options: { id?: string; label?: string } = {},\n): CommandStackState<BpmnRFNode, BpmnRFEdge> {\n return executeCommands(stack, commands, options);\n}\n"]}
@@ -1,226 +0,0 @@
1
- import { isDataType, isGatewayType, isEventType } from './chunk-RLAJNRF2.js';
2
- import { BPMN_ELEMENT_CATALOG } from './chunk-L5Z22RLX.js';
3
-
4
- // src/validation/index.ts
5
- function isFlowNode(type) {
6
- return isEventType(type) || isGatewayType(type) || type.includes("Task") || type === "CallActivity" || type === "SubProcess" || type === "Transaction" || type === "EventSubProcess" || type === "AdHocSubProcess" || type === "ChoreographyTask" || type === "SubChoreography" || type === "CallChoreography";
7
- }
8
- function isProcessNode(type) {
9
- return isFlowNode(type) && type !== "BoundaryEvent";
10
- }
11
- function isSubProcess(type) {
12
- return type === "SubProcess" || type === "Transaction" || type === "EventSubProcess" || type === "AdHocSubProcess";
13
- }
14
- function isCatchTarget(type) {
15
- return type === "IntermediateCatchEvent" || type === "ReceiveTask";
16
- }
17
- function poolAncestor(node, nodeById) {
18
- let current = node;
19
- const visited = /* @__PURE__ */ new Set();
20
- while (current?.parentId && !visited.has(current.id)) {
21
- visited.add(current.id);
22
- const parent = nodeById.get(current.parentId);
23
- if (parent?.data.elementType === "Pool") return parent.id;
24
- current = parent;
25
- }
26
- return void 0;
27
- }
28
- function countSequenceEdges(edges, nodeId, direction) {
29
- return edges.filter((edge) => {
30
- if (edge.data?.edgeType !== "sequenceFlow") return false;
31
- return direction === "in" ? edge.target === nodeId : edge.source === nodeId;
32
- }).length;
33
- }
34
- function sequenceEdges(edges) {
35
- return edges.filter((edge) => (edge.data?.edgeType ?? edge.type) === "sequenceFlow");
36
- }
37
- function sequenceOut(edges, nodeId) {
38
- return sequenceEdges(edges).filter((edge) => edge.source === nodeId);
39
- }
40
- function sequenceIn(edges, nodeId) {
41
- return sequenceEdges(edges).filter((edge) => edge.target === nodeId);
42
- }
43
- function issue(code, severity, message, elementId, relatedElementIds) {
44
- return {
45
- id: `${code}:${elementId ?? relatedElementIds?.join(",") ?? "diagram"}`,
46
- code,
47
- severity,
48
- message,
49
- ...elementId ? { elementId } : {},
50
- ...relatedElementIds ? { relatedElementIds } : {}
51
- };
52
- }
53
- function validateBpmnDiagram(nodes, edges, options = {}) {
54
- const opts = {
55
- requireStartEvent: true,
56
- requireEndEvent: true,
57
- strictNames: false,
58
- ...options
59
- };
60
- const issues = [];
61
- const nodeById = new Map(nodes.map((node) => [node.id, node]));
62
- const seqEdges = sequenceEdges(edges);
63
- const processNodes = nodes.filter((node) => isProcessNode(node.data.elementType));
64
- if (opts.requireStartEvent && !processNodes.some((node) => node.data.elementType === "StartEvent")) {
65
- issues.push(issue("bpmn/start-event-required", "error", "The diagram must contain at least one start event."));
66
- }
67
- if (opts.requireEndEvent && !processNodes.some((node) => node.data.elementType === "EndEvent")) {
68
- issues.push(issue("bpmn/end-event-required", "error", "The diagram must contain at least one end event."));
69
- }
70
- for (const edge of edges) {
71
- const edgeType = edge.data?.edgeType ?? edge.type;
72
- const source = nodeById.get(edge.source);
73
- const target = nodeById.get(edge.target);
74
- if (!source || !target) {
75
- issues.push(issue(
76
- "bpmn/no-orphan-edges",
77
- "error",
78
- `Edge "${edge.id}" references a missing ${!source ? "source" : "target"} node.`,
79
- edge.id,
80
- [edge.source, edge.target]
81
- ));
82
- continue;
83
- }
84
- if (edge.source === edge.target) {
85
- issues.push(issue("bpmn/no-self-loop", "error", "BPMN edges cannot connect an element to itself.", edge.id, [edge.source]));
86
- }
87
- if (edgeType === "sequenceFlow") {
88
- if (!isFlowNode(source.data.elementType) || !isFlowNode(target.data.elementType) || isDataType(source.data.elementType) || isDataType(target.data.elementType)) {
89
- issues.push(issue("bpmn/sequence-flow-valid-endpoints", "error", "Sequence flows must connect BPMN flow nodes.", edge.id, [source.id, target.id]));
90
- }
91
- const sourcePool = poolAncestor(source, nodeById);
92
- const targetPool = poolAncestor(target, nodeById);
93
- if (sourcePool && targetPool && sourcePool !== targetPool) {
94
- issues.push(issue("bpmn/sequence-flow-no-cross-pool", "error", "Sequence flows cannot cross pools. Use message flow between participants.", edge.id, [source.id, target.id]));
95
- }
96
- }
97
- if (edgeType === "messageFlow") {
98
- const sourcePool = poolAncestor(source, nodeById);
99
- const targetPool = poolAncestor(target, nodeById);
100
- if (!sourcePool || !targetPool || sourcePool === targetPool) {
101
- issues.push(issue("bpmn/message-flow-valid-endpoints", "error", "Message flows must connect flow nodes in different pools.", edge.id, [source.id, target.id]));
102
- }
103
- if (!isFlowNode(source.data.elementType) || !isFlowNode(target.data.elementType)) {
104
- issues.push(issue("bpmn/message-flow-valid-endpoints", "error", "Message flows must connect BPMN flow nodes, not containers.", edge.id, [source.id, target.id]));
105
- }
106
- }
107
- if (edgeType === "dataAssociation") {
108
- const hasDataEndpoint = isDataType(source.data.elementType) || isDataType(target.data.elementType);
109
- const hasFlowEndpoint = isFlowNode(source.data.elementType) || isFlowNode(target.data.elementType);
110
- if (!hasDataEndpoint || !hasFlowEndpoint) {
111
- issues.push(issue("bpmn/data-association-valid-endpoints", "error", "Data associations must connect data elements with flow nodes.", edge.id, [source.id, target.id]));
112
- }
113
- }
114
- }
115
- const duplicateSequenceKeys = /* @__PURE__ */ new Set();
116
- const reportedDuplicateKeys = /* @__PURE__ */ new Set();
117
- for (const edge of seqEdges) {
118
- const key = `${edge.source}->${edge.target}`;
119
- if (duplicateSequenceKeys.has(key) && !reportedDuplicateKeys.has(key)) {
120
- reportedDuplicateKeys.add(key);
121
- issues.push(issue("bpmn/no-duplicate-sequence-flow", "error", "Only one sequence flow is allowed between the same source and target.", edge.id, [edge.source, edge.target]));
122
- }
123
- duplicateSequenceKeys.add(key);
124
- }
125
- for (const node of nodes) {
126
- const type = node.data.elementType;
127
- const incoming = countSequenceEdges(edges, node.id, "in");
128
- const outgoing = countSequenceEdges(edges, node.id, "out");
129
- const meta = BPMN_ELEMENT_CATALOG[type];
130
- if (type === "StartEvent" && incoming > 0) {
131
- issues.push(issue("bpmn/start-event-no-incoming", "error", "Start events cannot have incoming sequence flows.", node.id));
132
- }
133
- if (type === "EndEvent") {
134
- if (outgoing > 0) issues.push(issue("bpmn/no-outgoing-from-end-event", "error", "End events cannot have outgoing sequence flows.", node.id));
135
- if (incoming === 0) issues.push(issue("bpmn/end-event-has-incoming", "error", "End events should have at least one incoming sequence flow.", node.id));
136
- }
137
- if ((type === "IntermediateCatchEvent" || type === "IntermediateThrowEvent") && (incoming === 0 || outgoing === 0)) {
138
- issues.push(issue("bpmn/intermediate-event-both-flows", "error", "Intermediate events should have both incoming and outgoing sequence flows.", node.id));
139
- }
140
- if (type === "BoundaryEvent") {
141
- const hostId = node.data.attachedToRef ?? node.parentId;
142
- const host = hostId ? nodeById.get(hostId) : void 0;
143
- if (!host || !BPMN_ELEMENT_CATALOG[host.data.elementType]?.acceptsBoundaryEvents) {
144
- issues.push(issue("bpmn/boundary-event-attached", "error", "Boundary events must be attached to an activity or subprocess.", node.id, hostId ? [hostId] : void 0));
145
- }
146
- if (sequenceIn(edges, node.id).length > 0) {
147
- issues.push(issue("bpmn/boundary-no-incoming", "error", "Boundary events cannot have incoming sequence flows.", node.id));
148
- }
149
- if (sequenceOut(edges, node.id).length === 0) {
150
- issues.push(issue("bpmn/boundary-has-outgoing", "warning", "Boundary events should define an outgoing exception path.", node.id));
151
- }
152
- }
153
- if (isGatewayType(type)) {
154
- if (incoming === 0) issues.push(issue("bpmn/gateway-has-incoming", "error", "Gateways should have at least one incoming sequence flow.", node.id));
155
- if (outgoing === 0) issues.push(issue("bpmn/gateway-has-outgoing", "error", "Gateways should have at least one outgoing sequence flow.", node.id));
156
- }
157
- if (type === "ExclusiveGateway" || type === "InclusiveGateway" || type === "ComplexGateway") {
158
- const outgoingEdges = sequenceOut(edges, node.id);
159
- const defaults = outgoingEdges.filter((edge) => edge.data?.isDefault);
160
- if (defaults.length > 1) {
161
- issues.push(issue("bpmn/gateway-single-default", "error", "Gateways can have at most one default sequence flow.", node.id, defaults.map((edge) => edge.id)));
162
- }
163
- if (outgoingEdges.length >= 2) {
164
- for (const edge of outgoingEdges) {
165
- if (!edge.data?.isDefault && !edge.data?.conditionExpression) {
166
- issues.push(issue("bpmn/gateway-condition", "error", "Conditional gateway branches should have a condition or be marked as default.", edge.id, [node.id, edge.target]));
167
- }
168
- }
169
- }
170
- }
171
- if (type === "EventBasedGateway") {
172
- const outgoingEdges = edges.filter((edge) => edge.data?.edgeType === "sequenceFlow" && edge.source === node.id);
173
- if (outgoingEdges.length < 2) {
174
- issues.push(issue("bpmn/event-based-gateway-min-outgoing", "error", "Event-based gateways should have at least two outgoing sequence flows.", node.id));
175
- }
176
- for (const edge of outgoingEdges) {
177
- const target = nodeById.get(edge.target);
178
- if (target && !isCatchTarget(target.data.elementType)) {
179
- issues.push(issue("bpmn/event-based-gateway-valid-targets", "error", "Event-based gateways must target catch events or receive tasks.", edge.id, [node.id, target.id]));
180
- }
181
- }
182
- }
183
- if (meta.maxIncoming !== void 0 && incoming > meta.maxIncoming) {
184
- issues.push(issue("bpmn/max-incoming", "error", `${type} cannot have more than ${meta.maxIncoming} incoming sequence flow(s).`, node.id));
185
- }
186
- if (meta.maxOutgoing !== void 0 && outgoing > meta.maxOutgoing) {
187
- issues.push(issue("bpmn/max-outgoing", "error", `${type} cannot have more than ${meta.maxOutgoing} outgoing sequence flow(s).`, node.id));
188
- }
189
- if (opts.strictNames && (type.includes("Task") || isGatewayType(type)) && !node.data.label) {
190
- issues.push(issue("bpmn/name-required", "warning", `${type} should have a label.`, node.id));
191
- }
192
- if (isSubProcess(type)) {
193
- const childNodes = nodes.filter((child) => child.parentId === node.id);
194
- if (childNodes.length > 0) {
195
- if (!childNodes.some((child) => child.data.elementType === "StartEvent")) {
196
- issues.push(issue("bpmn/subprocess-has-start-end", "error", "Expanded subprocesses should contain a start event.", node.id));
197
- }
198
- if (!childNodes.some((child) => child.data.elementType === "EndEvent")) {
199
- issues.push(issue("bpmn/subprocess-has-start-end", "error", "Expanded subprocesses should contain an end event.", node.id));
200
- }
201
- }
202
- if (type === "EventSubProcess") {
203
- const starts = childNodes.filter((child) => child.data.elementType === "StartEvent");
204
- for (const start of starts) {
205
- if (!start.data.trigger || start.data.trigger === "none") {
206
- issues.push(issue("bpmn/event-subprocess-triggered-start", "error", "Event subprocess start events must define an event trigger.", start.id, [node.id]));
207
- }
208
- }
209
- }
210
- }
211
- if (type === "Lane") {
212
- const parent = node.parentId ? nodeById.get(node.parentId) : void 0;
213
- if (parent?.data.elementType !== "Pool") {
214
- issues.push(issue("bpmn/lane-parent-pool", "error", "Lanes must be contained by a pool.", node.id));
215
- }
216
- }
217
- }
218
- return {
219
- valid: issues.every((item) => item.severity !== "error"),
220
- issues
221
- };
222
- }
223
-
224
- export { validateBpmnDiagram };
225
- //# sourceMappingURL=chunk-ZFGQVLHB.js.map
226
- //# sourceMappingURL=chunk-ZFGQVLHB.js.map