@notmrabhi/flowforge 0.1.52 → 0.1.54

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 (36) hide show
  1. package/dist/{GatewayBranchEdge-CrgczPYJ.js → GatewayBranchEdge-BWz43Sat.js} +99 -102
  2. package/dist/GatewayBranchEdge-BWz43Sat.js.map +1 -0
  3. package/dist/GatewayBranchEdge-Ukfp7i1Q.js +2 -0
  4. package/dist/GatewayBranchEdge-Ukfp7i1Q.js.map +1 -0
  5. package/dist/{templateSkeletons-f-XQQvyE.js → WorkflowExecutionHistory-B0OiFCyi.js} +804 -858
  6. package/dist/WorkflowExecutionHistory-B0OiFCyi.js.map +1 -0
  7. package/dist/{templateSkeletons-gOva2Xus.js → WorkflowExecutionHistory-BHb6-2lt.js} +2 -2
  8. package/dist/WorkflowExecutionHistory-BHb6-2lt.js.map +1 -0
  9. package/dist/buildBackendPayload-4SwOp7St.js +316 -0
  10. package/dist/buildBackendPayload-4SwOp7St.js.map +1 -0
  11. package/dist/buildBackendPayload-BvrjW1uM.js +2 -0
  12. package/dist/buildBackendPayload-BvrjW1uM.js.map +1 -0
  13. package/dist/canvas.cjs +1 -1
  14. package/dist/canvas.d.ts +0 -61
  15. package/dist/canvas.js +21 -25
  16. package/dist/core.cjs +1 -1
  17. package/dist/core.d.ts +163 -24
  18. package/dist/core.js +11 -9
  19. package/dist/core.js.map +1 -1
  20. package/dist/defaultUi.cjs +1 -1
  21. package/dist/defaultUi.js +1 -1
  22. package/dist/form.d.ts +0 -35
  23. package/dist/index-B-D9UuLO.js.map +1 -1
  24. package/dist/index-DUbQPmIx.js.map +1 -1
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.ts +0 -43
  28. package/dist/index.js +123 -443
  29. package/dist/index.js.map +1 -1
  30. package/dist/nodeRegistry.d.ts +0 -24
  31. package/package.json +1 -1
  32. package/dist/GatewayBranchEdge-CMY30xhz.js +0 -2
  33. package/dist/GatewayBranchEdge-CMY30xhz.js.map +0 -1
  34. package/dist/GatewayBranchEdge-CrgczPYJ.js.map +0 -1
  35. package/dist/templateSkeletons-f-XQQvyE.js.map +0 -1
  36. package/dist/templateSkeletons-gOva2Xus.js.map +0 -1
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/notificationChannelRegistry/index.ts","../src/datapills/buildVariableGroups.ts","../src/payload/buildBackendPayload.ts"],"sourcesContent":["export interface NotificationChannelOption {\n value: string;\n label: string;\n}\n\nexport interface NotificationChannelConfig {\n label: string;\n /** Fetch recipients/channels for this notification channel at runtime */\n fetchRecipients?: () => Promise<NotificationChannelOption[]>;\n}\n\nclass NotificationChannelRegistry {\n private channels = new Map<string, NotificationChannelConfig>();\n\n register(key: string, config: NotificationChannelConfig): void {\n this.channels.set(key, config);\n }\n\n get(key: string): NotificationChannelConfig | undefined {\n return this.channels.get(key);\n }\n\n list(): Array<{ key: string } & NotificationChannelConfig> {\n return Array.from(this.channels.entries()).map(([key, cfg]) => ({ key, ...cfg }));\n }\n\n has(key: string): boolean {\n return this.channels.has(key);\n }\n}\n\nexport const notificationChannelRegistry = new NotificationChannelRegistry();\nexport default NotificationChannelRegistry;\n","/**\n * buildVariableGroups — graph walker that turns upstream nodes' outputSchemas\n * into Smart Values picker groups.\n *\n * Pattern matches Workato's datapill model: every node declares what it\n * outputs; downstream nodes see the union of upstream outputs. The package\n * doesn't know your node-id scheme, your API, or your edge model — pass\n * those in via the four predicates and we do the rest.\n *\n * Usage (IAM-side):\n *\n * const variableGroups = buildVariableGroups({\n * currentNodeId,\n * nodes, // canvas state slots\n * getParents: (node) => upstreamSlotsOf(node, edges),\n * getOutputSchema: (node) => tasksByKey[node.descriptorType]?.outputSchema ?? [],\n * nodePath: (node) => node.id === 'trigger' ? 'endUser' : `data.${index(node)}`,\n * nodeLabel: (node) => node.label,\n * });\n *\n * <FlowForm variableGroups={variableGroups} ... />\n */\n\nimport type { VariableGroup, VariableItem } from '../FlowForm/VariablePicker/VariablePickerContext';\n\nexport interface OutputSchemaItem {\n key: string;\n label: string;\n /** Optional — display only. Lets the picker show a type chip (\"ABC\" / 123). */\n type?: string;\n /** Optional — shown under/beside the label in the picker (Workato-style). */\n sample?: string | number | boolean;\n /** Optional tooltip text (independent of `sample`). */\n description?: string;\n /** Nested fields — renders as an expandable subgroup. */\n children?: OutputSchemaItem[];\n}\n\nexport interface BuildVariableGroupsOptions<TNode> {\n /** Id of the node currently being configured (its outputs are NOT included). */\n currentNodeId: string;\n /** All nodes in the canvas / workflow. */\n nodes: TNode[];\n /** Return the immediate parent node(s) — consumer walks its own edge model. */\n getParents: (node: TNode, nodes: TNode[]) => TNode[];\n /** Return the node's output schema array (empty array if none). */\n getOutputSchema: (node: TNode) => OutputSchemaItem[];\n /** Return the runtime path prefix for this node (e.g. 'endUser', 'data.1'). */\n nodePath: (node: TNode) => string;\n /** Optional — group label shown in the picker. Defaults to `nodePath(node)`. */\n nodeLabel?: (node: TNode) => string;\n /**\n * Optional — function reading a node's id. Defaults to `(n) => (n as any).id`.\n * Override if your node model nests the id (e.g. `n.data.id`).\n */\n getNodeId?: (node: TNode) => string;\n}\n\n/**\n * Walks upstream from `currentNodeId` (excluding it), collects each ancestor's\n * outputSchema, and returns a `VariableGroup[]` ready for `<FlowForm variableGroups>`.\n *\n * - Excludes the current node (a node never references its own outputs).\n * - Deduplicates ancestors via id — diamond graphs don't produce duplicate groups.\n * - Skips ancestors with empty outputSchema (no group rendered for nodes that emit nothing).\n * - Preserves traversal order — the closest parent appears first in the picker.\n */\nexport function buildVariableGroups<TNode>(\n opts: BuildVariableGroupsOptions<TNode>\n): VariableGroup[] {\n const {\n currentNodeId,\n nodes,\n getParents,\n getOutputSchema,\n nodePath,\n nodeLabel,\n getNodeId = (n: TNode) => (n as unknown as { id: string }).id,\n } = opts;\n\n const current = nodes.find((n) => getNodeId(n) === currentNodeId);\n if (!current) return [];\n\n const upstream = collectUpstream(current, nodes, getParents, getNodeId);\n\n const groups: VariableGroup[] = [];\n for (const node of upstream) {\n const schema = getOutputSchema(node);\n if (!schema || schema.length === 0) continue;\n const prefix = nodePath(node);\n groups.push({\n label: nodeLabel ? nodeLabel(node) : prefix,\n items: schema.map((item) => mapToVariableItem(item, prefix)),\n });\n }\n return groups;\n}\n\n// ─── Internals ──────────────────────────────────────────────────────────────\n\nfunction collectUpstream<TNode>(\n start: TNode,\n nodes: TNode[],\n getParents: (node: TNode, nodes: TNode[]) => TNode[],\n getNodeId: (node: TNode) => string\n): TNode[] {\n const seen = new Set<string>();\n const ordered: TNode[] = [];\n // BFS upstream — the closest parent ends up first, mirroring how Workato\n // groups the most recent step at the top of the datapill panel.\n const queue: TNode[] = [...getParents(start, nodes)];\n while (queue.length > 0) {\n const node = queue.shift() as TNode;\n const id = getNodeId(node);\n if (seen.has(id)) continue;\n seen.add(id);\n ordered.push(node);\n queue.push(...getParents(node, nodes));\n }\n return ordered;\n}\n\nfunction mapToVariableItem(\n item: OutputSchemaItem,\n prefix: string\n): VariableItem {\n const path = `${prefix}.${item.key}`;\n // Workato-style: show the sample value under the label when present.\n const description =\n item.description ??\n (item.sample !== undefined && item.sample !== null\n ? String(item.sample)\n : undefined);\n const result: VariableItem = { label: item.label, path };\n if (description !== undefined) result.description = description;\n if (item.children && item.children.length > 0) {\n result.children = item.children.map((c) => mapToVariableItem(c, path));\n }\n return result;\n}\n","/**\n * buildBackendPayload — generic BPMN/DMN/canvasState emitter driven by each\n * task's `ui.bpmnEmit` block. Consumer ships per-task bpmnEmit specs from\n * the backend; the package handles the walk.\n *\n * Originally lived in IAM as `flowforgeStateToBackendJson`. Moved into the\n * package so every consumer gets the same emitter — and so DMN/filter/\n * approval fixes ship once, to everyone.\n *\n * Consumer injects:\n * - canvasState — `{ slots, branches }` from the canvas\n * - tasksByKey — `{ [descriptorType]: ApplicationTask }` lookup\n * - context — host-specific scalars (customerKey, workflowName)\n * - config — IAM-shaped defaults (path prefix, end-event ids,\n * trigger→category map, scheduler events)\n *\n * Returns a JSON object ready to POST to the backend.\n */\n\n// ─── Types ──────────────────────────────────────────────────────────────────\n\nexport type CanvasSlot = {\n id: string;\n kind?: string;\n descriptorType?: string;\n nodeData?: Record<string, unknown>;\n formData?: Record<string, unknown>;\n [key: string]: unknown;\n};\n\nexport type CanvasState = {\n slots?: CanvasSlot[];\n branches?: Record<string, unknown>;\n};\n\nexport interface FieldRef {\n from: 'literal' | 'task' | 'ctx' | 'slot' | 'formData';\n key?: string;\n value?: unknown;\n}\n\nexport interface ExtensionFieldSpec {\n name: string;\n source?: {\n type: 'literal' | 'json' | 'taskConfig' | 'formData';\n value?: unknown;\n shape?: Record<string, FieldRef>;\n passthrough?: boolean;\n exclude?: string[];\n key?: string;\n };\n}\n\nexport interface ServiceTaskSpec {\n idTemplate: string;\n name?: string;\n flowableClass?: string;\n extensionFields?: ExtensionFieldSpec[];\n}\n\nexport interface GatewaySpec {\n idTemplate: string;\n name?: string;\n}\n\nexport interface TemplateFlowSpec {\n from: string;\n to: string;\n idTemplate?: string;\n condition?: string | null;\n}\n\nexport interface DmnOutputSpec {\n id: string;\n label?: string;\n name: string;\n typeRef?: string;\n}\n\nexport interface DmnEmitSpec {\n tableName: string;\n inputExpr: string;\n hitPolicy?: string;\n outputs?: DmnOutputSpec[];\n operatorMap?: Record<string, string>;\n valuesField?: string;\n}\n\nexport interface BpmnEmitSpec {\n kind: 'linear' | 'gated' | 'filter' | 'approval';\n serviceTasks?: ServiceTaskSpec[];\n gateway?: GatewaySpec;\n templateFlows?: TemplateFlowSpec[];\n outgoingConditions?: Record<string, string>;\n dmnEmit?: DmnEmitSpec;\n callActivity?: Record<string, unknown>;\n}\n\nexport interface ApplicationTaskLike {\n name?: string;\n taskKey?: string;\n applicationUuid?: string;\n configuration?: unknown[];\n ui?: { bpmnEmit?: BpmnEmitSpec; [key: string]: unknown };\n [key: string]: unknown;\n}\n\nexport interface BuildPayloadContext {\n customerKey: string;\n workflowName: string;\n /** Anything else the host wants exposed via `from: 'ctx', key: '...'`. */\n [key: string]: unknown;\n}\n\nexport interface BuildPayloadConfig {\n /**\n * Map of trigger eventType → workflowCategory string. Defaults to a small\n * IAM-shaped fallback; consumers should pass the full map they use.\n */\n triggerToCategory?: Record<string, string>;\n /** eventType values that should set `sources: ['SCHEDULER']` and skip the message block. */\n schedulerEventTypes?: string[];\n /** DMN LHS prefix for condition expressions (default IAM-style). */\n conditionPathPrefix?: string;\n /** Fallback workflowCategory when eventType isn't mapped. */\n defaultWorkflowCategory?: string;\n /** End-event ids — override per backend convention. */\n endEventIds?: { success: string; failure: string; rejected: string };\n /** Names rendered on end events. */\n endEventNames?: { success: string; failure: string; rejected: string };\n /** Start event id used in the outer chain. */\n startEventId?: string;\n}\n\nexport interface BuildPayloadOptions {\n state: CanvasState;\n tasksByKey: Record<string, ApplicationTaskLike>;\n context: BuildPayloadContext;\n config?: BuildPayloadConfig;\n}\n\n// ─── Defaults ──────────────────────────────────────────────────────────────\n\nconst DEFAULTS: Required<BuildPayloadConfig> = {\n triggerToCategory: {\n END_USER_CREATION: 'END_USER_CREATION',\n END_USER_UPDATION: 'END_USER_UPDATION',\n DELETE_DORMANT_ACCOUNT: 'DELETE_DORMANT_ACCOUNT',\n NOTIFY_EXPIRED_PASSWORD: 'NOTIFY_EXPIRED_PASSWORD',\n },\n schedulerEventTypes: ['DELETE_DORMANT_ACCOUNT', 'NOTIFY_EXPIRED_PASSWORD'],\n conditionPathPrefix: 'startEvent.endUser',\n defaultWorkflowCategory: 'END_USER_CREATION',\n endEventIds: {\n success: 'endEventSuccess',\n failure: 'endEventFailure',\n rejected: 'endEventRejected',\n },\n endEventNames: {\n success: 'Task Completed successfully',\n failure: 'User Not Created',\n rejected: 'Approval Rejected',\n },\n startEventId: 'startEvent',\n};\n\nconst NON_TASK_KINDS = new Set([\n 'start',\n 'end',\n 'triggerFixed',\n 'addTrigger',\n 'addStep',\n]);\nconst isTaskSlot = (slot: CanvasSlot): boolean =>\n !!slot && !NON_TASK_KINDS.has(String(slot.kind ?? ''));\n\n// ─── Helpers ───────────────────────────────────────────────────────────────\n\nfunction interpolate(tpl: string | null | undefined, ctx: Record<string, unknown>): string {\n if (tpl == null) return '';\n return String(tpl).replace(/\\$\\{(\\w+)\\}/g, (m, k) =>\n Object.prototype.hasOwnProperty.call(ctx, k) ? String(ctx[k]) : m\n );\n}\n\ninterface ResolveCtx {\n task: ApplicationTaskLike;\n slot: CanvasSlot;\n ctx: BuildPayloadContext;\n}\n\nfunction resolveFieldRef(ref: FieldRef | undefined, ctx: ResolveCtx): string {\n if (!ref || typeof ref !== 'object') return '';\n const { from, key, value } = ref;\n if (from === 'literal') return value === undefined ? '' : String(value);\n if (from === 'task') return String((ctx.task as Record<string, unknown>)?.[key ?? ''] ?? '');\n if (from === 'ctx') return String((ctx.ctx as Record<string, unknown>)?.[key ?? ''] ?? '');\n if (from === 'slot') return String((ctx.slot as Record<string, unknown>)?.[key ?? ''] ?? '');\n if (from === 'formData') return String(ctx.slot?.formData?.[key ?? ''] ?? '');\n return '';\n}\n\nfunction buildExtensionStringValue(field: ExtensionFieldSpec, ctx: ResolveCtx): string {\n const source = field?.source;\n if (!source) return '';\n if (source.type === 'literal') {\n return typeof source.value === 'string'\n ? source.value\n : JSON.stringify(source.value ?? '');\n }\n if (source.type === 'json' || source.type === 'taskConfig') {\n const shape = source.shape || {};\n const out: Record<string, string> = {};\n Object.keys(shape).forEach((k) => {\n out[k] = resolveFieldRef(shape[k], ctx);\n });\n return JSON.stringify(out);\n }\n if (source.type === 'formData') {\n if (source.passthrough) {\n const exclude = new Set(source.exclude || []);\n const out: Record<string, unknown> = {};\n const fd = ctx.slot?.formData ?? {};\n Object.keys(fd).forEach((k) => {\n if (!exclude.has(k)) out[k] = fd[k];\n });\n return JSON.stringify(out);\n }\n return String(ctx.slot?.formData?.[source.key ?? ''] ?? '');\n }\n return '';\n}\n\n/** Walk a dotted path against a plain object. Returns undefined on miss. */\nfunction getValueByPath(obj: unknown, path: string): unknown {\n if (!obj || typeof obj !== 'object' || !path) return undefined;\n return path.split('.').reduce<unknown>((acc, key) => {\n if (acc == null || typeof acc !== 'object') return undefined;\n return (acc as Record<string, unknown>)[key];\n }, obj);\n}\n\n// ─── DMN rule builder ──────────────────────────────────────────────────────\n\ninterface ConditionEntry {\n field?: string;\n fieldLabel?: string;\n key?: string;\n operator?: string;\n value?: string | number | boolean | null;\n connector?: 'and' | 'or';\n logicalOperator?: 'AND' | 'OR';\n}\n\nfunction buildDmnRules(\n dmnSpec: DmnEmitSpec,\n slot: CanvasSlot,\n pathPrefix: string\n): Array<{\n id: string;\n inputEntries: Array<{ id: string; text: string }>;\n outputEntries: Array<{ id: string; text: string }>;\n}> {\n const opMap = dmnSpec.operatorMap || {};\n const valuesField = dmnSpec.valuesField || 'groups';\n\n const toJuel = (cond: ConditionEntry): string => {\n const op = opMap[String(cond?.operator ?? '')] ?? '==';\n const lhs = `${pathPrefix}.${cond?.key ?? cond?.field ?? ''}`;\n const rhs = `'${String(cond?.value ?? '')}'`;\n if (op.startsWith('.')) return `${lhs}${op}(${rhs})`;\n if (op.startsWith('!.')) return `!${lhs}${op.slice(1)}(${rhs})`;\n return `${lhs} ${op} ${rhs}`;\n };\n\n const entriesToExpression = (entries: ConditionEntry[] | undefined): string | null => {\n const list = Array.isArray(entries) ? entries : [];\n if (list.length === 0) return null;\n const parts = list.map(toJuel);\n const isOr = list[0]?.connector === 'or' || list[0]?.logicalOperator === 'OR';\n const logical = isOr ? '||' : '&&';\n return parts.join(` ${logical} `);\n };\n\n const rules: Array<{\n id: string;\n inputEntries: Array<{ id: string; text: string }>;\n outputEntries: Array<{ id: string; text: string }>;\n }> = [];\n let ruleNum = 1;\n const pushRule = (expression: string | null, outputValue: unknown) => {\n rules.push({\n id: `rule${ruleNum}`,\n inputEntries: [\n {\n id: `rule${ruleNum}InputEntry1`,\n text: expression ? `\\${(${expression})}` : '',\n },\n ],\n outputEntries: [\n {\n id: `rule${ruleNum}OutputEntry1`,\n text: `\"${outputValue}\"`,\n },\n ],\n });\n ruleNum += 1;\n };\n\n // Shape A — IAM-legacy groupBlocks[].\n const blocks = Array.isArray(slot?.formData?.groupBlocks)\n ? (slot.formData!.groupBlocks as Array<{\n conditions?: ConditionEntry[];\n [k: string]: unknown;\n }>)\n : [];\n if (blocks.length > 0) {\n blocks.forEach((block) => {\n const values = Array.isArray(block?.[valuesField])\n ? (block[valuesField] as unknown[])\n : [];\n const expression = entriesToExpression(block?.conditions);\n values.forEach((v) => pushRule(expression, v));\n });\n return rules;\n }\n\n // Shape B — FlowForm When-builder.\n const fd = (slot?.formData ?? {}) as Record<string, unknown>;\n // eslint-disable-next-line no-underscore-dangle\n const condCfg = (fd._conditionConfig ?? fd.conditionConfig) as\n | Record<string, ConditionEntry[]>\n | undefined;\n if (condCfg && typeof condCfg === 'object') {\n Object.keys(condCfg).forEach((fieldKey) => {\n const conditions = condCfg[fieldKey];\n const expression = entriesToExpression(conditions);\n // The conditionConfig key can be either a plain field name OR a dotted\n // formik path (e.g. `attributeMapping.rules.0.targetField`). Resolve\n // both shapes — first try direct, then walk the path.\n const fieldValue =\n Object.prototype.hasOwnProperty.call(fd, fieldKey)\n ? fd[fieldKey]\n : getValueByPath(fd, fieldKey);\n if (Array.isArray(fieldValue)) {\n fieldValue.forEach((v) => {\n const out =\n typeof v === 'object' && v !== null\n ? (v as { value?: unknown; label?: unknown }).value ??\n (v as { label?: unknown }).label ??\n v\n : v;\n pushRule(expression, out);\n });\n } else if (\n fieldValue !== undefined &&\n fieldValue !== null &&\n fieldValue !== ''\n ) {\n pushRule(expression, fieldValue);\n } else if (expression) {\n // Conditions present but no output value — still emit the rule with\n // an empty output so the table doesn't silently drop it. Backend\n // can treat an empty output as a no-op or surface it as a config gap.\n pushRule(expression, '');\n }\n });\n }\n return rules;\n}\n\nfunction buildDmn(dmnSpec: DmnEmitSpec, slot: CanvasSlot, pathPrefix: string) {\n return {\n mappings: [],\n name: dmnSpec.tableName,\n decision: {\n id: dmnSpec.tableName,\n name: dmnSpec.tableName,\n decisionTable: {\n id: `decisionTable_${dmnSpec.tableName}`,\n hitPolicy: dmnSpec.hitPolicy || 'FIRST',\n inputs: [\n {\n id: `input_${dmnSpec.tableName}`,\n inputExpression: {\n id: `inputExpr_${dmnSpec.tableName}`,\n typeRef: 'string',\n text: dmnSpec.inputExpr,\n },\n },\n ],\n outputs: (dmnSpec.outputs || []).map((o) => ({\n id: o.id,\n label: o.label,\n typeRef: o.typeRef || 'string',\n name: o.name,\n })),\n rules: buildDmnRules(dmnSpec, slot, pathPrefix),\n },\n },\n };\n}\n\n// ─── Task emitter ──────────────────────────────────────────────────────────\n\ninterface Emission {\n serviceTasks: unknown[];\n gateways: Array<{ id: string; name?: string }>;\n callActivities: unknown[];\n templateFlows: Array<{\n id: string;\n sourceRef: string;\n targetRef: string;\n conditionExpression: string | null;\n }>;\n dmn: ReturnType<typeof buildDmn> | null;\n bpmnEntry: string;\n bpmnExit: string;\n outgoingConditions: Record<string, string>;\n endsNeeded: Set<string>;\n}\n\nfunction emitTask(\n slot: CanvasSlot,\n task: ApplicationTaskLike,\n saveCtx: BuildPayloadContext,\n cfg: Required<BuildPayloadConfig>\n): Emission {\n const spec = task?.ui?.bpmnEmit;\n if (!spec) {\n return {\n serviceTasks: [\n {\n id: slot.id,\n name: task?.name || slot.descriptorType,\n configuration: Array.isArray(task?.configuration) ? task.configuration : [],\n input: slot.formData || {},\n },\n ],\n gateways: [],\n callActivities: [],\n templateFlows: [],\n dmn: null,\n bpmnEntry: slot.id,\n bpmnExit: slot.id,\n outgoingConditions: {},\n endsNeeded: new Set(),\n };\n }\n\n const interpCtx: Record<string, unknown> = {\n id: slot.id,\n endFailure: cfg.endEventIds.failure,\n endRejected: cfg.endEventIds.rejected,\n endSuccess: cfg.endEventIds.success,\n };\n\n const ctx: ResolveCtx = { task, slot, ctx: saveCtx };\n\n const serviceTasks = (spec.serviceTasks || []).map((st) => ({\n id: interpolate(st.idTemplate, interpCtx),\n name: st.name,\n flowableClass: st.flowableClass,\n extensionElements: {\n fields: (st.extensionFields || []).map((f) => ({\n name: f.name,\n stringValue: buildExtensionStringValue(f, ctx),\n })),\n },\n }));\n\n let gatewayId: string | null = null;\n const gateways: Array<{ id: string; name?: string }> = [];\n if (spec.gateway) {\n gatewayId = interpolate(spec.gateway.idTemplate, interpCtx);\n interpCtx.gateway = gatewayId;\n gateways.push({ id: gatewayId, name: spec.gateway.name });\n }\n\n const endsNeeded = new Set<string>();\n const templateFlows = (spec.templateFlows || []).map((f) => {\n const source = interpolate(f.from, interpCtx);\n const target = interpolate(f.to, interpCtx);\n if (target === cfg.endEventIds.failure) endsNeeded.add(cfg.endEventIds.failure);\n if (target === cfg.endEventIds.rejected) endsNeeded.add(cfg.endEventIds.rejected);\n const id = f.idTemplate\n ? interpolate(f.idTemplate, interpCtx)\n : `${source}-to-${target}`;\n return {\n id,\n sourceRef: source,\n targetRef: target,\n conditionExpression: f.condition ? interpolate(f.condition, interpCtx) : null,\n };\n });\n\n const callActivities: unknown[] = [];\n const dmn = spec.dmnEmit ? buildDmn(spec.dmnEmit, slot, cfg.conditionPathPrefix) : null;\n\n const bpmnEntry = (serviceTasks[0] as { id?: string })?.id ?? slot.id;\n const bpmnExit =\n gatewayId ??\n (serviceTasks[serviceTasks.length - 1] as { id?: string })?.id ??\n slot.id;\n\n const outgoingConditions: Record<string, string> = {};\n Object.keys(spec.outgoingConditions || {}).forEach((branch) => {\n outgoingConditions[branch] = interpolate(\n spec.outgoingConditions![branch],\n interpCtx\n );\n });\n\n return {\n serviceTasks,\n gateways,\n callActivities,\n templateFlows,\n dmn,\n bpmnEntry,\n bpmnExit,\n outgoingConditions,\n endsNeeded,\n };\n}\n\n// ─── Main entry point ──────────────────────────────────────────────────────\n\n/**\n * Generate a backend-ready payload from canvas state + task definitions.\n *\n * @example\n * const payload = buildBackendPayload({\n * state: { slots, branches },\n * tasksByKey: { USER_CREATION: {...}, USER_GROUP_ASSIGNMENT: {...} },\n * context: { customerKey: '51995', workflowName: 'My WF' },\n * config: { triggerToCategory: { CUSTOM_TRIGGER: 'CUSTOM_CATEGORY' } },\n * });\n * await api.post('/process', payload);\n */\nexport function buildBackendPayload(opts: BuildPayloadOptions): Record<string, unknown> {\n const { state, tasksByKey, context, config } = opts;\n const cfg: Required<BuildPayloadConfig> = {\n ...DEFAULTS,\n ...(config ?? {}),\n triggerToCategory: { ...DEFAULTS.triggerToCategory, ...(config?.triggerToCategory ?? {}) },\n schedulerEventTypes: config?.schedulerEventTypes ?? DEFAULTS.schedulerEventTypes,\n endEventIds: { ...DEFAULTS.endEventIds, ...(config?.endEventIds ?? {}) },\n endEventNames: { ...DEFAULTS.endEventNames, ...(config?.endEventNames ?? {}) },\n };\n\n const slots = Array.isArray(state?.slots) ? state.slots! : [];\n\n // 1. Trigger metadata\n const triggerSlot = slots.find((s) => s.kind === 'triggerFixed');\n const eventType = (triggerSlot?.nodeData as { eventType?: string } | undefined)?.eventType;\n const triggerType =\n (triggerSlot?.nodeData as { type?: string } | undefined)?.type || 'event';\n const sourcesData = (triggerSlot?.nodeData as { sources?: unknown[] } | undefined)?.sources;\n const pickedSources = Array.isArray(sourcesData)\n ? sourcesData\n .map((s) =>\n typeof s === 'string'\n ? s\n : (s as { value?: string; key?: string })?.value ??\n (s as { value?: string; key?: string })?.key ??\n ''\n )\n .filter(Boolean)\n : [];\n const workflowCategory =\n cfg.triggerToCategory[eventType ?? ''] ?? cfg.defaultWorkflowCategory;\n const isSchedulerEvent =\n !!eventType && cfg.schedulerEventTypes.includes(eventType);\n const sources = isSchedulerEvent ? ['SCHEDULER'] : pickedSources;\n\n // 2. Walk each task slot through the emitter\n const taskSlots = slots.filter(isTaskSlot);\n const emissions = taskSlots.map((slot) => ({\n slot,\n emit: emitTask(slot, tasksByKey[slot.descriptorType ?? ''] ?? {}, context, cfg),\n }));\n\n // 3. Collect emitted parts\n const allServiceTasks: unknown[] = [];\n const allGateways: Array<{ id: string; name?: string }> = [];\n const allCallActivities: unknown[] = [];\n const allTemplateFlows: Array<{\n id: string;\n sourceRef: string;\n targetRef: string;\n conditionExpression: string | null;\n }> = [];\n const allDmns: unknown[] = [];\n const endsNeeded = new Set<string>();\n\n emissions.forEach(({ emit }) => {\n allServiceTasks.push(...emit.serviceTasks);\n allGateways.push(...emit.gateways);\n allCallActivities.push(...emit.callActivities);\n allTemplateFlows.push(...emit.templateFlows);\n if (emit.dmn) allDmns.push(emit.dmn);\n emit.endsNeeded.forEach((e) => endsNeeded.add(e));\n });\n\n // 4. Outer chain — link each task's exit to the next task's entry\n const outerFlows: Array<{\n id: string;\n sourceRef: string;\n targetRef: string;\n conditionExpression: string | null;\n }> = [];\n\n if (emissions.length > 0) {\n outerFlows.push({\n id: `${cfg.startEventId}-to-${emissions[0].emit.bpmnEntry}`,\n sourceRef: cfg.startEventId,\n targetRef: emissions[0].emit.bpmnEntry,\n conditionExpression: null,\n });\n\n for (let i = 0; i < emissions.length - 1; i += 1) {\n const cur = emissions[i].emit;\n const next = emissions[i + 1].emit;\n const condition =\n cur.outgoingConditions.success ??\n cur.outgoingConditions.pass ??\n cur.outgoingConditions.approved ??\n null;\n outerFlows.push({\n id: `${cur.bpmnExit}-to-${next.bpmnEntry}`,\n sourceRef: cur.bpmnExit,\n targetRef: next.bpmnEntry,\n conditionExpression: condition,\n });\n }\n\n const last = emissions[emissions.length - 1].emit;\n outerFlows.push({\n id: `${last.bpmnExit}-to-${cfg.endEventIds.success}`,\n sourceRef: last.bpmnExit,\n targetRef: cfg.endEventIds.success,\n conditionExpression: null,\n });\n } else {\n outerFlows.push({\n id: `${cfg.startEventId}-to-${cfg.endEventIds.success}`,\n sourceRef: cfg.startEventId,\n targetRef: cfg.endEventIds.success,\n conditionExpression: null,\n });\n }\n\n // 5. End events\n const endEvent: Array<{ id: string; name: string; executionListener?: null }> = [\n {\n id: cfg.endEventIds.success,\n name: cfg.endEventNames.success,\n executionListener: null,\n },\n ...(endsNeeded.has(cfg.endEventIds.failure)\n ? [{ id: cfg.endEventIds.failure, name: cfg.endEventNames.failure }]\n : []),\n ...(endsNeeded.has(cfg.endEventIds.rejected)\n ? [{ id: cfg.endEventIds.rejected, name: cfg.endEventNames.rejected }]\n : []),\n ];\n\n // 6. Start event\n const startEvent: Record<string, unknown> = {\n id: cfg.startEventId,\n name: 'Start',\n ...(triggerType === 'event'\n ? {\n messageEventDefinition: {\n messageRef: `msg_${(eventType || 'EVENT').toLowerCase()}_${\n sources.length > 0 ? sources.join('_').toLowerCase() : 'default'\n }_${context.customerKey}`,\n },\n }\n : {}),\n };\n\n // 7. Final payload\n const json: Record<string, unknown> = {\n canvasState: {\n slots,\n branches: state?.branches ?? {},\n },\n bpmn: {\n customerId: `${context.customerKey}`,\n workflowCategory,\n sources,\n process: {\n name: context.workflowName,\n isExecutable: 'true',\n },\n startEvent,\n endEvent,\n sequenceFlows: [...outerFlows, ...allTemplateFlows],\n exclusiveGateways: allGateways,\n serviceTasks: allServiceTasks,\n callActivities: allCallActivities,\n },\n ...(triggerType === 'event'\n ? {\n message: {\n id: `msg_${(eventType || 'event').toLowerCase()}_${\n sources.length > 0 ? sources.join('_').toLowerCase() : 'default'\n }_${context.customerKey}`,\n name: `msg_${(eventType || 'event').toLowerCase()}_${\n sources.length > 0 ? sources.join('_').toLowerCase() : 'default'\n }_${context.customerKey}`,\n },\n dmns: allDmns,\n }\n : {\n eventConfig: [\n {\n eventType,\n config: {\n type: eventType,\n ...((triggerSlot?.nodeData as { scheduler?: Record<string, unknown> })?.scheduler ?? {}),\n },\n },\n ],\n }),\n };\n\n return json;\n}\n"],"names":["NotificationChannelRegistry","key","config","cfg","notificationChannelRegistry","buildVariableGroups","opts","currentNodeId","nodes","getParents","getOutputSchema","nodePath","nodeLabel","getNodeId","n","current","upstream","collectUpstream","groups","node","schema","prefix","item","mapToVariableItem","start","seen","ordered","queue","id","path","description","result","c","DEFAULTS","NON_TASK_KINDS","isTaskSlot","slot","interpolate","tpl","ctx","m","k","resolveFieldRef","ref","from","value","_a","_b","_c","_e","_d","buildExtensionStringValue","field","source","shape","out","exclude","fd","getValueByPath","obj","acc","buildDmnRules","dmnSpec","pathPrefix","opMap","valuesField","toJuel","cond","op","lhs","rhs","entriesToExpression","entries","list","parts","logical","rules","ruleNum","pushRule","expression","outputValue","blocks","block","values","v","condCfg","fieldKey","conditions","fieldValue","buildDmn","emitTask","task","saveCtx","spec","interpCtx","serviceTasks","st","f","gatewayId","gateways","endsNeeded","templateFlows","target","callActivities","dmn","bpmnEntry","bpmnExit","outgoingConditions","branch","buildBackendPayload","state","tasksByKey","context","slots","triggerSlot","s","eventType","triggerType","sourcesData","pickedSources","workflowCategory","sources","emissions","allServiceTasks","allGateways","allCallActivities","allTemplateFlows","allDmns","emit","e","outerFlows","i","cur","next","condition","last","endEvent","startEvent"],"mappings":";;;;;;;;;;;;AAWA,MAAMA,EAA4B;AAAA,EAAlC,cAAA;AACE,SAAQ,+BAAe,IAAA;AAAA,EAAuC;AAAA,EAE9D,SAASC,GAAaC,GAAyC;AAC7D,SAAK,SAAS,IAAID,GAAKC,CAAM;AAAA,EAC/B;AAAA,EAEA,IAAID,GAAoD;AACtD,WAAO,KAAK,SAAS,IAAIA,CAAG;AAAA,EAC9B;AAAA,EAEA,OAA2D;AACzD,WAAO,MAAM,KAAK,KAAK,SAAS,QAAA,CAAS,EAAE,IAAI,CAAC,CAACA,GAAKE,CAAG,OAAO,EAAE,KAAAF,GAAK,GAAGE,IAAM;AAAA,EAClF;AAAA,EAEA,IAAIF,GAAsB;AACxB,WAAO,KAAK,SAAS,IAAIA,CAAG;AAAA,EAC9B;AACF;AAEO,MAAMG,IAA8B,IAAIJ,EAAA;ACoCxC,SAASK,GACdC,GACiB;AACjB,QAAM;AAAA,IACJ,eAAAC;AAAA,IACA,OAAAC;AAAA,IACA,YAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,UAAAC;AAAA,IACA,WAAAC;AAAA,IACA,WAAAC,IAAY,CAACC,MAAcA,EAAgC;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AAA,IACzB,IAEF,CAAA;AAAA,EAAC;AAiDP,SA7CsC;AAAA,IACpC,aAAa;AAAA,MACX,OAAAC;AAAA,MACA,WAAUH,KAAA,gBAAAA,EAAO,aAAY,CAAA;AAAA,IAAC;AAAA,IAEhC,MAAM;AAAA,MACJ,YAAY,GAAGE,EAAQ,WAAW;AAAA,MAClC,kBAAAQ;AAAA,MACA,SAAAC;AAAA,MACA,SAAS;AAAA,QACP,MAAMT,EAAQ;AAAA,QACd,cAAc;AAAA,MAAA;AAAA,MAEhB,YAAAyB;AAAA,MACA,UAAAD;AAAA,MACA,eAAe,CAAC,GAAGN,GAAY,GAAGJ,CAAgB;AAAA,MAClD,mBAAmBF;AAAA,MACnB,cAAcD;AAAA,MACd,gBAAgBE;AAAA,IAAA;AAAA,IAElB,GAAIR,MAAgB,UAChB;AAAA,MACE,SAAS;AAAA,QACP,IAAI,QAAQD,KAAa,SAAS,YAAA,CAAa,IAC7CK,EAAQ,SAAS,IAAIA,EAAQ,KAAK,GAAG,EAAE,YAAA,IAAgB,SACzD,IAAIT,EAAQ,WAAW;AAAA,QACvB,MAAM,QAAQI,KAAa,SAAS,YAAA,CAAa,IAC/CK,EAAQ,SAAS,IAAIA,EAAQ,KAAK,GAAG,EAAE,YAAA,IAAgB,SACzD,IAAIT,EAAQ,WAAW;AAAA,MAAA;AAAA,MAEzB,MAAMe;AAAA,IAAA,IAER;AAAA,MACE,aAAa;AAAA,QACX;AAAA,UACE,WAAAX;AAAA,UACA,QAAQ;AAAA,YACN,MAAMA;AAAA,YACN,KAAKlE,IAAAgE,KAAA,gBAAAA,EAAa,aAAb,gBAAAhE,EAAmE,cAAa,CAAA;AAAA,UAAC;AAAA,QACxF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAIR;"}
1
+ {"version":3,"file":"index.js","sources":["../src/notificationChannelRegistry/index.ts","../src/datapills/buildVariableGroups.ts"],"sourcesContent":["export interface NotificationChannelOption {\n value: string;\n label: string;\n}\n\nexport interface NotificationChannelConfig {\n label: string;\n /** Fetch recipients/channels for this notification channel at runtime */\n fetchRecipients?: () => Promise<NotificationChannelOption[]>;\n}\n\nclass NotificationChannelRegistry {\n private channels = new Map<string, NotificationChannelConfig>();\n\n register(key: string, config: NotificationChannelConfig): void {\n this.channels.set(key, config);\n }\n\n get(key: string): NotificationChannelConfig | undefined {\n return this.channels.get(key);\n }\n\n list(): Array<{ key: string } & NotificationChannelConfig> {\n return Array.from(this.channels.entries()).map(([key, cfg]) => ({ key, ...cfg }));\n }\n\n has(key: string): boolean {\n return this.channels.has(key);\n }\n}\n\nexport const notificationChannelRegistry = new NotificationChannelRegistry();\nexport default NotificationChannelRegistry;\n","/**\n * buildVariableGroups — graph walker that turns upstream nodes' outputSchemas\n * into Smart Values picker groups.\n *\n * Pattern matches Workato's datapill model: every node declares what it\n * outputs; downstream nodes see the union of upstream outputs. The package\n * doesn't know your node-id scheme, your API, or your edge model — pass\n * those in via the four predicates and we do the rest.\n *\n * Usage (IAM-side):\n *\n * const variableGroups = buildVariableGroups({\n * currentNodeId,\n * nodes, // canvas state slots\n * getParents: (node) => upstreamSlotsOf(node, edges),\n * getOutputSchema: (node) => tasksByKey[node.descriptorType]?.outputSchema ?? [],\n * nodePath: (node) => node.id === 'trigger' ? 'endUser' : `data.${index(node)}`,\n * nodeLabel: (node) => node.label,\n * });\n *\n * <FlowForm variableGroups={variableGroups} ... />\n */\n\nimport type { VariableGroup, VariableItem } from '../FlowForm/VariablePicker/VariablePickerContext';\n\nexport interface OutputSchemaItem {\n key: string;\n label: string;\n /** Optional — display only. Lets the picker show a type chip (\"ABC\" / 123). */\n type?: string;\n /** Optional — shown under/beside the label in the picker (Workato-style). */\n sample?: string | number | boolean;\n /** Optional tooltip text (independent of `sample`). */\n description?: string;\n /** Nested fields — renders as an expandable subgroup. */\n children?: OutputSchemaItem[];\n}\n\nexport interface BuildVariableGroupsOptions<TNode> {\n /** Id of the node currently being configured (its outputs are NOT included). */\n currentNodeId: string;\n /** All nodes in the canvas / workflow. */\n nodes: TNode[];\n /** Return the immediate parent node(s) — consumer walks its own edge model. */\n getParents: (node: TNode, nodes: TNode[]) => TNode[];\n /** Return the node's output schema array (empty array if none). */\n getOutputSchema: (node: TNode) => OutputSchemaItem[];\n /** Return the runtime path prefix for this node (e.g. 'endUser', 'data.1'). */\n nodePath: (node: TNode) => string;\n /** Optional — group label shown in the picker. Defaults to `nodePath(node)`. */\n nodeLabel?: (node: TNode) => string;\n /**\n * Optional — function reading a node's id. Defaults to `(n) => (n as any).id`.\n * Override if your node model nests the id (e.g. `n.data.id`).\n */\n getNodeId?: (node: TNode) => string;\n}\n\n/**\n * Walks upstream from `currentNodeId` (excluding it), collects each ancestor's\n * outputSchema, and returns a `VariableGroup[]` ready for `<FlowForm variableGroups>`.\n *\n * - Excludes the current node (a node never references its own outputs).\n * - Deduplicates ancestors via id — diamond graphs don't produce duplicate groups.\n * - Skips ancestors with empty outputSchema (no group rendered for nodes that emit nothing).\n * - Preserves traversal order — the closest parent appears first in the picker.\n */\nexport function buildVariableGroups<TNode>(\n opts: BuildVariableGroupsOptions<TNode>\n): VariableGroup[] {\n const {\n currentNodeId,\n nodes,\n getParents,\n getOutputSchema,\n nodePath,\n nodeLabel,\n getNodeId = (n: TNode) => (n as unknown as { id: string }).id,\n } = opts;\n\n const current = nodes.find((n) => getNodeId(n) === currentNodeId);\n if (!current) return [];\n\n const upstream = collectUpstream(current, nodes, getParents, getNodeId);\n\n const groups: VariableGroup[] = [];\n for (const node of upstream) {\n const schema = getOutputSchema(node);\n if (!schema || schema.length === 0) continue;\n const prefix = nodePath(node);\n groups.push({\n label: nodeLabel ? nodeLabel(node) : prefix,\n items: schema.map((item) => mapToVariableItem(item, prefix)),\n });\n }\n return groups;\n}\n\n// ─── Internals ──────────────────────────────────────────────────────────────\n\nfunction collectUpstream<TNode>(\n start: TNode,\n nodes: TNode[],\n getParents: (node: TNode, nodes: TNode[]) => TNode[],\n getNodeId: (node: TNode) => string\n): TNode[] {\n const seen = new Set<string>();\n const ordered: TNode[] = [];\n // BFS upstream — the closest parent ends up first, mirroring how Workato\n // groups the most recent step at the top of the datapill panel.\n const queue: TNode[] = [...getParents(start, nodes)];\n while (queue.length > 0) {\n const node = queue.shift() as TNode;\n const id = getNodeId(node);\n if (seen.has(id)) continue;\n seen.add(id);\n ordered.push(node);\n queue.push(...getParents(node, nodes));\n }\n return ordered;\n}\n\nfunction mapToVariableItem(\n item: OutputSchemaItem,\n prefix: string\n): VariableItem {\n const path = `${prefix}.${item.key}`;\n // Workato-style: show the sample value under the label when present.\n const description =\n item.description ??\n (item.sample !== undefined && item.sample !== null\n ? String(item.sample)\n : undefined);\n const result: VariableItem = { label: item.label, path };\n if (description !== undefined) result.description = description;\n if (item.children && item.children.length > 0) {\n result.children = item.children.map((c) => mapToVariableItem(c, path));\n }\n return result;\n}\n"],"names":["NotificationChannelRegistry","key","config","cfg","notificationChannelRegistry","buildVariableGroups","opts","currentNodeId","nodes","getParents","getOutputSchema","nodePath","nodeLabel","getNodeId","n","current","upstream","collectUpstream","groups","node","schema","prefix","item","mapToVariableItem","start","seen","ordered","queue","id","path","description","result","c"],"mappings":";;;;;;;;;;;;;AAWA,MAAMA,EAA4B;AAAA,EAAlC,cAAA;AACE,SAAQ,+BAAe,IAAA;AAAA,EAAuC;AAAA,EAE9D,SAASC,GAAaC,GAAyC;AAC7D,SAAK,SAAS,IAAID,GAAKC,CAAM;AAAA,EAC/B;AAAA,EAEA,IAAID,GAAoD;AACtD,WAAO,KAAK,SAAS,IAAIA,CAAG;AAAA,EAC9B;AAAA,EAEA,OAA2D;AACzD,WAAO,MAAM,KAAK,KAAK,SAAS,QAAA,CAAS,EAAE,IAAI,CAAC,CAACA,GAAKE,CAAG,OAAO,EAAE,KAAAF,GAAK,GAAGE,IAAM;AAAA,EAClF;AAAA,EAEA,IAAIF,GAAsB;AACxB,WAAO,KAAK,SAAS,IAAIA,CAAG;AAAA,EAC9B;AACF;AAEO,MAAMG,IAA8B,IAAIJ,E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gBACJA,EAAK,WAAW,UAAaA,EAAK,WAAW,OAC1C,OAAOA,EAAK,MAAM,IAClB,SACAS,IAAuB,EAAE,OAAOT,EAAK,OAAO,MAAAO,EAAA;AAClD,SAAIC,MAAgB,WAAWC,EAAO,cAAcD,IAChDR,EAAK,YAAYA,EAAK,SAAS,SAAS,MAC1CS,EAAO,WAAWT,EAAK,SAAS,IAAI,CAACU,MAAMT,EAAkBS,GAAGH,CAAI,CAAC,IAEhEE;AACT;"}
@@ -59,12 +59,6 @@ declare interface ConditionFieldDef {
59
59
  value: string;
60
60
  label: string;
61
61
  }>;
