markdown-flow-ui 0.2.35 → 0.3.0-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.es10.js +2 -2
- package/dist/_virtual/index.es3.js +5 -4
- package/dist/_virtual/index.es3.js.map +1 -1
- package/dist/_virtual/index.es4.js +4 -5
- package/dist/_virtual/index.es4.js.map +1 -1
- package/dist/_virtual/index.es5.js +5 -5
- package/dist/_virtual/index.es6.js +5 -3
- package/dist/_virtual/index.es6.js.map +1 -1
- package/dist/_virtual/index.es7.js +3 -5
- package/dist/_virtual/index.es7.js.map +1 -1
- package/dist/_virtual/index.es8.js +2 -2
- package/dist/_virtual/index10.cjs +1 -1
- package/dist/_virtual/index3.cjs +1 -1
- package/dist/_virtual/index4.cjs +1 -1
- package/dist/_virtual/index5.cjs +1 -1
- package/dist/_virtual/index6.cjs +1 -1
- package/dist/_virtual/index7.cjs +1 -1
- package/dist/_virtual/index8.cjs +1 -1
- package/dist/_virtual/variable-marker.cjs +2 -0
- package/dist/_virtual/variable-marker.cjs.map +1 -0
- package/dist/_virtual/variable-marker.es.js +5 -0
- package/dist/_virtual/variable-marker.es.js.map +1 -0
- 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/ContentRender.cjs +2 -2
- package/dist/components/ContentRender/ContentRender.cjs.map +1 -1
- package/dist/components/ContentRender/ContentRender.es.js +206 -205
- package/dist/components/ContentRender/ContentRender.es.js.map +1 -1
- 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/ContentRender/utils/inline-code-ranges.cjs +9 -9
- package/dist/components/ContentRender/utils/inline-code-ranges.cjs.map +1 -1
- package/dist/components/ContentRender/utils/inline-code-ranges.d.ts +3 -0
- package/dist/components/ContentRender/utils/inline-code-ranges.es.js +185 -161
- package/dist/components/ContentRender/utils/inline-code-ranges.es.js.map +1 -1
- package/dist/components/ContentRender/utils/mermaid-parse.cjs +4 -4
- package/dist/components/ContentRender/utils/mermaid-parse.cjs.map +1 -1
- package/dist/components/ContentRender/utils/mermaid-parse.es.js +53 -48
- package/dist/components/ContentRender/utils/mermaid-parse.es.js.map +1 -1
- package/dist/components/ContentRender/utils/split-content.cjs +6 -6
- package/dist/components/ContentRender/utils/split-content.cjs.map +1 -1
- package/dist/components/ContentRender/utils/split-content.d.ts +1 -0
- package/dist/components/ContentRender/utils/split-content.es.js +361 -313
- package/dist/components/ContentRender/utils/split-content.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 +286 -290
- 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 +62 -63
- 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 +13 -13
- 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 +19 -19
- 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 +16 -16
- 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 +13 -13
- 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 +176 -174
- package/dist/components/MarkdownFlowEditor/plugins/SyntaxHighlighter.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/plugins/VariablePlaceholder.cjs +2 -1
- package/dist/components/MarkdownFlowEditor/plugins/VariablePlaceholder.cjs.map +1 -1
- package/dist/components/MarkdownFlowEditor/plugins/VariablePlaceholder.d.ts +3 -1
- package/dist/components/MarkdownFlowEditor/plugins/VariablePlaceholder.es.js +38 -55
- package/dist/components/MarkdownFlowEditor/plugins/VariablePlaceholder.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 +47 -51
- package/dist/components/MarkdownFlowEditor/utils.es.js.map +1 -1
- package/dist/components/MarkdownFlowEditor/utils.variables.test.d.ts +1 -0
- package/dist/components/ui/inputGroup/textarea.cjs +1 -1
- package/dist/components/ui/inputGroup/textarea.es.js +1 -1
- package/dist/lib/interaction-defaults.cjs +1 -1
- package/dist/lib/interaction-defaults.cjs.map +1 -1
- package/dist/lib/interaction-defaults.es.js +123 -132
- package/dist/lib/interaction-defaults.es.js.map +1 -1
- package/dist/lib/interaction-defaults.failure.test.d.ts +1 -0
- 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/hast-util-to-jsx-runtime/lib/index.cjs +1 -1
- package/dist/node_modules/hast-util-to-jsx-runtime/lib/index.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/mermaid/dist/chunks/mermaid.core/c4Diagram-AAMF2YG6.cjs +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-AAMF2YG6.es.js +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-OMD6QJNC.cjs +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-OMD6QJNC.es.js +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-U37J5Y7L.cjs +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-U37J5Y7L.es.js +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-WV7ZQ7D5.cjs +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-WV7ZQ7D5.es.js +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-4MX5Z3NR.cjs +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-4MX5Z3NR.es.js +1 -1
- package/dist/node_modules/rc-input/es/BaseInput.cjs +1 -1
- package/dist/node_modules/rc-input/es/BaseInput.es.js +1 -1
- package/dist/node_modules/rc-textarea/es/ResizableTextArea.cjs +1 -1
- package/dist/node_modules/rc-textarea/es/ResizableTextArea.es.js +1 -1
- package/dist/node_modules/rc-textarea/es/TextArea.cjs +1 -1
- package/dist/node_modules/rc-textarea/es/TextArea.es.js +1 -1
- package/dist/node_modules/rc-textarea/es/index.cjs +1 -1
- package/dist/node_modules/rc-textarea/es/index.es.js +1 -1
- package/dist/node_modules/remark-flow/dist/escaping.cjs +2 -2
- package/dist/node_modules/remark-flow/dist/escaping.cjs.map +1 -1
- package/dist/node_modules/remark-flow/dist/escaping.es.js +128 -63
- package/dist/node_modules/remark-flow/dist/escaping.es.js.map +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 +62 -33
- 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 +260 -256
- package/dist/node_modules/remark-flow/dist/interaction-parser.es.js.map +1 -1
- package/dist/node_modules/remark-flow/dist/interaction-plugin-core.cjs +1 -1
- package/dist/node_modules/remark-flow/dist/interaction-plugin-core.cjs.map +1 -1
- package/dist/node_modules/remark-flow/dist/interaction-plugin-core.es.js +71 -42
- package/dist/node_modules/remark-flow/dist/interaction-plugin-core.es.js.map +1 -1
- package/dist/node_modules/remark-flow/dist/interaction-syntax.cjs +1 -1
- package/dist/node_modules/remark-flow/dist/interaction-syntax.cjs.map +1 -1
- package/dist/node_modules/remark-flow/dist/interaction-syntax.es.js +500 -46
- package/dist/node_modules/remark-flow/dist/interaction-syntax.es.js.map +1 -1
- package/dist/node_modules/remark-flow/dist/variable-marker.cjs +2 -0
- package/dist/node_modules/remark-flow/dist/variable-marker.cjs.map +1 -0
- package/dist/node_modules/remark-flow/dist/variable-marker.es.js +77 -0
- package/dist/node_modules/remark-flow/dist/variable-marker.es.js.map +1 -0
- package/dist/node_modules/remark-flow/dist/variable-name.cjs +15 -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 +748 -0
- package/dist/node_modules/remark-flow/dist/variable-name.es.js.map +1 -0
- package/dist/node_modules/style-to-object/cjs/index.cjs +1 -1
- package/dist/node_modules/style-to-object/cjs/index.cjs.map +1 -1
- package/dist/node_modules/style-to-object/cjs/index.es.js +1 -1
- package/dist/node_modules/unified/lib/index.cjs +1 -1
- package/dist/node_modules/unified/lib/index.es.js +1 -1
- package/package.json +2 -2
|
@@ -1,280 +1,284 @@
|
|
|
1
|
-
import { __exports as
|
|
2
|
-
import { __require as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return this._createErrorResult(`Parsing error: ${t instanceof Error ? t.message : "Unknown error"}`);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Parse and convert to remark-compatible format
|
|
51
|
-
*
|
|
52
|
-
* @param content - Raw content of interaction block
|
|
53
|
-
* @returns remark-compatible result object
|
|
54
|
-
*/
|
|
55
|
-
parseToRemarkFormat(e) {
|
|
56
|
-
const t = this.parse(e);
|
|
57
|
-
if (t.error)
|
|
58
|
-
return { placeholder: e.trim() };
|
|
59
|
-
const r = {};
|
|
60
|
-
if (t.type === u.NON_ASSIGNMENT_BUTTON) {
|
|
61
|
-
const s = t;
|
|
62
|
-
s.buttons.length > 0 && (r.buttonTexts = s.buttons.map((i) => i.display), r.buttonValues = s.buttons.map((i) => i.value)), s.question !== void 0 && (r.placeholder = s.question), s.isMultiSelect !== void 0 && (r.isMultiSelect = s.isMultiSelect);
|
|
63
|
-
} else if (t.type !== null) {
|
|
64
|
-
const s = t;
|
|
65
|
-
r.variableName = s.variable, s.buttons && (r.buttonTexts = s.buttons.map((i) => i.display), r.buttonValues = s.buttons.map((i) => i.value)), s.question !== void 0 && (r.placeholder = s.question), s.isMultiSelect !== void 0 && (r.isMultiSelect = s.isMultiSelect);
|
|
66
|
-
}
|
|
67
|
-
return r;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Layer 1: Validate ?[] format and extract content
|
|
71
|
-
*
|
|
72
|
-
* @param content - Raw content
|
|
73
|
-
* @returns Extracted bracket content, returns null if validation fails
|
|
74
|
-
*/
|
|
75
|
-
_layer1ValidateFormat(e) {
|
|
76
|
-
e = e.trim();
|
|
77
|
-
const t = l.COMPILED_REGEXES.LAYER1_INTERACTION.exec(e);
|
|
78
|
-
return !t || t[0].trim() !== e ? null : t[1];
|
|
1
|
+
import { __exports as o } from "../../../_virtual/interaction-parser.es.js";
|
|
2
|
+
import { __require as S } from "./escaping.es.js";
|
|
3
|
+
import { __require as I } from "./variable-name.es.js";
|
|
4
|
+
var d;
|
|
5
|
+
function h() {
|
|
6
|
+
if (d) return o;
|
|
7
|
+
d = 1, Object.defineProperty(o, "__esModule", { value: !0 }), o.InteractionParser = o.COMPILED_REGEXES = o.InteractionType = void 0, o.parseInteractionFormat = f, o.createInteractionParser = T;
|
|
8
|
+
const n = S(), s = I();
|
|
9
|
+
var u;
|
|
10
|
+
(function(c) {
|
|
11
|
+
c.TEXT_ONLY = "text_only", c.BUTTONS_ONLY = "buttons_only", c.BUTTONS_WITH_TEXT = "buttons_with_text", c.BUTTONS_MULTI_SELECT = "buttons_multi_select", c.BUTTONS_MULTI_WITH_TEXT = "buttons_multi_with_text", c.NON_ASSIGNMENT_BUTTON = "non_assignment_button";
|
|
12
|
+
})(u || (o.InteractionType = u = {})), o.COMPILED_REGEXES = {
|
|
13
|
+
// Layer 1: Basic format validation - matches ?[content] but excludes ?[text](url) format.
|
|
14
|
+
// The content accepts an escaped delimiter as one unit, so a `\]` inside an option does not
|
|
15
|
+
// end the interaction. See ./escaping.
|
|
16
|
+
LAYER1_INTERACTION: new RegExp(`\\?\\[(${n.INTERACTION_CONTENT_SOURCE})\\](?!\\()`),
|
|
17
|
+
// Names use the teaching engine's grammar; only the content after the marker is split into
|
|
18
|
+
// choices, display/value pairs or a text input. Punctuation inside the name is ordinary text.
|
|
19
|
+
LAYER2_VARIABLE: new RegExp(`^${s.VARIABLE_PADDING_SOURCE}${s.VARIABLE_ASSIGNMENT_SOURCE}([\\s\\S]*)$`),
|
|
20
|
+
// Layer 3: Split content before and after ...
|
|
21
|
+
LAYER3_ELLIPSIS: /^(.*?)\.\.\.(.*)/,
|
|
22
|
+
// Kept for consumers that inspect the exported regex collection. Exact
|
|
23
|
+
// single-pipe splitting requires context that Safari-safe regexes cannot
|
|
24
|
+
// express without consuming adjacent text, and now also has to skip a bar
|
|
25
|
+
// an option escaped, so the parser uses the scanner in ./escaping instead.
|
|
26
|
+
LAYER3_SINGLE_PIPE_SPLIT: /\|(?!\|)/g
|
|
27
|
+
};
|
|
28
|
+
class p {
|
|
29
|
+
constructor() {
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Main parsing method
|
|
33
|
+
*
|
|
34
|
+
* @param content - Raw content of interaction block
|
|
35
|
+
* @returns Standardized parse result
|
|
36
|
+
*/
|
|
37
|
+
parse(e) {
|
|
38
|
+
try {
|
|
39
|
+
const t = this._layer1ValidateFormat(e);
|
|
40
|
+
if (t === null)
|
|
41
|
+
return this._createErrorResult(`Invalid interaction format: ${e}`);
|
|
42
|
+
const [r, i, a] = this._layer2DetectVariable(t);
|
|
43
|
+
return r && i === null ? this._createErrorResult("Invalid variable name") : r && i ? this._layer3ParseVariableInteraction(i, a) : this._layer3ParseDisplayButtons(t);
|
|
44
|
+
} catch (t) {
|
|
45
|
+
return this._createErrorResult(`Parsing error: ${t instanceof Error ? t.message : "Unknown error"}`);
|
|
79
46
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Parse and convert to remark-compatible format
|
|
50
|
+
*
|
|
51
|
+
* @param content - Raw content of interaction block
|
|
52
|
+
* @returns remark-compatible result object
|
|
53
|
+
*/
|
|
54
|
+
parseToRemarkFormat(e) {
|
|
55
|
+
const t = this.parse(e);
|
|
56
|
+
if (t.error)
|
|
57
|
+
return { placeholder: (0, s.trimVariablePadding)(e) };
|
|
58
|
+
const r = {};
|
|
59
|
+
if (t.type === u.NON_ASSIGNMENT_BUTTON) {
|
|
60
|
+
const i = t;
|
|
61
|
+
i.buttons.length > 0 && (r.buttonTexts = i.buttons.map((a) => a.display), r.buttonValues = i.buttons.map((a) => a.value)), i.question !== void 0 && (r.placeholder = i.question), i.isMultiSelect !== void 0 && (r.isMultiSelect = i.isMultiSelect);
|
|
62
|
+
} else if (t.type !== null) {
|
|
63
|
+
const i = t;
|
|
64
|
+
r.variableName = i.variable, i.buttons && (r.buttonTexts = i.buttons.map((a) => a.display), r.buttonValues = i.buttons.map((a) => a.value)), i.question !== void 0 && (r.placeholder = i.question), i.isMultiSelect !== void 0 && (r.isMultiSelect = i.isMultiSelect);
|
|
92
65
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
66
|
+
return r;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Layer 1: Validate ?[] format and extract content
|
|
70
|
+
*
|
|
71
|
+
* @param content - Raw content
|
|
72
|
+
* @returns Extracted bracket content, returns null if validation fails
|
|
73
|
+
*/
|
|
74
|
+
_layer1ValidateFormat(e) {
|
|
75
|
+
e = (0, s.trimVariablePadding)(e);
|
|
76
|
+
const t = (0, n.readInteraction)(e);
|
|
77
|
+
return t?.complete && t.end === e.length ? t.content : null;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Layer 2: Detect variables and perform pattern classification
|
|
81
|
+
*
|
|
82
|
+
* @param innerContent - Content extracted from layer 1
|
|
83
|
+
* @returns [hasVariable, variableName, remainingContent]
|
|
84
|
+
*/
|
|
85
|
+
_layer2DetectVariable(e) {
|
|
86
|
+
if (e = (0, s.trimVariablePadding)(e), !e.startsWith("%{{"))
|
|
87
|
+
return [!1, null, e];
|
|
88
|
+
const t = (0, s.readVariableMarker)(e, 1);
|
|
89
|
+
if (!t)
|
|
90
|
+
return [!0, null, e];
|
|
91
|
+
const r = (0, s.normalizeVariableName)(t.rawName), i = (0, s.trimVariablePadding)(e.slice(t.end));
|
|
92
|
+
return [!0, r, i];
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Parse the structural shape of interaction content: buttons, optional
|
|
96
|
+
* `...question` text input, multi-select flag. Shared by the variable and
|
|
97
|
+
* non-assignment branches, which only differ in how they map the shape
|
|
98
|
+
* into their result types.
|
|
99
|
+
*
|
|
100
|
+
* @param content - Content after the (optional) variable
|
|
101
|
+
* @returns The parsed content shape
|
|
102
|
+
*/
|
|
103
|
+
_parseContentShape(e) {
|
|
104
|
+
const t = (0, n.splitOnEllipsis)(e);
|
|
105
|
+
if (t) {
|
|
106
|
+
const r = (0, s.trimVariablePadding)(t[0]), i = (0, s.trimVariablePadding)((0, n.unescapeInteractionText)(t[1]));
|
|
107
|
+
if (r) {
|
|
108
|
+
const [a, l] = this._parseButtons(r);
|
|
109
|
+
return { buttons: a, question: i, isMultiSelect: l, hasTextInput: !0 };
|
|
120
110
|
}
|
|
121
|
-
return
|
|
122
|
-
buttons: [this._parseSingleButton(e)],
|
|
123
|
-
isMultiSelect: !1,
|
|
124
|
-
hasTextInput: !1
|
|
125
|
-
} : {
|
|
111
|
+
return {
|
|
126
112
|
buttons: [],
|
|
127
|
-
question:
|
|
113
|
+
question: i,
|
|
128
114
|
isMultiSelect: !1,
|
|
129
115
|
hasTextInput: !0
|
|
130
116
|
};
|
|
131
117
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
* @param variableName - Variable name
|
|
136
|
-
* @param content - Content after variable
|
|
137
|
-
* @returns Parse result
|
|
138
|
-
*/
|
|
139
|
-
_layer3ParseVariableInteraction(e, t) {
|
|
140
|
-
const r = this._parseContentShape(t);
|
|
141
|
-
return r.hasTextInput ? r.buttons.length > 0 ? {
|
|
142
|
-
type: r.isMultiSelect ? u.BUTTONS_MULTI_WITH_TEXT : u.BUTTONS_WITH_TEXT,
|
|
143
|
-
variable: e,
|
|
144
|
-
buttons: r.buttons,
|
|
145
|
-
question: r.question,
|
|
146
|
-
isMultiSelect: r.isMultiSelect
|
|
147
|
-
} : {
|
|
148
|
-
type: u.TEXT_ONLY,
|
|
149
|
-
variable: e,
|
|
150
|
-
question: r.question ?? "",
|
|
151
|
-
isMultiSelect: !1
|
|
152
|
-
} : {
|
|
153
|
-
type: r.isMultiSelect ? u.BUTTONS_MULTI_SELECT : u.BUTTONS_ONLY,
|
|
154
|
-
variable: e,
|
|
155
|
-
buttons: r.buttons,
|
|
156
|
-
isMultiSelect: r.isMultiSelect
|
|
157
|
-
};
|
|
118
|
+
if ((0, n.findUnescaped)(e, "|") >= 0) {
|
|
119
|
+
const [r, i] = this._parseButtons(e);
|
|
120
|
+
return { buttons: r, isMultiSelect: i, hasTextInput: !1 };
|
|
158
121
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
122
|
+
return e ? {
|
|
123
|
+
buttons: [this._parseSingleButton(e)],
|
|
124
|
+
isMultiSelect: !1,
|
|
125
|
+
hasTextInput: !1
|
|
126
|
+
} : {
|
|
127
|
+
buttons: [],
|
|
128
|
+
question: "",
|
|
129
|
+
isMultiSelect: !1,
|
|
130
|
+
hasTextInput: !0
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Layer 3: Parse variable interaction (variable assignment type)
|
|
135
|
+
*
|
|
136
|
+
* @param variableName - Variable name
|
|
137
|
+
* @param content - Content after variable
|
|
138
|
+
* @returns Parse result
|
|
139
|
+
*/
|
|
140
|
+
_layer3ParseVariableInteraction(e, t) {
|
|
141
|
+
const r = this._parseContentShape(t);
|
|
142
|
+
return r.hasTextInput ? r.buttons.length > 0 ? {
|
|
143
|
+
type: r.isMultiSelect ? u.BUTTONS_MULTI_WITH_TEXT : u.BUTTONS_WITH_TEXT,
|
|
144
|
+
variable: e,
|
|
145
|
+
buttons: r.buttons,
|
|
146
|
+
question: r.question,
|
|
147
|
+
isMultiSelect: r.isMultiSelect
|
|
148
|
+
} : {
|
|
149
|
+
type: u.TEXT_ONLY,
|
|
150
|
+
variable: e,
|
|
151
|
+
question: r.question ?? "",
|
|
152
|
+
isMultiSelect: !1
|
|
153
|
+
} : {
|
|
154
|
+
type: r.isMultiSelect ? u.BUTTONS_MULTI_SELECT : u.BUTTONS_ONLY,
|
|
155
|
+
variable: e,
|
|
156
|
+
buttons: r.buttons,
|
|
157
|
+
isMultiSelect: r.isMultiSelect
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Layer 3: Parse non-assignment interactions (no variable). Same shapes as
|
|
162
|
+
* the variable branch; the answer is not assigned to a variable.
|
|
163
|
+
*
|
|
164
|
+
* @param content - Content
|
|
165
|
+
* @returns Parse result
|
|
166
|
+
*/
|
|
167
|
+
_layer3ParseDisplayButtons(e) {
|
|
168
|
+
if (!e)
|
|
169
|
+
return {
|
|
173
170
|
type: u.NON_ASSIGNMENT_BUTTON,
|
|
174
|
-
buttons:
|
|
175
|
-
isMultiSelect: t.isMultiSelect
|
|
171
|
+
buttons: [{ display: "", value: "" }]
|
|
176
172
|
};
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
173
|
+
const t = this._parseContentShape(e), r = {
|
|
174
|
+
type: u.NON_ASSIGNMENT_BUTTON,
|
|
175
|
+
buttons: t.buttons,
|
|
176
|
+
isMultiSelect: t.isMultiSelect
|
|
177
|
+
};
|
|
178
|
+
return t.hasTextInput && (r.question = t.question), r;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Parse button group with fault tolerance
|
|
182
|
+
*
|
|
183
|
+
* @param content - Button content, separated by | or ||
|
|
184
|
+
* @returns [button list, isMultiSelect]
|
|
185
|
+
*/
|
|
186
|
+
_parseButtons(e) {
|
|
187
|
+
if (!e || typeof e != "string")
|
|
188
|
+
return [[], !1];
|
|
189
|
+
const [t, r] = this._detectSeparatorType(e), i = [];
|
|
190
|
+
try {
|
|
191
|
+
let a;
|
|
192
|
+
r ? a = (0, n.splitUnescaped)(e, "||") : a = (0, n.splitOnSingleUnescapedPipe)(e);
|
|
193
|
+
for (const l of a) {
|
|
194
|
+
const _ = (0, s.trimVariablePadding)(l);
|
|
195
|
+
if (_) {
|
|
196
|
+
const b = this._parseSingleButton(_);
|
|
197
|
+
i.push(b);
|
|
198
198
|
}
|
|
199
|
-
} catch {
|
|
200
|
-
const i = (0, a.unescapeInteractionText)(e).trim();
|
|
201
|
-
return [[{ display: i, value: i }], !1];
|
|
202
199
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
const i = (0, a.unescapeInteractionText)(e).trim();
|
|
207
|
-
s.push({ display: i, value: i });
|
|
208
|
-
}
|
|
209
|
-
return [s, r];
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Parse single button, supports Button//value format
|
|
213
|
-
*
|
|
214
|
-
* @param buttonText - Button text
|
|
215
|
-
* @returns {display: display text, value: actual value}
|
|
216
|
-
*/
|
|
217
|
-
_parseSingleButton(e) {
|
|
218
|
-
e = e.trim();
|
|
219
|
-
const t = (0, a.findUnescaped)(e, "//");
|
|
220
|
-
if (t > 0 && t + 2 < e.length)
|
|
221
|
-
return {
|
|
222
|
-
display: (0, a.unescapeInteractionText)(e.slice(0, t)).trim(),
|
|
223
|
-
value: (0, a.unescapeInteractionText)(e.slice(t + 2)).trim()
|
|
224
|
-
};
|
|
225
|
-
const r = (0, a.unescapeInteractionText)(e);
|
|
226
|
-
return { display: r, value: r };
|
|
200
|
+
} catch {
|
|
201
|
+
const a = (0, s.trimVariablePadding)((0, n.unescapeInteractionText)(e));
|
|
202
|
+
return [[{ display: a, value: a }], !1];
|
|
227
203
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
* - If first separator is ||, then single | is treated as part of the value
|
|
234
|
-
*
|
|
235
|
-
* @param content - Button content to analyze
|
|
236
|
-
* @returns [separator, isMultiSelect] where separator is '|' or '||'
|
|
237
|
-
*/
|
|
238
|
-
_detectSeparatorType(e) {
|
|
239
|
-
if (!e || typeof e != "string")
|
|
240
|
-
return ["|", !1];
|
|
241
|
-
const t = (0, a.findUnescaped)(e, "|"), r = (0, a.findUnescaped)(e, "||");
|
|
242
|
-
return t === -1 ? ["|", !1] : r === -1 ? ["|", !1] : r <= t ? ["||", !0] : ["|", !1];
|
|
204
|
+
if (!i.length && ((0, s.trimVariablePadding)(e) === "||" || (0, s.trimVariablePadding)(e) === "|"))
|
|
205
|
+
return [[], r];
|
|
206
|
+
if (!i.length && (0, s.trimVariablePadding)(e)) {
|
|
207
|
+
const a = (0, s.trimVariablePadding)((0, n.unescapeInteractionText)(e));
|
|
208
|
+
i.push({ display: a, value: a });
|
|
243
209
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
210
|
+
return [i, r];
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Parse single button, supports Button//value format
|
|
214
|
+
*
|
|
215
|
+
* @param buttonText - Button text
|
|
216
|
+
* @returns {display: display text, value: actual value}
|
|
217
|
+
*/
|
|
218
|
+
_parseSingleButton(e) {
|
|
219
|
+
e = (0, s.trimVariablePadding)(e);
|
|
220
|
+
const t = (0, n.findUnescaped)(e, "//");
|
|
221
|
+
if (t > 0 && t + 2 < e.length)
|
|
251
222
|
return {
|
|
252
|
-
|
|
253
|
-
|
|
223
|
+
display: (0, s.trimVariablePadding)((0, n.unescapeInteractionText)(e.slice(0, t))),
|
|
224
|
+
value: (0, s.trimVariablePadding)((0, n.unescapeInteractionText)(e.slice(t + 2)))
|
|
254
225
|
};
|
|
255
|
-
|
|
226
|
+
const r = (0, n.unescapeInteractionText)(e);
|
|
227
|
+
return { display: r, value: r };
|
|
256
228
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
229
|
+
/**
|
|
230
|
+
* Detect separator type and whether it's multi-select
|
|
231
|
+
*
|
|
232
|
+
* Logic: The first separator type encountered determines the parsing mode:
|
|
233
|
+
* - If first separator is |, then || is treated as part of the value
|
|
234
|
+
* - If first separator is ||, then single | is treated as part of the value
|
|
235
|
+
*
|
|
236
|
+
* @param content - Button content to analyze
|
|
237
|
+
* @returns [separator, isMultiSelect] where separator is '|' or '||'
|
|
238
|
+
*/
|
|
239
|
+
_detectSeparatorType(e) {
|
|
240
|
+
if (!e || typeof e != "string")
|
|
241
|
+
return ["|", !1];
|
|
242
|
+
const t = (0, n.findUnescaped)(e, "|"), r = (0, n.findUnescaped)(e, "||");
|
|
243
|
+
return t === -1 ? ["|", !1] : r === -1 ? ["|", !1] : r <= t ? ["||", !0] : ["|", !1];
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Create error result
|
|
247
|
+
*
|
|
248
|
+
* @param errorMessage - Error message
|
|
249
|
+
* @returns Error result
|
|
250
|
+
*/
|
|
251
|
+
_createErrorResult(e) {
|
|
252
|
+
return {
|
|
253
|
+
type: null,
|
|
254
|
+
error: e
|
|
255
|
+
};
|
|
271
256
|
}
|
|
272
|
-
|
|
273
|
-
|
|
257
|
+
}
|
|
258
|
+
o.InteractionParser = p;
|
|
259
|
+
function f(c) {
|
|
260
|
+
const t = new p().parse(c);
|
|
261
|
+
if (t.error)
|
|
262
|
+
return [
|
|
263
|
+
u.TEXT_ONLY,
|
|
264
|
+
{ question: (0, s.trimVariablePadding)(c) }
|
|
265
|
+
];
|
|
266
|
+
const r = t.type, i = {};
|
|
267
|
+
if (t.type !== u.NON_ASSIGNMENT_BUTTON) {
|
|
268
|
+
const l = t;
|
|
269
|
+
l.variable !== void 0 && (i.variable = l.variable), l.buttons !== void 0 && (i.buttons = l.buttons), l.question !== void 0 && (i.question = l.question), l.isMultiSelect !== void 0 && (i.isMultiSelect = l.isMultiSelect);
|
|
270
|
+
} else {
|
|
271
|
+
const l = t;
|
|
272
|
+
l.buttons !== void 0 && (i.buttons = l.buttons);
|
|
274
273
|
}
|
|
275
|
-
|
|
274
|
+
return [r || u.TEXT_ONLY, i];
|
|
275
|
+
}
|
|
276
|
+
function T() {
|
|
277
|
+
return new p();
|
|
278
|
+
}
|
|
279
|
+
return o;
|
|
276
280
|
}
|
|
277
281
|
export {
|
|
278
|
-
|
|
282
|
+
h as __require
|
|
279
283
|
};
|
|
280
284
|
//# sourceMappingURL=interaction-parser.es.js.map
|