markdown-flow-ui 0.1.120 → 0.1.121

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 (82) hide show
  1. package/dist/_virtual/index.cjs11.js +1 -1
  2. package/dist/_virtual/index.cjs12.js +1 -1
  3. package/dist/_virtual/index.cjs4.js +1 -1
  4. package/dist/_virtual/index.cjs5.js +1 -1
  5. package/dist/_virtual/index.cjs6.js +1 -1
  6. package/dist/_virtual/index.cjs8.js +1 -1
  7. package/dist/_virtual/index.cjs9.js +1 -1
  8. package/dist/_virtual/index.es10.js +2 -2
  9. package/dist/_virtual/index.es11.js +3 -3
  10. package/dist/_virtual/index.es12.js +2 -2
  11. package/dist/_virtual/index.es4.js +4 -4
  12. package/dist/_virtual/index.es5.js +4 -4
  13. package/dist/_virtual/index.es6.js +5 -5
  14. package/dist/_virtual/index.es8.js +3 -2
  15. package/dist/_virtual/index.es8.js.map +1 -1
  16. package/dist/_virtual/index.es9.js +2 -3
  17. package/dist/_virtual/index.es9.js.map +1 -1
  18. package/dist/assets/markdown-flow-ui.css +1 -1
  19. package/dist/components/ContentRender/ContentRender.cjs.js +2 -2
  20. package/dist/components/ContentRender/ContentRender.cjs.js.map +1 -1
  21. package/dist/components/ContentRender/ContentRender.d.ts +10 -1
  22. package/dist/components/ContentRender/ContentRender.es.js +221 -175
  23. package/dist/components/ContentRender/ContentRender.es.js.map +1 -1
  24. package/dist/components/ContentRender/ContentRender.stories.d.ts +1 -3
  25. package/dist/components/ContentRender/index.d.ts +1 -2
  26. package/dist/components/MarkdownFlow/MarkdownFlow.cjs.js +1 -1
  27. package/dist/components/MarkdownFlow/MarkdownFlow.cjs.js.map +1 -1
  28. package/dist/components/MarkdownFlow/MarkdownFlow.d.ts +0 -3
  29. package/dist/components/MarkdownFlow/MarkdownFlow.es.js +21 -29
  30. package/dist/components/MarkdownFlow/MarkdownFlow.es.js.map +1 -1
  31. package/dist/components/Slide/Slide.cjs.js +1 -1
  32. package/dist/components/Slide/Slide.cjs.js.map +1 -1
  33. package/dist/components/Slide/Slide.es.js +50 -51
  34. package/dist/components/Slide/Slide.es.js.map +1 -1
  35. package/dist/components/Slide/utils/runStreamFixture.d.ts +2 -0
  36. package/dist/components/ui/inputGroup/textarea.cjs.js +1 -1
  37. package/dist/components/ui/inputGroup/textarea.es.js +1 -1
  38. package/dist/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.cjs.js +1 -1
  39. package/dist/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.cjs.js.map +1 -1
  40. package/dist/markdown-flow-ui/node_modules/.pnpm/@braintree_sanitize-url@7.1.1/node_modules/@braintree/sanitize-url/dist/index.es.js +1 -1
  41. package/dist/markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.cjs.js +1 -1
  42. package/dist/markdown-flow-ui/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.es.js +1 -1
  43. package/dist/markdown-flow-ui/node_modules/.pnpm/hast-util-to-jsx-runtime@2.3.6/node_modules/hast-util-to-jsx-runtime/lib/index.cjs.js +1 -1
  44. package/dist/markdown-flow-ui/node_modules/.pnpm/hast-util-to-jsx-runtime@2.3.6/node_modules/hast-util-to-jsx-runtime/lib/index.es.js +1 -1
  45. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-YG6GDRKO.cjs.js +1 -1
  46. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-YG6GDRKO.cjs.js.map +1 -1
  47. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-YG6GDRKO.es.js +1 -1
  48. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-S3R3BYOJ.cjs.js +1 -1
  49. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-S3R3BYOJ.cjs.js.map +1 -1
  50. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-S3R3BYOJ.es.js +1 -1
  51. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-TZMSLE5B.cjs.js +1 -1
  52. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-TZMSLE5B.cjs.js.map +1 -1
  53. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/chunk-TZMSLE5B.es.js +1 -1
  54. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-LVOFAZNH.cjs.js +1 -1
  55. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-LVOFAZNH.cjs.js.map +1 -1
  56. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-LVOFAZNH.es.js +1 -1
  57. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-WL72ISMW.cjs.js +1 -1
  58. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-WL72ISMW.cjs.js.map +1 -1
  59. package/dist/markdown-flow-ui/node_modules/.pnpm/mermaid@11.12.1/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-WL72ISMW.es.js +1 -1
  60. package/dist/markdown-flow-ui/node_modules/.pnpm/rc-input@1.8.0_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-input/es/BaseInput.cjs.js +1 -1
  61. package/dist/markdown-flow-ui/node_modules/.pnpm/rc-input@1.8.0_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-input/es/BaseInput.es.js +1 -1
  62. package/dist/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/ResizableTextArea.cjs.js +1 -1
  63. package/dist/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/ResizableTextArea.es.js +1 -1
  64. package/dist/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/TextArea.cjs.js +1 -1
  65. package/dist/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/TextArea.es.js +1 -1
  66. package/dist/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/index.cjs.js +1 -1
  67. package/dist/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/index.es.js +1 -1
  68. package/dist/markdown-flow-ui/node_modules/.pnpm/rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/ref.cjs.js +1 -1
  69. package/dist/markdown-flow-ui/node_modules/.pnpm/rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/ref.cjs.js.map +1 -1
  70. package/dist/markdown-flow-ui/node_modules/.pnpm/rc-util@5.44.4_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-util/es/ref.es.js +1 -1
  71. package/dist/markdown-flow-ui/node_modules/.pnpm/react-is@18.3.1/node_modules/react-is/index.cjs.js +1 -1
  72. package/dist/markdown-flow-ui/node_modules/.pnpm/react-is@18.3.1/node_modules/react-is/index.es.js +1 -1
  73. package/dist/markdown-flow-ui/node_modules/.pnpm/unified@11.0.5/node_modules/unified/lib/index.cjs.js +1 -1
  74. package/dist/markdown-flow-ui/node_modules/.pnpm/unified@11.0.5/node_modules/unified/lib/index.es.js +1 -1
  75. package/dist/markdown-flow-ui-lib.css +1 -1
  76. package/package.json +2 -3
  77. package/dist/components/ContentRender/useTypewriter.d.ts +0 -19
  78. package/dist/components/ContentRender/useTypewriterStateMachine.cjs.js +0 -2
  79. package/dist/components/ContentRender/useTypewriterStateMachine.cjs.js.map +0 -1
  80. package/dist/components/ContentRender/useTypewriterStateMachine.d.ts +0 -19
  81. package/dist/components/ContentRender/useTypewriterStateMachine.es.js +0 -180
  82. package/dist/components/ContentRender/useTypewriterStateMachine.es.js.map +0 -1
