markdown-flow-ui 0.2.35 → 0.2.36-dev.1
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.
- package/README.md +12 -0
- package/dist/_virtual/index.es8.js +2 -2
- package/dist/_virtual/index.es9.js +2 -2
- package/dist/_virtual/index8.cjs +1 -1
- package/dist/_virtual/index9.cjs +1 -1
- package/dist/_virtual/variable-name.cjs +2 -0
- package/dist/_virtual/variable-name.cjs.map +1 -0
- package/dist/_virtual/variable-name.es.js +5 -0
- package/dist/_virtual/variable-name.es.js.map +1 -0
- package/dist/components/ContentRender/plugins/CustomVariable.cjs +1 -1
- package/dist/components/ContentRender/plugins/CustomVariable.cjs.map +1 -1
- package/dist/components/ContentRender/plugins/CustomVariable.es.js +52 -51
- package/dist/components/ContentRender/plugins/CustomVariable.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.cjs.map +1 -1
- package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.es.js +71 -70
- package/dist/components/MarkdownFlowEditor/MarkdownFlowEditor.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/components/VariableSelect.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/components/VariableSelect.cjs.map +1 -1
- package/dist/components/MarkdownFlowEditor/components/VariableSelect.es.js +16 -16
- package/dist/components/MarkdownFlowEditor/components/VariableSelect.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/locales/ar-SA.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/ar-SA.json.d.ts +1 -1
- package/dist/components/MarkdownFlowEditor/locales/ar-SA.json.es.js +1 -1
- package/dist/components/MarkdownFlowEditor/locales/de-DE.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/de-DE.json.d.ts +1 -1
- package/dist/components/MarkdownFlowEditor/locales/de-DE.json.es.js +23 -23
- package/dist/components/MarkdownFlowEditor/locales/en-US.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/en-US.json.d.ts +1 -1
- package/dist/components/MarkdownFlowEditor/locales/en-US.json.es.js +15 -15
- package/dist/components/MarkdownFlowEditor/locales/es-ES.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/es-ES.json.d.ts +1 -1
- package/dist/components/MarkdownFlowEditor/locales/es-ES.json.es.js +13 -13
- package/dist/components/MarkdownFlowEditor/locales/fil-PH.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/fil-PH.json.d.ts +1 -1
- package/dist/components/MarkdownFlowEditor/locales/fil-PH.json.es.js +8 -8
- package/dist/components/MarkdownFlowEditor/locales/fr-FR.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/fr-FR.json.d.ts +1 -1
- package/dist/components/MarkdownFlowEditor/locales/fr-FR.json.es.js +13 -13
- package/dist/components/MarkdownFlowEditor/locales/ja-JP.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/ja-JP.json.d.ts +1 -1
- package/dist/components/MarkdownFlowEditor/locales/ja-JP.json.es.js +1 -1
- package/dist/components/MarkdownFlowEditor/locales/th-TH.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/th-TH.json.d.ts +1 -1
- package/dist/components/MarkdownFlowEditor/locales/th-TH.json.es.js +1 -1
- package/dist/components/MarkdownFlowEditor/locales/ur-PK.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/ur-PK.json.d.ts +1 -1
- package/dist/components/MarkdownFlowEditor/locales/ur-PK.json.es.js +1 -1
- package/dist/components/MarkdownFlowEditor/locales/vi-VN.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/vi-VN.json.d.ts +1 -1
- package/dist/components/MarkdownFlowEditor/locales/vi-VN.json.es.js +11 -11
- package/dist/components/MarkdownFlowEditor/locales/zh-CN.json.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/locales/zh-CN.json.d.ts +1 -1
- package/dist/components/MarkdownFlowEditor/locales/zh-CN.json.es.js +1 -1
- package/dist/components/MarkdownFlowEditor/plugins/SyntaxHighlighter.cjs +3 -3
- package/dist/components/MarkdownFlowEditor/plugins/SyntaxHighlighter.cjs.map +1 -1
- package/dist/components/MarkdownFlowEditor/plugins/SyntaxHighlighter.es.js +104 -103
- package/dist/components/MarkdownFlowEditor/plugins/SyntaxHighlighter.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/plugins/VariablePlaceholder.test.d.ts +1 -0
- package/dist/components/MarkdownFlowEditor/utils.cjs +1 -1
- package/dist/components/MarkdownFlowEditor/utils.cjs.map +1 -1
- package/dist/components/MarkdownFlowEditor/utils.d.ts +2 -3
- package/dist/components/MarkdownFlowEditor/utils.es.js +43 -50
- package/dist/components/MarkdownFlowEditor/utils.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/utils.variables.test.d.ts +1 -0
- package/dist/lib/interaction-defaults.cjs +1 -1
- package/dist/lib/interaction-defaults.cjs.map +1 -1
- package/dist/lib/interaction-defaults.es.js +49 -49
- package/dist/lib/interaction-defaults.es.js.map +1 -1
- package/dist/node_modules/@braintree/sanitize-url/dist/index.cjs +1 -1
- package/dist/node_modules/@braintree/sanitize-url/dist/index.es.js +1 -1
- package/dist/node_modules/classnames/index.cjs +1 -1
- package/dist/node_modules/classnames/index.es.js +1 -1
- package/dist/node_modules/cose-base/cose-base.cjs +1 -1
- package/dist/node_modules/cose-base/cose-base.cjs.map +1 -1
- package/dist/node_modules/cose-base/cose-base.es.js +1 -1
- package/dist/node_modules/cytoscape-fcose/node_modules/cose-base/cose-base.cjs +1 -1
- package/dist/node_modules/cytoscape-fcose/node_modules/cose-base/cose-base.cjs.map +1 -1
- package/dist/node_modules/cytoscape-fcose/node_modules/cose-base/cose-base.es.js +1 -1
- package/dist/node_modules/cytoscape-fcose/node_modules/layout-base/layout-base.cjs +1 -1
- package/dist/node_modules/cytoscape-fcose/node_modules/layout-base/layout-base.cjs.map +1 -1
- package/dist/node_modules/cytoscape-fcose/node_modules/layout-base/layout-base.es.js +1 -1
- package/dist/node_modules/layout-base/layout-base.cjs +1 -1
- package/dist/node_modules/layout-base/layout-base.cjs.map +1 -1
- package/dist/node_modules/layout-base/layout-base.es.js +1 -1
- package/dist/node_modules/remark-flow/dist/index.cjs +1 -1
- package/dist/node_modules/remark-flow/dist/index.cjs.map +1 -1
- package/dist/node_modules/remark-flow/dist/index.es.js +41 -24
- package/dist/node_modules/remark-flow/dist/index.es.js.map +1 -1
- package/dist/node_modules/remark-flow/dist/interaction-parser.cjs +1 -1
- package/dist/node_modules/remark-flow/dist/interaction-parser.cjs.map +1 -1
- package/dist/node_modules/remark-flow/dist/interaction-parser.es.js +44 -45
- package/dist/node_modules/remark-flow/dist/interaction-parser.es.js.map +1 -1
- package/dist/node_modules/remark-flow/dist/variable-name.cjs +2 -0
- package/dist/node_modules/remark-flow/dist/variable-name.cjs.map +1 -0
- package/dist/node_modules/remark-flow/dist/variable-name.es.js +31 -0
- package/dist/node_modules/remark-flow/dist/variable-name.es.js.map +1 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interaction-defaults.es.js","sources":["../../src/lib/interaction-defaults.ts"],"sourcesContent":["import {\n createInteractionParser,\n INTERACTION_CONTENT_SOURCE,\n} from \"remark-flow\";\n\nexport interface InteractionParseResult {\n buttonTexts?: string[];\n buttonValues?: string[];\n placeholder?: string;\n variableName?: string;\n isMultiSelect?: boolean;\n}\n\nexport interface InteractionDefaultValues {\n buttonText?: string;\n inputText?: string;\n selectedValues?: string[];\n}\n\nexport interface InteractionDefaultResolverParams {\n content?: string | null;\n rawValue?: string | null;\n interactionInfo?: InteractionParseResult | null;\n}\n\nexport type InteractionDefaultResolver = (\n params: InteractionDefaultResolverParams\n) => InteractionDefaultValues | null | undefined;\n\nexport interface InteractionDefaultValueOptions {\n resolveDefaultValues?: InteractionDefaultResolver;\n}\n\ninterface StructuredInteractionPayload {\n buttonText?: unknown;\n inputText?: unknown;\n selectedValues?: unknown;\n}\n\nconst interactionParser = createInteractionParser();\nconst INTERACTION_TAG_PATTERN = /<custom-variable\\b/i;\n// Same definition of where an interaction ends as the parser uses, so an option carrying a\n// `\\]` is read whole instead of being cut at its first bracket. A variable assignment is optional.\nconst INTERACTION_SHORTCODE_PATTERN = new RegExp(\n `\\\\?\\\\[(?:%\\\\{\\\\{([^}]+)\\\\}\\\\})?(${INTERACTION_CONTENT_SOURCE})\\\\]`\n);\nconst JSON_LIKE_VALUE_PATTERN = /^[\\[{]/;\nconst INTERACTION_VALUE_SEPARATOR_PATTERN = /^[\\s,,\\n]+/;\n\ninterface InteractionOptionCandidate {\n token: string;\n value: string;\n}\n\nconst parseInteractionShortcode = (\n content?: string | null\n): InteractionParseResult | null => {\n if (!content) {\n return null;\n }\n\n const matched = content.match(INTERACTION_SHORTCODE_PATTERN);\n const variableName = matched?.[1]?.trim();\n const interactionBody = matched?.[2]?.trim();\n\n if (!interactionBody) {\n return null;\n }\n\n const isMultiSelect = interactionBody.includes(\"||\");\n const separator = isMultiSelect ? \"||\" : \"|\";\n const rawOptions = interactionBody\n .split(separator)\n .map((item) => item.trim())\n .filter(Boolean);\n\n if (!rawOptions.length) {\n return null;\n }\n\n const buttonTexts: string[] = [];\n const buttonValues: string[] = [];\n let placeholder: string | undefined;\n\n rawOptions.forEach((option) => {\n if (option.startsWith(\"...\")) {\n const normalizedPlaceholder = option.replace(/^\\.\\.\\./, \"\").trim();\n if (normalizedPlaceholder) {\n placeholder = normalizedPlaceholder;\n }\n return;\n }\n\n buttonTexts.push(option);\n buttonValues.push(option);\n });\n\n return {\n variableName,\n buttonTexts: buttonTexts.length ? buttonTexts : undefined,\n buttonValues: buttonValues.length ? buttonValues : undefined,\n placeholder,\n isMultiSelect,\n };\n};\n\nconst parseInteractionBlock = (\n content?: string | null\n): InteractionParseResult | null => {\n if (!content) {\n return null;\n }\n\n try {\n return interactionParser.parseToRemarkFormat(\n content\n ) as InteractionParseResult;\n } catch (error) {\n console.warn(\"Failed to parse interaction block\", error);\n }\n\n return parseInteractionShortcode(content);\n};\n\nconst normalizeButtonValue = (\n token: string,\n info: InteractionParseResult\n): { value: string; display?: string } | null => {\n if (!token) {\n return null;\n }\n\n const cleaned = token.trim();\n const buttonValues = info.buttonValues || [];\n const buttonTexts = info.buttonTexts || [];\n const valueIndex = buttonValues.indexOf(cleaned);\n\n if (valueIndex > -1) {\n return {\n value: buttonValues[valueIndex],\n display: buttonTexts[valueIndex],\n };\n }\n\n const textIndex = buttonTexts.indexOf(cleaned);\n\n if (textIndex > -1) {\n return {\n value: buttonValues[textIndex] || buttonTexts[textIndex],\n display: buttonTexts[textIndex],\n };\n }\n\n return null;\n};\n\nconst splitPresetValues = (raw: string) => {\n return raw\n .split(/[,,\\n]/)\n .map((item) => item.trim())\n .filter(Boolean);\n};\n\nconst trimLeadingInteractionSeparators = (raw: string) =>\n raw.replace(INTERACTION_VALUE_SEPARATOR_PATTERN, \"\");\n\nconst buildInteractionOptionCandidates = (\n info: InteractionParseResult\n): InteractionOptionCandidate[] => {\n const buttonValues = info.buttonValues || [];\n const buttonTexts = info.buttonTexts || [];\n const candidates: InteractionOptionCandidate[] = [];\n const seenCandidates = new Set<string>();\n\n buttonValues.forEach((buttonValue, index) => {\n const normalizedValue = `${buttonValue ?? \"\"}`.trim();\n const normalizedText = `${buttonTexts[index] ?? \"\"}`.trim();\n\n [normalizedValue, normalizedText].forEach((token) => {\n if (!token) {\n return;\n }\n\n const candidateKey = `${token}::${normalizedValue || token}`;\n if (seenCandidates.has(candidateKey)) {\n return;\n }\n\n seenCandidates.add(candidateKey);\n candidates.push({\n token,\n value: normalizedValue || token,\n });\n });\n });\n\n return candidates.sort(\n (left, right) => right.token.length - left.token.length\n );\n};\n\nconst matchInteractionOptionPrefix = (\n raw: string,\n info: InteractionParseResult\n): InteractionOptionCandidate | null => {\n const normalizedRaw = trimLeadingInteractionSeparators(raw);\n const candidates = buildInteractionOptionCandidates(info);\n\n for (const candidate of candidates) {\n if (!normalizedRaw.startsWith(candidate.token)) {\n continue;\n }\n\n const trailingChar = normalizedRaw[candidate.token.length];\n if (trailingChar && !/[\\s,,\\n]/.test(trailingChar)) {\n continue;\n }\n\n return candidate;\n }\n\n return null;\n};\n\nconst resolveMultiSelectFallbackDefaults = (\n raw: string,\n info: InteractionParseResult\n): InteractionDefaultValues => {\n const tokens = splitPresetValues(raw);\n\n if (!tokens.length) {\n return {};\n }\n\n const selectedValues: string[] = [];\n const customInputs: string[] = [];\n\n tokens.forEach((token) => {\n const mapped = normalizeButtonValue(token, info);\n\n if (mapped) {\n selectedValues.push(mapped.value);\n return;\n }\n\n if (info.placeholder) {\n customInputs.push(token);\n return;\n }\n\n selectedValues.push(token);\n });\n\n return {\n selectedValues: selectedValues.length ? selectedValues : undefined,\n inputText: customInputs.length ? customInputs.join(\", \") : undefined,\n };\n};\n\nconst resolveMultiSelectInteractionDefaults = (\n raw: string,\n info: InteractionParseResult\n): InteractionDefaultValues => {\n const selectedValues: string[] = [];\n let remainingRaw = raw.trim();\n\n // Prefer option-aware prefix matching before delimiter splitting so\n // option labels that contain commas can still round-trip correctly.\n while (remainingRaw) {\n const matchedCandidate = matchInteractionOptionPrefix(remainingRaw, info);\n\n if (!matchedCandidate) {\n break;\n }\n\n selectedValues.push(matchedCandidate.value);\n const normalizedRemainingRaw =\n trimLeadingInteractionSeparators(remainingRaw);\n remainingRaw = trimLeadingInteractionSeparators(\n normalizedRemainingRaw.slice(matchedCandidate.token.length)\n );\n }\n\n if (selectedValues.length > 0) {\n return {\n selectedValues,\n inputText:\n info.placeholder && remainingRaw.trim()\n ? remainingRaw.trim()\n : undefined,\n };\n }\n\n const fallbackDefaults = resolveMultiSelectFallbackDefaults(raw, info);\n\n if (fallbackDefaults.selectedValues?.length) {\n return fallbackDefaults;\n }\n\n if (info.placeholder) {\n return {\n inputText: raw.trim(),\n };\n }\n\n return fallbackDefaults;\n};\n\nconst normalizeStructuredInteractionDefaults = (\n payload?: StructuredInteractionPayload | null\n): InteractionDefaultValues | null => {\n if (!payload || Array.isArray(payload)) {\n return null;\n }\n\n const selectedValues = Array.isArray(payload.selectedValues)\n ? payload.selectedValues\n .map((item) => `${item ?? \"\"}`.trim())\n .filter(Boolean)\n : undefined;\n const buttonText = `${payload.buttonText ?? \"\"}`.trim();\n const inputText =\n typeof payload.inputText === \"string\" ? payload.inputText : undefined;\n\n if (!selectedValues?.length && !buttonText && !inputText) {\n return null;\n }\n\n return {\n buttonText: buttonText || undefined,\n inputText,\n selectedValues: selectedValues?.length ? selectedValues : undefined,\n };\n};\n\nconst parseStructuredInteractionDefaults = (rawValue?: string | null) => {\n if (!rawValue) {\n return null;\n }\n\n if (!JSON_LIKE_VALUE_PATTERN.test(rawValue.trim())) {\n return null;\n }\n\n try {\n const parsed = JSON.parse(rawValue) as StructuredInteractionPayload;\n return normalizeStructuredInteractionDefaults(parsed);\n } catch {\n return null;\n }\n};\n\nconst hasPotentialInteractionBlock = (content?: string | null) =>\n Boolean(\n content &&\n (INTERACTION_TAG_PATTERN.test(content) ||\n INTERACTION_SHORTCODE_PATTERN.test(content))\n );\n\nconst resolveCustomInteractionDefaults = (\n content?: string | null,\n rawValue?: string | null,\n interactionInfo?: InteractionParseResult | null,\n options?: InteractionDefaultValueOptions\n) => {\n return (\n options?.resolveDefaultValues?.({\n content,\n rawValue,\n interactionInfo,\n }) ?? null\n );\n};\n\nexport const getInteractionDefaultValues = (\n content?: string | null,\n rawValue?: string | null,\n options?: InteractionDefaultValueOptions\n): InteractionDefaultValues => {\n const normalized = rawValue?.toString().trim();\n\n if (!normalized) {\n return {};\n }\n\n const structuredDefaults = parseStructuredInteractionDefaults(normalized);\n\n if (structuredDefaults) {\n return structuredDefaults;\n }\n\n const customDefaults = resolveCustomInteractionDefaults(\n content,\n normalized,\n null,\n options\n );\n\n if (customDefaults) {\n return customDefaults;\n }\n\n if (!hasPotentialInteractionBlock(content)) {\n return {\n buttonText: normalized,\n inputText: normalized,\n };\n }\n\n const interactionInfo = parseInteractionBlock(content);\n const customDefaultsWithInteraction = resolveCustomInteractionDefaults(\n content,\n normalized,\n interactionInfo,\n options\n );\n\n if (customDefaultsWithInteraction) {\n return customDefaultsWithInteraction;\n }\n\n if (!interactionInfo) {\n return {\n buttonText: normalized,\n inputText: normalized,\n };\n }\n\n if (interactionInfo.isMultiSelect) {\n return resolveMultiSelectInteractionDefaults(normalized, interactionInfo);\n }\n\n const mapped = normalizeButtonValue(normalized, interactionInfo);\n\n if (mapped) {\n return {\n buttonText: mapped.value || mapped.display || normalized,\n };\n }\n\n if (interactionInfo.placeholder) {\n return {\n inputText: normalized,\n };\n }\n\n return {\n buttonText: normalized,\n inputText: normalized,\n };\n};\n\nexport const getInteractionDefaultSelectedValues = (\n content?: string | null,\n rawValue?: string | null,\n options?: InteractionDefaultValueOptions\n) => {\n const defaults = getInteractionDefaultValues(content, rawValue, options);\n\n if (defaults.selectedValues) {\n return defaults.selectedValues;\n }\n\n return rawValue\n ? rawValue\n .split(\",\")\n .map((value) => value.trim())\n .filter(Boolean)\n : undefined;\n};\n"],"names":["interactionParser","createInteractionParser","INTERACTION_TAG_PATTERN","INTERACTION_SHORTCODE_PATTERN","INTERACTION_CONTENT_SOURCE","JSON_LIKE_VALUE_PATTERN","INTERACTION_VALUE_SEPARATOR_PATTERN","parseInteractionShortcode","content","matched","variableName","interactionBody","isMultiSelect","separator","rawOptions","item","buttonTexts","buttonValues","placeholder","option","normalizedPlaceholder","parseInteractionBlock","error","normalizeButtonValue","token","info","cleaned","valueIndex","textIndex","splitPresetValues","raw","trimLeadingInteractionSeparators","buildInteractionOptionCandidates","candidates","seenCandidates","buttonValue","index","normalizedValue","normalizedText","candidateKey","left","right","matchInteractionOptionPrefix","normalizedRaw","candidate","trailingChar","resolveMultiSelectFallbackDefaults","tokens","selectedValues","customInputs","mapped","resolveMultiSelectInteractionDefaults","remainingRaw","matchedCandidate","normalizedRemainingRaw","fallbackDefaults","normalizeStructuredInteractionDefaults","payload","buttonText","inputText","parseStructuredInteractionDefaults","rawValue","parsed","hasPotentialInteractionBlock","resolveCustomInteractionDefaults","interactionInfo","options","getInteractionDefaultValues","normalized","structuredDefaults","customDefaults","customDefaultsWithInteraction","getInteractionDefaultSelectedValues","defaults","value"],"mappings":";AAuCA,MAAMA,IAAoBC,EAAAA,wBAAA,GACpBC,IAA0B,uBAG1BC,IAAgC,IAAI;AAAA,EACxC,mCAAmCC,EAAAA,0BAA0B;AAC/D,GACMC,IAA0B,UAC1BC,IAAsC,cAOtCC,IAA4B,CAChCC,MACkC;AAClC,MAAI,CAACA;AACH,WAAO;AAGT,QAAMC,IAAUD,EAAQ,MAAML,CAA6B,GACrDO,IAAeD,IAAU,CAAC,GAAG,KAAA,GAC7BE,IAAkBF,IAAU,CAAC,GAAG,KAAA;AAEtC,MAAI,CAACE;AACH,WAAO;AAGT,QAAMC,IAAgBD,EAAgB,SAAS,IAAI,GAC7CE,IAAYD,IAAgB,OAAO,KACnCE,IAAaH,EAChB,MAAME,CAAS,EACf,IAAI,CAACE,MAASA,EAAK,KAAA,CAAM,EACzB,OAAO,OAAO;AAEjB,MAAI,CAACD,EAAW;AACd,WAAO;AAGT,QAAME,IAAwB,CAAA,GACxBC,IAAyB,CAAA;AAC/B,MAAIC;AAEJ,SAAAJ,EAAW,QAAQ,CAACK,MAAW;AAC7B,QAAIA,EAAO,WAAW,KAAK,GAAG;AAC5B,YAAMC,IAAwBD,EAAO,QAAQ,WAAW,EAAE,EAAE,KAAA;AAC5D,MAAIC,MACFF,IAAcE;AAEhB;AAAA,IACF;AAEA,IAAAJ,EAAY,KAAKG,CAAM,GACvBF,EAAa,KAAKE,CAAM;AAAA,EAC1B,CAAC,GAEM;AAAA,IACL,cAAAT;AAAA,IACA,aAAaM,EAAY,SAASA,IAAc;AAAA,IAChD,cAAcC,EAAa,SAASA,IAAe;AAAA,IACnD,aAAAC;AAAA,IACA,eAAAN;AAAA,EAAA;AAEJ,GAEMS,IAAwB,CAC5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AAYA;AAAA,IACZ,WAAWA;AAAA,EAAA;AAEf,GAEaI,IAAsC,CACjDhE,GACAqD,GACAK,MACG;AACH,QAAMO,IAAWN,EAA4B3D,GAASqD,GAAUK,CAAO;AAEvE,SAAIO,EAAS,iBACJA,EAAS,iBAGXZ,IACHA,EACG,MAAM,GAAG,EACT,IAAI,CAACa,MAAUA,EAAM,KAAA,CAAM,EAC3B,OAAO,OAAO,IACjB;AACN;"}
|
|
1
|
+
{"version":3,"file":"interaction-defaults.es.js","sources":["../../src/lib/interaction-defaults.ts"],"sourcesContent":["import {\n createInteractionParser,\n createVariableExpressionRegex,\n normalizeVariableName,\n INTERACTION_CONTENT_SOURCE,\n} from \"remark-flow\";\n\nexport interface InteractionParseResult {\n buttonTexts?: string[];\n buttonValues?: string[];\n placeholder?: string;\n variableName?: string;\n isMultiSelect?: boolean;\n}\n\nexport interface InteractionDefaultValues {\n buttonText?: string;\n inputText?: string;\n selectedValues?: string[];\n}\n\nexport interface InteractionDefaultResolverParams {\n content?: string | null;\n rawValue?: string | null;\n interactionInfo?: InteractionParseResult | null;\n}\n\nexport type InteractionDefaultResolver = (\n params: InteractionDefaultResolverParams\n) => InteractionDefaultValues | null | undefined;\n\nexport interface InteractionDefaultValueOptions {\n resolveDefaultValues?: InteractionDefaultResolver;\n}\n\ninterface StructuredInteractionPayload {\n buttonText?: unknown;\n inputText?: unknown;\n selectedValues?: unknown;\n}\n\nconst interactionParser = createInteractionParser();\nconst INTERACTION_TAG_PATTERN = /<custom-variable\\b/i;\n// Same definition of where an interaction ends as the parser uses, so an option carrying a\n// `\\]` is read whole instead of being cut at its first bracket. A variable assignment is optional.\nconst INTERACTION_SHORTCODE_PATTERN = new RegExp(\n `\\\\?\\\\[(?:%${createVariableExpressionRegex().source})?(${INTERACTION_CONTENT_SOURCE})\\\\]`\n);\nconst JSON_LIKE_VALUE_PATTERN = /^[\\[{]/;\nconst INTERACTION_VALUE_SEPARATOR_PATTERN = /^[\\s,,\\n]+/;\n\ninterface InteractionOptionCandidate {\n token: string;\n value: string;\n}\n\nconst parseInteractionShortcode = (\n content?: string | null\n): InteractionParseResult | null => {\n if (!content) {\n return null;\n }\n\n const matched = content.match(INTERACTION_SHORTCODE_PATTERN);\n const variableName = matched?.[1]\n ? (normalizeVariableName(matched[1]) ?? undefined)\n : undefined;\n const interactionBody = matched?.[2]?.trim();\n\n if (!interactionBody) {\n return null;\n }\n\n const isMultiSelect = interactionBody.includes(\"||\");\n const separator = isMultiSelect ? \"||\" : \"|\";\n const rawOptions = interactionBody\n .split(separator)\n .map((item) => item.trim())\n .filter(Boolean);\n\n if (!rawOptions.length) {\n return null;\n }\n\n const buttonTexts: string[] = [];\n const buttonValues: string[] = [];\n let placeholder: string | undefined;\n\n rawOptions.forEach((option) => {\n if (option.startsWith(\"...\")) {\n const normalizedPlaceholder = option.replace(/^\\.\\.\\./, \"\").trim();\n if (normalizedPlaceholder) {\n placeholder = normalizedPlaceholder;\n }\n return;\n }\n\n buttonTexts.push(option);\n buttonValues.push(option);\n });\n\n return {\n variableName,\n buttonTexts: buttonTexts.length ? buttonTexts : undefined,\n buttonValues: buttonValues.length ? buttonValues : undefined,\n placeholder,\n isMultiSelect,\n };\n};\n\nconst parseInteractionBlock = (\n content?: string | null\n): InteractionParseResult | null => {\n if (!content) {\n return null;\n }\n\n try {\n return interactionParser.parseToRemarkFormat(\n content\n ) as InteractionParseResult;\n } catch (error) {\n console.warn(\"Failed to parse interaction block\", error);\n }\n\n return parseInteractionShortcode(content);\n};\n\nconst normalizeButtonValue = (\n token: string,\n info: InteractionParseResult\n): { value: string; display?: string } | null => {\n if (!token) {\n return null;\n }\n\n const cleaned = token.trim();\n const buttonValues = info.buttonValues || [];\n const buttonTexts = info.buttonTexts || [];\n const valueIndex = buttonValues.indexOf(cleaned);\n\n if (valueIndex > -1) {\n return {\n value: buttonValues[valueIndex],\n display: buttonTexts[valueIndex],\n };\n }\n\n const textIndex = buttonTexts.indexOf(cleaned);\n\n if (textIndex > -1) {\n return {\n value: buttonValues[textIndex] || buttonTexts[textIndex],\n display: buttonTexts[textIndex],\n };\n }\n\n return null;\n};\n\nconst splitPresetValues = (raw: string) => {\n return raw\n .split(/[,,\\n]/)\n .map((item) => item.trim())\n .filter(Boolean);\n};\n\nconst trimLeadingInteractionSeparators = (raw: string) =>\n raw.replace(INTERACTION_VALUE_SEPARATOR_PATTERN, \"\");\n\nconst buildInteractionOptionCandidates = (\n info: InteractionParseResult\n): InteractionOptionCandidate[] => {\n const buttonValues = info.buttonValues || [];\n const buttonTexts = info.buttonTexts || [];\n const candidates: InteractionOptionCandidate[] = [];\n const seenCandidates = new Set<string>();\n\n buttonValues.forEach((buttonValue, index) => {\n const normalizedValue = `${buttonValue ?? \"\"}`.trim();\n const normalizedText = `${buttonTexts[index] ?? \"\"}`.trim();\n\n [normalizedValue, normalizedText].forEach((token) => {\n if (!token) {\n return;\n }\n\n const candidateKey = `${token}::${normalizedValue || token}`;\n if (seenCandidates.has(candidateKey)) {\n return;\n }\n\n seenCandidates.add(candidateKey);\n candidates.push({\n token,\n value: normalizedValue || token,\n });\n });\n });\n\n return candidates.sort(\n (left, right) => right.token.length - left.token.length\n );\n};\n\nconst matchInteractionOptionPrefix = (\n raw: string,\n info: InteractionParseResult\n): InteractionOptionCandidate | null => {\n const normalizedRaw = trimLeadingInteractionSeparators(raw);\n const candidates = buildInteractionOptionCandidates(info);\n\n for (const candidate of candidates) {\n if (!normalizedRaw.startsWith(candidate.token)) {\n continue;\n }\n\n const trailingChar = normalizedRaw[candidate.token.length];\n if (trailingChar && !/[\\s,,\\n]/.test(trailingChar)) {\n continue;\n }\n\n return candidate;\n }\n\n return null;\n};\n\nconst resolveMultiSelectFallbackDefaults = (\n raw: string,\n info: InteractionParseResult\n): InteractionDefaultValues => {\n const tokens = splitPresetValues(raw);\n\n if (!tokens.length) {\n return {};\n }\n\n const selectedValues: string[] = [];\n const customInputs: string[] = [];\n\n tokens.forEach((token) => {\n const mapped = normalizeButtonValue(token, info);\n\n if (mapped) {\n selectedValues.push(mapped.value);\n return;\n }\n\n if (info.placeholder) {\n customInputs.push(token);\n return;\n }\n\n selectedValues.push(token);\n });\n\n return {\n selectedValues: selectedValues.length ? selectedValues : undefined,\n inputText: customInputs.length ? customInputs.join(\", \") : undefined,\n };\n};\n\nconst resolveMultiSelectInteractionDefaults = (\n raw: string,\n info: InteractionParseResult\n): InteractionDefaultValues => {\n const selectedValues: string[] = [];\n let remainingRaw = raw.trim();\n\n // Prefer option-aware prefix matching before delimiter splitting so\n // option labels that contain commas can still round-trip correctly.\n while (remainingRaw) {\n const matchedCandidate = matchInteractionOptionPrefix(remainingRaw, info);\n\n if (!matchedCandidate) {\n break;\n }\n\n selectedValues.push(matchedCandidate.value);\n const normalizedRemainingRaw =\n trimLeadingInteractionSeparators(remainingRaw);\n remainingRaw = trimLeadingInteractionSeparators(\n normalizedRemainingRaw.slice(matchedCandidate.token.length)\n );\n }\n\n if (selectedValues.length > 0) {\n return {\n selectedValues,\n inputText:\n info.placeholder && remainingRaw.trim()\n ? remainingRaw.trim()\n : undefined,\n };\n }\n\n const fallbackDefaults = resolveMultiSelectFallbackDefaults(raw, info);\n\n if (fallbackDefaults.selectedValues?.length) {\n return fallbackDefaults;\n }\n\n if (info.placeholder) {\n return {\n inputText: raw.trim(),\n };\n }\n\n return fallbackDefaults;\n};\n\nconst normalizeStructuredInteractionDefaults = (\n payload?: StructuredInteractionPayload | null\n): InteractionDefaultValues | null => {\n if (!payload || Array.isArray(payload)) {\n return null;\n }\n\n const selectedValues = Array.isArray(payload.selectedValues)\n ? payload.selectedValues\n .map((item) => `${item ?? \"\"}`.trim())\n .filter(Boolean)\n : undefined;\n const buttonText = `${payload.buttonText ?? \"\"}`.trim();\n const inputText =\n typeof payload.inputText === \"string\" ? payload.inputText : undefined;\n\n if (!selectedValues?.length && !buttonText && !inputText) {\n return null;\n }\n\n return {\n buttonText: buttonText || undefined,\n inputText,\n selectedValues: selectedValues?.length ? selectedValues : undefined,\n };\n};\n\nconst parseStructuredInteractionDefaults = (rawValue?: string | null) => {\n if (!rawValue) {\n return null;\n }\n\n if (!JSON_LIKE_VALUE_PATTERN.test(rawValue.trim())) {\n return null;\n }\n\n try {\n const parsed = JSON.parse(rawValue) as StructuredInteractionPayload;\n return normalizeStructuredInteractionDefaults(parsed);\n } catch {\n return null;\n }\n};\n\nconst hasPotentialInteractionBlock = (content?: string | null) =>\n Boolean(\n content &&\n (INTERACTION_TAG_PATTERN.test(content) ||\n INTERACTION_SHORTCODE_PATTERN.test(content))\n );\n\nconst resolveCustomInteractionDefaults = (\n content?: string | null,\n rawValue?: string | null,\n interactionInfo?: InteractionParseResult | null,\n options?: InteractionDefaultValueOptions\n) => {\n return (\n options?.resolveDefaultValues?.({\n content,\n rawValue,\n interactionInfo,\n }) ?? null\n );\n};\n\nexport const getInteractionDefaultValues = (\n content?: string | null,\n rawValue?: string | null,\n options?: InteractionDefaultValueOptions\n): InteractionDefaultValues => {\n const normalized = rawValue?.toString().trim();\n\n if (!normalized) {\n return {};\n }\n\n const structuredDefaults = parseStructuredInteractionDefaults(normalized);\n\n if (structuredDefaults) {\n return structuredDefaults;\n }\n\n const customDefaults = resolveCustomInteractionDefaults(\n content,\n normalized,\n null,\n options\n );\n\n if (customDefaults) {\n return customDefaults;\n }\n\n if (!hasPotentialInteractionBlock(content)) {\n return {\n buttonText: normalized,\n inputText: normalized,\n };\n }\n\n const interactionInfo = parseInteractionBlock(content);\n const customDefaultsWithInteraction = resolveCustomInteractionDefaults(\n content,\n normalized,\n interactionInfo,\n options\n );\n\n if (customDefaultsWithInteraction) {\n return customDefaultsWithInteraction;\n }\n\n if (!interactionInfo) {\n return {\n buttonText: normalized,\n inputText: normalized,\n };\n }\n\n if (interactionInfo.isMultiSelect) {\n return resolveMultiSelectInteractionDefaults(normalized, interactionInfo);\n }\n\n const mapped = normalizeButtonValue(normalized, interactionInfo);\n\n if (mapped) {\n return {\n buttonText: mapped.value || mapped.display || normalized,\n };\n }\n\n if (interactionInfo.placeholder) {\n return {\n inputText: normalized,\n };\n }\n\n return {\n buttonText: normalized,\n inputText: normalized,\n };\n};\n\nexport const getInteractionDefaultSelectedValues = (\n content?: string | null,\n rawValue?: string | null,\n options?: InteractionDefaultValueOptions\n) => {\n const defaults = getInteractionDefaultValues(content, rawValue, options);\n\n if (defaults.selectedValues) {\n return defaults.selectedValues;\n }\n\n return rawValue\n ? rawValue\n .split(\",\")\n .map((value) => value.trim())\n .filter(Boolean)\n : undefined;\n};\n"],"names":["interactionParser","createInteractionParser","INTERACTION_TAG_PATTERN","INTERACTION_SHORTCODE_PATTERN","createVariableExpressionRegex","INTERACTION_CONTENT_SOURCE","JSON_LIKE_VALUE_PATTERN","INTERACTION_VALUE_SEPARATOR_PATTERN","parseInteractionShortcode","content","matched","variableName","normalizeVariableName","interactionBody","isMultiSelect","separator","rawOptions","item","buttonTexts","buttonValues","placeholder","option","normalizedPlaceholder","parseInteractionBlock","error","normalizeButtonValue","token","info","cleaned","valueIndex","textIndex","splitPresetValues","raw","trimLeadingInteractionSeparators","buildInteractionOptionCandidates","candidates","seenCandidates","buttonValue","index","normalizedValue","normalizedText","candidateKey","left","right","matchInteractionOptionPrefix","normalizedRaw","candidate","trailingChar","resolveMultiSelectFallbackDefaults","tokens","selectedValues","customInputs","mapped","resolveMultiSelectInteractionDefaults","remainingRaw","matchedCandidate","normalizedRemainingRaw","fallbackDefaults","normalizeStructuredInteractionDefaults","payload","buttonText","inputText","parseStructuredInteractionDefaults","rawValue","parsed","hasPotentialInteractionBlock","resolveCustomInteractionDefaults","interactionInfo","options","getInteractionDefaultValues","normalized","structuredDefaults","customDefaults","customDefaultsWithInteraction","getInteractionDefaultSelectedValues","defaults","value"],"mappings":";AAyCA,MAAMA,IAAoBC,EAAAA,wBAAA,GACpBC,IAA0B,uBAG1BC,IAAgC,IAAI;AAAA,EACxC,aAAaC,EAAAA,8BAAA,EAAgC,MAAM,MAAMC,EAAAA,0BAA0B;AACrF,GACMC,IAA0B,U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AACN;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../../../_virtual/
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../../../_virtual/index8.cjs"),v=require("./constants.cjs");var d;function x(){if(d)return c.__exports;d=1,Object.defineProperty(c.__exports,"__esModule",{value:!0}),c.__exports.sanitizeUrl=void 0;var e=v.__require();function m(r){return e.relativeFirstCharacters.indexOf(r[0])>-1}function p(r){var i=r.replace(e.ctrlCharactersRegex,"");return i.replace(e.htmlEntitiesRegex,function(t,a){return String.fromCharCode(a)})}function R(r){return URL.canParse(r)}function l(r){try{return decodeURIComponent(r)}catch{return r}}function f(r){if(!r)return e.BLANK_URL;var i,t=l(r.trim());do t=p(t).replace(e.htmlCtrlEntityRegex,"").replace(e.ctrlCharactersRegex,"").replace(e.whitespaceEscapeCharsRegex,"").trim(),t=l(t),i=t.match(e.ctrlCharactersRegex)||t.match(e.htmlEntitiesRegex)||t.match(e.htmlCtrlEntityRegex)||t.match(e.whitespaceEscapeCharsRegex);while(i&&i.length>0);var a=t;if(!a)return e.BLANK_URL;if(m(a))return a;var u=a.trimStart(),h=u.match(e.urlSchemeRegex);if(!h)return a;var n=h[0].toLowerCase().trim();if(e.invalidProtocolRegex.test(n))return e.BLANK_URL;var s=u.replace(/\\/g,"/");if(n==="mailto:"||n.includes("://"))return s;if(n==="http:"||n==="https:"){if(!R(s))return e.BLANK_URL;var o=new URL(s);return o.protocol=o.protocol.toLowerCase(),o.hostname=o.hostname.toLowerCase(),o.toString()}return s}return c.__exports.sanitizeUrl=f,c.__exports}exports.__require=x;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../../_virtual/
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../../_virtual/index9.cjs");/*!
|
|
2
2
|
Copyright (c) 2018 Jed Watson.
|
|
3
3
|
Licensed under the MIT License (MIT), see
|
|
4
4
|
http://jedwatson.github.io/classnames
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("../../_virtual/cose-base2.cjs"),Q=require("../layout-base/layout-base.cjs");var $=I.__module.exports,X;function J(){return X||(X=1,(function(W,k){(function(y,w){W.exports=w(Q.__require())})($,function(x){return(function(y){var w={};function l(n){if(w[n])return w[n].exports;var g=w[n]={i:n,l:!1,exports:{}};return y[n].call(g.exports,g,g.exports,l),g.l=!0,g.exports}return l.m=y,l.c=w,l.i=function(n){return n},l.d=function(n,g,p){l.o(n,g)||Object.defineProperty(n,g,{configurable:!1,enumerable:!0,get:p})},l.n=function(n){var g=n&&n.__esModule?function(){return n.default}:function(){return n};return l.d(g,"a",g),g},l.o=function(n,g){return Object.prototype.hasOwnProperty.call(n,g)},l.p="",l(l.s=7)})([(function(y,w){y.exports=x}),(function(y,w,l){var n=l(0).FDLayoutConstants;function g(){}for(var p in n)g[p]=n[p];g.DEFAULT_USE_MULTI_LEVEL_SCALING=!1,g.DEFAULT_RADIAL_SEPARATION=n.DEFAULT_EDGE_LENGTH,g.DEFAULT_COMPONENT_SEPERATION=60,g.TILE=!0,g.TILING_PADDING_VERTICAL=10,g.TILING_PADDING_HORIZONTAL=10,g.TREE_REDUCTION_ON_INCREMENTAL=!1,y.exports=g}),(function(y,w,l){var n=l(0).FDLayoutEdge;function g(G,u,E){n.call(this,G,u,E)}g.prototype=Object.create(n.prototype);for(var p in n)g[p]=n[p];y.exports=g}),(function(y,w,l){var n=l(0).LGraph;function g(G,u,E){n.call(this,G,u,E)}g.prototype=Object.create(n.prototype);for(var p in n)g[p]=n[p];y.exports=g}),(function(y,w,l){var n=l(0).LGraphManager;function g(G){n.call(this,G)}g.prototype=Object.create(n.prototype);for(var p in n)g[p]=n[p];y.exports=g}),(function(y,w,l){var n=l(0).FDLayoutNode,g=l(0).IMath;function p(u,E,T,L){n.call(this,u,E,T,L)}p.prototype=Object.create(n.prototype);for(var G in n)p[G]=n[G];p.prototype.move=function(){var u=this.graphManager.getLayout();this.displacementX=u.coolingFactor*(this.springForceX+this.repulsionForceX+this.gravitationForceX)/this.noOfChildren,this.displacementY=u.coolingFactor*(this.springForceY+this.repulsionForceY+this.gravitationForceY)/this.noOfChildren,Math.abs(this.displacementX)>u.coolingFactor*u.maxNodeDisplacement&&(this.displacementX=u.coolingFactor*u.maxNodeDisplacement*g.sign(this.displacementX)),Math.abs(this.displacementY)>u.coolingFactor*u.maxNodeDisplacement&&(this.displacementY=u.coolingFactor*u.maxNodeDisplacement*g.sign(this.displacementY)),this.child==null?this.moveBy(this.displacementX,this.displacementY):this.child.getNodes().length==0?this.moveBy(this.displacementX,this.displacementY):this.propogateDisplacementToChildren(this.displacementX,this.displacementY),u.totalDisplacement+=Math.abs(this.displacementX)+Math.abs(this.displacementY),this.springForceX=0,this.springForceY=0,this.repulsionForceX=0,this.repulsionForceY=0,this.gravitationForceX=0,this.gravitationForceY=0,this.displacementX=0,this.displacementY=0},p.prototype.propogateDisplacementToChildren=function(u,E){for(var T=this.getChild().getNodes(),L,P=0;P<T.length;P++)L=T[P],L.getChild()==null?(L.moveBy(u,E),L.displacementX+=u,L.displacementY+=E):L.propogateDisplacementToChildren(u,E)},p.prototype.setPred1=function(u){this.pred1=u},p.prototype.getPred1=function(){return pred1},p.prototype.getPred2=function(){return pred2},p.prototype.setNext=function(u){this.next=u},p.prototype.getNext=function(){return next},p.prototype.setProcessed=function(u){this.processed=u},p.prototype.isProcessed=function(){return processed},y.exports=p}),(function(y,w,l){var n=l(0).FDLayout,g=l(4),p=l(3),G=l(5),u=l(2),E=l(1),T=l(0).FDLayoutConstants,L=l(0).LayoutConstants,P=l(0).Point,R=l(0).PointD,V=l(0).Layout,B=l(0).Integer,Z=l(0).IGeometry,j=l(0).LGraph,_=l(0).Transform;function d(){n.call(this),this.toBeTiled={}}d.prototype=Object.create(n.prototype);for(var U in n)d[U]=n[U];d.prototype.newGraphManager=function(){var t=new g(this);return this.graphManager=t,t},d.prototype.newGraph=function(t){return new p(null,this.graphManager,t)},d.prototype.newNode=function(t){return new G(this.graphManager,t)},d.prototype.newEdge=function(t){return new u(null,null,t)},d.prototype.initParameters=function(){n.prototype.initParameters.call(this,arguments),this.isSubLayout||(E.DEFAULT_EDGE_LENGTH<10?this.idealEdgeLength=10:this.idealEdgeLength=E.DEFAULT_EDGE_LENGTH,this.useSmartIdealEdgeLengthCalculation=E.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION,this.springConstant=T.DEFAULT_SPRING_STRENGTH,this.repulsionConstant=T.DEFAULT_REPULSION_STRENGTH,this.gravityConstant=T.DEFAULT_GRAVITY_STRENGTH,this.compoundGravityConstant=T.DEFAULT_COMPOUND_GRAVITY_STRENGTH,this.gravityRangeFactor=T.DEFAULT_GRAVITY_RANGE_FACTOR,this.compoundGravityRangeFactor=T.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR,this.prunedNodesAll=[],this.growTreeIterations=0,this.afterGrowthIterations=0,this.isTreeGrowing=!1,this.isGrowthFinished=!1,this.coolingCycle=0,this.maxCoolingCycle=this.maxIterations/T.CONVERGENCE_CHECK_PERIOD,this.finalTemperature=T.CONVERGENCE_CHECK_PERIOD/this.maxIterations,this.coolingAdjuster=1)},d.prototype.layout=function(){var t=L.DEFAULT_CREATE_BENDS_AS_NEEDED;return t&&(this.createBendpoints(),this.graphManager.resetAllEdges()),this.level=0,this.classicLayout()},d.prototype.classicLayout=function(){if(this.nodesWithGravity=this.calculateNodesToApplyGravitationTo(),this.graphManager.setAllNodesToApplyGravitation(this.nodesWithGravity),this.calcNoOfChildrenForAllNodes(),this.graphManager.calcLowestCommonAncestors(),this.graphManager.calcInclusionTreeDepths(),this.graphManager.getRoot().calcEstimatedSize(),this.calcIdealEdgeLengths(),this.incremental){if(E.TREE_REDUCTION_ON_INCREMENTAL){this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation();var e=new Set(this.getAllNodes()),r=this.nodesWithGravity.filter(function(a){return e.has(a)});this.graphManager.setAllNodesToApplyGravitation(r)}}else{var t=this.getFlatForest();if(t.length>0)this.positionNodesRadially(t);else{this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation();var e=new Set(this.getAllNodes()),r=this.nodesWithGravity.filter(function(i){return e.has(i)});this.graphManager.setAllNodesToApplyGravitation(r),this.positionNodesRandomly()}}return this.initSpringEmbedder(),this.runSpringEmbedder(),!0},d.prototype.tick=function(){if(this.totalIterations++,this.totalIterations===this.maxIterations&&!this.isTreeGrowing&&!this.isGrowthFinished)if(this.prunedNodesAll.length>0)this.isTreeGrowing=!0;else return!0;if(this.totalIterations%T.CONVERGENCE_CHECK_PERIOD==0&&!this.isTreeGrowing&&!this.isGrowthFinished){if(this.isConverged())if(this.prunedNodesAll.length>0)this.isTreeGrowing=!0;else return!0;this.coolingCycle++,this.layoutQuality==0?this.coolingAdjuster=this.coolingCycle:this.layoutQuality==1&&(this.coolingAdjuster=this.coolingCycle/3),this.coolingFactor=Math.max(this.initialCoolingFactor-Math.pow(this.coolingCycle,Math.log(100*(this.initialCoolingFactor-this.finalTemperature))/Math.log(this.maxCoolingCycle))/100*this.coolingAdjuster,this.finalTemperature),this.animationPeriod=Math.ceil(this.initialAnimationPeriod*Math.sqrt(this.coolingFactor))}if(this.isTreeGrowing){if(this.growTreeIterations%10==0)if(this.prunedNodesAll.length>0){this.graphManager.updateBounds(),this.updateGrid(),this.growTree(this.prunedNodesAll),this.graphManager.resetAllNodesToApplyGravitation();var t=new Set(this.getAllNodes()),e=this.nodesWithGravity.filter(function(o){return t.has(o)});this.graphManager.setAllNodesToApplyGravitation(e),this.graphManager.updateBounds(),this.updateGrid(),this.coolingFactor=T.DEFAULT_COOLING_FACTOR_INCREMENTAL}else this.isTreeGrowing=!1,this.isGrowthFinished=!0;this.growTreeIterations++}if(this.isGrowthFinished){if(this.isConverged())return!0;this.afterGrowthIterations%10==0&&(this.graphManager.updateBounds(),this.updateGrid()),this.coolingFactor=T.DEFAULT_COOLING_FACTOR_INCREMENTAL*((100-this.afterGrowthIterations)/100),this.afterGrowthIterations++}var r=!this.isTreeGrowing&&!this.isGrowthFinished,i=this.growTreeIterations%10==1&&this.isTreeGrowing||this.afterGrowthIterations%10==1&&this.isGrowthFinished;return this.totalDisplacement=0,this.graphManager.updateBounds(),this.calcSpringForces(),this.calcRepulsionForces(r,i),this.calcGravitationalForces(),this.moveNodes(),this.animate(),!1},d.prototype.getPositionsData=function(){for(var t=this.graphManager.getAllNodes(),e={},r=0;r<t.length;r++){var i=t[r].rect,o=t[r].id;e[o]={id:o,x:i.getCenterX(),y:i.getCenterY(),w:i.width,h:i.height}}return e},d.prototype.runSpringEmbedder=function(){this.initialAnimationPeriod=25,this.animationPeriod=this.initialAnimationPeriod;var t=!1;if(T.ANIMATE==="during")this.emit("layoutstarted");else{for(;!t;)t=this.tick();this.graphManager.updateBounds()}},d.prototype.calculateNodesToApplyGravitationTo=function(){var t=[],e,r=this.graphManager.getGraphs(),i=r.length,o;for(o=0;o<i;o++)e=r[o],e.updateConnected(),e.isConnected||(t=t.concat(e.getNodes()));return t},d.prototype.createBendpoints=function(){var t=[];t=t.concat(this.graphManager.getAllEdges());var e=new Set,r;for(r=0;r<t.length;r++){var i=t[r];if(!e.has(i)){var o=i.getSource(),a=i.getTarget();if(o==a)i.getBendpoints().push(new R),i.getBendpoints().push(new R),this.createDummyNodesForBendpoints(i),e.add(i);else{var s=[];if(s=s.concat(o.getEdgeListToNode(a)),s=s.concat(a.getEdgeListToNode(o)),!e.has(s[0])){if(s.length>1){var h;for(h=0;h<s.length;h++){var f=s[h];f.getBendpoints().push(new R),this.createDummyNodesForBendpoints(f)}}s.forEach(function(C){e.add(C)})}}}if(e.size==t.length)break}},d.prototype.positionNodesRadially=function(t){for(var e=new P(0,0),r=Math.ceil(Math.sqrt(t.length)),i=0,o=0,a=0,s=new R(0,0),h=0;h<t.length;h++){h%r==0&&(a=0,o=i,h!=0&&(o+=E.DEFAULT_COMPONENT_SEPERATION),i=0);var f=t[h],C=V.findCenterOfTree(f);e.x=a,e.y=o,s=d.radialLayout(f,C,e),s.y>i&&(i=Math.floor(s.y)),a=Math.floor(s.x+E.DEFAULT_COMPONENT_SEPERATION)}this.transform(new R(L.WORLD_CENTER_X-s.x/2,L.WORLD_CENTER_Y-s.y/2))},d.radialLayout=function(t,e,r){var i=Math.max(this.maxDiagonalInTree(t),E.DEFAULT_RADIAL_SEPARATION);d.branchRadialLayout(e,null,0,359,0,i);var o=j.calculateBounds(t),a=new _;a.setDeviceOrgX(o.getMinX()),a.setDeviceOrgY(o.getMinY()),a.setWorldOrgX(r.x),a.setWorldOrgY(r.y);for(var s=0;s<t.length;s++){var h=t[s];h.transform(a)}var f=new R(o.getMaxX(),o.getMaxY());return a.inverseTransformPoint(f)},d.branchRadialLayout=function(t,e,r,i,o,a){var s=(i-r+1)/2;s<0&&(s+=180);var h=(s+r)%360,f=h*Z.TWO_PI/360,C=o*Math.cos(f),m=o*Math.sin(f);t.setCenter(C,m);var N=[];N=N.concat(t.getEdges());var c=N.length;e!=null&&c--;for(var v=0,A=N.length,D,O=t.getEdgesBetween(e);O.length>1;){var F=O[0];O.splice(0,1);var M=N.indexOf(F);M>=0&&N.splice(M,1),A--,c--}e!=null?D=(N.indexOf(O[0])+1)%A:D=0;for(var b=Math.abs(i-r)/c,S=D;v!=c;S=++S%A){var Y=N[S].getOtherEnd(t);if(Y!=e){var H=(r+v*b)%360,K=(H+b)%360;d.branchRadialLayout(Y,t,H,K,o+a,a),v++}}},d.maxDiagonalInTree=function(t){for(var e=B.MIN_VALUE,r=0;r<t.length;r++){var i=t[r],o=i.getDiagonal();o>e&&(e=o)}return e},d.prototype.calcRepulsionRange=function(){return 2*(this.level+1)*this.idealEdgeLength},d.prototype.groupZeroDegreeMembers=function(){var t=this,e={};this.memberGroups={},this.idToDummyNode={};for(var r=[],i=this.graphManager.getAllNodes(),o=0;o<i.length;o++){var a=i[o],s=a.getParent();this.getNodeDegreeWithChildren(a)===0&&(s.id==null||!this.getToBeTiled(s))&&r.push(a)}for(var o=0;o<r.length;o++){var a=r[o],h=a.getParent().id;typeof e[h]>"u"&&(e[h]=[]),e[h]=e[h].concat(a)}Object.keys(e).forEach(function(f){if(e[f].length>1){var C="DummyCompound_"+f;t.memberGroups[C]=e[f];var m=e[f][0].getParent(),N=new G(t.graphManager);N.id=C,N.paddingLeft=m.paddingLeft||0,N.paddingRight=m.paddingRight||0,N.paddingBottom=m.paddingBottom||0,N.paddingTop=m.paddingTop||0,t.idToDummyNode[C]=N;var c=t.getGraphManager().add(t.newGraph(),N),v=m.getChild();v.add(N);for(var A=0;A<e[f].length;A++){var D=e[f][A];v.remove(D),c.add(D)}}})},d.prototype.clearCompounds=function(){var t={},e={};this.performDFSOnCompounds();for(var r=0;r<this.compoundOrder.length;r++)e[this.compoundOrder[r].id]=this.compoundOrder[r],t[this.compoundOrder[r].id]=[].concat(this.compoundOrder[r].getChild().getNodes()),this.graphManager.remove(this.compoundOrder[r].getChild()),this.compoundOrder[r].child=null;this.graphManager.resetAllNodes(),this.tileCompoundMembers(t,e)},d.prototype.clearZeroDegreeMembers=function(){var t=this,e=this.tiledZeroDegreePack=[];Object.keys(this.memberGroups).forEach(function(r){var i=t.idToDummyNode[r];e[r]=t.tileNodes(t.memberGroups[r],i.paddingLeft+i.paddingRight),i.rect.width=e[r].width,i.rect.height=e[r].height})},d.prototype.repopulateCompounds=function(){for(var t=this.compoundOrder.length-1;t>=0;t--){var e=this.compoundOrder[t],r=e.id,i=e.paddingLeft,o=e.paddingTop;this.adjustLocations(this.tiledMemberPack[r],e.rect.x,e.rect.y,i,o)}},d.prototype.repopulateZeroDegreeMembers=function(){var t=this,e=this.tiledZeroDegreePack;Object.keys(e).forEach(function(r){var i=t.idToDummyNode[r],o=i.paddingLeft,a=i.paddingTop;t.adjustLocations(e[r],i.rect.x,i.rect.y,o,a)})},d.prototype.getToBeTiled=function(t){var e=t.id;if(this.toBeTiled[e]!=null)return this.toBeTiled[e];var r=t.getChild();if(r==null)return this.toBeTiled[e]=!1,!1;for(var i=r.getNodes(),o=0;o<i.length;o++){var a=i[o];if(this.getNodeDegree(a)>0)return this.toBeTiled[e]=!1,!1;if(a.getChild()==null){this.toBeTiled[a.id]=!1;continue}if(!this.getToBeTiled(a))return this.toBeTiled[e]=!1,!1}return this.toBeTiled[e]=!0,!0},d.prototype.getNodeDegree=function(t){t.id;for(var e=t.getEdges(),r=0,i=0;i<e.length;i++){var o=e[i];o.getSource().id!==o.getTarget().id&&(r=r+1)}return r},d.prototype.getNodeDegreeWithChildren=function(t){var e=this.getNodeDegree(t);if(t.getChild()==null)return e;for(var r=t.getChild().getNodes(),i=0;i<r.length;i++){var o=r[i];e+=this.getNodeDegreeWithChildren(o)}return e},d.prototype.performDFSOnCompounds=function(){this.compoundOrder=[],this.fillCompexOrderByDFS(this.graphManager.getRoot().getNodes())},d.prototype.fillCompexOrderByDFS=function(t){for(var e=0;e<t.length;e++){var r=t[e];r.getChild()!=null&&this.fillCompexOrderByDFS(r.getChild().getNodes()),this.getToBeTiled(r)&&this.compoundOrder.push(r)}},d.prototype.adjustLocations=function(t,e,r,i,o){e+=i,r+=o;for(var a=e,s=0;s<t.rows.length;s++){var h=t.rows[s];e=a;for(var f=0,C=0;C<h.length;C++){var m=h[C];m.rect.x=e,m.rect.y=r,e+=m.rect.width+t.horizontalPadding,m.rect.height>f&&(f=m.rect.height)}r+=f+t.verticalPadding}},d.prototype.tileCompoundMembers=function(t,e){var r=this;this.tiledMemberPack=[],Object.keys(t).forEach(function(i){var o=e[i];r.tiledMemberPack[i]=r.tileNodes(t[i],o.paddingLeft+o.paddingRight),o.rect.width=r.tiledMemberPack[i].width,o.rect.height=r.tiledMemberPack[i].height})},d.prototype.tileNodes=function(t,e){var r=E.TILING_PADDING_VERTICAL,i=E.TILING_PADDING_HORIZONTAL,o={rows:[],rowWidth:[],rowHeight:[],width:0,height:e,verticalPadding:r,horizontalPadding:i};t.sort(function(h,f){return h.rect.width*h.rect.height>f.rect.width*f.rect.height?-1:h.rect.width*h.rect.height<f.rect.width*f.rect.height?1:0});for(var a=0;a<t.length;a++){var s=t[a];o.rows.length==0?this.insertNodeToRow(o,s,0,e):this.canAddHorizontal(o,s.rect.width,s.rect.height)?this.insertNodeToRow(o,s,this.getShortestRowIndex(o),e):this.insertNodeToRow(o,s,o.rows.length,e),this.shiftToLastRow(o)}return o},d.prototype.insertNodeToRow=function(t,e,r,i){var o=i;if(r==t.rows.length){var a=[];t.rows.push(a),t.rowWidth.push(o),t.rowHeight.push(0)}var s=t.rowWidth[r]+e.rect.width;t.rows[r].length>0&&(s+=t.horizontalPadding),t.rowWidth[r]=s,t.width<s&&(t.width=s);var h=e.rect.height;r>0&&(h+=t.verticalPadding);var f=0;h>t.rowHeight[r]&&(f=t.rowHeight[r],t.rowHeight[r]=h,f=t.rowHeight[r]-f),t.height+=f,t.rows[r].push(e)},d.prototype.getShortestRowIndex=function(t){for(var e=-1,r=Number.MAX_VALUE,i=0;i<t.rows.length;i++)t.rowWidth[i]<r&&(e=i,r=t.rowWidth[i]);return e},d.prototype.getLongestRowIndex=function(t){for(var e=-1,r=Number.MIN_VALUE,i=0;i<t.rows.length;i++)t.rowWidth[i]>r&&(e=i,r=t.rowWidth[i]);return e},d.prototype.canAddHorizontal=function(t,e,r){var i=this.getShortestRowIndex(t);if(i<0)return!0;var o=t.rowWidth[i];if(o+t.horizontalPadding+e<=t.width)return!0;var a=0;t.rowHeight[i]<r&&i>0&&(a=r+t.verticalPadding-t.rowHeight[i]);var s;t.width-o>=e+t.horizontalPadding?s=(t.height+a)/(o+e+t.horizontalPadding):s=(t.height+a)/t.width,a=r+t.verticalPadding;var h;return t.width<e?h=(t.height+a)/e:h=(t.height+a)/t.width,h<1&&(h=1/h),s<1&&(s=1/s),s<h},d.prototype.shiftToLastRow=function(t){var e=this.getLongestRowIndex(t),r=t.rowWidth.length-1,i=t.rows[e],o=i[i.length-1],a=o.width+t.horizontalPadding;if(t.width-t.rowWidth[r]>a&&e!=r){i.splice(-1,1),t.rows[r].push(o),t.rowWidth[e]=t.rowWidth[e]-a,t.rowWidth[r]=t.rowWidth[r]+a,t.width=t.rowWidth[instance.getLongestRowIndex(t)];for(var s=Number.MIN_VALUE,h=0;h<i.length;h++)i[h].height>s&&(s=i[h].height);e>0&&(s+=t.verticalPadding);var f=t.rowHeight[e]+t.rowHeight[r];t.rowHeight[e]=s,t.rowHeight[r]<o.height+t.verticalPadding&&(t.rowHeight[r]=o.height+t.verticalPadding);var C=t.rowHeight[e]+t.rowHeight[r];t.height+=C-f,this.shiftToLastRow(t)}},d.prototype.tilingPreLayout=function(){E.TILE&&(this.groupZeroDegreeMembers(),this.clearCompounds(),this.clearZeroDegreeMembers())},d.prototype.tilingPostLayout=function(){E.TILE&&(this.repopulateZeroDegreeMembers(),this.repopulateCompounds())},d.prototype.reduceTrees=function(){for(var t=[],e=!0,r;e;){var i=this.graphManager.getAllNodes(),o=[];e=!1;for(var a=0;a<i.length;a++)r=i[a],r.getEdges().length==1&&!r.getEdges()[0].isInterGraph&&r.getChild()==null&&(o.push([r,r.getEdges()[0],r.getOwner()]),e=!0);if(e==!0){for(var s=[],h=0;h<o.length;h++)o[h][0].getEdges().length==1&&(s.push(o[h]),o[h][0].getOwner().remove(o[h][0]));t.push(s),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()}}this.prunedNodesAll=t},d.prototype.growTree=function(t){for(var e=t.length,r=t[e-1],i,o=0;o<r.length;o++)i=r[o],this.findPlaceforPrunedNode(i),i[2].add(i[0]),i[2].add(i[1],i[1].source,i[1].target);t.splice(t.length-1,1),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()},d.prototype.findPlaceforPrunedNode=function(t){var e,r,i=t[0];i==t[1].source?r=t[1].target:r=t[1].source;var o=r.startX,a=r.finishX,s=r.startY,h=r.finishY,f=0,C=0,m=0,N=0,c=[f,m,C,N];if(s>0)for(var v=o;v<=a;v++)c[0]+=this.grid[v][s-1].length+this.grid[v][s].length-1;if(a<this.grid.length-1)for(var v=s;v<=h;v++)c[1]+=this.grid[a+1][v].length+this.grid[a][v].length-1;if(h<this.grid[0].length-1)for(var v=o;v<=a;v++)c[2]+=this.grid[v][h+1].length+this.grid[v][h].length-1;if(o>0)for(var v=s;v<=h;v++)c[3]+=this.grid[o-1][v].length+this.grid[o][v].length-1;for(var A=B.MAX_VALUE,D,O,F=0;F<c.length;F++)c[F]<A?(A=c[F],D=1,O=F):c[F]==A&&D++;if(D==3&&A==0)c[0]==0&&c[1]==0&&c[2]==0?e=1:c[0]==0&&c[1]==0&&c[3]==0?e=0:c[0]==0&&c[2]==0&&c[3]==0?e=3:c[1]==0&&c[2]==0&&c[3]==0&&(e=2);else if(D==2&&A==0){var M=Math.floor(Math.random()*2);c[0]==0&&c[1]==0?M==0?e=0:e=1:c[0]==0&&c[2]==0?M==0?e=0:e=2:c[0]==0&&c[3]==0?M==0?e=0:e=3:c[1]==0&&c[2]==0?M==0?e=1:e=2:c[1]==0&&c[3]==0?M==0?e=1:e=3:M==0?e=2:e=3}else if(D==4&&A==0){var M=Math.floor(Math.random()*4);e=M}else e=O;e==0?i.setCenter(r.getCenterX(),r.getCenterY()-r.getHeight()/2-T.DEFAULT_EDGE_LENGTH-i.getHeight()/2):e==1?i.setCenter(r.getCenterX()+r.getWidth()/2+T.DEFAULT_EDGE_LENGTH+i.getWidth()/2,r.getCenterY()):e==2?i.setCenter(r.getCenterX(),r.getCenterY()+r.getHeight()/2+T.DEFAULT_EDGE_LENGTH+i.getHeight()/2):i.setCenter(r.getCenterX()-r.getWidth()/2-T.DEFAULT_EDGE_LENGTH-i.getWidth()/2,r.getCenterY())},y.exports=d}),(function(y,w,l){var n={};n.layoutBase=l(0),n.CoSEConstants=l(1),n.CoSEEdge=l(2),n.CoSEGraph=l(3),n.CoSEGraphManager=l(4),n.CoSELayout=l(6),n.CoSENode=l(5),y.exports=n})])})})(I.__module)),I.__module.exports}exports.__require=J;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("../../_virtual/cose-base.cjs"),Q=require("../layout-base/layout-base.cjs");var $=I.__module.exports,X;function J(){return X||(X=1,(function(W,k){(function(y,w){W.exports=w(Q.__require())})($,function(x){return(function(y){var w={};function l(n){if(w[n])return w[n].exports;var g=w[n]={i:n,l:!1,exports:{}};return y[n].call(g.exports,g,g.exports,l),g.l=!0,g.exports}return l.m=y,l.c=w,l.i=function(n){return n},l.d=function(n,g,p){l.o(n,g)||Object.defineProperty(n,g,{configurable:!1,enumerable:!0,get:p})},l.n=function(n){var g=n&&n.__esModule?function(){return n.default}:function(){return n};return l.d(g,"a",g),g},l.o=function(n,g){return Object.prototype.hasOwnProperty.call(n,g)},l.p="",l(l.s=7)})([(function(y,w){y.exports=x}),(function(y,w,l){var n=l(0).FDLayoutConstants;function g(){}for(var p in n)g[p]=n[p];g.DEFAULT_USE_MULTI_LEVEL_SCALING=!1,g.DEFAULT_RADIAL_SEPARATION=n.DEFAULT_EDGE_LENGTH,g.DEFAULT_COMPONENT_SEPERATION=60,g.TILE=!0,g.TILING_PADDING_VERTICAL=10,g.TILING_PADDING_HORIZONTAL=10,g.TREE_REDUCTION_ON_INCREMENTAL=!1,y.exports=g}),(function(y,w,l){var n=l(0).FDLayoutEdge;function g(G,u,E){n.call(this,G,u,E)}g.prototype=Object.create(n.prototype);for(var p in n)g[p]=n[p];y.exports=g}),(function(y,w,l){var n=l(0).LGraph;function g(G,u,E){n.call(this,G,u,E)}g.prototype=Object.create(n.prototype);for(var p in n)g[p]=n[p];y.exports=g}),(function(y,w,l){var n=l(0).LGraphManager;function g(G){n.call(this,G)}g.prototype=Object.create(n.prototype);for(var p in n)g[p]=n[p];y.exports=g}),(function(y,w,l){var n=l(0).FDLayoutNode,g=l(0).IMath;function p(u,E,T,L){n.call(this,u,E,T,L)}p.prototype=Object.create(n.prototype);for(var G in n)p[G]=n[G];p.prototype.move=function(){var u=this.graphManager.getLayout();this.displacementX=u.coolingFactor*(this.springForceX+this.repulsionForceX+this.gravitationForceX)/this.noOfChildren,this.displacementY=u.coolingFactor*(this.springForceY+this.repulsionForceY+this.gravitationForceY)/this.noOfChildren,Math.abs(this.displacementX)>u.coolingFactor*u.maxNodeDisplacement&&(this.displacementX=u.coolingFactor*u.maxNodeDisplacement*g.sign(this.displacementX)),Math.abs(this.displacementY)>u.coolingFactor*u.maxNodeDisplacement&&(this.displacementY=u.coolingFactor*u.maxNodeDisplacement*g.sign(this.displacementY)),this.child==null?this.moveBy(this.displacementX,this.displacementY):this.child.getNodes().length==0?this.moveBy(this.displacementX,this.displacementY):this.propogateDisplacementToChildren(this.displacementX,this.displacementY),u.totalDisplacement+=Math.abs(this.displacementX)+Math.abs(this.displacementY),this.springForceX=0,this.springForceY=0,this.repulsionForceX=0,this.repulsionForceY=0,this.gravitationForceX=0,this.gravitationForceY=0,this.displacementX=0,this.displacementY=0},p.prototype.propogateDisplacementToChildren=function(u,E){for(var T=this.getChild().getNodes(),L,P=0;P<T.length;P++)L=T[P],L.getChild()==null?(L.moveBy(u,E),L.displacementX+=u,L.displacementY+=E):L.propogateDisplacementToChildren(u,E)},p.prototype.setPred1=function(u){this.pred1=u},p.prototype.getPred1=function(){return pred1},p.prototype.getPred2=function(){return pred2},p.prototype.setNext=function(u){this.next=u},p.prototype.getNext=function(){return next},p.prototype.setProcessed=function(u){this.processed=u},p.prototype.isProcessed=function(){return processed},y.exports=p}),(function(y,w,l){var n=l(0).FDLayout,g=l(4),p=l(3),G=l(5),u=l(2),E=l(1),T=l(0).FDLayoutConstants,L=l(0).LayoutConstants,P=l(0).Point,R=l(0).PointD,V=l(0).Layout,B=l(0).Integer,Z=l(0).IGeometry,j=l(0).LGraph,_=l(0).Transform;function d(){n.call(this),this.toBeTiled={}}d.prototype=Object.create(n.prototype);for(var U in n)d[U]=n[U];d.prototype.newGraphManager=function(){var t=new g(this);return this.graphManager=t,t},d.prototype.newGraph=function(t){return new p(null,this.graphManager,t)},d.prototype.newNode=function(t){return new G(this.graphManager,t)},d.prototype.newEdge=function(t){return new u(null,null,t)},d.prototype.initParameters=function(){n.prototype.initParameters.call(this,arguments),this.isSubLayout||(E.DEFAULT_EDGE_LENGTH<10?this.idealEdgeLength=10:this.idealEdgeLength=E.DEFAULT_EDGE_LENGTH,this.useSmartIdealEdgeLengthCalculation=E.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION,this.springConstant=T.DEFAULT_SPRING_STRENGTH,this.repulsionConstant=T.DEFAULT_REPULSION_STRENGTH,this.gravityConstant=T.DEFAULT_GRAVITY_STRENGTH,this.compoundGravityConstant=T.DEFAULT_COMPOUND_GRAVITY_STRENGTH,this.gravityRangeFactor=T.DEFAULT_GRAVITY_RANGE_FACTOR,this.compoundGravityRangeFactor=T.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR,this.prunedNodesAll=[],this.growTreeIterations=0,this.afterGrowthIterations=0,this.isTreeGrowing=!1,this.isGrowthFinished=!1,this.coolingCycle=0,this.maxCoolingCycle=this.maxIterations/T.CONVERGENCE_CHECK_PERIOD,this.finalTemperature=T.CONVERGENCE_CHECK_PERIOD/this.maxIterations,this.coolingAdjuster=1)},d.prototype.layout=function(){var t=L.DEFAULT_CREATE_BENDS_AS_NEEDED;return t&&(this.createBendpoints(),this.graphManager.resetAllEdges()),this.level=0,this.classicLayout()},d.prototype.classicLayout=function(){if(this.nodesWithGravity=this.calculateNodesToApplyGravitationTo(),this.graphManager.setAllNodesToApplyGravitation(this.nodesWithGravity),this.calcNoOfChildrenForAllNodes(),this.graphManager.calcLowestCommonAncestors(),this.graphManager.calcInclusionTreeDepths(),this.graphManager.getRoot().calcEstimatedSize(),this.calcIdealEdgeLengths(),this.incremental){if(E.TREE_REDUCTION_ON_INCREMENTAL){this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation();var e=new Set(this.getAllNodes()),r=this.nodesWithGravity.filter(function(a){return e.has(a)});this.graphManager.setAllNodesToApplyGravitation(r)}}else{var t=this.getFlatForest();if(t.length>0)this.positionNodesRadially(t);else{this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation();var e=new Set(this.getAllNodes()),r=this.nodesWithGravity.filter(function(i){return e.has(i)});this.graphManager.setAllNodesToApplyGravitation(r),this.positionNodesRandomly()}}return this.initSpringEmbedder(),this.runSpringEmbedder(),!0},d.prototype.tick=function(){if(this.totalIterations++,this.totalIterations===this.maxIterations&&!this.isTreeGrowing&&!this.isGrowthFinished)if(this.prunedNodesAll.length>0)this.isTreeGrowing=!0;else return!0;if(this.totalIterations%T.CONVERGENCE_CHECK_PERIOD==0&&!this.isTreeGrowing&&!this.isGrowthFinished){if(this.isConverged())if(this.prunedNodesAll.length>0)this.isTreeGrowing=!0;else return!0;this.coolingCycle++,this.layoutQuality==0?this.coolingAdjuster=this.coolingCycle:this.layoutQuality==1&&(this.coolingAdjuster=this.coolingCycle/3),this.coolingFactor=Math.max(this.initialCoolingFactor-Math.pow(this.coolingCycle,Math.log(100*(this.initialCoolingFactor-this.finalTemperature))/Math.log(this.maxCoolingCycle))/100*this.coolingAdjuster,this.finalTemperature),this.animationPeriod=Math.ceil(this.initialAnimationPeriod*Math.sqrt(this.coolingFactor))}if(this.isTreeGrowing){if(this.growTreeIterations%10==0)if(this.prunedNodesAll.length>0){this.graphManager.updateBounds(),this.updateGrid(),this.growTree(this.prunedNodesAll),this.graphManager.resetAllNodesToApplyGravitation();var t=new Set(this.getAllNodes()),e=this.nodesWithGravity.filter(function(o){return t.has(o)});this.graphManager.setAllNodesToApplyGravitation(e),this.graphManager.updateBounds(),this.updateGrid(),this.coolingFactor=T.DEFAULT_COOLING_FACTOR_INCREMENTAL}else this.isTreeGrowing=!1,this.isGrowthFinished=!0;this.growTreeIterations++}if(this.isGrowthFinished){if(this.isConverged())return!0;this.afterGrowthIterations%10==0&&(this.graphManager.updateBounds(),this.updateGrid()),this.coolingFactor=T.DEFAULT_COOLING_FACTOR_INCREMENTAL*((100-this.afterGrowthIterations)/100),this.afterGrowthIterations++}var r=!this.isTreeGrowing&&!this.isGrowthFinished,i=this.growTreeIterations%10==1&&this.isTreeGrowing||this.afterGrowthIterations%10==1&&this.isGrowthFinished;return this.totalDisplacement=0,this.graphManager.updateBounds(),this.calcSpringForces(),this.calcRepulsionForces(r,i),this.calcGravitationalForces(),this.moveNodes(),this.animate(),!1},d.prototype.getPositionsData=function(){for(var t=this.graphManager.getAllNodes(),e={},r=0;r<t.length;r++){var i=t[r].rect,o=t[r].id;e[o]={id:o,x:i.getCenterX(),y:i.getCenterY(),w:i.width,h:i.height}}return e},d.prototype.runSpringEmbedder=function(){this.initialAnimationPeriod=25,this.animationPeriod=this.initialAnimationPeriod;var t=!1;if(T.ANIMATE==="during")this.emit("layoutstarted");else{for(;!t;)t=this.tick();this.graphManager.updateBounds()}},d.prototype.calculateNodesToApplyGravitationTo=function(){var t=[],e,r=this.graphManager.getGraphs(),i=r.length,o;for(o=0;o<i;o++)e=r[o],e.updateConnected(),e.isConnected||(t=t.concat(e.getNodes()));return t},d.prototype.createBendpoints=function(){var t=[];t=t.concat(this.graphManager.getAllEdges());var e=new Set,r;for(r=0;r<t.length;r++){var i=t[r];if(!e.has(i)){var o=i.getSource(),a=i.getTarget();if(o==a)i.getBendpoints().push(new R),i.getBendpoints().push(new R),this.createDummyNodesForBendpoints(i),e.add(i);else{var s=[];if(s=s.concat(o.getEdgeListToNode(a)),s=s.concat(a.getEdgeListToNode(o)),!e.has(s[0])){if(s.length>1){var h;for(h=0;h<s.length;h++){var f=s[h];f.getBendpoints().push(new R),this.createDummyNodesForBendpoints(f)}}s.forEach(function(C){e.add(C)})}}}if(e.size==t.length)break}},d.prototype.positionNodesRadially=function(t){for(var e=new P(0,0),r=Math.ceil(Math.sqrt(t.length)),i=0,o=0,a=0,s=new R(0,0),h=0;h<t.length;h++){h%r==0&&(a=0,o=i,h!=0&&(o+=E.DEFAULT_COMPONENT_SEPERATION),i=0);var f=t[h],C=V.findCenterOfTree(f);e.x=a,e.y=o,s=d.radialLayout(f,C,e),s.y>i&&(i=Math.floor(s.y)),a=Math.floor(s.x+E.DEFAULT_COMPONENT_SEPERATION)}this.transform(new R(L.WORLD_CENTER_X-s.x/2,L.WORLD_CENTER_Y-s.y/2))},d.radialLayout=function(t,e,r){var i=Math.max(this.maxDiagonalInTree(t),E.DEFAULT_RADIAL_SEPARATION);d.branchRadialLayout(e,null,0,359,0,i);var o=j.calculateBounds(t),a=new _;a.setDeviceOrgX(o.getMinX()),a.setDeviceOrgY(o.getMinY()),a.setWorldOrgX(r.x),a.setWorldOrgY(r.y);for(var s=0;s<t.length;s++){var h=t[s];h.transform(a)}var f=new R(o.getMaxX(),o.getMaxY());return a.inverseTransformPoint(f)},d.branchRadialLayout=function(t,e,r,i,o,a){var s=(i-r+1)/2;s<0&&(s+=180);var h=(s+r)%360,f=h*Z.TWO_PI/360,C=o*Math.cos(f),m=o*Math.sin(f);t.setCenter(C,m);var N=[];N=N.concat(t.getEdges());var c=N.length;e!=null&&c--;for(var v=0,A=N.length,D,O=t.getEdgesBetween(e);O.length>1;){var F=O[0];O.splice(0,1);var M=N.indexOf(F);M>=0&&N.splice(M,1),A--,c--}e!=null?D=(N.indexOf(O[0])+1)%A:D=0;for(var b=Math.abs(i-r)/c,S=D;v!=c;S=++S%A){var Y=N[S].getOtherEnd(t);if(Y!=e){var H=(r+v*b)%360,K=(H+b)%360;d.branchRadialLayout(Y,t,H,K,o+a,a),v++}}},d.maxDiagonalInTree=function(t){for(var e=B.MIN_VALUE,r=0;r<t.length;r++){var i=t[r],o=i.getDiagonal();o>e&&(e=o)}return e},d.prototype.calcRepulsionRange=function(){return 2*(this.level+1)*this.idealEdgeLength},d.prototype.groupZeroDegreeMembers=function(){var t=this,e={};this.memberGroups={},this.idToDummyNode={};for(var r=[],i=this.graphManager.getAllNodes(),o=0;o<i.length;o++){var a=i[o],s=a.getParent();this.getNodeDegreeWithChildren(a)===0&&(s.id==null||!this.getToBeTiled(s))&&r.push(a)}for(var o=0;o<r.length;o++){var a=r[o],h=a.getParent().id;typeof e[h]>"u"&&(e[h]=[]),e[h]=e[h].concat(a)}Object.keys(e).forEach(function(f){if(e[f].length>1){var C="DummyCompound_"+f;t.memberGroups[C]=e[f];var m=e[f][0].getParent(),N=new G(t.graphManager);N.id=C,N.paddingLeft=m.paddingLeft||0,N.paddingRight=m.paddingRight||0,N.paddingBottom=m.paddingBottom||0,N.paddingTop=m.paddingTop||0,t.idToDummyNode[C]=N;var c=t.getGraphManager().add(t.newGraph(),N),v=m.getChild();v.add(N);for(var A=0;A<e[f].length;A++){var D=e[f][A];v.remove(D),c.add(D)}}})},d.prototype.clearCompounds=function(){var t={},e={};this.performDFSOnCompounds();for(var r=0;r<this.compoundOrder.length;r++)e[this.compoundOrder[r].id]=this.compoundOrder[r],t[this.compoundOrder[r].id]=[].concat(this.compoundOrder[r].getChild().getNodes()),this.graphManager.remove(this.compoundOrder[r].getChild()),this.compoundOrder[r].child=null;this.graphManager.resetAllNodes(),this.tileCompoundMembers(t,e)},d.prototype.clearZeroDegreeMembers=function(){var t=this,e=this.tiledZeroDegreePack=[];Object.keys(this.memberGroups).forEach(function(r){var i=t.idToDummyNode[r];e[r]=t.tileNodes(t.memberGroups[r],i.paddingLeft+i.paddingRight),i.rect.width=e[r].width,i.rect.height=e[r].height})},d.prototype.repopulateCompounds=function(){for(var t=this.compoundOrder.length-1;t>=0;t--){var e=this.compoundOrder[t],r=e.id,i=e.paddingLeft,o=e.paddingTop;this.adjustLocations(this.tiledMemberPack[r],e.rect.x,e.rect.y,i,o)}},d.prototype.repopulateZeroDegreeMembers=function(){var t=this,e=this.tiledZeroDegreePack;Object.keys(e).forEach(function(r){var i=t.idToDummyNode[r],o=i.paddingLeft,a=i.paddingTop;t.adjustLocations(e[r],i.rect.x,i.rect.y,o,a)})},d.prototype.getToBeTiled=function(t){var e=t.id;if(this.toBeTiled[e]!=null)return this.toBeTiled[e];var r=t.getChild();if(r==null)return this.toBeTiled[e]=!1,!1;for(var i=r.getNodes(),o=0;o<i.length;o++){var a=i[o];if(this.getNodeDegree(a)>0)return this.toBeTiled[e]=!1,!1;if(a.getChild()==null){this.toBeTiled[a.id]=!1;continue}if(!this.getToBeTiled(a))return this.toBeTiled[e]=!1,!1}return this.toBeTiled[e]=!0,!0},d.prototype.getNodeDegree=function(t){t.id;for(var e=t.getEdges(),r=0,i=0;i<e.length;i++){var o=e[i];o.getSource().id!==o.getTarget().id&&(r=r+1)}return r},d.prototype.getNodeDegreeWithChildren=function(t){var e=this.getNodeDegree(t);if(t.getChild()==null)return e;for(var r=t.getChild().getNodes(),i=0;i<r.length;i++){var o=r[i];e+=this.getNodeDegreeWithChildren(o)}return e},d.prototype.performDFSOnCompounds=function(){this.compoundOrder=[],this.fillCompexOrderByDFS(this.graphManager.getRoot().getNodes())},d.prototype.fillCompexOrderByDFS=function(t){for(var e=0;e<t.length;e++){var r=t[e];r.getChild()!=null&&this.fillCompexOrderByDFS(r.getChild().getNodes()),this.getToBeTiled(r)&&this.compoundOrder.push(r)}},d.prototype.adjustLocations=function(t,e,r,i,o){e+=i,r+=o;for(var a=e,s=0;s<t.rows.length;s++){var h=t.rows[s];e=a;for(var f=0,C=0;C<h.length;C++){var m=h[C];m.rect.x=e,m.rect.y=r,e+=m.rect.width+t.horizontalPadding,m.rect.height>f&&(f=m.rect.height)}r+=f+t.verticalPadding}},d.prototype.tileCompoundMembers=function(t,e){var r=this;this.tiledMemberPack=[],Object.keys(t).forEach(function(i){var o=e[i];r.tiledMemberPack[i]=r.tileNodes(t[i],o.paddingLeft+o.paddingRight),o.rect.width=r.tiledMemberPack[i].width,o.rect.height=r.tiledMemberPack[i].height})},d.prototype.tileNodes=function(t,e){var r=E.TILING_PADDING_VERTICAL,i=E.TILING_PADDING_HORIZONTAL,o={rows:[],rowWidth:[],rowHeight:[],width:0,height:e,verticalPadding:r,horizontalPadding:i};t.sort(function(h,f){return h.rect.width*h.rect.height>f.rect.width*f.rect.height?-1:h.rect.width*h.rect.height<f.rect.width*f.rect.height?1:0});for(var a=0;a<t.length;a++){var s=t[a];o.rows.length==0?this.insertNodeToRow(o,s,0,e):this.canAddHorizontal(o,s.rect.width,s.rect.height)?this.insertNodeToRow(o,s,this.getShortestRowIndex(o),e):this.insertNodeToRow(o,s,o.rows.length,e),this.shiftToLastRow(o)}return o},d.prototype.insertNodeToRow=function(t,e,r,i){var o=i;if(r==t.rows.length){var a=[];t.rows.push(a),t.rowWidth.push(o),t.rowHeight.push(0)}var s=t.rowWidth[r]+e.rect.width;t.rows[r].length>0&&(s+=t.horizontalPadding),t.rowWidth[r]=s,t.width<s&&(t.width=s);var h=e.rect.height;r>0&&(h+=t.verticalPadding);var f=0;h>t.rowHeight[r]&&(f=t.rowHeight[r],t.rowHeight[r]=h,f=t.rowHeight[r]-f),t.height+=f,t.rows[r].push(e)},d.prototype.getShortestRowIndex=function(t){for(var e=-1,r=Number.MAX_VALUE,i=0;i<t.rows.length;i++)t.rowWidth[i]<r&&(e=i,r=t.rowWidth[i]);return e},d.prototype.getLongestRowIndex=function(t){for(var e=-1,r=Number.MIN_VALUE,i=0;i<t.rows.length;i++)t.rowWidth[i]>r&&(e=i,r=t.rowWidth[i]);return e},d.prototype.canAddHorizontal=function(t,e,r){var i=this.getShortestRowIndex(t);if(i<0)return!0;var o=t.rowWidth[i];if(o+t.horizontalPadding+e<=t.width)return!0;var a=0;t.rowHeight[i]<r&&i>0&&(a=r+t.verticalPadding-t.rowHeight[i]);var s;t.width-o>=e+t.horizontalPadding?s=(t.height+a)/(o+e+t.horizontalPadding):s=(t.height+a)/t.width,a=r+t.verticalPadding;var h;return t.width<e?h=(t.height+a)/e:h=(t.height+a)/t.width,h<1&&(h=1/h),s<1&&(s=1/s),s<h},d.prototype.shiftToLastRow=function(t){var e=this.getLongestRowIndex(t),r=t.rowWidth.length-1,i=t.rows[e],o=i[i.length-1],a=o.width+t.horizontalPadding;if(t.width-t.rowWidth[r]>a&&e!=r){i.splice(-1,1),t.rows[r].push(o),t.rowWidth[e]=t.rowWidth[e]-a,t.rowWidth[r]=t.rowWidth[r]+a,t.width=t.rowWidth[instance.getLongestRowIndex(t)];for(var s=Number.MIN_VALUE,h=0;h<i.length;h++)i[h].height>s&&(s=i[h].height);e>0&&(s+=t.verticalPadding);var f=t.rowHeight[e]+t.rowHeight[r];t.rowHeight[e]=s,t.rowHeight[r]<o.height+t.verticalPadding&&(t.rowHeight[r]=o.height+t.verticalPadding);var C=t.rowHeight[e]+t.rowHeight[r];t.height+=C-f,this.shiftToLastRow(t)}},d.prototype.tilingPreLayout=function(){E.TILE&&(this.groupZeroDegreeMembers(),this.clearCompounds(),this.clearZeroDegreeMembers())},d.prototype.tilingPostLayout=function(){E.TILE&&(this.repopulateZeroDegreeMembers(),this.repopulateCompounds())},d.prototype.reduceTrees=function(){for(var t=[],e=!0,r;e;){var i=this.graphManager.getAllNodes(),o=[];e=!1;for(var a=0;a<i.length;a++)r=i[a],r.getEdges().length==1&&!r.getEdges()[0].isInterGraph&&r.getChild()==null&&(o.push([r,r.getEdges()[0],r.getOwner()]),e=!0);if(e==!0){for(var s=[],h=0;h<o.length;h++)o[h][0].getEdges().length==1&&(s.push(o[h]),o[h][0].getOwner().remove(o[h][0]));t.push(s),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()}}this.prunedNodesAll=t},d.prototype.growTree=function(t){for(var e=t.length,r=t[e-1],i,o=0;o<r.length;o++)i=r[o],this.findPlaceforPrunedNode(i),i[2].add(i[0]),i[2].add(i[1],i[1].source,i[1].target);t.splice(t.length-1,1),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()},d.prototype.findPlaceforPrunedNode=function(t){var e,r,i=t[0];i==t[1].source?r=t[1].target:r=t[1].source;var o=r.startX,a=r.finishX,s=r.startY,h=r.finishY,f=0,C=0,m=0,N=0,c=[f,m,C,N];if(s>0)for(var v=o;v<=a;v++)c[0]+=this.grid[v][s-1].length+this.grid[v][s].length-1;if(a<this.grid.length-1)for(var v=s;v<=h;v++)c[1]+=this.grid[a+1][v].length+this.grid[a][v].length-1;if(h<this.grid[0].length-1)for(var v=o;v<=a;v++)c[2]+=this.grid[v][h+1].length+this.grid[v][h].length-1;if(o>0)for(var v=s;v<=h;v++)c[3]+=this.grid[o-1][v].length+this.grid[o][v].length-1;for(var A=B.MAX_VALUE,D,O,F=0;F<c.length;F++)c[F]<A?(A=c[F],D=1,O=F):c[F]==A&&D++;if(D==3&&A==0)c[0]==0&&c[1]==0&&c[2]==0?e=1:c[0]==0&&c[1]==0&&c[3]==0?e=0:c[0]==0&&c[2]==0&&c[3]==0?e=3:c[1]==0&&c[2]==0&&c[3]==0&&(e=2);else if(D==2&&A==0){var M=Math.floor(Math.random()*2);c[0]==0&&c[1]==0?M==0?e=0:e=1:c[0]==0&&c[2]==0?M==0?e=0:e=2:c[0]==0&&c[3]==0?M==0?e=0:e=3:c[1]==0&&c[2]==0?M==0?e=1:e=2:c[1]==0&&c[3]==0?M==0?e=1:e=3:M==0?e=2:e=3}else if(D==4&&A==0){var M=Math.floor(Math.random()*4);e=M}else e=O;e==0?i.setCenter(r.getCenterX(),r.getCenterY()-r.getHeight()/2-T.DEFAULT_EDGE_LENGTH-i.getHeight()/2):e==1?i.setCenter(r.getCenterX()+r.getWidth()/2+T.DEFAULT_EDGE_LENGTH+i.getWidth()/2,r.getCenterY()):e==2?i.setCenter(r.getCenterX(),r.getCenterY()+r.getHeight()/2+T.DEFAULT_EDGE_LENGTH+i.getHeight()/2):i.setCenter(r.getCenterX()-r.getWidth()/2-T.DEFAULT_EDGE_LENGTH-i.getWidth()/2,r.getCenterY())},y.exports=d}),(function(y,w,l){var n={};n.layoutBase=l(0),n.CoSEConstants=l(1),n.CoSEEdge=l(2),n.CoSEGraph=l(3),n.CoSEGraphManager=l(4),n.CoSELayout=l(6),n.CoSENode=l(5),y.exports=n})])})})(I.__module)),I.__module.exports}exports.__require=J;
|
|
2
2
|
//# sourceMappingURL=cose-base.cjs.map
|