@bikdotai/bik-component-library 0.0.838-beta.6 → 0.0.838
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/dist/cjs/components/WhatsAppTextEditor/WhatsAppTextEditor.js +23 -23
- package/dist/cjs/components/WhatsAppTextEditor/WhatsAppTextEditor.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/AiTextArea.js +1 -1
- package/dist/cjs/components/agent-builder/components/AiTextArea.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/ToolInstructionsField.js +2 -2
- package/dist/cjs/components/agent-builder/components/ToolInstructionsField.js.map +1 -1
- package/dist/cjs/components/bik-chatbot/components/ChatWindow.js +20 -20
- package/dist/cjs/components/bik-chatbot/components/ChatWindow.js.map +1 -1
- package/dist/cjs/components/input/ChipInput.js +1 -1
- package/dist/cjs/components/input/ChipInput.js.map +1 -1
- package/dist/cjs/components/input/Input-helper.js +1 -1
- package/dist/cjs/components/input/Input-helper.js.map +1 -1
- package/dist/cjs/components/input/Input.js +1 -1
- package/dist/cjs/components/input/Input.js.map +1 -1
- package/dist/cjs/components/plans/SubscriptionPlanSelector.js +5 -5
- package/dist/cjs/components/plans/SubscriptionPlanSelector.js.map +1 -1
- package/dist/cjs/editor/BikEditor.js +1 -1
- package/dist/cjs/editor/BikEditor.js.map +1 -1
- package/dist/cjs/editor/BikEditor.utils.js +3 -3
- package/dist/cjs/editor/BikEditor.utils.js.map +1 -1
- package/dist/cjs/editor/extensions/buildExtensions.js +2 -2
- package/dist/cjs/editor/extensions/buildExtensions.js.map +1 -1
- package/dist/cjs/icons/Informational/General/HourglassFilled.js +2 -0
- package/dist/cjs/icons/Informational/General/HourglassFilled.js.map +1 -0
- package/dist/cjs/icons/index.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/esm/components/WhatsAppTextEditor/WhatsAppTextEditor.js +143 -144
- package/dist/esm/components/WhatsAppTextEditor/WhatsAppTextEditor.js.map +1 -1
- package/dist/esm/components/agent-builder/components/AiTextArea.js +23 -24
- package/dist/esm/components/agent-builder/components/AiTextArea.js.map +1 -1
- package/dist/esm/components/agent-builder/components/ToolInstructionsField.js +30 -31
- package/dist/esm/components/agent-builder/components/ToolInstructionsField.js.map +1 -1
- package/dist/esm/components/bik-chatbot/components/ChatWindow.js +53 -54
- package/dist/esm/components/bik-chatbot/components/ChatWindow.js.map +1 -1
- package/dist/esm/components/input/ChipInput.js +40 -41
- package/dist/esm/components/input/ChipInput.js.map +1 -1
- package/dist/esm/components/input/Input-helper.d.ts +0 -7
- package/dist/esm/components/input/Input-helper.js +25 -16
- package/dist/esm/components/input/Input-helper.js.map +1 -1
- package/dist/esm/components/input/Input.js +58 -60
- package/dist/esm/components/input/Input.js.map +1 -1
- package/dist/esm/components/input/Input.model.d.ts +0 -1
- package/dist/esm/components/plans/SubscriptionPlanSelector.js +40 -42
- package/dist/esm/components/plans/SubscriptionPlanSelector.js.map +1 -1
- package/dist/esm/editor/BikEditor.js +118 -122
- package/dist/esm/editor/BikEditor.js.map +1 -1
- package/dist/esm/editor/BikEditor.utils.d.ts +1 -1
- package/dist/esm/editor/BikEditor.utils.js +140 -141
- package/dist/esm/editor/BikEditor.utils.js.map +1 -1
- package/dist/esm/editor/extensions/buildExtensions.js +39 -49
- package/dist/esm/editor/extensions/buildExtensions.js.map +1 -1
- package/dist/esm/helpers/index.d.ts +0 -1
- package/dist/esm/icons/Informational/General/HourglassFilled.d.ts +7 -0
- package/dist/esm/icons/Informational/General/HourglassFilled.js +33 -0
- package/dist/esm/icons/Informational/General/HourglassFilled.js.map +1 -0
- package/dist/esm/icons/Informational/General/index.d.ts +1 -0
- package/dist/esm/icons/Media/Visual/index.d.ts +0 -2
- package/dist/esm/icons/index.d.ts +25 -25
- package/dist/esm/icons/index.js +416 -418
- package/dist/esm/icons/index.js.map +1 -1
- package/dist/esm/index.js +114 -124
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -2
- package/dist/cjs/editor/extensions/htmlTagStrip/HtmlTagStripExtension.js +0 -2
- package/dist/cjs/editor/extensions/htmlTagStrip/HtmlTagStripExtension.js.map +0 -1
- package/dist/cjs/helpers/sanitize.js +0 -2
- package/dist/cjs/helpers/sanitize.js.map +0 -1
- package/dist/cjs/icons/Media/Visual/FormkitNeutral.js +0 -2
- package/dist/cjs/icons/Media/Visual/FormkitNeutral.js.map +0 -1
- package/dist/cjs/icons/Media/Visual/FormkitSad.js +0 -2
- package/dist/cjs/icons/Media/Visual/FormkitSad.js.map +0 -1
- package/dist/esm/editor/extensions/htmlTagStrip/HtmlTagStripExtension.d.ts +0 -13
- package/dist/esm/editor/extensions/htmlTagStrip/HtmlTagStripExtension.js +0 -64
- package/dist/esm/editor/extensions/htmlTagStrip/HtmlTagStripExtension.js.map +0 -1
- package/dist/esm/helpers/sanitize.d.ts +0 -32
- package/dist/esm/helpers/sanitize.js +0 -204
- package/dist/esm/helpers/sanitize.js.map +0 -1
- package/dist/esm/icons/Media/Visual/FormkitNeutral.js +0 -58
- package/dist/esm/icons/Media/Visual/FormkitNeutral.js.map +0 -1
- package/dist/esm/icons/Media/Visual/FormkitSad.js +0 -61
- package/dist/esm/icons/Media/Visual/FormkitSad.js.map +0 -1
|
@@ -1,31 +1,30 @@
|
|
|
1
|
-
import { jsxs as h, jsx as n, Fragment as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import { BaseWhatsappContentLangHelper as
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import a, { keyframes as tn } from "styled-components";
|
|
1
|
+
import { jsxs as h, jsx as n, Fragment as Ne } from "react/jsx-runtime";
|
|
2
|
+
import Ue from "../../assets/icons/check.svg.js";
|
|
3
|
+
import ze from "../../assets/icons/chevronLeft.svg.js";
|
|
4
|
+
import Ge from "../../assets/icons/chevronRight.svg.js";
|
|
5
|
+
import je from "../../assets/icons/cross.svg.js";
|
|
6
|
+
import We from "../../assets/icons/edit.svg.js";
|
|
7
|
+
import Xe from "../../assets/icons/info.svg.js";
|
|
8
|
+
import Ye from "../../assets/icons/rewind.svg.js";
|
|
9
|
+
import Je from "../../assets/icons/thumb-down-line.svg.js";
|
|
10
|
+
import Qe from "../../assets/icons/thumb-up-line.svg.js";
|
|
11
|
+
import { BaseWhatsappContentLangHelper as Ze } from "../../helpers/BaseWhatsappContentLang.helper.js";
|
|
12
|
+
import qe, { useRef as f, useState as S, useMemo as L, useEffect as _, useCallback as E, useImperativeHandle as Ve } from "react";
|
|
13
|
+
import a, { keyframes as Ke } from "styled-components";
|
|
15
14
|
import { COLORS as i } from "../../constants/Theme.js";
|
|
16
15
|
import { Tooltip as it } from "../tooltips/Tooltip.js";
|
|
17
|
-
import { TitleSmall as
|
|
18
|
-
import { resolveActionPrompts as
|
|
19
|
-
import { computeAiTagOnPostEdit as
|
|
20
|
-
import { AI_TAG_CHANGE_RATIO_THRESHOLD as
|
|
21
|
-
import { buildActionPrompt as
|
|
22
|
-
import { OuterContainer as
|
|
23
|
-
import { AIEditorActionTypes as p, AIActionVariant as mt, WhatsAppTextEditorHeader as
|
|
24
|
-
const Ht = "Character limit reached",
|
|
16
|
+
import { TitleSmall as tn, BodyCaption as ge } from "../TypographyStyle.js";
|
|
17
|
+
import { resolveActionPrompts as en, DEFAULT_INSTRUCTION_SUGGESTIONS as nn, DEFAULT_AI_ACTION_MIN_CHARS as pt } from "./ai/actionRegistry.js";
|
|
18
|
+
import { computeAiTagOnPostEdit as rn, computeAiTagOnAccept as on } from "./ai/aiTag.js";
|
|
19
|
+
import { AI_TAG_CHANGE_RATIO_THRESHOLD as sr, levenshteinDistance as lr } from "./ai/aiTag.js";
|
|
20
|
+
import { buildActionPrompt as cn, requestAISuggestion as sn } from "./ai/api.js";
|
|
21
|
+
import { OuterContainer as ln, EditorFooterRow as an, EditorFooterTitle as un, EditorFooterRight as dn, Container as gn, TextSpace as hn } from "./CustomEditor.styled.js";
|
|
22
|
+
import { AIEditorActionTypes as p, AIActionVariant as mt, WhatsAppTextEditorHeader as fn, EditorActionTypes as kt } from "./WhatsAppTextEditorHeader.js";
|
|
23
|
+
const Ht = "Character limit reached", he = 3e3, pn = 5, fe = 3, pe = 1200, mn = 1e3, bn = "Rephrase this WhatsApp utility template to improve clarity and readability while preserving variables, intent, and compliance.", be = Ke`
|
|
25
24
|
0% { opacity: 0.55; }
|
|
26
25
|
50% { opacity: 1; }
|
|
27
26
|
100% { opacity: 0.55; }
|
|
28
|
-
`,
|
|
27
|
+
`, xn = a.div`
|
|
29
28
|
padding: 14px 12px;
|
|
30
29
|
display: flex;
|
|
31
30
|
flex-direction: column;
|
|
@@ -36,8 +35,8 @@ const Ht = "Character limit reached", fe = 3e3, mn = 5, pe = 3, me = 1200, bn =
|
|
|
36
35
|
border-radius: 6px;
|
|
37
36
|
width: ${(g) => g.width};
|
|
38
37
|
background: #ececef;
|
|
39
|
-
animation: ${
|
|
40
|
-
`,
|
|
38
|
+
animation: ${be} 1.1s ease-in-out infinite;
|
|
39
|
+
`, Sn = a.div`
|
|
41
40
|
padding: 12px;
|
|
42
41
|
display: flex;
|
|
43
42
|
flex-direction: column;
|
|
@@ -56,22 +55,22 @@ const Ht = "Character limit reached", fe = 3e3, mn = 5, pe = 3, me = 1200, bn =
|
|
|
56
55
|
::-webkit-scrollbar-track {
|
|
57
56
|
background: transparent;
|
|
58
57
|
}
|
|
59
|
-
`,
|
|
58
|
+
`, Rn = a.div`
|
|
60
59
|
text-decoration: line-through;
|
|
61
60
|
color: ${i.content.secondary};
|
|
62
|
-
`,
|
|
61
|
+
`, me = a.div`
|
|
63
62
|
color: ${i.content.primary};
|
|
64
|
-
`,
|
|
63
|
+
`, En = a.div`
|
|
65
64
|
display: flex;
|
|
66
65
|
flex-direction: column;
|
|
67
66
|
gap: 8px;
|
|
68
67
|
width: 100%;
|
|
69
68
|
min-height: 40px;
|
|
70
|
-
`,
|
|
69
|
+
`, vn = a.div`
|
|
71
70
|
display: flex;
|
|
72
71
|
align-items: center;
|
|
73
72
|
gap: 6px;
|
|
74
|
-
`,
|
|
73
|
+
`, Tn = a.span`
|
|
75
74
|
color: ${i.content.primary};
|
|
76
75
|
font-size: 14px;
|
|
77
76
|
`, O = a.button`
|
|
@@ -92,19 +91,19 @@ const Ht = "Character limit reached", fe = 3e3, mn = 5, pe = 3, me = 1200, bn =
|
|
|
92
91
|
opacity: 0.35;
|
|
93
92
|
cursor: not-allowed;
|
|
94
93
|
}
|
|
95
|
-
`,
|
|
94
|
+
`, wn = a(O)`
|
|
96
95
|
:disabled {
|
|
97
96
|
opacity: 1;
|
|
98
97
|
cursor: wait;
|
|
99
98
|
}
|
|
100
|
-
`,
|
|
99
|
+
`, Cn = a.div`
|
|
101
100
|
width: 14px;
|
|
102
101
|
height: 14px;
|
|
103
102
|
border-radius: 4px;
|
|
104
103
|
background: #ececef;
|
|
105
104
|
flex-shrink: 0;
|
|
106
|
-
animation: ${
|
|
107
|
-
`,
|
|
105
|
+
animation: ${be} 1.1s ease-in-out infinite;
|
|
106
|
+
`, _n = a.div`
|
|
108
107
|
background: ${i.surface.standard};
|
|
109
108
|
display: flex;
|
|
110
109
|
flex-direction: column;
|
|
@@ -112,7 +111,7 @@ const Ht = "Character limit reached", fe = 3e3, mn = 5, pe = 3, me = 1200, bn =
|
|
|
112
111
|
gap: 10px;
|
|
113
112
|
border-radius: 0 0 4px 4px;
|
|
114
113
|
position: relative;
|
|
115
|
-
`,
|
|
114
|
+
`, An = a.div`
|
|
116
115
|
border: 1px solid #f5a4c0;
|
|
117
116
|
border-radius: 10px;
|
|
118
117
|
padding: 8px 10px;
|
|
@@ -120,7 +119,7 @@ const Ht = "Character limit reached", fe = 3e3, mn = 5, pe = 3, me = 1200, bn =
|
|
|
120
119
|
align-items: center;
|
|
121
120
|
gap: 10px;
|
|
122
121
|
background: ${i.surface.standard};
|
|
123
|
-
`,
|
|
122
|
+
`, yn = a.input`
|
|
124
123
|
flex: 1;
|
|
125
124
|
min-width: 0;
|
|
126
125
|
border: 0;
|
|
@@ -128,11 +127,11 @@ const Ht = "Character limit reached", fe = 3e3, mn = 5, pe = 3, me = 1200, bn =
|
|
|
128
127
|
font-size: 14px;
|
|
129
128
|
background: transparent;
|
|
130
129
|
color: ${i.content.primary};
|
|
131
|
-
`,
|
|
130
|
+
`, kn = a.div`
|
|
132
131
|
display: flex;
|
|
133
132
|
align-items: center;
|
|
134
133
|
gap: 10px;
|
|
135
|
-
`,
|
|
134
|
+
`, Hn = a.button`
|
|
136
135
|
border: 0;
|
|
137
136
|
background: transparent;
|
|
138
137
|
color: ${i.content.secondary};
|
|
@@ -140,7 +139,7 @@ const Ht = "Character limit reached", fe = 3e3, mn = 5, pe = 3, me = 1200, bn =
|
|
|
140
139
|
font-weight: 500;
|
|
141
140
|
padding: 0;
|
|
142
141
|
cursor: pointer;
|
|
143
|
-
`,
|
|
142
|
+
`, In = a.button`
|
|
144
143
|
border: 1px solid #5d3a72;
|
|
145
144
|
color: #5d3a72;
|
|
146
145
|
background: ${i.surface.standard};
|
|
@@ -150,7 +149,7 @@ const Ht = "Character limit reached", fe = 3e3, mn = 5, pe = 3, me = 1200, bn =
|
|
|
150
149
|
line-height: 1.1;
|
|
151
150
|
font-weight: 600;
|
|
152
151
|
cursor: pointer;
|
|
153
|
-
`,
|
|
152
|
+
`, Ln = a.div`
|
|
154
153
|
margin-top: 4px;
|
|
155
154
|
border-radius: 12px;
|
|
156
155
|
width: 331px;
|
|
@@ -161,7 +160,7 @@ const Ht = "Character limit reached", fe = 3e3, mn = 5, pe = 3, me = 1200, bn =
|
|
|
161
160
|
display: flex;
|
|
162
161
|
flex-direction: column;
|
|
163
162
|
gap: 2px;
|
|
164
|
-
`,
|
|
163
|
+
`, Pn = a.button`
|
|
165
164
|
width: 100%;
|
|
166
165
|
border: 0;
|
|
167
166
|
border-radius: 8px;
|
|
@@ -175,25 +174,25 @@ const Ht = "Character limit reached", fe = 3e3, mn = 5, pe = 3, me = 1200, bn =
|
|
|
175
174
|
:hover {
|
|
176
175
|
background: ${(g) => g.selected ? "#d9e8db" : i.surface.subdued};
|
|
177
176
|
}
|
|
178
|
-
`, B = new
|
|
177
|
+
`, B = new Ze(), $n = {
|
|
179
178
|
[kt.BOLD]: "*",
|
|
180
179
|
[kt.ITALIC]: "_",
|
|
181
180
|
[kt.STRIKETHROUGH]: "~"
|
|
182
181
|
};
|
|
183
|
-
function
|
|
182
|
+
function Dn(g) {
|
|
184
183
|
return `whatsapp-editor-rephrase-highlight-${g || "default"}`;
|
|
185
184
|
}
|
|
186
|
-
const
|
|
185
|
+
const Mn = qe.forwardRef(
|
|
187
186
|
({
|
|
188
187
|
onChange: g,
|
|
189
|
-
onClickVariable:
|
|
188
|
+
onClickVariable: Fn,
|
|
190
189
|
text: N,
|
|
191
|
-
RightComponent:
|
|
190
|
+
RightComponent: xe,
|
|
192
191
|
error: P,
|
|
193
192
|
limit: U,
|
|
194
193
|
onError: z,
|
|
195
|
-
rows:
|
|
196
|
-
actions:
|
|
194
|
+
rows: Se,
|
|
195
|
+
actions: Re,
|
|
197
196
|
editorInstanceKey: w,
|
|
198
197
|
editorSessionId: ot,
|
|
199
198
|
templateType: $ = "marketing",
|
|
@@ -217,18 +216,18 @@ const Fn = Ve.forwardRef(
|
|
|
217
216
|
promptOverrides: Ot,
|
|
218
217
|
rephraseTones: Nt,
|
|
219
218
|
aiActionMinChars: Ut,
|
|
220
|
-
instructionSuggestions: zt =
|
|
219
|
+
instructionSuggestions: zt = nn,
|
|
221
220
|
onAnalyticsEvent: Gt,
|
|
222
221
|
onAITagComputed: ct,
|
|
223
222
|
prefillWasAiGenerated: A = !1,
|
|
224
223
|
editorHeader: jt,
|
|
225
|
-
onAIToneSelect:
|
|
224
|
+
onAIToneSelect: Ee,
|
|
226
225
|
onAIActionRequest: st,
|
|
227
226
|
onBuildAIPrompt: Wt,
|
|
228
|
-
onBlur:
|
|
229
|
-
...
|
|
230
|
-
},
|
|
231
|
-
const u = f(null), [o,
|
|
227
|
+
onBlur: ve,
|
|
228
|
+
...Te
|
|
229
|
+
}, we) => {
|
|
230
|
+
const u = f(null), [o, Ce] = S(N || ""), [Xt, Y] = S(!1), [Rt, Yt] = S(0), [c, Jt] = S(!1), [Qt, Et] = S(!1), [y, lt] = S(""), [at, _e] = S({}), [R, Zt] = S(
|
|
232
231
|
null
|
|
233
232
|
), [m, vt] = S(
|
|
234
233
|
[]
|
|
@@ -236,10 +235,10 @@ const Fn = Ve.forwardRef(
|
|
|
236
235
|
null
|
|
237
236
|
), C = f(
|
|
238
237
|
null
|
|
239
|
-
), Z = f(null), q = f(null), Kt = f(null), Tt = f(!!A), ut = f(null), V = f(""), dt = f(!1), [wt, te] = S({}),
|
|
238
|
+
), Z = f(null), q = f(null), Kt = f(null), Tt = f(!!A), ut = f(null), V = f(""), dt = f(!1), [wt, te] = S({}), Ae = f(
|
|
240
239
|
`mount-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`
|
|
241
|
-
), K = L(() =>
|
|
242
|
-
`${w || "default"}-${ot ||
|
|
240
|
+
), K = L(() => Dn(
|
|
241
|
+
`${w || "default"}-${ot || Ae.current}`
|
|
243
242
|
), [w, ot]);
|
|
244
243
|
_(() => {
|
|
245
244
|
Tt.current = !!A;
|
|
@@ -254,7 +253,7 @@ const Fn = Ve.forwardRef(
|
|
|
254
253
|
const t = N ?? "";
|
|
255
254
|
t.length > 0 && (V.current = t, dt.current = !0);
|
|
256
255
|
}, [A, N, w, ot]);
|
|
257
|
-
const gt = L(() =>
|
|
256
|
+
const gt = L(() => en($, Ot, Nt), [Ot, Nt, $]), ee = L(() => {
|
|
258
257
|
const t = y.trim().toLowerCase();
|
|
259
258
|
return t ? zt.filter(
|
|
260
259
|
(e) => e.toLowerCase().includes(t)
|
|
@@ -262,7 +261,7 @@ const Fn = Ve.forwardRef(
|
|
|
262
261
|
}, [zt, y]), tt = L(() => ({
|
|
263
262
|
...pt,
|
|
264
263
|
...Ut || {}
|
|
265
|
-
}), [Ut]), ne = tt[p.REPHRASE] || pt[p.REPHRASE],
|
|
264
|
+
}), [Ut]), ne = tt[p.REPHRASE] || pt[p.REPHRASE], ye = E((t) => {
|
|
266
265
|
const e = t.trim().replace(/\s+/g, " ");
|
|
267
266
|
if (!e) return "";
|
|
268
267
|
const r = e.split(" ").length;
|
|
@@ -273,10 +272,10 @@ const Fn = Ve.forwardRef(
|
|
|
273
272
|
},
|
|
274
273
|
[Gt]
|
|
275
274
|
), H = E((t) => {
|
|
276
|
-
|
|
275
|
+
Ce((e) => e === t ? e : t);
|
|
277
276
|
}, []), D = E(
|
|
278
277
|
(t) => {
|
|
279
|
-
if (q.current && clearTimeout(q.current), t.length >
|
|
278
|
+
if (q.current && clearTimeout(q.current), t.length > pe) {
|
|
280
279
|
g?.(t, t), q.current = setTimeout(() => {
|
|
281
280
|
g?.(t, B.getHTML(t));
|
|
282
281
|
}, 16);
|
|
@@ -289,7 +288,7 @@ const Fn = Ve.forwardRef(
|
|
|
289
288
|
(t) => {
|
|
290
289
|
const r = ut.current?.acceptedText || (A ? V.current : "");
|
|
291
290
|
if (!r || t === r) return;
|
|
292
|
-
const l =
|
|
291
|
+
const l = rn({
|
|
293
292
|
acceptedAiText: r,
|
|
294
293
|
currentEditedText: t
|
|
295
294
|
});
|
|
@@ -302,7 +301,7 @@ const Fn = Ve.forwardRef(
|
|
|
302
301
|
), et = E(() => {
|
|
303
302
|
Zt(null), vt([]), J(0), qt(null), te({});
|
|
304
303
|
}, []), ie = E(() => {
|
|
305
|
-
if (c || R && m.length > 0 || Rt >=
|
|
304
|
+
if (c || R && m.length > 0 || Rt >= pn)
|
|
306
305
|
return;
|
|
307
306
|
const t = Rt + 1;
|
|
308
307
|
Yt(t), typeof window < "u" && w && sessionStorage.setItem(K, String(t)), Y(!0), Q.current && clearTimeout(Q.current), Q.current = setTimeout(() => {
|
|
@@ -317,8 +316,8 @@ const Fn = Ve.forwardRef(
|
|
|
317
316
|
Rt
|
|
318
317
|
]), ht = f(ie);
|
|
319
318
|
ht.current = ie;
|
|
320
|
-
function
|
|
321
|
-
const e =
|
|
319
|
+
function ke(t) {
|
|
320
|
+
const e = t.target.value, r = ut.current;
|
|
322
321
|
r && !r.editedEventEmitted && e !== r.acceptedText && (ut.current = {
|
|
323
322
|
...r,
|
|
324
323
|
editedEventEmitted: !0
|
|
@@ -329,14 +328,14 @@ const Fn = Ve.forwardRef(
|
|
|
329
328
|
const l = r?.acceptedText || (A ? V.current : "");
|
|
330
329
|
l && e !== l && (C.current = setTimeout(() => {
|
|
331
330
|
re(e);
|
|
332
|
-
},
|
|
331
|
+
}, mn)), H(e), D(e);
|
|
333
332
|
}
|
|
334
333
|
function oe(t) {
|
|
335
334
|
const e = u?.current;
|
|
336
335
|
e != null && (e.selectionStart ? (e.focus(), e.selectionEnd = t) : e.focus());
|
|
337
336
|
}
|
|
338
|
-
function
|
|
339
|
-
const e =
|
|
337
|
+
function He(t) {
|
|
338
|
+
const e = $n[t];
|
|
340
339
|
if (e && u.current) {
|
|
341
340
|
const r = u.current.selectionStart, l = u.current.selectionEnd;
|
|
342
341
|
if (r === l) {
|
|
@@ -348,7 +347,7 @@ const Fn = Ve.forwardRef(
|
|
|
348
347
|
}
|
|
349
348
|
}
|
|
350
349
|
}
|
|
351
|
-
function
|
|
350
|
+
function Ie(t) {
|
|
352
351
|
const { text: e } = ft(t);
|
|
353
352
|
D(e);
|
|
354
353
|
}
|
|
@@ -405,7 +404,7 @@ const Fn = Ve.forwardRef(
|
|
|
405
404
|
if (Z.current === null) {
|
|
406
405
|
Z.current = t, t && (d.current = setTimeout(() => {
|
|
407
406
|
ht.current();
|
|
408
|
-
},
|
|
407
|
+
}, he));
|
|
409
408
|
return;
|
|
410
409
|
}
|
|
411
410
|
if (!t) {
|
|
@@ -415,7 +414,7 @@ const Fn = Ve.forwardRef(
|
|
|
415
414
|
const e = !Z.current && t;
|
|
416
415
|
Z.current = !0, e && ht.current(), d.current && clearTimeout(d.current), d.current = setTimeout(() => {
|
|
417
416
|
ht.current();
|
|
418
|
-
},
|
|
417
|
+
}, he);
|
|
419
418
|
}, [
|
|
420
419
|
o,
|
|
421
420
|
c,
|
|
@@ -425,13 +424,13 @@ const Fn = Ve.forwardRef(
|
|
|
425
424
|
]), _(() => () => {
|
|
426
425
|
d.current && clearTimeout(d.current), Q.current && clearTimeout(Q.current), q.current && clearTimeout(q.current), C.current && clearTimeout(C.current);
|
|
427
426
|
}, []);
|
|
428
|
-
const b = m[k] || "", G = L(() => !s || !b ? null : `${s}-${k}-${b}`, [b, s, k]), se = !!(G && wt[G]),
|
|
427
|
+
const b = m[k] || "", G = L(() => !s || !b ? null : `${s}-${k}-${b}`, [b, s, k]), se = !!(G && wt[G]), Le = L(
|
|
429
428
|
() => B.getHTML(R || ""),
|
|
430
429
|
[R]
|
|
431
|
-
),
|
|
430
|
+
), Pe = L(
|
|
432
431
|
() => B.getHTML(b),
|
|
433
432
|
[b]
|
|
434
|
-
), _t = m.length <
|
|
433
|
+
), _t = m.length < fe, I = !!R && m.length > 0, $e = m.length <= 1 || k <= 0, De = m.length <= 1 || k >= m.length - 1;
|
|
435
434
|
_(() => {
|
|
436
435
|
if (!I) return;
|
|
437
436
|
const t = Vt.current;
|
|
@@ -449,7 +448,7 @@ const Fn = Ve.forwardRef(
|
|
|
449
448
|
const rt = gt[t], W = t === p.REPHRASE && $ === "utility" && x === mt.REPHRASE ? {
|
|
450
449
|
...rt,
|
|
451
450
|
label: "Rephrase",
|
|
452
|
-
basePrompt:
|
|
451
|
+
basePrompt: bn
|
|
453
452
|
} : rt, M = l || at[t], ae = W.tones?.find(
|
|
454
453
|
(X) => X.id === M
|
|
455
454
|
), At = r !== void 0 ? r : y, ue = Wt?.({
|
|
@@ -461,7 +460,7 @@ const Fn = Ve.forwardRef(
|
|
|
461
460
|
toneId: M,
|
|
462
461
|
toneLabel: ae?.label,
|
|
463
462
|
instructionText: At || void 0
|
|
464
|
-
}) ||
|
|
463
|
+
}) || cn({
|
|
465
464
|
config: W,
|
|
466
465
|
currentText: o,
|
|
467
466
|
selectedToneId: M,
|
|
@@ -482,7 +481,7 @@ const Fn = Ve.forwardRef(
|
|
|
482
481
|
toneLabel: ae?.label,
|
|
483
482
|
instructionText: At || void 0,
|
|
484
483
|
prompt: ue
|
|
485
|
-
}) : await
|
|
484
|
+
}) : await sn({
|
|
486
485
|
apiAdapter: St,
|
|
487
486
|
requestExecutor: bt,
|
|
488
487
|
baseUrl: xt,
|
|
@@ -499,8 +498,8 @@ const Fn = Ve.forwardRef(
|
|
|
499
498
|
Zt(o), qt(t), vt([yt]), J(0);
|
|
500
499
|
return;
|
|
501
500
|
}
|
|
502
|
-
vt((
|
|
503
|
-
const de = [...
|
|
501
|
+
vt((Oe) => {
|
|
502
|
+
const de = [...Oe, yt].slice(0, fe);
|
|
504
503
|
return J(de.length - 1), de;
|
|
505
504
|
});
|
|
506
505
|
} catch {
|
|
@@ -533,7 +532,7 @@ const Fn = Ve.forwardRef(
|
|
|
533
532
|
st,
|
|
534
533
|
Wt
|
|
535
534
|
]
|
|
536
|
-
),
|
|
535
|
+
), Me = E(() => {
|
|
537
536
|
if (!b || !R || !s)
|
|
538
537
|
return;
|
|
539
538
|
H(b), D(b), T("ai_suggestion_accepted", {
|
|
@@ -545,7 +544,7 @@ const Fn = Ve.forwardRef(
|
|
|
545
544
|
actionType: s,
|
|
546
545
|
editedEventEmitted: !1
|
|
547
546
|
};
|
|
548
|
-
const t = Tt.current, e =
|
|
547
|
+
const t = Tt.current, e = on({
|
|
549
548
|
baselineText: R,
|
|
550
549
|
acceptedText: b,
|
|
551
550
|
initialAiPrefillPhase: t
|
|
@@ -564,7 +563,7 @@ const Fn = Ve.forwardRef(
|
|
|
564
563
|
v,
|
|
565
564
|
ct,
|
|
566
565
|
et
|
|
567
|
-
]),
|
|
566
|
+
]), Fe = E(() => {
|
|
568
567
|
s && (T("ai_suggestion_discarded", {
|
|
569
568
|
action_type: s,
|
|
570
569
|
template_id: v
|
|
@@ -589,7 +588,7 @@ const Fn = Ve.forwardRef(
|
|
|
589
588
|
k,
|
|
590
589
|
v
|
|
591
590
|
]
|
|
592
|
-
),
|
|
591
|
+
), Be = L(() => Bt ? [] : Ft.map((t) => {
|
|
593
592
|
const e = gt[t], r = at[t];
|
|
594
593
|
return {
|
|
595
594
|
type: t,
|
|
@@ -614,8 +613,8 @@ const Fn = Ve.forwardRef(
|
|
|
614
613
|
o,
|
|
615
614
|
tt
|
|
616
615
|
]);
|
|
617
|
-
return
|
|
618
|
-
|
|
616
|
+
return Ve(
|
|
617
|
+
we,
|
|
619
618
|
() => ({
|
|
620
619
|
addTextOrWrap: Ct,
|
|
621
620
|
addText: ft,
|
|
@@ -631,23 +630,23 @@ const Fn = Ve.forwardRef(
|
|
|
631
630
|
if (!U || !z) return;
|
|
632
631
|
const t = o.length > U ? Ht : P ?? "";
|
|
633
632
|
Kt.current !== t && (Kt.current = t, z(t));
|
|
634
|
-
}, [o, P, U, z]), /* @__PURE__ */ h(
|
|
635
|
-
/* @__PURE__ */ h(
|
|
636
|
-
/* @__PURE__ */ n(
|
|
637
|
-
/* @__PURE__ */ h(
|
|
638
|
-
P && P !== Ht ? /* @__PURE__ */ h(
|
|
633
|
+
}, [o, P, U, z]), /* @__PURE__ */ h(ln, { children: [
|
|
634
|
+
/* @__PURE__ */ h(an, { children: [
|
|
635
|
+
/* @__PURE__ */ n(un, { children: jt ? /* @__PURE__ */ n(tn, { "data-test": "body-text-for-edit-template", children: jt }) : null }),
|
|
636
|
+
/* @__PURE__ */ h(dn, { children: [
|
|
637
|
+
P && P !== Ht ? /* @__PURE__ */ h(Ne, { children: [
|
|
639
638
|
/* @__PURE__ */ n(
|
|
640
|
-
|
|
639
|
+
Xe,
|
|
641
640
|
{
|
|
642
641
|
width: 16,
|
|
643
642
|
height: 16,
|
|
644
643
|
color: i.content.negative
|
|
645
644
|
}
|
|
646
645
|
),
|
|
647
|
-
/* @__PURE__ */ n(
|
|
646
|
+
/* @__PURE__ */ n(ge, { color: i.content.negative, children: P })
|
|
648
647
|
] }) : null,
|
|
649
648
|
U ? /* @__PURE__ */ h(
|
|
650
|
-
|
|
649
|
+
ge,
|
|
651
650
|
{
|
|
652
651
|
style: {
|
|
653
652
|
color: P === Ht || o.length > U ? i.content.negative : i.content.secondary
|
|
@@ -661,36 +660,36 @@ const Fn = Ve.forwardRef(
|
|
|
661
660
|
) : null
|
|
662
661
|
] })
|
|
663
662
|
] }),
|
|
664
|
-
/* @__PURE__ */ h(
|
|
665
|
-
I ? /* @__PURE__ */ h(
|
|
663
|
+
/* @__PURE__ */ h(gn, { isError: !!P, children: [
|
|
664
|
+
I ? /* @__PURE__ */ h(Sn, { ref: Vt, children: [
|
|
666
665
|
/* @__PURE__ */ n(
|
|
667
|
-
|
|
666
|
+
Rn,
|
|
668
667
|
{
|
|
669
|
-
dangerouslySetInnerHTML: { __html:
|
|
668
|
+
dangerouslySetInnerHTML: { __html: Le }
|
|
670
669
|
}
|
|
671
670
|
),
|
|
672
|
-
c ? /* @__PURE__ */ n(
|
|
671
|
+
c ? /* @__PURE__ */ n(me, { "aria-busy": "true", children: /* @__PURE__ */ h(En, { children: [
|
|
673
672
|
/* @__PURE__ */ n(F, { width: "96%" }),
|
|
674
673
|
/* @__PURE__ */ n(F, { width: "84%" }),
|
|
675
674
|
/* @__PURE__ */ n(F, { width: "68%" })
|
|
676
675
|
] }) }) : /* @__PURE__ */ n(
|
|
677
|
-
|
|
676
|
+
me,
|
|
678
677
|
{
|
|
679
678
|
dangerouslySetInnerHTML: {
|
|
680
|
-
__html:
|
|
679
|
+
__html: Pe
|
|
681
680
|
}
|
|
682
681
|
}
|
|
683
682
|
),
|
|
684
|
-
/* @__PURE__ */ h(
|
|
683
|
+
/* @__PURE__ */ h(vn, { children: [
|
|
685
684
|
/* @__PURE__ */ n(
|
|
686
685
|
O,
|
|
687
686
|
{
|
|
688
687
|
"aria-label": "Previous suggestion",
|
|
689
688
|
type: "button",
|
|
690
|
-
disabled:
|
|
689
|
+
disabled: $e,
|
|
691
690
|
onClick: () => J((t) => Math.max(0, t - 1)),
|
|
692
691
|
children: /* @__PURE__ */ n(
|
|
693
|
-
|
|
692
|
+
ze,
|
|
694
693
|
{
|
|
695
694
|
width: 14,
|
|
696
695
|
height: 14,
|
|
@@ -699,7 +698,7 @@ const Fn = Ve.forwardRef(
|
|
|
699
698
|
)
|
|
700
699
|
}
|
|
701
700
|
),
|
|
702
|
-
/* @__PURE__ */ h(
|
|
701
|
+
/* @__PURE__ */ h(Tn, { children: [
|
|
703
702
|
k + 1,
|
|
704
703
|
"/",
|
|
705
704
|
m.length
|
|
@@ -709,12 +708,12 @@ const Fn = Ve.forwardRef(
|
|
|
709
708
|
{
|
|
710
709
|
"aria-label": "Next suggestion",
|
|
711
710
|
type: "button",
|
|
712
|
-
disabled:
|
|
711
|
+
disabled: De,
|
|
713
712
|
onClick: () => J(
|
|
714
713
|
(t) => Math.min(m.length - 1, t + 1)
|
|
715
714
|
),
|
|
716
715
|
children: /* @__PURE__ */ n(
|
|
717
|
-
|
|
716
|
+
Ge,
|
|
718
717
|
{
|
|
719
718
|
width: 14,
|
|
720
719
|
height: 14,
|
|
@@ -734,7 +733,7 @@ const Fn = Ve.forwardRef(
|
|
|
734
733
|
/* LIKE */
|
|
735
734
|
),
|
|
736
735
|
children: /* @__PURE__ */ n(
|
|
737
|
-
|
|
736
|
+
Qe,
|
|
738
737
|
{
|
|
739
738
|
width: 14,
|
|
740
739
|
height: 14,
|
|
@@ -754,7 +753,7 @@ const Fn = Ve.forwardRef(
|
|
|
754
753
|
/* DISLIKE */
|
|
755
754
|
),
|
|
756
755
|
children: /* @__PURE__ */ n(
|
|
757
|
-
|
|
756
|
+
Je,
|
|
758
757
|
{
|
|
759
758
|
width: 14,
|
|
760
759
|
height: 14,
|
|
@@ -769,7 +768,7 @@ const Fn = Ve.forwardRef(
|
|
|
769
768
|
body: c ? "Regenerating…" : "Regenerate",
|
|
770
769
|
placement: "top",
|
|
771
770
|
children: /* @__PURE__ */ n(
|
|
772
|
-
|
|
771
|
+
wn,
|
|
773
772
|
{
|
|
774
773
|
"aria-label": "Regenerate suggestion",
|
|
775
774
|
"aria-busy": c,
|
|
@@ -778,7 +777,7 @@ const Fn = Ve.forwardRef(
|
|
|
778
777
|
onClick: () => {
|
|
779
778
|
s && nt(s, !0);
|
|
780
779
|
},
|
|
781
|
-
children: c ? /* @__PURE__ */ n(
|
|
780
|
+
children: c ? /* @__PURE__ */ n(Cn, { "aria-hidden": !0 }) : /* @__PURE__ */ n(Ye, { width: 14, height: 14 })
|
|
782
781
|
}
|
|
783
782
|
)
|
|
784
783
|
}
|
|
@@ -788,9 +787,9 @@ const Fn = Ve.forwardRef(
|
|
|
788
787
|
{
|
|
789
788
|
"aria-label": "Discard suggestion",
|
|
790
789
|
type: "button",
|
|
791
|
-
onClick:
|
|
790
|
+
onClick: Fe,
|
|
792
791
|
children: /* @__PURE__ */ n(
|
|
793
|
-
|
|
792
|
+
je,
|
|
794
793
|
{
|
|
795
794
|
width: 14,
|
|
796
795
|
height: 14,
|
|
@@ -804,9 +803,9 @@ const Fn = Ve.forwardRef(
|
|
|
804
803
|
{
|
|
805
804
|
"aria-label": "Accept suggestion",
|
|
806
805
|
type: "button",
|
|
807
|
-
onClick:
|
|
806
|
+
onClick: Me,
|
|
808
807
|
children: /* @__PURE__ */ n(
|
|
809
|
-
|
|
808
|
+
Ue,
|
|
810
809
|
{
|
|
811
810
|
width: 14,
|
|
812
811
|
height: 14,
|
|
@@ -816,24 +815,24 @@ const Fn = Ve.forwardRef(
|
|
|
816
815
|
}
|
|
817
816
|
) })
|
|
818
817
|
] })
|
|
819
|
-
] }) : c ? /* @__PURE__ */ h(
|
|
818
|
+
] }) : c ? /* @__PURE__ */ h(xn, { children: [
|
|
820
819
|
/* @__PURE__ */ n(F, { width: "96%" }),
|
|
821
820
|
/* @__PURE__ */ n(F, { width: "92%" }),
|
|
822
821
|
/* @__PURE__ */ n(F, { width: "88%" }),
|
|
823
822
|
/* @__PURE__ */ n(F, { width: "54%" })
|
|
824
823
|
] }) : /* @__PURE__ */ n(
|
|
825
|
-
|
|
824
|
+
hn,
|
|
826
825
|
{
|
|
827
826
|
ref: u,
|
|
828
|
-
...
|
|
827
|
+
...Te,
|
|
829
828
|
value: o,
|
|
830
|
-
onChange:
|
|
829
|
+
onChange: ke,
|
|
831
830
|
onBlur: (t) => {
|
|
832
|
-
C.current && (clearTimeout(C.current), C.current = null), re(t.target.value),
|
|
831
|
+
C.current && (clearTimeout(C.current), C.current = null), re(t.target.value), ve?.(t);
|
|
833
832
|
},
|
|
834
833
|
onPaste: (t) => {
|
|
835
834
|
const e = t.clipboardData.getData("text");
|
|
836
|
-
if (e.length >
|
|
835
|
+
if (e.length > pe) {
|
|
837
836
|
t.preventDefault();
|
|
838
837
|
const r = u.current, l = r?.selectionStart ?? 0, x = r?.selectionEnd ?? l, j = r?.value ?? o, rt = j.slice(0, l) + e + j.slice(x);
|
|
839
838
|
H(rt), D(rt);
|
|
@@ -848,13 +847,13 @@ const Fn = Ve.forwardRef(
|
|
|
848
847
|
});
|
|
849
848
|
}
|
|
850
849
|
},
|
|
851
|
-
rows:
|
|
850
|
+
rows: Se
|
|
852
851
|
}
|
|
853
852
|
),
|
|
854
|
-
Qt ? /* @__PURE__ */ h(
|
|
855
|
-
/* @__PURE__ */ h(
|
|
853
|
+
Qt ? /* @__PURE__ */ h(_n, { children: [
|
|
854
|
+
/* @__PURE__ */ h(An, { children: [
|
|
856
855
|
/* @__PURE__ */ n(
|
|
857
|
-
|
|
856
|
+
We,
|
|
858
857
|
{
|
|
859
858
|
width: 18,
|
|
860
859
|
height: 18,
|
|
@@ -862,16 +861,16 @@ const Fn = Ve.forwardRef(
|
|
|
862
861
|
}
|
|
863
862
|
),
|
|
864
863
|
/* @__PURE__ */ n(
|
|
865
|
-
|
|
864
|
+
yn,
|
|
866
865
|
{
|
|
867
866
|
value: y,
|
|
868
867
|
placeholder: "Add specific instructions to refine your message",
|
|
869
|
-
onChange: (t) => lt(
|
|
868
|
+
onChange: (t) => lt(t.target.value)
|
|
870
869
|
}
|
|
871
870
|
),
|
|
872
|
-
/* @__PURE__ */ h(
|
|
871
|
+
/* @__PURE__ */ h(kn, { children: [
|
|
873
872
|
/* @__PURE__ */ n(
|
|
874
|
-
|
|
873
|
+
Hn,
|
|
875
874
|
{
|
|
876
875
|
type: "button",
|
|
877
876
|
onClick: () => {
|
|
@@ -881,7 +880,7 @@ const Fn = Ve.forwardRef(
|
|
|
881
880
|
}
|
|
882
881
|
),
|
|
883
882
|
/* @__PURE__ */ n(
|
|
884
|
-
|
|
883
|
+
In,
|
|
885
884
|
{
|
|
886
885
|
type: "button",
|
|
887
886
|
onClick: () => {
|
|
@@ -889,7 +888,7 @@ const Fn = Ve.forwardRef(
|
|
|
889
888
|
t && T("ai_instruction_used", {
|
|
890
889
|
action_type: p.REPHRASE,
|
|
891
890
|
template_id: v,
|
|
892
|
-
instruction_text:
|
|
891
|
+
instruction_text: ye(t)
|
|
893
892
|
}), Et(!1), lt(""), nt(
|
|
894
893
|
p.REPHRASE,
|
|
895
894
|
!1,
|
|
@@ -901,8 +900,8 @@ const Fn = Ve.forwardRef(
|
|
|
901
900
|
)
|
|
902
901
|
] })
|
|
903
902
|
] }),
|
|
904
|
-
y.trim().length > 0 && ee.length > 0 ? /* @__PURE__ */ n(
|
|
905
|
-
|
|
903
|
+
y.trim().length > 0 && ee.length > 0 ? /* @__PURE__ */ n(Ln, { children: ee.map((t) => /* @__PURE__ */ n(
|
|
904
|
+
Pn,
|
|
906
905
|
{
|
|
907
906
|
type: "button",
|
|
908
907
|
selected: y === t,
|
|
@@ -912,20 +911,20 @@ const Fn = Ve.forwardRef(
|
|
|
912
911
|
t
|
|
913
912
|
)) }) : null
|
|
914
913
|
] }) : /* @__PURE__ */ n(
|
|
915
|
-
|
|
914
|
+
fn,
|
|
916
915
|
{
|
|
917
|
-
actions:
|
|
916
|
+
actions: Re,
|
|
918
917
|
ref: u,
|
|
919
|
-
onActionSelect:
|
|
920
|
-
RightComponent:
|
|
918
|
+
onActionSelect: He,
|
|
919
|
+
RightComponent: xe,
|
|
921
920
|
rightActionsDisabled: I || c,
|
|
922
|
-
onEmojiClick:
|
|
923
|
-
aiActions:
|
|
921
|
+
onEmojiClick: Ie,
|
|
922
|
+
aiActions: Be,
|
|
924
923
|
disableAllActions: I || c,
|
|
925
924
|
instructionActive: Qt,
|
|
926
925
|
onAIInstructionsClick: () => Et(!0),
|
|
927
926
|
onAIToneChange: (t, e) => {
|
|
928
|
-
|
|
927
|
+
_e((r) => ({ ...r, [t]: e })), Ee?.(t, e), t === p.REPHRASE && nt(
|
|
929
928
|
t,
|
|
930
929
|
!1,
|
|
931
930
|
void 0,
|
|
@@ -962,11 +961,11 @@ const Fn = Ve.forwardRef(
|
|
|
962
961
|
] });
|
|
963
962
|
}
|
|
964
963
|
);
|
|
965
|
-
|
|
964
|
+
Mn.displayName = "WhatsAppTextEditor";
|
|
966
965
|
export {
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
966
|
+
sr as AI_TAG_CHANGE_RATIO_THRESHOLD,
|
|
967
|
+
Mn as WhatsAppTextEditor,
|
|
968
|
+
on as computeAiTagOnAccept,
|
|
969
|
+
lr as levenshteinDistance
|
|
971
970
|
};
|
|
972
971
|
//# sourceMappingURL=WhatsAppTextEditor.js.map
|