+ {template ? (
<>
- {promptOpen &&
- template?.split("\n")?.map((line, index) => {
- const regex = /{([^}]+)}/g;
- let match;
- let parts = [];
- let lastIndex = 0;
- while ((match = regex.exec(line)) !== null) {
- // Push text up to the match
- if (match.index !== lastIndex) {
- parts.push(line.substring(lastIndex, match.index));
- }
- // Push div with matched text
- if (chat.message[match[1]]) {
- parts.push(
-
- {chat.message[match[1]]}
-
- );
- }
+ {promptOpen
+ ? template?.split("\n")?.map((line, index) => {
+ const regex = /{([^}]+)}/g;
+ let match;
+ let parts = [];
+ let lastIndex = 0;
+ while ((match = regex.exec(line)) !== null) {
+ // Push text up to the match
+ if (match.index !== lastIndex) {
+ parts.push(line.substring(lastIndex, match.index));
+ }
+ // Push div with matched text
+ if (chat.message[match[1]]) {
+ parts.push(
+
+ {chat.message[match[1]]}
+
+ );
+ }
- // Update last index
- lastIndex = regex.lastIndex;
- }
- // Push text after the last match
- if (lastIndex !== line.length) {
- parts.push(line.substring(lastIndex));
- }
- return
{parts}
;
- })}
+ // Update last index
+ lastIndex = regex.lastIndex;
+ }
+ // Push text after the last match
+ if (lastIndex !== line.length) {
+ parts.push(line.substring(lastIndex));
+ }
+ return