@resulticks/trustsignal-wa-hsm 0.7.0 → 0.9.0
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.
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { jsx as e, jsxs as r, Fragment as ce } from "react/jsx-runtime";
|
|
2
|
-
import X, { forwardRef as
|
|
3
|
-
const
|
|
2
|
+
import X, { forwardRef as Be, createElement as Ne, useRef as fe, useEffect as le, useState as B, useMemo as Ve, useCallback as Ce, createContext as Oe } from "react";
|
|
3
|
+
const Pe = async (a, s = {}) => {
|
|
4
4
|
try {
|
|
5
|
-
return await
|
|
5
|
+
return await ze(a.apiKey);
|
|
6
6
|
} catch (n) {
|
|
7
7
|
return console.error("API Error:", n), {
|
|
8
8
|
status: "error",
|
|
9
9
|
message: n instanceof Error ? n.message : "Failed to fetch templates"
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
-
},
|
|
12
|
+
}, ze = async (a) => {
|
|
13
13
|
const s = await fetch(
|
|
14
14
|
"https://wpapi.trustsignal.io/api/v1/template?page=1&limit=100",
|
|
15
15
|
{
|
|
@@ -53,7 +53,7 @@ const Oe = async (a, s = {}) => {
|
|
|
53
53
|
* This source code is licensed under the ISC license.
|
|
54
54
|
* See the LICENSE file in the root directory of this source tree.
|
|
55
55
|
*/
|
|
56
|
-
var
|
|
56
|
+
var De = {
|
|
57
57
|
xmlns: "http://www.w3.org/2000/svg",
|
|
58
58
|
width: 24,
|
|
59
59
|
height: 24,
|
|
@@ -70,30 +70,30 @@ var ze = {
|
|
|
70
70
|
* This source code is licensed under the ISC license.
|
|
71
71
|
* See the LICENSE file in the root directory of this source tree.
|
|
72
72
|
*/
|
|
73
|
-
const
|
|
74
|
-
const n =
|
|
73
|
+
const _e = (a) => a.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase().trim(), H = (a, s) => {
|
|
74
|
+
const n = Be(
|
|
75
75
|
({
|
|
76
76
|
color: i = "currentColor",
|
|
77
77
|
size: c = 24,
|
|
78
|
-
strokeWidth:
|
|
78
|
+
strokeWidth: h = 2,
|
|
79
79
|
absoluteStrokeWidth: l,
|
|
80
|
-
className:
|
|
80
|
+
className: N = "",
|
|
81
81
|
children: g,
|
|
82
|
-
...
|
|
83
|
-
}, k) =>
|
|
82
|
+
...o
|
|
83
|
+
}, k) => Ne(
|
|
84
84
|
"svg",
|
|
85
85
|
{
|
|
86
86
|
ref: k,
|
|
87
|
-
...
|
|
87
|
+
...De,
|
|
88
88
|
width: c,
|
|
89
89
|
height: c,
|
|
90
90
|
stroke: i,
|
|
91
|
-
strokeWidth: l ? Number(
|
|
92
|
-
className: ["lucide", `lucide-${
|
|
93
|
-
...
|
|
91
|
+
strokeWidth: l ? Number(h) * 24 / Number(c) : h,
|
|
92
|
+
className: ["lucide", `lucide-${_e(a)}`, N].join(" "),
|
|
93
|
+
...o
|
|
94
94
|
},
|
|
95
95
|
[
|
|
96
|
-
...s.map(([
|
|
96
|
+
...s.map(([A, d]) => Ne(A, d)),
|
|
97
97
|
...Array.isArray(g) ? g : [g]
|
|
98
98
|
]
|
|
99
99
|
)
|
|
@@ -106,7 +106,7 @@ const De = (a) => a.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase().trim(),
|
|
|
106
106
|
* This source code is licensed under the ISC license.
|
|
107
107
|
* See the LICENSE file in the root directory of this source tree.
|
|
108
108
|
*/
|
|
109
|
-
const
|
|
109
|
+
const he = H("AlertCircle", [
|
|
110
110
|
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
111
111
|
["line", { x1: "12", x2: "12", y1: "8", y2: "12", key: "1pkeuh" }],
|
|
112
112
|
["line", { x1: "12", x2: "12.01", y1: "16", y2: "16", key: "4dfq90" }]
|
|
@@ -117,7 +117,7 @@ const fe = q("AlertCircle", [
|
|
|
117
117
|
* This source code is licensed under the ISC license.
|
|
118
118
|
* See the LICENSE file in the root directory of this source tree.
|
|
119
119
|
*/
|
|
120
|
-
const
|
|
120
|
+
const Fe = H("ArrowRight", [
|
|
121
121
|
["path", { d: "M5 12h14", key: "1ays0h" }],
|
|
122
122
|
["path", { d: "m12 5 7 7-7 7", key: "xquz4c" }]
|
|
123
123
|
]);
|
|
@@ -127,7 +127,7 @@ const _e = q("ArrowRight", [
|
|
|
127
127
|
* This source code is licensed under the ISC license.
|
|
128
128
|
* See the LICENSE file in the root directory of this source tree.
|
|
129
129
|
*/
|
|
130
|
-
const
|
|
130
|
+
const qe = H("ChevronLeft", [
|
|
131
131
|
["path", { d: "m15 18-6-6 6-6", key: "1wnfg3" }]
|
|
132
132
|
]);
|
|
133
133
|
/**
|
|
@@ -136,7 +136,7 @@ const Fe = q("ChevronLeft", [
|
|
|
136
136
|
* This source code is licensed under the ISC license.
|
|
137
137
|
* See the LICENSE file in the root directory of this source tree.
|
|
138
138
|
*/
|
|
139
|
-
const
|
|
139
|
+
const He = H("ExternalLink", [
|
|
140
140
|
["path", { d: "M15 3h6v6", key: "1q9fwt" }],
|
|
141
141
|
["path", { d: "M10 14 21 3", key: "gplh6r" }],
|
|
142
142
|
["path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6", key: "a6xqqp" }]
|
|
@@ -147,7 +147,7 @@ const qe = q("ExternalLink", [
|
|
|
147
147
|
* This source code is licensed under the ISC license.
|
|
148
148
|
* See the LICENSE file in the root directory of this source tree.
|
|
149
149
|
*/
|
|
150
|
-
const
|
|
150
|
+
const $e = H("FileText", [
|
|
151
151
|
["path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z", key: "1rqfz7" }],
|
|
152
152
|
["path", { d: "M14 2v4a2 2 0 0 0 2 2h4", key: "tnqrlb" }],
|
|
153
153
|
["path", { d: "M10 9H8", key: "b1mrlr" }],
|
|
@@ -160,7 +160,7 @@ const He = q("FileText", [
|
|
|
160
160
|
* This source code is licensed under the ISC license.
|
|
161
161
|
* See the LICENSE file in the root directory of this source tree.
|
|
162
162
|
*/
|
|
163
|
-
const
|
|
163
|
+
const Ge = H("FileVideo", [
|
|
164
164
|
["path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z", key: "1rqfz7" }],
|
|
165
165
|
["path", { d: "M14 2v4a2 2 0 0 0 2 2h4", key: "tnqrlb" }],
|
|
166
166
|
["path", { d: "m10 11 5 3-5 3v-6Z", key: "7ntvm4" }]
|
|
@@ -171,7 +171,7 @@ const $e = q("FileVideo", [
|
|
|
171
171
|
* This source code is licensed under the ISC license.
|
|
172
172
|
* See the LICENSE file in the root directory of this source tree.
|
|
173
173
|
*/
|
|
174
|
-
const
|
|
174
|
+
const We = H("Link", [
|
|
175
175
|
["path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71", key: "1cjeqo" }],
|
|
176
176
|
["path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71", key: "19qd67" }]
|
|
177
177
|
]);
|
|
@@ -181,7 +181,7 @@ const Ge = q("Link", [
|
|
|
181
181
|
* This source code is licensed under the ISC license.
|
|
182
182
|
* See the LICENSE file in the root directory of this source tree.
|
|
183
183
|
*/
|
|
184
|
-
const me =
|
|
184
|
+
const me = H("MessageCircle", [
|
|
185
185
|
["path", { d: "M7.9 20A9 9 0 1 0 4 16.1L2 22Z", key: "vv11sd" }]
|
|
186
186
|
]);
|
|
187
187
|
/**
|
|
@@ -190,7 +190,7 @@ const me = q("MessageCircle", [
|
|
|
190
190
|
* This source code is licensed under the ISC license.
|
|
191
191
|
* See the LICENSE file in the root directory of this source tree.
|
|
192
192
|
*/
|
|
193
|
-
const
|
|
193
|
+
const Ke = H("Pencil", [
|
|
194
194
|
["path", { d: "M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z", key: "5qss01" }],
|
|
195
195
|
["path", { d: "m15 5 4 4", key: "1mk7zo" }]
|
|
196
196
|
]);
|
|
@@ -200,7 +200,7 @@ const We = q("Pencil", [
|
|
|
200
200
|
* This source code is licensed under the ISC license.
|
|
201
201
|
* See the LICENSE file in the root directory of this source tree.
|
|
202
202
|
*/
|
|
203
|
-
const
|
|
203
|
+
const Ae = H("Phone", [
|
|
204
204
|
[
|
|
205
205
|
"path",
|
|
206
206
|
{
|
|
@@ -215,7 +215,7 @@ const Ve = q("Phone", [
|
|
|
215
215
|
* This source code is licensed under the ISC license.
|
|
216
216
|
* See the LICENSE file in the root directory of this source tree.
|
|
217
217
|
*/
|
|
218
|
-
const
|
|
218
|
+
const ue = H("Plus", [
|
|
219
219
|
["path", { d: "M5 12h14", key: "1ays0h" }],
|
|
220
220
|
["path", { d: "M12 5v14", key: "s699le" }]
|
|
221
221
|
]);
|
|
@@ -225,7 +225,7 @@ const he = q("Plus", [
|
|
|
225
225
|
* This source code is licensed under the ISC license.
|
|
226
226
|
* See the LICENSE file in the root directory of this source tree.
|
|
227
227
|
*/
|
|
228
|
-
const
|
|
228
|
+
const Je = H("Reply", [
|
|
229
229
|
["polyline", { points: "9 17 4 12 9 7", key: "hvgpf2" }],
|
|
230
230
|
["path", { d: "M20 18v-2a4 4 0 0 0-4-4H4", key: "5vmcpk" }]
|
|
231
231
|
]);
|
|
@@ -235,7 +235,7 @@ const Ke = q("Reply", [
|
|
|
235
235
|
* This source code is licensed under the ISC license.
|
|
236
236
|
* See the LICENSE file in the root directory of this source tree.
|
|
237
237
|
*/
|
|
238
|
-
const
|
|
238
|
+
const be = H("Smile", [
|
|
239
239
|
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
240
240
|
["path", { d: "M8 14s1.5 2 4 2 4-2 4-2", key: "1y1vjs" }],
|
|
241
241
|
["line", { x1: "9", x2: "9.01", y1: "9", y2: "9", key: "yxxnd0" }],
|
|
@@ -247,7 +247,7 @@ const ue = q("Smile", [
|
|
|
247
247
|
* This source code is licensed under the ISC license.
|
|
248
248
|
* See the LICENSE file in the root directory of this source tree.
|
|
249
249
|
*/
|
|
250
|
-
const
|
|
250
|
+
const Xe = H("Trash2", [
|
|
251
251
|
["path", { d: "M3 6h18", key: "d0wm0j" }],
|
|
252
252
|
["path", { d: "M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6", key: "4alrt4" }],
|
|
253
253
|
["path", { d: "M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2", key: "v07s0e" }],
|
|
@@ -260,7 +260,7 @@ const Je = q("Trash2", [
|
|
|
260
260
|
* This source code is licensed under the ISC license.
|
|
261
261
|
* See the LICENSE file in the root directory of this source tree.
|
|
262
262
|
*/
|
|
263
|
-
const
|
|
263
|
+
const Ye = H("Upload", [
|
|
264
264
|
["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4", key: "ih7n3h" }],
|
|
265
265
|
["polyline", { points: "17 8 12 3 7 8", key: "t8dd8p" }],
|
|
266
266
|
["line", { x1: "12", x2: "12", y1: "3", y2: "15", key: "widbto" }]
|
|
@@ -271,7 +271,7 @@ const Xe = q("Upload", [
|
|
|
271
271
|
* This source code is licensed under the ISC license.
|
|
272
272
|
* See the LICENSE file in the root directory of this source tree.
|
|
273
273
|
*/
|
|
274
|
-
const
|
|
274
|
+
const Qe = H("Workflow", [
|
|
275
275
|
["rect", { width: "8", height: "8", x: "3", y: "3", rx: "2", key: "by2w9f" }],
|
|
276
276
|
["path", { d: "M7 11v4a2 2 0 0 0 2 2h4", key: "xkn7yn" }],
|
|
277
277
|
["rect", { width: "8", height: "8", x: "13", y: "13", rx: "2", key: "1cgmvn" }]
|
|
@@ -282,18 +282,18 @@ const Ye = q("Workflow", [
|
|
|
282
282
|
* This source code is licensed under the ISC license.
|
|
283
283
|
* See the LICENSE file in the root directory of this source tree.
|
|
284
284
|
*/
|
|
285
|
-
const
|
|
285
|
+
const se = H("X", [
|
|
286
286
|
["path", { d: "M18 6 6 18", key: "1bl5f8" }],
|
|
287
287
|
["path", { d: "m6 6 12 12", key: "d8bk6v" }]
|
|
288
288
|
]);
|
|
289
289
|
function te({ isOpen: a, onClose: s, title: n, children: i }) {
|
|
290
|
-
const c =
|
|
290
|
+
const c = fe(null);
|
|
291
291
|
return le(() => {
|
|
292
|
-
const
|
|
292
|
+
const h = (l) => {
|
|
293
293
|
c.current && !c.current.contains(l.target) && s();
|
|
294
294
|
};
|
|
295
|
-
return a && document.addEventListener("mousedown",
|
|
296
|
-
document.removeEventListener("mousedown",
|
|
295
|
+
return a && document.addEventListener("mousedown", h), () => {
|
|
296
|
+
document.removeEventListener("mousedown", h);
|
|
297
297
|
};
|
|
298
298
|
}, [a, s]), a ? /* @__PURE__ */ e("div", { className: "rsp-fixed rsp-inset-0 rsp-bg-black rsp-bg-opacity-50 rsp-flex rsp-items-center rsp-justify-center rsp-p-4 rsp-z-50", children: /* @__PURE__ */ r("div", { ref: c, className: "rsp-bg-white rsp-rounded-lg rsp-shadow-xl rsp-w-full rsp-max-w-[600px] rsp-animate-modal-appear", style: { backgroundColor: "#f5f7fc" }, children: [
|
|
299
299
|
/* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-justify-between rsp-px-6 rsp-py-4 rsp-border-b", children: [
|
|
@@ -303,75 +303,81 @@ function te({ isOpen: a, onClose: s, title: n, children: i }) {
|
|
|
303
303
|
{
|
|
304
304
|
onClick: s,
|
|
305
305
|
className: "rsp-p-1 hover:rsp-bg-gray-100 rsp-rounded-full",
|
|
306
|
-
children: /* @__PURE__ */ e(
|
|
306
|
+
children: /* @__PURE__ */ e(se, { className: "rsp-w-5 rsp-h-5 rsp-text-gray-500" })
|
|
307
307
|
}
|
|
308
308
|
)
|
|
309
309
|
] }),
|
|
310
310
|
/* @__PURE__ */ e("div", { className: "rsp-px-6 rsp-py-4 rsp-overflow-y-auto rsp-max-h-[70vh] rsp-break-words rsp-whitespace-pre-wrap", children: i })
|
|
311
311
|
] }) }) : null;
|
|
312
312
|
}
|
|
313
|
-
|
|
314
|
-
|
|
313
|
+
const Ee = (a) => a ? /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(a) : !1;
|
|
314
|
+
function Sa({ onCreateTemplate: a, onEditTemplate: s }) {
|
|
315
|
+
const [n, i] = B([]), [c, h] = B(() => {
|
|
315
316
|
const u = localStorage.getItem("account");
|
|
316
317
|
return u ? JSON.parse(u) : {
|
|
317
318
|
apiKey: ""
|
|
318
319
|
};
|
|
319
|
-
}), [
|
|
320
|
+
}), [l, N] = B(() => {
|
|
321
|
+
const u = localStorage.getItem("account"), U = u ? JSON.parse(u).apiKey : "";
|
|
322
|
+
return Ee(U);
|
|
323
|
+
}), [g, o] = B(null), [k, A] = B(null), [d, w] = B({ isOpen: !1 }), M = fe(null), [b, y] = B(""), [t, x] = B("all"), [p, v] = B("all"), [j] = B("all"), [R, f] = B(1), C = 20, [T, O] = B({ isOpen: !1 });
|
|
320
324
|
le(() => {
|
|
321
325
|
(async () => {
|
|
326
|
+
const U = c.apiKey;
|
|
327
|
+
if (!Ee(U)) {
|
|
328
|
+
M.current && U !== M.current && (i([]), M.current = null), N(!1);
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
322
331
|
try {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
return;
|
|
326
|
-
}
|
|
327
|
-
const T = await Oe(d, {
|
|
332
|
+
o(null), N(!0), M.current && U !== M.current && i([]);
|
|
333
|
+
const P = await Pe(c, {
|
|
328
334
|
limit: 1e3
|
|
329
335
|
});
|
|
330
|
-
if (
|
|
331
|
-
throw new Error(
|
|
332
|
-
i(
|
|
333
|
-
} catch (
|
|
334
|
-
|
|
336
|
+
if (P.status === "error")
|
|
337
|
+
throw new Error(P.message);
|
|
338
|
+
i(P.data), M.current = U;
|
|
339
|
+
} catch (P) {
|
|
340
|
+
o(P instanceof Error ? P.message : "Failed to fetch templates"), i([]), M.current = null;
|
|
335
341
|
} finally {
|
|
336
|
-
|
|
342
|
+
N(!1);
|
|
337
343
|
}
|
|
338
344
|
})();
|
|
339
|
-
}, [
|
|
340
|
-
const
|
|
341
|
-
const { name:
|
|
342
|
-
...
|
|
343
|
-
[
|
|
345
|
+
}, [c]);
|
|
346
|
+
const z = (u) => {
|
|
347
|
+
const { name: U, value: P } = u.target, L = {
|
|
348
|
+
...c,
|
|
349
|
+
[U]: P
|
|
344
350
|
};
|
|
345
|
-
|
|
346
|
-
},
|
|
347
|
-
|
|
351
|
+
h(L), localStorage.setItem("account", JSON.stringify(L));
|
|
352
|
+
}, $ = (u, U) => {
|
|
353
|
+
O({
|
|
348
354
|
isOpen: !0,
|
|
349
355
|
url: u,
|
|
350
|
-
templateName:
|
|
356
|
+
templateName: U
|
|
351
357
|
});
|
|
352
|
-
},
|
|
353
|
-
|
|
354
|
-
},
|
|
358
|
+
}, m = () => {
|
|
359
|
+
O({ isOpen: !1 });
|
|
360
|
+
}, E = async (u) => {
|
|
355
361
|
try {
|
|
356
|
-
const
|
|
357
|
-
if (!
|
|
358
|
-
|
|
362
|
+
const U = localStorage.getItem("account"), P = U ? JSON.parse(U) : { apiKey: "" };
|
|
363
|
+
if (!P.apiKey) {
|
|
364
|
+
o("Please enter your TrustSignal API key");
|
|
359
365
|
return;
|
|
360
366
|
}
|
|
361
|
-
|
|
362
|
-
const { deleteTemplateById:
|
|
363
|
-
if (!
|
|
364
|
-
i((
|
|
365
|
-
} catch (
|
|
366
|
-
|
|
367
|
+
A(u);
|
|
368
|
+
const { deleteTemplateById: L } = await import("./delete-BgBYMUw2.js"), Y = await L(P.apiKey, u);
|
|
369
|
+
if (!Y.success) throw new Error(Y.message || "Delete failed");
|
|
370
|
+
i((D) => D.filter((Z) => Z.id !== u)), w({ isOpen: !1 });
|
|
371
|
+
} catch (U) {
|
|
372
|
+
o(U instanceof Error ? U.message : "Failed to delete template");
|
|
367
373
|
} finally {
|
|
368
|
-
|
|
374
|
+
A(null);
|
|
369
375
|
}
|
|
370
|
-
},
|
|
371
|
-
const
|
|
372
|
-
return
|
|
373
|
-
}),
|
|
374
|
-
return
|
|
376
|
+
}, S = n.filter((u) => {
|
|
377
|
+
const U = b.trim(), P = U.toLowerCase(), L = U === "" || u.id.toString().includes(U) || u.name.toLowerCase().includes(P), Y = t === "all" || u.status.toLowerCase() === t.toLowerCase(), D = p === "all" || u.category.toLowerCase() === p.toLowerCase(), Z = j === "all" || u.language.toLowerCase().startsWith(j.toLowerCase());
|
|
378
|
+
return L && Y && D && Z;
|
|
379
|
+
}), V = Math.ceil(S.length / C), I = (R - 1) * C, _ = I + C, F = S.slice(I, _);
|
|
380
|
+
return l ? /* @__PURE__ */ e("div", { className: "rsp-flex rsp-items-center rsp-justify-center rsp-min-h-screen", children: /* @__PURE__ */ e("div", { className: "rsp-text-lg rsp-text-gray-600", children: "Loading templates..." }) }) : /* @__PURE__ */ r("div", { className: "rsp-container rsp-mx-auto rsp-px-4 rsp-py-8 rsp-bg-[#f5f7fc] rsp-rounded-lg rsp-shadow-sm", children: [
|
|
375
381
|
/* @__PURE__ */ r("div", { className: "rsp-flex rsp-justify-between rsp-items-center rsp-mb-6", children: [
|
|
376
382
|
/* @__PURE__ */ e("h1", { className: "rsp-text-2xl rsp-font-bold", children: "Whatsapp HSM Templates" }),
|
|
377
383
|
/* @__PURE__ */ e(
|
|
@@ -379,7 +385,7 @@ function Ta({ onCreateTemplate: a, onEditTemplate: s }) {
|
|
|
379
385
|
{
|
|
380
386
|
onClick: () => a == null ? void 0 : a(),
|
|
381
387
|
className: "rsp-bg-blue-600 rsp-text-white rsp-p-1 rsp-rounded-full hover:rsp-bg-blue-700 rsp-flex rsp-items-center rsp-gap-2",
|
|
382
|
-
children: /* @__PURE__ */ e(
|
|
388
|
+
children: /* @__PURE__ */ e(ue, { className: "rsp-w-6 rsp-h-6" })
|
|
383
389
|
}
|
|
384
390
|
)
|
|
385
391
|
] }),
|
|
@@ -391,8 +397,8 @@ function Ta({ onCreateTemplate: a, onEditTemplate: s }) {
|
|
|
391
397
|
{
|
|
392
398
|
type: "password",
|
|
393
399
|
name: "apiKey",
|
|
394
|
-
value:
|
|
395
|
-
onChange:
|
|
400
|
+
value: c.apiKey,
|
|
401
|
+
onChange: z,
|
|
396
402
|
className: "rsp-w-full rsp-px-0 rsp-py-2 rsp-border-0 rsp-border-b rsp-border-gray-300 rsp-text-sm focus:rsp-outline-none focus:rsp-border-blue-500 rsp-bg-transparent",
|
|
397
403
|
placeholder: "Enter your TrustSignal API key"
|
|
398
404
|
}
|
|
@@ -400,17 +406,17 @@ function Ta({ onCreateTemplate: a, onEditTemplate: s }) {
|
|
|
400
406
|
/* @__PURE__ */ e("div", { className: "rsp-absolute rsp-bottom-0 rsp-left-0 rsp-w-4 rsp-h-0.5 rsp-bg-red-500" })
|
|
401
407
|
] })
|
|
402
408
|
] }) }),
|
|
403
|
-
|
|
404
|
-
/* @__PURE__ */ e("div", { className: "rsp-flex-shrink-0", children: /* @__PURE__ */ e(
|
|
405
|
-
/* @__PURE__ */ e("div", { className: "rsp-ml-3", children: /* @__PURE__ */ e("p", { className: "rsp-text-sm rsp-text-red-700", children:
|
|
409
|
+
g && /* @__PURE__ */ e("div", { className: "rsp-bg-red-50 rsp-border-l-4 rsp-border-red-500 rsp-p-4 rsp-mb-6", children: /* @__PURE__ */ r("div", { className: "rsp-flex", children: [
|
|
410
|
+
/* @__PURE__ */ e("div", { className: "rsp-flex-shrink-0", children: /* @__PURE__ */ e(he, { className: "rsp-h-5 rsp-w-5 rsp-text-red-400" }) }),
|
|
411
|
+
/* @__PURE__ */ e("div", { className: "rsp-ml-3", children: /* @__PURE__ */ e("p", { className: "rsp-text-sm rsp-text-red-700", children: g }) })
|
|
406
412
|
] }) }),
|
|
407
413
|
/* @__PURE__ */ e("div", { className: "rsp-mb-6", children: /* @__PURE__ */ e("div", { className: "rsp-relative", children: /* @__PURE__ */ e(
|
|
408
414
|
"input",
|
|
409
415
|
{
|
|
410
416
|
type: "text",
|
|
411
417
|
placeholder: "Search by name or ID...",
|
|
412
|
-
value:
|
|
413
|
-
onChange: (u) =>
|
|
418
|
+
value: b,
|
|
419
|
+
onChange: (u) => y(u.target.value),
|
|
414
420
|
className: "rsp-w-full rsp-px-0 rsp-py-3 rsp-border-0 rsp-border-b rsp-border-gray-300 rsp-text-sm focus:rsp-outline-none focus:rsp-border-blue-500 rsp-bg-transparent"
|
|
415
421
|
}
|
|
416
422
|
) }) }),
|
|
@@ -423,8 +429,8 @@ function Ta({ onCreateTemplate: a, onEditTemplate: s }) {
|
|
|
423
429
|
/* @__PURE__ */ e("div", { className: "rsp-flex rsp-items-center", children: /* @__PURE__ */ r(
|
|
424
430
|
"select",
|
|
425
431
|
{
|
|
426
|
-
value:
|
|
427
|
-
onChange: (u) =>
|
|
432
|
+
value: p,
|
|
433
|
+
onChange: (u) => v(u.target.value),
|
|
428
434
|
className: "rsp-cursor-pointer rsp-ml-2 rsp-bg-transparent rsp-text-white rsp-border-0 rsp-text-sm focus:rsp-outline-none ",
|
|
429
435
|
onClick: (u) => u.stopPropagation(),
|
|
430
436
|
children: [
|
|
@@ -442,8 +448,8 @@ function Ta({ onCreateTemplate: a, onEditTemplate: s }) {
|
|
|
442
448
|
/* @__PURE__ */ e("div", { className: "rsp-flex rsp-items-center", children: /* @__PURE__ */ r(
|
|
443
449
|
"select",
|
|
444
450
|
{
|
|
445
|
-
value:
|
|
446
|
-
onChange: (u) =>
|
|
451
|
+
value: t,
|
|
452
|
+
onChange: (u) => x(u.target.value),
|
|
447
453
|
className: "rsp-cursor-pointer rsp-ml-2 rsp-bg-transparent rsp-text-white rsp-border-0 rsp-text-sm focus:rsp-outline-none",
|
|
448
454
|
onClick: (u) => u.stopPropagation(),
|
|
449
455
|
children: [
|
|
@@ -460,10 +466,10 @@ function Ta({ onCreateTemplate: a, onEditTemplate: s }) {
|
|
|
460
466
|
/* @__PURE__ */ e("th", { className: "rsp-px-6 rsp-py-3 rsp-text-left rsp-text-sm rsp-font-medium", children: "Media" }),
|
|
461
467
|
/* @__PURE__ */ e("th", { className: "rsp-px-6 rsp-py-3 rsp-text-left rsp-text-sm rsp-font-medium", children: "Actions" })
|
|
462
468
|
] }) }),
|
|
463
|
-
/* @__PURE__ */ e("tbody", { children:
|
|
469
|
+
/* @__PURE__ */ e("tbody", { children: F.length > 0 ? F.map((u, U) => /* @__PURE__ */ r(
|
|
464
470
|
"tr",
|
|
465
471
|
{
|
|
466
|
-
className: `rsp-border-b rsp-border-gray-200 ${
|
|
472
|
+
className: `rsp-border-b rsp-border-gray-200 ${U % 2 === 0 ? "rsp-bg-white" : "rsp-bg-blue-50"} hover:rsp-bg-blue-100 rsp-transition-colors`,
|
|
467
473
|
children: [
|
|
468
474
|
/* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-900", children: u.id }),
|
|
469
475
|
/* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-900 rsp-font-medium", children: u.name }),
|
|
@@ -477,7 +483,7 @@ function Ta({ onCreateTemplate: a, onEditTemplate: s }) {
|
|
|
477
483
|
/* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-700", children: u.medialist && typeof u.medialist == "object" && "header" in u.medialist && u.medialist.header ? /* @__PURE__ */ r(
|
|
478
484
|
"button",
|
|
479
485
|
{
|
|
480
|
-
onClick: () =>
|
|
486
|
+
onClick: () => $(String(u.medialist.header || ""), u.name),
|
|
481
487
|
className: "rsp-inline-flex rsp-items-center rsp-px-3 rsp-py-1 rsp-rounded rsp-text-xs rsp-font-medium rsp-bg-blue-100 rsp-text-blue-800 hover:rsp-bg-blue-200 rsp-transition-colors",
|
|
482
488
|
children: [
|
|
483
489
|
/* @__PURE__ */ r("svg", { className: "rsp-w-3 rsp-h-3 rsp-mr-1", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: [
|
|
@@ -495,17 +501,17 @@ function Ta({ onCreateTemplate: a, onEditTemplate: s }) {
|
|
|
495
501
|
onClick: () => s == null ? void 0 : s(String(u.id)),
|
|
496
502
|
className: "rsp-inline-flex rsp-items-center rsp-justify-center rsp-w-8 rsp-h-8 rsp-rounded rsp-bg-blue-600 rsp-text-white hover:rsp-bg-blue-700 rsp-transition-colors",
|
|
497
503
|
title: "Update",
|
|
498
|
-
children: /* @__PURE__ */ e(
|
|
504
|
+
children: /* @__PURE__ */ e(Ke, { className: "rsp-w-4 rsp-h-4" })
|
|
499
505
|
}
|
|
500
506
|
),
|
|
501
507
|
/* @__PURE__ */ e(
|
|
502
508
|
"button",
|
|
503
509
|
{
|
|
504
|
-
onClick: () =>
|
|
505
|
-
disabled:
|
|
506
|
-
className: `rsp-inline-flex rsp-items-center rsp-justify-center rsp-w-8 rsp-h-8 rsp-rounded rsp-text-white rsp-transition-colors ${
|
|
507
|
-
title:
|
|
508
|
-
children: /* @__PURE__ */ e(
|
|
510
|
+
onClick: () => w({ isOpen: !0, templateId: String(u.id), templateName: u.name }),
|
|
511
|
+
disabled: k === u.id,
|
|
512
|
+
className: `rsp-inline-flex rsp-items-center rsp-justify-center rsp-w-8 rsp-h-8 rsp-rounded rsp-text-white rsp-transition-colors ${k === u.id ? "rsp-bg-red-400" : "rsp-bg-red-600 hover:rsp-bg-red-700"}`,
|
|
513
|
+
title: k === u.id ? "Deleting..." : "Delete",
|
|
514
|
+
children: /* @__PURE__ */ e(Xe, { className: "rsp-w-4 rsp-h-4" })
|
|
509
515
|
}
|
|
510
516
|
)
|
|
511
517
|
] }) })
|
|
@@ -514,37 +520,37 @@ function Ta({ onCreateTemplate: a, onEditTemplate: s }) {
|
|
|
514
520
|
u.id
|
|
515
521
|
)) : /* @__PURE__ */ e("tr", { children: /* @__PURE__ */ e("td", { colSpan: 9, className: "rsp-px-6 rsp-py-8 rsp-text-center rsp-text-gray-500", children: "No templates found" }) }) })
|
|
516
522
|
] }) }) }),
|
|
517
|
-
|
|
523
|
+
F.length > 0 && /* @__PURE__ */ r("div", { className: "rsp-flex rsp-justify-between rsp-items-center rsp-mt-6 rsp-px-6 rsp-py-4 rsp-bg-white rsp-rounded-lg rsp-shadow-sm rsp-border rsp-border-gray-200", children: [
|
|
518
524
|
/* @__PURE__ */ r("div", { className: "rsp-text-sm rsp-text-gray-700", children: [
|
|
519
525
|
"Showing ",
|
|
520
|
-
/* @__PURE__ */ e("span", { className: "rsp-font-medium", children:
|
|
526
|
+
/* @__PURE__ */ e("span", { className: "rsp-font-medium", children: I + 1 }),
|
|
521
527
|
" to ",
|
|
522
|
-
/* @__PURE__ */ e("span", { className: "rsp-font-medium", children: Math.min(
|
|
528
|
+
/* @__PURE__ */ e("span", { className: "rsp-font-medium", children: Math.min(_, S.length) }),
|
|
523
529
|
" of ",
|
|
524
|
-
/* @__PURE__ */ e("span", { className: "rsp-font-medium", children:
|
|
530
|
+
/* @__PURE__ */ e("span", { className: "rsp-font-medium", children: S.length }),
|
|
525
531
|
" results"
|
|
526
532
|
] }),
|
|
527
533
|
/* @__PURE__ */ r("div", { className: "rsp-flex rsp-gap-2", children: [
|
|
528
534
|
/* @__PURE__ */ e(
|
|
529
535
|
"button",
|
|
530
536
|
{
|
|
531
|
-
onClick: () =>
|
|
532
|
-
disabled:
|
|
537
|
+
onClick: () => f((u) => Math.max(u - 1, 1)),
|
|
538
|
+
disabled: R === 1,
|
|
533
539
|
className: "rsp-px-4 rsp-py-2 rsp-text-sm rsp-font-medium rsp-text-gray-700 rsp-bg-white rsp-border rsp-border-gray-300 rsp-rounded-md hover:rsp-bg-gray-50 disabled:rsp-opacity-50 disabled:rsp-cursor-not-allowed rsp-transition-colors",
|
|
534
540
|
children: "Previous"
|
|
535
541
|
}
|
|
536
542
|
),
|
|
537
543
|
/* @__PURE__ */ r("span", { className: "rsp-px-4 rsp-py-2 rsp-text-sm rsp-font-medium rsp-text-gray-700", children: [
|
|
538
544
|
"Page ",
|
|
539
|
-
|
|
545
|
+
R,
|
|
540
546
|
" of ",
|
|
541
|
-
|
|
547
|
+
V
|
|
542
548
|
] }),
|
|
543
549
|
/* @__PURE__ */ e(
|
|
544
550
|
"button",
|
|
545
551
|
{
|
|
546
|
-
onClick: () =>
|
|
547
|
-
disabled:
|
|
552
|
+
onClick: () => f((u) => Math.min(u + 1, V)),
|
|
553
|
+
disabled: R === V,
|
|
548
554
|
className: "rsp-px-4 rsp-py-2 rsp-text-sm rsp-font-medium rsp-text-gray-700 rsp-bg-white rsp-border rsp-border-gray-300 rsp-rounded-md hover:rsp-bg-gray-50 disabled:rsp-opacity-50 disabled:rsp-cursor-not-allowed rsp-transition-colors",
|
|
549
555
|
children: "Next"
|
|
550
556
|
}
|
|
@@ -554,30 +560,30 @@ function Ta({ onCreateTemplate: a, onEditTemplate: s }) {
|
|
|
554
560
|
/* @__PURE__ */ e(
|
|
555
561
|
te,
|
|
556
562
|
{
|
|
557
|
-
isOpen:
|
|
558
|
-
onClose:
|
|
559
|
-
title: `Media - ${
|
|
563
|
+
isOpen: T.isOpen,
|
|
564
|
+
onClose: m,
|
|
565
|
+
title: `Media - ${T.templateName || "Template"}`,
|
|
560
566
|
children: /* @__PURE__ */ r("div", { className: "rsp-space-y-4", children: [
|
|
561
|
-
|
|
567
|
+
T.url && /* @__PURE__ */ r("div", { className: "rsp-text-center", children: [
|
|
562
568
|
/* @__PURE__ */ r("div", { className: "rsp-relative rsp-bg-gray-50 rsp-rounded-lg rsp-p-4 rsp-min-h-[200px] rsp-flex rsp-items-center rsp-justify-center", children: [
|
|
563
569
|
/* @__PURE__ */ e(
|
|
564
570
|
"img",
|
|
565
571
|
{
|
|
566
|
-
src:
|
|
572
|
+
src: T.url,
|
|
567
573
|
alt: "Template media",
|
|
568
574
|
className: "rsp-max-w-full rsp-max-h-[400px] rsp-mx-auto rsp-rounded-lg rsp-shadow-md rsp-object-contain",
|
|
569
575
|
onLoad: (u) => {
|
|
570
|
-
const
|
|
571
|
-
|
|
576
|
+
const U = u.currentTarget.parentElement, P = U == null ? void 0 : U.querySelector(".loading-placeholder");
|
|
577
|
+
P && (P.style.display = "none");
|
|
572
578
|
},
|
|
573
579
|
onError: (u) => {
|
|
574
580
|
u.currentTarget.style.display = "none";
|
|
575
|
-
const
|
|
576
|
-
|
|
581
|
+
const U = u.currentTarget.parentElement, P = U == null ? void 0 : U.querySelector(".error-placeholder");
|
|
582
|
+
P && (P.style.display = "block");
|
|
577
583
|
}
|
|
578
584
|
}
|
|
579
585
|
),
|
|
580
|
-
|
|
586
|
+
l && /* @__PURE__ */ e("div", { className: "loading-placeholder rsp-absolute rsp-inset-0 rsp-flex rsp-items-center rsp-justify-center", children: /* @__PURE__ */ e("div", { className: "rsp-text-gray-500 rsp-text-sm", children: "Loading media..." }) }),
|
|
581
587
|
/* @__PURE__ */ r("div", { className: "error-placeholder rsp-absolute rsp-inset-0 rsp-flex rsp-flex-col rsp-items-center rsp-justify-center", style: { display: "none" }, children: [
|
|
582
588
|
/* @__PURE__ */ e("svg", { className: "rsp-w-[100%] rsp-h-12 rsp-text-gray-400 rsp-m-2", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" }) }),
|
|
583
589
|
/* @__PURE__ */ e("p", { className: "rsp-text-gray-500 rsp-text-sm rsp-mb-2", children: "Load media on new tab" })
|
|
@@ -585,13 +591,13 @@ function Ta({ onCreateTemplate: a, onEditTemplate: s }) {
|
|
|
585
591
|
] }),
|
|
586
592
|
/* @__PURE__ */ r("div", { className: "rsp-mt-4 rsp-p-3 rsp-bg-gray-50 rsp-rounded-lg", children: [
|
|
587
593
|
/* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-gray-600 rsp-mb-1", children: "Media URL:" }),
|
|
588
|
-
/* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-gray-800 rsp-break-all rsp-font-mono", children:
|
|
594
|
+
/* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-gray-800 rsp-break-all rsp-font-mono", children: T.url })
|
|
589
595
|
] })
|
|
590
596
|
] }),
|
|
591
597
|
/* @__PURE__ */ e("div", { className: "rsp-flex rsp-justify-end rsp-pt-4", children: /* @__PURE__ */ r(
|
|
592
598
|
"a",
|
|
593
599
|
{
|
|
594
|
-
href:
|
|
600
|
+
href: T.url,
|
|
595
601
|
target: "_blank",
|
|
596
602
|
rel: "noopener noreferrer",
|
|
597
603
|
className: "rsp-inline-flex rsp-items-center rsp-px-4 rsp-py-2 rsp-bg-blue-600 rsp-text-white rsp-text-sm rsp-font-medium rsp-rounded-md hover:rsp-bg-blue-700 rsp-transition-colors",
|
|
@@ -607,21 +613,21 @@ function Ta({ onCreateTemplate: a, onEditTemplate: s }) {
|
|
|
607
613
|
/* @__PURE__ */ e(
|
|
608
614
|
te,
|
|
609
615
|
{
|
|
610
|
-
isOpen:
|
|
611
|
-
onClose: () =>
|
|
616
|
+
isOpen: d.isOpen,
|
|
617
|
+
onClose: () => w({ isOpen: !1 }),
|
|
612
618
|
title: "Delete Template",
|
|
613
619
|
children: /* @__PURE__ */ r("div", { className: "rsp-space-y-4", children: [
|
|
614
620
|
/* @__PURE__ */ r("p", { className: "rsp-text-sm rsp-text-gray-700", children: [
|
|
615
621
|
"Are you sure you want to delete the template ",
|
|
616
|
-
/* @__PURE__ */ e("span", { className: "rsp-font-medium", children:
|
|
622
|
+
/* @__PURE__ */ e("span", { className: "rsp-font-medium", children: d.templateName }),
|
|
617
623
|
"?"
|
|
618
624
|
] }),
|
|
619
625
|
/* @__PURE__ */ r("div", { className: "rsp-flex rsp-justify-end rsp-gap-3", children: [
|
|
620
|
-
/* @__PURE__ */ e("button", { onClick: () =>
|
|
626
|
+
/* @__PURE__ */ e("button", { onClick: () => w({ isOpen: !1 }), className: "rsp-px-4 rsp-py-2 rsp-text-sm rsp-font-medium rsp-text-gray-700 rsp-bg-white rsp-border rsp-border-gray-300 rsp-rounded-md hover:rsp-bg-gray-50", children: "Cancel" }),
|
|
621
627
|
/* @__PURE__ */ e(
|
|
622
628
|
"button",
|
|
623
629
|
{
|
|
624
|
-
onClick: () =>
|
|
630
|
+
onClick: () => d.templateId && E(d.templateId),
|
|
625
631
|
className: "rsp-px-4 rsp-py-2 rsp-text-sm rsp-font-medium rsp-text-white rsp-bg-red-600 rsp-rounded-md hover:rsp-bg-red-700",
|
|
626
632
|
children: "Delete"
|
|
627
633
|
}
|
|
@@ -632,14 +638,14 @@ function Ta({ onCreateTemplate: a, onEditTemplate: s }) {
|
|
|
632
638
|
)
|
|
633
639
|
] });
|
|
634
640
|
}
|
|
635
|
-
const
|
|
636
|
-
var n, i, c,
|
|
641
|
+
const Ze = async (a, s) => {
|
|
642
|
+
var n, i, c, h, l, N, g;
|
|
637
643
|
try {
|
|
638
644
|
console.log("Creating template with data:", s);
|
|
639
|
-
const
|
|
645
|
+
const o = s.language, k = s.headerType === "MEDIA" && s.mediaType === "DOCUMENT", A = s.type === "CAROUSEL";
|
|
640
646
|
let d = "";
|
|
641
|
-
k ? d = Ue(s,
|
|
642
|
-
const
|
|
647
|
+
k ? d = Ue(s, o) : A ? d = je(s, o) : d = Re(s, o), console.log("Raw JSON string being sent:", d);
|
|
648
|
+
const w = {
|
|
643
649
|
method: "POST",
|
|
644
650
|
headers: {
|
|
645
651
|
"Content-Type": "application/json"
|
|
@@ -650,10 +656,10 @@ const Qe = async (a, s) => {
|
|
|
650
656
|
console.log(
|
|
651
657
|
"Making request to:",
|
|
652
658
|
`https://wpapi.trustsignal.io/api/v1/template?api_key=${a}`
|
|
653
|
-
), console.log("Request options:",
|
|
659
|
+
), console.log("Request options:", w);
|
|
654
660
|
const M = await fetch(
|
|
655
661
|
`https://wpapi.trustsignal.io/api/v1/template?api_key=${a}`,
|
|
656
|
-
|
|
662
|
+
w
|
|
657
663
|
);
|
|
658
664
|
console.log("Response status:", M.status), console.log(
|
|
659
665
|
"Response headers:",
|
|
@@ -674,27 +680,27 @@ const Qe = async (a, s) => {
|
|
|
674
680
|
template_name: ((n = y.template) == null ? void 0 : n.name) || s.name,
|
|
675
681
|
template_id: ((i = y.template) == null ? void 0 : i.id) || "unknown",
|
|
676
682
|
meta_tid: (c = y.template) == null ? void 0 : c.meta_tid,
|
|
677
|
-
status: (
|
|
683
|
+
status: (h = y.template) == null ? void 0 : h.status,
|
|
678
684
|
quality: (l = y.template) == null ? void 0 : l.quality,
|
|
679
|
-
temp_route: (
|
|
685
|
+
temp_route: (N = y.template) == null ? void 0 : N.temp_route,
|
|
680
686
|
temptype: (g = y.template) == null ? void 0 : g.temptype
|
|
681
687
|
}
|
|
682
688
|
]
|
|
683
689
|
}
|
|
684
690
|
};
|
|
685
|
-
} catch (
|
|
686
|
-
return console.error("TrustSignal API Error:",
|
|
691
|
+
} catch (o) {
|
|
692
|
+
return console.error("TrustSignal API Error:", o), {
|
|
687
693
|
status: "error",
|
|
688
|
-
message:
|
|
694
|
+
message: o instanceof Error ? o.message : "Failed to create template"
|
|
689
695
|
};
|
|
690
696
|
}
|
|
691
697
|
};
|
|
692
|
-
function
|
|
698
|
+
function ea(a) {
|
|
693
699
|
const s = a.language, n = a.headerType === "MEDIA" && a.mediaType === "DOCUMENT", i = a.type === "CAROUSEL";
|
|
694
|
-
return n ? Ue(a, s) : i ?
|
|
700
|
+
return n ? Ue(a, s) : i ? je(a, s) : Re(a, s);
|
|
695
701
|
}
|
|
696
702
|
const Ue = (a, s) => {
|
|
697
|
-
var
|
|
703
|
+
var h, l;
|
|
698
704
|
const n = {
|
|
699
705
|
name: a.name,
|
|
700
706
|
lang: s,
|
|
@@ -708,14 +714,14 @@ const Ue = (a, s) => {
|
|
|
708
714
|
type: "HEADER",
|
|
709
715
|
format: "DOCUMENT"
|
|
710
716
|
}));
|
|
711
|
-
const i =
|
|
717
|
+
const i = ae(a.body), c = {
|
|
712
718
|
type: "BODY",
|
|
713
719
|
text: a.body
|
|
714
720
|
};
|
|
715
|
-
if (i.length > 0 && ((
|
|
716
|
-
const
|
|
721
|
+
if (i.length > 0 && ((h = a.sampleContent) != null && h.bodyVariables)) {
|
|
722
|
+
const N = ye(a, i);
|
|
717
723
|
c.example = {
|
|
718
|
-
body_text: [
|
|
724
|
+
body_text: [N]
|
|
719
725
|
// This creates the required nested array
|
|
720
726
|
};
|
|
721
727
|
}
|
|
@@ -723,34 +729,34 @@ const Ue = (a, s) => {
|
|
|
723
729
|
type: "FOOTER",
|
|
724
730
|
text: a.footer
|
|
725
731
|
}), a.buttons && a.buttons.length > 0) {
|
|
726
|
-
const
|
|
732
|
+
const N = a.buttons.map((g) => {
|
|
727
733
|
var k;
|
|
728
|
-
const
|
|
734
|
+
const o = {
|
|
729
735
|
type: g.type === "CALL" ? "PHONE_NUMBER" : g.type,
|
|
730
736
|
text: g.text
|
|
731
737
|
};
|
|
732
|
-
if (g.type === "URL" && g.value && (
|
|
733
|
-
const
|
|
734
|
-
if (
|
|
735
|
-
const d =
|
|
736
|
-
({ number:
|
|
738
|
+
if (g.type === "URL" && g.value && (o.url = g.value, g.urlType === "dynamic" && g.value.includes("{{"))) {
|
|
739
|
+
const A = ae(g.value);
|
|
740
|
+
if (A.length > 0 && ((k = a.sampleContent) != null && k.buttonVariables)) {
|
|
741
|
+
const d = A.map(
|
|
742
|
+
({ number: w }) => {
|
|
737
743
|
var M, b;
|
|
738
|
-
return ((b = (M = a.sampleContent) == null ? void 0 : M.buttonVariables) == null ? void 0 : b[
|
|
744
|
+
return ((b = (M = a.sampleContent) == null ? void 0 : M.buttonVariables) == null ? void 0 : b[w]) || `sample${w}`;
|
|
739
745
|
}
|
|
740
746
|
);
|
|
741
|
-
|
|
747
|
+
o.example = d;
|
|
742
748
|
}
|
|
743
749
|
}
|
|
744
|
-
return (g.type === "CALL" || g.type === "PHONE_NUMBER") && g.value && (
|
|
750
|
+
return (g.type === "CALL" || g.type === "PHONE_NUMBER") && g.value && (o.phone_number = ge(g.value)), o;
|
|
745
751
|
});
|
|
746
752
|
n.components.push({
|
|
747
753
|
type: "BUTTONS",
|
|
748
|
-
buttons:
|
|
754
|
+
buttons: N
|
|
749
755
|
});
|
|
750
756
|
}
|
|
751
757
|
return JSON.stringify(n);
|
|
752
|
-
},
|
|
753
|
-
var l,
|
|
758
|
+
}, je = (a, s) => {
|
|
759
|
+
var l, N, g;
|
|
754
760
|
const n = {
|
|
755
761
|
name: a.name,
|
|
756
762
|
lang: s,
|
|
@@ -758,35 +764,35 @@ const Ue = (a, s) => {
|
|
|
758
764
|
shortlink: a.enableClickTracking ? "1" : "0",
|
|
759
765
|
components: []
|
|
760
766
|
};
|
|
761
|
-
(l = a.carousel) != null && l.cards.length && (n.media = {}, a.carousel.cards.forEach((
|
|
762
|
-
|
|
767
|
+
(l = a.carousel) != null && l.cards.length && (n.media = {}, a.carousel.cards.forEach((o, k) => {
|
|
768
|
+
o.mediaUrl && (n.media[`card${k}header`] = o.mediaUrl);
|
|
763
769
|
}));
|
|
764
|
-
const i = [], c =
|
|
770
|
+
const i = [], c = ae(a.body), h = {
|
|
765
771
|
type: "BODY",
|
|
766
772
|
text: a.body,
|
|
767
|
-
...c.length > 0 && ((
|
|
773
|
+
...c.length > 0 && ((N = a.sampleContent) == null ? void 0 : N.bodyVariables) && {
|
|
768
774
|
example: {
|
|
769
|
-
body_text: [
|
|
775
|
+
body_text: [ye(a, c)]
|
|
770
776
|
}
|
|
771
777
|
}
|
|
772
778
|
};
|
|
773
|
-
if (i.push(
|
|
774
|
-
const
|
|
779
|
+
if (i.push(h), (g = a.carousel) != null && g.cards.length) {
|
|
780
|
+
const o = {
|
|
775
781
|
type: "CAROUSEL",
|
|
776
782
|
cards: a.carousel.cards.map((k) => {
|
|
777
|
-
var
|
|
783
|
+
var A;
|
|
778
784
|
return {
|
|
779
785
|
components: [
|
|
780
786
|
{
|
|
781
787
|
type: "HEADER",
|
|
782
|
-
format: ((
|
|
788
|
+
format: ((A = a.carousel) == null ? void 0 : A.type) || "IMAGE"
|
|
783
789
|
},
|
|
784
790
|
{
|
|
785
791
|
type: "BODY",
|
|
786
792
|
text: k.body,
|
|
787
|
-
...
|
|
793
|
+
...ae(k.body).length > 0 && {
|
|
788
794
|
example: {
|
|
789
|
-
body_text: [
|
|
795
|
+
body_text: [aa(k)]
|
|
790
796
|
}
|
|
791
797
|
}
|
|
792
798
|
},
|
|
@@ -794,33 +800,33 @@ const Ue = (a, s) => {
|
|
|
794
800
|
type: "BUTTONS",
|
|
795
801
|
buttons: k.buttons.map((d) => {
|
|
796
802
|
var M;
|
|
797
|
-
const
|
|
803
|
+
const w = {
|
|
798
804
|
type: d.type === "CALL" ? "PHONE_NUMBER" : d.type,
|
|
799
805
|
text: d.text
|
|
800
806
|
};
|
|
801
|
-
if (d.type === "URL" && d.value && (
|
|
802
|
-
const b =
|
|
807
|
+
if (d.type === "URL" && d.value && (w.url = d.value, d.urlType === "dynamic" && d.value.includes("{{"))) {
|
|
808
|
+
const b = ae(d.value);
|
|
803
809
|
if (b.length > 0) {
|
|
804
810
|
const y = ((M = k == null ? void 0 : k.sampleContent) == null ? void 0 : M.buttonVariables) || {}, t = b.map(({ number: x }) => y[x] || `sample${x}`);
|
|
805
|
-
|
|
811
|
+
w.example = t;
|
|
806
812
|
}
|
|
807
813
|
}
|
|
808
|
-
return (d.type === "CALL" || d.type === "PHONE_NUMBER") && d.value && (
|
|
814
|
+
return (d.type === "CALL" || d.type === "PHONE_NUMBER") && d.value && (w.phone_number = ge(d.value)), console.log("Carousel card button data:", w), w;
|
|
809
815
|
})
|
|
810
816
|
}] : []
|
|
811
817
|
]
|
|
812
818
|
};
|
|
813
819
|
})
|
|
814
820
|
};
|
|
815
|
-
i.push(
|
|
821
|
+
i.push(o);
|
|
816
822
|
}
|
|
817
823
|
return n.components = i, JSON.stringify(n);
|
|
818
|
-
},
|
|
824
|
+
}, aa = (a) => {
|
|
819
825
|
var i;
|
|
820
|
-
const s =
|
|
826
|
+
const s = ae(a.body || ""), n = ((i = a == null ? void 0 : a.sampleContent) == null ? void 0 : i.bodyVariables) || {};
|
|
821
827
|
return s.map(({ number: c }) => n[c] || `Sample ${c}`);
|
|
822
|
-
},
|
|
823
|
-
var l,
|
|
828
|
+
}, Re = (a, s) => {
|
|
829
|
+
var l, N;
|
|
824
830
|
const n = {
|
|
825
831
|
name: a.name,
|
|
826
832
|
lang: s,
|
|
@@ -834,17 +840,17 @@ const Ue = (a, s) => {
|
|
|
834
840
|
const i = [];
|
|
835
841
|
if (a.type !== "CAROUSEL") {
|
|
836
842
|
if (a.headerType === "TEXT" && a.headerText) {
|
|
837
|
-
const g =
|
|
843
|
+
const g = ae(a.headerText), o = {
|
|
838
844
|
type: "HEADER",
|
|
839
845
|
format: "TEXT",
|
|
840
846
|
text: a.headerText,
|
|
841
847
|
...g.length > 0 && ((l = a.sampleContent) == null ? void 0 : l.headerVariables) && {
|
|
842
848
|
example: {
|
|
843
|
-
header_text:
|
|
849
|
+
header_text: ra(a, g)
|
|
844
850
|
}
|
|
845
851
|
}
|
|
846
852
|
};
|
|
847
|
-
i.push(
|
|
853
|
+
i.push(o);
|
|
848
854
|
} else if (a.headerType === "MEDIA") {
|
|
849
855
|
const g = {
|
|
850
856
|
type: "HEADER",
|
|
@@ -853,38 +859,38 @@ const Ue = (a, s) => {
|
|
|
853
859
|
i.push(g);
|
|
854
860
|
}
|
|
855
861
|
}
|
|
856
|
-
const c =
|
|
862
|
+
const c = ae(a.body), h = {
|
|
857
863
|
type: "BODY",
|
|
858
864
|
text: a.body,
|
|
859
|
-
...c.length > 0 && ((
|
|
865
|
+
...c.length > 0 && ((N = a.sampleContent) == null ? void 0 : N.bodyVariables) && {
|
|
860
866
|
example: {
|
|
861
|
-
body_text: [
|
|
867
|
+
body_text: [ye(a, c)]
|
|
862
868
|
}
|
|
863
869
|
}
|
|
864
870
|
};
|
|
865
|
-
if (i.push(
|
|
871
|
+
if (i.push(h), a.footer && a.type !== "CAROUSEL" && i.push({
|
|
866
872
|
type: "FOOTER",
|
|
867
873
|
text: a.footer
|
|
868
874
|
}), a.buttons.length > 0) {
|
|
869
|
-
const g = a.buttons.map((
|
|
870
|
-
var
|
|
875
|
+
const g = a.buttons.map((o) => {
|
|
876
|
+
var A;
|
|
871
877
|
const k = {
|
|
872
|
-
type:
|
|
873
|
-
text:
|
|
878
|
+
type: o.type === "CALL" ? "PHONE_NUMBER" : o.type,
|
|
879
|
+
text: o.text
|
|
874
880
|
};
|
|
875
|
-
if (
|
|
876
|
-
const d =
|
|
877
|
-
if (d.length > 0 && ((
|
|
878
|
-
const
|
|
881
|
+
if (o.type === "URL" && o.value && (k.url = o.value, o.urlType === "dynamic" && o.value.includes("{{"))) {
|
|
882
|
+
const d = ae(o.value);
|
|
883
|
+
if (d.length > 0 && ((A = a.sampleContent) != null && A.buttonVariables)) {
|
|
884
|
+
const w = d.map(
|
|
879
885
|
({ number: M }) => {
|
|
880
886
|
var b, y;
|
|
881
887
|
return ((y = (b = a.sampleContent) == null ? void 0 : b.buttonVariables) == null ? void 0 : y[M]) || `sample${M}`;
|
|
882
888
|
}
|
|
883
889
|
);
|
|
884
|
-
k.example =
|
|
890
|
+
k.example = w;
|
|
885
891
|
}
|
|
886
892
|
}
|
|
887
|
-
return (
|
|
893
|
+
return (o.type === "CALL" || o.type === "PHONE_NUMBER") && o.value && (k.phone_number = ge(o.value)), k;
|
|
888
894
|
});
|
|
889
895
|
i.push({
|
|
890
896
|
type: "BUTTONS",
|
|
@@ -892,26 +898,26 @@ const Ue = (a, s) => {
|
|
|
892
898
|
});
|
|
893
899
|
}
|
|
894
900
|
return n.components = i, JSON.stringify(n);
|
|
895
|
-
},
|
|
901
|
+
}, ae = (a) => (a.match(/\{\{(\d+)\}\}/g) || []).map((n) => ({
|
|
896
902
|
variable: n.replace(/[{}]/g, ""),
|
|
897
903
|
number: n.replace(/[{}]/g, "")
|
|
898
|
-
})),
|
|
904
|
+
})), ge = (a) => a.startsWith("+") ? a : `+${a}`, ra = (a, s) => s.map(
|
|
899
905
|
({ number: n }) => {
|
|
900
906
|
var i, c;
|
|
901
907
|
return ((c = (i = a.sampleContent) == null ? void 0 : i.headerVariables) == null ? void 0 : c[n]) || `Sample ${n}`;
|
|
902
908
|
}
|
|
903
|
-
),
|
|
909
|
+
), ye = (a, s) => s.map(
|
|
904
910
|
({ number: n }) => {
|
|
905
911
|
var i, c;
|
|
906
912
|
return ((c = (i = a.sampleContent) == null ? void 0 : i.bodyVariables) == null ? void 0 : c[n]) || `Sample ${n}`;
|
|
907
913
|
}
|
|
908
|
-
),
|
|
914
|
+
), sa = async (a, s) => {
|
|
909
915
|
try {
|
|
910
916
|
if (!s.name || !s.body)
|
|
911
917
|
throw new Error("Missing required template fields: name and body are required");
|
|
912
918
|
if (!a.apiKey)
|
|
913
919
|
throw new Error("Missing TrustSignal API key");
|
|
914
|
-
return await
|
|
920
|
+
return await Ze(
|
|
915
921
|
a.apiKey,
|
|
916
922
|
s
|
|
917
923
|
);
|
|
@@ -922,80 +928,80 @@ const Ue = (a, s) => {
|
|
|
922
928
|
};
|
|
923
929
|
}
|
|
924
930
|
};
|
|
925
|
-
async function
|
|
926
|
-
const i =
|
|
931
|
+
async function na(a, s, n) {
|
|
932
|
+
const i = ea(n), h = {
|
|
927
933
|
method: "POST",
|
|
928
934
|
headers: { "Content-Type": "application/json" },
|
|
929
935
|
body: i,
|
|
930
936
|
redirect: "follow"
|
|
931
|
-
}, l = `https://wpapi.trustsignal.io/v1/user-templates/update/${encodeURIComponent(s)}?api_key=${encodeURIComponent(a)}`,
|
|
932
|
-
if (!
|
|
933
|
-
return { success: !1, message: `Update failed (${
|
|
937
|
+
}, l = `https://wpapi.trustsignal.io/v1/user-templates/update/${encodeURIComponent(s)}?api_key=${encodeURIComponent(a)}`, N = await fetch(l, h), g = await N.text();
|
|
938
|
+
if (!N.ok)
|
|
939
|
+
return { success: !1, message: `Update failed (${N.status}): ${g}`, raw: i };
|
|
934
940
|
try {
|
|
935
|
-
const
|
|
936
|
-
return { success: !!((
|
|
941
|
+
const o = JSON.parse(g);
|
|
942
|
+
return { success: !!((o == null ? void 0 : o.success) ?? !0), message: o == null ? void 0 : o.message, raw: i };
|
|
937
943
|
} catch {
|
|
938
944
|
return { success: !0, raw: i };
|
|
939
945
|
}
|
|
940
946
|
}
|
|
941
|
-
async function
|
|
942
|
-
var
|
|
947
|
+
async function ia(a, s) {
|
|
948
|
+
var N;
|
|
943
949
|
const n = `https://wpapi.trustsignal.io/api/v1/template/${encodeURIComponent(s)}?api_key=${encodeURIComponent(a)}`, i = await fetch(n, { method: "GET", redirect: "follow" });
|
|
944
950
|
if (!i.ok)
|
|
945
951
|
throw new Error(`Failed to fetch template ${s}: ${i.status}`);
|
|
946
|
-
const c = await i.text(),
|
|
952
|
+
const c = await i.text(), h = JSON.parse(c), l = h.template || ((N = h.data) == null ? void 0 : N.template) || h;
|
|
947
953
|
if (!l)
|
|
948
954
|
throw new Error("Invalid template details response");
|
|
949
|
-
return
|
|
955
|
+
return la(l);
|
|
950
956
|
}
|
|
951
|
-
function
|
|
952
|
-
var k,
|
|
957
|
+
function la(a) {
|
|
958
|
+
var k, A;
|
|
953
959
|
const s = {
|
|
954
960
|
headerVariables: {},
|
|
955
961
|
bodyVariables: {},
|
|
956
962
|
buttonVariables: {}
|
|
957
963
|
};
|
|
958
|
-
let n = "NONE", i = "", c,
|
|
964
|
+
let n = "NONE", i = "", c, h, l = "", N = "";
|
|
959
965
|
const g = [];
|
|
960
966
|
if (a.jsonstruct)
|
|
961
967
|
try {
|
|
962
968
|
const d = JSON.parse(a.jsonstruct);
|
|
963
969
|
if (d != null && d.header) {
|
|
964
|
-
const
|
|
965
|
-
|
|
970
|
+
const w = d.header.format;
|
|
971
|
+
w && w !== "TEXT" ? (n = "MEDIA", c = w, h = d.header.url || ((k = a.medialist) == null ? void 0 : k.header)) : w === "TEXT" && (n = "TEXT", i = d.header.text || "");
|
|
966
972
|
}
|
|
967
|
-
if (d != null && d.body && (l = d.body.text || ""), (
|
|
968
|
-
for (const
|
|
969
|
-
if (!
|
|
973
|
+
if (d != null && d.body && (l = d.body.text || ""), (A = d == null ? void 0 : d.buttons) != null && A.buttons && Array.isArray(d.buttons.buttons))
|
|
974
|
+
for (const w of d.buttons.buttons) {
|
|
975
|
+
if (!w || !w.type || !w.text) continue;
|
|
970
976
|
const M = {
|
|
971
977
|
id: de(),
|
|
972
|
-
type:
|
|
973
|
-
text:
|
|
978
|
+
type: w.type === "PHONE_NUMBER" ? "PHONE_NUMBER" : w.type,
|
|
979
|
+
text: w.text
|
|
974
980
|
};
|
|
975
|
-
|
|
976
|
-
s.buttonVariables[y] =
|
|
977
|
-
}), M.urlType = "dynamic") : M.urlType = "static"), (
|
|
981
|
+
w.type === "URL" && (M.value = w.url, typeof w.url == "string" && w.url.includes("{{") && Array.isArray(w.example) ? (Me(w.url).forEach((y, t) => {
|
|
982
|
+
s.buttonVariables[y] = w.example[t] ?? "";
|
|
983
|
+
}), M.urlType = "dynamic") : M.urlType = "static"), (w.type === "CALL" || w.type === "PHONE_NUMBER") && (M.value = w.phone_number || ""), g.push(M);
|
|
978
984
|
}
|
|
979
985
|
if (d != null && d.carousel) {
|
|
980
|
-
const
|
|
981
|
-
|
|
982
|
-
const
|
|
983
|
-
return
|
|
986
|
+
const w = Object.keys(d.carousel).filter((x) => /^card\d+$/.test(x));
|
|
987
|
+
w.sort((x, p) => {
|
|
988
|
+
const v = parseInt(x.replace("card", ""), 10), j = parseInt(p.replace("card", ""), 10);
|
|
989
|
+
return v - j;
|
|
984
990
|
});
|
|
985
|
-
const M =
|
|
986
|
-
const p = d.carousel[x] || {},
|
|
991
|
+
const M = w.map((x) => {
|
|
992
|
+
const p = d.carousel[x] || {}, v = p.header || {}, j = p.body || {}, R = p.buttons && Array.isArray(p.buttons.buttons) ? p.buttons.buttons : [], f = v.format, C = f === "IMAGE" || f === "VIDEO" || f === "DOCUMENT" ? f : void 0, O = `card${x.replace("card", "")}header`, z = v.url || (a.medialist ? a.medialist[O] : void 0), $ = j.text || "", m = [];
|
|
987
993
|
for (const E of R) {
|
|
988
994
|
if (!E || !E.type || !E.text) continue;
|
|
989
995
|
const S = { id: de(), type: E.type === "PHONE_NUMBER" ? "PHONE_NUMBER" : E.type, text: E.text };
|
|
990
|
-
E.type === "URL" && (S.value = E.url, typeof E.url == "string" && E.url.includes("{{") && Array.isArray(E.example) ? (
|
|
996
|
+
E.type === "URL" && (S.value = E.url, typeof E.url == "string" && E.url.includes("{{") && Array.isArray(E.example) ? (Me(E.url).forEach((I, _) => {
|
|
991
997
|
}), S.urlType = "dynamic") : S.urlType = "static"), (E.type === "CALL" || E.type === "PHONE_NUMBER") && (S.value = E.phone_number || ""), m.push(S);
|
|
992
998
|
}
|
|
993
999
|
return {
|
|
994
1000
|
id: de(),
|
|
995
1001
|
headerType: C ? "MEDIA" : "NONE",
|
|
996
1002
|
mediaType: C,
|
|
997
|
-
mediaUrl:
|
|
998
|
-
body:
|
|
1003
|
+
mediaUrl: z,
|
|
1004
|
+
body: $,
|
|
999
1005
|
buttons: m,
|
|
1000
1006
|
sampleContent: {
|
|
1001
1007
|
headerVariables: {},
|
|
@@ -1020,7 +1026,7 @@ function ia(a) {
|
|
|
1020
1026
|
headerType: "NONE",
|
|
1021
1027
|
headerText: "",
|
|
1022
1028
|
body: l,
|
|
1023
|
-
footer:
|
|
1029
|
+
footer: N,
|
|
1024
1030
|
buttons: [],
|
|
1025
1031
|
sampleContent: s,
|
|
1026
1032
|
carousel: t
|
|
@@ -1038,14 +1044,14 @@ function ia(a) {
|
|
|
1038
1044
|
headerType: n,
|
|
1039
1045
|
headerText: i,
|
|
1040
1046
|
mediaType: c,
|
|
1041
|
-
mediaUrl:
|
|
1047
|
+
mediaUrl: h,
|
|
1042
1048
|
body: l,
|
|
1043
|
-
footer:
|
|
1049
|
+
footer: N,
|
|
1044
1050
|
buttons: g,
|
|
1045
1051
|
sampleContent: s
|
|
1046
1052
|
};
|
|
1047
1053
|
}
|
|
1048
|
-
function
|
|
1054
|
+
function Me(a) {
|
|
1049
1055
|
if (!a) return [];
|
|
1050
1056
|
const s = a.match(/\{\{(\d+)\}\}/g) || [];
|
|
1051
1057
|
return [...new Set(s.map((n) => n.replace(/[{}]/g, "")))];
|
|
@@ -1053,7 +1059,7 @@ function Ce(a) {
|
|
|
1053
1059
|
function de() {
|
|
1054
1060
|
return typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : "id-" + Math.random().toString(36).slice(2);
|
|
1055
1061
|
}
|
|
1056
|
-
const
|
|
1062
|
+
const ta = [
|
|
1057
1063
|
{ value: "af", label: "Afrikaans" },
|
|
1058
1064
|
{ value: "sq", label: "Albanian" },
|
|
1059
1065
|
{ value: "ar", label: "Arabic" },
|
|
@@ -1119,37 +1125,37 @@ const la = [
|
|
|
1119
1125
|
{ value: "ur", label: "Urdu" },
|
|
1120
1126
|
{ value: "uz", label: "Uzbek" },
|
|
1121
1127
|
{ value: "vi", label: "Vietnamese" }
|
|
1122
|
-
],
|
|
1128
|
+
], ca = [
|
|
1123
1129
|
{ value: "NONE", label: "None" },
|
|
1124
1130
|
{ value: "TEXT", label: "Text" },
|
|
1125
1131
|
{ value: "MEDIA", label: "Media" }
|
|
1126
|
-
],
|
|
1132
|
+
], ma = [
|
|
1127
1133
|
{ value: "IMAGE", label: "Image" },
|
|
1128
1134
|
{ value: "VIDEO", label: "Video" },
|
|
1129
1135
|
{ value: "DOCUMENT", label: "Document" }
|
|
1130
|
-
],
|
|
1131
|
-
function
|
|
1132
|
-
var
|
|
1133
|
-
const [i, c] = X.useState(null), [
|
|
1136
|
+
], da = 5 * 1024 * 1024, xa = 16 * 1024 * 1024, pa = 100 * 1024 * 1024, xe = ["jpg", "jpeg", "png"], pe = ["mp4", "3gpp"], oe = ["pdf", "docx", "xlsx", "pptx", "txt"];
|
|
1137
|
+
function oa({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
1138
|
+
var j, R;
|
|
1139
|
+
const [i, c] = X.useState(null), [h, l] = X.useState(!1), [N, g] = X.useState(null), [o, k] = X.useState(null), A = () => {
|
|
1134
1140
|
const C = (a.headerText || "").match(/{{\d+}}/g);
|
|
1135
1141
|
if (!C) return 0;
|
|
1136
|
-
const
|
|
1137
|
-
const
|
|
1138
|
-
return
|
|
1142
|
+
const T = C.map((O) => {
|
|
1143
|
+
const z = O.match(/{{(\d+)}}/);
|
|
1144
|
+
return z ? parseInt(z[1], 10) : 0;
|
|
1139
1145
|
});
|
|
1140
|
-
return
|
|
1146
|
+
return T.length > 0 ? Math.max(...T) : 0;
|
|
1141
1147
|
}, d = () => {
|
|
1142
|
-
const
|
|
1143
|
-
if (
|
|
1144
|
-
const O =
|
|
1148
|
+
const T = `{{${A() + 1}}}`;
|
|
1149
|
+
if (N && a.headerText.length + T.length <= 60) {
|
|
1150
|
+
const O = N.selectionStart || a.headerText.length, z = a.headerText.substring(0, O), $ = a.headerText.substring(O), m = z + T + $;
|
|
1145
1151
|
s({ ...a, headerText: m }), setTimeout(() => {
|
|
1146
|
-
if (
|
|
1147
|
-
const E = O +
|
|
1148
|
-
|
|
1152
|
+
if (N) {
|
|
1153
|
+
const E = O + T.length;
|
|
1154
|
+
N.setSelectionRange(E, E), N.focus();
|
|
1149
1155
|
}
|
|
1150
1156
|
}, 0);
|
|
1151
1157
|
}
|
|
1152
|
-
},
|
|
1158
|
+
}, w = (f) => {
|
|
1153
1159
|
s((C) => ({
|
|
1154
1160
|
...C,
|
|
1155
1161
|
headerType: f,
|
|
@@ -1161,19 +1167,19 @@ function pa({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
1161
1167
|
var C;
|
|
1162
1168
|
return ((C = f.split("?")[0].split(".").pop()) == null ? void 0 : C.toLowerCase()) || "";
|
|
1163
1169
|
}, b = (f, C) => {
|
|
1164
|
-
const
|
|
1170
|
+
const T = M(f.name);
|
|
1165
1171
|
switch (C) {
|
|
1166
1172
|
case "IMAGE":
|
|
1167
|
-
if (!xe.includes(
|
|
1168
|
-
if (f.size >
|
|
1173
|
+
if (!xe.includes(T)) return "Invalid format. Only JPG, JPEG, PNG are allowed.";
|
|
1174
|
+
if (f.size > da) return "File is too large. Max size is 5 MB.";
|
|
1169
1175
|
break;
|
|
1170
1176
|
case "VIDEO":
|
|
1171
|
-
if (!pe.includes(
|
|
1172
|
-
if (f.size >
|
|
1177
|
+
if (!pe.includes(T)) return "Invalid format. Only MP4, 3GPP are allowed.";
|
|
1178
|
+
if (f.size > xa) return "File is too large. Max size is 16 MB.";
|
|
1173
1179
|
break;
|
|
1174
1180
|
case "DOCUMENT":
|
|
1175
|
-
if (!oe.includes(
|
|
1176
|
-
if (f.size >
|
|
1181
|
+
if (!oe.includes(T)) return "Invalid format. Allowed types: PDF, DOCX, XLSX, PPTX, TXT.";
|
|
1182
|
+
if (f.size > pa) return "File is too large. Max size is 100 MB.";
|
|
1177
1183
|
break;
|
|
1178
1184
|
default:
|
|
1179
1185
|
return "Invalid media type.";
|
|
@@ -1181,16 +1187,16 @@ function pa({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
1181
1187
|
return null;
|
|
1182
1188
|
}, y = (f, C) => {
|
|
1183
1189
|
if (!f) return null;
|
|
1184
|
-
const
|
|
1190
|
+
const T = M(f);
|
|
1185
1191
|
switch (C) {
|
|
1186
1192
|
case "IMAGE":
|
|
1187
|
-
if (!xe.includes(
|
|
1193
|
+
if (!xe.includes(T)) return "URL does not point to a valid image (JPG, JPEG, PNG).";
|
|
1188
1194
|
break;
|
|
1189
1195
|
case "VIDEO":
|
|
1190
|
-
if (!pe.includes(
|
|
1196
|
+
if (!pe.includes(T)) return "URL does not point to a valid video (MP4, 3GPP).";
|
|
1191
1197
|
break;
|
|
1192
1198
|
case "DOCUMENT":
|
|
1193
|
-
if (!oe.includes(
|
|
1199
|
+
if (!oe.includes(T)) return "URL does not point to a valid document.";
|
|
1194
1200
|
break;
|
|
1195
1201
|
}
|
|
1196
1202
|
return null;
|
|
@@ -1201,29 +1207,29 @@ function pa({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
1201
1207
|
const C = (O = f.target.files) == null ? void 0 : O[0];
|
|
1202
1208
|
if (!C || !a.mediaType) return;
|
|
1203
1209
|
k(null);
|
|
1204
|
-
const
|
|
1205
|
-
if (
|
|
1206
|
-
k(
|
|
1210
|
+
const T = b(C, a.mediaType);
|
|
1211
|
+
if (T) {
|
|
1212
|
+
k(T);
|
|
1207
1213
|
return;
|
|
1208
1214
|
}
|
|
1209
1215
|
l(!0), c(C);
|
|
1210
1216
|
try {
|
|
1211
|
-
const
|
|
1212
|
-
s({ ...a, mediaUrl:
|
|
1213
|
-
} catch (
|
|
1214
|
-
console.error("File upload failed:",
|
|
1215
|
-
const
|
|
1216
|
-
k(
|
|
1217
|
+
const z = await n(C);
|
|
1218
|
+
s({ ...a, mediaUrl: z });
|
|
1219
|
+
} catch (z) {
|
|
1220
|
+
console.error("File upload failed:", z), t();
|
|
1221
|
+
const $ = z instanceof Error ? z.message : "File upload failed. Please try again.";
|
|
1222
|
+
k($);
|
|
1217
1223
|
} finally {
|
|
1218
1224
|
l(!1);
|
|
1219
1225
|
}
|
|
1220
1226
|
}, p = (f) => {
|
|
1221
1227
|
const C = f.target.value;
|
|
1222
1228
|
if (c(null), s({ ...a, mediaUrl: C }), a.mediaType) {
|
|
1223
|
-
const
|
|
1224
|
-
k(
|
|
1229
|
+
const T = y(C, a.mediaType);
|
|
1230
|
+
k(T);
|
|
1225
1231
|
}
|
|
1226
|
-
},
|
|
1232
|
+
}, v = () => {
|
|
1227
1233
|
switch (a.mediaType) {
|
|
1228
1234
|
case "IMAGE":
|
|
1229
1235
|
return xe.map((f) => `.${f}`).join(",");
|
|
@@ -1243,9 +1249,9 @@ function pa({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
1243
1249
|
"select",
|
|
1244
1250
|
{
|
|
1245
1251
|
value: a.headerType,
|
|
1246
|
-
onChange: (f) =>
|
|
1252
|
+
onChange: (f) => w(f.target.value),
|
|
1247
1253
|
className: "rsp-w-full rsp-px-0 rsp-py-2 rsp-border-0 rsp-border-b rsp-border-gray-300 rsp-text-sm focus:rsp-outline-none focus:rsp-border-blue-500 rsp-bg-transparent rsp-appearance-none",
|
|
1248
|
-
children:
|
|
1254
|
+
children: ca.map((f) => /* @__PURE__ */ e("option", { value: f.value, children: f.label }, f.value))
|
|
1249
1255
|
}
|
|
1250
1256
|
),
|
|
1251
1257
|
/* @__PURE__ */ e("div", { className: "rsp-absolute rsp-inset-y-0 rsp-right-0 rsp-flex rsp-items-center rsp-px-2 rsp-pointer-events-none", children: /* @__PURE__ */ e("svg", { className: "rsp-w-4 rsp-h-4 rsp-text-gray-400", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 9l-7 7-7-7" }) }) }),
|
|
@@ -1286,7 +1292,7 @@ function pa({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
1286
1292
|
return f.length === 0 ? null : /* @__PURE__ */ r("div", { className: "rsp-mt-3", children: [
|
|
1287
1293
|
/* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-font-medium rsp-text-gray-600 rsp-mb-2", children: "Sample Values" }),
|
|
1288
1294
|
/* @__PURE__ */ e("div", { className: "rsp-grid rsp-grid-cols-3 rsp-gap-2", children: f.map((C) => {
|
|
1289
|
-
var
|
|
1295
|
+
var T, O;
|
|
1290
1296
|
return /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-2", children: [
|
|
1291
1297
|
/* @__PURE__ */ r("label", { className: "rsp-text-xs rsp-text-gray-500 rsp-whitespace-nowrap", children: [
|
|
1292
1298
|
`{{${C}}}`,
|
|
@@ -1296,16 +1302,16 @@ function pa({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
1296
1302
|
"input",
|
|
1297
1303
|
{
|
|
1298
1304
|
type: "text",
|
|
1299
|
-
value: ((O = (
|
|
1300
|
-
onChange: (
|
|
1305
|
+
value: ((O = (T = a.sampleContent) == null ? void 0 : T.headerVariables) == null ? void 0 : O[C]) || "",
|
|
1306
|
+
onChange: (z) => {
|
|
1301
1307
|
var m, E, S;
|
|
1302
|
-
const
|
|
1308
|
+
const $ = {
|
|
1303
1309
|
...a.sampleContent,
|
|
1304
|
-
headerVariables: { ...(m = a.sampleContent) == null ? void 0 : m.headerVariables, [C]:
|
|
1310
|
+
headerVariables: { ...(m = a.sampleContent) == null ? void 0 : m.headerVariables, [C]: z.target.value },
|
|
1305
1311
|
bodyVariables: ((E = a.sampleContent) == null ? void 0 : E.bodyVariables) || {},
|
|
1306
1312
|
buttonVariables: ((S = a.sampleContent) == null ? void 0 : S.buttonVariables) || {}
|
|
1307
1313
|
};
|
|
1308
|
-
s({ ...a, sampleContent:
|
|
1314
|
+
s({ ...a, sampleContent: $ });
|
|
1309
1315
|
},
|
|
1310
1316
|
className: "rsp-flex-1 rsp-px-2 rsp-py-1 rsp-border rsp-border-gray-300 rsp-rounded rsp-text-xs focus:rsp-outline-none focus:rsp-border-blue-500",
|
|
1311
1317
|
placeholder: "Sample"
|
|
@@ -1316,16 +1322,16 @@ function pa({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
1316
1322
|
{
|
|
1317
1323
|
type: "button",
|
|
1318
1324
|
onClick: () => {
|
|
1319
|
-
var E, S,
|
|
1320
|
-
const
|
|
1325
|
+
var E, S, V;
|
|
1326
|
+
const z = new RegExp(`\\{\\{${C}\\}\\}`, "g"), $ = (a.headerText || "").replace(z, ""), m = Object.fromEntries(Object.entries(((E = a.sampleContent) == null ? void 0 : E.headerVariables) || {}).filter(([I]) => I !== C));
|
|
1321
1327
|
s({
|
|
1322
1328
|
...a,
|
|
1323
|
-
headerText:
|
|
1329
|
+
headerText: $,
|
|
1324
1330
|
sampleContent: {
|
|
1325
1331
|
...a.sampleContent,
|
|
1326
1332
|
headerVariables: m,
|
|
1327
1333
|
bodyVariables: ((S = a.sampleContent) == null ? void 0 : S.bodyVariables) || {},
|
|
1328
|
-
buttonVariables: ((
|
|
1334
|
+
buttonVariables: ((V = a.sampleContent) == null ? void 0 : V.buttonVariables) || {}
|
|
1329
1335
|
}
|
|
1330
1336
|
});
|
|
1331
1337
|
},
|
|
@@ -1355,7 +1361,7 @@ function pa({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
1355
1361
|
})), c(null), k(null);
|
|
1356
1362
|
},
|
|
1357
1363
|
className: "rsp-w-full rsp-px-0 rsp-py-2 rsp-border-0 rsp-border-b rsp-border-gray-300 rsp-text-sm focus:rsp-outline-none focus:rsp-border-blue-500 rsp-bg-transparent rsp-appearance-none",
|
|
1358
|
-
children:
|
|
1364
|
+
children: ma.map((f) => /* @__PURE__ */ e("option", { value: f.value, children: f.label }, f.value))
|
|
1359
1365
|
}
|
|
1360
1366
|
),
|
|
1361
1367
|
/* @__PURE__ */ e("div", { className: "rsp-absolute rsp-inset-y-0 rsp-right-0 rsp-flex rsp-items-center rsp-px-2 rsp-pointer-events-none", children: /* @__PURE__ */ e("svg", { className: "rsp-w-4 rsp-h-4 rsp-text-gray-400", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 9l-7 7-7-7" }) }) })
|
|
@@ -1372,31 +1378,31 @@ function pa({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
1372
1378
|
alt: "Preview",
|
|
1373
1379
|
className: "rsp-w-12 rsp-h-12 rsp-object-cover rsp-rounded",
|
|
1374
1380
|
onError: (f) => {
|
|
1375
|
-
f.currentTarget.style.display = "none",
|
|
1381
|
+
f.currentTarget.style.display = "none", o || k("Could not load image preview from URL.");
|
|
1376
1382
|
},
|
|
1377
1383
|
onLoad: () => {
|
|
1378
|
-
|
|
1384
|
+
o != null && o.includes("Could not load") && k(null);
|
|
1379
1385
|
}
|
|
1380
1386
|
}
|
|
1381
1387
|
),
|
|
1382
|
-
a.mediaType === "VIDEO" && /* @__PURE__ */ e("div", { className: "rsp-w-12 rsp-h-12 rsp-bg-gray-200 rsp-rounded rsp-flex rsp-items-center rsp-justify-center flex-shrink-0", children: /* @__PURE__ */ e(
|
|
1383
|
-
a.mediaType === "DOCUMENT" && /* @__PURE__ */ e("div", { className: "rsp-w-12 rsp-h-12 rsp-bg-gray-200 rsp-rounded rsp-flex rsp-items-center rsp-justify-center flex-shrink-0", children: /* @__PURE__ */ e(
|
|
1388
|
+
a.mediaType === "VIDEO" && /* @__PURE__ */ e("div", { className: "rsp-w-12 rsp-h-12 rsp-bg-gray-200 rsp-rounded rsp-flex rsp-items-center rsp-justify-center flex-shrink-0", children: /* @__PURE__ */ e(Ge, { className: "rsp-w-6 rsp-h-6 rsp-text-gray-500" }) }),
|
|
1389
|
+
a.mediaType === "DOCUMENT" && /* @__PURE__ */ e("div", { className: "rsp-w-12 rsp-h-12 rsp-bg-gray-200 rsp-rounded rsp-flex rsp-items-center rsp-justify-center flex-shrink-0", children: /* @__PURE__ */ e($e, { className: "rsp-w-6 rsp-h-6 rsp-text-gray-500" }) }),
|
|
1384
1390
|
/* @__PURE__ */ r("div", { className: "overflow-hidden", children: [
|
|
1385
1391
|
/* @__PURE__ */ e("p", { className: "rsp-text-sm rsp-font-medium rsp-text-gray-900 rsp-truncate", children: i ? i.name : a.mediaUrl }),
|
|
1386
1392
|
i && /* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-gray-500", children: `${(i.size / 1024 / 1024).toFixed(2)} MB` })
|
|
1387
1393
|
] })
|
|
1388
1394
|
] }),
|
|
1389
|
-
/* @__PURE__ */ e("button", { onClick: t, className: "rsp-p-1 rsp-text-gray-400 hover:rsp-text-red-500 rsp-transition-colors flex-shrink-0", children: /* @__PURE__ */ e(
|
|
1395
|
+
/* @__PURE__ */ e("button", { onClick: t, className: "rsp-p-1 rsp-text-gray-400 hover:rsp-text-red-500 rsp-transition-colors flex-shrink-0", children: /* @__PURE__ */ e(se, { className: "rsp-w-4 rsp-h-4" }) })
|
|
1390
1396
|
] }) : /* @__PURE__ */ r("div", { children: [
|
|
1391
|
-
/* @__PURE__ */ e("input", { type: "file", accept:
|
|
1397
|
+
/* @__PURE__ */ e("input", { type: "file", accept: v(), onChange: x, className: "rsp-hidden", id: "media-upload", disabled: h }),
|
|
1392
1398
|
/* @__PURE__ */ r(
|
|
1393
1399
|
"label",
|
|
1394
1400
|
{
|
|
1395
1401
|
htmlFor: "media-upload",
|
|
1396
|
-
className: `rsp-w-full rsp-px-4 rsp-py-3 rsp-border-2 rsp-border-dashed rsp-border-gray-300 rsp-rounded-md rsp-flex rsp-flex-col rsp-items-center rsp-justify-center rsp-cursor-pointer rsp-transition-colors hover:rsp-border-gray-400 hover:rsp-bg-gray-50 ${
|
|
1402
|
+
className: `rsp-w-full rsp-px-4 rsp-py-3 rsp-border-2 rsp-border-dashed rsp-border-gray-300 rsp-rounded-md rsp-flex rsp-flex-col rsp-items-center rsp-justify-center rsp-cursor-pointer rsp-transition-colors hover:rsp-border-gray-400 hover:rsp-bg-gray-50 ${h ? "rsp-opacity-50 rsp-cursor-not-allowed" : ""}`,
|
|
1397
1403
|
children: [
|
|
1398
|
-
/* @__PURE__ */ e(
|
|
1399
|
-
/* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-text-gray-600", children:
|
|
1404
|
+
/* @__PURE__ */ e(Ye, { className: "rsp-w-6 rsp-h-6 rsp-text-gray-400 rsp-mb-2" }),
|
|
1405
|
+
/* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-text-gray-600", children: h ? "Uploading..." : `Upload ${((j = a.mediaType) == null ? void 0 : j.toLowerCase()) || "file"}` }),
|
|
1400
1406
|
/* @__PURE__ */ r("span", { className: "rsp-text-xs rsp-text-gray-400 rsp-mt-1", children: [
|
|
1401
1407
|
a.mediaType === "IMAGE" && "JPG, PNG up to 5MB",
|
|
1402
1408
|
a.mediaType === "VIDEO" && "MP4, 3GPP up to 16MB",
|
|
@@ -1406,9 +1412,9 @@ function pa({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
1406
1412
|
}
|
|
1407
1413
|
)
|
|
1408
1414
|
] }),
|
|
1409
|
-
|
|
1410
|
-
/* @__PURE__ */ e(
|
|
1411
|
-
/* @__PURE__ */ e("span", { children:
|
|
1415
|
+
o && /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-2 rsp-text-xs rsp-text-red-600", children: [
|
|
1416
|
+
/* @__PURE__ */ e(he, { className: "rsp-w-4 rsp-h-4" }),
|
|
1417
|
+
/* @__PURE__ */ e("span", { children: o })
|
|
1412
1418
|
] }),
|
|
1413
1419
|
/* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center", children: [
|
|
1414
1420
|
/* @__PURE__ */ e("div", { className: "rsp-flex-1 rsp-border-t rsp-border-gray-300" }),
|
|
@@ -1429,7 +1435,7 @@ function pa({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
1429
1435
|
] })
|
|
1430
1436
|
] });
|
|
1431
1437
|
}
|
|
1432
|
-
const
|
|
1438
|
+
const Le = [
|
|
1433
1439
|
{ name: "grinning-face", hexadecimal: "😀" },
|
|
1434
1440
|
{ name: "grinning-face-with-smiling-eyes", hexadecimal: "😁" },
|
|
1435
1441
|
{ name: "face-with-tears-of-joy", hexadecimal: "😂" },
|
|
@@ -3228,29 +3234,29 @@ const Ee = [
|
|
|
3228
3234
|
{ name: "south-africa", hexadecimal: "🇿🇦" },
|
|
3229
3235
|
{ name: "zambia", hexadecimal: "🇿🇲" },
|
|
3230
3236
|
{ name: "zimbabwe", hexadecimal: "🇿🇼" }
|
|
3231
|
-
],
|
|
3237
|
+
], fa = ({
|
|
3232
3238
|
emojis: a,
|
|
3233
3239
|
onSelect: s,
|
|
3234
3240
|
onClose: n
|
|
3235
3241
|
}) => {
|
|
3236
|
-
const [i, c] = B({ start: 0, end: 80 }),
|
|
3237
|
-
const
|
|
3238
|
-
M + Math.ceil(
|
|
3239
|
-
Math.ceil(a.length /
|
|
3242
|
+
const [i, c] = B({ start: 0, end: 80 }), h = 8, l = 40, N = 400, g = Ce((d) => {
|
|
3243
|
+
const w = d.currentTarget.scrollTop, M = Math.floor(w / l), b = Math.min(
|
|
3244
|
+
M + Math.ceil(N / l) + 2,
|
|
3245
|
+
Math.ceil(a.length / h)
|
|
3240
3246
|
);
|
|
3241
3247
|
c({
|
|
3242
|
-
start: M *
|
|
3243
|
-
end: b *
|
|
3248
|
+
start: M * h,
|
|
3249
|
+
end: b * h
|
|
3244
3250
|
});
|
|
3245
|
-
}, [a.length, l,
|
|
3246
|
-
const
|
|
3247
|
-
if (!
|
|
3248
|
-
const M =
|
|
3251
|
+
}, [a.length, l, N, h]), o = Ce((d) => {
|
|
3252
|
+
const w = d.match(/&#x([0-9A-Fa-f]+);/g);
|
|
3253
|
+
if (!w) return "";
|
|
3254
|
+
const M = w.map((b) => {
|
|
3249
3255
|
const y = b.replace(/&#x|;/g, "");
|
|
3250
3256
|
return parseInt(y, 16);
|
|
3251
3257
|
});
|
|
3252
3258
|
return String.fromCodePoint(...M);
|
|
3253
|
-
}, []), k = Math.ceil(a.length /
|
|
3259
|
+
}, []), k = Math.ceil(a.length / h) * l, A = a.slice(i.start, i.end);
|
|
3254
3260
|
return /* @__PURE__ */ e(
|
|
3255
3261
|
"div",
|
|
3256
3262
|
{
|
|
@@ -3261,21 +3267,21 @@ const Ee = [
|
|
|
3261
3267
|
{
|
|
3262
3268
|
className: "rsp-absolute rsp-w-full rsp-grid rsp-grid-cols-8 rsp-gap-1",
|
|
3263
3269
|
style: {
|
|
3264
|
-
top: Math.floor(i.start /
|
|
3270
|
+
top: Math.floor(i.start / h) * l,
|
|
3265
3271
|
transform: "translateY(0px)"
|
|
3266
3272
|
},
|
|
3267
|
-
children:
|
|
3268
|
-
const M = i.start +
|
|
3273
|
+
children: A.map((d, w) => {
|
|
3274
|
+
const M = i.start + w;
|
|
3269
3275
|
return /* @__PURE__ */ e(
|
|
3270
3276
|
"button",
|
|
3271
3277
|
{
|
|
3272
3278
|
onClick: () => {
|
|
3273
|
-
s(
|
|
3279
|
+
s(o(d.hexadecimal));
|
|
3274
3280
|
},
|
|
3275
3281
|
className: "rsp-w-10 rsp-h-10 rsp-flex rsp-items-center rsp-justify-center rsp-text-xl hover:rsp-bg-gray-100 rsp-rounded rsp-transition-colors",
|
|
3276
3282
|
title: d.name,
|
|
3277
3283
|
style: { height: l },
|
|
3278
|
-
children:
|
|
3284
|
+
children: o(d.hexadecimal)
|
|
3279
3285
|
},
|
|
3280
3286
|
M
|
|
3281
3287
|
);
|
|
@@ -3285,10 +3291,10 @@ const Ee = [
|
|
|
3285
3291
|
}
|
|
3286
3292
|
);
|
|
3287
3293
|
};
|
|
3288
|
-
function
|
|
3289
|
-
const [i, c] = B(""),
|
|
3294
|
+
function we({ isOpen: a, onClose: s, onSelect: n }) {
|
|
3295
|
+
const [i, c] = B(""), h = Ve(() => i ? Le.filter(
|
|
3290
3296
|
(l) => l.name.toLowerCase().includes(i.toLowerCase())
|
|
3291
|
-
) :
|
|
3297
|
+
) : Le, [i]);
|
|
3292
3298
|
return X.useEffect(() => {
|
|
3293
3299
|
a || c("");
|
|
3294
3300
|
}, [a]), /* @__PURE__ */ e(te, { isOpen: a, onClose: s, title: "Select Emoji", children: /* @__PURE__ */ r("div", { className: "rsp-space-y-4", children: [
|
|
@@ -3324,32 +3330,32 @@ function ye({ isOpen: a, onClose: s, onSelect: n }) {
|
|
|
3324
3330
|
l
|
|
3325
3331
|
)) }),
|
|
3326
3332
|
/* @__PURE__ */ r("div", { className: "rsp-text-sm rsp-text-gray-500", children: [
|
|
3327
|
-
|
|
3333
|
+
h.length,
|
|
3328
3334
|
" emojis found"
|
|
3329
3335
|
] }),
|
|
3330
3336
|
/* @__PURE__ */ e(
|
|
3331
|
-
|
|
3337
|
+
fa,
|
|
3332
3338
|
{
|
|
3333
|
-
emojis:
|
|
3339
|
+
emojis: h,
|
|
3334
3340
|
onSelect: n,
|
|
3335
3341
|
onClose: s
|
|
3336
3342
|
}
|
|
3337
3343
|
)
|
|
3338
3344
|
] }) });
|
|
3339
3345
|
}
|
|
3340
|
-
function
|
|
3341
|
-
const [n, i] = B(!1), [c,
|
|
3346
|
+
function ha({ template: a, setTemplate: s }) {
|
|
3347
|
+
const [n, i] = B(!1), [c, h] = B(null), [l, N] = B(null), [g, o] = B(null), [k, A] = B(!1), d = () => {
|
|
3342
3348
|
const t = (a.body || "").match(/{{\d+}}/g);
|
|
3343
3349
|
if (!t) return 0;
|
|
3344
3350
|
const x = t.map((p) => {
|
|
3345
|
-
const
|
|
3346
|
-
return
|
|
3351
|
+
const v = p.match(/{{(\d+)}}/);
|
|
3352
|
+
return v ? parseInt(v[1], 10) : 0;
|
|
3347
3353
|
});
|
|
3348
3354
|
return x.length > 0 ? Math.max(...x) : 0;
|
|
3349
|
-
},
|
|
3355
|
+
}, w = () => {
|
|
3350
3356
|
const x = `{{${d() + 1}}}`;
|
|
3351
3357
|
if (l && a.body.length + x.length <= 1024) {
|
|
3352
|
-
const p = l.selectionStart || a.body.length,
|
|
3358
|
+
const p = l.selectionStart || a.body.length, v = a.body.substring(0, p), j = a.body.substring(p), R = v + x + j;
|
|
3353
3359
|
s({
|
|
3354
3360
|
...a,
|
|
3355
3361
|
body: R
|
|
@@ -3361,7 +3367,7 @@ function fa({ template: a, setTemplate: s }) {
|
|
|
3361
3367
|
}, 0);
|
|
3362
3368
|
}
|
|
3363
3369
|
}, M = () => {
|
|
3364
|
-
|
|
3370
|
+
h("body"), i(!0), setTimeout(() => {
|
|
3365
3371
|
l && l.focus();
|
|
3366
3372
|
}, 0);
|
|
3367
3373
|
}, b = (y) => {
|
|
@@ -3369,7 +3375,7 @@ function fa({ template: a, setTemplate: s }) {
|
|
|
3369
3375
|
if (!l) return;
|
|
3370
3376
|
const t = l.selectionStart || a.body.length, x = 1024, p = a.body;
|
|
3371
3377
|
if (p.length + y.length <= x) {
|
|
3372
|
-
const
|
|
3378
|
+
const v = p.substring(0, t), j = p.substring(t), R = v + y + j;
|
|
3373
3379
|
s({
|
|
3374
3380
|
...a,
|
|
3375
3381
|
body: R
|
|
@@ -3384,7 +3390,7 @@ function fa({ template: a, setTemplate: s }) {
|
|
|
3384
3390
|
if (!g) return;
|
|
3385
3391
|
const t = g.selectionStart || a.footer.length, x = 60, p = a.footer;
|
|
3386
3392
|
if (p.length + y.length <= x) {
|
|
3387
|
-
const
|
|
3393
|
+
const v = p.substring(0, t), j = p.substring(t), R = v + y + j;
|
|
3388
3394
|
s({
|
|
3389
3395
|
...a,
|
|
3390
3396
|
footer: R
|
|
@@ -3403,15 +3409,15 @@ function fa({ template: a, setTemplate: s }) {
|
|
|
3403
3409
|
/* @__PURE__ */ e("div", { className: "rsp-relative", children: /* @__PURE__ */ e(
|
|
3404
3410
|
"textarea",
|
|
3405
3411
|
{
|
|
3406
|
-
ref:
|
|
3412
|
+
ref: N,
|
|
3407
3413
|
value: a.body,
|
|
3408
3414
|
onChange: (y) => s({ ...a, body: y.target.value }),
|
|
3409
3415
|
maxLength: 1024,
|
|
3410
3416
|
rows: 6,
|
|
3411
3417
|
className: "rsp-w-full rsp-px-3 rsp-py-2 rsp-border rsp-border-gray-300 rsp-rounded-md rsp-text-sm focus:rsp-outline-none focus:rsp-border-blue-500 rsp-bg-white rsp-resize-none rsp-shadow-sm",
|
|
3412
3418
|
placeholder: "Enter the text for your message",
|
|
3413
|
-
onFocus: () =>
|
|
3414
|
-
onBlur: () =>
|
|
3419
|
+
onFocus: () => h("body"),
|
|
3420
|
+
onBlur: () => A(!0)
|
|
3415
3421
|
}
|
|
3416
3422
|
) }),
|
|
3417
3423
|
!a.body && k && /* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-red-600 rsp-mt-1", children: "Body is required." }),
|
|
@@ -3420,7 +3426,7 @@ function fa({ template: a, setTemplate: s }) {
|
|
|
3420
3426
|
/* @__PURE__ */ e(
|
|
3421
3427
|
"button",
|
|
3422
3428
|
{
|
|
3423
|
-
onClick:
|
|
3429
|
+
onClick: w,
|
|
3424
3430
|
className: "rsp-p-1 rsp-text-gray-500 hover:rsp-text-gray-700 hover:rsp-bg-gray-100 rsp-rounded",
|
|
3425
3431
|
title: "Add Variable",
|
|
3426
3432
|
children: /* @__PURE__ */ e("svg", { className: "rsp-w-4 rsp-h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" }) })
|
|
@@ -3432,7 +3438,7 @@ function fa({ template: a, setTemplate: s }) {
|
|
|
3432
3438
|
onClick: M,
|
|
3433
3439
|
className: "rsp-p-1 rsp-text-gray-500 hover:rsp-text-gray-700 hover:rsp-bg-gray-100 rsp-rounded",
|
|
3434
3440
|
title: "Add emoji",
|
|
3435
|
-
children: /* @__PURE__ */ e(
|
|
3441
|
+
children: /* @__PURE__ */ e(be, { className: "rsp-w-4 rsp-h-4" })
|
|
3436
3442
|
}
|
|
3437
3443
|
)
|
|
3438
3444
|
] }),
|
|
@@ -3446,7 +3452,7 @@ function fa({ template: a, setTemplate: s }) {
|
|
|
3446
3452
|
return t.length === 0 ? null : /* @__PURE__ */ r("div", { className: "rsp-mt-3", children: [
|
|
3447
3453
|
/* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-font-medium rsp-text-gray-600 rsp-mb-2", children: "Sample Values" }),
|
|
3448
3454
|
/* @__PURE__ */ e("div", { className: "rsp-grid rsp-grid-cols-3 rsp-gap-2", children: t.map((x) => {
|
|
3449
|
-
var p,
|
|
3455
|
+
var p, v;
|
|
3450
3456
|
return /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-2", children: [
|
|
3451
3457
|
/* @__PURE__ */ r("label", { className: "rsp-text-xs rsp-text-gray-500 rsp-whitespace-nowrap", children: [
|
|
3452
3458
|
"{{",
|
|
@@ -3458,17 +3464,17 @@ function fa({ template: a, setTemplate: s }) {
|
|
|
3458
3464
|
"input",
|
|
3459
3465
|
{
|
|
3460
3466
|
type: "text",
|
|
3461
|
-
value: ((
|
|
3462
|
-
onChange: (
|
|
3463
|
-
var f, C,
|
|
3467
|
+
value: ((v = (p = a.sampleContent) == null ? void 0 : p.bodyVariables) == null ? void 0 : v[x]) || "",
|
|
3468
|
+
onChange: (j) => {
|
|
3469
|
+
var f, C, T;
|
|
3464
3470
|
const R = {
|
|
3465
3471
|
...a.sampleContent,
|
|
3466
3472
|
bodyVariables: {
|
|
3467
3473
|
...(f = a.sampleContent) == null ? void 0 : f.bodyVariables,
|
|
3468
|
-
[x]:
|
|
3474
|
+
[x]: j.target.value
|
|
3469
3475
|
},
|
|
3470
3476
|
headerVariables: ((C = a.sampleContent) == null ? void 0 : C.headerVariables) || {},
|
|
3471
|
-
buttonVariables: ((
|
|
3477
|
+
buttonVariables: ((T = a.sampleContent) == null ? void 0 : T.buttonVariables) || {}
|
|
3472
3478
|
};
|
|
3473
3479
|
s({
|
|
3474
3480
|
...a,
|
|
@@ -3484,15 +3490,15 @@ function fa({ template: a, setTemplate: s }) {
|
|
|
3484
3490
|
{
|
|
3485
3491
|
type: "button",
|
|
3486
3492
|
onClick: () => {
|
|
3487
|
-
var C,
|
|
3488
|
-
const
|
|
3493
|
+
var C, T, O;
|
|
3494
|
+
const j = new RegExp(`\\{\\{${x}\\}\\}`, "g"), R = (a.body || "").replace(j, ""), f = Object.fromEntries(Object.entries(((C = a.sampleContent) == null ? void 0 : C.bodyVariables) || {}).filter(([z]) => z !== x));
|
|
3489
3495
|
s({
|
|
3490
3496
|
...a,
|
|
3491
3497
|
body: R,
|
|
3492
3498
|
sampleContent: {
|
|
3493
3499
|
...a.sampleContent,
|
|
3494
3500
|
bodyVariables: f,
|
|
3495
|
-
headerVariables: ((
|
|
3501
|
+
headerVariables: ((T = a.sampleContent) == null ? void 0 : T.headerVariables) || {},
|
|
3496
3502
|
buttonVariables: ((O = a.sampleContent) == null ? void 0 : O.buttonVariables) || {}
|
|
3497
3503
|
}
|
|
3498
3504
|
});
|
|
@@ -3512,14 +3518,14 @@ function fa({ template: a, setTemplate: s }) {
|
|
|
3512
3518
|
/* @__PURE__ */ e("div", { className: "rsp-relative", children: /* @__PURE__ */ e(
|
|
3513
3519
|
"input",
|
|
3514
3520
|
{
|
|
3515
|
-
ref:
|
|
3521
|
+
ref: o,
|
|
3516
3522
|
type: "text",
|
|
3517
3523
|
value: a.footer,
|
|
3518
3524
|
onChange: (y) => s({ ...a, footer: y.target.value }),
|
|
3519
3525
|
maxLength: 60,
|
|
3520
3526
|
className: "rsp-w-full rsp-px-0 rsp-py-2 rsp-border-0 rsp-border-b rsp-border-gray-300 rsp-text-sm focus:rsp-outline-none focus:rsp-border-blue-500 rsp-bg-transparent",
|
|
3521
3527
|
placeholder: "Footer Text",
|
|
3522
|
-
onFocus: () =>
|
|
3528
|
+
onFocus: () => h("footer")
|
|
3523
3529
|
}
|
|
3524
3530
|
) }),
|
|
3525
3531
|
/* @__PURE__ */ r("p", { className: "rsp-text-xs rsp-text-gray-500 rsp-mt-1", children: [
|
|
@@ -3528,7 +3534,7 @@ function fa({ template: a, setTemplate: s }) {
|
|
|
3528
3534
|
] })
|
|
3529
3535
|
] }),
|
|
3530
3536
|
/* @__PURE__ */ e(
|
|
3531
|
-
|
|
3537
|
+
we,
|
|
3532
3538
|
{
|
|
3533
3539
|
isOpen: n,
|
|
3534
3540
|
onClose: () => i(!1),
|
|
@@ -3537,20 +3543,20 @@ function fa({ template: a, setTemplate: s }) {
|
|
|
3537
3543
|
)
|
|
3538
3544
|
] });
|
|
3539
3545
|
}
|
|
3540
|
-
function
|
|
3546
|
+
function ua({ template: a, setTemplate: s }) {
|
|
3541
3547
|
var y;
|
|
3542
|
-
const [n, i] = B(null), [c,
|
|
3548
|
+
const [n, i] = B(null), [c, h] = B(!1), [l, N] = B({
|
|
3543
3549
|
text: "",
|
|
3544
3550
|
value: "",
|
|
3545
3551
|
urlType: "static"
|
|
3546
|
-
}),
|
|
3552
|
+
}), o = {
|
|
3547
3553
|
quickReply: a.buttons.filter((t) => t.type === "QUICK_REPLY").length,
|
|
3548
3554
|
url: a.buttons.filter((t) => t.type === "URL").length,
|
|
3549
3555
|
call: a.buttons.filter((t) => t.type === "CALL").length,
|
|
3550
3556
|
flow: a.buttons.filter((t) => t.type === "FLOW").length
|
|
3551
3557
|
}, k = () => {
|
|
3552
|
-
|
|
3553
|
-
},
|
|
3558
|
+
N({ text: "", value: "", urlType: "static" }), i(null), h(!1);
|
|
3559
|
+
}, A = (t) => {
|
|
3554
3560
|
if (!l.text.trim()) return;
|
|
3555
3561
|
let x = t === "QUICK_REPLY" ? l.text : l.value;
|
|
3556
3562
|
t === "CALL" && x && !x.startsWith("+") && (x = "+" + x);
|
|
@@ -3570,10 +3576,10 @@ function ha({ template: a, setTemplate: s }) {
|
|
|
3570
3576
|
...a,
|
|
3571
3577
|
buttons: a.buttons.filter((x) => x.id !== t)
|
|
3572
3578
|
});
|
|
3573
|
-
},
|
|
3574
|
-
const
|
|
3575
|
-
let R = p.slice(0,
|
|
3576
|
-
x === "value" && (
|
|
3579
|
+
}, w = (t, x, p) => {
|
|
3580
|
+
const v = a.buttons.find((f) => f.id === t), j = x === "text" ? 25 : x === "value" && (v == null ? void 0 : v.type) === "URL" ? 2e3 : 20;
|
|
3581
|
+
let R = p.slice(0, j);
|
|
3582
|
+
x === "value" && (v == null ? void 0 : v.type) === "CALL" && R && !R.startsWith("+") && (R = "+" + R), s({
|
|
3577
3583
|
...a,
|
|
3578
3584
|
buttons: a.buttons.map(
|
|
3579
3585
|
(f) => f.id === t ? { ...f, [x]: R } : f
|
|
@@ -3581,14 +3587,14 @@ function ha({ template: a, setTemplate: s }) {
|
|
|
3581
3587
|
});
|
|
3582
3588
|
}, M = () => {
|
|
3583
3589
|
const x = [
|
|
3584
|
-
...a.buttons.filter((
|
|
3590
|
+
...a.buttons.filter((v) => v.type === "URL" && v.urlType === "dynamic").map((v) => v.value || ""),
|
|
3585
3591
|
l.value
|
|
3586
3592
|
// Include current form input
|
|
3587
3593
|
].join(" ").match(/{{\d+}}/g);
|
|
3588
3594
|
if (!x) return 0;
|
|
3589
|
-
const p = x.map((
|
|
3590
|
-
const
|
|
3591
|
-
return
|
|
3595
|
+
const p = x.map((v) => {
|
|
3596
|
+
const j = v.match(/{{(\d+)}}/);
|
|
3597
|
+
return j ? parseInt(j[1], 10) : 0;
|
|
3592
3598
|
});
|
|
3593
3599
|
return p.length > 0 ? Math.max(...p) : 0;
|
|
3594
3600
|
}, b = [
|
|
@@ -3598,25 +3604,25 @@ function ha({ template: a, setTemplate: s }) {
|
|
|
3598
3604
|
label: "Quick Reply",
|
|
3599
3605
|
description: "Add quick response options",
|
|
3600
3606
|
limit: 10,
|
|
3601
|
-
current:
|
|
3607
|
+
current: o.quickReply,
|
|
3602
3608
|
color: "blue"
|
|
3603
3609
|
},
|
|
3604
3610
|
{
|
|
3605
3611
|
type: "URL",
|
|
3606
|
-
icon:
|
|
3612
|
+
icon: He,
|
|
3607
3613
|
label: "Web URL",
|
|
3608
3614
|
description: "Link to websites or pages",
|
|
3609
3615
|
limit: 2,
|
|
3610
|
-
current:
|
|
3616
|
+
current: o.url,
|
|
3611
3617
|
color: "green"
|
|
3612
3618
|
},
|
|
3613
3619
|
{
|
|
3614
3620
|
type: "CALL",
|
|
3615
|
-
icon:
|
|
3621
|
+
icon: Ae,
|
|
3616
3622
|
label: "Call Button",
|
|
3617
3623
|
description: "Add phone number to call",
|
|
3618
3624
|
limit: 1,
|
|
3619
|
-
current:
|
|
3625
|
+
current: o.call,
|
|
3620
3626
|
color: "purple"
|
|
3621
3627
|
}
|
|
3622
3628
|
// {
|
|
@@ -3663,7 +3669,7 @@ function ha({ template: a, setTemplate: s }) {
|
|
|
3663
3669
|
"/",
|
|
3664
3670
|
t.limit
|
|
3665
3671
|
] }),
|
|
3666
|
-
!p && /* @__PURE__ */ e(
|
|
3672
|
+
!p && /* @__PURE__ */ e(ue, { className: "rsp-w-4 rsp-h-4" })
|
|
3667
3673
|
] })
|
|
3668
3674
|
] })
|
|
3669
3675
|
},
|
|
@@ -3681,7 +3687,7 @@ function ha({ template: a, setTemplate: s }) {
|
|
|
3681
3687
|
{
|
|
3682
3688
|
onClick: k,
|
|
3683
3689
|
className: "rsp-p-2 rsp-text-gray-400 hover:rsp-text-gray-600 hover:rsp-bg-white rsp-rounded-lg rsp-transition-colors",
|
|
3684
|
-
children: /* @__PURE__ */ e(
|
|
3690
|
+
children: /* @__PURE__ */ e(se, { className: "rsp-w-5 rsp-h-5" })
|
|
3685
3691
|
}
|
|
3686
3692
|
)
|
|
3687
3693
|
] }),
|
|
@@ -3694,7 +3700,7 @@ function ha({ template: a, setTemplate: s }) {
|
|
|
3694
3700
|
{
|
|
3695
3701
|
type: "text",
|
|
3696
3702
|
value: l.text,
|
|
3697
|
-
onChange: (t) =>
|
|
3703
|
+
onChange: (t) => N({ ...l, text: t.target.value.slice(0, 25) }),
|
|
3698
3704
|
className: "rsp-w-full rsp-px-4 rsp-py-3 rsp-border rsp-border-gray-300 rsp-rounded-lg rsp-bg-white rsp-text-sm focus:rsp-outline-none focus:rsp-ring-2 focus:rsp-ring-blue-500 focus:rsp-border-transparent rsp-shadow-sm",
|
|
3699
3705
|
placeholder: "Enter button text (max 25 characters)",
|
|
3700
3706
|
maxLength: 25
|
|
@@ -3716,7 +3722,7 @@ function ha({ template: a, setTemplate: s }) {
|
|
|
3716
3722
|
{
|
|
3717
3723
|
type: "radio",
|
|
3718
3724
|
checked: l.urlType === "static",
|
|
3719
|
-
onChange: () =>
|
|
3725
|
+
onChange: () => N({ ...l, urlType: "static" }),
|
|
3720
3726
|
className: "rsp-mr-2 rsp-text-blue-600"
|
|
3721
3727
|
}
|
|
3722
3728
|
),
|
|
@@ -3728,7 +3734,7 @@ function ha({ template: a, setTemplate: s }) {
|
|
|
3728
3734
|
{
|
|
3729
3735
|
type: "radio",
|
|
3730
3736
|
checked: l.urlType === "dynamic",
|
|
3731
|
-
onChange: () =>
|
|
3737
|
+
onChange: () => N({ ...l, urlType: "dynamic" }),
|
|
3732
3738
|
className: "rsp-mr-2 rsp-text-blue-600"
|
|
3733
3739
|
}
|
|
3734
3740
|
),
|
|
@@ -3753,7 +3759,7 @@ function ha({ template: a, setTemplate: s }) {
|
|
|
3753
3759
|
value: l.value,
|
|
3754
3760
|
onChange: (t) => {
|
|
3755
3761
|
const x = n === "URL" ? 2e3 : 20;
|
|
3756
|
-
|
|
3762
|
+
N({ ...l, value: t.target.value.slice(0, x) });
|
|
3757
3763
|
},
|
|
3758
3764
|
className: "rsp-w-full rsp-px-4 rsp-py-3 rsp-border rsp-border-gray-300 rsp-rounded-lg rsp-bg-white rsp-text-sm focus:rsp-outline-none focus:rsp-ring-2 focus:rsp-ring-blue-500 focus:rsp-border-transparent rsp-shadow-sm",
|
|
3759
3765
|
placeholder: n === "URL" ? l.urlType === "dynamic" ? "https://example.com/order/{{1}}?user={{2}}" : "https://example.com" : n === "CALL" ? "+1234567890" : "Flow ID",
|
|
@@ -3773,8 +3779,8 @@ function ha({ template: a, setTemplate: s }) {
|
|
|
3773
3779
|
type: "button",
|
|
3774
3780
|
onClick: () => {
|
|
3775
3781
|
if ((l.value.match(/\{\{(\d+)\}\}/g) || []).length >= 3) return;
|
|
3776
|
-
const p = M() + 1,
|
|
3777
|
-
|
|
3782
|
+
const p = M() + 1, v = l.value + `{{${p}}}`;
|
|
3783
|
+
N({ ...l, value: v }), h(!0);
|
|
3778
3784
|
},
|
|
3779
3785
|
disabled: (l.value.match(/\{\{(\d+)\}\}/g) || []).length >= 3,
|
|
3780
3786
|
className: "rsp-px-2 rsp-py-2 rsp-text-xs rsp-bg-gray-300 hover:rsp-bg-gray-200 rsp-rounded rsp-text-gray-700 disabled:rsp-bg-gray-200 disabled:rsp-text-gray-500",
|
|
@@ -3787,7 +3793,7 @@ function ha({ template: a, setTemplate: s }) {
|
|
|
3787
3793
|
/* @__PURE__ */ e("div", { className: "rsp-space-y-3", children: (() => {
|
|
3788
3794
|
const t = l.value.match(/\{\{(\d+)\}\}/g) || [];
|
|
3789
3795
|
return [...new Set(t.map((p) => p.replace(/[{}]/g, "")))].map((p) => {
|
|
3790
|
-
var
|
|
3796
|
+
var v, j;
|
|
3791
3797
|
return /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-2", children: [
|
|
3792
3798
|
/* @__PURE__ */ r("label", { className: "rsp-text-sm rsp-text-gray-600 rsp-whitespace-nowrap", children: [
|
|
3793
3799
|
"Variable {{",
|
|
@@ -3798,13 +3804,13 @@ function ha({ template: a, setTemplate: s }) {
|
|
|
3798
3804
|
"input",
|
|
3799
3805
|
{
|
|
3800
3806
|
type: "text",
|
|
3801
|
-
value: ((
|
|
3807
|
+
value: ((j = (v = a.sampleContent) == null ? void 0 : v.buttonVariables) == null ? void 0 : j[p]) || "",
|
|
3802
3808
|
onChange: (R) => {
|
|
3803
|
-
var C,
|
|
3809
|
+
var C, T, O;
|
|
3804
3810
|
const f = {
|
|
3805
3811
|
...a.sampleContent,
|
|
3806
3812
|
headerVariables: ((C = a.sampleContent) == null ? void 0 : C.headerVariables) || {},
|
|
3807
|
-
bodyVariables: ((
|
|
3813
|
+
bodyVariables: ((T = a.sampleContent) == null ? void 0 : T.bodyVariables) || {},
|
|
3808
3814
|
buttonVariables: {
|
|
3809
3815
|
...(O = a.sampleContent) == null ? void 0 : O.buttonVariables,
|
|
3810
3816
|
[p]: R.target.value
|
|
@@ -3824,16 +3830,16 @@ function ha({ template: a, setTemplate: s }) {
|
|
|
3824
3830
|
{
|
|
3825
3831
|
type: "button",
|
|
3826
3832
|
onClick: () => {
|
|
3827
|
-
var
|
|
3833
|
+
var T, O, z;
|
|
3828
3834
|
const R = new RegExp(`\\{\\{${p}\\}\\}`, "g"), f = (l.value || "").replace(R, "");
|
|
3829
|
-
|
|
3830
|
-
const C = Object.fromEntries(Object.entries(((
|
|
3835
|
+
N({ ...l, value: f });
|
|
3836
|
+
const C = Object.fromEntries(Object.entries(((T = a.sampleContent) == null ? void 0 : T.buttonVariables) || {}).filter(([$]) => $ !== p));
|
|
3831
3837
|
s({
|
|
3832
3838
|
...a,
|
|
3833
3839
|
sampleContent: {
|
|
3834
3840
|
...a.sampleContent,
|
|
3835
3841
|
headerVariables: ((O = a.sampleContent) == null ? void 0 : O.headerVariables) || {},
|
|
3836
|
-
bodyVariables: ((
|
|
3842
|
+
bodyVariables: ((z = a.sampleContent) == null ? void 0 : z.bodyVariables) || {},
|
|
3837
3843
|
buttonVariables: C
|
|
3838
3844
|
}
|
|
3839
3845
|
});
|
|
@@ -3851,8 +3857,8 @@ function ha({ template: a, setTemplate: s }) {
|
|
|
3851
3857
|
/* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-gray-600 rsp-font-mono rsp-break-all", children: l.value.replace(
|
|
3852
3858
|
/\{\{(\d+)\}\}/g,
|
|
3853
3859
|
(t, x) => {
|
|
3854
|
-
var p,
|
|
3855
|
-
return ((
|
|
3860
|
+
var p, v;
|
|
3861
|
+
return ((v = (p = a.sampleContent) == null ? void 0 : p.buttonVariables) == null ? void 0 : v[x]) || `[${t}]`;
|
|
3856
3862
|
}
|
|
3857
3863
|
) })
|
|
3858
3864
|
] }),
|
|
@@ -3860,7 +3866,7 @@ function ha({ template: a, setTemplate: s }) {
|
|
|
3860
3866
|
"button",
|
|
3861
3867
|
{
|
|
3862
3868
|
type: "button",
|
|
3863
|
-
onClick: () =>
|
|
3869
|
+
onClick: () => h(!1),
|
|
3864
3870
|
className: "rsp-px-3 rsp-py-1 rsp-text-xs rsp-text-gray-500 hover:rsp-text-gray-700",
|
|
3865
3871
|
children: "Close"
|
|
3866
3872
|
}
|
|
@@ -3872,7 +3878,7 @@ function ha({ template: a, setTemplate: s }) {
|
|
|
3872
3878
|
/* @__PURE__ */ e(
|
|
3873
3879
|
"button",
|
|
3874
3880
|
{
|
|
3875
|
-
onClick: () =>
|
|
3881
|
+
onClick: () => A(n),
|
|
3876
3882
|
disabled: !l.text.trim() || n !== "QUICK_REPLY" && !l.value.trim(),
|
|
3877
3883
|
className: "rsp-flex-1 rsp-bg-blue-600 rsp-text-white rsp-py-3 rsp-px-4 rsp-rounded-lg rsp-font-medium rsp-text-sm rsp-transition-colors hover:rsp-bg-blue-700 disabled:rsp-opacity-50 disabled:rsp-cursor-not-allowed rsp-shadow-sm",
|
|
3878
3884
|
children: "Add Button"
|
|
@@ -3892,7 +3898,7 @@ function ha({ template: a, setTemplate: s }) {
|
|
|
3892
3898
|
a.buttons.length > 0 && /* @__PURE__ */ r("div", { className: "rsp-space-y-4", children: [
|
|
3893
3899
|
/* @__PURE__ */ e("h4", { className: "rsp-text-md rsp-font-semibold rsp-text-gray-900", children: "Added Buttons" }),
|
|
3894
3900
|
/* @__PURE__ */ e("div", { className: "rsp-space-y-3", children: a.buttons.map((t) => {
|
|
3895
|
-
const x = b.find((
|
|
3901
|
+
const x = b.find((v) => v.type === t.type), p = (x == null ? void 0 : x.icon) || me;
|
|
3896
3902
|
return /* @__PURE__ */ e("div", { className: "rsp-bg-white rsp-border rsp-border-gray-200 rsp-rounded-lg rsp-p-4 rsp-shadow-sm", children: /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-start rsp-gap-3", children: [
|
|
3897
3903
|
/* @__PURE__ */ e("div", { className: "rsp-p-2 rsp-bg-gray-50 rsp-rounded-lg", children: /* @__PURE__ */ e(p, { className: "rsp-w-4 rsp-h-4 rsp-text-gray-600" }) }),
|
|
3898
3904
|
/* @__PURE__ */ r("div", { className: "rsp-flex-1 rsp-space-y-3", children: [
|
|
@@ -3903,7 +3909,7 @@ function ha({ template: a, setTemplate: s }) {
|
|
|
3903
3909
|
{
|
|
3904
3910
|
onClick: () => d(t.id),
|
|
3905
3911
|
className: "rsp-p-1 rsp-text-red-400 hover:rsp-text-red-600 hover:rsp-bg-red-50 rsp-rounded rsp-transition-colors",
|
|
3906
|
-
children: /* @__PURE__ */ e(
|
|
3912
|
+
children: /* @__PURE__ */ e(se, { className: "rsp-w-4 rsp-h-4" })
|
|
3907
3913
|
}
|
|
3908
3914
|
)
|
|
3909
3915
|
] }),
|
|
@@ -3916,7 +3922,7 @@ function ha({ template: a, setTemplate: s }) {
|
|
|
3916
3922
|
{
|
|
3917
3923
|
type: "text",
|
|
3918
3924
|
value: t.text,
|
|
3919
|
-
onChange: (
|
|
3925
|
+
onChange: (v) => w(t.id, "text", v.target.value),
|
|
3920
3926
|
maxLength: 25,
|
|
3921
3927
|
className: "rsp-w-full rsp-px-3 rsp-py-2 rsp-border rsp-border-gray-300 rsp-rounded-md rsp-text-sm focus:rsp-outline-none focus:rsp-ring-1 focus:rsp-ring-blue-500 focus:rsp-border-blue-500"
|
|
3922
3928
|
}
|
|
@@ -3935,7 +3941,7 @@ function ha({ template: a, setTemplate: s }) {
|
|
|
3935
3941
|
{
|
|
3936
3942
|
type: t.type === "CALL" ? "tel" : t.type === "URL" ? "url" : "text",
|
|
3937
3943
|
value: t.value || "",
|
|
3938
|
-
onChange: (
|
|
3944
|
+
onChange: (v) => w(t.id, "value", v.target.value),
|
|
3939
3945
|
maxLength: t.type === "URL" ? 2e3 : 20,
|
|
3940
3946
|
className: "rsp-w-full rsp-px-3 rsp-py-2 rsp-border rsp-border-gray-300 rsp-rounded-md rsp-text-sm focus:rsp-outline-none focus:rsp-ring-1 focus:rsp-ring-blue-500 focus:rsp-border-blue-500"
|
|
3941
3947
|
}
|
|
@@ -3960,7 +3966,7 @@ function ha({ template: a, setTemplate: s }) {
|
|
|
3960
3966
|
] })
|
|
3961
3967
|
] });
|
|
3962
3968
|
}
|
|
3963
|
-
const
|
|
3969
|
+
const ba = async (a) => {
|
|
3964
3970
|
try {
|
|
3965
3971
|
if (!a)
|
|
3966
3972
|
throw new Error("No file provided");
|
|
@@ -3976,16 +3982,16 @@ const ua = async (a) => {
|
|
|
3976
3982
|
console.log("Upload response status:", i.status), console.log("Upload response headers:", Object.fromEntries(i.headers.entries()));
|
|
3977
3983
|
const c = await i.text();
|
|
3978
3984
|
console.log("Raw upload response:", c);
|
|
3979
|
-
let
|
|
3985
|
+
let h;
|
|
3980
3986
|
try {
|
|
3981
|
-
|
|
3987
|
+
h = JSON.parse(c);
|
|
3982
3988
|
} catch (l) {
|
|
3983
3989
|
throw console.error("Failed to parse upload response:", l), new Error("Invalid response from upload server");
|
|
3984
3990
|
}
|
|
3985
|
-
if (console.log("Parsed upload response:",
|
|
3986
|
-
throw new Error(
|
|
3987
|
-
if (
|
|
3988
|
-
const l =
|
|
3991
|
+
if (console.log("Parsed upload response:", h), console.log("Upload status:", h.status), console.log("Upload message:", h.message), console.log("Upload data:", h.data), !h.status)
|
|
3992
|
+
throw new Error(h.message || "Upload failed");
|
|
3993
|
+
if (h.data && Array.isArray(h.data) && h.data.length > 0) {
|
|
3994
|
+
const l = h.data[0];
|
|
3989
3995
|
if (l.url)
|
|
3990
3996
|
return console.log("File uploaded successfully:", {
|
|
3991
3997
|
url: l.url,
|
|
@@ -3999,7 +4005,7 @@ const ua = async (a) => {
|
|
|
3999
4005
|
} catch (s) {
|
|
4000
4006
|
throw console.error("File upload error:", s), s instanceof Error ? s : new Error("Unknown error occurred during file upload");
|
|
4001
4007
|
}
|
|
4002
|
-
},
|
|
4008
|
+
}, ga = (a, s) => {
|
|
4003
4009
|
const i = a.name.toLowerCase().split(".").pop();
|
|
4004
4010
|
switch (s) {
|
|
4005
4011
|
case "IMAGE":
|
|
@@ -4011,7 +4017,7 @@ const ua = async (a) => {
|
|
|
4011
4017
|
default:
|
|
4012
4018
|
return !1;
|
|
4013
4019
|
}
|
|
4014
|
-
},
|
|
4020
|
+
}, ya = (a) => {
|
|
4015
4021
|
switch (a) {
|
|
4016
4022
|
case "IMAGE":
|
|
4017
4023
|
return 5 * 1024 * 1024;
|
|
@@ -4023,9 +4029,9 @@ const ua = async (a) => {
|
|
|
4023
4029
|
return 10 * 1024 * 1024;
|
|
4024
4030
|
}
|
|
4025
4031
|
};
|
|
4026
|
-
function
|
|
4027
|
-
var C,
|
|
4028
|
-
const [i, c] = X.useState({}), [,
|
|
4032
|
+
function wa({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
4033
|
+
var C, T, O, z, $;
|
|
4034
|
+
const [i, c] = X.useState({}), [, h] = X.useState({}), [l, N] = X.useState({ open: !1, message: "" }), [g, o] = X.useState(!1), [k, A] = X.useState(null), d = X.useRef({}), w = () => {
|
|
4029
4035
|
var E;
|
|
4030
4036
|
const m = {
|
|
4031
4037
|
id: Math.random().toString(36).substr(2, 9),
|
|
@@ -4035,11 +4041,11 @@ function ya({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
4035
4041
|
buttons: []
|
|
4036
4042
|
};
|
|
4037
4043
|
s((S) => {
|
|
4038
|
-
var
|
|
4044
|
+
var V, I;
|
|
4039
4045
|
return {
|
|
4040
4046
|
...S,
|
|
4041
4047
|
carousel: {
|
|
4042
|
-
type: ((
|
|
4048
|
+
type: ((V = a.carousel) == null ? void 0 : V.type) || "IMAGE",
|
|
4043
4049
|
cards: [...((I = a.carousel) == null ? void 0 : I.cards) || [], m]
|
|
4044
4050
|
}
|
|
4045
4051
|
};
|
|
@@ -4053,18 +4059,18 @@ function ya({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
4053
4059
|
}
|
|
4054
4060
|
}));
|
|
4055
4061
|
}, b = (m, E, S) => {
|
|
4056
|
-
s((
|
|
4057
|
-
...
|
|
4062
|
+
s((V) => ({
|
|
4063
|
+
...V,
|
|
4058
4064
|
carousel: {
|
|
4059
|
-
...
|
|
4060
|
-
cards:
|
|
4065
|
+
...V.carousel,
|
|
4066
|
+
cards: V.carousel.cards.map(
|
|
4061
4067
|
(I) => I.id === m ? { ...I, [E]: S } : I
|
|
4062
4068
|
)
|
|
4063
4069
|
}
|
|
4064
4070
|
}));
|
|
4065
4071
|
}, y = (m) => {
|
|
4066
4072
|
s((E) => {
|
|
4067
|
-
const
|
|
4073
|
+
const V = ((E.carousel || { type: m, cards: [] }).cards || []).map((I) => ({
|
|
4068
4074
|
...I,
|
|
4069
4075
|
mediaType: m,
|
|
4070
4076
|
mediaUrl: ""
|
|
@@ -4073,93 +4079,93 @@ function ya({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
4073
4079
|
...E,
|
|
4074
4080
|
carousel: {
|
|
4075
4081
|
type: m,
|
|
4076
|
-
cards:
|
|
4082
|
+
cards: V
|
|
4077
4083
|
}
|
|
4078
4084
|
};
|
|
4079
4085
|
});
|
|
4080
4086
|
}, t = (m, E) => {
|
|
4081
|
-
var
|
|
4082
|
-
const S = (
|
|
4087
|
+
var U;
|
|
4088
|
+
const S = (U = a.carousel) == null ? void 0 : U.cards.find((P) => P.id === m);
|
|
4083
4089
|
if (!S) return;
|
|
4084
|
-
const
|
|
4085
|
-
b(m, E,
|
|
4090
|
+
const _ = `{{${p(m) + 1}}}`, u = S[E] + _;
|
|
4091
|
+
b(m, E, u);
|
|
4086
4092
|
}, x = (m) => {
|
|
4087
|
-
var
|
|
4093
|
+
var u;
|
|
4088
4094
|
if (!k) return;
|
|
4089
|
-
const E = d.current[k], S = (
|
|
4095
|
+
const E = d.current[k], S = (u = a.carousel) == null ? void 0 : u.cards.find((U) => U.id === k);
|
|
4090
4096
|
if (!S) return;
|
|
4091
|
-
const
|
|
4092
|
-
b(k, "body",
|
|
4093
|
-
const
|
|
4094
|
-
if (
|
|
4095
|
-
const
|
|
4096
|
-
|
|
4097
|
+
const V = E && typeof E.selectionStart == "number" ? E.selectionStart : S.body.length, I = S.body.substring(0, V), _ = S.body.substring(V), F = I + m + _;
|
|
4098
|
+
b(k, "body", F), setTimeout(() => {
|
|
4099
|
+
const U = d.current[k];
|
|
4100
|
+
if (U) {
|
|
4101
|
+
const P = V + m.length;
|
|
4102
|
+
U.setSelectionRange(P, P), U.focus();
|
|
4097
4103
|
}
|
|
4098
|
-
}, 0),
|
|
4104
|
+
}, 0), o(!1);
|
|
4099
4105
|
}, p = (m) => {
|
|
4100
|
-
var
|
|
4101
|
-
const E = (
|
|
4106
|
+
var _;
|
|
4107
|
+
const E = (_ = a.carousel) == null ? void 0 : _.cards.find((F) => F.id === m);
|
|
4102
4108
|
if (!E) return 0;
|
|
4103
|
-
const
|
|
4104
|
-
if (!
|
|
4105
|
-
const I =
|
|
4106
|
-
const
|
|
4107
|
-
return
|
|
4109
|
+
const V = (E.body || "").match(/\{\{(\d+)\}\}/g);
|
|
4110
|
+
if (!V) return 0;
|
|
4111
|
+
const I = V.map((F) => {
|
|
4112
|
+
const u = F.match(/{{(\d+)}}/);
|
|
4113
|
+
return u ? parseInt(u[1], 10) : 0;
|
|
4108
4114
|
});
|
|
4109
4115
|
return I.length > 0 ? Math.max(...I) : 0;
|
|
4110
|
-
},
|
|
4116
|
+
}, v = (m, E) => {
|
|
4111
4117
|
var I;
|
|
4112
|
-
const S = (I = a.carousel) == null ? void 0 : I.cards.find((
|
|
4118
|
+
const S = (I = a.carousel) == null ? void 0 : I.cards.find((_) => _.id === m);
|
|
4113
4119
|
if (!S || S.buttons.length >= 2) return;
|
|
4114
|
-
const
|
|
4120
|
+
const V = {
|
|
4115
4121
|
id: Math.random().toString(36).substr(2, 9),
|
|
4116
4122
|
type: E,
|
|
4117
4123
|
text: "",
|
|
4118
4124
|
value: "",
|
|
4119
4125
|
urlType: "static"
|
|
4120
4126
|
};
|
|
4121
|
-
b(m, "buttons", [...S.buttons,
|
|
4122
|
-
},
|
|
4123
|
-
var
|
|
4124
|
-
const I = (
|
|
4127
|
+
b(m, "buttons", [...S.buttons, V]);
|
|
4128
|
+
}, j = (m, E, S, V) => {
|
|
4129
|
+
var F;
|
|
4130
|
+
const I = (F = a.carousel) == null ? void 0 : F.cards.find((u) => u.id === m);
|
|
4125
4131
|
if (!I) return;
|
|
4126
|
-
const
|
|
4127
|
-
(
|
|
4132
|
+
const _ = I.buttons.map(
|
|
4133
|
+
(u) => u.id === E ? { ...u, [S]: V } : u
|
|
4128
4134
|
);
|
|
4129
|
-
b(m, "buttons",
|
|
4135
|
+
b(m, "buttons", _);
|
|
4130
4136
|
}, R = (m, E) => {
|
|
4131
4137
|
var I;
|
|
4132
|
-
const S = (I = a.carousel) == null ? void 0 : I.cards.find((
|
|
4138
|
+
const S = (I = a.carousel) == null ? void 0 : I.cards.find((_) => _.id === m);
|
|
4133
4139
|
if (!S) return;
|
|
4134
|
-
const
|
|
4135
|
-
b(m, "buttons",
|
|
4140
|
+
const V = S.buttons.filter((_) => _.id !== E);
|
|
4141
|
+
b(m, "buttons", V);
|
|
4136
4142
|
}, f = async (m, E) => {
|
|
4137
4143
|
var S;
|
|
4138
4144
|
try {
|
|
4139
|
-
c((
|
|
4140
|
-
const
|
|
4141
|
-
if (!
|
|
4142
|
-
throw new Error(`Invalid file type. Expected ${
|
|
4143
|
-
const I =
|
|
4145
|
+
c((F) => ({ ...F, [m]: !0 })), h((F) => ({ ...F, [m]: !1 }));
|
|
4146
|
+
const V = ((S = a.carousel) == null ? void 0 : S.type) === "VIDEO" ? "VIDEO" : "IMAGE";
|
|
4147
|
+
if (!ga(E, V))
|
|
4148
|
+
throw new Error(`Invalid file type. Expected ${V.toLowerCase()} file.`);
|
|
4149
|
+
const I = ya(V);
|
|
4144
4150
|
if (E.size > I) {
|
|
4145
|
-
const
|
|
4146
|
-
throw new Error(`File size too large. Maximum allowed size is ${
|
|
4151
|
+
const F = I / 1048576;
|
|
4152
|
+
throw new Error(`File size too large. Maximum allowed size is ${F}MB.`);
|
|
4147
4153
|
}
|
|
4148
|
-
const
|
|
4149
|
-
b(m, "mediaUrl",
|
|
4150
|
-
} catch (
|
|
4151
|
-
console.error("File upload failed:",
|
|
4154
|
+
const _ = await n(E);
|
|
4155
|
+
b(m, "mediaUrl", _);
|
|
4156
|
+
} catch (V) {
|
|
4157
|
+
console.error("File upload failed:", V), N({ open: !0, message: V instanceof Error ? V.message : "File upload failed" });
|
|
4152
4158
|
} finally {
|
|
4153
|
-
c((
|
|
4159
|
+
c((V) => ({ ...V, [m]: !1 }));
|
|
4154
4160
|
}
|
|
4155
4161
|
};
|
|
4156
4162
|
return /* @__PURE__ */ r("div", { className: "rsp-space-y-6", children: [
|
|
4157
4163
|
l.open && /* @__PURE__ */ r("div", { className: "rsp-fixed rsp-inset-0 rsp-z-50 rsp-flex rsp-items-center rsp-justify-center", children: [
|
|
4158
|
-
/* @__PURE__ */ e("div", { className: "rsp-absolute rsp-inset-0 rsp-bg-black rsp-bg-opacity-40", onClick: () =>
|
|
4164
|
+
/* @__PURE__ */ e("div", { className: "rsp-absolute rsp-inset-0 rsp-bg-black rsp-bg-opacity-40", onClick: () => N({ open: !1, message: "" }) }),
|
|
4159
4165
|
/* @__PURE__ */ r("div", { className: "rsp-relative rsp-z-10 rsp-bg-white rsp-rounded-lg rsp-shadow-lg rsp-w-full rsp-max-w-md rsp-p-5", children: [
|
|
4160
4166
|
/* @__PURE__ */ e("div", { className: "rsp-mb-3 rsp-text-lg rsp-font-semibold rsp-text-gray-900", children: "Upload Error" }),
|
|
4161
4167
|
/* @__PURE__ */ e("div", { className: "rsp-text-sm rsp-text-gray-700 rsp-break-words rsp-whitespace-pre-wrap", children: l.message }),
|
|
4162
|
-
/* @__PURE__ */ e("div", { className: "rsp-flex rsp-justify-end rsp-mt-4", children: /* @__PURE__ */ e("button", { onClick: () =>
|
|
4168
|
+
/* @__PURE__ */ e("div", { className: "rsp-flex rsp-justify-end rsp-mt-4", children: /* @__PURE__ */ e("button", { onClick: () => N({ open: !1, message: "" }), className: "rsp-px-4 rsp-py-2 rsp-text-sm rsp-font-medium rsp-text-white rsp-bg-blue-600 rsp-rounded-md hover:rsp-bg-blue-700", children: "OK" }) })
|
|
4163
4169
|
] })
|
|
4164
4170
|
] }),
|
|
4165
4171
|
/* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-justify-between", children: [
|
|
@@ -4173,11 +4179,11 @@ function ya({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
4173
4179
|
/* @__PURE__ */ r(
|
|
4174
4180
|
"button",
|
|
4175
4181
|
{
|
|
4176
|
-
onClick:
|
|
4177
|
-
disabled: (((
|
|
4182
|
+
onClick: w,
|
|
4183
|
+
disabled: (((T = a.carousel) == null ? void 0 : T.cards.length) || 0) >= 10,
|
|
4178
4184
|
className: "rsp-px-4 rsp-py-2 rsp-bg-blue-600 rsp-text-white rsp-rounded-md hover:rsp-bg-blue-700 disabled:rsp-bg-gray-400 disabled:rsp-cursor-not-allowed rsp-text-sm rsp-font-medium",
|
|
4179
4185
|
children: [
|
|
4180
|
-
/* @__PURE__ */ e(
|
|
4186
|
+
/* @__PURE__ */ e(ue, { className: "rsp-w-4 rsp-h-4 rsp-inline rsp-mr-2" }),
|
|
4181
4187
|
"Add Card"
|
|
4182
4188
|
]
|
|
4183
4189
|
}
|
|
@@ -4208,7 +4214,7 @@ function ya({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
4208
4214
|
type: "radio",
|
|
4209
4215
|
name: "carouselType",
|
|
4210
4216
|
value: "VIDEO",
|
|
4211
|
-
checked: ((
|
|
4217
|
+
checked: ((z = a.carousel) == null ? void 0 : z.type) === "VIDEO",
|
|
4212
4218
|
onChange: (m) => y(m.target.value),
|
|
4213
4219
|
className: "rsp-mr-2"
|
|
4214
4220
|
}
|
|
@@ -4217,8 +4223,8 @@ function ya({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
4217
4223
|
] })
|
|
4218
4224
|
] })
|
|
4219
4225
|
] }),
|
|
4220
|
-
/* @__PURE__ */ e("div", { className: "rsp-space-y-6", children: (
|
|
4221
|
-
var S,
|
|
4226
|
+
/* @__PURE__ */ e("div", { className: "rsp-space-y-6", children: ($ = a.carousel) == null ? void 0 : $.cards.map((m, E) => {
|
|
4227
|
+
var S, V, I, _, F, u, U, P;
|
|
4222
4228
|
return /* @__PURE__ */ r("div", { className: "rsp-bg-white rsp-rounded-xl rsp-border-2 rsp-border-gray-200 rsp-overflow-hidden rsp-shadow-lg rsp-transition-all hover:rsp-shadow-xl hover:rsp-border-blue-300", children: [
|
|
4223
4229
|
/* @__PURE__ */ r("div", { className: "rsp-bg-gradient-to-r rsp-from-blue-50 rsp-to-blue-100 rsp-px-5 rsp-py-3 rsp-flex rsp-items-center rsp-justify-between rsp-border-b rsp-border-gray-200", children: [
|
|
4224
4230
|
/* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-3", children: [
|
|
@@ -4234,7 +4240,7 @@ function ya({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
4234
4240
|
onClick: () => M(m.id),
|
|
4235
4241
|
className: "rsp-p-1.5 rsp-text-gray-500 hover:rsp-text-white hover:rsp-bg-red-500 rsp-rounded-full rsp-transition-colors",
|
|
4236
4242
|
title: "Remove Card",
|
|
4237
|
-
children: /* @__PURE__ */ e(
|
|
4243
|
+
children: /* @__PURE__ */ e(se, { className: "rsp-w-4 rsp-h-4" })
|
|
4238
4244
|
}
|
|
4239
4245
|
)
|
|
4240
4246
|
] }),
|
|
@@ -4242,7 +4248,7 @@ function ya({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
4242
4248
|
/* @__PURE__ */ r("div", { children: [
|
|
4243
4249
|
/* @__PURE__ */ r("label", { className: "rsp-text-sm rsp-font-semibold rsp-text-gray-800 rsp-mb-3 rsp-flex rsp-items-center rsp-gap-2", children: [
|
|
4244
4250
|
/* @__PURE__ */ e("svg", { className: "rsp-w-4 rsp-h-4 rsp-text-blue-500", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: ((S = a.carousel) == null ? void 0 : S.type) === "VIDEO" ? /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z" }) : /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" }) }),
|
|
4245
|
-
((
|
|
4251
|
+
((V = a.carousel) == null ? void 0 : V.type) === "VIDEO" ? "Video" : "Image",
|
|
4246
4252
|
" Upload"
|
|
4247
4253
|
] }),
|
|
4248
4254
|
/* @__PURE__ */ r("div", { className: "rsp-border-2 rsp-border-dashed rsp-border-blue-200 rsp-rounded-xl rsp-p-6 rsp-text-center rsp-bg-gradient-to-br rsp-from-blue-50 rsp-to-white rsp-transition-all hover:rsp-border-blue-400 hover:rsp-from-blue-100 rsp-relative", children: [
|
|
@@ -4253,8 +4259,8 @@ function ya({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
4253
4259
|
src: m.mediaUrl,
|
|
4254
4260
|
alt: `Card ${E + 1}`,
|
|
4255
4261
|
className: "rsp-w-full rsp-h-48 rsp-object-cover rsp-rounded-lg rsp-shadow-md",
|
|
4256
|
-
onLoad: () =>
|
|
4257
|
-
onError: () =>
|
|
4262
|
+
onLoad: () => h((L) => ({ ...L, [m.id]: !0 })),
|
|
4263
|
+
onError: () => h((L) => ({ ...L, [m.id]: !1 }))
|
|
4258
4264
|
}
|
|
4259
4265
|
) : /* @__PURE__ */ e(
|
|
4260
4266
|
"video",
|
|
@@ -4262,8 +4268,8 @@ function ya({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
4262
4268
|
src: m.mediaUrl,
|
|
4263
4269
|
className: "rsp-w-full rsp-h-48 rsp-object-cover rsp-rounded-lg rsp-shadow-md",
|
|
4264
4270
|
controls: !0,
|
|
4265
|
-
onLoadedData: () =>
|
|
4266
|
-
onError: () =>
|
|
4271
|
+
onLoadedData: () => h((L) => ({ ...L, [m.id]: !0 })),
|
|
4272
|
+
onError: () => h((L) => ({ ...L, [m.id]: !1 }))
|
|
4267
4273
|
}
|
|
4268
4274
|
),
|
|
4269
4275
|
/* @__PURE__ */ e(
|
|
@@ -4272,20 +4278,20 @@ function ya({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
4272
4278
|
onClick: () => b(m.id, "mediaUrl", ""),
|
|
4273
4279
|
className: "rsp-absolute rsp-top-2 rsp-right-2 rsp-p-2 rsp-bg-red-500 rsp-text-white rsp-rounded-full hover:rsp-bg-red-600 rsp-shadow-lg rsp-opacity-0 group-hover:rsp-opacity-100 rsp-transition-opacity",
|
|
4274
4280
|
title: "Remove media",
|
|
4275
|
-
children: /* @__PURE__ */ e(
|
|
4281
|
+
children: /* @__PURE__ */ e(se, { className: "rsp-w-4 rsp-h-4" })
|
|
4276
4282
|
}
|
|
4277
4283
|
),
|
|
4278
|
-
/* @__PURE__ */ e("div", { className: "rsp-absolute rsp-bottom-2 rsp-left-2 rsp-bg-black rsp-bg-opacity-60 rsp-text-white rsp-text-xs rsp-px-2 rsp-py-1 rsp-rounded rsp-backdrop-blur-sm", children: ((
|
|
4284
|
+
/* @__PURE__ */ e("div", { className: "rsp-absolute rsp-bottom-2 rsp-left-2 rsp-bg-black rsp-bg-opacity-60 rsp-text-white rsp-text-xs rsp-px-2 rsp-py-1 rsp-rounded rsp-backdrop-blur-sm", children: ((_ = a.carousel) == null ? void 0 : _.type) === "VIDEO" ? "📹 Video" : "🖼️ Image" })
|
|
4279
4285
|
] }) : /* @__PURE__ */ r("div", { children: [
|
|
4280
|
-
/* @__PURE__ */ e("div", { className: "rsp-w-20 rsp-h-20 rsp-mx-auto rsp-mb-4 rsp-bg-gradient-to-br rsp-from-blue-100 rsp-to-blue-200 rsp-rounded-xl rsp-flex rsp-items-center rsp-justify-center rsp-shadow-md", children: /* @__PURE__ */ e("svg", { className: "rsp-w-10 rsp-h-10 rsp-text-blue-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: ((
|
|
4286
|
+
/* @__PURE__ */ e("div", { className: "rsp-w-20 rsp-h-20 rsp-mx-auto rsp-mb-4 rsp-bg-gradient-to-br rsp-from-blue-100 rsp-to-blue-200 rsp-rounded-xl rsp-flex rsp-items-center rsp-justify-center rsp-shadow-md", children: /* @__PURE__ */ e("svg", { className: "rsp-w-10 rsp-h-10 rsp-text-blue-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: ((F = a.carousel) == null ? void 0 : F.type) === "VIDEO" ? /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z" }) : /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" }) }) }),
|
|
4281
4287
|
/* @__PURE__ */ e(
|
|
4282
4288
|
"input",
|
|
4283
4289
|
{
|
|
4284
4290
|
type: "file",
|
|
4285
|
-
accept: ((
|
|
4291
|
+
accept: ((u = a.carousel) == null ? void 0 : u.type) === "VIDEO" ? "video/*" : "image/*",
|
|
4286
4292
|
onChange: (L) => {
|
|
4287
|
-
var
|
|
4288
|
-
const Y = (
|
|
4293
|
+
var D;
|
|
4294
|
+
const Y = (D = L.target.files) == null ? void 0 : D[0];
|
|
4289
4295
|
Y && !i[m.id] && f(m.id, Y);
|
|
4290
4296
|
},
|
|
4291
4297
|
className: "rsp-hidden",
|
|
@@ -4302,11 +4308,11 @@ function ya({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
4302
4308
|
children: [
|
|
4303
4309
|
/* @__PURE__ */ e("svg", { className: "rsp-w-4 rsp-h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12" }) }),
|
|
4304
4310
|
"Upload ",
|
|
4305
|
-
((
|
|
4311
|
+
((U = a.carousel) == null ? void 0 : U.type) === "VIDEO" ? "Video" : "Image"
|
|
4306
4312
|
]
|
|
4307
4313
|
}
|
|
4308
4314
|
),
|
|
4309
|
-
/* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-gray-500 rsp-mt-3 rsp-px-2", children: ((
|
|
4315
|
+
/* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-gray-500 rsp-mt-3 rsp-px-2", children: ((P = a.carousel) == null ? void 0 : P.type) === "VIDEO" ? "📹 MP4, MOV, AVI (Max 16MB)" : "🖼️ PNG, JPG, GIF, TIFF, SVG, BMP (Max 5MB)" })
|
|
4310
4316
|
] }),
|
|
4311
4317
|
i[m.id] && /* @__PURE__ */ e("div", { className: "rsp-absolute rsp-inset-0 rsp-bg-black rsp-bg-opacity-30 rsp-flex rsp-items-center rsp-justify-center", children: /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-2 rsp-bg-white rsp-px-3 rsp-py-2 rsp-rounded-md rsp-shadow", children: [
|
|
4312
4318
|
/* @__PURE__ */ r("svg", { className: "rsp-w-4 rsp-h-4 rsp-animate-spin", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", children: [
|
|
@@ -4353,11 +4359,11 @@ function ya({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
4353
4359
|
"button",
|
|
4354
4360
|
{
|
|
4355
4361
|
onClick: () => {
|
|
4356
|
-
|
|
4362
|
+
A(m.id), o(!0);
|
|
4357
4363
|
},
|
|
4358
4364
|
className: "rsp-p-1.5 rsp-text-gray-500 hover:rsp-text-blue-600 hover:rsp-bg-blue-50 rsp-rounded rsp-transition-colors",
|
|
4359
4365
|
title: "Add Emoji",
|
|
4360
|
-
children: /* @__PURE__ */ e(
|
|
4366
|
+
children: /* @__PURE__ */ e(be, { className: "rsp-w-4 rsp-h-4" })
|
|
4361
4367
|
}
|
|
4362
4368
|
)
|
|
4363
4369
|
] }),
|
|
@@ -4367,15 +4373,15 @@ function ya({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
4367
4373
|
] })
|
|
4368
4374
|
] }),
|
|
4369
4375
|
(() => {
|
|
4370
|
-
const L = m.body.match(/\{\{(\d+)\}\}/g) || [], Y = [...new Set(L.map((
|
|
4376
|
+
const L = m.body.match(/\{\{(\d+)\}\}/g) || [], Y = [...new Set(L.map((D) => D.replace(/[{}]/g, "")))];
|
|
4371
4377
|
return Y.length === 0 ? null : /* @__PURE__ */ r("div", { className: "rsp-mt-3 rsp-p-3 rsp-bg-blue-50 rsp-rounded-lg rsp-border rsp-border-blue-200", children: [
|
|
4372
4378
|
/* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-font-semibold rsp-text-blue-800 rsp-mb-2", children: "Sample Values for This Card" }),
|
|
4373
|
-
/* @__PURE__ */ e("div", { className: "rsp-grid rsp-grid-cols-1 rsp-gap-2", children: Y.map((
|
|
4374
|
-
var
|
|
4379
|
+
/* @__PURE__ */ e("div", { className: "rsp-grid rsp-grid-cols-1 rsp-gap-2", children: Y.map((D) => {
|
|
4380
|
+
var Z, W;
|
|
4375
4381
|
return /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-2", children: [
|
|
4376
4382
|
/* @__PURE__ */ r("label", { className: "rsp-text-xs rsp-text-gray-700 rsp-font-medium rsp-whitespace-nowrap", children: [
|
|
4377
4383
|
"{{",
|
|
4378
|
-
|
|
4384
|
+
D,
|
|
4379
4385
|
"}}",
|
|
4380
4386
|
":"
|
|
4381
4387
|
] }),
|
|
@@ -4383,24 +4389,24 @@ function ya({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
4383
4389
|
"input",
|
|
4384
4390
|
{
|
|
4385
4391
|
type: "text",
|
|
4386
|
-
value: ((
|
|
4387
|
-
onChange: (
|
|
4388
|
-
const
|
|
4392
|
+
value: ((W = (Z = m.sampleContent) == null ? void 0 : Z.bodyVariables) == null ? void 0 : W[D]) || "",
|
|
4393
|
+
onChange: (ne) => {
|
|
4394
|
+
const re = ne.target.value;
|
|
4389
4395
|
s((J) => ({
|
|
4390
4396
|
...J,
|
|
4391
4397
|
carousel: {
|
|
4392
4398
|
...J.carousel,
|
|
4393
|
-
cards: J.carousel.cards.map((
|
|
4394
|
-
var
|
|
4395
|
-
return
|
|
4396
|
-
...
|
|
4399
|
+
cards: J.carousel.cards.map((q) => {
|
|
4400
|
+
var G, K, ee;
|
|
4401
|
+
return q.id !== m.id ? q : {
|
|
4402
|
+
...q,
|
|
4397
4403
|
sampleContent: {
|
|
4398
|
-
headerVariables: ((
|
|
4404
|
+
headerVariables: ((G = q.sampleContent) == null ? void 0 : G.headerVariables) || {},
|
|
4399
4405
|
bodyVariables: {
|
|
4400
|
-
...((
|
|
4401
|
-
[
|
|
4406
|
+
...((K = q.sampleContent) == null ? void 0 : K.bodyVariables) || {},
|
|
4407
|
+
[D]: re
|
|
4402
4408
|
},
|
|
4403
|
-
buttonVariables: ((
|
|
4409
|
+
buttonVariables: ((ee = q.sampleContent) == null ? void 0 : ee.buttonVariables) || {}
|
|
4404
4410
|
}
|
|
4405
4411
|
};
|
|
4406
4412
|
})
|
|
@@ -4416,22 +4422,22 @@ function ya({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
4416
4422
|
{
|
|
4417
4423
|
type: "button",
|
|
4418
4424
|
onClick: () => {
|
|
4419
|
-
const
|
|
4425
|
+
const ne = new RegExp(`\\{\\{${D}\\}\\}`, "g"), re = (m.body || "").replace(ne, "");
|
|
4420
4426
|
s((J) => ({
|
|
4421
4427
|
...J,
|
|
4422
4428
|
carousel: {
|
|
4423
4429
|
...J.carousel,
|
|
4424
|
-
cards: J.carousel.cards.map((
|
|
4425
|
-
var
|
|
4426
|
-
if (
|
|
4427
|
-
const Q = Object.fromEntries(Object.entries(((
|
|
4430
|
+
cards: J.carousel.cards.map((q) => {
|
|
4431
|
+
var G, K, ee;
|
|
4432
|
+
if (q.id !== m.id) return q;
|
|
4433
|
+
const Q = Object.fromEntries(Object.entries(((G = q.sampleContent) == null ? void 0 : G.bodyVariables) || {}).filter(([ie]) => ie !== D));
|
|
4428
4434
|
return {
|
|
4429
|
-
...
|
|
4430
|
-
body:
|
|
4435
|
+
...q,
|
|
4436
|
+
body: re,
|
|
4431
4437
|
sampleContent: {
|
|
4432
|
-
headerVariables: ((
|
|
4438
|
+
headerVariables: ((K = q.sampleContent) == null ? void 0 : K.headerVariables) || {},
|
|
4433
4439
|
bodyVariables: Q,
|
|
4434
|
-
buttonVariables: ((
|
|
4440
|
+
buttonVariables: ((ee = q.sampleContent) == null ? void 0 : ee.buttonVariables) || {}
|
|
4435
4441
|
}
|
|
4436
4442
|
};
|
|
4437
4443
|
})
|
|
@@ -4443,7 +4449,7 @@ function ya({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
4443
4449
|
children: "×"
|
|
4444
4450
|
}
|
|
4445
4451
|
)
|
|
4446
|
-
] }, `card-${m.id}-sample-${
|
|
4452
|
+
] }, `card-${m.id}-sample-${D}`);
|
|
4447
4453
|
}) })
|
|
4448
4454
|
] });
|
|
4449
4455
|
})()
|
|
@@ -4462,7 +4468,7 @@ function ya({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
4462
4468
|
/* @__PURE__ */ r(
|
|
4463
4469
|
"button",
|
|
4464
4470
|
{
|
|
4465
|
-
onClick: () =>
|
|
4471
|
+
onClick: () => v(m.id, "QUICK_REPLY"),
|
|
4466
4472
|
className: "rsp-flex rsp-flex-col rsp-items-center rsp-gap-2 rsp-px-3 rsp-py-4 rsp-border-2 rsp-border-gray-200 rsp-rounded-lg rsp-text-sm rsp-font-medium rsp-text-gray-700 hover:rsp-border-blue-400 hover:rsp-bg-blue-50 rsp-transition-all rsp-shadow-sm",
|
|
4467
4473
|
children: [
|
|
4468
4474
|
/* @__PURE__ */ e("svg", { className: "rsp-w-6 rsp-h-6 rsp-text-blue-500", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z" }) }),
|
|
@@ -4473,7 +4479,7 @@ function ya({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
4473
4479
|
/* @__PURE__ */ r(
|
|
4474
4480
|
"button",
|
|
4475
4481
|
{
|
|
4476
|
-
onClick: () =>
|
|
4482
|
+
onClick: () => v(m.id, "URL"),
|
|
4477
4483
|
className: "rsp-flex rsp-flex-col rsp-items-center rsp-gap-2 rsp-px-3 rsp-py-4 rsp-border-2 rsp-border-gray-200 rsp-rounded-lg rsp-text-sm rsp-font-medium rsp-text-gray-700 hover:rsp-border-blue-400 hover:rsp-bg-blue-50 rsp-transition-all rsp-shadow-sm",
|
|
4478
4484
|
children: [
|
|
4479
4485
|
/* @__PURE__ */ e("svg", { className: "rsp-w-6 rsp-h-6 rsp-text-blue-500", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" }) }),
|
|
@@ -4484,7 +4490,7 @@ function ya({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
4484
4490
|
/* @__PURE__ */ r(
|
|
4485
4491
|
"button",
|
|
4486
4492
|
{
|
|
4487
|
-
onClick: () =>
|
|
4493
|
+
onClick: () => v(m.id, "PHONE_NUMBER"),
|
|
4488
4494
|
className: "rsp-flex rsp-flex-col rsp-items-center rsp-gap-2 rsp-px-3 rsp-py-4 rsp-border-2 rsp-border-gray-200 rsp-rounded-lg rsp-text-sm rsp-font-medium rsp-text-gray-700 hover:rsp-border-blue-400 hover:rsp-bg-blue-50 rsp-transition-all rsp-shadow-sm",
|
|
4489
4495
|
children: [
|
|
4490
4496
|
/* @__PURE__ */ e("svg", { className: "rsp-w-6 rsp-h-6 rsp-text-blue-500", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z" }) }),
|
|
@@ -4511,7 +4517,7 @@ function ya({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
4511
4517
|
onClick: () => R(m.id, L.id),
|
|
4512
4518
|
className: "rsp-p-1 rsp-text-gray-400 hover:rsp-text-red-500 hover:rsp-bg-red-50 rsp-rounded rsp-transition-colors",
|
|
4513
4519
|
title: "Remove button",
|
|
4514
|
-
children: /* @__PURE__ */ e(
|
|
4520
|
+
children: /* @__PURE__ */ e(se, { className: "rsp-w-4 rsp-h-4" })
|
|
4515
4521
|
}
|
|
4516
4522
|
)
|
|
4517
4523
|
] }),
|
|
@@ -4523,7 +4529,7 @@ function ya({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
4523
4529
|
{
|
|
4524
4530
|
type: "text",
|
|
4525
4531
|
value: L.text,
|
|
4526
|
-
onChange: (
|
|
4532
|
+
onChange: (D) => j(m.id, L.id, "text", D.target.value),
|
|
4527
4533
|
placeholder: `Enter Button Text (Max ${L.type === "QUICK_REPLY" ? "25" : "20"} characters)`,
|
|
4528
4534
|
maxLength: L.type === "QUICK_REPLY" ? 25 : 20,
|
|
4529
4535
|
className: "rsp-w-full rsp-px-3 rsp-py-2 rsp-border rsp-border-gray-300 rsp-rounded-md rsp-text-sm focus:rsp-outline-none focus:rsp-border-blue-500 rsp-bg-white"
|
|
@@ -4540,7 +4546,7 @@ function ya({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
4540
4546
|
{
|
|
4541
4547
|
type: "radio",
|
|
4542
4548
|
checked: L.urlType !== "dynamic",
|
|
4543
|
-
onChange: () =>
|
|
4549
|
+
onChange: () => j(m.id, L.id, "urlType", "static"),
|
|
4544
4550
|
className: "rsp-mr-2 rsp-text-blue-600"
|
|
4545
4551
|
}
|
|
4546
4552
|
),
|
|
@@ -4552,7 +4558,7 @@ function ya({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
4552
4558
|
{
|
|
4553
4559
|
type: "radio",
|
|
4554
4560
|
checked: L.urlType === "dynamic",
|
|
4555
|
-
onChange: () =>
|
|
4561
|
+
onChange: () => j(m.id, L.id, "urlType", "dynamic"),
|
|
4556
4562
|
className: "rsp-mr-2 rsp-text-blue-600"
|
|
4557
4563
|
}
|
|
4558
4564
|
),
|
|
@@ -4567,7 +4573,7 @@ function ya({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
4567
4573
|
{
|
|
4568
4574
|
type: "text",
|
|
4569
4575
|
value: L.value || "",
|
|
4570
|
-
onChange: (
|
|
4576
|
+
onChange: (D) => j(m.id, L.id, "value", D.target.value),
|
|
4571
4577
|
placeholder: L.urlType === "dynamic" ? "https://example.com/order/{{1}}" : "https://example.com",
|
|
4572
4578
|
className: "rsp-w-full rsp-px-3 rsp-py-2 rsp-border rsp-border-gray-300 rsp-rounded-md rsp-text-sm focus:rsp-outline-none focus:rsp-border-blue-500 rsp-bg-white"
|
|
4573
4579
|
}
|
|
@@ -4593,11 +4599,11 @@ function ya({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
4593
4599
|
type: "button",
|
|
4594
4600
|
onClick: () => {
|
|
4595
4601
|
if (((L.value || "").match(/\{\{(\d+)\}\}/g) || []).length >= 3) return;
|
|
4596
|
-
const
|
|
4597
|
-
const Q =
|
|
4602
|
+
const W = ((L.value || "").match(/\{\{(\d+)\}\}/g) || []).map((q) => {
|
|
4603
|
+
const Q = q.match(/{{(\d+)}}/);
|
|
4598
4604
|
return Q ? parseInt(Q[1], 10) : 0;
|
|
4599
|
-
}),
|
|
4600
|
-
|
|
4605
|
+
}), re = (W.length > 0 ? Math.max(...W) : 0) + 1, J = (L.value || "") + `{{${re}}}`;
|
|
4606
|
+
j(m.id, L.id, "value", J);
|
|
4601
4607
|
},
|
|
4602
4608
|
disabled: ((L.value || "").match(/\{\{(\d+)\}\}/g) || []).length >= 3,
|
|
4603
4609
|
className: "rsp-px-3 rsp-py-1.5 rsp-text-xs rsp-bg-blue-500 hover:rsp-bg-blue-600 rsp-text-white rsp-rounded disabled:rsp-bg-gray-300 disabled:rsp-cursor-not-allowed rsp-transition-colors",
|
|
@@ -4607,39 +4613,39 @@ function ya({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
4607
4613
|
((L.value || "").match(/\{\{(\d+)\}\}/g) || []).length >= 3 && /* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-gray-500 rsp-mt-1", children: "Maximum 3 variables allowed" })
|
|
4608
4614
|
] }),
|
|
4609
4615
|
(() => {
|
|
4610
|
-
const
|
|
4611
|
-
return
|
|
4616
|
+
const D = (L.value || "").match(/\{\{(\d+)\}\}/g) || [], Z = [...new Set(D.map((W) => W.replace(/[{}]/g, "")))];
|
|
4617
|
+
return Z.length === 0 ? null : /* @__PURE__ */ r("div", { className: "rsp-p-3 rsp-bg-gray-50 rsp-rounded-lg rsp-border rsp-border-gray-200", children: [
|
|
4612
4618
|
/* @__PURE__ */ e("h4", { className: "rsp-text-xs rsp-font-semibold rsp-text-gray-700 rsp-mb-2", children: "Sample Values for URL Variables" }),
|
|
4613
|
-
/* @__PURE__ */ e("div", { className: "rsp-space-y-2", children:
|
|
4614
|
-
var
|
|
4619
|
+
/* @__PURE__ */ e("div", { className: "rsp-space-y-2", children: Z.map((W) => {
|
|
4620
|
+
var ne, re;
|
|
4615
4621
|
return /* @__PURE__ */ r("div", { className: "rsp-space-y-1", children: [
|
|
4616
4622
|
/* @__PURE__ */ r("label", { className: "rsp-block rsp-text-xs rsp-text-gray-600 rsp-mb-1", children: [
|
|
4617
4623
|
"Variable ",
|
|
4618
4624
|
"{{",
|
|
4619
|
-
|
|
4625
|
+
W,
|
|
4620
4626
|
"}}"
|
|
4621
4627
|
] }),
|
|
4622
4628
|
/* @__PURE__ */ e(
|
|
4623
4629
|
"input",
|
|
4624
4630
|
{
|
|
4625
4631
|
type: "text",
|
|
4626
|
-
value: ((
|
|
4632
|
+
value: ((re = (ne = m.sampleContent) == null ? void 0 : ne.buttonVariables) == null ? void 0 : re[W]) || "",
|
|
4627
4633
|
onChange: (J) => {
|
|
4628
|
-
const
|
|
4634
|
+
const q = J.target.value;
|
|
4629
4635
|
s((Q) => ({
|
|
4630
4636
|
...Q,
|
|
4631
4637
|
carousel: {
|
|
4632
4638
|
...Q.carousel,
|
|
4633
|
-
cards: Q.carousel.cards.map((
|
|
4634
|
-
var
|
|
4635
|
-
return
|
|
4636
|
-
|
|
4639
|
+
cards: Q.carousel.cards.map((G) => {
|
|
4640
|
+
var K, ee, ie;
|
|
4641
|
+
return G.id !== m.id ? G : {
|
|
4642
|
+
...G,
|
|
4637
4643
|
sampleContent: {
|
|
4638
|
-
headerVariables: ((
|
|
4639
|
-
bodyVariables: ((
|
|
4644
|
+
headerVariables: ((K = G.sampleContent) == null ? void 0 : K.headerVariables) || {},
|
|
4645
|
+
bodyVariables: ((ee = G.sampleContent) == null ? void 0 : ee.bodyVariables) || {},
|
|
4640
4646
|
buttonVariables: {
|
|
4641
|
-
...((
|
|
4642
|
-
[
|
|
4647
|
+
...((ie = G.sampleContent) == null ? void 0 : ie.buttonVariables) || {},
|
|
4648
|
+
[W]: q
|
|
4643
4649
|
}
|
|
4644
4650
|
}
|
|
4645
4651
|
};
|
|
@@ -4648,7 +4654,7 @@ function ya({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
4648
4654
|
}));
|
|
4649
4655
|
},
|
|
4650
4656
|
className: "rsp-w-full rsp-px-3 rsp-py-2 rsp-border rsp-border-gray-300 rsp-rounded-md rsp-text-sm focus:rsp-outline-none focus:rsp-ring-1 focus:rsp-ring-blue-500 focus:rsp-border-blue-500 rsp-bg-white",
|
|
4651
|
-
placeholder: `Sample value (e.g., ${
|
|
4657
|
+
placeholder: `Sample value (e.g., ${W === "1" ? "order123" : "user456"})`
|
|
4652
4658
|
}
|
|
4653
4659
|
),
|
|
4654
4660
|
/* @__PURE__ */ e(
|
|
@@ -4656,21 +4662,21 @@ function ya({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
4656
4662
|
{
|
|
4657
4663
|
type: "button",
|
|
4658
4664
|
onClick: () => {
|
|
4659
|
-
const J = L.value || "",
|
|
4660
|
-
|
|
4661
|
-
|
|
4665
|
+
const J = L.value || "", q = new RegExp(`\\{\\{${W}\\}\\}`, "g"), Q = J.replace(q, "");
|
|
4666
|
+
j(m.id, L.id, "value", Q), s((G) => ({
|
|
4667
|
+
...G,
|
|
4662
4668
|
carousel: {
|
|
4663
|
-
|
|
4664
|
-
cards:
|
|
4665
|
-
var
|
|
4666
|
-
if (
|
|
4667
|
-
const
|
|
4669
|
+
...G.carousel,
|
|
4670
|
+
cards: G.carousel.cards.map((K) => {
|
|
4671
|
+
var ie, ve, ke;
|
|
4672
|
+
if (K.id !== m.id) return K;
|
|
4673
|
+
const ee = Object.fromEntries(Object.entries(((ie = K.sampleContent) == null ? void 0 : ie.buttonVariables) || {}).filter(([Ie]) => Ie !== W));
|
|
4668
4674
|
return {
|
|
4669
|
-
...
|
|
4675
|
+
...K,
|
|
4670
4676
|
sampleContent: {
|
|
4671
|
-
headerVariables: ((
|
|
4672
|
-
bodyVariables: ((
|
|
4673
|
-
buttonVariables:
|
|
4677
|
+
headerVariables: ((ve = K.sampleContent) == null ? void 0 : ve.headerVariables) || {},
|
|
4678
|
+
bodyVariables: ((ke = K.sampleContent) == null ? void 0 : ke.bodyVariables) || {},
|
|
4679
|
+
buttonVariables: ee
|
|
4674
4680
|
}
|
|
4675
4681
|
};
|
|
4676
4682
|
})
|
|
@@ -4682,7 +4688,7 @@ function ya({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
4682
4688
|
children: "×"
|
|
4683
4689
|
}
|
|
4684
4690
|
)
|
|
4685
|
-
] }, `button-${L.id}-sample-${
|
|
4691
|
+
] }, `button-${L.id}-sample-${W}`);
|
|
4686
4692
|
}) })
|
|
4687
4693
|
] });
|
|
4688
4694
|
})()
|
|
@@ -4695,7 +4701,7 @@ function ya({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
4695
4701
|
{
|
|
4696
4702
|
type: "text",
|
|
4697
4703
|
value: L.value || "",
|
|
4698
|
-
onChange: (
|
|
4704
|
+
onChange: (D) => j(m.id, L.id, "value", D.target.value),
|
|
4699
4705
|
placeholder: "+1234567890",
|
|
4700
4706
|
className: "rsp-w-full rsp-px-3 rsp-py-2 rsp-border rsp-border-gray-300 rsp-rounded-md rsp-text-sm focus:rsp-outline-none focus:rsp-border-blue-500 rsp-bg-white"
|
|
4701
4707
|
}
|
|
@@ -4723,42 +4729,42 @@ function ya({ template: a, setTemplate: s, onFileUpload: n }) {
|
|
|
4723
4729
|
] })
|
|
4724
4730
|
] }) }),
|
|
4725
4731
|
/* @__PURE__ */ e(
|
|
4726
|
-
|
|
4732
|
+
we,
|
|
4727
4733
|
{
|
|
4728
4734
|
isOpen: g,
|
|
4729
|
-
onClose: () =>
|
|
4735
|
+
onClose: () => o(!1),
|
|
4730
4736
|
onSelect: x
|
|
4731
4737
|
}
|
|
4732
4738
|
)
|
|
4733
4739
|
] });
|
|
4734
4740
|
}
|
|
4735
|
-
const
|
|
4741
|
+
const Te = async (a) => {
|
|
4736
4742
|
try {
|
|
4737
4743
|
console.log(`Starting file upload: ${a.name}`);
|
|
4738
|
-
const s = await
|
|
4744
|
+
const s = await ba(a);
|
|
4739
4745
|
return console.log(`File uploaded successfully: ${s}`), s;
|
|
4740
4746
|
} catch (s) {
|
|
4741
4747
|
throw console.error("Upload failed in parent:", s), s;
|
|
4742
4748
|
}
|
|
4743
|
-
},
|
|
4749
|
+
}, va = (a) => {
|
|
4744
4750
|
const n = (a.body || "").match(/\{\{(\d+)\}\}/g);
|
|
4745
4751
|
if (!n) return 0;
|
|
4746
4752
|
const i = n.map((c) => {
|
|
4747
|
-
const
|
|
4748
|
-
return
|
|
4753
|
+
const h = c.match(/{{(\d+)}}/);
|
|
4754
|
+
return h ? parseInt(h[1], 10) : 0;
|
|
4749
4755
|
});
|
|
4750
4756
|
return i.length > 0 ? Math.max(...i) : 0;
|
|
4751
4757
|
};
|
|
4752
|
-
function
|
|
4753
|
-
const [n, i] = X.useState(!1), c = X.useRef(null),
|
|
4758
|
+
function ka({ template: a, setTemplate: s }) {
|
|
4759
|
+
const [n, i] = X.useState(!1), c = X.useRef(null), h = () => {
|
|
4754
4760
|
i(!0), setTimeout(() => {
|
|
4755
4761
|
c.current && c.current.focus();
|
|
4756
4762
|
}, 0);
|
|
4757
|
-
}, l = (
|
|
4758
|
-
const g = c.current,
|
|
4759
|
-
s({ ...a, body:
|
|
4763
|
+
}, l = (N) => {
|
|
4764
|
+
const g = c.current, o = a.body, k = g && typeof g.selectionStart == "number" ? g.selectionStart : o.length, A = o.substring(0, k), d = o.substring(k), w = A + N + d;
|
|
4765
|
+
s({ ...a, body: w }), setTimeout(() => {
|
|
4760
4766
|
if (c.current) {
|
|
4761
|
-
const M = k +
|
|
4767
|
+
const M = k + N.length;
|
|
4762
4768
|
c.current.setSelectionRange(M, M), c.current.focus();
|
|
4763
4769
|
}
|
|
4764
4770
|
}, 0), i(!1);
|
|
@@ -4767,8 +4773,8 @@ function va({ template: a, setTemplate: s }) {
|
|
|
4767
4773
|
a.type !== "CAROUSEL" && /* @__PURE__ */ r("div", { className: "rsp-space-y-6", children: [
|
|
4768
4774
|
/* @__PURE__ */ e("h2", { className: "rsp-text-lg rsp-font-semibold rsp-text-gray-900", children: "Message Content" }),
|
|
4769
4775
|
/* @__PURE__ */ r("div", { className: "rsp-space-y-6", children: [
|
|
4770
|
-
/* @__PURE__ */ e(
|
|
4771
|
-
/* @__PURE__ */ e(
|
|
4776
|
+
/* @__PURE__ */ e(oa, { template: a, setTemplate: s, onFileUpload: Te }),
|
|
4777
|
+
/* @__PURE__ */ e(ha, { template: a, setTemplate: s })
|
|
4772
4778
|
] })
|
|
4773
4779
|
] }),
|
|
4774
4780
|
a.type === "CAROUSEL" && /* @__PURE__ */ r("div", { className: "rsp-space-y-6", children: [
|
|
@@ -4783,7 +4789,7 @@ function va({ template: a, setTemplate: s }) {
|
|
|
4783
4789
|
{
|
|
4784
4790
|
ref: c,
|
|
4785
4791
|
value: a.body,
|
|
4786
|
-
onChange: (
|
|
4792
|
+
onChange: (N) => s({ ...a, body: N.target.value }),
|
|
4787
4793
|
maxLength: 1024,
|
|
4788
4794
|
rows: 4,
|
|
4789
4795
|
className: "rsp-w-full rsp-px-3 rsp-py-2 rsp-border rsp-border-gray-300 rsp-rounded-md rsp-text-sm focus:rsp-outline-none focus:rsp-border-blue-500 rsp-bg-white rsp-resize-none",
|
|
@@ -4797,8 +4803,8 @@ function va({ template: a, setTemplate: s }) {
|
|
|
4797
4803
|
"button",
|
|
4798
4804
|
{
|
|
4799
4805
|
onClick: () => {
|
|
4800
|
-
const
|
|
4801
|
-
s({ ...a, body: a.body +
|
|
4806
|
+
const o = `{{${va(a) + 1}}}`;
|
|
4807
|
+
s({ ...a, body: a.body + o });
|
|
4802
4808
|
},
|
|
4803
4809
|
className: "rsp-p-1 rsp-text-gray-500 hover:rsp-text-gray-700 hover:rsp-bg-gray-100 rsp-rounded",
|
|
4804
4810
|
title: "Add Variable",
|
|
@@ -4808,10 +4814,10 @@ function va({ template: a, setTemplate: s }) {
|
|
|
4808
4814
|
/* @__PURE__ */ e(
|
|
4809
4815
|
"button",
|
|
4810
4816
|
{
|
|
4811
|
-
onClick:
|
|
4817
|
+
onClick: h,
|
|
4812
4818
|
className: "rsp-p-1 rsp-text-gray-500 hover:rsp-text-gray-700 hover:rsp-bg-gray-100 rsp-rounded",
|
|
4813
4819
|
title: "Add emoji",
|
|
4814
|
-
children: /* @__PURE__ */ e(
|
|
4820
|
+
children: /* @__PURE__ */ e(be, { className: "rsp-w-4 rsp-h-4" })
|
|
4815
4821
|
}
|
|
4816
4822
|
)
|
|
4817
4823
|
] }),
|
|
@@ -4821,15 +4827,15 @@ function va({ template: a, setTemplate: s }) {
|
|
|
4821
4827
|
] })
|
|
4822
4828
|
] }),
|
|
4823
4829
|
(() => {
|
|
4824
|
-
const
|
|
4830
|
+
const N = a.body.match(/\{\{(\d+)\}\}/g) || [], g = [...new Set(N.map((o) => o.replace(/[{}]/g, "")))];
|
|
4825
4831
|
return g.length === 0 ? null : /* @__PURE__ */ r("div", { className: "rsp-mt-3", children: [
|
|
4826
4832
|
/* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-font-medium rsp-text-gray-600 rsp-mb-2", children: "Sample Values" }),
|
|
4827
|
-
/* @__PURE__ */ e("div", { className: "rsp-grid rsp-grid-cols-3 rsp-gap-2", children: g.map((
|
|
4828
|
-
var k,
|
|
4833
|
+
/* @__PURE__ */ e("div", { className: "rsp-grid rsp-grid-cols-3 rsp-gap-2", children: g.map((o) => {
|
|
4834
|
+
var k, A;
|
|
4829
4835
|
return /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-2", children: [
|
|
4830
4836
|
/* @__PURE__ */ r("label", { className: "rsp-text-xs rsp-text-gray-500 rsp-whitespace-nowrap", children: [
|
|
4831
4837
|
"{{",
|
|
4832
|
-
|
|
4838
|
+
o,
|
|
4833
4839
|
"}}",
|
|
4834
4840
|
":"
|
|
4835
4841
|
] }),
|
|
@@ -4837,19 +4843,19 @@ function va({ template: a, setTemplate: s }) {
|
|
|
4837
4843
|
"input",
|
|
4838
4844
|
{
|
|
4839
4845
|
type: "text",
|
|
4840
|
-
value: ((
|
|
4846
|
+
value: ((A = (k = a.sampleContent) == null ? void 0 : k.bodyVariables) == null ? void 0 : A[o]) || "",
|
|
4841
4847
|
onChange: (d) => {
|
|
4842
4848
|
var M, b, y;
|
|
4843
|
-
const
|
|
4849
|
+
const w = {
|
|
4844
4850
|
...a.sampleContent,
|
|
4845
4851
|
headerVariables: ((M = a.sampleContent) == null ? void 0 : M.headerVariables) || {},
|
|
4846
4852
|
bodyVariables: {
|
|
4847
4853
|
...(b = a.sampleContent) == null ? void 0 : b.bodyVariables,
|
|
4848
|
-
[
|
|
4854
|
+
[o]: d.target.value
|
|
4849
4855
|
},
|
|
4850
4856
|
buttonVariables: ((y = a.sampleContent) == null ? void 0 : y.buttonVariables) || {}
|
|
4851
4857
|
};
|
|
4852
|
-
s({ ...a, sampleContent:
|
|
4858
|
+
s({ ...a, sampleContent: w });
|
|
4853
4859
|
},
|
|
4854
4860
|
className: "rsp-flex-1 rsp-px-2 rsp-py-1 rsp-border rsp-border-gray-300 rsp-rounded rsp-text-xs focus:rsp-outline-none focus:rsp-border-blue-500",
|
|
4855
4861
|
placeholder: "Sample"
|
|
@@ -4861,10 +4867,10 @@ function va({ template: a, setTemplate: s }) {
|
|
|
4861
4867
|
type: "button",
|
|
4862
4868
|
onClick: () => {
|
|
4863
4869
|
var b, y, t;
|
|
4864
|
-
const d = new RegExp(`\\{\\{${
|
|
4870
|
+
const d = new RegExp(`\\{\\{${o}\\}\\}`, "g"), w = (a.body || "").replace(d, ""), M = Object.fromEntries(Object.entries(((b = a.sampleContent) == null ? void 0 : b.bodyVariables) || {}).filter(([x]) => x !== o));
|
|
4865
4871
|
s({
|
|
4866
4872
|
...a,
|
|
4867
|
-
body:
|
|
4873
|
+
body: w,
|
|
4868
4874
|
sampleContent: {
|
|
4869
4875
|
...a.sampleContent,
|
|
4870
4876
|
bodyVariables: M,
|
|
@@ -4878,29 +4884,29 @@ function va({ template: a, setTemplate: s }) {
|
|
|
4878
4884
|
children: "×"
|
|
4879
4885
|
}
|
|
4880
4886
|
)
|
|
4881
|
-
] }, `global-body-sample-${
|
|
4887
|
+
] }, `global-body-sample-${o}`);
|
|
4882
4888
|
}) })
|
|
4883
4889
|
] });
|
|
4884
4890
|
})()
|
|
4885
4891
|
] }) })
|
|
4886
4892
|
] }),
|
|
4887
4893
|
a.type === "CAROUSEL" && /* @__PURE__ */ e("div", { className: "rsp-space-y-6", children: /* @__PURE__ */ e(
|
|
4888
|
-
|
|
4894
|
+
wa,
|
|
4889
4895
|
{
|
|
4890
4896
|
template: a,
|
|
4891
4897
|
setTemplate: s,
|
|
4892
|
-
onFileUpload:
|
|
4898
|
+
onFileUpload: Te
|
|
4893
4899
|
}
|
|
4894
4900
|
) }),
|
|
4895
4901
|
a.type !== "CAROUSEL" && /* @__PURE__ */ e("div", { className: "rsp-space-y-6", children: /* @__PURE__ */ e(
|
|
4896
|
-
|
|
4902
|
+
ua,
|
|
4897
4903
|
{
|
|
4898
4904
|
template: a,
|
|
4899
4905
|
setTemplate: s
|
|
4900
4906
|
}
|
|
4901
4907
|
) }),
|
|
4902
4908
|
/* @__PURE__ */ e(
|
|
4903
|
-
|
|
4909
|
+
we,
|
|
4904
4910
|
{
|
|
4905
4911
|
isOpen: n,
|
|
4906
4912
|
onClose: () => i(!1),
|
|
@@ -4909,21 +4915,21 @@ function va({ template: a, setTemplate: s }) {
|
|
|
4909
4915
|
)
|
|
4910
4916
|
] });
|
|
4911
4917
|
}
|
|
4912
|
-
function
|
|
4918
|
+
function Na({ type: a }) {
|
|
4913
4919
|
switch (a) {
|
|
4914
4920
|
case "QUICK_REPLY":
|
|
4915
|
-
return /* @__PURE__ */ e(
|
|
4921
|
+
return /* @__PURE__ */ e(Je, { className: "w-4 h-4" });
|
|
4916
4922
|
case "URL":
|
|
4917
|
-
return /* @__PURE__ */ e(
|
|
4923
|
+
return /* @__PURE__ */ e(We, { className: "w-4 h-4" });
|
|
4918
4924
|
case "CALL":
|
|
4919
|
-
return /* @__PURE__ */ e(
|
|
4925
|
+
return /* @__PURE__ */ e(Ae, { className: "w-4 h-4" });
|
|
4920
4926
|
case "FLOW":
|
|
4921
|
-
return /* @__PURE__ */ e(
|
|
4927
|
+
return /* @__PURE__ */ e(Qe, { className: "w-4 h-4" });
|
|
4922
4928
|
default:
|
|
4923
4929
|
return null;
|
|
4924
4930
|
}
|
|
4925
4931
|
}
|
|
4926
|
-
function
|
|
4932
|
+
function Ca({ buttons: a, flowButtonText: s, onShowAllOptions: n }) {
|
|
4927
4933
|
const i = [...a];
|
|
4928
4934
|
s && i.push({
|
|
4929
4935
|
id: "flow-button",
|
|
@@ -4932,18 +4938,18 @@ function Na({ buttons: a, flowButtonText: s, onShowAllOptions: n }) {
|
|
|
4932
4938
|
});
|
|
4933
4939
|
const c = i.slice(0, 2);
|
|
4934
4940
|
return /* @__PURE__ */ r("div", { className: "rsp-divide-y rsp-divide-gray-200", children: [
|
|
4935
|
-
c.map((
|
|
4941
|
+
c.map((h) => /* @__PURE__ */ r(
|
|
4936
4942
|
"button",
|
|
4937
4943
|
{
|
|
4938
4944
|
className: "rsp-w-full rsp-py-4 rsp-text-[#128C7E] rsp-text-[15px] rsp-font-medium rsp-bg-white hover:rsp-bg-gray-50 rsp-flex rsp-items-center rsp-gap-3 rsp-px-4 rsp-transition-colors",
|
|
4939
4945
|
style: { fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif' },
|
|
4940
4946
|
children: [
|
|
4941
|
-
/* @__PURE__ */ e("div", { className: "rsp-text-[#128C7E]", children: /* @__PURE__ */ e(
|
|
4942
|
-
/* @__PURE__ */ e("span", { className: "rsp-flex-1 rsp-text-left rsp-break-words rsp-break-all rsp-whitespace-pre-wrap", children:
|
|
4943
|
-
|
|
4947
|
+
/* @__PURE__ */ e("div", { className: "rsp-text-[#128C7E]", children: /* @__PURE__ */ e(Na, { type: h.type }) }),
|
|
4948
|
+
/* @__PURE__ */ e("span", { className: "rsp-flex-1 rsp-text-left rsp-break-words rsp-break-all rsp-whitespace-pre-wrap", children: h.text }),
|
|
4949
|
+
h.id === "flow-button" && /* @__PURE__ */ e(Fe, { className: "rsp-w-5 rsp-h-5 rsp-text-[#128C7E] rsp-ml-auto" })
|
|
4944
4950
|
]
|
|
4945
4951
|
},
|
|
4946
|
-
|
|
4952
|
+
h.id
|
|
4947
4953
|
)),
|
|
4948
4954
|
i.length > 2 && /* @__PURE__ */ r(
|
|
4949
4955
|
"button",
|
|
@@ -4959,16 +4965,16 @@ function Na({ buttons: a, flowButtonText: s, onShowAllOptions: n }) {
|
|
|
4959
4965
|
)
|
|
4960
4966
|
] });
|
|
4961
4967
|
}
|
|
4962
|
-
function
|
|
4963
|
-
var
|
|
4964
|
-
const [s, n] = B(!1), [i, c] = B(0),
|
|
4968
|
+
function Ea({ template: a }) {
|
|
4969
|
+
var A, d, w, M;
|
|
4970
|
+
const [s, n] = B(!1), [i, c] = B(0), h = (A = a.carousel) != null && A.cards ? a.carousel.cards.length : 0;
|
|
4965
4971
|
le(() => {
|
|
4966
|
-
a.type === "CAROUSEL" &&
|
|
4967
|
-
}, [
|
|
4972
|
+
a.type === "CAROUSEL" && h > 0 ? i >= h && c(0) : c(0);
|
|
4973
|
+
}, [h, a.type]);
|
|
4968
4974
|
const l = (b) => b ? b.replace(/\{\{(\d+)\}\}/g, (y, t) => {
|
|
4969
4975
|
var x, p;
|
|
4970
4976
|
return ((p = (x = a.sampleContent) == null ? void 0 : x.headerVariables) == null ? void 0 : p[t]) || `[Variable ${t}]`;
|
|
4971
|
-
}) : "",
|
|
4977
|
+
}) : "", N = (b) => b ? b.replace(/\{\{(\d+)\}\}/g, (y, t) => {
|
|
4972
4978
|
var x, p;
|
|
4973
4979
|
return ((p = (x = a.sampleContent) == null ? void 0 : x.bodyVariables) == null ? void 0 : p[t]) || `[Variable ${t}]`;
|
|
4974
4980
|
}) : "", g = (b) => {
|
|
@@ -4976,8 +4982,8 @@ function Ca({ template: a }) {
|
|
|
4976
4982
|
const y = (b == null ? void 0 : b.body) ?? "";
|
|
4977
4983
|
if (!y) return "";
|
|
4978
4984
|
const t = ((x = b == null ? void 0 : b.sampleContent) == null ? void 0 : x.bodyVariables) ?? {};
|
|
4979
|
-
return y.replace(/\{\{(\d+)\}\}/g, (p,
|
|
4980
|
-
},
|
|
4985
|
+
return y.replace(/\{\{(\d+)\}\}/g, (p, v) => t[v] || `[Variable ${v}]`);
|
|
4986
|
+
}, o = a.headerType !== "NONE" || a.body || a.footer || a.buttons.length > 0 || a.type === "CAROUSEL" && ((d = a.carousel) == null ? void 0 : d.cards.length), k = a.headerText || a.body || a.footer;
|
|
4981
4987
|
return /* @__PURE__ */ r("div", { className: "rsp-bg-white rsp-rounded-lg rsp-shadow-sm rsp-border rsp-border-gray-200", children: [
|
|
4982
4988
|
/* @__PURE__ */ r("div", { className: "rsp-p-4 rsp-border-b rsp-border-gray-200", children: [
|
|
4983
4989
|
/* @__PURE__ */ e("h3", { className: "rsp-text-lg rsp-font-semibold rsp-text-gray-900", children: "Preview" }),
|
|
@@ -5024,7 +5030,7 @@ function Ca({ template: a }) {
|
|
|
5024
5030
|
] }),
|
|
5025
5031
|
/* @__PURE__ */ r("div", { className: "rsp-absolute rsp-top-[105px] rsp-left-0 rsp-right-0 rsp-bottom-[60px] rsp-bg-gradient-to-b rsp-from-[#E8E2DB] rsp-via-[#E5DDD5] rsp-to-[#DDD5CC] rsp-overflow-y-auto", children: [
|
|
5026
5032
|
/* @__PURE__ */ e("div", { className: "rsp-absolute rsp-inset-0 rsp-opacity-[0.03]", style: { backgroundImage: `url("data:image/svg+xml,%3Csvg width='80' height='80' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23000000' fill-opacity='0.08'%3E%3Cpath d='M40 40c0-4.4-3.6-8-8-8s-8 3.6-8 8 3.6 8 8 8 8-3.6 8-8zm0-32c0-4.4-3.6-8-8-8s-8 3.6-8 8 3.6 8 8 8 8-3.6 8-8zm32 32c0-4.4-3.6-8-8-8s-8 3.6-8 8 3.6 8 8 8 8-3.6 8-8z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E")` } }),
|
|
5027
|
-
/* @__PURE__ */ e("div", { className: "rsp-relative rsp-px-4 rsp-py-4", children:
|
|
5033
|
+
/* @__PURE__ */ e("div", { className: "rsp-relative rsp-px-4 rsp-py-4", children: o ? /* @__PURE__ */ r("div", { className: "rsp-flex rsp-flex-col rsp-items-start", children: [
|
|
5028
5034
|
a.headerType === "MEDIA" && a.mediaUrl && /* @__PURE__ */ r("div", { className: "rsp-max-w-[220px] rsp-w-auto rsp-rounded-xl rsp-overflow-hidden rsp-shadow-md rsp-mb-1.5 rsp-animate-slide-up rsp-border rsp-border-gray-200", children: [
|
|
5029
5035
|
a.mediaType === "IMAGE" && /* @__PURE__ */ e(
|
|
5030
5036
|
"img",
|
|
@@ -5051,14 +5057,14 @@ function Ca({ template: a }) {
|
|
|
5051
5057
|
] }),
|
|
5052
5058
|
k && /* @__PURE__ */ e("div", { className: "rsp-flex rsp-justify-start rsp-mb-1.5", children: /* @__PURE__ */ r("div", { className: "rsp-bg-gradient-to-b rsp-from-white rsp-to-[#fafafa] rsp-rounded-[12px] rsp-max-w-[220px] rsp-shadow-[0_2px_8px_rgba(0,0,0,0.08)] rsp-relative rsp-border rsp-border-gray-100 rsp-animate-slide-up", children: [
|
|
5053
5059
|
a.headerType === "TEXT" && a.headerText && /* @__PURE__ */ e("div", { className: "rsp-px-4 rsp-pt-3 rsp-pb-2", children: /* @__PURE__ */ e("div", { className: "rsp-text-[15px] rsp-font-semibold rsp-text-[#111b21] rsp-leading-[1.3] rsp-tracking-normal rsp-break-words", style: { fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif' }, children: l(a.headerText) }) }),
|
|
5054
|
-
a.body && /* @__PURE__ */ e("div", { className: "rsp-px-4 rsp-py-2", children: /* @__PURE__ */ e("div", { className: "rsp-text-[14px] rsp-text-[#111b21] rsp-leading-[1.4] rsp-whitespace-pre-wrap rsp-tracking-normal rsp-break-words", style: { fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif' }, children:
|
|
5060
|
+
a.body && /* @__PURE__ */ e("div", { className: "rsp-px-4 rsp-py-2", children: /* @__PURE__ */ e("div", { className: "rsp-text-[14px] rsp-text-[#111b21] rsp-leading-[1.4] rsp-whitespace-pre-wrap rsp-tracking-normal rsp-break-words", style: { fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif' }, children: N(a.body) }) }),
|
|
5055
5061
|
a.footer && /* @__PURE__ */ e("div", { className: "rsp-px-4 rsp-pb-2", children: /* @__PURE__ */ e("div", { className: "rsp-text-[12px] rsp-text-[#667781] rsp-pt-2 rsp-border-t rsp-border-gray-100 rsp-break-words rsp-break-all rsp-whitespace-pre-wrap", style: { fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif' }, children: a.footer }) }),
|
|
5056
5062
|
/* @__PURE__ */ e("div", { className: "rsp-px-4 rsp-pb-2 rsp-text-right", children: /* @__PURE__ */ r("div", { className: "rsp-text-[11px] rsp-text-[#667781] rsp-flex rsp-items-center rsp-justify-end rsp-gap-1 rsp-opacity-80", style: { fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif' }, children: [
|
|
5057
5063
|
"9:41 AM",
|
|
5058
5064
|
/* @__PURE__ */ e("svg", { className: "rsp-w-3 rsp-h-3 rsp-text-[#53bdeb]", viewBox: "0 0 16 15", fill: "currentColor", children: /* @__PURE__ */ e("path", { d: "M15.01 3.316l-.478-.372a.365.365 0 0 0-.51.063L8.666 9.879a.32.32 0 0 1-.484.033l-.358-.325a.319.319 0 0 0-.484.032l-.378.483a.418.418 0 0 0 .036.541l1.32 1.266c.143.14.361.125.484-.033l6.272-8.048a.366.366 0 0 0-.064-.512zm-4.1 0l-.478-.372a.365.365 0 0 0-.51.063L4.566 9.879a.32.32 0 0 1-.484.033L1.891 7.769a.319.319 0 0 0-.484.032l-.378.483a.418.418 0 0 0 .036.541l3.61 3.463c.143.14.361.125.484-.033l6.272-8.048a.365.365 0 0 0-.064-.512z" }) })
|
|
5059
5065
|
] }) })
|
|
5060
5066
|
] }) }),
|
|
5061
|
-
a.type === "CAROUSEL" && (((M = (
|
|
5067
|
+
a.type === "CAROUSEL" && (((M = (w = a.carousel) == null ? void 0 : w.cards) == null ? void 0 : M.length) || 0) > 0 && /* @__PURE__ */ e("div", { className: "rsp-flex rsp-justify-start rsp-mb-1.5", children: /* @__PURE__ */ e("div", { className: "rsp-w-[220px] rsp-animate-slide-up", children: /* @__PURE__ */ e("div", { className: "rsp-bg-gradient-to-b rsp-from-white rsp-to-[#fafafa] rsp-rounded-[12px] rsp-overflow-hidden rsp-shadow-[0_2px_8px_rgba(0,0,0,0.08)] rsp-border rsp-border-gray-100 rsp-relative rsp-min-h-[280px] rsp-flex rsp-flex-col", children: /* @__PURE__ */ r("div", { className: "rsp-relative rsp-flex-1 rsp-flex rsp-flex-col", children: [
|
|
5062
5068
|
(() => {
|
|
5063
5069
|
var y, t;
|
|
5064
5070
|
const b = a.carousel && a.carousel.cards.length > 0 ? a.carousel.cards[i] || a.carousel.cards[0] : void 0;
|
|
@@ -5132,7 +5138,7 @@ function Ca({ template: a }) {
|
|
|
5132
5138
|
)) })
|
|
5133
5139
|
] }) }) }) }),
|
|
5134
5140
|
a.buttons.length > 0 && /* @__PURE__ */ e("div", { className: "rsp-flex rsp-justify-start", children: /* @__PURE__ */ e("div", { className: "rsp-bg-gradient-to-b rsp-from-white rsp-to-[#fafafa] rsp-rounded-[12px] rsp-overflow-hidden rsp-shadow-[0_2px_8px_rgba(0,0,0,0.08)] rsp-max-w-[220px] rsp-w-full rsp-border rsp-border-gray-100 rsp-animate-slide-up", children: /* @__PURE__ */ e(
|
|
5135
|
-
|
|
5141
|
+
Ca,
|
|
5136
5142
|
{
|
|
5137
5143
|
buttons: a.buttons,
|
|
5138
5144
|
onShowAllOptions: () => n(!0)
|
|
@@ -5181,7 +5187,7 @@ function Ca({ template: a }) {
|
|
|
5181
5187
|
] }) }) })
|
|
5182
5188
|
] });
|
|
5183
5189
|
}
|
|
5184
|
-
const
|
|
5190
|
+
const Se = {
|
|
5185
5191
|
name: "",
|
|
5186
5192
|
category: "MARKETING",
|
|
5187
5193
|
type: "BASIC",
|
|
@@ -5193,9 +5199,9 @@ const Le = {
|
|
|
5193
5199
|
footer: "",
|
|
5194
5200
|
buttons: []
|
|
5195
5201
|
};
|
|
5196
|
-
function
|
|
5202
|
+
function Va({ editId: a, onCancel: s }) {
|
|
5197
5203
|
var y, t, x;
|
|
5198
|
-
const [n, i] = B(
|
|
5204
|
+
const [n, i] = B(Se), [c, h] = B(!0), [l, N] = B(!1), [g, o] = B(!1), [k, A] = B(null), [d, w] = B({
|
|
5199
5205
|
isOpen: !1
|
|
5200
5206
|
});
|
|
5201
5207
|
B({
|
|
@@ -5203,60 +5209,60 @@ function Sa({ editId: a, onCancel: s }) {
|
|
|
5203
5209
|
}), le(() => {
|
|
5204
5210
|
if (k) {
|
|
5205
5211
|
const p = setTimeout(() => {
|
|
5206
|
-
|
|
5212
|
+
A(null);
|
|
5207
5213
|
}, 5e3);
|
|
5208
5214
|
return () => clearTimeout(p);
|
|
5209
5215
|
}
|
|
5210
5216
|
}, [k]);
|
|
5211
5217
|
const M = async () => {
|
|
5212
|
-
var p,
|
|
5218
|
+
var p, v, j;
|
|
5213
5219
|
try {
|
|
5214
|
-
if (
|
|
5220
|
+
if (o(!0), A(null), !n.name || !n.body)
|
|
5215
5221
|
throw new Error("Template name and body are required");
|
|
5216
5222
|
const R = localStorage.getItem("account"), f = R ? JSON.parse(R) : { apiKey: "" };
|
|
5217
5223
|
if (!f.apiKey)
|
|
5218
5224
|
throw new Error("Please set your API key in the dashboard first");
|
|
5219
5225
|
let C;
|
|
5220
5226
|
if (a) {
|
|
5221
|
-
const
|
|
5222
|
-
if (!
|
|
5223
|
-
throw new Error(
|
|
5227
|
+
const T = await na(f.apiKey, a, n);
|
|
5228
|
+
if (!T.success)
|
|
5229
|
+
throw new Error(T.message || "Update failed");
|
|
5224
5230
|
C = {
|
|
5225
5231
|
status: "success",
|
|
5226
5232
|
data: { details: [{ template_name: n.name, template_id: a }] }
|
|
5227
5233
|
};
|
|
5228
|
-
} else if (C = await
|
|
5234
|
+
} else if (C = await sa(f, n), C.status === "error")
|
|
5229
5235
|
throw new Error(C.message);
|
|
5230
5236
|
if (C.status === "error")
|
|
5231
5237
|
throw new Error(C.message);
|
|
5232
|
-
|
|
5238
|
+
w({
|
|
5233
5239
|
isOpen: !0,
|
|
5234
5240
|
templateName: (p = C.data) == null ? void 0 : p.details[0].template_name,
|
|
5235
|
-
templateId: (
|
|
5236
|
-
template: (
|
|
5237
|
-
}), i(
|
|
5241
|
+
templateId: (v = C.data) == null ? void 0 : v.details[0].template_id,
|
|
5242
|
+
template: (j = C.data) == null ? void 0 : j.template
|
|
5243
|
+
}), i(Se);
|
|
5238
5244
|
} catch (R) {
|
|
5239
|
-
|
|
5245
|
+
A(R instanceof Error ? R.message : "An error occurred while creating the template");
|
|
5240
5246
|
} finally {
|
|
5241
|
-
|
|
5247
|
+
o(!1);
|
|
5242
5248
|
}
|
|
5243
5249
|
};
|
|
5244
5250
|
le(() => {
|
|
5245
5251
|
if (!a) return;
|
|
5246
5252
|
(async () => {
|
|
5247
5253
|
try {
|
|
5248
|
-
const
|
|
5249
|
-
if (!
|
|
5254
|
+
const v = localStorage.getItem("account"), j = v ? JSON.parse(v) : { apiKey: "" };
|
|
5255
|
+
if (!j.apiKey)
|
|
5250
5256
|
throw new Error("Please set your API key in the dashboard first");
|
|
5251
|
-
const R = await
|
|
5257
|
+
const R = await ia(j.apiKey, a);
|
|
5252
5258
|
i((f) => ({ ...f, ...R }));
|
|
5253
|
-
} catch (
|
|
5254
|
-
console.error("Failed to load template for edit",
|
|
5259
|
+
} catch (v) {
|
|
5260
|
+
console.error("Failed to load template for edit", v), A(v instanceof Error ? v.message : "Failed to load template");
|
|
5255
5261
|
}
|
|
5256
5262
|
})();
|
|
5257
5263
|
}, [a]);
|
|
5258
5264
|
const b = () => {
|
|
5259
|
-
|
|
5265
|
+
w({ isOpen: !1 }), s && s();
|
|
5260
5266
|
};
|
|
5261
5267
|
return /* @__PURE__ */ r("div", { className: "rsp-min-h-screen rsp-bg-[#f5f7fc] rsp-rounded-lg rsp-shadow-sm", children: [
|
|
5262
5268
|
/* @__PURE__ */ r("div", { className: "rsp-max-w-[1200px] rsp-mx-auto rsp-px-6 rsp-h-full", children: [
|
|
@@ -5266,7 +5272,7 @@ function Sa({ editId: a, onCancel: s }) {
|
|
|
5266
5272
|
/* @__PURE__ */ r(
|
|
5267
5273
|
"button",
|
|
5268
5274
|
{
|
|
5269
|
-
onClick: () =>
|
|
5275
|
+
onClick: () => h(!c),
|
|
5270
5276
|
className: `rsp-flex rsp-items-center rsp-gap-2 rsp-px-4 rsp-py-2 rsp-rounded-md rsp-text-sm rsp-font-medium rsp-transition-colors
|
|
5271
5277
|
${c ? "rsp-bg-blue-100 rsp-text-blue-700 rsp-border rsp-border-blue-200" : "rsp-bg-gray-100 rsp-text-gray-700 rsp-border rsp-border-gray-200"}`,
|
|
5272
5278
|
children: [
|
|
@@ -5284,7 +5290,7 @@ function Sa({ editId: a, onCancel: s }) {
|
|
|
5284
5290
|
onClick: () => s == null ? void 0 : s(),
|
|
5285
5291
|
className: "rsp-flex rsp-items-center rsp-gap-1 rsp-text-sm rsp-font-medium rsp-text-[#0043ff] hover:rsp-text-[#0033cc] rsp-transition-colors rsp-bg-transparent rsp-border-0 rsp-cursor-pointer",
|
|
5286
5292
|
children: [
|
|
5287
|
-
/* @__PURE__ */ e(
|
|
5293
|
+
/* @__PURE__ */ e(qe, { className: "rsp-w-5 rsp-h-5 rsp-relative rsp-left-[6px]" }),
|
|
5288
5294
|
"Back"
|
|
5289
5295
|
]
|
|
5290
5296
|
}
|
|
@@ -5306,7 +5312,7 @@ function Sa({ editId: a, onCancel: s }) {
|
|
|
5306
5312
|
type: "text",
|
|
5307
5313
|
value: n.name,
|
|
5308
5314
|
onChange: (p) => i({ ...n, name: p.target.value.replace(/\s/g, "_").replace(/[^a-zA-Z0-9_]/g, "").replace(/_+/g, "_") }),
|
|
5309
|
-
onBlur: () =>
|
|
5315
|
+
onBlur: () => N(!0),
|
|
5310
5316
|
className: "rsp-w-full rsp-px-0 rsp-py-2 rsp-border-0 rsp-border-b rsp-border-gray-300 rsp-text-sm focus:rsp-outline-none focus:rsp-border-blue-500 rsp-bg-transparent",
|
|
5311
5317
|
placeholder: "Template name cannot Have capital letters and space"
|
|
5312
5318
|
}
|
|
@@ -5346,7 +5352,7 @@ function Sa({ editId: a, onCancel: s }) {
|
|
|
5346
5352
|
value: n.language,
|
|
5347
5353
|
onChange: (p) => i({ ...n, language: p.target.value }),
|
|
5348
5354
|
className: "rsp-w-full rsp-px-0 rsp-py-2 rsp-border-0 rsp-border-b rsp-border-gray-300 rsp-text-sm focus:rsp-outline-none focus:rsp-border-blue-500 rsp-bg-transparent rsp-appearance-none",
|
|
5349
|
-
children:
|
|
5355
|
+
children: ta.map((p) => /* @__PURE__ */ e("option", { value: p.value, children: p.label }, p.value))
|
|
5350
5356
|
}
|
|
5351
5357
|
),
|
|
5352
5358
|
/* @__PURE__ */ e("div", { className: "rsp-absolute rsp-inset-y-0 rsp-right-0 rsp-flex rsp-items-center rsp-px-2 rsp-pointer-events-none", children: /* @__PURE__ */ e("svg", { className: "rsp-w-4 rsp-h-4 rsp-text-gray-400", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 9l-7 7-7-7" }) }) }),
|
|
@@ -5363,10 +5369,10 @@ function Sa({ editId: a, onCancel: s }) {
|
|
|
5363
5369
|
{
|
|
5364
5370
|
value: n.type,
|
|
5365
5371
|
onChange: (p) => {
|
|
5366
|
-
const
|
|
5367
|
-
|
|
5372
|
+
const v = p.target.value;
|
|
5373
|
+
v === "CAROUSEL" && !n.carousel ? i({
|
|
5368
5374
|
...n,
|
|
5369
|
-
type:
|
|
5375
|
+
type: v,
|
|
5370
5376
|
carousel: {
|
|
5371
5377
|
type: "IMAGE",
|
|
5372
5378
|
cards: [{
|
|
@@ -5378,7 +5384,7 @@ function Sa({ editId: a, onCancel: s }) {
|
|
|
5378
5384
|
buttons: []
|
|
5379
5385
|
}]
|
|
5380
5386
|
}
|
|
5381
|
-
}) : i({ ...n, type:
|
|
5387
|
+
}) : i({ ...n, type: v });
|
|
5382
5388
|
},
|
|
5383
5389
|
className: "rsp-w-full rsp-px-0 rsp-py-2 rsp-border-0 rsp-border-b rsp-border-gray-300 rsp-text-sm focus:rsp-outline-none focus:rsp-border-blue-500 rsp-bg-transparent rsp-appearance-none",
|
|
5384
5390
|
children: [
|
|
@@ -5411,10 +5417,10 @@ function Sa({ editId: a, onCancel: s }) {
|
|
|
5411
5417
|
] })
|
|
5412
5418
|
] })
|
|
5413
5419
|
] }),
|
|
5414
|
-
/* @__PURE__ */ e("div", { className: "rsp-bg-white rsp-p-6 rsp-rounded-lg rsp-shadow-sm", children: /* @__PURE__ */ e(
|
|
5420
|
+
/* @__PURE__ */ e("div", { className: "rsp-bg-white rsp-p-6 rsp-rounded-lg rsp-shadow-sm", children: /* @__PURE__ */ e(ka, { template: n, setTemplate: i }) }),
|
|
5415
5421
|
/* @__PURE__ */ r("div", { className: "rsp-bg-white rsp-p-6 rsp-rounded-lg rsp-shadow-sm rsp-pt-6 rsp-border-t rsp-border-gray-200", children: [
|
|
5416
5422
|
k && /* @__PURE__ */ r("div", { className: "rsp-mb-4 rsp-flex rsp-items-start rsp-gap-3 rsp-p-4 rsp-rounded-lg rsp-bg-red-50 rsp-border-l-4 rsp-border-l-red-500 rsp-relative rsp-animate-fade-in", children: [
|
|
5417
|
-
/* @__PURE__ */ e(
|
|
5423
|
+
/* @__PURE__ */ e(he, { className: "rsp-w-5 rsp-h-5 rsp-text-red-500 rsp-flex-shrink-0 rsp-mt-0.5" }),
|
|
5418
5424
|
/* @__PURE__ */ r("div", { children: [
|
|
5419
5425
|
/* @__PURE__ */ e("h3", { className: "rsp-text-sm rsp-font-medium rsp-text-red-800", children: "Error" }),
|
|
5420
5426
|
/* @__PURE__ */ e("p", { className: "rsp-mt-1 rsp-text-sm rsp-text-red-700", children: k })
|
|
@@ -5422,9 +5428,9 @@ function Sa({ editId: a, onCancel: s }) {
|
|
|
5422
5428
|
/* @__PURE__ */ e(
|
|
5423
5429
|
"button",
|
|
5424
5430
|
{
|
|
5425
|
-
onClick: () =>
|
|
5431
|
+
onClick: () => A(null),
|
|
5426
5432
|
className: "rsp-absolute rsp-top-2 rsp-right-2 rsp-p-1 hover:rsp-bg-red-100 rsp-rounded-full",
|
|
5427
|
-
children: /* @__PURE__ */ e(
|
|
5433
|
+
children: /* @__PURE__ */ e(se, { className: "rsp-w-4 rsp-h-4 rsp-text-red-500" })
|
|
5428
5434
|
}
|
|
5429
5435
|
)
|
|
5430
5436
|
] }),
|
|
@@ -5440,7 +5446,7 @@ function Sa({ editId: a, onCancel: s }) {
|
|
|
5440
5446
|
) })
|
|
5441
5447
|
] })
|
|
5442
5448
|
] }),
|
|
5443
|
-
c && /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e("div", { className: "rsp-sticky rsp-top-4", children: /* @__PURE__ */ e(
|
|
5449
|
+
c && /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e("div", { className: "rsp-sticky rsp-top-4", children: /* @__PURE__ */ e(Ea, { template: n }) }) })
|
|
5444
5450
|
] })
|
|
5445
5451
|
] }),
|
|
5446
5452
|
/* @__PURE__ */ e(
|
|
@@ -5482,19 +5488,19 @@ function Sa({ editId: a, onCancel: s }) {
|
|
|
5482
5488
|
)
|
|
5483
5489
|
] });
|
|
5484
5490
|
}
|
|
5485
|
-
const
|
|
5486
|
-
function
|
|
5487
|
-
const i =
|
|
5491
|
+
const Ma = Oe({});
|
|
5492
|
+
function Aa({ apiKey: a, pConfig: s, children: n }) {
|
|
5493
|
+
const i = Ve(
|
|
5488
5494
|
() => ({ apiKey: a, resulMeta: s }),
|
|
5489
5495
|
[a, s]
|
|
5490
|
-
), c =
|
|
5496
|
+
), c = fe(null);
|
|
5491
5497
|
return le(() => {
|
|
5492
5498
|
if (typeof window > "u" || a === void 0 && !s)
|
|
5493
5499
|
return;
|
|
5494
|
-
let
|
|
5500
|
+
let h = {};
|
|
5495
5501
|
try {
|
|
5496
5502
|
const g = localStorage.getItem("account");
|
|
5497
|
-
g && (
|
|
5503
|
+
g && (h = JSON.parse(g));
|
|
5498
5504
|
} catch (g) {
|
|
5499
5505
|
console.error(
|
|
5500
5506
|
"TrustSignalProvider: Failed to read account from storage",
|
|
@@ -5502,23 +5508,23 @@ function Va({ apiKey: a, pConfig: s, children: n }) {
|
|
|
5502
5508
|
);
|
|
5503
5509
|
}
|
|
5504
5510
|
const l = {
|
|
5505
|
-
...
|
|
5511
|
+
...h,
|
|
5506
5512
|
...a !== void 0 ? { apiKey: a } : {},
|
|
5507
5513
|
...s ? { resulMeta: s } : {}
|
|
5508
|
-
},
|
|
5509
|
-
if (
|
|
5514
|
+
}, N = JSON.stringify(l);
|
|
5515
|
+
if (N !== c.current)
|
|
5510
5516
|
try {
|
|
5511
|
-
localStorage.setItem("account",
|
|
5517
|
+
localStorage.setItem("account", N), c.current = N;
|
|
5512
5518
|
} catch (g) {
|
|
5513
5519
|
console.error(
|
|
5514
5520
|
"TrustSignalProvider: Failed to persist account to storage",
|
|
5515
5521
|
g
|
|
5516
5522
|
);
|
|
5517
5523
|
}
|
|
5518
|
-
}, [a, s]), /* @__PURE__ */ e(
|
|
5524
|
+
}, [a, s]), /* @__PURE__ */ e(Ma.Provider, { value: i, children: n });
|
|
5519
5525
|
}
|
|
5520
5526
|
export {
|
|
5521
|
-
|
|
5522
|
-
|
|
5523
|
-
|
|
5527
|
+
Va as CreateTemplate,
|
|
5528
|
+
Sa as Dashboard,
|
|
5529
|
+
Aa as TrustSignalProvider
|
|
5524
5530
|
};
|