62
- /**
63
- * Declarative dynamic options — same shape as `FieldDescriptor.optionsSource`.
64
- * `dependsOn` resolves against the OUTER form values (not the condition entry),
65
- * so a condition column can depend on another top-level field (e.g. attributes
66
- * scoped by `applicationUuid`).
67
- */
68
62
  optionsSource?: OptionsSource;
69
63
  /** When true, renders a FormulaInput chip editor instead of a plain <input> */
70
64
  formula?: boolean;
@@ -298,26 +292,8 @@ export declare const notificationDescriptor: NodeDescriptor;
298
292
  declare interface OptionsSource {
299
293
  /** Resolver id — must match a key in the host's `optionsResolvers` map. */
300
294
  id: string;
301
- /**
302
- * Other field values this resolver depends on. Two shapes accepted:
303
- * - `string[]` — pass through verbatim ({ fieldA: values.fieldA, ... })
304
- * - `Record<arg, fieldName>` — rename parent values for the resolver
305
- *
306
- * When any dep value changes, the cache key for this field invalidates
307
- * and the resolver re-fires.
308
- */
309
295
  dependsOn?: string[] | Record<string, string>;
310
- /**
311
- * Static params merged into the deps object for every call. Use for
312
- * "URL template via the generic resolver" style:
313
- * { id: 'default', params: { url: '/groups', valueKey: 'uuid' } }
314
- */
315
296
  params?: Record<string, unknown>;
316
- /**
317
- * Lookup individual options by value (edit-mode hydration). When set,
318
- * the field calls this resolver with `{ ids: [...] }` to render labels
319
- * for already-selected values that aren't in the current page.
320
- */
321
297
  resolveValueId?: string;
322
298
  }
