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