@@ -1,19 +0,0 @@
1
- interface UseTypewriterProps {
2
- content?: string;
3
- typingSpeed?: number;
4
- disabled?: boolean;
5
- }
6
- interface Segment {
7
- content: string;
8
- isMarkdown: boolean;
9
- type?: string;
10
- }
11
- declare const useTypewriterStateMachine: ({ content, typingSpeed, disabled, }?: UseTypewriterProps) => {
12
- displayContent: string;
13
- isTyping: boolean;
14
- isComplete: boolean;
15
- reset: () => void;
16
- start: () => void;
17
- getSegments: () => Segment[];
18
- };
19
- export default useTypewriterStateMachine;
@@ -1,180 +0,0 @@
1
- import { useState as y, useRef as m, useCallback as B, useEffect as S } from "react";
2
- const D = ({
3
- content: C = "",
4
- typingSpeed: _ = 80,
5
- disabled: x = !1
6
- } = {}) => {
7
- const [T, b] = y(""), [g, i] = y(!1), [I, l] = y(!1), c = m([]), a = m(0), k = m(null), h = m(!0), d = m(""), w = m({
8
- state: "normal",
9
- buffer: "",
10
- depth: 0,
11
- tempBuffer: ""
12
- }), o = B(() => {
13
- k.current && (clearTimeout(k.current), k.current = null);
14
- }, []), M = B((n) => {
15
- const r = [], e = w.current;
16
- for (let f = 0; f < n.length; f++) {
17
- const t = n[f], u = n[f + 1], R = n[f + 2];
18
- switch (e.state) {
19
- case "normal":
20
- if (t === "?" && u === "[") {
21
- if (e.buffer) {
22
- for (const s of e.buffer)
23
- r.push({ content: s, isMarkdown: !1 });
24
- e.buffer = "";
25
- }
26
- e.state = "custom_tag", e.tempBuffer = "?[", f++;
27
- } else if (t === "`" && u === "`" && R === "`") {
28
- if (e.buffer) {
29
- for (const s of e.buffer)
30
- r.push({ content: s, isMarkdown: !1 });
31
- e.buffer = "";
32
- }
33
- e.state = "code_block", e.tempBuffer = "```", f += 2;
34
- } else if (t === "`") {
35
- if (e.buffer) {
36
- for (const s of e.buffer)
37
- r.push({ content: s, isMarkdown: !1 });
38
- e.buffer = "";
39
- }
40
- e.state = "inline_code", e.tempBuffer = "`";
41
- } else if (t === "*" && u === "*") {
42
- if (e.buffer) {
43
- for (const s of e.buffer)
44
- r.push({ content: s, isMarkdown: !1 });
45
- e.buffer = "";
46
- }
47
- e.state = "bold", e.tempBuffer = "**", f++;
48
- } else if (t === "*") {
49
- if (e.buffer) {
50
- for (const s of e.buffer)
51
- r.push({ content: s, isMarkdown: !1 });
52
- e.buffer = "";
53
- }
54
- e.state = "italic", e.tempBuffer = "*";
55
- } else if (t === "[") {
56
- if (e.buffer) {
57
- for (const s of e.buffer)
58
- r.push({ content: s, isMarkdown: !1 });
59
- e.buffer = "";
60
- }
61
- e.state = "link_text", e.tempBuffer = "[";
62
- } else
63
- e.buffer += t;
64
- break;
65
- case "code_block":
66
- e.tempBuffer += t, t === "`" && u === "`" && R === "`" && (e.tempBuffer += "``", r.push({
67
- content: e.tempBuffer,
68
- isMarkdown: !0,
69
- type: "code-block"
70
- }), e.tempBuffer = "", e.state = "normal", f += 2);
71
- break;
72
- case "inline_code":
73
- e.tempBuffer += t, t === "`" && (r.push({
74
- content: e.tempBuffer,
75
- isMarkdown: !0,
76
- type: "inline-code"
77
- }), e.tempBuffer = "", e.state = "normal");
78
- break;
79
- case "bold":
80
- e.tempBuffer += t, t === "*" && u === "*" && (e.tempBuffer += "*", r.push({
81
- content: e.tempBuffer,
82
- isMarkdown: !0,
83
- type: "bold"
84
- }), e.tempBuffer = "", e.state = "normal", f++);
85
- break;
86
- case "italic":
87
- e.tempBuffer += t, t === "*" && u !== "*" && (r.push({
88
- content: e.tempBuffer,
89
- isMarkdown: !0,
90
- type: "italic"
91
- }), e.tempBuffer = "", e.state = "normal");
92
- break;
93
- case "link_text":
94
- e.tempBuffer += t, t === "]" && u === "(" && (e.tempBuffer += "(", e.state = "link_url", f++);
95
- break;
96
- case "link_url":
97
- e.tempBuffer += t, t === ")" && (r.push({
98
- content: e.tempBuffer,
99
- isMarkdown: !0,
100
- type: "link"
101
- }), e.tempBuffer = "", e.state = "normal");
102
- break;
103
- case "custom_tag":
104
- e.tempBuffer += t, t === "]" && (r.push({
105
- content: e.tempBuffer,
106
- isMarkdown: !0,
107
- type: "custom-tag"
108
- }), e.tempBuffer = "", e.state = "normal");
109
- break;
110
- }
111
- }
112
- if (e.state === "normal" && e.buffer) {
113
- for (const f of e.buffer)
114
- r.push({ content: f, isMarkdown: !1 });
115
- e.buffer = "";
116
- }
117
- return r;
118
- }, []), p = B(() => {
119
- if (h.current)
120
- if (a.current < c.current.length) {
121
- const n = c.current[a.current];
122
- b((r) => r + (n?.content || "")), a.current++, h.current && (k.current = setTimeout(p, _));
123
- } else
124
- i(!1), l(!0);
125
- }, [_]);
126
- S(() => {
127
- const n = C || "", r = d.current;
128
- if (n === r)
129
- return;
130
- if (x) {
131
- o(), b(n), i(!1), l(!0), d.current = n;
132
- return;
133
- }
134
- if (n.length >= r.length && n.startsWith(r) && r) {
135
- const f = n.substring(r.length), t = M(f);
136
- c.current = [
137
- ...c.current,
138
- ...t
139
- ];
140
- const u = a.current >= c.current.length;
141
- l(u), !u && !g && (i(!0), p());
142
- } else {
143
- o(), b(""), w.current = {
144
- state: "normal",
145
- buffer: "",
146
- depth: 0,
147
- tempBuffer: ""
148
- };
149
- const f = M(n);
150
- c.current = f, a.current = 0;
151
- const t = f.length === 0;
152
- l(t), !t && n && h.current && (i(!0), p());
153
- }
154
- d.current = n;
155
- }, [C, x, o, M, p, g]), S(() => (h.current = !0, () => {
156
- h.current = !1, o();
157
- }), [o]);
158
- const N = B(() => {
159
- o(), b(""), c.current = [], a.current = 0, i(!1), l(!1), d.current = "", w.current = {
160
- state: "normal",
161
- buffer: "",
162
- depth: 0,
163
- tempBuffer: ""
164
- };
165
- }, [o]), G = B(() => {
166
- o(), a.current = 0, b(""), i(!0), l(!1), p();
167
- }, [o, p]);
168
- return {
169
- displayContent: T,
170
- isTyping: g,
171
- isComplete: I,
172
- reset: N,
173
- start: G,
174
- getSegments: () => c.current
175
- };
176
- };
177
- export {
178
- D as default
179
- };
180
- //# sourceMappingURL=useTypewriterStateMachine.es.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useTypewriterStateMachine.es.js","sources":["../../../src/components/ContentRender/useTypewriterStateMachine.ts"],"sourcesContent":["import { useState, useEffect, useRef, useCallback } from \"react\";\n\ninterface UseTypewriterProps {\n content?: string;\n typingSpeed?: number;\n disabled?: boolean;\n}\n\ninterface Segment {\n content: string;\n isMarkdown: boolean;\n type?: string;\n}\n\n// State machine states\ntype ParseState =\n | \"normal\"\n | \"code_block\"\n | \"inline_code\"\n | \"bold\"\n | \"italic\"\n | \"link_text\"\n | \"link_url\"\n | \"custom_tag\";\n\ninterface ParserState {\n state: ParseState;\n buffer: string;\n depth: number;\n tempBuffer: string;\n}\n\nconst useTypewriterStateMachine = ({\n content = \"\",\n typingSpeed = 80,\n disabled = false,\n}: UseTypewriterProps = {}) => {\n const [displayContent, setDisplayContent] = useState(\"\");\n const [isTyping, setIsTyping] = useState(false);\n const [isComplete, setIsComplete] = useState(false);\n\n const parsedSegmentsRef = useRef<Segment[]>([]);\n const displayIndexRef = useRef(0);\n const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const isMountedRef = useRef(true);\n const lastContentRef = useRef(\"\");\n const parserStateRef = useRef<ParserState>({\n state: \"normal\",\n buffer: \"\",\n depth: 0,\n tempBuffer: \"\",\n });\n\n // Cleanup function\n const clearTimer = useCallback(() => {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n timerRef.current = null;\n }\n }, []);\n\n // State machine parser - incremental parsing\n const parseWithStateMachine = useCallback((newChars: string): Segment[] => {\n const segments: Segment[] = [];\n const state = parserStateRef.current;\n\n for (let i = 0; i < newChars.length; i++) {\n const char = newChars[i];\n const nextChar = newChars[i + 1];\n const nextNextChar = newChars[i + 2];\n\n switch (state.state) {\n case \"normal\":\n // Check custom tag ?[\n if (char === \"?\" && nextChar === \"[\") {\n if (state.buffer) {\n // Output previous plain text\n for (const c of state.buffer) {\n segments.push({ content: c, isMarkdown: false });\n }\n state.buffer = \"\";\n }\n state.state = \"custom_tag\";\n state.tempBuffer = \"?[\";\n i++;\n }\n // Check code block start\n else if (char === \"`\" && nextChar === \"`\" && nextNextChar === \"`\") {\n if (state.buffer) {\n // Output previous plain text\n for (const c of state.buffer) {\n segments.push({ content: c, isMarkdown: false });\n }\n state.buffer = \"\";\n }\n state.state = \"code_block\";\n state.tempBuffer = \"```\";\n i += 2;\n }\n // Check inline code\n else if (char === \"`\") {\n if (state.buffer) {\n for (const c of state.buffer) {\n segments.push({ content: c, isMarkdown: false });\n }\n state.buffer = \"\";\n }\n state.state = \"inline_code\";\n state.tempBuffer = \"`\";\n }\n // Check bold\n else if (char === \"*\" && nextChar === \"*\") {\n if (state.buffer) {\n for (const c of state.buffer) {\n segments.push({ content: c, isMarkdown: false });\n }\n state.buffer = \"\";\n }\n state.state = \"bold\";\n state.tempBuffer = \"**\";\n i++;\n }\n // Check italic\n else if (char === \"*\") {\n if (state.buffer) {\n for (const c of state.buffer) {\n segments.push({ content: c, isMarkdown: false });\n }\n state.buffer = \"\";\n }\n state.state = \"italic\";\n state.tempBuffer = \"*\";\n }\n // Check link\n else if (char === \"[\") {\n if (state.buffer) {\n for (const c of state.buffer) {\n segments.push({ content: c, isMarkdown: false });\n }\n state.buffer = \"\";\n }\n state.state = \"link_text\";\n state.tempBuffer = \"[\";\n } else {\n state.buffer += char;\n }\n break;\n\n case \"code_block\":\n state.tempBuffer += char;\n // Check code block end\n if (char === \"`\" && nextChar === \"`\" && nextNextChar === \"`\") {\n state.tempBuffer += \"``\";\n segments.push({\n content: state.tempBuffer,\n isMarkdown: true,\n type: \"code-block\",\n });\n state.tempBuffer = \"\";\n state.state = \"normal\";\n i += 2;\n }\n break;\n\n case \"inline_code\":\n state.tempBuffer += char;\n if (char === \"`\") {\n segments.push({\n content: state.tempBuffer,\n isMarkdown: true,\n type: \"inline-code\",\n });\n state.tempBuffer = \"\";\n state.state = \"normal\";\n }\n break;\n\n case \"bold\":\n state.tempBuffer += char;\n if (char === \"*\" && nextChar === \"*\") {\n state.tempBuffer += \"*\";\n segments.push({\n content: state.tempBuffer,\n isMarkdown: true,\n type: \"bold\",\n });\n state.tempBuffer = \"\";\n state.state = \"normal\";\n i++;\n }\n break;\n\n case \"italic\":\n state.tempBuffer += char;\n if (char === \"*\" && nextChar !== \"*\") {\n segments.push({\n content: state.tempBuffer,\n isMarkdown: true,\n type: \"italic\",\n });\n state.tempBuffer = \"\";\n state.state = \"normal\";\n }\n break;\n\n case \"link_text\":\n state.tempBuffer += char;\n if (char === \"]\" && nextChar === \"(\") {\n state.tempBuffer += \"(\";\n state.state = \"link_url\";\n i++;\n }\n break;\n\n case \"link_url\":\n state.tempBuffer += char;\n if (char === \")\") {\n segments.push({\n content: state.tempBuffer,\n isMarkdown: true,\n type: \"link\",\n });\n state.tempBuffer = \"\";\n state.state = \"normal\";\n }\n break;\n\n case \"custom_tag\":\n state.tempBuffer += char;\n if (char === \"]\") {\n segments.push({\n content: state.tempBuffer,\n isMarkdown: true,\n type: \"custom-tag\",\n });\n state.tempBuffer = \"\";\n state.state = \"normal\";\n }\n break;\n }\n }\n\n // Process remaining plain text\n if (state.state === \"normal\" && state.buffer) {\n for (const c of state.buffer) {\n segments.push({ content: c, isMarkdown: false });\n }\n state.buffer = \"\";\n }\n\n return segments;\n }, []);\n\n // Typing function\n const type = useCallback(() => {\n if (!isMountedRef.current) return;\n\n if (displayIndexRef.current < parsedSegmentsRef.current.length) {\n const segment = parsedSegmentsRef.current[displayIndexRef.current];\n setDisplayContent((prev) => prev + (segment?.content || \"\"));\n displayIndexRef.current++;\n\n if (isMountedRef.current) {\n timerRef.current = setTimeout(type, typingSpeed);\n }\n } else {\n setIsTyping(false);\n setIsComplete(true);\n }\n }, [typingSpeed]);\n\n // Main effect\n useEffect(() => {\n const newContent = content || \"\";\n const oldContent = lastContentRef.current;\n\n // If content is the same, don't process\n if (newContent === oldContent) {\n return;\n }\n\n // Disabled mode: show all content immediately\n if (disabled) {\n clearTimer();\n setDisplayContent(newContent);\n setIsTyping(false);\n setIsComplete(true);\n lastContentRef.current = newContent;\n return;\n }\n\n // Check if content is growing\n const isContentGrowth =\n newContent.length >= oldContent.length &&\n newContent.startsWith(oldContent);\n\n if (isContentGrowth && oldContent) {\n // Content growth: parse only new parts\n const newChars = newContent.substring(oldContent.length);\n const newSegments = parseWithStateMachine(newChars);\n parsedSegmentsRef.current = [\n ...parsedSegmentsRef.current,\n ...newSegments,\n ];\n\n // Update completion status\n const isNowComplete =\n displayIndexRef.current >= parsedSegmentsRef.current.length;\n setIsComplete(isNowComplete);\n\n // If there's more content to type, ensure typewriter continues working\n if (!isNowComplete && !isTyping) {\n setIsTyping(true);\n type();\n }\n } else {\n // New content: start over\n clearTimer();\n setDisplayContent(\"\");\n\n // Reset parser state\n parserStateRef.current = {\n state: \"normal\",\n buffer: \"\",\n depth: 0,\n tempBuffer: \"\",\n };\n\n const segments = parseWithStateMachine(newContent);\n parsedSegmentsRef.current = segments;\n displayIndexRef.current = 0;\n\n const isNowComplete = segments.length === 0;\n setIsComplete(isNowComplete);\n\n if (!isNowComplete && newContent && isMountedRef.current) {\n setIsTyping(true);\n type();\n }\n }\n\n lastContentRef.current = newContent;\n }, [content, disabled, clearTimer, parseWithStateMachine, type, isTyping]);\n\n // Cleanup\n useEffect(() => {\n isMountedRef.current = true;\n return () => {\n isMountedRef.current = false;\n clearTimer();\n };\n }, [clearTimer]);\n\n const reset = useCallback(() => {\n clearTimer();\n setDisplayContent(\"\");\n parsedSegmentsRef.current = [];\n displayIndexRef.current = 0;\n setIsTyping(false);\n setIsComplete(false);\n lastContentRef.current = \"\";\n parserStateRef.current = {\n state: \"normal\",\n buffer: \"\",\n depth: 0,\n tempBuffer: \"\",\n };\n }, [clearTimer]);\n\n const start = useCallback(() => {\n clearTimer();\n displayIndexRef.current = 0;\n setDisplayContent(\"\");\n setIsTyping(true);\n setIsComplete(false);\n type();\n }, [clearTimer, type]);\n\n return {\n displayContent,\n isTyping,\n isComplete,\n reset,\n start,\n getSegments: () => parsedSegmentsRef.current,\n };\n};\n\nexport default useTypewriterStateMachine;\n"],"names":["useTypewriterStateMachine","content","typingSpeed","disabled","displayContent","setDisplayContent","useState","isTyping","setIsTyping","isComplete","setIsComplete","parsedSegmentsRef","useRef","displayIndexRef","timerRef","isMountedRef","lastContentRef","parserStateRef","clearTimer","useCallback","parseWithStateMachine","newChars","segments","state","i","char","nextChar","nextNextChar","c","type","segment","prev","useEffect","newContent","oldContent","newSegments","isNowComplete","reset","start"],"mappings":";AAgCA,MAAMA,IAA4B,CAAC;AAAA,EACjC,SAAAC,IAAU;AAAA,EACV,aAAAC,IAAc;AAAA,EACd,UAAAC,IAAW;AACb,IAAwB,OAAO;AAC7B,QAAM,CAACC,GAAgBC,CAAiB,IAAIC,EAAS,EAAE,GACjD,CAACC,GAAUC,CAAW,IAAIF,EAAS,EAAK,GACxC,CAACG,GAAYC,CAAa,IAAIJ,EAAS,EAAK,GAE5CK,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