323
299
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@notmrabhi/flowforge",
3
- "version": "0.1.52",
3
+ "version": "0.1.54",
4
4
  "description": "Schema-driven form renderer and workflow engine for miniOrange IAM",
5
5
  "license": "UNLICENSED",
6
6
  "author": "miniOrange",
@@ -1,2 +0,0 @@
1
- "use strict";const e=require("react/jsx-runtime"),r=require("reactflow"),z=require("@mui/material"),be=require("react-icons/gr"),ee=require("react"),Ne=require("./messages-O9Tw_XXR.js"),y=require("react-icons/md"),$=require("react-icons/fa"),ke=require("react-icons/fi"),W=require("./canvasTokens-gKNYrPl4.js"),te=ee.createContext({onEditNode:()=>{},onDeleteNode:()=>{},onAddStep:()=>{},onClickAddTrigger:()=>{},messages:Ne.defaultFlowForgeMessages,nodeRegistry:null,nodeBody:"full"}),P=()=>ee.useContext(te),ne=()=>e.jsxs("div",{style:{width:350,display:"flex",justifyContent:"center"},children:[e.jsx(r.Handle,{type:"source",position:r.Position.Bottom,style:{opacity:0,left:"50%"}}),e.jsx("div",{style:{padding:"8px 28px",borderRadius:999,background:"#f5f5f5",border:"1.5px solid #bdbdbd",fontSize:13,fontWeight:500,color:"#424242",userSelect:"none"},children:"Start"})]}),se=()=>e.jsxs("div",{style:{width:350,display:"flex",justifyContent:"center"},children:[e.jsx(r.Handle,{type:"target",position:r.Position.Top,style:{opacity:0,left:"50%"}}),e.jsx("div",{style:{padding:"8px 28px",borderRadius:999,background:"#f5f5f5",border:"1.5px solid #bdbdbd",fontSize:13,fontWeight:500,color:"#424242",userSelect:"none"},children:"End"})]}),ie=()=>{const{onClickAddTrigger:t,messages:s}=P();return e.jsxs("div",{style:{width:350,display:"flex",justifyContent:"center"},children:[e.jsx(r.Handle,{type:"target",position:r.Position.Top,style:{opacity:0,left:"50%"}}),e.jsx(z.Tooltip,{title:s.addTriggerTooltip,placement:"top",arrow:!0,children:e.jsxs("div",{onClick:t,role:"button",tabIndex:0,onKeyDown:c=>{c.key==="Enter"&&t()},style:{padding:"10px 24px",borderRadius:8,border:"1.5px dashed #d0d0d0",background:"#fff",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:8},children:[e.jsx(be.GrTrigger,{size:16}),e.jsx("span",{className:"ff-text-black",style:{fontSize:13},"data-testid":"add-trigger-btn-text",children:s.addTriggerButton})]})}),e.jsx(r.Handle,{type:"source",position:r.Position.Bottom,style:{opacity:0,left:"50%"}})]})},ve=({id:t})=>{const{onAddStep:s}=P();return e.jsxs("div",{onClick:()=>s(t),role:"button",tabIndex:0,onKeyDown:c=>{c.key==="Enter"&&s(t)},style:{width:28,height:28,borderRadius:"50%",border:"1.5px solid #9e9e9e",background:"#fff",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:18,color:"#757575",lineHeight:1,userSelect:"none"},children:[e.jsx(r.Handle,{type:"target",position:r.Position.Top,style:{opacity:0}}),"+",e.jsx(r.Handle,{type:"source",position:r.Position.Bottom,style:{opacity:0}})]})};function oe(t){return t?t.replace(/[_-]+/g," ").toLowerCase().replace(/\b\w/g,s=>s.toUpperCase()):""}function we(t){if(typeof t!="string"&&t.label)return t.label;const s=typeof t=="string"?t:t.value??"";return oe(s)}const le=({data:t})=>{const{onClickAddTrigger:s}=P(),{type:c,eventType:p,sources:d,label:o,source:g,previewWorkflow:n,executionStatus:i,infoText:f="This node decides the flow trigger type and configuration."}=t??{},u=m=>{m==null||m.stopPropagation(),s()},h=Array.isArray(d)&&d.length>0,b=!!(o||g),x=c==="scheduler"?"Scheduler Trigger":c==="event"||h||b?"Event Trigger Source":"Select Trigger",l=(()=>{if(c==="scheduler")return e.jsx("span",{children:"Scheduler to be configured"});if(c==="event"||h){const m=o||oe(p);return e.jsxs("div",{children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center",children:[e.jsx("span",{style:{fontWeight:600},children:m}),e.jsx("span",{className:"ff-ms-2 ff-text-muted",style:{fontSize:12},children:"via"})]}),e.jsx("div",{className:"ff-d-flex ff-flex-wrap ff-mt-2",style:{gap:4},children:h?d.map((w,N)=>e.jsx(z.Chip,{label:we(w),variant:"outlined",size:"small",className:"ff-text-dark"},N)):e.jsx("span",{className:"ff-text-muted",style:{fontSize:12},children:"No source selected"})})]})}return b?e.jsxs("div",{className:"ff-d-flex ff-flex-wrap ff-align-items-center",style:{gap:6},children:[o&&e.jsx("span",{style:{fontWeight:600},children:o}),g&&e.jsx(z.Chip,{label:g,variant:"outlined",size:"small"})]}):e.jsx("span",{role:"button",tabIndex:0,onClick:u,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&u(m)},style:{cursor:"pointer",color:"#1e88e5"},children:"Click to select a trigger to start your workflow"})})(),v=i?e.jsxs(e.Fragment,{children:[i.status==="success"&&e.jsx($.FaCheckCircle,{size:16,color:"#1DBF60",style:{marginRight:8}}),i.status==="failed"&&e.jsx($.FaTimesCircle,{size:16,color:"#f44336",style:{marginRight:8}})]}):e.jsxs("div",{className:"ff-d-flex ff-align-items-center",children:[!n&&e.jsx("div",{role:"button",tabIndex:0,onClick:u,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&u(m)},className:"ff-me-2",style:{cursor:"pointer",color:"#212121"},"aria-label":"Edit trigger",children:e.jsx(y.MdOutlineModeEdit,{size:16})}),e.jsx(z.Tooltip,{title:e.jsx("div",{children:f}),placement:"right",arrow:!0,children:e.jsx("span",{children:e.jsx(y.MdInfoOutline,{color:"gray",size:16})})})]});return e.jsxs("div",{style:{width:350},children:[e.jsx(r.Handle,{type:"target",position:r.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #a5d6a7",borderRadius:8,background:"#fff",overflow:"hidden"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center",style:{padding:"12px 14px"},children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{style:{width:28,height:28,borderRadius:6,background:"rgba(76,175,80,0.1)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(y.MdInput,{size:16,color:"#388e3c"})}),e.jsx("span",{style:{fontSize:14,fontWeight:500,color:"#212121"},children:x})]}),e.jsx("div",{className:"ff-d-flex ff-align-items-center",children:v})]}),e.jsx("div",{style:{background:"#f5f5f5",fontSize:12,color:"#212121",padding:"14px 16px",margin:"0 10px 12px",borderRadius:6,textAlign:"left"},children:l})]}),e.jsx(r.Handle,{type:"source",position:r.Position.Bottom,style:{opacity:0},id:"1"})]})};function Se(t){return t?t==="END_USER_CREATION"?"New User Registration":t==="END_USER_UPDATION"?"On User Update":t.replace(/[_-]+/g," ").replace(/\b\w/g,s=>s.toUpperCase()):""}function Ee(t){const s=typeof t=="string"?t:t.value??"";return s==="SIGNUP_FLOW"?"User Self-Registration":s==="ADMIN_CREATION_FLOW"?"Create User via Admin Portal":s==="SHEDULAR"||s==="SCHEDULER"?"Scheduler":typeof t!="string"&&t.label?t.label:s.replace(/[_-]+/g," ").replace(/\b\w/g,c=>c.toUpperCase())}const Te=({data:t})=>{const{header:s="Event",title:c,eventType:p,sources:d,executionStatus:o,infoText:g="This event is raised by the system. It cannot be configured."}=t??{},n=c??Se(p)??"—";return e.jsxs("div",{style:{width:350},children:[e.jsx(r.Handle,{type:"target",position:r.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #a5d6a7",borderRadius:8,background:"#fff",overflow:"hidden"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center",style:{padding:"12px 14px"},children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{style:{width:28,height:28,borderRadius:6,background:"rgba(76,175,80,0.1)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(y.MdInput,{size:16,color:"#388e3c"})}),e.jsx("span",{style:{fontSize:14,fontWeight:500,color:"#212121"},children:s})]}),e.jsxs("div",{className:"ff-d-flex ff-align-items-center",children:[(o==null?void 0:o.status)==="success"&&e.jsx($.FaCheckCircle,{size:16,color:"#1DBF60",style:{marginRight:8}}),(o==null?void 0:o.status)==="failed"&&e.jsx($.FaTimesCircle,{size:16,color:"#f44336",style:{marginRight:8}}),!o&&e.jsx(z.Tooltip,{title:e.jsx("div",{children:g}),placement:"right",arrow:!0,children:e.jsx("span",{children:e.jsx(y.MdInfoOutline,{color:"gray",size:16})})})]})]}),e.jsxs("div",{style:{background:"#f5f5f5",fontSize:13,color:"#212121",padding:"14px 16px",margin:"0 10px 12px",borderRadius:6,textAlign:"left"},children:[e.jsx("div",{style:{fontWeight:600},children:n}),Array.isArray(d)&&d.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"ff-text-muted",style:{fontSize:12,marginTop:4},children:"via"}),e.jsx("div",{className:"ff-d-flex ff-flex-wrap ff-mt-1",style:{gap:4},children:d.map((i,f)=>e.jsx(z.Chip,{label:Ee(i),variant:"outlined",size:"small",className:"ff-text-dark"},f))})]})]})]}),e.jsx(r.Handle,{type:"source",position:r.Position.Bottom,style:{opacity:0},id:"1"})]})},re=({rail:t,cardWidth:s})=>{const c=s/2;s/2+t.indent;const p="var(--ff-edge-color, #b0bec5)";return e.jsxs("svg",{width:s+t.indent+200,height:t.height,style:{position:"absolute",left:0,top:"100%",pointerEvents:"none",overflow:"visible"},children:[e.jsx("line",{x1:c,y1:0,x2:c,y2:t.height,stroke:p,strokeWidth:1.5}),t.branches.map((d,o)=>{const g=d.y;return e.jsxs("g",{transform:`translate(0, ${g})`,children:[e.jsx("rect",{x:c-5,y:-5,width:10,height:10,fill:"#fff",stroke:p,strokeWidth:1.5,transform:`rotate(45, ${c}, 0)`}),e.jsx("text",{x:c+14,y:4,fontSize:12,fontWeight:500,fill:"var(--ff-text, #212121)",style:{fontFamily:"sans-serif"},children:d.label})]},o)})]})},de=({id:t,data:s})=>{const{onEditNode:c,onDeleteNode:p}=P(),{conditions:d=[],infoText:o="Filter conditions applied to workflow data",_branchRail:g}=s;return e.jsxs("div",{style:{width:350,position:"relative"},children:[e.jsx(r.Handle,{type:"target",position:r.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #ffe082",borderRadius:8,background:"#fff"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center",style:{padding:"10px 6px"},children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center",children:[e.jsx("div",{className:"ff-d-flex ff-align-items-center ff-justify-content-center ff-rounded",style:{width:25,height:25,background:"rgba(255,160,0,0.1)"},children:e.jsx(ke.FiFilter,{className:"ff-text-warning",size:16})}),e.jsx("span",{className:"ff-ms-2 ff-fw-medium ff-text-dark",style:{fontSize:14},children:"Filter"})]}),e.jsxs("div",{className:"node-actions ff-d-flex ff-align-items-center",children:[e.jsx("div",{role:"button",tabIndex:0,onClick:n=>{n.stopPropagation(),c(t)},onKeyDown:n=>{n.key==="Enter"&&(n.stopPropagation(),c(t))},children:e.jsx(y.MdOutlineModeEdit,{size:16})}),e.jsx("div",{className:"ff-ms-2",role:"button",tabIndex:0,onClick:n=>{n.stopPropagation(),p(t)},onKeyDown:n=>{n.key==="Enter"&&(n.stopPropagation(),p(t))},children:e.jsx(y.MdDeleteOutline,{color:"red",size:16})}),e.jsx(z.Tooltip,{title:o,placement:"right",arrow:!0,children:e.jsx("div",{className:"ff-ms-2",children:e.jsx(y.MdInfoOutline,{color:"gray",size:16})})})]})]}),e.jsx("div",{style:{margin:"0 6px 10px",padding:"10px 12px",borderRadius:6,background:"#fafafa",fontSize:12},children:d.length===0?e.jsx("span",{className:"ff-text-muted",children:"No conditions configured"}):d.map((n,i)=>e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-mb-1",children:[e.jsx("p",{className:"ff-m-0 ff-fw-bold ff-me-1 ff-text-truncate",style:{maxWidth:100},title:n.field,children:n.field}),e.jsx("span",{className:"ff-text-muted",children:n.operator}),e.jsx("p",{className:"ff-text-dark ff-text-truncate ff-mx-1 ff-m-0",title:n.value,children:n.value}),i<d.length-1&&e.jsx("p",{className:"ff-bg-primary ff-text-white ff-fw-bold ff-ms-1 ff-px-1 ff-rounded-1 ff-m-0",children:n.logicalOperator})]},i))})]}),e.jsx(r.Handle,{type:"source",position:r.Position.Bottom,style:{opacity:0}}),g&&e.jsx(re,{rail:g,cardWidth:350})]})},ce=({id:t,data:s})=>{const{onEditNode:c,onDeleteNode:p,nodeRegistry:d,nodeBody:o="full"}=P(),{title:g="Task",descriptorType:n,groupBlocks:i,groups:f,roles:u,groupId:h,roleId:b,infoText:x=""}=s,l=n?d==null?void 0:d.forType(n):void 0,v=l==null?void 0:l.icon,m=a=>a==null?"":typeof a=="string"?a:typeof a=="object"&&"label"in a?String(a.label):String(a),w=a=>Array.isArray(a)?a.map(m).filter(Boolean):a!=null&&a!==""?[m(a)]:[],N=new Set(["descriptorType","title","header","icon","infoText","label","conditionConfig","_conditionConfig"]),D=l==null?void 0:l.formSchema,E=a=>{if(Array.isArray(D)){const j=D.find(k=>(k==null?void 0:k.id)===a||(k==null?void 0:k.name)===a);if(j!=null&&j.label)return j.label}return a.replace(/[_-]+/g," ").replace(/\b\w/g,j=>j.toUpperCase())},I=a=>{if(Array.isArray(a)){const j=a.map(R=>typeof R=="object"&&R?R.label??R.name??R.value??"":String(R)).filter(Boolean),k=j.slice(0,3).join(", ");return j.length>3?`${k} +${j.length-3}`:k}if(a&&typeof a=="object"){const j=a;return j.label??j.name??j.value??JSON.stringify(a)}return String(a)},C=Object.entries(s||{}).filter(([a,j])=>!N.has(a)&&j!==""&&j!==null&&j!==void 0&&!(Array.isArray(j)&&j.length===0)),T=(s==null?void 0:s.conditionConfig)??(s==null?void 0:s._conditionConfig),S=T&&typeof T=="object"?Object.entries(T).filter(([,a])=>Array.isArray(a)&&a.length>0).map(([a,j])=>({path:a,entries:j})):[],A=(i==null?void 0:i.flatMap(a=>a.groups??[]))??[...w(f),...w(u),...w(h),...w(b)],H=A.length>0;return e.jsxs("div",{style:{width:350},children:[e.jsx(r.Handle,{type:"target",position:r.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #b0bec5",borderRadius:8,background:"#fff"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center",style:{padding:"10px 6px"},children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[v&&e.jsx("div",{style:{display:"flex",alignItems:"center"},children:v}),e.jsx("span",{className:"ff-text-dark",style:{fontSize:14,fontWeight:500},children:g})]}),e.jsxs("div",{className:"node-actions ff-d-flex ff-align-items-center",children:[e.jsx("div",{role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),c(t)},onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),c(t))},children:e.jsx(y.MdOutlineModeEdit,{size:16})}),e.jsx("div",{className:"ff-ms-2",role:"button",tabIndex:0,onClick:a=>{a.stopPropagation(),p(t)},onKeyDown:a=>{a.key==="Enter"&&(a.stopPropagation(),p(t))},children:e.jsx(y.MdDeleteOutline,{color:"red",size:16})}),x&&e.jsx(z.Tooltip,{title:x,placement:"right",arrow:!0,children:e.jsx("div",{className:"ff-ms-2",children:e.jsx(y.MdInfoOutline,{color:"gray",size:16})})})]})]}),o!=="title-only"&&e.jsx("div",{style:{margin:"0 8px 8px",padding:8,borderRadius:4,background:"#f8f9fa",fontSize:12,textAlign:"left",color:"#212529",lineHeight:1.4},children:l!=null&&l.renderNode?l.renderNode(s):C.length>0||S.length>0?e.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[S.map((a,j)=>e.jsxs("div",{children:[e.jsx("div",{style:{color:"#6c757d"},children:"When"}),a.entries.slice(0,3).map((k,R,he)=>{const ye=k.field||"",ue=k.fieldLabel||E(ye),me=k.operator||"",B=k.value==null?"":typeof k.value=="object"?I(k.value):String(k.value),je=k.connector||"and";return e.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",marginTop:4},children:[e.jsx("span",{style:{fontWeight:700,marginRight:4,color:"#212529"},children:ue}),e.jsx("span",{style:{color:"#6c757d",marginRight:4},children:me}),e.jsx("span",{style:{color:"#212529",marginRight:4},title:B,children:B}),R<he.length-1&&e.jsx("span",{style:{background:"#0d6efd",color:"#fff",fontWeight:700,marginLeft:4,padding:"0 4px",borderRadius:2,textTransform:"uppercase",fontSize:10},children:je})]},R)}),a.entries.length>3&&e.jsxs("div",{style:{color:"#6c757d",fontSize:11,marginTop:2},children:["+",a.entries.length-3," more"]})]},`cond-${j}`)),C.length>0&&e.jsx("div",{style:{marginTop:4,color:"#212529",display:"flex",justifyContent:"flex-start"},children:(l==null?void 0:l.label)||g}),C.length>0&&e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginTop:4},children:[C.slice(0,6).map(([a,j])=>e.jsx("span",{title:`${E(a)}: ${I(j)}`,style:{background:"#212529",color:"#fff",padding:"4px 8px",borderRadius:4,fontSize:11},children:I(j)},a)),C.length>6&&e.jsxs("span",{style:{color:"#6c757d",fontSize:11,alignSelf:"center"},children:["+",C.length-6]})]})]}):H?e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:A.map((a,j)=>e.jsx("span",{title:a,style:{background:"#212529",color:"#fff",padding:"4px 8px",borderRadius:4,fontSize:11},children:a},j))}):e.jsx("span",{style:{color:"#6c757d"},children:"Click edit to configure"})})]}),e.jsx(r.Handle,{type:"source",position:r.Position.Bottom,style:{opacity:0}})]})},O=5,fe=({id:t,data:s})=>{const{onEditNode:c,onDeleteNode:p}=P(),{approvalData:d,isPreview:o=!1,_branchRail:g}=s,n=(d==null?void 0:d.policy)??{},i=n.stages??[],f=i.length,u=i.slice(0,O),h=f-O,b=n.name??n.policyName??"Untitled Policy";return e.jsxs("div",{style:{width:350,position:"relative"},children:[e.jsx(r.Handle,{type:"target",position:r.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #ffe082",borderRadius:8,background:"#fff"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center",style:{padding:"10px 6px"},children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{className:"ff-d-flex ff-align-items-center ff-justify-content-center ff-rounded",style:{width:25,height:25,background:"rgba(251,192,45,0.2)"},children:e.jsx(y.MdCheckCircle,{style:{color:"#FBC02D"},size:16})}),e.jsx("span",{className:"ff-fw-medium ff-text-dark",style:{fontSize:14},children:"Approval Policy"})]}),e.jsxs("div",{className:"node-actions ff-d-flex ff-align-items-center",children:[!o&&e.jsx("div",{role:"button",tabIndex:0,style:{cursor:"pointer"},onClick:x=>{x.stopPropagation(),c(t)},onKeyDown:x=>{x.key==="Enter"&&(x.stopPropagation(),c(t))},children:e.jsx(y.MdOutlineModeEdit,{size:16,className:"ff-text-secondary"})}),!o&&e.jsx("div",{className:"ff-ms-2",role:"button",tabIndex:0,style:{cursor:"pointer"},onClick:x=>{x.stopPropagation(),p(t)},onKeyDown:x=>{x.key==="Enter"&&(x.stopPropagation(),p(t))},children:e.jsx(y.MdDeleteOutline,{color:"red",size:16})}),e.jsx(z.Tooltip,{title:"This approval policy determines who must approve a request before the workflow continues.",arrow:!0,placement:"right",children:e.jsx("span",{className:"ff-ms-2 ff-d-inline-flex",children:e.jsx(y.MdInfoOutline,{color:"gray",size:16})})})]})]}),e.jsxs("div",{style:{margin:"0 6px 10px",padding:"10px 12px",borderRadius:6,background:"#FCFCFC"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-start ff-align-items-center ff-mb-2",children:[e.jsx("h6",{className:"ff-text-dark ff-mb-0 ff-text-truncate ff-flex-grow-1 ff-me-2",style:{fontSize:13,fontWeight:700},title:b,children:b}),e.jsxs("span",{className:"ff-badge ff-rounded-pill ff-px-2 ff-py-1 ff-flex-shrink-0",style:{background:"#FFF9C4",color:"#616161",fontSize:11,fontWeight:600},children:[f," Stage",f!==1?"s":""]})]}),i.length>0?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[u.map((x,l)=>{var I,C,T;const v=((I=x.stageName)==null?void 0:I.trim())||`Stage ${l+1}`,m=Array.isArray(x.userIds)?x.userIds.length:0,w=((C=x.groupName)==null?void 0:C.trim())??"",N=((T=x.roleName)==null?void 0:T.trim())??"",D=m>0||w||N;let E="Not configured";return w?E=`Group: ${w}`:N?E=`Role: ${N}`:m>0&&(E=`${m} approver${m!==1?"s":""}`),e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{className:"ff-rounded-circle ff-d-flex ff-align-items-center ff-justify-content-center ff-flex-shrink-0",style:{width:28,height:28,background:"#FFF9C4",color:"#5D4037",fontSize:12,fontWeight:700},children:l+1}),e.jsxs("div",{className:"ff-flex-grow-1 ff-rounded ff-p-2 ff-d-flex ff-justify-content-between ff-align-items-center ff-border",style:{background:"#FFFDE7",borderColor:"#FEE79A"},children:[e.jsx("span",{style:{fontSize:12,fontWeight:700,color:"#212121"},children:v}),e.jsxs("span",{className:`ff-d-flex ff-align-items-center ff-gap-1 ${D?"ff-text-dark":"ff-text-muted"}`,style:{fontSize:12},children:[e.jsx(y.MdPeople,{size:16,className:"ff-flex-shrink-0",style:{color:D?"#5D4037":"#9E9E9E"}}),E]})]})]},l)}),h>0&&e.jsxs("div",{className:"ff-text-center ff-fw-bold ff-py-2 ff-border ff-rounded",style:{fontSize:11,color:"#1976d2",borderColor:"#FEE79A",background:"#FFFDE7",borderStyle:"dashed",cursor:o?"default":"pointer"},role:o?void 0:"button",tabIndex:o?void 0:0,onClick:x=>{o||(x.stopPropagation(),c(t))},onKeyDown:x=>{o||x.key!=="Enter"||(x.stopPropagation(),c(t))},children:["+ ",h," More Stage",h>1?"s":""]})]}):e.jsx("div",{className:"ff-text-center ff-py-3 ff-rounded ff-border",style:{fontSize:12,color:"#9e9e9e",background:"#FFFDE7",borderColor:"#FEE79A",borderStyle:"dashed"},children:"No stages configured"})]})]}),e.jsx(r.Handle,{type:"source",position:r.Position.Bottom,style:{opacity:0}}),g&&e.jsx(re,{rail:g,cardWidth:350})]})},ae=({id:t,data:s})=>{const{onEditNode:c,onDeleteNode:p}=P(),{duration:d,unit:o}=s,g=d!=null&&o,n=g?`Wait ${d} ${o}`:"Not configured";return e.jsxs("div",{style:{width:350},children:[e.jsx(r.Handle,{type:"target",position:r.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #b0bec5",borderRadius:8,background:"#fff"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center ff-mx-2 ff-mt-2 ff-mb-1",children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{className:"ff-d-flex ff-align-items-center ff-justify-content-center ff-rounded",style:{width:25,height:25,background:"rgba(33,150,243,0.1)"},children:e.jsx(y.MdSchedule,{size:16,color:"#1976d2"})}),e.jsx("span",{className:"ff-fw-medium ff-text-dark",style:{fontSize:14},children:"Delay"})]}),e.jsxs("div",{className:"node-actions ff-d-flex ff-align-items-center",children:[e.jsx("div",{role:"button",tabIndex:0,onClick:i=>{i.stopPropagation(),c(t)},onKeyDown:i=>{i.key==="Enter"&&(i.stopPropagation(),c(t))},children:e.jsx(y.MdOutlineModeEdit,{size:16})}),e.jsx("div",{className:"ff-ms-2",role:"button",tabIndex:0,onClick:i=>{i.stopPropagation(),p(t)},onKeyDown:i=>{i.key==="Enter"&&(i.stopPropagation(),p(t))},children:e.jsx(y.MdDeleteOutline,{color:"red",size:16})})]})]}),e.jsx("div",{className:"ff-mx-2 ff-mb-2 ff-p-2 ff-rounded",style:{background:"#fafafa",fontSize:12},children:e.jsx("span",{className:g?"ff-text-dark ff-fw-medium":"ff-text-muted",children:n})})]}),e.jsx(r.Handle,{type:"source",position:r.Position.Bottom,style:{opacity:0}})]})},_={email:{label:"Email",bg:"#e3f2fd",color:"#1565c0",iconType:y.MdEmail},slack:{label:"Slack",bg:"#e8f5e9",color:"#2e7d32",iconType:y.MdNotifications},teams:{label:"MS Teams",bg:"#ede7f6",color:"#4527a0",iconType:y.MdNotifications},sms:{label:"SMS",bg:"#fce4ec",color:"#880e4f",iconType:y.MdSms},"in-app":{label:"In-App",bg:"#fff3e0",color:"#e65100",iconType:y.MdNotifications},webhook:{label:"Webhook",bg:"#f3e5f5",color:"#6a1b9a",iconType:y.MdWebhook}},Ce={label:"Notification",bg:"rgba(156,39,176,0.1)",color:"#7b1fa2",iconType:y.MdNotifications};function Pe(t){var s;switch(t.channel){case"email":return((s=t.emailTo)==null?void 0:s.join(", "))??t.recipient??null;case"slack":return t.slackChannel??null;case"teams":return t.teamsMessage?"Message configured":null;case"sms":return t.smsTo??null;case"in-app":return t.inAppRecipient??null;case"webhook":return t.webhookUrl??null;default:return t.recipient??null}}function Ie(t){switch(t.channel){case"email":return t.emailSubject??t.subject??null;case"slack":{const s=t.slackMessage;return s?s.length>60?`${s.slice(0,60)}…`:s:null}case"in-app":return t.inAppTitle??null;default:return t.subject??null}}const pe=({id:t,data:s})=>{const{onEditNode:c,onDeleteNode:p}=P(),d=s,o=d.channel&&_[d.channel]?_[d.channel]:Ce,g=Pe(d),n=Ie(d),i=!!(d.channel&&g),f=o.iconType;return e.jsxs("div",{style:{width:W.NODE_WIDTH},children:[e.jsx(r.Handle,{type:"target",position:r.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #b0bec5",borderRadius:8,background:"#fff"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center",style:{padding:"10px 6px"},children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{className:"ff-d-flex ff-align-items-center ff-justify-content-center ff-rounded",style:{width:25,height:25,background:o.bg},children:e.jsx(f,{size:16,color:o.color})}),e.jsx("span",{className:"ff-fw-medium ff-text-dark",style:{fontSize:14},children:d.channel?`${o.label} Notification`:"Notification"})]}),e.jsxs("div",{className:"node-actions ff-d-flex ff-align-items-center",children:[e.jsx("div",{role:"button",tabIndex:0,onClick:u=>{u.stopPropagation(),c(t)},onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&(u.stopPropagation(),c(t))},children:e.jsx(y.MdOutlineModeEdit,{size:16})}),e.jsx("div",{className:"ff-ms-2",role:"button",tabIndex:0,onClick:u=>{u.stopPropagation(),p(t)},onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&(u.stopPropagation(),p(t))},children:e.jsx(y.MdDeleteOutline,{color:"red",size:16})})]})]}),e.jsx("div",{style:{margin:"0 6px 10px",padding:"10px 12px",borderRadius:6,background:"#fafafa",fontSize:12},children:i?e.jsxs("div",{className:"ff-d-flex ff-flex-column ff-gap-1",children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("span",{className:"ff-px-2 ff-py-1 ff-rounded",style:{fontSize:10,background:o.bg,color:o.color,fontWeight:600,flexShrink:0},children:o.label}),e.jsx("span",{className:"ff-text-dark ff-text-truncate",style:{maxWidth:220},children:g})]}),n&&e.jsx("span",{className:"ff-text-muted ff-text-truncate",style:{maxWidth:280},children:n})]}):e.jsx("span",{className:"ff-text-muted",children:"Not configured"})})]}),e.jsx(r.Handle,{type:"source",position:r.Position.Bottom,style:{opacity:0}})]})},K={"api-key":"API Key",hmac:"HMAC"},xe=({data:t})=>{const{onClickAddTrigger:s}=P(),{label:c="Webhook Trigger",endpointUrl:p,authMethod:d,source:o}=t,g=i=>{i.stopPropagation(),s()},n=i=>{i.stopPropagation(),p&&navigator.clipboard.writeText(p).catch(()=>{})};return e.jsxs("div",{style:{width:W.NODE_WIDTH},children:[e.jsx(r.Handle,{type:"target",position:r.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #90caf9",borderRadius:8,background:"#fff",overflow:"hidden"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center",style:{padding:"10px 6px"},children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{style:{width:28,height:28,borderRadius:6,background:"rgba(33,150,243,0.1)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(y.MdWebhook,{size:16,color:"#1565c0"})}),e.jsx("span",{style:{fontSize:13,fontWeight:600,color:"#212121"},children:"Webhook Trigger"})]}),e.jsx("div",{role:"button",tabIndex:0,onClick:g,onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&g(i)},className:"ff-d-flex ff-align-items-center",style:{paddingRight:4,cursor:"pointer"},children:e.jsx(y.MdOutlineModeEdit,{size:16,color:"#555"})})]}),e.jsxs("div",{style:{margin:"0 6px 10px",padding:"10px 12px",borderRadius:6,background:"#e3f2fd",border:"1px solid #90caf9"},children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-flex-wrap ff-gap-2 ff-mb-1",children:[e.jsx("span",{style:{fontSize:12,color:"#1565c0",fontWeight:600},children:c}),o&&e.jsx("span",{className:"ff-px-2 ff-py-1 ff-rounded",style:{fontSize:11,background:"#fff",border:"1px solid #90caf9",color:"#1565c0"},children:o}),d&&d!=="none"&&K[d]&&e.jsx("span",{className:"ff-px-2 ff-py-1 ff-rounded",style:{fontSize:10,background:"#1565c0",color:"#fff",fontWeight:600},children:K[d]})]}),p&&e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-1",style:{marginTop:4},children:[e.jsx("span",{style:{fontSize:10,color:"#1565c0",fontFamily:"monospace",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p}),e.jsx(z.Tooltip,{title:"Copy URL",placement:"top",arrow:!0,children:e.jsx("div",{role:"button",tabIndex:0,onClick:n,onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&n(i)},style:{cursor:"pointer",flexShrink:0},children:e.jsx(y.MdContentCopy,{size:12,color:"#1565c0"})})})]})]})]}),e.jsx(r.Handle,{type:"source",position:r.Position.Bottom,style:{opacity:0}})]})},ge=({id:t,data:s})=>{var b;const{onEditNode:c,onDeleteNode:p,nodeRegistry:d}=P(),{method:o,url:g,descriptorType:n}=s,i=n?(b=d==null?void 0:d.forType(n))==null?void 0:b.icon:e.jsx(y.MdHttp,{size:16,color:"#546e7a"}),f=!!(o&&g),u=(o==null?void 0:o.toUpperCase())??"",h=W.HTTP_METHOD_STYLE[u]??null;return e.jsxs("div",{style:{width:W.NODE_WIDTH},children:[e.jsx(r.Handle,{type:"target",position:r.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #b0bec5",borderRadius:8,background:"#fff"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center",style:{padding:"10px 6px"},children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{style:{width:25,height:25,display:"flex",alignItems:"center",justifyContent:"center"},children:i}),e.jsx("span",{className:"ff-fw-medium ff-text-dark",style:{fontSize:14},children:"REST API Call"})]}),e.jsxs("div",{className:"node-actions ff-d-flex ff-align-items-center",children:[e.jsx("div",{role:"button",tabIndex:0,onClick:x=>{x.stopPropagation(),c(t)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.stopPropagation(),c(t))},children:e.jsx(y.MdOutlineModeEdit,{size:16})}),e.jsx("div",{className:"ff-ms-2",role:"button",tabIndex:0,onClick:x=>{x.stopPropagation(),p(t)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.stopPropagation(),p(t))},children:e.jsx(y.MdDeleteOutline,{color:"red",size:16})})]})]}),e.jsx("div",{style:{margin:"0 6px 10px",padding:"10px 12px",borderRadius:6,background:"#fafafa",fontSize:12},children:f?e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[h&&e.jsx("span",{style:{fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:4,background:h.bg,color:h.color,flexShrink:0},children:u}),e.jsx("span",{className:"ff-text-dark ff-text-truncate",style:{fontFamily:"monospace",fontSize:11},title:g,children:g})]}):e.jsx("span",{className:"ff-text-muted",children:"Not configured"})})]}),e.jsx(r.Handle,{type:"source",position:r.Position.Bottom,style:{opacity:0}})]})},ze={eq:"=",neq:"≠",gt:">",gte:"≥",lt:"<",lte:"≤",contains:"contains",startsWith:"starts with",endsWith:"ends with",isEmpty:"is empty",isNotEmpty:"is not empty"},De=({id:t,data:s})=>{const{onEditNode:c,onDeleteNode:p}=P(),{title:d="Condition Branch",branchConfigs:o=[],defaultBranch:g}=s,n=o.length>0;return e.jsxs("div",{style:{width:W.NODE_WIDTH},children:[e.jsx(r.Handle,{type:"target",position:r.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #b39ddb",borderRadius:8,background:"#fff"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center",style:{padding:"10px 6px"},children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{style:{width:25,height:25,borderRadius:6,background:"rgba(103,58,183,0.1)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(y.MdCallSplit,{size:16,color:"#512da8"})}),e.jsx("span",{className:"ff-fw-medium ff-text-dark",style:{fontSize:14},children:d})]}),e.jsxs("div",{className:"node-actions ff-d-flex ff-align-items-center",children:[e.jsx("div",{role:"button",tabIndex:0,onClick:i=>{i.stopPropagation(),c(t)},onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&(i.stopPropagation(),c(t))},children:e.jsx(y.MdOutlineModeEdit,{size:16})}),e.jsx("div",{className:"ff-ms-2",role:"button",tabIndex:0,onClick:i=>{i.stopPropagation(),p(t)},onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&(i.stopPropagation(),p(t))},children:e.jsx(y.MdDeleteOutline,{color:"red",size:16})})]})]}),e.jsx("div",{style:{margin:"0 6px 10px",padding:"10px 12px",borderRadius:6,background:"#fafafa",fontSize:12},children:n?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[o.map((i,f)=>{var x,l;const u=W.BRANCH_PALETTE[f%W.BRANCH_PALETTE.length],h=(x=i.conditions)==null?void 0:x[0],b=(((l=i.conditions)==null?void 0:l.length)??0)-1;return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:10,background:u.bg,color:u.color,flexShrink:0},children:i.label||i.key}),h?e.jsxs("span",{style:{fontSize:11,color:"#616161",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[h.field," ",ze[h.operator]??h.operator,h.value?` ${h.value}`:"",b>0?` +${b} more`:""]}):e.jsx("span",{style:{fontSize:11,color:"#9e9e9e"},children:"No conditions yet"})]},i.key)}),g&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginTop:2},children:[e.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:10,background:"#f5f5f5",color:"#757575",flexShrink:0},children:"Default"}),e.jsx("span",{style:{fontSize:11,color:"#9e9e9e"},children:"fallback path"})]})]}):e.jsx("span",{className:"ff-text-muted",children:"Not configured — click edit to add branches"})})]}),e.jsx(r.Handle,{type:"source",position:r.Position.Bottom,style:{opacity:0}})]})},Ae=({id:t,data:s})=>{var x;const{onEditNode:c,onDeleteNode:p,nodeRegistry:d}=P(),{title:o="Sub-Workflow",workflowId:g,workflowLabel:n,descriptorType:i,onPreview:f}=s,u=i?(x=d==null?void 0:d.forType(i))==null?void 0:x.icon:e.jsx(y.MdAccountTree,{size:16,color:"#00695c"}),h=!!g,b=l=>{l.stopPropagation(),g&&f&&f(g)};return e.jsxs("div",{style:{width:W.NODE_WIDTH},children:[e.jsx(r.Handle,{type:"target",position:r.Position.Top,style:{opacity:0}}),e.jsxs("div",{style:{border:"1.5px solid #80cbc4",borderRadius:8,background:"#fff"},children:[e.jsxs("div",{className:"ff-d-flex ff-justify-content-between ff-align-items-center",style:{padding:"10px 6px"},children:[e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-gap-2",children:[e.jsx("div",{style:{width:25,height:25,borderRadius:6,background:"rgba(0,137,123,0.1)",display:"flex",alignItems:"center",justifyContent:"center"},children:u}),e.jsx("span",{className:"ff-fw-medium ff-text-dark",style:{fontSize:14},children:o})]}),e.jsxs("div",{className:"node-actions ff-d-flex ff-align-items-center",children:[e.jsx("div",{role:"button",tabIndex:0,onClick:l=>{l.stopPropagation(),c(t)},onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.stopPropagation(),c(t))},children:e.jsx(y.MdOutlineModeEdit,{size:16})}),e.jsx("div",{className:"ff-ms-2",role:"button",tabIndex:0,onClick:l=>{l.stopPropagation(),p(t)},onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.stopPropagation(),p(t))},children:e.jsx(y.MdDeleteOutline,{color:"red",size:16})})]})]}),e.jsx("div",{style:{margin:"0 6px 10px",padding:"10px 12px",borderRadius:6,background:h?"#e0f2f1":"#fafafa",fontSize:12,border:h?"1px solid #b2dfdb":"none"},children:h?e.jsxs("div",{className:"ff-d-flex ff-align-items-center ff-justify-content-between",children:[e.jsxs("div",{className:"ff-d-flex ff-flex-column ff-gap-1",children:[e.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#00695c"},children:n||g}),e.jsxs("span",{style:{fontSize:10,color:"#80cbc4",fontFamily:"monospace"},children:["ID: ",g]})]}),f&&e.jsxs("div",{role:"button",tabIndex:0,onClick:b,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&b(l)},style:{cursor:"pointer",display:"flex",alignItems:"center",gap:3,fontSize:11,color:"#00897b"},children:[e.jsx(y.MdOpenInNew,{size:13}),"Preview"]})]}):e.jsx("span",{className:"ff-text-muted",children:"Not configured — select a workflow"})})]}),e.jsx(r.Handle,{type:"source",position:r.Position.Bottom,style:{opacity:0}})]})},Re={startNode:ne,endNode:se,addTriggerNode:ie,addStepNode:ve,triggerNode:le,eventNode:Te,filterNode:de,actionNode:ce,approvalNode:fe,delayNode:ae,notificationNode:pe,webhookTriggerNode:xe,restApiNode:ge,conditionBranchNode:De,subWorkflowNode:Ae},We=11.5,U=2,L=6,q=40,G=20,V=4,Le=({id:t,sourceX:s,sourceY:c,targetX:p,targetY:d,sourcePosition:o,targetPosition:g,source:n,target:i,data:f})=>{const[u,h,b]=r.getStraightPath({sourceX:s,sourceY:c,targetX:p,targetY:d}),x=f==null?void 0:f.label,l=x==="Pass",v=l||x==="Fail",m=s+(p-s)/3,w=c+(d-c)/3,N=s+2*(p-s)/3,D=c+2*(d-c)/3,E=f==null?void 0:f.onAddStepClick,I=A=>{if(A.stopPropagation(),typeof E!="function")return;const H={edgeId:t,nodeId:n,sourceNodeId:n,targetNodeId:i,position:"between",referenceNodeId:n,referenceNodeType:f==null?void 0:f.referenceNodeType,stepVisibility:f==null?void 0:f.stepVisibility};E(n,H)},C=A=>{(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),I(A))},T=()=>e.jsxs(e.Fragment,{children:[e.jsxs("g",{className:"plus-icon-container",children:[e.jsx("circle",{r:We,className:"edge-plus-circle"}),e.jsx("line",{x1:0,y1:-L,x2:0,y2:L,strokeWidth:U,strokeLinecap:"round",className:"plus-line"}),e.jsx("line",{x1:-L,y1:0,x2:L,y2:0,strokeWidth:U,strokeLinecap:"round",className:"plus-line"})]}),e.jsxs("g",{className:"edge-plus-tooltip",transform:"translate(18, 0)",children:[e.jsx("rect",{x:0,y:-10,width:65,height:20,rx:4,className:"tooltip-bg"}),e.jsx("path",{d:"M0 -4 L-4 0 L0 4 Z",className:"tooltip-bg"}),e.jsx("text",{x:32,y:0,textAnchor:"middle",dominantBaseline:"central",fill:"white",style:{fontSize:10,fontWeight:600,pointerEvents:"none"},children:"Add Step"})]})]}),S=E?{onClick:I,onKeyDown:C,role:"button",tabIndex:0,style:{cursor:"pointer",pointerEvents:"all"}}:{style:{cursor:"default",pointerEvents:"all"}};return e.jsxs("g",{className:"edge-with-plus-wrapper",children:[e.jsx(r.BaseEdge,{id:t,path:u}),v?e.jsxs(e.Fragment,{children:[e.jsxs("g",{transform:`translate(${m}, ${w})`,children:[e.jsx("rect",{x:-q/2,y:-G/2,width:q,height:G,rx:V,ry:V,fill:l?"#ADE6C5":"#FDBFBF"}),e.jsx("text",{textAnchor:"middle",dominantBaseline:"central",fill:l?"#1DBF60":"#C50000",style:{fontSize:12,fontWeight:500},children:x})]}),e.jsx("g",{className:"nodrag nopan edge-plus-svg",transform:`translate(${N}, ${D})`,"data-testid":"plus-node-icon",...S,children:e.jsx(T,{})})]}):e.jsx("g",{className:"nodrag nopan edge-plus-svg",transform:`translate(${h}, ${b})`,"data-testid":"plus-node-icon",...S,children:e.jsx(T,{})})]})},Me=11.5,Z=2,M=6,Fe=({id:t,sourceX:s,sourceY:c,targetX:p,targetY:d,source:o,target:g,data:n})=>{const[i,f,u]=r.getStraightPath({sourceX:s,sourceY:c,targetX:p,targetY:d}),h=n==null?void 0:n.onAddStepClick,b=l=>{l.stopPropagation(),typeof h=="function"&&h(o,{edgeId:t,nodeId:o,sourceNodeId:o,targetNodeId:g,position:"between",referenceNodeId:o,referenceNodeType:n==null?void 0:n.referenceNodeType,stepVisibility:n==null?void 0:n.stepVisibility,filterId:n==null?void 0:n.filterId,branch:n==null?void 0:n.branch})},x=l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),b(l))};return e.jsxs("g",{className:"edge-with-plus-wrapper",children:[e.jsx(r.BaseEdge,{id:t,path:i,style:{stroke:"#b0bec5"}}),e.jsxs("g",{className:"nodrag nopan edge-plus-svg",transform:`translate(${f}, ${u})`,style:{cursor:h?"pointer":"default",pointerEvents:"all",outline:"none"},onClick:h?b:void 0,onKeyDown:h?x:void 0,role:h?"button":void 0,tabIndex:h?0:void 0,"data-testid":"plus-node-icon",children:[e.jsx("circle",{r:Me,className:"edge-plus-circle"}),e.jsx("line",{x1:0,y1:-M,x2:0,y2:M,strokeWidth:Z,strokeLinecap:"round",className:"plus-line"}),e.jsx("line",{x1:-M,y1:0,x2:M,y2:0,strokeWidth:Z,strokeLinecap:"round",className:"plus-line"}),e.jsxs("g",{className:"edge-plus-tooltip",transform:"translate(18, 0)",children:[e.jsx("rect",{x:0,y:-10,width:65,height:20,rx:4,className:"tooltip-bg"}),e.jsx("path",{d:"M0 -4 L-4 0 L0 4 Z",className:"tooltip-bg"}),e.jsx("text",{x:32,y:0,textAnchor:"middle",dominantBaseline:"central",fill:"white",style:{fontSize:10,fontWeight:600,pointerEvents:"none"},children:"Add Step"})]})]})]})},$e=({id:t,sourceX:s,sourceY:c,targetX:p,targetY:d})=>{const[o]=r.getStraightPath({sourceX:s,sourceY:c,targetX:p,targetY:d});return e.jsx(r.BaseEdge,{id:t,path:o,style:{stroke:"#b0bec5"}})},He=11.5,Y=2,F=6,Be=-24,J=40,Q=20,X=4,Oe=({id:t,sourceX:s,sourceY:c,targetX:p,targetY:d,source:o,target:g,data:n})=>{const[i,f,u]=r.getStraightPath({sourceX:s,sourceY:c,targetX:p,targetY:d}),h=n==null?void 0:n.label,b=h==="Pass",x=b||h==="Fail",l=n==null?void 0:n.onAddStepClick,v=(n==null?void 0:n.showPlus)!==!1&&!!l,m=N=>{N.stopPropagation(),typeof l=="function"&&l(o,{edgeId:t,nodeId:o,sourceNodeId:o,targetNodeId:g,position:"between",referenceNodeId:o,referenceNodeType:n==null?void 0:n.referenceNodeType,stepVisibility:n==null?void 0:n.stepVisibility})},w=N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),m(N))};return e.jsxs("g",{className:"edge-with-plus-wrapper",children:[e.jsx(r.BaseEdge,{id:t,path:i,style:{stroke:"#b0bec5"}}),e.jsxs("g",{className:"nodrag nopan edge-plus-svg",transform:`translate(${f}, ${u})`,style:{cursor:l?"pointer":"default",pointerEvents:"all",outline:"none"},onClick:l?m:void 0,onKeyDown:l?w:void 0,role:l?"button":void 0,tabIndex:l?0:void 0,children:[x&&e.jsxs("g",{transform:`translate(0, ${v?Be:0})`,children:[e.jsx("rect",{x:-J/2,y:-Q/2,width:J,height:Q,rx:X,ry:X,fill:b?"#ADE6C5":"#FDBFBF"}),e.jsx("text",{textAnchor:"middle",dominantBaseline:"central",fill:b?"#1DBF60":"#C50000",style:{fontSize:12,fontWeight:500},children:h})]}),v&&e.jsxs("g",{className:"plus-icon-container",children:[e.jsx("circle",{r:He,className:"edge-plus-circle"}),e.jsx("line",{x1:0,y1:-F,x2:0,y2:F,strokeWidth:Y,strokeLinecap:"round",className:"plus-line"}),e.jsx("line",{x1:-F,y1:0,x2:F,y2:0,strokeWidth:Y,strokeLinecap:"round",className:"plus-line"})]}),v&&e.jsxs("g",{className:"edge-plus-tooltip",transform:"translate(22, 0)",children:[e.jsx("rect",{x:0,y:-10,width:65,height:20,rx:4,className:"tooltip-bg"}),e.jsx("path",{d:"M0 -4 L-4 0 L0 4 Z",className:"tooltip-bg"}),e.jsx("text",{x:32,y:0,textAnchor:"middle",dominantBaseline:"central",fill:"white",style:{fontSize:10,fontWeight:600,pointerEvents:"none"},children:"Add Step"})]})]})]})},_e=({id:t,source:s,target:c,sourceX:p,sourceY:d,targetX:o,targetY:g,style:n={},markerEnd:i,data:f})=>{const u=(f==null?void 0:f.verticalRouting)??!1,h=30,b=u?(()=>{const S=g-h;return`M ${p},${S} L ${o},${S} L ${o},${g}`})():(()=>{const S=d+30;return`M ${p},${d} L ${p},${S} L ${o},${S} L ${o},${g}`})(),x=n.stroke||"#d1d5db",l=f==null?void 0:f.label,v=(f==null?void 0:f.isFirst)??!1,m=f==null?void 0:f.onAddStepClick,w=u?g-h:d+30,N=p+(o-p)*(u?.25:.35),D=p+(o-p)*(u?.65:.7),E=w,I=S=>{S.stopPropagation(),m&&m(s,{edgeId:t,nodeId:s,sourceNodeId:s,targetNodeId:c,position:"between",referenceNodeId:s,filterId:f==null?void 0:f.filterId,branch:f==null?void 0:f.branch})},C=11.5,T=6;return e.jsxs("g",{children:[e.jsx("path",{id:t,d:b,fill:"none",stroke:x,strokeWidth:1.5,markerEnd:i}),l&&!u&&e.jsx("g",{transform:`translate(${N}, ${E})`,children:(()=>{const S=Math.max(44,l.length*7+20);return e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:-S/2,y:-11,width:S,height:22,rx:11,fill:v?"#e8f5e9":"#ffebee",stroke:v?"#81c784":"#e57373",strokeWidth:1}),e.jsx("text",{x:0,y:4,textAnchor:"middle",fontSize:10,fontWeight:600,fill:v?"#2e7d32":"#c62828",style:{fontFamily:"sans-serif",pointerEvents:"none"},children:l})]})})()}),m&&e.jsxs("g",{transform:`translate(${D}, ${E})`,onClick:I,style:{cursor:"pointer",pointerEvents:"all"},className:"nodrag nopan edge-plus-svg",children:[e.jsx("circle",{r:C,className:"edge-plus-circle"}),e.jsx("line",{x1:0,y1:-T,x2:0,y2:T,strokeWidth:2,strokeLinecap:"round",className:"plus-line"}),e.jsx("line",{x1:-T,y1:0,x2:T,y2:0,strokeWidth:2,strokeLinecap:"round",className:"plus-line"})]})]})};exports.ActionNode=ce;exports.AddTriggerNode=ie;exports.ApprovalNode=fe;exports.DelayNode=ae;exports.EdgeWithPlusLabel=Le;exports.EndNode=se;exports.FilterNode=de;exports.GatewayBranchEdge=_e;exports.LabelPlusEdge=Oe;exports.NotificationNode=pe;exports.PlainEdge=$e;exports.PlusEdge=Fe;exports.RestApiNode=ge;exports.StartNode=ne;exports.TriggerNode=le;exports.WebhookTriggerNode=xe;exports.WorkflowCanvasContext=te;exports.builtInNodeTypes=Re;
2
- //# sourceMappingURL=GatewayBranchEdge-CMY30xhz.js.map