"use strict";
/*
 * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
 * This devtool is neither made for production nor for readable output files.
 * It uses "eval()" calls to create a separate source file in the browser devtools.
 * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
 * or disable the default devtool with "devtool: false".
 * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
 */
(self["webpackChunk_mdts_frontend"] = self["webpackChunk_mdts_frontend"] || []).push([["vendors-node_modules_mermaid_dist_chunks_mermaid_core_diagram-FQU43EPY_mjs"],{

/***/ "./node_modules/mermaid/dist/chunks/mermaid.core/chunk-JWPE2WC7.mjs"
/*!**************************************************************************!*\
  !*** ./node_modules/mermaid/dist/chunks/mermaid.core/chunk-JWPE2WC7.mjs ***!
  \**************************************************************************/
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {

eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   populateCommonDb: () => (/* binding */ populateCommonDb)\n/* harmony export */ });\n/* harmony import */ var _chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./chunk-Y2CYZVJY.mjs */ \"./node_modules/mermaid/dist/chunks/mermaid.core/chunk-Y2CYZVJY.mjs\");\n\n\n// src/diagrams/common/populateCommonDb.ts\nfunction populateCommonDb(ast, db) {\n  if (ast.accDescr) {\n    db.setAccDescription?.(ast.accDescr);\n  }\n  if (ast.accTitle) {\n    db.setAccTitle?.(ast.accTitle);\n  }\n  if (ast.title) {\n    db.setDiagramTitle?.(ast.title);\n  }\n}\n;(0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_0__.__name)(populateCommonDb, \"populateCommonDb\");\n\n\n\n\n//# sourceURL=webpack://@mdts/frontend/./node_modules/mermaid/dist/chunks/mermaid.core/chunk-JWPE2WC7.mjs?\n}");

/***/ },

/***/ "./node_modules/mermaid/dist/chunks/mermaid.core/diagram-FQU43EPY.mjs"
/*!****************************************************************************!*\
  !*** ./node_modules/mermaid/dist/chunks/mermaid.core/diagram-FQU43EPY.mjs ***!
  \****************************************************************************/
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {

eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   diagram: () => (/* binding */ diagram)\n/* harmony export */ });\n/* harmony import */ var _chunk_JWPE2WC7_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./chunk-JWPE2WC7.mjs */ \"./node_modules/mermaid/dist/chunks/mermaid.core/chunk-JWPE2WC7.mjs\");\n/* harmony import */ var _chunk_ICXQ74PX_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./chunk-ICXQ74PX.mjs */ \"./node_modules/mermaid/dist/chunks/mermaid.core/chunk-ICXQ74PX.mjs\");\n/* harmony import */ var _chunk_WYO6CB5R_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./chunk-WYO6CB5R.mjs */ \"./node_modules/mermaid/dist/chunks/mermaid.core/chunk-WYO6CB5R.mjs\");\n/* harmony import */ var _chunk_X3CZISLH_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./chunk-X3CZISLH.mjs */ \"./node_modules/mermaid/dist/chunks/mermaid.core/chunk-X3CZISLH.mjs\");\n/* harmony import */ var _chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./chunk-Y2CYZVJY.mjs */ \"./node_modules/mermaid/dist/chunks/mermaid.core/chunk-Y2CYZVJY.mjs\");\n/* harmony import */ var _mermaid_js_parser__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @mermaid-js/parser */ \"./node_modules/@mermaid-js/parser/dist/mermaid-parser.core.mjs\");\n/* harmony import */ var d3__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! d3 */ \"./node_modules/d3/src/index.js\");\n\n\n\n\n\n\n// src/diagrams/eventmodeling/parser.ts\n\n\n// src/diagrams/eventmodeling/db.ts\n\n\n// src/diagrams/eventmodeling/types.ts\nvar PositionFrameKind = \"position frame\";\nvar FramePositionedKind = \"frame positioned\";\nvar PositionRelationKind = \"position relation\";\nvar RelationPositionedKind = \"relation positioned\";\n\n// src/diagrams/eventmodeling/db.ts\nvar setOptions = /* @__PURE__ */ (0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(function(_rawOptString) {\n  _chunk_X3CZISLH_mjs__WEBPACK_IMPORTED_MODULE_3__.log.debug(\"options str\", _rawOptString);\n}, \"setOptions\");\nvar getOptions = /* @__PURE__ */ (0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(function() {\n  return {};\n}, \"getOptions\");\nvar clear2 = /* @__PURE__ */ (0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(function() {\n  reset();\n  (0,_chunk_WYO6CB5R_mjs__WEBPACK_IMPORTED_MODULE_2__.clear)();\n}, \"clear\");\nfunction reset() {\n  store = {};\n}\n;(0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(reset, \"reset\");\nvar DEFAULT_EVENTMODELING_CONFIG = _chunk_WYO6CB5R_mjs__WEBPACK_IMPORTED_MODULE_2__.defaultConfig_default.eventmodeling;\nvar getConfig3 = /* @__PURE__ */ (0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(() => {\n  const config = (0,_chunk_ICXQ74PX_mjs__WEBPACK_IMPORTED_MODULE_1__.cleanAndMerge)({\n    ...DEFAULT_EVENTMODELING_CONFIG,\n    ...(0,_chunk_WYO6CB5R_mjs__WEBPACK_IMPORTED_MODULE_2__.getConfig)().eventmodeling\n  });\n  return config;\n}, \"getConfig\");\nvar store = {};\nfunction getState() {\n  let state = initial;\n  const { ast } = store;\n  const diagramProps2 = getDiagramProps();\n  if (!ast) {\n    throw new Error(\"No data for EventModel\");\n  }\n  ast.frames.forEach((frame, index) => {\n    const textProps = calculateTextProps(frame, ast.dataEntities, diagramProps2);\n    state = dispatch(state, {\n      $kind: PositionFrameKind,\n      index,\n      frame,\n      textProps\n    });\n    let sourceFrames = void 0;\n    if (hasSourceFrame(frame)) {\n      _chunk_X3CZISLH_mjs__WEBPACK_IMPORTED_MODULE_3__.log.debug(`source frame`, frame.sourceFrames);\n      sourceFrames = ast.frames.filter((currentFrame) => {\n        return frame.sourceFrames.some((sf) => sf.$refText === currentFrame.name);\n      });\n      sourceFrames.forEach((sourceFrame) => {\n        state = dispatch(state, {\n          $kind: PositionRelationKind,\n          index,\n          frame,\n          sourceFrame\n        });\n      });\n    } else {\n      state = dispatch(state, {\n        $kind: PositionRelationKind,\n        index,\n        frame\n      });\n    }\n  });\n  state = {\n    ...state,\n    sortedSwimlanesArray: sortedSwimlanesArray(state.swimlanes)\n  };\n  return state;\n}\n;(0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(getState, \"getState\");\nfunction setAst(ast) {\n  store.ast = ast;\n}\n;(0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(setAst, \"setAst\");\nvar diagramProps = {\n  swimlaneMinHeight: 70,\n  swimlanePadding: 15,\n  swimlaneGap: 10,\n  boxPadding: 10,\n  boxOverlap: 90,\n  boxDefaultY: 0,\n  boxMinWidth: 80,\n  boxMaxWidth: 450,\n  boxMinHeight: 80,\n  boxMaxHeight: 750,\n  contentStartX: 250,\n  textMaxWidth: 450 - 2 * 10,\n  boxTextFontWeight: \"bold\",\n  boxTextPadding: 10,\n  swimlaneTextFontWeight: \"bold\",\n  labelUiAutomation: \"UI/Automation\",\n  labelUiAutomationPrefix: \"UI/A: \",\n  labelCommandReadModel: \"Command/Read Model\",\n  labelCommandReadModelPrefix: \"C/RM: \",\n  labelEvents: \"Events\",\n  labelEventsPrefix: \"Stream: \"\n};\nfunction getDiagramProps() {\n  return diagramProps;\n}\n;(0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(getDiagramProps, \"getDiagramProps\");\nvar initial = {\n  boxes: [],\n  swimlanes: {},\n  relations: [],\n  maxR: 0,\n  sortedSwimlanesArray: []\n};\nfunction extractNamespace(entityIdentifier) {\n  const spl = entityIdentifier.split(\".\");\n  if (spl.length === 2) {\n    return spl[0];\n  }\n  return void 0;\n}\n;(0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(extractNamespace, \"extractNamespace\");\nfunction extractName(entityIdentifier) {\n  const spl = entityIdentifier.split(\".\");\n  if (spl.length === 2) {\n    return spl[1];\n  }\n  return entityIdentifier;\n}\n;(0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(extractName, \"extractName\");\nfunction findSwimlaneByNamespace(swimlanes, namespace) {\n  if (!namespace || namespace.length === 0) {\n    return void 0;\n  }\n  return Object.values(swimlanes).find((swimlane) => swimlane.namespace === namespace);\n}\n;(0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(findSwimlaneByNamespace, \"findSwimlaneByNamespace\");\nfunction findNextAvailableIndex(swimlanes, boundaryMin, boundaryMax) {\n  return Math.max(\n    boundaryMin,\n    ...Object.keys(swimlanes).filter((key) => {\n      const index = Number.parseInt(key);\n      return index > boundaryMin && index < boundaryMax;\n    }).map((key) => Number.parseInt(key))\n  ) + 1;\n}\n;(0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(findNextAvailableIndex, \"findNextAvailableIndex\");\nfunction calculateSwimlaneProps(frame, swimlanes) {\n  const namespace = extractNamespace(frame.entityIdentifier);\n  const sw = findSwimlaneByNamespace(swimlanes, namespace);\n  switch (frame.modelEntityType) {\n    case \"ui\":\n    case \"pcr\":\n    case \"processor\":\n      if (sw) {\n        return {\n          index: sw.index,\n          label: sw.namespace || diagramProps.labelUiAutomation\n        };\n      } else if (namespace) {\n        return {\n          index: findNextAvailableIndex(swimlanes, 0, 100),\n          label: diagramProps.labelUiAutomationPrefix + namespace\n        };\n      }\n      return { index: 0, label: diagramProps.labelUiAutomation };\n    case \"rmo\":\n    case \"readmodel\":\n    case \"cmd\":\n    case \"command\":\n      if (sw) {\n        return {\n          index: sw.index,\n          label: sw.namespace || diagramProps.labelCommandReadModel\n        };\n      } else if (namespace) {\n        return {\n          index: findNextAvailableIndex(swimlanes, 100, 200),\n          label: diagramProps.labelCommandReadModelPrefix + namespace\n        };\n      }\n      return { index: 100, label: diagramProps.labelCommandReadModel };\n    case \"evt\":\n    case \"event\":\n    default:\n      if (sw) {\n        return {\n          index: sw.index,\n          label: sw.namespace || diagramProps.labelEvents\n        };\n      } else if (namespace) {\n        return {\n          index: findNextAvailableIndex(swimlanes, 200, 300),\n          label: diagramProps.labelEventsPrefix + namespace\n        };\n      }\n      return { index: 200, label: diagramProps.labelEvents };\n  }\n}\n;(0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(calculateSwimlaneProps, \"calculateSwimlaneProps\");\nfunction calculateEntityVisualProps(frame) {\n  const { themeVariables } = (0,_chunk_WYO6CB5R_mjs__WEBPACK_IMPORTED_MODULE_2__.getConfig)();\n  switch (frame.modelEntityType) {\n    case \"ui\":\n      return {\n        fill: themeVariables.emUiFill ?? \"white\",\n        stroke: themeVariables.emUiStroke ?? \"#dbdada\"\n      };\n    case \"pcr\":\n    case \"processor\":\n      return {\n        fill: themeVariables.emProcessorFill ?? \"#edb3f6\",\n        stroke: themeVariables.emProcessorStroke ?? \"#b88cbf\"\n      };\n    case \"rmo\":\n    case \"readmodel\":\n      return {\n        fill: themeVariables.emReadModelFill ?? \"#d3f1a2\",\n        stroke: themeVariables.emReadModelStroke ?? \"#a3b732\"\n      };\n    case \"cmd\":\n    case \"command\":\n      return {\n        fill: themeVariables.emCommandFill ?? \"#bcd6fe\",\n        stroke: themeVariables.emCommandStroke ?? \"#679ac3\"\n      };\n    case \"evt\":\n    case \"event\":\n      return {\n        fill: themeVariables.emEventFill ?? \"#ffb778\",\n        stroke: themeVariables.emEventStroke ?? \"#c19a0f\"\n      };\n    default:\n      return {\n        fill: \"red\",\n        stroke: \"black\"\n      };\n  }\n}\n;(0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(calculateEntityVisualProps, \"calculateEntityVisualProps\");\nfunction calculateTextProps(frame, dataEntities, diagramProps2) {\n  const config = (0,_chunk_WYO6CB5R_mjs__WEBPACK_IMPORTED_MODULE_2__.getConfig)();\n  const name = (0,_chunk_WYO6CB5R_mjs__WEBPACK_IMPORTED_MODULE_2__.sanitizeText)(extractName(frame.entityIdentifier) ?? \"\", config);\n  let toHtml;\n  const wrapLabelConfig = {\n    fontSize: 16,\n    fontWeight: 700,\n    fontFamily: '\"trebuchet ms\", verdana, arial, sans-serif',\n    joinWith: \"<br/>\"\n  };\n  const wrappedName = (0,_chunk_ICXQ74PX_mjs__WEBPACK_IMPORTED_MODULE_1__.wrapLabel)(name, diagramProps2.textMaxWidth, wrapLabelConfig);\n  let content = `<b>${wrappedName}</b>`;\n  if (frame.dataInlineValue) {\n    toHtml = frame.dataInlineValue;\n    toHtml = toHtml.substring(toHtml.indexOf(\"{\") + 1);\n    toHtml = toHtml.substring(0, toHtml.lastIndexOf(\"}\") - 1);\n    toHtml = (0,_chunk_WYO6CB5R_mjs__WEBPACK_IMPORTED_MODULE_2__.sanitizeText)(toHtml, config);\n    toHtml = (0,_chunk_ICXQ74PX_mjs__WEBPACK_IMPORTED_MODULE_1__.wrapLabel)(toHtml, diagramProps2.textMaxWidth, wrapLabelConfig);\n    toHtml = toHtml.replaceAll(\" \", \"&nbsp;\");\n  }\n  if (frame.dataReference) {\n    const dataEntity = dataEntities.find(\n      (dataEntity2) => dataEntity2.name === frame.dataReference?.$refText\n    );\n    if (dataEntity) {\n      toHtml = dataEntity.dataBlockValue;\n      toHtml = toHtml.substring(toHtml.indexOf(\"{\\n\") + 2);\n      toHtml = toHtml.substring(0, toHtml.lastIndexOf(\"}\") - 1);\n      toHtml = (0,_chunk_WYO6CB5R_mjs__WEBPACK_IMPORTED_MODULE_2__.sanitizeText)(toHtml, config);\n      toHtml = (0,_chunk_ICXQ74PX_mjs__WEBPACK_IMPORTED_MODULE_1__.wrapLabel)(toHtml, diagramProps2.textMaxWidth, wrapLabelConfig);\n      toHtml = toHtml.replaceAll(\" \", \"&nbsp;\");\n      toHtml += `<br/>`;\n    }\n  }\n  const hasRenderedData = toHtml !== void 0;\n  if (hasRenderedData) {\n    content += `<br/><br/><code style=\"text-align: left; display: block;max-width:${diagramProps2.textMaxWidth}px\">${toHtml}</code>`;\n  }\n  const textDimensionConfig = {\n    fontSize: wrapLabelConfig.fontSize,\n    fontWeight: wrapLabelConfig.fontWeight,\n    fontFamily: wrapLabelConfig.fontFamily\n  };\n  const dimensions = (0,_chunk_ICXQ74PX_mjs__WEBPACK_IMPORTED_MODULE_1__.calculateTextDimensions)(content, textDimensionConfig);\n  const calculatedWidthFix = hasRenderedData ? dimensions.width / 3 : dimensions.width;\n  const props = {\n    content,\n    width: calculatedWidthFix,\n    height: dimensions.height\n  };\n  _chunk_X3CZISLH_mjs__WEBPACK_IMPORTED_MODULE_3__.log.debug(`[${frame.name}] ${frame.entityIdentifier} text`, props);\n  return props;\n}\n;(0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(calculateTextProps, \"calculateTextProps\");\nfunction decidePositionFrame(state, _command) {\n  const command = _command;\n  const visual = calculateEntityVisualProps(command.frame);\n  const dimension = {\n    width: command.textProps.width + 2 * diagramProps.boxTextPadding,\n    height: command.textProps.height + 2 * diagramProps.boxTextPadding\n  };\n  const event = {\n    $kind: FramePositionedKind,\n    frame: command.frame,\n    index: command.index,\n    visual,\n    dimension,\n    textProps: command.textProps\n  };\n  return [event];\n}\n;(0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(decidePositionFrame, \"decidePositionFrame\");\nfunction calculateX(swimlane, previousSwimlane, lastBox) {\n  if (previousSwimlane === void 0) {\n    return diagramProps.contentStartX;\n  }\n  if (previousSwimlane.index === swimlane.index && swimlane.r) {\n    return swimlane.r + diagramProps.boxPadding;\n  }\n  if (lastBox === void 0) {\n    return diagramProps.contentStartX;\n  }\n  return lastBox.r - diagramProps.boxOverlap + diagramProps.boxPadding;\n}\n;(0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(calculateX, \"calculateX\");\nfunction calculateMaxRight(swimlanes, swimlaneR) {\n  const rs = [...swimlanes.map((s) => s.r), swimlaneR];\n  return Math.max(...rs);\n}\n;(0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(calculateMaxRight, \"calculateMaxRight\");\nfunction sortedSwimlanesArray(swimlanes) {\n  return Object.values(swimlanes).sort((a, b) => a.index - b.index);\n}\n;(0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(sortedSwimlanesArray, \"sortedSwimlanesArray\");\nfunction evolveFramePositioned(state, _event) {\n  const event = _event;\n  const swimlaneProps = calculateSwimlaneProps(event.frame, state.swimlanes);\n  let swimlane;\n  if (swimlaneProps.index in state.swimlanes) {\n    swimlane = state.swimlanes[swimlaneProps.index];\n  } else {\n    swimlane = {\n      index: swimlaneProps.index,\n      label: swimlaneProps.label,\n      r: 0,\n      y: swimlaneProps.index * diagramProps.swimlaneMinHeight + diagramProps.swimlaneGap,\n      height: diagramProps.swimlaneMinHeight,\n      maxHeight: diagramProps.swimlaneMinHeight\n    };\n  }\n  const lastBox = state.boxes.length > 0 ? state.boxes[state.boxes.length - 1] : void 0;\n  const previousSwimlane = state.previousSwimlaneNumber !== void 0 ? state.swimlanes[state.previousSwimlaneNumber] : void 0;\n  const dimension = {\n    width: Math.max(\n      diagramProps.boxMinWidth,\n      Math.min(diagramProps.boxMaxWidth, event.dimension.width)\n    ) + 2 * diagramProps.boxPadding,\n    height: Math.max(\n      diagramProps.boxMinHeight,\n      Math.min(diagramProps.boxMaxHeight, event.dimension.height)\n    ) + 2 * diagramProps.boxPadding\n  };\n  const x = calculateX(swimlane, previousSwimlane, lastBox);\n  const r = x + dimension.width + diagramProps.boxPadding;\n  const maxR = calculateMaxRight(Object.values(state.swimlanes), r);\n  swimlane.r = x + dimension.width;\n  swimlane.maxHeight = Math.max(swimlane.maxHeight, dimension.height);\n  swimlane.height = Math.max(diagramProps.swimlaneMinHeight, swimlane.maxHeight) + 2 * diagramProps.swimlanePadding;\n  const box = {\n    x,\n    y: diagramProps.swimlanePadding + swimlane.y,\n    // y: diagramProps.swimlanePadding + (swimlane.y || diagramProps.boxDefaultY),\n    r,\n    dimension,\n    leftSibling: false,\n    swimlane,\n    visual: event.visual,\n    text: event.textProps.content,\n    frame: event.frame,\n    index: event.index\n  };\n  const newState = {\n    ...state,\n    boxes: [...state.boxes, box],\n    swimlanes: {\n      ...state.swimlanes,\n      [`${swimlane.index}`]: swimlane\n    },\n    previousSwimlaneNumber: swimlaneProps.index,\n    previousFrame: event.frame,\n    maxR\n  };\n  const swimlanes = sortedSwimlanesArray(newState.swimlanes);\n  if (swimlanes.length > 0) {\n    swimlanes[0].y = 0;\n  }\n  for (let i = 1; i < swimlanes.length; i++) {\n    const sw = swimlanes[i];\n    const prevSw = swimlanes[i - 1];\n    sw.y = prevSw.y + prevSw.height + diagramProps.swimlaneGap;\n  }\n  return newState;\n}\n;(0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(evolveFramePositioned, \"evolveFramePositioned\");\nfunction isFirstFrame(index, frame) {\n  if (index === 0 && frame.sourceFrames.length === 0) {\n    return true;\n  }\n  return false;\n}\n;(0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(isFirstFrame, \"isFirstFrame\");\nfunction hasSourceFrame(frame) {\n  return frame.sourceFrames !== void 0 && frame.sourceFrames !== null && frame.sourceFrames.length > 0;\n}\n;(0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(hasSourceFrame, \"hasSourceFrame\");\nfunction findBoxByFrame(boxes, frame) {\n  if (frame === void 0 || frame === null) {\n    return void 0;\n  }\n  return boxes.find((box) => box.frame.name === frame.name);\n}\n;(0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(findBoxByFrame, \"findBoxByFrame\");\nfunction findBoxByLineIndex(boxes, targetSwimlane, lineIndex) {\n  if (lineIndex < 0) {\n    return void 0;\n  }\n  for (let i = lineIndex; i >= 0; i--) {\n    const box = boxes[i];\n    if (box.swimlane.index !== targetSwimlane) {\n      return box;\n    }\n  }\n  return void 0;\n}\n;(0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(findBoxByLineIndex, \"findBoxByLineIndex\");\nfunction decidePositionRelation(state, _command) {\n  const command = _command;\n  if ((0,_mermaid_js_parser__WEBPACK_IMPORTED_MODULE_5__.isEmResetFrame)(command.frame) || isFirstFrame(command.index, command.frame)) {\n    return [];\n  }\n  const targetBox = findBoxByFrame(state.boxes, command.frame);\n  if (targetBox === void 0) {\n    throw new Error(`Target box not found for frame ${command.frame.name}`);\n  }\n  let sourceBox;\n  if (command.sourceFrame) {\n    sourceBox = findBoxByFrame(state.boxes, command.sourceFrame);\n  } else {\n    sourceBox = findBoxByLineIndex(state.boxes, targetBox.swimlane.index, command.index - 1);\n  }\n  if (sourceBox === void 0) {\n    return [];\n  }\n  const event = {\n    $kind: RelationPositionedKind,\n    frame: command.frame,\n    index: command.index,\n    sourceBox,\n    targetBox\n  };\n  return [event];\n}\n;(0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(decidePositionRelation, \"decidePositionRelation\");\nfunction evolveRelationPositioned(state, _event) {\n  const event = _event;\n  const relation = {\n    visual: {\n      fill: \"none\",\n      stroke: \"#000\"\n    },\n    source: {\n      x: event.sourceBox.x,\n      y: event.sourceBox.y\n    },\n    target: {\n      x: event.targetBox.x,\n      y: event.targetBox.y\n    },\n    sourceBox: event.sourceBox,\n    targetBox: event.targetBox\n  };\n  const newState = {\n    ...state,\n    relations: [...state.relations, relation]\n  };\n  return newState;\n}\n;(0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(evolveRelationPositioned, \"evolveRelationPositioned\");\nvar deciders = {\n  [PositionFrameKind]: decidePositionFrame,\n  [PositionRelationKind]: decidePositionRelation\n};\nvar evolvers = {\n  [FramePositionedKind]: evolveFramePositioned,\n  [RelationPositionedKind]: evolveRelationPositioned\n};\nfunction decide(state, command) {\n  const fn = deciders[command.$kind];\n  if (fn === void 0 || fn === null) {\n    return [];\n  }\n  const events = fn(state, command);\n  _chunk_X3CZISLH_mjs__WEBPACK_IMPORTED_MODULE_3__.log.debug(`decided events`, events);\n  return events;\n}\n;(0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(decide, \"decide\");\nfunction evolve(state, events) {\n  const newState = events.reduce((previousState, event) => {\n    const fn = evolvers[event.$kind];\n    if (fn === void 0 || fn === null) {\n      return previousState;\n    }\n    return fn(previousState, event);\n  }, state);\n  _chunk_X3CZISLH_mjs__WEBPACK_IMPORTED_MODULE_3__.log.debug(`evolve events`, { state, newState, events });\n  return newState;\n}\n;(0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(evolve, \"evolve\");\nfunction dispatch(state, command) {\n  const events = decide(state, command);\n  const newState = evolve(state, events);\n  return newState;\n}\n;(0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(dispatch, \"dispatch\");\nvar db = {\n  getConfig: getConfig3,\n  setOptions,\n  getOptions,\n  clear: clear2,\n  setAccTitle: _chunk_WYO6CB5R_mjs__WEBPACK_IMPORTED_MODULE_2__.setAccTitle,\n  getAccTitle: _chunk_WYO6CB5R_mjs__WEBPACK_IMPORTED_MODULE_2__.getAccTitle,\n  getAccDescription: _chunk_WYO6CB5R_mjs__WEBPACK_IMPORTED_MODULE_2__.getAccDescription,\n  setAccDescription: _chunk_WYO6CB5R_mjs__WEBPACK_IMPORTED_MODULE_2__.setAccDescription,\n  setDiagramTitle: _chunk_WYO6CB5R_mjs__WEBPACK_IMPORTED_MODULE_2__.setDiagramTitle,\n  getDiagramTitle: _chunk_WYO6CB5R_mjs__WEBPACK_IMPORTED_MODULE_2__.getDiagramTitle,\n  setAst,\n  getDiagramProps,\n  getState\n};\n\n// src/diagrams/eventmodeling/parser.ts\nvar parser = {\n  parse: /* @__PURE__ */ (0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(async (input) => {\n    const ast = await (0,_mermaid_js_parser__WEBPACK_IMPORTED_MODULE_5__.parse)(\"eventmodeling\", input);\n    _chunk_X3CZISLH_mjs__WEBPACK_IMPORTED_MODULE_3__.log.debug(ast);\n    db.setAst(ast);\n    (0,_chunk_JWPE2WC7_mjs__WEBPACK_IMPORTED_MODULE_0__.populateCommonDb)(ast, db);\n  }, \"parse\")\n};\nif (void 0) {\n  const { it, expect, describe } = void 0;\n  describe(\"EventModeling Parser\", () => {\n    it(\"should parse simple model\", () => {\n      const result = parser.parse(`eventmodeling\n  tf 01 evt Start\n\n    `);\n      expect(result !== void 0);\n    });\n  });\n}\n\n// src/diagrams/eventmodeling/renderer.ts\n;\nvar DEFAULT_CONFIG = (0,_chunk_WYO6CB5R_mjs__WEBPACK_IMPORTED_MODULE_2__.getConfig2)();\nvar DEFAULT_EVENTMODELING_CONFIG2 = DEFAULT_CONFIG?.eventmodeling;\nfunction renderD3Box(diagram2, diagramProps2) {\n  return (box) => {\n    const y = box.swimlane.y + diagramProps2.swimlanePadding;\n    const g = diagram2.append(\"g\").attr(\"class\", \"em-box\");\n    g.append(\"rect\").attr(\"x\", box.x).attr(\"y\", y).attr(\"rx\", \"3\").attr(\"width\", box.dimension.width).attr(\"height\", box.dimension.height).attr(\"stroke\", box.visual.stroke).attr(\"fill\", box.visual.fill);\n    const f = g.append(\"foreignObject\").attr(\"x\", box.x + diagramProps2.boxPadding).attr(\"y\", y + 10).attr(\"width\", box.dimension.width - 2 * diagramProps2.boxPadding).attr(\"height\", box.dimension.height - 2 * diagramProps2.boxPadding);\n    const text = f.append(\"xhtml:div\").style(\"display\", \"table\").style(\"height\", \"100%\").style(\"width\", \"100%\");\n    text.append(\"span\").style(\"display\", \"table-cell\").style(\"text-align\", \"center\").style(\"vertical-align\", \"middle\").html(box.text);\n  };\n}\n;(0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(renderD3Box, \"renderD3Box\");\nfunction dirUpwards(sourceY, targetY) {\n  return sourceY > targetY;\n}\n;(0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(dirUpwards, \"dirUpwards\");\nfunction renderD3Relation(diagram2, diagramProps2, arrowheadId, themeVariables) {\n  return (relation) => {\n    const sourceBoxY = relation.sourceBox.swimlane.y + diagramProps2.swimlanePadding;\n    const targetBoxY = relation.targetBox.swimlane.y + diagramProps2.swimlanePadding;\n    const upwards = dirUpwards(sourceBoxY, targetBoxY);\n    const sourceX = relation.sourceBox.x + relation.sourceBox.dimension.width * 2 / 3;\n    const targetX = relation.targetBox.x + relation.targetBox.dimension.width / 3;\n    let sourceY;\n    let targetY;\n    _chunk_X3CZISLH_mjs__WEBPACK_IMPORTED_MODULE_3__.log.debug(`rendering relation up=${upwards} for `, {\n      sourceBox: relation.sourceBox,\n      targetBox: relation.targetBox\n    });\n    if (upwards) {\n      sourceY = sourceBoxY;\n      targetY = targetBoxY + relation.targetBox.dimension.height;\n    } else {\n      sourceY = sourceBoxY + relation.sourceBox.dimension.height;\n      targetY = targetBoxY;\n    }\n    const relationStroke = themeVariables.emRelationStroke ?? relation.visual.stroke;\n    diagram2.append(\"path\").attr(\"class\", \"em-relation\").attr(\"fill\", relation.visual.fill).attr(\"stroke\", relationStroke).attr(\"stroke-width\", \"1\").attr(\"marker-end\", `url(#${arrowheadId})`).attr(\"d\", `M${sourceX} ${sourceY} L${targetX} ${targetY}`);\n  };\n}\n;(0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(renderD3Relation, \"renderD3Relation\");\nfunction renderD3Swimlane(diagram2, maxR, diagramProps2, themeVariables) {\n  return (swimlane) => {\n    const g = diagram2.append(\"g\").attr(\"class\", \"em-swimlane\");\n    const oddBackground = themeVariables.emSwimlaneBackgroundOdd ?? \"rgb(250,250,250)\";\n    const backgroundStroke = themeVariables.emSwimlaneBackgroundStroke ?? \"rgb(240,240,240)\";\n    g.append(\"rect\").attr(\"x\", 0).attr(\"y\", swimlane.y).attr(\"rx\", \"3\").attr(\"width\", maxR + diagramProps2.swimlanePadding).attr(\"height\", swimlane.height).attr(\"fill\", oddBackground).attr(\"stroke\", backgroundStroke);\n    g.append(\"text\").attr(\"font-weight\", diagramProps2.swimlaneTextFontWeight).attr(\"x\", 30).attr(\"y\", swimlane.y + 30).text(swimlane.label);\n  };\n}\n;(0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(renderD3Swimlane, \"renderD3Swimlane\");\nvar draw = /* @__PURE__ */ (0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)(function(txt, id, ver, diagObj) {\n  _chunk_X3CZISLH_mjs__WEBPACK_IMPORTED_MODULE_3__.log.debug(\"in eventmodeling renderer\", txt + \"\\n\", \"id:\", id, ver);\n  if (!DEFAULT_EVENTMODELING_CONFIG2) {\n    throw new Error(\"EventModeling config not found\");\n  }\n  const db2 = diagObj.db;\n  const { themeVariables, eventmodeling: config } = (0,_chunk_WYO6CB5R_mjs__WEBPACK_IMPORTED_MODULE_2__.getConfig2)();\n  const diagram2 = (0,d3__WEBPACK_IMPORTED_MODULE_6__.select)(`[id=\"${id}\"]`);\n  const diagramProps2 = db2.getDiagramProps();\n  const state = db2.getState();\n  const arrowheadId = `em-arrowhead-${id}`;\n  const arrowheadColor = themeVariables.emArrowhead ?? \"#000000\";\n  state.sortedSwimlanesArray.forEach(\n    renderD3Swimlane(diagram2, state.maxR, diagramProps2, themeVariables)\n  );\n  state.boxes.forEach(renderD3Box(diagram2, diagramProps2));\n  state.relations.forEach(renderD3Relation(diagram2, diagramProps2, arrowheadId, themeVariables));\n  const marker = diagram2.append(\"defs\").append(\"marker\").attr(\"id\", arrowheadId).attr(\"markerWidth\", \"10\").attr(\"markerHeight\", \"7\").attr(\"refX\", \"10\").attr(\"refY\", \"3.5\").attr(\"orient\", \"auto\");\n  marker.append(\"polygon\").attr(\"points\", \"0 0, 10 3.5, 0 7\").attr(\"fill\", arrowheadColor);\n  (0,_chunk_WYO6CB5R_mjs__WEBPACK_IMPORTED_MODULE_2__.setupGraphViewbox2)(void 0, diagram2, config?.padding ?? 30, config?.useMaxWidth);\n}, \"draw\");\nvar renderer_default = {\n  draw\n};\n\n// src/diagrams/eventmodeling/styles.js\nvar getStyles = /* @__PURE__ */ (0,_chunk_Y2CYZVJY_mjs__WEBPACK_IMPORTED_MODULE_4__.__name)((_options) => ``, \"getStyles\");\nvar styles_default = getStyles;\n\n// src/diagrams/eventmodeling/diagram.ts\nvar diagram = {\n  parser,\n  db,\n  renderer: renderer_default,\n  styles: styles_default\n};\n\n\n\n//# sourceURL=webpack://@mdts/frontend/./node_modules/mermaid/dist/chunks/mermaid.core/diagram-FQU43EPY.mjs?\n}");

/***/ }

}]);