@resulticks/trustsignal-wa-hsm 0.5.0 → 0.6.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,17 +1,17 @@
1
- import { jsx as e, jsxs as r, Fragment as ne } from "react/jsx-runtime";
2
- import K, { forwardRef as Le, createElement as be, useRef as Te, useEffect as se, useState as B, useMemo as Ne, useCallback as ge, createContext as Se } from "react";
3
- import { useNavigate as Ce, useInRouterContext as ye } from "react-router-dom";
4
- const Ve = async (a, n = {}) => {
1
+ import { jsx as e, jsxs as r, Fragment as ce } from "react/jsx-runtime";
2
+ import J, { forwardRef as Oe, createElement as ve, useRef as Le, useEffect as le, useState as P, useMemo as Se, useCallback as ke, createContext as Pe } from "react";
3
+ import { useNavigate as Ve, useInRouterContext as Ne } from "react-router-dom";
4
+ const ze = async (a, s = {}) => {
5
5
  try {
6
- return await je(a.apiKey);
6
+ return await De(a.apiKey);
7
7
  } catch (i) {
8
8
  return console.error("API Error:", i), {
9
9
  status: "error",
10
10
  message: i instanceof Error ? i.message : "Failed to fetch templates"
11
11
  };
12
12
  }
13
- }, je = async (a) => {
14
- const n = await fetch(
13
+ }, De = async (a) => {
14
+ const s = await fetch(
15
15
  "https://wpapi.trustsignal.io/api/v1/template?page=1&limit=100",
16
16
  {
17
17
  method: "GET",
@@ -21,25 +21,25 @@ const Ve = async (a, n = {}) => {
21
21
  }
22
22
  }
23
23
  );
24
- if (!n.ok)
25
- throw new Error(`HTTP error! status: ${n.status}`);
26
- const i = await n.json();
24
+ if (!s.ok)
25
+ throw new Error(`HTTP error! status: ${s.status}`);
26
+ const i = await s.json();
27
27
  if (!i.success)
28
28
  throw new Error(i.message || "Failed to fetch templates");
29
29
  return {
30
30
  status: "success",
31
- data: i.templates.map((d) => ({
32
- id: d.id,
33
- name: d.name,
34
- category: d.category,
35
- language: d.lang,
36
- type: d.temptype || "TEXT",
37
- body: d.temp_var_data || "",
38
- status: d.status,
39
- creation_time: new Date(d.created_at).getTime(),
40
- updation_time: new Date(d.modified_at).getTime(),
41
- medialist: d.medialist,
42
- shortlink: d.shortlink
31
+ data: i.templates.map((t) => ({
32
+ id: t.id,
33
+ name: t.name,
34
+ category: t.category,
35
+ language: t.lang,
36
+ type: t.temptype || "TEXT",
37
+ body: t.temp_var_data || "",
38
+ status: t.status,
39
+ creation_time: new Date(t.created_at).getTime(),
40
+ updation_time: new Date(t.modified_at).getTime(),
41
+ medialist: t.medialist,
42
+ shortlink: t.shortlink
43
43
  })),
44
44
  meta: {
45
45
  total: i.totalrecords,
@@ -54,7 +54,7 @@ const Ve = async (a, n = {}) => {
54
54
  * This source code is licensed under the ISC license.
55
55
  * See the LICENSE file in the root directory of this source tree.
56
56
  */
57
- var Ue = {
57
+ var _e = {
58
58
  xmlns: "http://www.w3.org/2000/svg",
59
59
  width: 24,
60
60
  height: 24,
@@ -71,31 +71,31 @@ var Ue = {
71
71
  * This source code is licensed under the ISC license.
72
72
  * See the LICENSE file in the root directory of this source tree.
73
73
  */
74
- const Ae = (a) => a.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase().trim(), H = (a, n) => {
75
- const i = Le(
74
+ const Fe = (a) => a.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase().trim(), $ = (a, s) => {
75
+ const i = Oe(
76
76
  ({
77
- color: l = "currentColor",
78
- size: d = 24,
79
- strokeWidth: p = 2,
80
- absoluteStrokeWidth: m,
81
- className: C = "",
82
- children: g,
83
- ...f
84
- }, y) => be(
77
+ color: n = "currentColor",
78
+ size: t = 24,
79
+ strokeWidth: x = 2,
80
+ absoluteStrokeWidth: l,
81
+ className: k = "",
82
+ children: w,
83
+ ...o
84
+ }, N) => ve(
85
85
  "svg",
86
86
  {
87
- ref: y,
88
- ...Ue,
89
- width: d,
90
- height: d,
91
- stroke: l,
92
- strokeWidth: m ? Number(p) * 24 / Number(d) : p,
93
- className: ["lucide", `lucide-${Ae(a)}`, C].join(" "),
94
- ...f
87
+ ref: N,
88
+ ..._e,
89
+ width: t,
90
+ height: t,
91
+ stroke: n,
92
+ strokeWidth: l ? Number(x) * 24 / Number(t) : x,
93
+ className: ["lucide", `lucide-${Fe(a)}`, k].join(" "),
94
+ ...o
95
95
  },
96
96
  [
97
- ...n.map(([j, U]) => be(j, U)),
98
- ...Array.isArray(g) ? g : [g]
97
+ ...s.map(([U, f]) => ve(U, f)),
98
+ ...Array.isArray(w) ? w : [w]
99
99
  ]
100
100
  )
101
101
  );
@@ -107,7 +107,7 @@ const Ae = (a) => a.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase().trim(),
107
107
  * This source code is licensed under the ISC license.
108
108
  * See the LICENSE file in the root directory of this source tree.
109
109
  */
110
- const ce = H("AlertCircle", [
110
+ const fe = $("AlertCircle", [
111
111
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
112
112
  ["line", { x1: "12", x2: "12", y1: "8", y2: "12", key: "1pkeuh" }],
113
113
  ["line", { x1: "12", x2: "12.01", y1: "16", y2: "16", key: "4dfq90" }]
@@ -118,7 +118,7 @@ const ce = H("AlertCircle", [
118
118
  * This source code is licensed under the ISC license.
119
119
  * See the LICENSE file in the root directory of this source tree.
120
120
  */
121
- const Re = H("ArrowRight", [
121
+ const qe = $("ArrowRight", [
122
122
  ["path", { d: "M5 12h14", key: "1ays0h" }],
123
123
  ["path", { d: "m12 5 7 7-7 7", key: "xquz4c" }]
124
124
  ]);
@@ -128,7 +128,7 @@ const Re = H("ArrowRight", [
128
128
  * This source code is licensed under the ISC license.
129
129
  * See the LICENSE file in the root directory of this source tree.
130
130
  */
131
- const Be = H("ExternalLink", [
131
+ const He = $("ExternalLink", [
132
132
  ["path", { d: "M15 3h6v6", key: "1q9fwt" }],
133
133
  ["path", { d: "M10 14 21 3", key: "gplh6r" }],
134
134
  ["path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6", key: "a6xqqp" }]
@@ -139,7 +139,7 @@ const Be = H("ExternalLink", [
139
139
  * This source code is licensed under the ISC license.
140
140
  * See the LICENSE file in the root directory of this source tree.
141
141
  */
142
- const Ie = H("FileText", [
142
+ const $e = $("FileText", [
143
143
  ["path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z", key: "1rqfz7" }],
144
144
  ["path", { d: "M14 2v4a2 2 0 0 0 2 2h4", key: "tnqrlb" }],
145
145
  ["path", { d: "M10 9H8", key: "b1mrlr" }],
@@ -152,7 +152,7 @@ const Ie = H("FileText", [
152
152
  * This source code is licensed under the ISC license.
153
153
  * See the LICENSE file in the root directory of this source tree.
154
154
  */
155
- const ze = H("FileVideo", [
155
+ const Ge = $("FileVideo", [
156
156
  ["path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z", key: "1rqfz7" }],
157
157
  ["path", { d: "M14 2v4a2 2 0 0 0 2 2h4", key: "tnqrlb" }],
158
158
  ["path", { d: "m10 11 5 3-5 3v-6Z", key: "7ntvm4" }]
@@ -163,7 +163,7 @@ const ze = H("FileVideo", [
163
163
  * This source code is licensed under the ISC license.
164
164
  * See the LICENSE file in the root directory of this source tree.
165
165
  */
166
- const Oe = H("Link", [
166
+ const We = $("Link", [
167
167
  ["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" }],
168
168
  ["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" }]
169
169
  ]);
@@ -173,7 +173,7 @@ const Oe = H("Link", [
173
173
  * This source code is licensed under the ISC license.
174
174
  * See the LICENSE file in the root directory of this source tree.
175
175
  */
176
- const le = H("MessageCircle", [
176
+ const me = $("MessageCircle", [
177
177
  ["path", { d: "M7.9 20A9 9 0 1 0 4 16.1L2 22Z", key: "vv11sd" }]
178
178
  ]);
179
179
  /**
@@ -182,7 +182,17 @@ const le = H("MessageCircle", [
182
182
  * This source code is licensed under the ISC license.
183
183
  * See the LICENSE file in the root directory of this source tree.
184
184
  */
185
- const Me = H("Phone", [
185
+ const Ke = $("Pencil", [
186
+ ["path", { d: "M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z", key: "5qss01" }],
187
+ ["path", { d: "m15 5 4 4", key: "1mk7zo" }]
188
+ ]);
189
+ /**
190
+ * @license lucide-react v0.344.0 - ISC
191
+ *
192
+ * This source code is licensed under the ISC license.
193
+ * See the LICENSE file in the root directory of this source tree.
194
+ */
195
+ const Ue = $("Phone", [
186
196
  [
187
197
  "path",
188
198
  {
@@ -197,7 +207,7 @@ const Me = H("Phone", [
197
207
  * This source code is licensed under the ISC license.
198
208
  * See the LICENSE file in the root directory of this source tree.
199
209
  */
200
- const de = H("Plus", [
210
+ const Ae = $("Plus", [
201
211
  ["path", { d: "M5 12h14", key: "1ays0h" }],
202
212
  ["path", { d: "M12 5v14", key: "s699le" }]
203
213
  ]);
@@ -207,7 +217,7 @@ const de = H("Plus", [
207
217
  * This source code is licensed under the ISC license.
208
218
  * See the LICENSE file in the root directory of this source tree.
209
219
  */
210
- const Pe = H("Reply", [
220
+ const Je = $("Reply", [
211
221
  ["polyline", { points: "9 17 4 12 9 7", key: "hvgpf2" }],
212
222
  ["path", { d: "M20 18v-2a4 4 0 0 0-4-4H4", key: "5vmcpk" }]
213
223
  ]);
@@ -217,7 +227,7 @@ const Pe = H("Reply", [
217
227
  * This source code is licensed under the ISC license.
218
228
  * See the LICENSE file in the root directory of this source tree.
219
229
  */
220
- const xe = H("Smile", [
230
+ const he = $("Smile", [
221
231
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
222
232
  ["path", { d: "M8 14s1.5 2 4 2 4-2 4-2", key: "1y1vjs" }],
223
233
  ["line", { x1: "9", x2: "9.01", y1: "9", y2: "9", key: "yxxnd0" }],
@@ -229,7 +239,20 @@ const xe = H("Smile", [
229
239
  * This source code is licensed under the ISC license.
230
240
  * See the LICENSE file in the root directory of this source tree.
231
241
  */
232
- const _e = H("Upload", [
242
+ const Xe = $("Trash2", [
243
+ ["path", { d: "M3 6h18", key: "d0wm0j" }],
244
+ ["path", { d: "M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6", key: "4alrt4" }],
245
+ ["path", { d: "M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2", key: "v07s0e" }],
246
+ ["line", { x1: "10", x2: "10", y1: "11", y2: "17", key: "1uufr5" }],
247
+ ["line", { x1: "14", x2: "14", y1: "11", y2: "17", key: "xtxkd" }]
248
+ ]);
249
+ /**
250
+ * @license lucide-react v0.344.0 - ISC
251
+ *
252
+ * This source code is licensed under the ISC license.
253
+ * See the LICENSE file in the root directory of this source tree.
254
+ */
255
+ const Ye = $("Upload", [
233
256
  ["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4", key: "ih7n3h" }],
234
257
  ["polyline", { points: "17 8 12 3 7 8", key: "t8dd8p" }],
235
258
  ["line", { x1: "12", x2: "12", y1: "3", y2: "15", key: "widbto" }]
@@ -240,7 +263,7 @@ const _e = H("Upload", [
240
263
  * This source code is licensed under the ISC license.
241
264
  * See the LICENSE file in the root directory of this source tree.
242
265
  */
243
- const Fe = H("Workflow", [
266
+ const Qe = $("Workflow", [
244
267
  ["rect", { width: "8", height: "8", x: "3", y: "3", rx: "2", key: "by2w9f" }],
245
268
  ["path", { d: "M7 11v4a2 2 0 0 0 2 2h4", key: "xkn7yn" }],
246
269
  ["rect", { width: "8", height: "8", x: "13", y: "13", rx: "2", key: "1cgmvn" }]
@@ -251,91 +274,97 @@ const Fe = H("Workflow", [
251
274
  * This source code is licensed under the ISC license.
252
275
  * See the LICENSE file in the root directory of this source tree.
253
276
  */
254
- const ee = H("X", [
277
+ const re = $("X", [
255
278
  ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
256
279
  ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
257
280
  ]);
258
- function pe({ isOpen: a, onClose: n, title: i, children: l }) {
259
- const d = Te(null);
260
- return se(() => {
261
- const p = (m) => {
262
- d.current && !d.current.contains(m.target) && n();
281
+ function te({ isOpen: a, onClose: s, title: i, children: n }) {
282
+ const t = Le(null);
283
+ return le(() => {
284
+ const x = (l) => {
285
+ t.current && !t.current.contains(l.target) && s();
263
286
  };
264
- return a && document.addEventListener("mousedown", p), () => {
265
- document.removeEventListener("mousedown", p);
287
+ return a && document.addEventListener("mousedown", x), () => {
288
+ document.removeEventListener("mousedown", x);
266
289
  };
267
- }, [a, n]), 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: d, 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: [
290
+ }, [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: t, 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: [
268
291
  /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-justify-between rsp-px-6 rsp-py-4 rsp-border-b", children: [
269
292
  /* @__PURE__ */ e("h2", { className: "rsp-text-lg rsp-font-semibold rsp-text-gray-900 rsp-text-center rsp-w-full rsp-break-words rsp-break-all rsp-whitespace-pre-wrap", children: i }),
270
293
  /* @__PURE__ */ e(
271
294
  "button",
272
295
  {
273
- onClick: n,
296
+ onClick: s,
274
297
  className: "rsp-p-1 hover:rsp-bg-gray-100 rsp-rounded-full",
275
- children: /* @__PURE__ */ e(ee, { className: "rsp-w-5 rsp-h-5 rsp-text-gray-500" })
298
+ children: /* @__PURE__ */ e(re, { className: "rsp-w-5 rsp-h-5 rsp-text-gray-500" })
276
299
  }
277
300
  )
278
301
  ] }),
279
- /* @__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: l })
302
+ /* @__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: n })
280
303
  ] }) }) : null;
281
304
  }
282
- function ga() {
283
- const a = Ce(), [n, i] = B([]), [l, d] = B(!0), [p, m] = B(null), [C, g] = B(() => {
284
- const c = localStorage.getItem("account");
285
- return c ? JSON.parse(c) : {
305
+ function Va() {
306
+ const a = Ve(), [s, i] = P([]), [n, t] = P(!0), [x, l] = P(null), [k, w] = P(null), [o, N] = P({ isOpen: !1 }), [U, f] = P(() => {
307
+ const h = localStorage.getItem("account");
308
+ return h ? JSON.parse(h) : {
286
309
  apiKey: ""
287
310
  };
288
- }), [f, y] = B(""), [j, U] = B("all"), [k, N] = B("all"), [o, u] = B("all"), [t, h] = B(1), v = 20, [V, R] = B({ isOpen: !1 });
289
- se(() => {
311
+ }), [b, M] = P(""), [g, v] = P("all"), [c, p] = P("all"), [y] = P("all"), [u, V] = P(1), B = 20, [d, E] = P({ isOpen: !1 });
312
+ le(() => {
290
313
  (async () => {
291
314
  try {
292
- if (m(null), d(!0), i([]), !C.apiKey) {
293
- m("Please enter your TrustSignal API key"), d(!1);
315
+ if (l(null), t(!0), i([]), !U.apiKey) {
316
+ l("Please enter your TrustSignal API key"), t(!1);
294
317
  return;
295
318
  }
296
- const M = await Ve(C, {
319
+ const L = await ze(U, {
297
320
  limit: 1e3
298
321
  });
299
- if (M.status === "error")
300
- throw new Error(M.message);
301
- i(M.data);
302
- } catch (M) {
303
- m(M instanceof Error ? M.message : "Failed to fetch templates"), i([]);
322
+ if (L.status === "error")
323
+ throw new Error(L.message);
324
+ i(L.data);
325
+ } catch (L) {
326
+ l(L instanceof Error ? L.message : "Failed to fetch templates"), i([]);
304
327
  } finally {
305
- d(!1);
328
+ t(!1);
306
329
  }
307
330
  })();
308
- }, [C]);
309
- const I = (c) => {
310
- const { name: M, value: A } = c.target, O = {
311
- ...C,
312
- [M]: A
331
+ }, [U]);
332
+ const A = (h) => {
333
+ const { name: L, value: z } = h.target, q = {
334
+ ...U,
335
+ [L]: z
313
336
  };
314
- g(O), localStorage.setItem("account", JSON.stringify(O));
315
- }, x = (c, M) => {
316
- R({
337
+ f(q), localStorage.setItem("account", JSON.stringify(q));
338
+ }, O = (h, L) => {
339
+ E({
317
340
  isOpen: !0,
318
- url: c,
319
- templateName: M
341
+ url: h,
342
+ templateName: L
320
343
  });
321
- }, w = () => {
322
- R({ isOpen: !1 });
323
- }, L = n.filter((c) => {
324
- const M = f.trim(), A = M.toLowerCase(), O = M === "" || c.id.toString().includes(M) || c.name.toLowerCase().includes(A), $ = j === "all" || c.status.toLowerCase() === j.toLowerCase(), X = k === "all" || c.category.toLowerCase() === k.toLowerCase(), S = o === "all" || c.language.toLowerCase().startsWith(o.toLowerCase());
325
- return O && $ && X && S;
326
- }), s = Math.ceil(L.length / v), b = (t - 1) * v, E = b + v, T = L.slice(b, E);
327
- 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: [
328
- /* @__PURE__ */ r("div", { className: "rsp-flex rsp-justify-between rsp-items-center rsp-mb-6", children: [
329
- /* @__PURE__ */ e("h1", { className: "rsp-text-2xl rsp-font-bold", children: "Whatsapp HSM Templates" }),
330
- /* @__PURE__ */ e(
331
- "button",
332
- {
333
- onClick: () => a("/create"),
334
- 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",
335
- children: /* @__PURE__ */ e(de, { className: "rsp-w-6 rsp-h-6" })
336
- }
337
- )
338
- ] }),
344
+ }, R = () => {
345
+ E({ isOpen: !1 });
346
+ }, _ = async (h) => {
347
+ try {
348
+ const L = localStorage.getItem("account"), z = L ? JSON.parse(L) : { apiKey: "" };
349
+ if (!z.apiKey) {
350
+ l("Please enter your TrustSignal API key");
351
+ return;
352
+ }
353
+ w(h);
354
+ const { deleteTemplateById: q } = await import("./delete-BgBYMUw2.js"), X = await q(z.apiKey, h);
355
+ if (!X.success) throw new Error(X.message || "Delete failed");
356
+ i((T) => T.filter((Y) => Y.id !== h)), N({ isOpen: !1 });
357
+ } catch (L) {
358
+ l(L instanceof Error ? L.message : "Failed to delete template");
359
+ } finally {
360
+ w(null);
361
+ }
362
+ }, m = s.filter((h) => {
363
+ const L = b.trim(), z = L.toLowerCase(), q = L === "" || h.id.toString().includes(L) || h.name.toLowerCase().includes(z), X = g === "all" || h.status.toLowerCase() === g.toLowerCase(), T = c === "all" || h.category.toLowerCase() === c.toLowerCase(), Y = y === "all" || h.language.toLowerCase().startsWith(y.toLowerCase());
364
+ return q && X && T && Y;
365
+ }), C = Math.ceil(m.length / B), S = (u - 1) * B, j = S + B, I = m.slice(S, j);
366
+ return n ? /* @__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: [
367
+ /* @__PURE__ */ e("div", { className: "rsp-flex rsp-justify-between rsp-items-center rsp-mb-6", children: /* @__PURE__ */ e("h1", { className: "rsp-text-2xl rsp-font-bold", children: "Whatsapp HSM Templates" }) }),
339
368
  /* @__PURE__ */ e("div", { className: " rsp-p-4 rsp-pl-0 rsp-rounded-lg rsp-shadow-sm rsp-mb-6", children: /* @__PURE__ */ r("div", { children: [
340
369
  /* @__PURE__ */ e("label", { className: "rsp-block rsp-text-sm rsp-font-medium rsp-text-gray-700 rsp-mb-1", children: "TrustSignal API Key" }),
341
370
  /* @__PURE__ */ r("div", { className: "rsp-relative", children: [
@@ -344,8 +373,8 @@ function ga() {
344
373
  {
345
374
  type: "password",
346
375
  name: "apiKey",
347
- value: C.apiKey,
348
- onChange: I,
376
+ value: U.apiKey,
377
+ onChange: A,
349
378
  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",
350
379
  placeholder: "Enter your TrustSignal API key"
351
380
  }
@@ -353,17 +382,17 @@ function ga() {
353
382
  /* @__PURE__ */ e("div", { className: "rsp-absolute rsp-bottom-0 rsp-left-0 rsp-w-4 rsp-h-0.5 rsp-bg-red-500" })
354
383
  ] })
355
384
  ] }) }),
356
- p && /* @__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: [
357
- /* @__PURE__ */ e("div", { className: "rsp-flex-shrink-0", children: /* @__PURE__ */ e(ce, { className: "rsp-h-5 rsp-w-5 rsp-text-red-400" }) }),
358
- /* @__PURE__ */ e("div", { className: "rsp-ml-3", children: /* @__PURE__ */ e("p", { className: "rsp-text-sm rsp-text-red-700", children: p }) })
385
+ x && /* @__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: [
386
+ /* @__PURE__ */ e("div", { className: "rsp-flex-shrink-0", children: /* @__PURE__ */ e(fe, { className: "rsp-h-5 rsp-w-5 rsp-text-red-400" }) }),
387
+ /* @__PURE__ */ e("div", { className: "rsp-ml-3", children: /* @__PURE__ */ e("p", { className: "rsp-text-sm rsp-text-red-700", children: x }) })
359
388
  ] }) }),
360
389
  /* @__PURE__ */ e("div", { className: "rsp-mb-6", children: /* @__PURE__ */ e("div", { className: "rsp-relative", children: /* @__PURE__ */ e(
361
390
  "input",
362
391
  {
363
392
  type: "text",
364
393
  placeholder: "Search by name or ID...",
365
- value: f,
366
- onChange: (c) => y(c.target.value),
394
+ value: b,
395
+ onChange: (h) => M(h.target.value),
367
396
  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"
368
397
  }
369
398
  ) }) }),
@@ -376,10 +405,10 @@ function ga() {
376
405
  /* @__PURE__ */ e("div", { className: "rsp-flex rsp-items-center", children: /* @__PURE__ */ r(
377
406
  "select",
378
407
  {
379
- value: k,
380
- onChange: (c) => N(c.target.value),
408
+ value: c,
409
+ onChange: (h) => p(h.target.value),
381
410
  className: "rsp-cursor-pointer rsp-ml-2 rsp-bg-transparent rsp-text-white rsp-border-0 rsp-text-sm focus:rsp-outline-none ",
382
- onClick: (c) => c.stopPropagation(),
411
+ onClick: (h) => h.stopPropagation(),
383
412
  children: [
384
413
  /* @__PURE__ */ e("option", { value: "all", className: "rsp-text-gray-900", children: "All" }),
385
414
  /* @__PURE__ */ e("option", { value: "utility", className: "rsp-text-gray-900", children: "Utility" }),
@@ -395,10 +424,10 @@ function ga() {
395
424
  /* @__PURE__ */ e("div", { className: "rsp-flex rsp-items-center", children: /* @__PURE__ */ r(
396
425
  "select",
397
426
  {
398
- value: j,
399
- onChange: (c) => U(c.target.value),
427
+ value: g,
428
+ onChange: (h) => v(h.target.value),
400
429
  className: "rsp-cursor-pointer rsp-ml-2 rsp-bg-transparent rsp-text-white rsp-border-0 rsp-text-sm focus:rsp-outline-none",
401
- onClick: (c) => c.stopPropagation(),
430
+ onClick: (h) => h.stopPropagation(),
402
431
  children: [
403
432
  /* @__PURE__ */ e("option", { value: "all", className: "rsp-text-gray-900", children: "All" }),
404
433
  /* @__PURE__ */ e("option", { value: "pending", className: "rsp-text-gray-900", children: "Pending" }),
@@ -410,75 +439,94 @@ function ga() {
410
439
  ] }) }),
411
440
  /* @__PURE__ */ e("th", { className: "rsp-px-6 rsp-py-3 rsp-text-left rsp-text-sm rsp-font-medium", children: "Created" }),
412
441
  /* @__PURE__ */ e("th", { className: "rsp-px-6 rsp-py-3 rsp-text-left rsp-text-sm rsp-font-medium", children: "Updated" }),
413
- /* @__PURE__ */ e("th", { className: "rsp-px-6 rsp-py-3 rsp-text-left rsp-text-sm rsp-font-medium", children: "Media" })
442
+ /* @__PURE__ */ e("th", { className: "rsp-px-6 rsp-py-3 rsp-text-left rsp-text-sm rsp-font-medium", children: "Media" }),
443
+ /* @__PURE__ */ e("th", { className: "rsp-px-6 rsp-py-3 rsp-text-left rsp-text-sm rsp-font-medium", children: "Actions" })
414
444
  ] }) }),
415
- /* @__PURE__ */ e("tbody", { children: T.length > 0 ? T.map((c, M) => {
416
- var A;
417
- return /* @__PURE__ */ r(
418
- "tr",
419
- {
420
- className: `rsp-border-b rsp-border-gray-200 ${M % 2 === 0 ? "rsp-bg-white" : "rsp-bg-blue-50"} hover:rsp-bg-blue-100 rsp-transition-colors`,
421
- children: [
422
- /* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-900", children: c.id }),
423
- /* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-900 rsp-font-medium", children: c.name }),
424
- /* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-700 rsp-capitalize", children: c.category }),
425
- /* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-700", children: c.language }),
426
- /* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-700", children: c.type }),
427
- /* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4", children: /* @__PURE__ */ e("span", { className: `rsp-inline-flex rsp-px-3 rsp-py-1 rsp-rounded-full rsp-text-xs rsp-font-medium
428
- ${c.status.toLowerCase() === "approved" ? "rsp-bg-green-100 rsp-text-green-800" : c.status.toLowerCase() === "rejected" ? "rsp-bg-red-100 rsp-text-red-800" : "rsp-bg-yellow-100 rsp-text-yellow-800"}`, children: c.status }) }),
429
- /* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-700", children: c.creation_time ? new Date(c.creation_time).toLocaleDateString() : "N/A" }),
430
- /* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-700", children: c.updation_time ? new Date(c.updation_time).toLocaleDateString() : "N/A" }),
431
- /* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-700", children: (A = c.medialist) != null && A.header ? /* @__PURE__ */ r(
445
+ /* @__PURE__ */ e("tbody", { children: I.length > 0 ? I.map((h, L) => /* @__PURE__ */ r(
446
+ "tr",
447
+ {
448
+ className: `rsp-border-b rsp-border-gray-200 ${L % 2 === 0 ? "rsp-bg-white" : "rsp-bg-blue-50"} hover:rsp-bg-blue-100 rsp-transition-colors`,
449
+ children: [
450
+ /* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-900", children: h.id }),
451
+ /* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-900 rsp-font-medium", children: h.name }),
452
+ /* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-700 rsp-capitalize", children: h.category }),
453
+ /* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-700", children: h.language }),
454
+ /* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-700", children: h.type }),
455
+ /* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4", children: /* @__PURE__ */ e("span", { className: `rsp-inline-flex rsp-px-3 rsp-py-1 rsp-rounded-full rsp-text-xs rsp-font-medium
456
+ ${h.status.toLowerCase() === "approved" ? "rsp-bg-green-100 rsp-text-green-800" : h.status.toLowerCase() === "rejected" ? "rsp-bg-red-100 rsp-text-red-800" : "rsp-bg-yellow-100 rsp-text-yellow-800"}`, children: h.status }) }),
457
+ /* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-700", children: h.creation_time ? new Date(h.creation_time).toLocaleDateString() : "N/A" }),
458
+ /* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-700", children: h.updation_time ? new Date(h.updation_time).toLocaleDateString() : "N/A" }),
459
+ /* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4 rsp-text-sm rsp-text-gray-700", children: h.medialist && typeof h.medialist == "object" && "header" in h.medialist && h.medialist.header ? /* @__PURE__ */ r(
460
+ "button",
461
+ {
462
+ onClick: () => O(String(h.medialist.header || ""), h.name),
463
+ 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",
464
+ children: [
465
+ /* @__PURE__ */ r("svg", { className: "rsp-w-3 rsp-h-3 rsp-mr-1", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: [
466
+ /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 12a3 3 0 11-6 0 3 3 0 016 0z" }),
467
+ /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" })
468
+ ] }),
469
+ /* @__PURE__ */ e("span", { children: "View Media" })
470
+ ]
471
+ }
472
+ ) : /* @__PURE__ */ e("span", { className: "rsp-inline-flex rsp-px-2 rsp-py-1 rsp-rounded-full rsp-text-xs rsp-font-medium rsp-bg-gray-100 rsp-text-gray-800", children: "No Media" }) }),
473
+ /* @__PURE__ */ e("td", { className: "rsp-px-6 rsp-py-4", children: /* @__PURE__ */ r("div", { className: "rsp-flex rsp-gap-2", children: [
474
+ /* @__PURE__ */ e(
432
475
  "button",
433
476
  {
434
- onClick: () => x(c.medialist.header, c.name),
435
- 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",
436
- children: [
437
- /* @__PURE__ */ r("svg", { className: "rsp-w-3 rsp-h-3 rsp-mr-1", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: [
438
- /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 12a3 3 0 11-6 0 3 3 0 016 0z" }),
439
- /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" })
440
- ] }),
441
- /* @__PURE__ */ e("span", { children: "View Media" })
442
- ]
477
+ onClick: () => a(`/create?edit=${encodeURIComponent(String(h.id))}`),
478
+ 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",
479
+ title: "Update",
480
+ children: /* @__PURE__ */ e(Ke, { className: "rsp-w-4 rsp-h-4" })
443
481
  }
444
- ) : /* @__PURE__ */ e("span", { className: "rsp-inline-flex rsp-px-2 rsp-py-1 rsp-rounded-full rsp-text-xs rsp-font-medium rsp-bg-gray-100 rsp-text-gray-800", children: "No Media" }) })
445
- ]
446
- },
447
- c.id
448
- );
449
- }) : /* @__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" }) }) })
482
+ ),
483
+ /* @__PURE__ */ e(
484
+ "button",
485
+ {
486
+ onClick: () => N({ isOpen: !0, templateId: String(h.id), templateName: h.name }),
487
+ disabled: k === h.id,
488
+ 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 === h.id ? "rsp-bg-red-400" : "rsp-bg-red-600 hover:rsp-bg-red-700"}`,
489
+ title: k === h.id ? "Deleting..." : "Delete",
490
+ children: /* @__PURE__ */ e(Xe, { className: "rsp-w-4 rsp-h-4" })
491
+ }
492
+ )
493
+ ] }) })
494
+ ]
495
+ },
496
+ h.id
497
+ )) : /* @__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" }) }) })
450
498
  ] }) }) }),
451
- T.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: [
499
+ I.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: [
452
500
  /* @__PURE__ */ r("div", { className: "rsp-text-sm rsp-text-gray-700", children: [
453
501
  "Showing ",
454
- /* @__PURE__ */ e("span", { className: "rsp-font-medium", children: b + 1 }),
502
+ /* @__PURE__ */ e("span", { className: "rsp-font-medium", children: S + 1 }),
455
503
  " to ",
456
- /* @__PURE__ */ e("span", { className: "rsp-font-medium", children: Math.min(E, L.length) }),
504
+ /* @__PURE__ */ e("span", { className: "rsp-font-medium", children: Math.min(j, m.length) }),
457
505
  " of ",
458
- /* @__PURE__ */ e("span", { className: "rsp-font-medium", children: L.length }),
506
+ /* @__PURE__ */ e("span", { className: "rsp-font-medium", children: m.length }),
459
507
  " results"
460
508
  ] }),
461
509
  /* @__PURE__ */ r("div", { className: "rsp-flex rsp-gap-2", children: [
462
510
  /* @__PURE__ */ e(
463
511
  "button",
464
512
  {
465
- onClick: () => h((c) => Math.max(c - 1, 1)),
466
- disabled: t === 1,
513
+ onClick: () => V((h) => Math.max(h - 1, 1)),
514
+ disabled: u === 1,
467
515
  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",
468
516
  children: "Previous"
469
517
  }
470
518
  ),
471
519
  /* @__PURE__ */ r("span", { className: "rsp-px-4 rsp-py-2 rsp-text-sm rsp-font-medium rsp-text-gray-700", children: [
472
520
  "Page ",
473
- t,
521
+ u,
474
522
  " of ",
475
- s
523
+ C
476
524
  ] }),
477
525
  /* @__PURE__ */ e(
478
526
  "button",
479
527
  {
480
- onClick: () => h((c) => Math.min(c + 1, s)),
481
- disabled: t === s,
528
+ onClick: () => V((h) => Math.min(h + 1, C)),
529
+ disabled: u === C,
482
530
  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",
483
531
  children: "Next"
484
532
  }
@@ -486,34 +534,32 @@ function ga() {
486
534
  ] })
487
535
  ] }),
488
536
  /* @__PURE__ */ e(
489
- pe,
537
+ te,
490
538
  {
491
- isOpen: V.isOpen,
492
- onClose: w,
493
- title: `Media - ${V.templateName || "Template"}`,
539
+ isOpen: d.isOpen,
540
+ onClose: R,
541
+ title: `Media - ${d.templateName || "Template"}`,
494
542
  children: /* @__PURE__ */ r("div", { className: "rsp-space-y-4", children: [
495
- V.url && /* @__PURE__ */ r("div", { className: "rsp-text-center", children: [
543
+ d.url && /* @__PURE__ */ r("div", { className: "rsp-text-center", children: [
496
544
  /* @__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: [
497
545
  /* @__PURE__ */ e(
498
546
  "img",
499
547
  {
500
- src: V.url,
548
+ src: d.url,
501
549
  alt: "Template media",
502
550
  className: "rsp-max-w-full rsp-max-h-[400px] rsp-mx-auto rsp-rounded-lg rsp-shadow-md rsp-object-contain",
503
- onLoad: (c) => {
504
- var A;
505
- const M = (A = c.currentTarget.parentElement) == null ? void 0 : A.querySelector(".loading-placeholder");
506
- M && (M.style.display = "none");
551
+ onLoad: (h) => {
552
+ const L = h.currentTarget.parentElement, z = L == null ? void 0 : L.querySelector(".loading-placeholder");
553
+ z && (z.style.display = "none");
507
554
  },
508
- onError: (c) => {
509
- var A;
510
- c.currentTarget.style.display = "none";
511
- const M = (A = c.currentTarget.parentElement) == null ? void 0 : A.querySelector(".error-placeholder");
512
- M && (M.style.display = "block");
555
+ onError: (h) => {
556
+ h.currentTarget.style.display = "none";
557
+ const L = h.currentTarget.parentElement, z = L == null ? void 0 : L.querySelector(".error-placeholder");
558
+ z && (z.style.display = "block");
513
559
  }
514
560
  }
515
561
  ),
516
- 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..." }) }),
562
+ n && /* @__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..." }) }),
517
563
  /* @__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: [
518
564
  /* @__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" }) }),
519
565
  /* @__PURE__ */ e("p", { className: "rsp-text-gray-500 rsp-text-sm rsp-mb-2", children: "Load media on new tab" })
@@ -521,13 +567,13 @@ function ga() {
521
567
  ] }),
522
568
  /* @__PURE__ */ r("div", { className: "rsp-mt-4 rsp-p-3 rsp-bg-gray-50 rsp-rounded-lg", children: [
523
569
  /* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-gray-600 rsp-mb-1", children: "Media URL:" }),
524
- /* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-gray-800 rsp-break-all rsp-font-mono", children: V.url })
570
+ /* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-gray-800 rsp-break-all rsp-font-mono", children: d.url })
525
571
  ] })
526
572
  ] }),
527
573
  /* @__PURE__ */ e("div", { className: "rsp-flex rsp-justify-end rsp-pt-4", children: /* @__PURE__ */ r(
528
574
  "a",
529
575
  {
530
- href: V.url,
576
+ href: d.url,
531
577
  target: "_blank",
532
578
  rel: "noopener noreferrer",
533
579
  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",
@@ -539,70 +585,101 @@ function ga() {
539
585
  ) })
540
586
  ] })
541
587
  }
588
+ ),
589
+ /* @__PURE__ */ e(
590
+ te,
591
+ {
592
+ isOpen: o.isOpen,
593
+ onClose: () => N({ isOpen: !1 }),
594
+ title: "Delete Template",
595
+ children: /* @__PURE__ */ r("div", { className: "rsp-space-y-4", children: [
596
+ /* @__PURE__ */ r("p", { className: "rsp-text-sm rsp-text-gray-700", children: [
597
+ "Are you sure you want to delete the template ",
598
+ /* @__PURE__ */ e("span", { className: "rsp-font-medium", children: o.templateName }),
599
+ "?"
600
+ ] }),
601
+ /* @__PURE__ */ r("div", { className: "rsp-flex rsp-justify-end rsp-gap-3", children: [
602
+ /* @__PURE__ */ e("button", { onClick: () => N({ 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" }),
603
+ /* @__PURE__ */ e(
604
+ "button",
605
+ {
606
+ onClick: () => o.templateId && _(o.templateId),
607
+ 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",
608
+ children: "Delete"
609
+ }
610
+ )
611
+ ] })
612
+ ] })
613
+ }
542
614
  )
543
615
  ] });
544
616
  }
545
- const De = async (a, n) => {
546
- var i, l, d, p, m, C, g;
617
+ const Ze = async (a, s) => {
618
+ var i, n, t, x, l, k, w;
547
619
  try {
548
- console.log("Creating template with data:", n);
549
- const f = n.language, y = n.headerType === "MEDIA" && n.mediaType === "DOCUMENT", j = n.type === "CAROUSEL";
550
- let U = "";
551
- y ? U = qe(n, f) : j ? U = He(n, f) : U = Ge(n, f), console.log("Raw JSON string being sent:", U);
552
- const k = {
620
+ console.log("Creating template with data:", s);
621
+ const o = s.language, N = s.headerType === "MEDIA" && s.mediaType === "DOCUMENT", U = s.type === "CAROUSEL";
622
+ let f = "";
623
+ N ? f = je(s, o) : U ? f = Re(s, o) : f = Ie(s, o), console.log("Raw JSON string being sent:", f);
624
+ const b = {
553
625
  method: "POST",
554
626
  headers: {
555
627
  "Content-Type": "application/json"
556
628
  },
557
- body: U,
629
+ body: f,
558
630
  redirect: "follow"
559
631
  };
560
632
  console.log(
561
633
  "Making request to:",
562
634
  `https://wpapi.trustsignal.io/api/v1/template?api_key=${a}`
563
- ), console.log("Request options:", k);
564
- const N = await fetch(
635
+ ), console.log("Request options:", b);
636
+ const M = await fetch(
565
637
  `https://wpapi.trustsignal.io/api/v1/template?api_key=${a}`,
566
- k
638
+ b
567
639
  );
568
- console.log("Response status:", N.status), console.log(
640
+ console.log("Response status:", M.status), console.log(
569
641
  "Response headers:",
570
- Object.fromEntries(N.headers.entries())
642
+ Object.fromEntries(M.headers.entries())
571
643
  );
572
- const o = await N.text();
573
- console.log("Raw response:", o);
574
- const u = JSON.parse(o);
575
- if (console.log("Parsed response:", u), !u.success)
576
- throw new Error(u.message || "Template creation failed");
644
+ const g = await M.text();
645
+ console.log("Raw response:", g);
646
+ const v = JSON.parse(g);
647
+ if (console.log("Parsed response:", v), !v.success)
648
+ throw new Error(v.message || "Template creation failed");
577
649
  return {
578
650
  status: "success",
579
651
  message: "Template created successfully",
580
652
  data: {
581
- template: u.template,
653
+ template: v.template,
582
654
  details: [
583
655
  {
584
- template_name: ((i = u.template) == null ? void 0 : i.name) || n.name,
585
- template_id: ((l = u.template) == null ? void 0 : l.id) || "unknown",
586
- meta_tid: (d = u.template) == null ? void 0 : d.meta_tid,
587
- status: (p = u.template) == null ? void 0 : p.status,
588
- quality: (m = u.template) == null ? void 0 : m.quality,
589
- temp_route: (C = u.template) == null ? void 0 : C.temp_route,
590
- temptype: (g = u.template) == null ? void 0 : g.temptype
656
+ template_name: ((i = v.template) == null ? void 0 : i.name) || s.name,
657
+ template_id: ((n = v.template) == null ? void 0 : n.id) || "unknown",
658
+ meta_tid: (t = v.template) == null ? void 0 : t.meta_tid,
659
+ status: (x = v.template) == null ? void 0 : x.status,
660
+ quality: (l = v.template) == null ? void 0 : l.quality,
661
+ temp_route: (k = v.template) == null ? void 0 : k.temp_route,
662
+ temptype: (w = v.template) == null ? void 0 : w.temptype
591
663
  }
592
664
  ]
593
665
  }
594
666
  };
595
- } catch (f) {
596
- return console.error("TrustSignal API Error:", f), {
667
+ } catch (o) {
668
+ return console.error("TrustSignal API Error:", o), {
597
669
  status: "error",
598
- message: f instanceof Error ? f.message : "Failed to create template"
670
+ message: o instanceof Error ? o.message : "Failed to create template"
599
671
  };
600
672
  }
601
- }, qe = (a, n) => {
602
- var p, m;
673
+ };
674
+ function ea(a) {
675
+ const s = a.language, i = a.headerType === "MEDIA" && a.mediaType === "DOCUMENT", n = a.type === "CAROUSEL";
676
+ return i ? je(a, s) : n ? Re(a, s) : Ie(a, s);
677
+ }
678
+ const je = (a, s) => {
679
+ var x, l;
603
680
  const i = {
604
681
  name: a.name,
605
- lang: n,
682
+ lang: s,
606
683
  category: a.category,
607
684
  components: []
608
685
  // Components should be an array
@@ -613,72 +690,72 @@ const De = async (a, n) => {
613
690
  type: "HEADER",
614
691
  format: "DOCUMENT"
615
692
  }));
616
- const l = J(a.body), d = {
693
+ const n = ee(a.body), t = {
617
694
  type: "BODY",
618
695
  text: a.body
619
696
  };
620
- if (l.length > 0 && ((p = a.sampleContent) != null && p.bodyVariables)) {
621
- const C = oe(a, l);
622
- d.example = {
623
- body_text: [C]
697
+ if (n.length > 0 && ((x = a.sampleContent) != null && x.bodyVariables)) {
698
+ const k = be(a, n);
699
+ t.example = {
700
+ body_text: [k]
624
701
  // This creates the required nested array
625
702
  };
626
703
  }
627
- if (i.components.push(d), (m = a.footer) != null && m.trim() && i.components.push({
704
+ if (i.components.push(t), (l = a.footer) != null && l.trim() && i.components.push({
628
705
  type: "FOOTER",
629
706
  text: a.footer
630
707
  }), a.buttons && a.buttons.length > 0) {
631
- const C = a.buttons.map((g) => {
632
- var y;
633
- const f = {
634
- type: g.type === "CALL" ? "PHONE_NUMBER" : g.type,
635
- text: g.text
708
+ const k = a.buttons.map((w) => {
709
+ var N;
710
+ const o = {
711
+ type: w.type === "CALL" ? "PHONE_NUMBER" : w.type,
712
+ text: w.text
636
713
  };
637
- if (g.type === "URL" && g.value && (f.url = g.value, g.urlType === "dynamic" && g.value.includes("{{"))) {
638
- const j = J(g.value);
639
- if (j.length > 0 && ((y = a.sampleContent) != null && y.buttonVariables)) {
640
- const U = j.map(
641
- ({ number: k }) => {
642
- var N, o;
643
- return ((o = (N = a.sampleContent) == null ? void 0 : N.buttonVariables) == null ? void 0 : o[k]) || `sample${k}`;
714
+ if (w.type === "URL" && w.value && (o.url = w.value, w.urlType === "dynamic" && w.value.includes("{{"))) {
715
+ const U = ee(w.value);
716
+ if (U.length > 0 && ((N = a.sampleContent) != null && N.buttonVariables)) {
717
+ const f = U.map(
718
+ ({ number: b }) => {
719
+ var M, g;
720
+ return ((g = (M = a.sampleContent) == null ? void 0 : M.buttonVariables) == null ? void 0 : g[b]) || `sample${b}`;
644
721
  }
645
722
  );
646
- f.example = U;
723
+ o.example = f;
647
724
  }
648
725
  }
649
- return (g.type === "CALL" || g.type === "PHONE_NUMBER") && g.value && (f.phone_number = g.value.startsWith("+") ? g.value : `+${g.value}`), f;
726
+ return (w.type === "CALL" || w.type === "PHONE_NUMBER") && w.value && (o.phone_number = ue(w.value)), o;
650
727
  });
651
728
  i.components.push({
652
729
  type: "BUTTONS",
653
- buttons: C
730
+ buttons: k
654
731
  });
655
732
  }
656
733
  return JSON.stringify(i);
657
- }, He = (a, n) => {
658
- var m, C, g;
734
+ }, Re = (a, s) => {
735
+ var l, k, w;
659
736
  const i = {
660
737
  name: a.name,
661
- lang: n,
738
+ lang: s,
662
739
  category: a.category,
663
740
  shortlink: a.enableClickTracking ? "1" : "0",
664
741
  components: []
665
742
  };
666
- (m = a.carousel) != null && m.cards.length && (i.media = {}, a.carousel.cards.forEach((f, y) => {
667
- f.mediaUrl && (i.media[`card${y}header`] = f.mediaUrl);
743
+ (l = a.carousel) != null && l.cards.length && (i.media = {}, a.carousel.cards.forEach((o, N) => {
744
+ o.mediaUrl && (i.media[`card${N}header`] = o.mediaUrl);
668
745
  }));
669
- const l = [], d = J(a.body), p = {
746
+ const n = [], t = ee(a.body), x = {
670
747
  type: "BODY",
671
748
  text: a.body,
672
- ...d.length > 0 && ((C = a.sampleContent) == null ? void 0 : C.bodyVariables) && {
749
+ ...t.length > 0 && ((k = a.sampleContent) == null ? void 0 : k.bodyVariables) && {
673
750
  example: {
674
- body_text: [oe(a, d)]
751
+ body_text: [be(a, t)]
675
752
  }
676
753
  }
677
754
  };
678
- if (l.push(p), (g = a.carousel) != null && g.cards.length) {
679
- const f = {
755
+ if (n.push(x), (w = a.carousel) != null && w.cards.length) {
756
+ const o = {
680
757
  type: "CAROUSEL",
681
- cards: a.carousel.cards.map((y, j) => {
758
+ cards: a.carousel.cards.map((N) => {
682
759
  var U;
683
760
  return {
684
761
  components: [
@@ -688,47 +765,47 @@ const De = async (a, n) => {
688
765
  },
689
766
  {
690
767
  type: "BODY",
691
- text: y.body,
692
- ...J(y.body).length > 0 && {
768
+ text: N.body,
769
+ ...ee(N.body).length > 0 && {
693
770
  example: {
694
- body_text: [$e(y)]
771
+ body_text: [aa(N)]
695
772
  }
696
773
  }
697
774
  },
698
- ...y.buttons.length > 0 ? [{
775
+ ...N.buttons.length > 0 ? [{
699
776
  type: "BUTTONS",
700
- buttons: y.buttons.map((k) => {
701
- var o;
702
- const N = {
703
- type: k.type === "CALL" ? "PHONE_NUMBER" : k.type,
704
- text: k.text
777
+ buttons: N.buttons.map((f) => {
778
+ var M;
779
+ const b = {
780
+ type: f.type === "CALL" ? "PHONE_NUMBER" : f.type,
781
+ text: f.text
705
782
  };
706
- if (k.type === "URL" && k.value && (N.url = k.value, k.urlType === "dynamic" && k.value.includes("{{"))) {
707
- const u = J(k.value);
708
- if (u.length > 0) {
709
- const t = ((o = y == null ? void 0 : y.sampleContent) == null ? void 0 : o.buttonVariables) || {}, h = u.map(({ number: v }) => t[v] || `sample${v}`);
710
- N.example = h;
783
+ if (f.type === "URL" && f.value && (b.url = f.value, f.urlType === "dynamic" && f.value.includes("{{"))) {
784
+ const g = ee(f.value);
785
+ if (g.length > 0) {
786
+ const v = ((M = N == null ? void 0 : N.sampleContent) == null ? void 0 : M.buttonVariables) || {}, c = g.map(({ number: p }) => v[p] || `sample${p}`);
787
+ b.example = c;
711
788
  }
712
789
  }
713
- return (k.type === "CALL" || k.type === "PHONE_NUMBER") && k.value && (N.phone_number = k.value), console.log("Carousel card button data:", N), N;
790
+ return (f.type === "CALL" || f.type === "PHONE_NUMBER") && f.value && (b.phone_number = ue(f.value)), console.log("Carousel card button data:", b), b;
714
791
  })
715
792
  }] : []
716
793
  ]
717
794
  };
718
795
  })
719
796
  };
720
- l.push(f);
797
+ n.push(o);
721
798
  }
722
- return i.components = l, JSON.stringify(i);
723
- }, $e = (a) => {
724
- var l;
725
- const n = J(a.body || ""), i = ((l = a == null ? void 0 : a.sampleContent) == null ? void 0 : l.bodyVariables) || {};
726
- return n.map(({ number: d }) => i[d] || `Sample ${d}`);
727
- }, Ge = (a, n) => {
728
- var m, C;
799
+ return i.components = n, JSON.stringify(i);
800
+ }, aa = (a) => {
801
+ var n;
802
+ const s = ee(a.body || ""), i = ((n = a == null ? void 0 : a.sampleContent) == null ? void 0 : n.bodyVariables) || {};
803
+ return s.map(({ number: t }) => i[t] || `Sample ${t}`);
804
+ }, Ie = (a, s) => {
805
+ var l, k;
729
806
  const i = {
730
807
  name: a.name,
731
- lang: n,
808
+ lang: s,
732
809
  category: a.category,
733
810
  shortlink: a.enableClickTracking ? "1" : "0",
734
811
  components: []
@@ -736,94 +813,229 @@ const De = async (a, n) => {
736
813
  a.headerType === "MEDIA" && a.mediaUrl && a.mediaType !== "DOCUMENT" && (i.media = {
737
814
  header: a.mediaUrl
738
815
  });
739
- const l = [];
816
+ const n = [];
740
817
  if (a.type !== "CAROUSEL") {
741
818
  if (a.headerType === "TEXT" && a.headerText) {
742
- const g = J(a.headerText), f = {
819
+ const w = ee(a.headerText), o = {
743
820
  type: "HEADER",
744
821
  format: "TEXT",
745
822
  text: a.headerText,
746
- ...g.length > 0 && ((m = a.sampleContent) == null ? void 0 : m.headerVariables) && {
823
+ ...w.length > 0 && ((l = a.sampleContent) == null ? void 0 : l.headerVariables) && {
747
824
  example: {
748
- header_text: We(a, g)
825
+ header_text: ra(a, w)
749
826
  }
750
827
  }
751
828
  };
752
- l.push(f);
829
+ n.push(o);
753
830
  } else if (a.headerType === "MEDIA") {
754
- const g = {
831
+ const w = {
755
832
  type: "HEADER",
756
833
  format: a.mediaType || "IMAGE"
757
834
  };
758
- l.push(g);
835
+ n.push(w);
759
836
  }
760
837
  }
761
- const d = J(a.body), p = {
838
+ const t = ee(a.body), x = {
762
839
  type: "BODY",
763
840
  text: a.body,
764
- ...d.length > 0 && ((C = a.sampleContent) == null ? void 0 : C.bodyVariables) && {
841
+ ...t.length > 0 && ((k = a.sampleContent) == null ? void 0 : k.bodyVariables) && {
765
842
  example: {
766
- body_text: [oe(a, d)]
843
+ body_text: [be(a, t)]
767
844
  }
768
845
  }
769
846
  };
770
- if (l.push(p), a.footer && a.type !== "CAROUSEL" && l.push({
847
+ if (n.push(x), a.footer && a.type !== "CAROUSEL" && n.push({
771
848
  type: "FOOTER",
772
849
  text: a.footer
773
850
  }), a.buttons.length > 0) {
774
- const g = a.buttons.map((f) => {
775
- var j;
776
- const y = {
777
- type: f.type === "CALL" ? "PHONE_NUMBER" : f.type,
778
- text: f.text
851
+ const w = a.buttons.map((o) => {
852
+ var U;
853
+ const N = {
854
+ type: o.type === "CALL" ? "PHONE_NUMBER" : o.type,
855
+ text: o.text
779
856
  };
780
- if (f.type === "URL" && f.value && (y.url = f.value, f.urlType === "dynamic" && f.value.includes("{{"))) {
781
- const U = J(f.value);
782
- if (U.length > 0 && ((j = a.sampleContent) != null && j.buttonVariables)) {
783
- const k = U.map(
784
- ({ number: N }) => {
785
- var o, u;
786
- return ((u = (o = a.sampleContent) == null ? void 0 : o.buttonVariables) == null ? void 0 : u[N]) || `sample${N}`;
857
+ if (o.type === "URL" && o.value && (N.url = o.value, o.urlType === "dynamic" && o.value.includes("{{"))) {
858
+ const f = ee(o.value);
859
+ if (f.length > 0 && ((U = a.sampleContent) != null && U.buttonVariables)) {
860
+ const b = f.map(
861
+ ({ number: M }) => {
862
+ var g, v;
863
+ return ((v = (g = a.sampleContent) == null ? void 0 : g.buttonVariables) == null ? void 0 : v[M]) || `sample${M}`;
787
864
  }
788
865
  );
789
- y.example = k;
866
+ N.example = b;
790
867
  }
791
868
  }
792
- return (f.type === "CALL" || f.type === "PHONE_NUMBER") && f.value && (y.phone_number = f.value), y;
869
+ return (o.type === "CALL" || o.type === "PHONE_NUMBER") && o.value && (N.phone_number = ue(o.value)), N;
793
870
  });
794
- l.push({
871
+ n.push({
795
872
  type: "BUTTONS",
796
- buttons: g
873
+ buttons: w
797
874
  });
798
875
  }
799
- return i.components = l, JSON.stringify(i);
800
- }, J = (a) => (a.match(/\{\{(\d+)\}\}/g) || []).map((i) => ({
876
+ return i.components = n, JSON.stringify(i);
877
+ }, ee = (a) => (a.match(/\{\{(\d+)\}\}/g) || []).map((i) => ({
801
878
  variable: i.replace(/[{}]/g, ""),
802
879
  number: i.replace(/[{}]/g, "")
803
- })), We = (a, n) => n.map(
880
+ })), ue = (a) => a.startsWith("+") ? a : `+${a}`, ra = (a, s) => s.map(
804
881
  ({ number: i }) => {
805
- var l, d;
806
- return ((d = (l = a.sampleContent) == null ? void 0 : l.headerVariables) == null ? void 0 : d[i]) || `Sample ${i}`;
882
+ var n, t;
883
+ return ((t = (n = a.sampleContent) == null ? void 0 : n.headerVariables) == null ? void 0 : t[i]) || `Sample ${i}`;
807
884
  }
808
- ), oe = (a, n) => n.map(
885
+ ), be = (a, s) => s.map(
809
886
  ({ number: i }) => {
810
- var l, d;
811
- return ((d = (l = a.sampleContent) == null ? void 0 : l.bodyVariables) == null ? void 0 : d[i]) || `Sample ${i}`;
887
+ var n, t;
888
+ return ((t = (n = a.sampleContent) == null ? void 0 : n.bodyVariables) == null ? void 0 : t[i]) || `Sample ${i}`;
812
889
  }
813
- ), Ke = async (a, n) => {
890
+ ), sa = async (a, s) => {
814
891
  try {
815
- if (!n.name || !n.body)
892
+ if (!s.name || !s.body)
816
893
  throw new Error("Missing required template fields: name and body are required");
817
894
  if (!a.apiKey)
818
895
  throw new Error("Missing TrustSignal API key");
819
- return await De(a.apiKey, n);
896
+ return await Ze(
897
+ a.apiKey,
898
+ s
899
+ );
820
900
  } catch (i) {
821
901
  return console.error("API Error:", i), {
822
902
  status: "error",
823
903
  message: i instanceof Error ? i.message : "An unexpected error occurred while creating the template"
824
904
  };
825
905
  }
826
- }, Qe = [
906
+ };
907
+ async function na(a, s, i) {
908
+ const n = ea(i), x = {
909
+ method: "POST",
910
+ headers: { "Content-Type": "application/json" },
911
+ body: n,
912
+ redirect: "follow"
913
+ }, l = `https://wpapi.trustsignal.io/v1/user-templates/update/${encodeURIComponent(s)}?api_key=${encodeURIComponent(a)}`, k = await fetch(l, x), w = await k.text();
914
+ if (!k.ok)
915
+ return { success: !1, message: `Update failed (${k.status}): ${w}`, raw: n };
916
+ try {
917
+ const o = JSON.parse(w);
918
+ return { success: !!((o == null ? void 0 : o.success) ?? !0), message: o == null ? void 0 : o.message, raw: n };
919
+ } catch {
920
+ return { success: !0, raw: n };
921
+ }
922
+ }
923
+ async function ia(a, s) {
924
+ var k;
925
+ const i = `https://wpapi.trustsignal.io/api/v1/template/${encodeURIComponent(s)}?api_key=${encodeURIComponent(a)}`, n = await fetch(i, { method: "GET", redirect: "follow" });
926
+ if (!n.ok)
927
+ throw new Error(`Failed to fetch template ${s}: ${n.status}`);
928
+ const t = await n.text(), x = JSON.parse(t), l = x.template || ((k = x.data) == null ? void 0 : k.template) || x;
929
+ if (!l)
930
+ throw new Error("Invalid template details response");
931
+ return la(l);
932
+ }
933
+ function la(a) {
934
+ var N, U;
935
+ const s = {
936
+ headerVariables: {},
937
+ bodyVariables: {},
938
+ buttonVariables: {}
939
+ };
940
+ let i = "NONE", n = "", t, x, l = "", k = "";
941
+ const w = [];
942
+ if (a.jsonstruct)
943
+ try {
944
+ const f = JSON.parse(a.jsonstruct);
945
+ if (f != null && f.header) {
946
+ const b = f.header.format;
947
+ b && b !== "TEXT" ? (i = "MEDIA", t = b, x = f.header.url || ((N = a.medialist) == null ? void 0 : N.header)) : b === "TEXT" && (i = "TEXT", n = f.header.text || "");
948
+ }
949
+ if (f != null && f.body && (l = f.body.text || ""), (U = f == null ? void 0 : f.buttons) != null && U.buttons && Array.isArray(f.buttons.buttons))
950
+ for (const b of f.buttons.buttons) {
951
+ if (!b || !b.type || !b.text) continue;
952
+ const M = {
953
+ id: de(),
954
+ type: b.type === "PHONE_NUMBER" ? "PHONE_NUMBER" : b.type,
955
+ text: b.text
956
+ };
957
+ b.type === "URL" && (M.value = b.url, typeof b.url == "string" && b.url.includes("{{") && Array.isArray(b.example) ? (Ce(b.url).forEach((v, c) => {
958
+ s.buttonVariables[v] = b.example[c] ?? "";
959
+ }), M.urlType = "dynamic") : M.urlType = "static"), (b.type === "CALL" || b.type === "PHONE_NUMBER") && (M.value = b.phone_number || ""), w.push(M);
960
+ }
961
+ if (f != null && f.carousel) {
962
+ const b = Object.keys(f.carousel).filter((p) => /^card\d+$/.test(p));
963
+ b.sort((p, y) => {
964
+ const u = parseInt(p.replace("card", ""), 10), V = parseInt(y.replace("card", ""), 10);
965
+ return u - V;
966
+ });
967
+ const M = b.map((p) => {
968
+ const y = f.carousel[p] || {}, u = y.header || {}, V = y.body || {}, B = y.buttons && Array.isArray(y.buttons.buttons) ? y.buttons.buttons : [], d = u.format, E = d === "IMAGE" || d === "VIDEO" || d === "DOCUMENT" ? d : void 0, O = `card${p.replace("card", "")}header`, R = u.url || (a.medialist ? a.medialist[O] : void 0), _ = V.text || "", m = [];
969
+ for (const C of B) {
970
+ if (!C || !C.type || !C.text) continue;
971
+ const S = { id: de(), type: C.type === "PHONE_NUMBER" ? "PHONE_NUMBER" : C.type, text: C.text };
972
+ C.type === "URL" && (S.value = C.url, typeof C.url == "string" && C.url.includes("{{") && Array.isArray(C.example) ? (Ce(C.url).forEach((I, h) => {
973
+ }), S.urlType = "dynamic") : S.urlType = "static"), (C.type === "CALL" || C.type === "PHONE_NUMBER") && (S.value = C.phone_number || ""), m.push(S);
974
+ }
975
+ return {
976
+ id: de(),
977
+ headerType: E ? "MEDIA" : "NONE",
978
+ mediaType: E,
979
+ mediaUrl: R,
980
+ body: _,
981
+ buttons: m,
982
+ sampleContent: {
983
+ headerVariables: {},
984
+ bodyVariables: {},
985
+ buttonVariables: {}
986
+ }
987
+ };
988
+ });
989
+ let g = "IMAGE";
990
+ const v = M[0];
991
+ (v == null ? void 0 : v.mediaType) === "VIDEO" && (g = "VIDEO");
992
+ const c = {
993
+ type: g,
994
+ cards: M
995
+ };
996
+ return {
997
+ name: a.name,
998
+ category: a.category === "MARKETING" || a.category === "UTILITY" ? a.category : "MARKETING",
999
+ type: "CAROUSEL",
1000
+ language: a.lang || "en",
1001
+ enableClickTracking: !1,
1002
+ headerType: "NONE",
1003
+ headerText: "",
1004
+ body: l,
1005
+ footer: k,
1006
+ buttons: [],
1007
+ sampleContent: s,
1008
+ carousel: c
1009
+ };
1010
+ }
1011
+ } catch (f) {
1012
+ console.warn("Failed to parse jsonstruct; falling back", f);
1013
+ }
1014
+ return {
1015
+ name: a.name,
1016
+ category: a.category === "MARKETING" || a.category === "UTILITY" ? a.category : "MARKETING",
1017
+ type: "BASIC",
1018
+ language: a.lang || "en",
1019
+ enableClickTracking: !1,
1020
+ headerType: i,
1021
+ headerText: n,
1022
+ mediaType: t,
1023
+ mediaUrl: x,
1024
+ body: l,
1025
+ footer: k,
1026
+ buttons: w,
1027
+ sampleContent: s
1028
+ };
1029
+ }
1030
+ function Ce(a) {
1031
+ if (!a) return [];
1032
+ const s = a.match(/\{\{(\d+)\}\}/g) || [];
1033
+ return [...new Set(s.map((i) => i.replace(/[{}]/g, "")))];
1034
+ }
1035
+ function de() {
1036
+ return typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : "id-" + Math.random().toString(36).slice(2);
1037
+ }
1038
+ const ta = [
827
1039
  { value: "af", label: "Afrikaans" },
828
1040
  { value: "sq", label: "Albanian" },
829
1041
  { value: "ar", label: "Arabic" },
@@ -889,118 +1101,118 @@ const De = async (a, n) => {
889
1101
  { value: "ur", label: "Urdu" },
890
1102
  { value: "uz", label: "Uzbek" },
891
1103
  { value: "vi", label: "Vietnamese" }
892
- ], Ye = [
1104
+ ], ca = [
893
1105
  { value: "NONE", label: "None" },
894
1106
  { value: "TEXT", label: "Text" },
895
1107
  { value: "MEDIA", label: "Media" }
896
- ], Xe = [
1108
+ ], ma = [
897
1109
  { value: "IMAGE", label: "Image" },
898
1110
  { value: "VIDEO", label: "Video" },
899
1111
  { value: "DOCUMENT", label: "Document" }
900
- ], Je = 5 * 1024 * 1024, Ze = 16 * 1024 * 1024, ea = 100 * 1024 * 1024, ie = ["jpg", "jpeg", "png"], te = ["mp4", "3gpp"], me = ["pdf", "docx", "xlsx", "pptx", "txt"];
901
- function aa({ template: a, setTemplate: n, onFileUpload: i }) {
902
- var R, I;
903
- const [l, d] = K.useState(null), [p, m] = K.useState(!1), [C, g] = K.useState(null), [f, y] = K.useState(null), j = () => {
904
- const w = (a.headerText || "").match(/{{\d+}}/g);
905
- if (!w) return 0;
906
- const L = w.map((s) => {
907
- const b = s.match(/{{(\d+)}}/);
908
- return b ? parseInt(b[1], 10) : 0;
1112
+ ], 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"];
1113
+ function oa({ template: a, setTemplate: s, onFileUpload: i }) {
1114
+ var V, B;
1115
+ const [n, t] = J.useState(null), [x, l] = J.useState(!1), [k, w] = J.useState(null), [o, N] = J.useState(null), U = () => {
1116
+ const E = (a.headerText || "").match(/{{\d+}}/g);
1117
+ if (!E) return 0;
1118
+ const A = E.map((O) => {
1119
+ const R = O.match(/{{(\d+)}}/);
1120
+ return R ? parseInt(R[1], 10) : 0;
909
1121
  });
910
- return L.length > 0 ? Math.max(...L) : 0;
911
- }, U = () => {
912
- const L = `{{${j() + 1}}}`;
913
- if (C && a.headerText.length + L.length <= 60) {
914
- const s = C.selectionStart || a.headerText.length, b = a.headerText.substring(0, s), E = a.headerText.substring(s), T = b + L + E;
915
- n({ ...a, headerText: T }), setTimeout(() => {
916
- if (C) {
917
- const c = s + L.length;
918
- C.setSelectionRange(c, c), C.focus();
1122
+ return A.length > 0 ? Math.max(...A) : 0;
1123
+ }, f = () => {
1124
+ const A = `{{${U() + 1}}}`;
1125
+ if (k && a.headerText.length + A.length <= 60) {
1126
+ const O = k.selectionStart || a.headerText.length, R = a.headerText.substring(0, O), _ = a.headerText.substring(O), m = R + A + _;
1127
+ s({ ...a, headerText: m }), setTimeout(() => {
1128
+ if (k) {
1129
+ const C = O + A.length;
1130
+ k.setSelectionRange(C, C), k.focus();
919
1131
  }
920
1132
  }, 0);
921
1133
  }
922
- }, k = (x) => {
923
- n((w) => ({
924
- ...w,
925
- headerType: x,
926
- headerText: x === "TEXT" ? w.headerText : "",
927
- mediaType: x === "MEDIA" ? w.mediaType || "IMAGE" : void 0,
928
- mediaUrl: x === "MEDIA" ? w.mediaUrl : void 0
929
- })), x !== "MEDIA" && (d(null), y(null));
930
- }, N = (x) => {
931
- var w;
932
- return ((w = x.split("?")[0].split(".").pop()) == null ? void 0 : w.toLowerCase()) || "";
933
- }, o = (x, w) => {
934
- const L = N(x.name);
935
- switch (w) {
1134
+ }, b = (d) => {
1135
+ s((E) => ({
1136
+ ...E,
1137
+ headerType: d,
1138
+ headerText: d === "TEXT" ? E.headerText : "",
1139
+ mediaType: d === "MEDIA" ? E.mediaType || "IMAGE" : void 0,
1140
+ mediaUrl: d === "MEDIA" ? E.mediaUrl : void 0
1141
+ })), d !== "MEDIA" && (t(null), N(null));
1142
+ }, M = (d) => {
1143
+ var E;
1144
+ return ((E = d.split("?")[0].split(".").pop()) == null ? void 0 : E.toLowerCase()) || "";
1145
+ }, g = (d, E) => {
1146
+ const A = M(d.name);
1147
+ switch (E) {
936
1148
  case "IMAGE":
937
- if (!ie.includes(L)) return "Invalid format. Only JPG, JPEG, PNG are allowed.";
938
- if (x.size > Je) return "File is too large. Max size is 5 MB.";
1149
+ if (!xe.includes(A)) return "Invalid format. Only JPG, JPEG, PNG are allowed.";
1150
+ if (d.size > da) return "File is too large. Max size is 5 MB.";
939
1151
  break;
940
1152
  case "VIDEO":
941
- if (!te.includes(L)) return "Invalid format. Only MP4, 3GPP are allowed.";
942
- if (x.size > Ze) return "File is too large. Max size is 16 MB.";
1153
+ if (!pe.includes(A)) return "Invalid format. Only MP4, 3GPP are allowed.";
1154
+ if (d.size > xa) return "File is too large. Max size is 16 MB.";
943
1155
  break;
944
1156
  case "DOCUMENT":
945
- if (!me.includes(L)) return "Invalid format. Allowed types: PDF, DOCX, XLSX, PPTX, TXT.";
946
- if (x.size > ea) return "File is too large. Max size is 100 MB.";
1157
+ if (!oe.includes(A)) return "Invalid format. Allowed types: PDF, DOCX, XLSX, PPTX, TXT.";
1158
+ if (d.size > pa) return "File is too large. Max size is 100 MB.";
947
1159
  break;
948
1160
  default:
949
1161
  return "Invalid media type.";
950
1162
  }
951
1163
  return null;
952
- }, u = (x, w) => {
953
- if (!x) return null;
954
- const L = N(x);
955
- switch (w) {
1164
+ }, v = (d, E) => {
1165
+ if (!d) return null;
1166
+ const A = M(d);
1167
+ switch (E) {
956
1168
  case "IMAGE":
957
- if (!ie.includes(L)) return "URL does not point to a valid image (JPG, JPEG, PNG).";
1169
+ if (!xe.includes(A)) return "URL does not point to a valid image (JPG, JPEG, PNG).";
958
1170
  break;
959
1171
  case "VIDEO":
960
- if (!te.includes(L)) return "URL does not point to a valid video (MP4, 3GPP).";
1172
+ if (!pe.includes(A)) return "URL does not point to a valid video (MP4, 3GPP).";
961
1173
  break;
962
1174
  case "DOCUMENT":
963
- if (!me.includes(L)) return "URL does not point to a valid document.";
1175
+ if (!oe.includes(A)) return "URL does not point to a valid document.";
964
1176
  break;
965
1177
  }
966
1178
  return null;
967
- }, t = () => {
968
- d(null), n({ ...a, mediaUrl: "" }), y(null);
969
- }, h = async (x) => {
970
- var s;
971
- const w = (s = x.target.files) == null ? void 0 : s[0];
972
- if (!w || !a.mediaType) return;
973
- y(null);
974
- const L = o(w, a.mediaType);
975
- if (L) {
976
- y(L);
1179
+ }, c = () => {
1180
+ t(null), s({ ...a, mediaUrl: "" }), N(null);
1181
+ }, p = async (d) => {
1182
+ var O;
1183
+ const E = (O = d.target.files) == null ? void 0 : O[0];
1184
+ if (!E || !a.mediaType) return;
1185
+ N(null);
1186
+ const A = g(E, a.mediaType);
1187
+ if (A) {
1188
+ N(A);
977
1189
  return;
978
1190
  }
979
- m(!0), d(w);
1191
+ l(!0), t(E);
980
1192
  try {
981
- const b = await i(w);
982
- n({ ...a, mediaUrl: b });
983
- } catch (b) {
984
- console.error("File upload failed:", b), t();
985
- const E = b instanceof Error ? b.message : "File upload failed. Please try again.";
986
- y(E);
1193
+ const R = await i(E);
1194
+ s({ ...a, mediaUrl: R });
1195
+ } catch (R) {
1196
+ console.error("File upload failed:", R), c();
1197
+ const _ = R instanceof Error ? R.message : "File upload failed. Please try again.";
1198
+ N(_);
987
1199
  } finally {
988
- m(!1);
1200
+ l(!1);
989
1201
  }
990
- }, v = (x) => {
991
- const w = x.target.value;
992
- if (d(null), n({ ...a, mediaUrl: w }), a.mediaType) {
993
- const L = u(w, a.mediaType);
994
- y(L);
1202
+ }, y = (d) => {
1203
+ const E = d.target.value;
1204
+ if (t(null), s({ ...a, mediaUrl: E }), a.mediaType) {
1205
+ const A = v(E, a.mediaType);
1206
+ N(A);
995
1207
  }
996
- }, V = () => {
1208
+ }, u = () => {
997
1209
  switch (a.mediaType) {
998
1210
  case "IMAGE":
999
- return ie.map((x) => `.${x}`).join(",");
1211
+ return xe.map((d) => `.${d}`).join(",");
1000
1212
  case "VIDEO":
1001
- return te.map((x) => `.${x}`).join(",");
1213
+ return pe.map((d) => `.${d}`).join(",");
1002
1214
  case "DOCUMENT":
1003
- return me.map((x) => `.${x}`).join(",");
1215
+ return oe.map((d) => `.${d}`).join(",");
1004
1216
  default:
1005
1217
  return "*/*";
1006
1218
  }
@@ -1013,9 +1225,9 @@ function aa({ template: a, setTemplate: n, onFileUpload: i }) {
1013
1225
  "select",
1014
1226
  {
1015
1227
  value: a.headerType,
1016
- onChange: (x) => k(x.target.value),
1228
+ onChange: (d) => b(d.target.value),
1017
1229
  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",
1018
- children: Ye.map((x) => /* @__PURE__ */ e("option", { value: x.value, children: x.label }, x.value))
1230
+ children: ca.map((d) => /* @__PURE__ */ e("option", { value: d.value, children: d.label }, d.value))
1019
1231
  }
1020
1232
  ),
1021
1233
  /* @__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" }) }) }),
@@ -1027,10 +1239,10 @@ function aa({ template: a, setTemplate: n, onFileUpload: i }) {
1027
1239
  /* @__PURE__ */ e("div", { className: "rsp-relative", children: /* @__PURE__ */ e(
1028
1240
  "input",
1029
1241
  {
1030
- ref: g,
1242
+ ref: w,
1031
1243
  type: "text",
1032
1244
  value: a.headerText,
1033
- onChange: (x) => n({ ...a, headerText: x.target.value }),
1245
+ onChange: (d) => s({ ...a, headerText: d.target.value }),
1034
1246
  maxLength: 60,
1035
1247
  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",
1036
1248
  placeholder: "Add a 60 character title to your message"
@@ -1040,7 +1252,7 @@ function aa({ template: a, setTemplate: n, onFileUpload: i }) {
1040
1252
  /* @__PURE__ */ e(
1041
1253
  "button",
1042
1254
  {
1043
- onClick: U,
1255
+ onClick: f,
1044
1256
  className: "rsp-px-2 rsp-py-1 rsp-text-xs hover:rsp-bg-gray-100 rsp-rounded rsp-text-gray-500 rsp-flex rsp-items-center rsp-gap-1",
1045
1257
  title: "Add variable to header",
1046
1258
  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" }) })
@@ -1052,30 +1264,30 @@ function aa({ template: a, setTemplate: n, onFileUpload: i }) {
1052
1264
  ] })
1053
1265
  ] }),
1054
1266
  (() => {
1055
- const x = [...new Set((a.headerText.match(/\{\{(\d+)\}\}/g) || []).map((w) => w.replace(/[{}]/g, "")))];
1056
- return x.length === 0 ? null : /* @__PURE__ */ r("div", { className: "rsp-mt-3", children: [
1267
+ const d = [...new Set((a.headerText.match(/\{\{(\d+)\}\}/g) || []).map((E) => E.replace(/[{}]/g, "")))];
1268
+ return d.length === 0 ? null : /* @__PURE__ */ r("div", { className: "rsp-mt-3", children: [
1057
1269
  /* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-font-medium rsp-text-gray-600 rsp-mb-2", children: "Sample Values" }),
1058
- /* @__PURE__ */ e("div", { className: "rsp-grid rsp-grid-cols-3 rsp-gap-2", children: x.map((w) => {
1059
- var L, s;
1270
+ /* @__PURE__ */ e("div", { className: "rsp-grid rsp-grid-cols-3 rsp-gap-2", children: d.map((E) => {
1271
+ var A, O;
1060
1272
  return /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-2", children: [
1061
1273
  /* @__PURE__ */ r("label", { className: "rsp-text-xs rsp-text-gray-500 rsp-whitespace-nowrap", children: [
1062
- `{{${w}}}`,
1274
+ `{{${E}}}`,
1063
1275
  ":"
1064
1276
  ] }),
1065
1277
  /* @__PURE__ */ e(
1066
1278
  "input",
1067
1279
  {
1068
1280
  type: "text",
1069
- value: ((s = (L = a.sampleContent) == null ? void 0 : L.headerVariables) == null ? void 0 : s[w]) || "",
1070
- onChange: (b) => {
1071
- var T, c, M;
1072
- const E = {
1281
+ value: ((O = (A = a.sampleContent) == null ? void 0 : A.headerVariables) == null ? void 0 : O[E]) || "",
1282
+ onChange: (R) => {
1283
+ var m, C, S;
1284
+ const _ = {
1073
1285
  ...a.sampleContent,
1074
- headerVariables: { ...(T = a.sampleContent) == null ? void 0 : T.headerVariables, [w]: b.target.value },
1075
- bodyVariables: ((c = a.sampleContent) == null ? void 0 : c.bodyVariables) || {},
1076
- buttonVariables: ((M = a.sampleContent) == null ? void 0 : M.buttonVariables) || {}
1286
+ headerVariables: { ...(m = a.sampleContent) == null ? void 0 : m.headerVariables, [E]: R.target.value },
1287
+ bodyVariables: ((C = a.sampleContent) == null ? void 0 : C.bodyVariables) || {},
1288
+ buttonVariables: ((S = a.sampleContent) == null ? void 0 : S.buttonVariables) || {}
1077
1289
  };
1078
- n({ ...a, sampleContent: E });
1290
+ s({ ...a, sampleContent: _ });
1079
1291
  },
1080
1292
  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",
1081
1293
  placeholder: "Sample"
@@ -1086,16 +1298,16 @@ function aa({ template: a, setTemplate: n, onFileUpload: i }) {
1086
1298
  {
1087
1299
  type: "button",
1088
1300
  onClick: () => {
1089
- var c, M, A;
1090
- const b = new RegExp(`\\{\\{${w}\\}\\}`, "g"), E = (a.headerText || "").replace(b, ""), T = Object.fromEntries(Object.entries(((c = a.sampleContent) == null ? void 0 : c.headerVariables) || {}).filter(([O]) => O !== w));
1091
- n({
1301
+ var C, S, j;
1302
+ const R = new RegExp(`\\{\\{${E}\\}\\}`, "g"), _ = (a.headerText || "").replace(R, ""), m = Object.fromEntries(Object.entries(((C = a.sampleContent) == null ? void 0 : C.headerVariables) || {}).filter(([I]) => I !== E));
1303
+ s({
1092
1304
  ...a,
1093
- headerText: E,
1305
+ headerText: _,
1094
1306
  sampleContent: {
1095
1307
  ...a.sampleContent,
1096
- headerVariables: T,
1097
- bodyVariables: ((M = a.sampleContent) == null ? void 0 : M.bodyVariables) || {},
1098
- buttonVariables: ((A = a.sampleContent) == null ? void 0 : A.buttonVariables) || {}
1308
+ headerVariables: m,
1309
+ bodyVariables: ((S = a.sampleContent) == null ? void 0 : S.bodyVariables) || {},
1310
+ buttonVariables: ((j = a.sampleContent) == null ? void 0 : j.buttonVariables) || {}
1099
1311
  }
1100
1312
  });
1101
1313
  },
@@ -1104,7 +1316,7 @@ function aa({ template: a, setTemplate: n, onFileUpload: i }) {
1104
1316
  children: "×"
1105
1317
  }
1106
1318
  )
1107
- ] }, `header-sample-${w}`);
1319
+ ] }, `header-sample-${E}`);
1108
1320
  }) })
1109
1321
  ] });
1110
1322
  })()
@@ -1117,15 +1329,15 @@ function aa({ template: a, setTemplate: n, onFileUpload: i }) {
1117
1329
  "select",
1118
1330
  {
1119
1331
  value: a.mediaType || "IMAGE",
1120
- onChange: (x) => {
1121
- n((w) => ({
1122
- ...w,
1123
- mediaType: x.target.value,
1332
+ onChange: (d) => {
1333
+ s((E) => ({
1334
+ ...E,
1335
+ mediaType: d.target.value,
1124
1336
  mediaUrl: ""
1125
- })), d(null), y(null);
1337
+ })), t(null), N(null);
1126
1338
  },
1127
1339
  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",
1128
- children: Xe.map((x) => /* @__PURE__ */ e("option", { value: x.value, children: x.label }, x.value))
1340
+ children: ma.map((d) => /* @__PURE__ */ e("option", { value: d.value, children: d.label }, d.value))
1129
1341
  }
1130
1342
  ),
1131
1343
  /* @__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" }) }) })
@@ -1141,32 +1353,32 @@ function aa({ template: a, setTemplate: n, onFileUpload: i }) {
1141
1353
  src: a.mediaUrl,
1142
1354
  alt: "Preview",
1143
1355
  className: "rsp-w-12 rsp-h-12 rsp-object-cover rsp-rounded",
1144
- onError: (x) => {
1145
- x.currentTarget.style.display = "none", f || y("Could not load image preview from URL.");
1356
+ onError: (d) => {
1357
+ d.currentTarget.style.display = "none", o || N("Could not load image preview from URL.");
1146
1358
  },
1147
1359
  onLoad: () => {
1148
- f != null && f.includes("Could not load") && y(null);
1360
+ o != null && o.includes("Could not load") && N(null);
1149
1361
  }
1150
1362
  }
1151
1363
  ),
1152
- 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(ze, { className: "rsp-w-6 rsp-h-6 rsp-text-gray-500" }) }),
1153
- 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(Ie, { className: "rsp-w-6 rsp-h-6 rsp-text-gray-500" }) }),
1364
+ 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" }) }),
1365
+ 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" }) }),
1154
1366
  /* @__PURE__ */ r("div", { className: "overflow-hidden", children: [
1155
- /* @__PURE__ */ e("p", { className: "rsp-text-sm rsp-font-medium rsp-text-gray-900 rsp-truncate", children: l ? l.name : a.mediaUrl }),
1156
- l && /* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-gray-500", children: `${(l.size / 1024 / 1024).toFixed(2)} MB` })
1367
+ /* @__PURE__ */ e("p", { className: "rsp-text-sm rsp-font-medium rsp-text-gray-900 rsp-truncate", children: n ? n.name : a.mediaUrl }),
1368
+ n && /* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-gray-500", children: `${(n.size / 1024 / 1024).toFixed(2)} MB` })
1157
1369
  ] })
1158
1370
  ] }),
1159
- /* @__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(ee, { className: "rsp-w-4 rsp-h-4" }) })
1371
+ /* @__PURE__ */ e("button", { onClick: c, className: "rsp-p-1 rsp-text-gray-400 hover:rsp-text-red-500 rsp-transition-colors flex-shrink-0", children: /* @__PURE__ */ e(re, { className: "rsp-w-4 rsp-h-4" }) })
1160
1372
  ] }) : /* @__PURE__ */ r("div", { children: [
1161
- /* @__PURE__ */ e("input", { type: "file", accept: V(), onChange: h, className: "rsp-hidden", id: "media-upload", disabled: p }),
1373
+ /* @__PURE__ */ e("input", { type: "file", accept: u(), onChange: p, className: "rsp-hidden", id: "media-upload", disabled: x }),
1162
1374
  /* @__PURE__ */ r(
1163
1375
  "label",
1164
1376
  {
1165
1377
  htmlFor: "media-upload",
1166
- 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 ${p ? "rsp-opacity-50 rsp-cursor-not-allowed" : ""}`,
1378
+ 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 ${x ? "rsp-opacity-50 rsp-cursor-not-allowed" : ""}`,
1167
1379
  children: [
1168
- /* @__PURE__ */ e(_e, { className: "rsp-w-6 rsp-h-6 rsp-text-gray-400 rsp-mb-2" }),
1169
- /* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-text-gray-600", children: p ? "Uploading..." : `Upload ${((R = a.mediaType) == null ? void 0 : R.toLowerCase()) || "file"}` }),
1380
+ /* @__PURE__ */ e(Ye, { className: "rsp-w-6 rsp-h-6 rsp-text-gray-400 rsp-mb-2" }),
1381
+ /* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-text-gray-600", children: x ? "Uploading..." : `Upload ${((V = a.mediaType) == null ? void 0 : V.toLowerCase()) || "file"}` }),
1170
1382
  /* @__PURE__ */ r("span", { className: "rsp-text-xs rsp-text-gray-400 rsp-mt-1", children: [
1171
1383
  a.mediaType === "IMAGE" && "JPG, PNG up to 5MB",
1172
1384
  a.mediaType === "VIDEO" && "MP4, 3GPP up to 16MB",
@@ -1176,9 +1388,9 @@ function aa({ template: a, setTemplate: n, onFileUpload: i }) {
1176
1388
  }
1177
1389
  )
1178
1390
  ] }),
1179
- f && /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-2 rsp-text-xs rsp-text-red-600", children: [
1180
- /* @__PURE__ */ e(ce, { className: "rsp-w-4 rsp-h-4" }),
1181
- /* @__PURE__ */ e("span", { children: f })
1391
+ o && /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-2 rsp-text-xs rsp-text-red-600", children: [
1392
+ /* @__PURE__ */ e(fe, { className: "rsp-w-4 rsp-h-4" }),
1393
+ /* @__PURE__ */ e("span", { children: o })
1182
1394
  ] }),
1183
1395
  /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center", children: [
1184
1396
  /* @__PURE__ */ e("div", { className: "rsp-flex-1 rsp-border-t rsp-border-gray-300" }),
@@ -1190,16 +1402,16 @@ function aa({ template: a, setTemplate: n, onFileUpload: i }) {
1190
1402
  {
1191
1403
  type: "url",
1192
1404
  value: a.mediaUrl || "",
1193
- onChange: v,
1405
+ onChange: y,
1194
1406
  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",
1195
- placeholder: `Enter ${(I = a.mediaType) == null ? void 0 : I.toLowerCase()} URL`
1407
+ placeholder: `Enter ${(B = a.mediaType) == null ? void 0 : B.toLowerCase()} URL`
1196
1408
  }
1197
1409
  ) })
1198
1410
  ] })
1199
1411
  ] })
1200
1412
  ] });
1201
1413
  }
1202
- const we = [
1414
+ const Ee = [
1203
1415
  { name: "grinning-face", hexadecimal: "&#x1f600;" },
1204
1416
  { name: "grinning-face-with-smiling-eyes", hexadecimal: "&#x1f601;" },
1205
1417
  { name: "face-with-tears-of-joy", hexadecimal: "&#x1f602;" },
@@ -2998,56 +3210,56 @@ const we = [
2998
3210
  { name: "south-africa", hexadecimal: "&#x1f1ff;&#x1f1e6;" },
2999
3211
  { name: "zambia", hexadecimal: "&#x1f1ff;&#x1f1f2;" },
3000
3212
  { name: "zimbabwe", hexadecimal: "&#x1f1ff;&#x1f1fc;" }
3001
- ], ra = ({
3213
+ ], fa = ({
3002
3214
  emojis: a,
3003
- onSelect: n,
3215
+ onSelect: s,
3004
3216
  onClose: i
3005
3217
  }) => {
3006
- const [l, d] = B({ start: 0, end: 80 }), p = 8, m = 40, C = 400, g = ge((U) => {
3007
- const k = U.currentTarget.scrollTop, N = Math.floor(k / m), o = Math.min(
3008
- N + Math.ceil(C / m) + 2,
3009
- Math.ceil(a.length / p)
3218
+ const [n, t] = P({ start: 0, end: 80 }), x = 8, l = 40, k = 400, w = ke((f) => {
3219
+ const b = f.currentTarget.scrollTop, M = Math.floor(b / l), g = Math.min(
3220
+ M + Math.ceil(k / l) + 2,
3221
+ Math.ceil(a.length / x)
3010
3222
  );
3011
- d({
3012
- start: N * p,
3013
- end: o * p
3223
+ t({
3224
+ start: M * x,
3225
+ end: g * x
3014
3226
  });
3015
- }, [a.length, m, C, p]), f = ge((U) => {
3016
- const k = U.match(/&#x([0-9A-Fa-f]+);/g);
3017
- if (!k) return "";
3018
- const N = k.map((o) => {
3019
- const u = o.replace(/&#x|;/g, "");
3020
- return parseInt(u, 16);
3227
+ }, [a.length, l, k, x]), o = ke((f) => {
3228
+ const b = f.match(/&#x([0-9A-Fa-f]+);/g);
3229
+ if (!b) return "";
3230
+ const M = b.map((g) => {
3231
+ const v = g.replace(/&#x|;/g, "");
3232
+ return parseInt(v, 16);
3021
3233
  });
3022
- return String.fromCodePoint(...N);
3023
- }, []), y = Math.ceil(a.length / p) * m, j = a.slice(l.start, l.end);
3234
+ return String.fromCodePoint(...M);
3235
+ }, []), N = Math.ceil(a.length / x) * l, U = a.slice(n.start, n.end);
3024
3236
  return /* @__PURE__ */ e(
3025
3237
  "div",
3026
3238
  {
3027
3239
  className: "rsp-h-[400px] rsp-overflow-y-auto rsp-relative",
3028
- onScroll: g,
3029
- children: /* @__PURE__ */ e("div", { style: { height: y }, className: "rsp-relative", children: /* @__PURE__ */ e(
3240
+ onScroll: w,
3241
+ children: /* @__PURE__ */ e("div", { style: { height: N }, className: "rsp-relative", children: /* @__PURE__ */ e(
3030
3242
  "div",
3031
3243
  {
3032
3244
  className: "rsp-absolute rsp-w-full rsp-grid rsp-grid-cols-8 rsp-gap-1",
3033
3245
  style: {
3034
- top: Math.floor(l.start / p) * m,
3246
+ top: Math.floor(n.start / x) * l,
3035
3247
  transform: "translateY(0px)"
3036
3248
  },
3037
- children: j.map((U, k) => {
3038
- const N = l.start + k;
3249
+ children: U.map((f, b) => {
3250
+ const M = n.start + b;
3039
3251
  return /* @__PURE__ */ e(
3040
3252
  "button",
3041
3253
  {
3042
3254
  onClick: () => {
3043
- n(f(U.hexadecimal));
3255
+ s(o(f.hexadecimal));
3044
3256
  },
3045
3257
  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",
3046
- title: U.name,
3047
- style: { height: m },
3048
- children: f(U.hexadecimal)
3258
+ title: f.name,
3259
+ style: { height: l },
3260
+ children: o(f.hexadecimal)
3049
3261
  },
3050
- N
3262
+ M
3051
3263
  );
3052
3264
  })
3053
3265
  }
@@ -3055,113 +3267,113 @@ const we = [
3055
3267
  }
3056
3268
  );
3057
3269
  };
3058
- function fe({ isOpen: a, onClose: n, onSelect: i }) {
3059
- const [l, d] = B(""), p = Ne(() => l ? we.filter(
3060
- (m) => m.name.toLowerCase().includes(l.toLowerCase())
3061
- ) : we, [l]);
3062
- return K.useEffect(() => {
3063
- a || d("");
3064
- }, [a]), /* @__PURE__ */ e(pe, { isOpen: a, onClose: n, title: "Select Emoji", children: /* @__PURE__ */ r("div", { className: "rsp-space-y-4", children: [
3270
+ function ge({ isOpen: a, onClose: s, onSelect: i }) {
3271
+ const [n, t] = P(""), x = Se(() => n ? Ee.filter(
3272
+ (l) => l.name.toLowerCase().includes(n.toLowerCase())
3273
+ ) : Ee, [n]);
3274
+ return J.useEffect(() => {
3275
+ a || t("");
3276
+ }, [a]), /* @__PURE__ */ e(te, { isOpen: a, onClose: s, title: "Select Emoji", children: /* @__PURE__ */ r("div", { className: "rsp-space-y-4", children: [
3065
3277
  /* @__PURE__ */ r("div", { className: "rsp-relative", children: [
3066
3278
  /* @__PURE__ */ e(
3067
3279
  "input",
3068
3280
  {
3069
3281
  type: "text",
3070
3282
  placeholder: "Search emojis...",
3071
- value: l,
3072
- onChange: (m) => d(m.target.value),
3283
+ value: n,
3284
+ onChange: (l) => t(l.target.value),
3073
3285
  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"
3074
3286
  }
3075
3287
  ),
3076
- l && /* @__PURE__ */ e(
3288
+ n && /* @__PURE__ */ e(
3077
3289
  "button",
3078
3290
  {
3079
- onClick: () => d(""),
3291
+ onClick: () => t(""),
3080
3292
  className: "rsp-absolute rsp-right-2 rsp-top-1/2 rsp-transform -rsp-translate-y-1/2 rsp-text-gray-400 hover:rsp-text-gray-600",
3081
3293
  children: "×"
3082
3294
  }
3083
3295
  )
3084
3296
  ] }),
3085
- /* @__PURE__ */ e("div", { className: "rsp-flex rsp-gap-2 rsp-flex-wrap", children: ["😀", "🎉", "❤️", "👍", "🔥", "💯", "✨", "🎯"].map((m) => /* @__PURE__ */ e(
3297
+ /* @__PURE__ */ e("div", { className: "rsp-flex rsp-gap-2 rsp-flex-wrap", children: ["😀", "🎉", "❤️", "👍", "🔥", "💯", "✨", "🎯"].map((l) => /* @__PURE__ */ e(
3086
3298
  "button",
3087
3299
  {
3088
3300
  onClick: () => {
3089
- i(m);
3301
+ i(l);
3090
3302
  },
3091
3303
  className: "rsp-w-8 rsp-h-8 rsp-flex rsp-items-center rsp-justify-center rsp-text-lg hover:rsp-bg-gray-100 rsp-rounded rsp-transition-colors",
3092
- children: m
3304
+ children: l
3093
3305
  },
3094
- m
3306
+ l
3095
3307
  )) }),
3096
3308
  /* @__PURE__ */ r("div", { className: "rsp-text-sm rsp-text-gray-500", children: [
3097
- p.length,
3309
+ x.length,
3098
3310
  " emojis found"
3099
3311
  ] }),
3100
3312
  /* @__PURE__ */ e(
3101
- ra,
3313
+ fa,
3102
3314
  {
3103
- emojis: p,
3315
+ emojis: x,
3104
3316
  onSelect: i,
3105
- onClose: n
3317
+ onClose: s
3106
3318
  }
3107
3319
  )
3108
3320
  ] }) });
3109
3321
  }
3110
- function sa({ template: a, setTemplate: n }) {
3111
- const [i, l] = B(!1), [d, p] = B(null), [m, C] = B(null), [g, f] = B(null), y = () => {
3112
- const o = (a.body || "").match(/{{\d+}}/g);
3113
- if (!o) return 0;
3114
- const u = o.map((t) => {
3115
- const h = t.match(/{{(\d+)}}/);
3116
- return h ? parseInt(h[1], 10) : 0;
3322
+ function ha({ template: a, setTemplate: s }) {
3323
+ const [i, n] = P(!1), [t, x] = P(null), [l, k] = P(null), [w, o] = P(null), [N, U] = P(!1), f = () => {
3324
+ const c = (a.body || "").match(/{{\d+}}/g);
3325
+ if (!c) return 0;
3326
+ const p = c.map((y) => {
3327
+ const u = y.match(/{{(\d+)}}/);
3328
+ return u ? parseInt(u[1], 10) : 0;
3117
3329
  });
3118
- return u.length > 0 ? Math.max(...u) : 0;
3119
- }, j = () => {
3120
- const u = `{{${y() + 1}}}`;
3121
- if (m && a.body.length + u.length <= 1024) {
3122
- const t = m.selectionStart || a.body.length, h = a.body.substring(0, t), v = a.body.substring(t), V = h + u + v;
3123
- n({
3330
+ return p.length > 0 ? Math.max(...p) : 0;
3331
+ }, b = () => {
3332
+ const p = `{{${f() + 1}}}`;
3333
+ if (l && a.body.length + p.length <= 1024) {
3334
+ const y = l.selectionStart || a.body.length, u = a.body.substring(0, y), V = a.body.substring(y), B = u + p + V;
3335
+ s({
3124
3336
  ...a,
3125
- body: V
3337
+ body: B
3126
3338
  }), setTimeout(() => {
3127
- if (m) {
3128
- const R = t + u.length;
3129
- m.setSelectionRange(R, R), m.focus();
3339
+ if (l) {
3340
+ const d = y + p.length;
3341
+ l.setSelectionRange(d, d), l.focus();
3130
3342
  }
3131
3343
  }, 0);
3132
3344
  }
3133
- }, U = () => {
3134
- p("body"), l(!0), setTimeout(() => {
3135
- m && m.focus();
3345
+ }, M = () => {
3346
+ x("body"), n(!0), setTimeout(() => {
3347
+ l && l.focus();
3136
3348
  }, 0);
3137
- }, k = (N) => {
3138
- if (d === "body") {
3139
- if (!m) return;
3140
- const o = m.selectionStart || a.body.length, u = 1024, t = a.body;
3141
- if (t.length + N.length <= u) {
3142
- const h = t.substring(0, o), v = t.substring(o), V = h + N + v;
3143
- n({
3349
+ }, g = (v) => {
3350
+ if (t === "body") {
3351
+ if (!l) return;
3352
+ const c = l.selectionStart || a.body.length, p = 1024, y = a.body;
3353
+ if (y.length + v.length <= p) {
3354
+ const u = y.substring(0, c), V = y.substring(c), B = u + v + V;
3355
+ s({
3144
3356
  ...a,
3145
- body: V
3357
+ body: B
3146
3358
  }), setTimeout(() => {
3147
- if (m) {
3148
- const R = o + N.length;
3149
- m.setSelectionRange(R, R), m.focus();
3359
+ if (l) {
3360
+ const d = c + v.length;
3361
+ l.setSelectionRange(d, d), l.focus();
3150
3362
  }
3151
3363
  }, 0);
3152
3364
  }
3153
- } else if (d === "footer") {
3154
- if (!g) return;
3155
- const o = g.selectionStart || a.footer.length, u = 60, t = a.footer;
3156
- if (t.length + N.length <= u) {
3157
- const h = t.substring(0, o), v = t.substring(o), V = h + N + v;
3158
- n({
3365
+ } else if (t === "footer") {
3366
+ if (!w) return;
3367
+ const c = w.selectionStart || a.footer.length, p = 60, y = a.footer;
3368
+ if (y.length + v.length <= p) {
3369
+ const u = y.substring(0, c), V = y.substring(c), B = u + v + V;
3370
+ s({
3159
3371
  ...a,
3160
- footer: V
3372
+ footer: B
3161
3373
  }), setTimeout(() => {
3162
- if (g) {
3163
- const R = o + N.length;
3164
- g.setSelectionRange(R, R), g.focus();
3374
+ if (w) {
3375
+ const d = c + v.length;
3376
+ w.setSelectionRange(d, d), w.focus();
3165
3377
  }
3166
3378
  }, 0);
3167
3379
  }
@@ -3173,22 +3385,24 @@ function sa({ template: a, setTemplate: n }) {
3173
3385
  /* @__PURE__ */ e("div", { className: "rsp-relative", children: /* @__PURE__ */ e(
3174
3386
  "textarea",
3175
3387
  {
3176
- ref: C,
3388
+ ref: k,
3177
3389
  value: a.body,
3178
- onChange: (N) => n({ ...a, body: N.target.value }),
3390
+ onChange: (v) => s({ ...a, body: v.target.value }),
3179
3391
  maxLength: 1024,
3180
3392
  rows: 6,
3181
3393
  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",
3182
3394
  placeholder: "Enter the text for your message",
3183
- onFocus: () => p("body")
3395
+ onFocus: () => x("body"),
3396
+ onBlur: () => U(!0)
3184
3397
  }
3185
3398
  ) }),
3399
+ !a.body && N && /* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-red-600 rsp-mt-1", children: "Body is required." }),
3186
3400
  /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-justify-between rsp-mt-2", children: [
3187
3401
  /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-2", children: [
3188
3402
  /* @__PURE__ */ e(
3189
3403
  "button",
3190
3404
  {
3191
- onClick: j,
3405
+ onClick: b,
3192
3406
  className: "rsp-p-1 rsp-text-gray-500 hover:rsp-text-gray-700 hover:rsp-bg-gray-100 rsp-rounded",
3193
3407
  title: "Add Variable",
3194
3408
  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" }) })
@@ -3197,10 +3411,10 @@ function sa({ template: a, setTemplate: n }) {
3197
3411
  /* @__PURE__ */ e(
3198
3412
  "button",
3199
3413
  {
3200
- onClick: U,
3414
+ onClick: M,
3201
3415
  className: "rsp-p-1 rsp-text-gray-500 hover:rsp-text-gray-700 hover:rsp-bg-gray-100 rsp-rounded",
3202
3416
  title: "Add emoji",
3203
- children: /* @__PURE__ */ e(xe, { className: "rsp-w-4 rsp-h-4" })
3417
+ children: /* @__PURE__ */ e(he, { className: "rsp-w-4 rsp-h-4" })
3204
3418
  }
3205
3419
  )
3206
3420
  ] }),
@@ -3210,15 +3424,15 @@ function sa({ template: a, setTemplate: n }) {
3210
3424
  ] }) })
3211
3425
  ] }),
3212
3426
  (() => {
3213
- const N = a.body.match(/\{\{(\d+)\}\}/g) || [], o = [...new Set(N.map((u) => u.replace(/[{}]/g, "")))];
3214
- return o.length === 0 ? null : /* @__PURE__ */ r("div", { className: "rsp-mt-3", children: [
3427
+ const v = a.body.match(/\{\{(\d+)\}\}/g) || [], c = [...new Set(v.map((p) => p.replace(/[{}]/g, "")))];
3428
+ return c.length === 0 ? null : /* @__PURE__ */ r("div", { className: "rsp-mt-3", children: [
3215
3429
  /* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-font-medium rsp-text-gray-600 rsp-mb-2", children: "Sample Values" }),
3216
- /* @__PURE__ */ e("div", { className: "rsp-grid rsp-grid-cols-3 rsp-gap-2", children: o.map((u) => {
3217
- var t, h;
3430
+ /* @__PURE__ */ e("div", { className: "rsp-grid rsp-grid-cols-3 rsp-gap-2", children: c.map((p) => {
3431
+ var y, u;
3218
3432
  return /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-2", children: [
3219
3433
  /* @__PURE__ */ r("label", { className: "rsp-text-xs rsp-text-gray-500 rsp-whitespace-nowrap", children: [
3220
3434
  "{{",
3221
- u,
3435
+ p,
3222
3436
  "}}",
3223
3437
  ":"
3224
3438
  ] }),
@@ -3226,21 +3440,21 @@ function sa({ template: a, setTemplate: n }) {
3226
3440
  "input",
3227
3441
  {
3228
3442
  type: "text",
3229
- value: ((h = (t = a.sampleContent) == null ? void 0 : t.bodyVariables) == null ? void 0 : h[u]) || "",
3230
- onChange: (v) => {
3231
- var R, I, x;
3232
- const V = {
3443
+ value: ((u = (y = a.sampleContent) == null ? void 0 : y.bodyVariables) == null ? void 0 : u[p]) || "",
3444
+ onChange: (V) => {
3445
+ var d, E, A;
3446
+ const B = {
3233
3447
  ...a.sampleContent,
3234
3448
  bodyVariables: {
3235
- ...(R = a.sampleContent) == null ? void 0 : R.bodyVariables,
3236
- [u]: v.target.value
3449
+ ...(d = a.sampleContent) == null ? void 0 : d.bodyVariables,
3450
+ [p]: V.target.value
3237
3451
  },
3238
- headerVariables: ((I = a.sampleContent) == null ? void 0 : I.headerVariables) || {},
3239
- buttonVariables: ((x = a.sampleContent) == null ? void 0 : x.buttonVariables) || {}
3452
+ headerVariables: ((E = a.sampleContent) == null ? void 0 : E.headerVariables) || {},
3453
+ buttonVariables: ((A = a.sampleContent) == null ? void 0 : A.buttonVariables) || {}
3240
3454
  };
3241
- n({
3455
+ s({
3242
3456
  ...a,
3243
- sampleContent: V
3457
+ sampleContent: B
3244
3458
  });
3245
3459
  },
3246
3460
  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",
@@ -3252,16 +3466,16 @@ function sa({ template: a, setTemplate: n }) {
3252
3466
  {
3253
3467
  type: "button",
3254
3468
  onClick: () => {
3255
- var I, x, w;
3256
- const v = new RegExp(`\\{\\{${u}\\}\\}`, "g"), V = (a.body || "").replace(v, ""), R = Object.fromEntries(Object.entries(((I = a.sampleContent) == null ? void 0 : I.bodyVariables) || {}).filter(([L]) => L !== u));
3257
- n({
3469
+ var E, A, O;
3470
+ const V = new RegExp(`\\{\\{${p}\\}\\}`, "g"), B = (a.body || "").replace(V, ""), d = Object.fromEntries(Object.entries(((E = a.sampleContent) == null ? void 0 : E.bodyVariables) || {}).filter(([R]) => R !== p));
3471
+ s({
3258
3472
  ...a,
3259
- body: V,
3473
+ body: B,
3260
3474
  sampleContent: {
3261
3475
  ...a.sampleContent,
3262
- bodyVariables: R,
3263
- headerVariables: ((x = a.sampleContent) == null ? void 0 : x.headerVariables) || {},
3264
- buttonVariables: ((w = a.sampleContent) == null ? void 0 : w.buttonVariables) || {}
3476
+ bodyVariables: d,
3477
+ headerVariables: ((A = a.sampleContent) == null ? void 0 : A.headerVariables) || {},
3478
+ buttonVariables: ((O = a.sampleContent) == null ? void 0 : O.buttonVariables) || {}
3265
3479
  }
3266
3480
  });
3267
3481
  },
@@ -3270,7 +3484,7 @@ function sa({ template: a, setTemplate: n }) {
3270
3484
  children: "×"
3271
3485
  }
3272
3486
  )
3273
- ] }, `body-sample-${u}`);
3487
+ ] }, `body-sample-${p}`);
3274
3488
  }) })
3275
3489
  ] });
3276
3490
  })()
@@ -3280,14 +3494,14 @@ function sa({ template: a, setTemplate: n }) {
3280
3494
  /* @__PURE__ */ e("div", { className: "rsp-relative", children: /* @__PURE__ */ e(
3281
3495
  "input",
3282
3496
  {
3283
- ref: f,
3497
+ ref: o,
3284
3498
  type: "text",
3285
3499
  value: a.footer,
3286
- onChange: (N) => n({ ...a, footer: N.target.value }),
3500
+ onChange: (v) => s({ ...a, footer: v.target.value }),
3287
3501
  maxLength: 60,
3288
3502
  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",
3289
3503
  placeholder: "Footer Text",
3290
- onFocus: () => p("footer")
3504
+ onFocus: () => x("footer")
3291
3505
  }
3292
3506
  ) }),
3293
3507
  /* @__PURE__ */ r("p", { className: "rsp-text-xs rsp-text-gray-500 rsp-mt-1", children: [
@@ -3296,93 +3510,95 @@ function sa({ template: a, setTemplate: n }) {
3296
3510
  ] })
3297
3511
  ] }),
3298
3512
  /* @__PURE__ */ e(
3299
- fe,
3513
+ ge,
3300
3514
  {
3301
3515
  isOpen: i,
3302
- onClose: () => l(!1),
3303
- onSelect: k
3516
+ onClose: () => n(!1),
3517
+ onSelect: g
3304
3518
  }
3305
3519
  )
3306
3520
  ] });
3307
3521
  }
3308
- function na({ template: a, setTemplate: n }) {
3309
- var u;
3310
- const [i, l] = B(null), [d, p] = B(!1), [m, C] = B({
3522
+ function ua({ template: a, setTemplate: s }) {
3523
+ var v;
3524
+ const [i, n] = P(null), [t, x] = P(!1), [l, k] = P({
3311
3525
  text: "",
3312
3526
  value: "",
3313
3527
  urlType: "static"
3314
- }), f = {
3315
- quickReply: a.buttons.filter((t) => t.type === "QUICK_REPLY").length,
3316
- url: a.buttons.filter((t) => t.type === "URL").length,
3317
- call: a.buttons.filter((t) => t.type === "CALL").length,
3318
- flow: a.buttons.filter((t) => t.type === "FLOW").length
3319
- }, y = () => {
3320
- C({ text: "", value: "", urlType: "static" }), l(null), p(!1);
3321
- }, j = (t) => {
3322
- if (!m.text.trim()) return;
3323
- const h = {
3528
+ }), o = {
3529
+ quickReply: a.buttons.filter((c) => c.type === "QUICK_REPLY").length,
3530
+ url: a.buttons.filter((c) => c.type === "URL").length,
3531
+ call: a.buttons.filter((c) => c.type === "CALL").length,
3532
+ flow: a.buttons.filter((c) => c.type === "FLOW").length
3533
+ }, N = () => {
3534
+ k({ text: "", value: "", urlType: "static" }), n(null), x(!1);
3535
+ }, U = (c) => {
3536
+ if (!l.text.trim()) return;
3537
+ let p = c === "QUICK_REPLY" ? l.text : l.value;
3538
+ c === "CALL" && p && !p.startsWith("+") && (p = "+" + p);
3539
+ const y = {
3324
3540
  id: Math.random().toString(36).substr(2, 9),
3325
- type: t,
3326
- text: m.text,
3327
- value: t === "QUICK_REPLY" ? m.text : m.value,
3328
- urlType: t === "URL" ? m.urlType : void 0
3541
+ type: c,
3542
+ text: l.text,
3543
+ value: p,
3544
+ urlType: c === "URL" ? l.urlType : void 0
3329
3545
  };
3330
- n({
3546
+ s({
3331
3547
  ...a,
3332
- buttons: [...a.buttons, h]
3333
- }), y();
3334
- }, U = (t) => {
3335
- n({
3548
+ buttons: [...a.buttons, y]
3549
+ }), N();
3550
+ }, f = (c) => {
3551
+ s({
3336
3552
  ...a,
3337
- buttons: a.buttons.filter((h) => h.id !== t)
3553
+ buttons: a.buttons.filter((p) => p.id !== c)
3338
3554
  });
3339
- }, k = (t, h, v) => {
3340
- var R;
3341
- const V = h === "text" ? 25 : h === "value" && ((R = a.buttons.find((I) => I.id === t)) == null ? void 0 : R.type) === "URL" ? 2e3 : 20;
3342
- n({
3555
+ }, b = (c, p, y) => {
3556
+ const u = a.buttons.find((d) => d.id === c), V = p === "text" ? 25 : p === "value" && (u == null ? void 0 : u.type) === "URL" ? 2e3 : 20;
3557
+ let B = y.slice(0, V);
3558
+ p === "value" && (u == null ? void 0 : u.type) === "CALL" && B && !B.startsWith("+") && (B = "+" + B), s({
3343
3559
  ...a,
3344
3560
  buttons: a.buttons.map(
3345
- (I) => I.id === t ? { ...I, [h]: v.slice(0, V) } : I
3561
+ (d) => d.id === c ? { ...d, [p]: B } : d
3346
3562
  )
3347
3563
  });
3348
- }, N = () => {
3349
- const h = [
3350
- ...a.buttons.filter((V) => V.type === "URL" && V.urlType === "dynamic").map((V) => V.value || ""),
3351
- m.value
3564
+ }, M = () => {
3565
+ const p = [
3566
+ ...a.buttons.filter((u) => u.type === "URL" && u.urlType === "dynamic").map((u) => u.value || ""),
3567
+ l.value
3352
3568
  // Include current form input
3353
3569
  ].join(" ").match(/{{\d+}}/g);
3354
- if (!h) return 0;
3355
- const v = h.map((V) => {
3356
- const R = V.match(/{{(\d+)}}/);
3357
- return R ? parseInt(R[1], 10) : 0;
3570
+ if (!p) return 0;
3571
+ const y = p.map((u) => {
3572
+ const V = u.match(/{{(\d+)}}/);
3573
+ return V ? parseInt(V[1], 10) : 0;
3358
3574
  });
3359
- return v.length > 0 ? Math.max(...v) : 0;
3360
- }, o = [
3575
+ return y.length > 0 ? Math.max(...y) : 0;
3576
+ }, g = [
3361
3577
  {
3362
3578
  type: "QUICK_REPLY",
3363
- icon: le,
3579
+ icon: me,
3364
3580
  label: "Quick Reply",
3365
3581
  description: "Add quick response options",
3366
3582
  limit: 10,
3367
- current: f.quickReply,
3583
+ current: o.quickReply,
3368
3584
  color: "blue"
3369
3585
  },
3370
3586
  {
3371
3587
  type: "URL",
3372
- icon: Be,
3588
+ icon: He,
3373
3589
  label: "Web URL",
3374
3590
  description: "Link to websites or pages",
3375
3591
  limit: 2,
3376
- current: f.url,
3592
+ current: o.url,
3377
3593
  color: "green"
3378
3594
  },
3379
3595
  {
3380
3596
  type: "CALL",
3381
- icon: Me,
3597
+ icon: Ue,
3382
3598
  label: "Call Button",
3383
3599
  description: "Add phone number to call",
3384
3600
  limit: 1,
3385
- current: f.call,
3601
+ current: o.call,
3386
3602
  color: "purple"
3387
3603
  }
3388
3604
  // {
@@ -3407,47 +3623,47 @@ function na({ template: a, setTemplate: n }) {
3407
3623
  /* @__PURE__ */ e("div", { className: "rsp-flex-shrink-0", children: /* @__PURE__ */ e("svg", { className: "rsp-h-5 rsp-w-5 rsp-text-blue-400", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ e("path", { fillRule: "evenodd", d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z", clipRule: "evenodd" }) }) }),
3408
3624
  /* @__PURE__ */ e("div", { className: "rsp-ml-3", children: /* @__PURE__ */ e("p", { className: "rsp-text-sm rsp-text-blue-700", children: "We recommend adding the marketing opt-out button. This can help reduce blocks from customers and increase your quality rating." }) })
3409
3625
  ] }) }),
3410
- !i && /* @__PURE__ */ e("div", { className: "rsp-grid rsp-grid-cols-1 md:rsp-grid-cols-2 rsp-gap-4", children: o.map((t) => {
3411
- const h = t.icon, v = t.current >= t.limit;
3626
+ !i && /* @__PURE__ */ e("div", { className: "rsp-grid rsp-grid-cols-1 md:rsp-grid-cols-2 rsp-gap-4", children: g.map((c) => {
3627
+ const p = c.icon, y = c.current >= c.limit;
3412
3628
  return /* @__PURE__ */ e(
3413
3629
  "button",
3414
3630
  {
3415
- onClick: () => !v && l(t.type),
3416
- disabled: v,
3417
- className: `rsp-p-4 rsp-border-2 rsp-rounded-xl rsp-text-left rsp-transition-all rsp-duration-200 ${v ? "rsp-border-gray-200 rsp-bg-gray-50 rsp-text-gray-400 rsp-cursor-not-allowed rsp-opacity-60" : "rsp-cursor-pointer rsp-transform rsp-shadow-sm hover:rsp-shadow-md"}`,
3631
+ onClick: () => !y && n(c.type),
3632
+ disabled: y,
3633
+ className: `rsp-p-4 rsp-border-2 rsp-rounded-xl rsp-text-left rsp-transition-all rsp-duration-200 ${y ? "rsp-border-gray-200 rsp-bg-gray-50 rsp-text-gray-400 rsp-cursor-not-allowed rsp-opacity-60" : "rsp-cursor-pointer rsp-transform rsp-shadow-sm hover:rsp-shadow-md"}`,
3418
3634
  children: /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-start rsp-justify-between", children: [
3419
3635
  /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-3", children: [
3420
- /* @__PURE__ */ e("div", { className: `rsp-p-2 rsp-rounded-lg ${v ? "rsp-bg-gray-200" : "rsp-bg-white rsp-shadow-sm"}`, children: /* @__PURE__ */ e(h, { className: "rsp-w-5 rsp-h-5" }) }),
3636
+ /* @__PURE__ */ e("div", { className: `rsp-p-2 rsp-rounded-lg ${y ? "rsp-bg-gray-200" : "rsp-bg-white rsp-shadow-sm"}`, children: /* @__PURE__ */ e(p, { className: "rsp-w-5 rsp-h-5" }) }),
3421
3637
  /* @__PURE__ */ r("div", { children: [
3422
- /* @__PURE__ */ e("h4", { className: "rsp-font-semibold rsp-text-sm", children: t.label }),
3423
- /* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-opacity-80 rsp-mt-1", children: t.description })
3638
+ /* @__PURE__ */ e("h4", { className: "rsp-font-semibold rsp-text-sm", children: c.label }),
3639
+ /* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-opacity-80 rsp-mt-1", children: c.description })
3424
3640
  ] })
3425
3641
  ] }),
3426
3642
  /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-2", children: [
3427
3643
  /* @__PURE__ */ r("span", { className: "rsp-text-xs rsp-font-medium rsp-px-2 rsp-py-1 rsp-rounded-full rsp-bg-white rsp-bg-opacity-70", children: [
3428
- t.current,
3644
+ c.current,
3429
3645
  "/",
3430
- t.limit
3646
+ c.limit
3431
3647
  ] }),
3432
- !v && /* @__PURE__ */ e(de, { className: "rsp-w-4 rsp-h-4" })
3648
+ !y && /* @__PURE__ */ e(Ae, { className: "rsp-w-4 rsp-h-4" })
3433
3649
  ] })
3434
3650
  ] })
3435
3651
  },
3436
- t.type
3652
+ c.type
3437
3653
  );
3438
3654
  }) }),
3439
3655
  i && /* @__PURE__ */ r("div", { className: "rsp-bg-gradient-to-br rsp-from-gray-50 rsp-to-gray-100 rsp-border rsp-border-gray-200 rsp-rounded-xl rsp-p-6 rsp-shadow-sm", children: [
3440
3656
  /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-justify-between rsp-mb-4", children: [
3441
3657
  /* @__PURE__ */ r("h4", { className: "rsp-text-lg rsp-font-semibold rsp-text-gray-900", children: [
3442
3658
  "Add ",
3443
- (u = o.find((t) => t.type === i)) == null ? void 0 : u.label
3659
+ (v = g.find((c) => c.type === i)) == null ? void 0 : v.label
3444
3660
  ] }),
3445
3661
  /* @__PURE__ */ e(
3446
3662
  "button",
3447
3663
  {
3448
- onClick: y,
3664
+ onClick: N,
3449
3665
  className: "rsp-p-2 rsp-text-gray-400 hover:rsp-text-gray-600 hover:rsp-bg-white rsp-rounded-lg rsp-transition-colors",
3450
- children: /* @__PURE__ */ e(ee, { className: "rsp-w-5 rsp-h-5" })
3666
+ children: /* @__PURE__ */ e(re, { className: "rsp-w-5 rsp-h-5" })
3451
3667
  }
3452
3668
  )
3453
3669
  ] }),
@@ -3459,15 +3675,15 @@ function na({ template: a, setTemplate: n }) {
3459
3675
  "input",
3460
3676
  {
3461
3677
  type: "text",
3462
- value: m.text,
3463
- onChange: (t) => C({ ...m, text: t.target.value.slice(0, 25) }),
3678
+ value: l.text,
3679
+ onChange: (c) => k({ ...l, text: c.target.value.slice(0, 25) }),
3464
3680
  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",
3465
3681
  placeholder: "Enter button text (max 25 characters)",
3466
3682
  maxLength: 25
3467
3683
  }
3468
3684
  ),
3469
3685
  /* @__PURE__ */ r("span", { className: "rsp-absolute rsp-right-3 rsp-top-1/2 rsp-transform -rsp-translate-y-1/2 rsp-text-xs rsp-text-gray-400", children: [
3470
- m.text.length,
3686
+ l.text.length,
3471
3687
  "/25"
3472
3688
  ] })
3473
3689
  ] })
@@ -3481,8 +3697,8 @@ function na({ template: a, setTemplate: n }) {
3481
3697
  "input",
3482
3698
  {
3483
3699
  type: "radio",
3484
- checked: m.urlType === "static",
3485
- onChange: () => C({ ...m, urlType: "static" }),
3700
+ checked: l.urlType === "static",
3701
+ onChange: () => k({ ...l, urlType: "static" }),
3486
3702
  className: "rsp-mr-2 rsp-text-blue-600"
3487
3703
  }
3488
3704
  ),
@@ -3493,15 +3709,15 @@ function na({ template: a, setTemplate: n }) {
3493
3709
  "input",
3494
3710
  {
3495
3711
  type: "radio",
3496
- checked: m.urlType === "dynamic",
3497
- onChange: () => C({ ...m, urlType: "dynamic" }),
3712
+ checked: l.urlType === "dynamic",
3713
+ onChange: () => k({ ...l, urlType: "dynamic" }),
3498
3714
  className: "rsp-mr-2 rsp-text-blue-600"
3499
3715
  }
3500
3716
  ),
3501
3717
  /* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-text-gray-700", children: "Dynamic URL" })
3502
3718
  ] })
3503
3719
  ] }),
3504
- m.urlType === "dynamic" && /* @__PURE__ */ r("div", { className: "rsp-mt-3 rsp-p-3 rsp-bg-blue-50 rsp-rounded-lg rsp-border rsp-border-blue-200", children: [
3720
+ l.urlType === "dynamic" && /* @__PURE__ */ r("div", { className: "rsp-mt-3 rsp-p-3 rsp-bg-blue-50 rsp-rounded-lg rsp-border rsp-border-blue-200", children: [
3505
3721
  /* @__PURE__ */ e("h4", { className: "rsp-text-sm rsp-font-medium rsp-text-blue-800 rsp-mb-2", children: "Dynamic URL Guidelines:" }),
3506
3722
  /* @__PURE__ */ r("ul", { className: "rsp-text-xs rsp-text-blue-700 rsp-space-y-1", children: [
3507
3723
  /* @__PURE__ */ e("li", { children: "• Use placeholders like: https://example.com/order/{{1}}" }),
@@ -3516,73 +3732,73 @@ function na({ template: a, setTemplate: n }) {
3516
3732
  "input",
3517
3733
  {
3518
3734
  type: i === "CALL" ? "tel" : i === "URL" ? "url" : "text",
3519
- value: m.value,
3520
- onChange: (t) => {
3521
- const h = i === "URL" ? 2e3 : 20;
3522
- C({ ...m, value: t.target.value.slice(0, h) });
3735
+ value: l.value,
3736
+ onChange: (c) => {
3737
+ const p = i === "URL" ? 2e3 : 20;
3738
+ k({ ...l, value: c.target.value.slice(0, p) });
3523
3739
  },
3524
3740
  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",
3525
- placeholder: i === "URL" ? m.urlType === "dynamic" ? "https://example.com/order/{{1}}?user={{2}}" : "https://example.com" : i === "CALL" ? "+1234567890" : "Flow ID",
3741
+ placeholder: i === "URL" ? l.urlType === "dynamic" ? "https://example.com/order/{{1}}?user={{2}}" : "https://example.com" : i === "CALL" ? "+1234567890" : "Flow ID",
3526
3742
  maxLength: i === "URL" ? 2e3 : 20
3527
3743
  }
3528
3744
  ),
3529
3745
  /* @__PURE__ */ r("span", { className: "rsp-absolute rsp-right-3 rsp-top-1/2 rsp-transform -rsp-translate-y-1/2 rsp-text-xs rsp-text-gray-400", children: [
3530
- m.value.length,
3746
+ l.value.length,
3531
3747
  "/",
3532
3748
  i === "URL" ? 2e3 : 20
3533
3749
  ] })
3534
3750
  ] }),
3535
- i === "URL" && m.urlType === "dynamic" && /* @__PURE__ */ r("div", { className: "rsp-mt-3", children: [
3751
+ i === "URL" && l.urlType === "dynamic" && /* @__PURE__ */ r("div", { className: "rsp-mt-3", children: [
3536
3752
  /* @__PURE__ */ e("div", { className: "rsp-flex rsp-items-center rsp-gap-2 rsp-mb-2", children: /* @__PURE__ */ e(
3537
3753
  "button",
3538
3754
  {
3539
3755
  type: "button",
3540
3756
  onClick: () => {
3541
- if ((m.value.match(/\{\{(\d+)\}\}/g) || []).length >= 3) return;
3542
- const v = N() + 1, V = m.value + `{{${v}}}`;
3543
- C({ ...m, value: V }), p(!0);
3757
+ if ((l.value.match(/\{\{(\d+)\}\}/g) || []).length >= 3) return;
3758
+ const y = M() + 1, u = l.value + `{{${y}}}`;
3759
+ k({ ...l, value: u }), x(!0);
3544
3760
  },
3545
- disabled: (m.value.match(/\{\{(\d+)\}\}/g) || []).length >= 3,
3761
+ disabled: (l.value.match(/\{\{(\d+)\}\}/g) || []).length >= 3,
3546
3762
  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",
3547
3763
  children: "+ Add Variable"
3548
3764
  }
3549
3765
  ) }),
3550
- (m.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." }),
3551
- d && /* @__PURE__ */ r("div", { className: "rsp-mt-4 rsp-p-4 rsp-bg-gray-50 rsp-rounded-lg rsp-border", children: [
3766
+ (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." }),
3767
+ t && /* @__PURE__ */ r("div", { className: "rsp-mt-4 rsp-p-4 rsp-bg-gray-50 rsp-rounded-lg rsp-border", children: [
3552
3768
  /* @__PURE__ */ e("h4", { className: "rsp-text-sm rsp-font-medium rsp-text-gray-700 rsp-mb-3", children: "Sample Values for URL Variables" }),
3553
3769
  /* @__PURE__ */ e("div", { className: "rsp-space-y-3", children: (() => {
3554
- const t = m.value.match(/\{\{(\d+)\}\}/g) || [];
3555
- return [...new Set(t.map((v) => v.replace(/[{}]/g, "")))].map((v) => {
3556
- var V, R;
3770
+ const c = l.value.match(/\{\{(\d+)\}\}/g) || [];
3771
+ return [...new Set(c.map((y) => y.replace(/[{}]/g, "")))].map((y) => {
3772
+ var u, V;
3557
3773
  return /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-2", children: [
3558
3774
  /* @__PURE__ */ r("label", { className: "rsp-text-sm rsp-text-gray-600 rsp-whitespace-nowrap", children: [
3559
3775
  "Variable {{",
3560
- v,
3776
+ y,
3561
3777
  "}}"
3562
3778
  ] }),
3563
3779
  /* @__PURE__ */ e(
3564
3780
  "input",
3565
3781
  {
3566
3782
  type: "text",
3567
- value: ((R = (V = a.sampleContent) == null ? void 0 : V.buttonVariables) == null ? void 0 : R[v]) || "",
3568
- onChange: (I) => {
3569
- var w, L, s;
3570
- const x = {
3783
+ value: ((V = (u = a.sampleContent) == null ? void 0 : u.buttonVariables) == null ? void 0 : V[y]) || "",
3784
+ onChange: (B) => {
3785
+ var E, A, O;
3786
+ const d = {
3571
3787
  ...a.sampleContent,
3572
- headerVariables: ((w = a.sampleContent) == null ? void 0 : w.headerVariables) || {},
3573
- bodyVariables: ((L = a.sampleContent) == null ? void 0 : L.bodyVariables) || {},
3788
+ headerVariables: ((E = a.sampleContent) == null ? void 0 : E.headerVariables) || {},
3789
+ bodyVariables: ((A = a.sampleContent) == null ? void 0 : A.bodyVariables) || {},
3574
3790
  buttonVariables: {
3575
- ...(s = a.sampleContent) == null ? void 0 : s.buttonVariables,
3576
- [v]: I.target.value
3791
+ ...(O = a.sampleContent) == null ? void 0 : O.buttonVariables,
3792
+ [y]: B.target.value
3577
3793
  }
3578
3794
  };
3579
- n({
3795
+ s({
3580
3796
  ...a,
3581
- sampleContent: x
3797
+ sampleContent: d
3582
3798
  });
3583
3799
  },
3584
3800
  className: "rsp-flex-1 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",
3585
- placeholder: `Sample value (e.g., ${v === "1" ? "order123" : "user456"})`
3801
+ placeholder: `Sample value (e.g., ${y === "1" ? "order123" : "user456"})`
3586
3802
  }
3587
3803
  ),
3588
3804
  /* @__PURE__ */ e(
@@ -3590,17 +3806,17 @@ function na({ template: a, setTemplate: n }) {
3590
3806
  {
3591
3807
  type: "button",
3592
3808
  onClick: () => {
3593
- var L, s, b;
3594
- const I = new RegExp(`\\{\\{${v}\\}\\}`, "g"), x = (m.value || "").replace(I, "");
3595
- C({ ...m, value: x });
3596
- const w = Object.fromEntries(Object.entries(((L = a.sampleContent) == null ? void 0 : L.buttonVariables) || {}).filter(([E]) => E !== v));
3597
- n({
3809
+ var A, O, R;
3810
+ const B = new RegExp(`\\{\\{${y}\\}\\}`, "g"), d = (l.value || "").replace(B, "");
3811
+ k({ ...l, value: d });
3812
+ const E = Object.fromEntries(Object.entries(((A = a.sampleContent) == null ? void 0 : A.buttonVariables) || {}).filter(([_]) => _ !== y));
3813
+ s({
3598
3814
  ...a,
3599
3815
  sampleContent: {
3600
3816
  ...a.sampleContent,
3601
- headerVariables: ((s = a.sampleContent) == null ? void 0 : s.headerVariables) || {},
3602
- bodyVariables: ((b = a.sampleContent) == null ? void 0 : b.bodyVariables) || {},
3603
- buttonVariables: w
3817
+ headerVariables: ((O = a.sampleContent) == null ? void 0 : O.headerVariables) || {},
3818
+ bodyVariables: ((R = a.sampleContent) == null ? void 0 : R.bodyVariables) || {},
3819
+ buttonVariables: E
3604
3820
  }
3605
3821
  });
3606
3822
  },
@@ -3609,16 +3825,16 @@ function na({ template: a, setTemplate: n }) {
3609
3825
  children: "×"
3610
3826
  }
3611
3827
  )
3612
- ] }, `sample-${v}`);
3828
+ ] }, `sample-${y}`);
3613
3829
  });
3614
3830
  })() }),
3615
3831
  /* @__PURE__ */ r("div", { className: "rsp-mt-4 rsp-p-3 rsp-bg-white rsp-rounded-lg rsp-border", children: [
3616
3832
  /* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-font-medium rsp-text-gray-700 rsp-mb-1", children: "Preview URL:" }),
3617
- /* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-gray-600 rsp-font-mono rsp-break-all", children: m.value.replace(
3833
+ /* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-gray-600 rsp-font-mono rsp-break-all", children: l.value.replace(
3618
3834
  /\{\{(\d+)\}\}/g,
3619
- (t, h) => {
3620
- var v, V;
3621
- return ((V = (v = a.sampleContent) == null ? void 0 : v.buttonVariables) == null ? void 0 : V[h]) || `[${t}]`;
3835
+ (c, p) => {
3836
+ var y, u;
3837
+ return ((u = (y = a.sampleContent) == null ? void 0 : y.buttonVariables) == null ? void 0 : u[p]) || `[${c}]`;
3622
3838
  }
3623
3839
  ) })
3624
3840
  ] }),
@@ -3626,7 +3842,7 @@ function na({ template: a, setTemplate: n }) {
3626
3842
  "button",
3627
3843
  {
3628
3844
  type: "button",
3629
- onClick: () => p(!1),
3845
+ onClick: () => x(!1),
3630
3846
  className: "rsp-px-3 rsp-py-1 rsp-text-xs rsp-text-gray-500 hover:rsp-text-gray-700",
3631
3847
  children: "Close"
3632
3848
  }
@@ -3638,8 +3854,8 @@ function na({ template: a, setTemplate: n }) {
3638
3854
  /* @__PURE__ */ e(
3639
3855
  "button",
3640
3856
  {
3641
- onClick: () => j(i),
3642
- disabled: !m.text.trim() || i !== "QUICK_REPLY" && !m.value.trim(),
3857
+ onClick: () => U(i),
3858
+ disabled: !l.text.trim() || i !== "QUICK_REPLY" && !l.value.trim(),
3643
3859
  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",
3644
3860
  children: "Add Button"
3645
3861
  }
@@ -3647,7 +3863,7 @@ function na({ template: a, setTemplate: n }) {
3647
3863
  /* @__PURE__ */ e(
3648
3864
  "button",
3649
3865
  {
3650
- onClick: y,
3866
+ onClick: N,
3651
3867
  className: "rsp-px-4 rsp-py-3 rsp-text-gray-600 rsp-bg-white rsp-border rsp-border-gray-300 rsp-rounded-lg rsp-font-medium rsp-text-sm rsp-transition-colors hover:rsp-bg-gray-50 rsp-shadow-sm",
3652
3868
  children: "Cancel"
3653
3869
  }
@@ -3657,19 +3873,19 @@ function na({ template: a, setTemplate: n }) {
3657
3873
  ] }),
3658
3874
  a.buttons.length > 0 && /* @__PURE__ */ r("div", { className: "rsp-space-y-4", children: [
3659
3875
  /* @__PURE__ */ e("h4", { className: "rsp-text-md rsp-font-semibold rsp-text-gray-900", children: "Added Buttons" }),
3660
- /* @__PURE__ */ e("div", { className: "rsp-space-y-3", children: a.buttons.map((t) => {
3661
- const h = o.find((V) => V.type === t.type), v = (h == null ? void 0 : h.icon) || le;
3876
+ /* @__PURE__ */ e("div", { className: "rsp-space-y-3", children: a.buttons.map((c) => {
3877
+ const p = g.find((u) => u.type === c.type), y = (p == null ? void 0 : p.icon) || me;
3662
3878
  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: [
3663
- /* @__PURE__ */ e("div", { className: "rsp-p-2 rsp-bg-gray-50 rsp-rounded-lg", children: /* @__PURE__ */ e(v, { className: "rsp-w-4 rsp-h-4 rsp-text-gray-600" }) }),
3879
+ /* @__PURE__ */ e("div", { className: "rsp-p-2 rsp-bg-gray-50 rsp-rounded-lg", children: /* @__PURE__ */ e(y, { className: "rsp-w-4 rsp-h-4 rsp-text-gray-600" }) }),
3664
3880
  /* @__PURE__ */ r("div", { className: "rsp-flex-1 rsp-space-y-3", children: [
3665
3881
  /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-justify-between", children: [
3666
- /* @__PURE__ */ e("span", { className: "rsp-text-xs rsp-font-medium rsp-text-gray-500 rsp-uppercase rsp-tracking-wider", children: t.type.replace("_", " ") }),
3882
+ /* @__PURE__ */ e("span", { className: "rsp-text-xs rsp-font-medium rsp-text-gray-500 rsp-uppercase rsp-tracking-wider", children: c.type.replace("_", " ") }),
3667
3883
  /* @__PURE__ */ e(
3668
3884
  "button",
3669
3885
  {
3670
- onClick: () => U(t.id),
3886
+ onClick: () => f(c.id),
3671
3887
  className: "rsp-p-1 rsp-text-red-400 hover:rsp-text-red-600 hover:rsp-bg-red-50 rsp-rounded rsp-transition-colors",
3672
- children: /* @__PURE__ */ e(ee, { className: "rsp-w-4 rsp-h-4" })
3888
+ children: /* @__PURE__ */ e(re, { className: "rsp-w-4 rsp-h-4" })
3673
3889
  }
3674
3890
  )
3675
3891
  ] }),
@@ -3681,103 +3897,103 @@ function na({ template: a, setTemplate: n }) {
3681
3897
  "input",
3682
3898
  {
3683
3899
  type: "text",
3684
- value: t.text,
3685
- onChange: (V) => k(t.id, "text", V.target.value),
3900
+ value: c.text,
3901
+ onChange: (u) => b(c.id, "text", u.target.value),
3686
3902
  maxLength: 25,
3687
3903
  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"
3688
3904
  }
3689
3905
  ),
3690
3906
  /* @__PURE__ */ r("span", { className: "rsp-absolute rsp-right-2 rsp-top-1/2 rsp-transform -rsp-translate-y-1/2 rsp-text-xs rsp-text-gray-400", children: [
3691
- t.text.length,
3907
+ c.text.length,
3692
3908
  "/25"
3693
3909
  ] })
3694
3910
  ] })
3695
3911
  ] }),
3696
- t.type !== "QUICK_REPLY" && /* @__PURE__ */ r("div", { children: [
3697
- /* @__PURE__ */ e("label", { className: "rsp-block rsp-text-xs rsp-font-medium rsp-text-gray-600 rsp-mb-1", children: t.type === "URL" ? "Website URL" : t.type === "CALL" ? "Phone Number" : "Flow ID" }),
3912
+ c.type !== "QUICK_REPLY" && /* @__PURE__ */ r("div", { children: [
3913
+ /* @__PURE__ */ e("label", { className: "rsp-block rsp-text-xs rsp-font-medium rsp-text-gray-600 rsp-mb-1", children: c.type === "URL" ? "Website URL" : c.type === "CALL" ? "Phone Number" : "Flow ID" }),
3698
3914
  /* @__PURE__ */ r("div", { className: "rsp-relative", children: [
3699
3915
  /* @__PURE__ */ e(
3700
3916
  "input",
3701
3917
  {
3702
- type: t.type === "CALL" ? "tel" : t.type === "URL" ? "url" : "text",
3703
- value: t.value || "",
3704
- onChange: (V) => k(t.id, "value", V.target.value),
3705
- maxLength: t.type === "URL" ? 2e3 : 20,
3918
+ type: c.type === "CALL" ? "tel" : c.type === "URL" ? "url" : "text",
3919
+ value: c.value || "",
3920
+ onChange: (u) => b(c.id, "value", u.target.value),
3921
+ maxLength: c.type === "URL" ? 2e3 : 20,
3706
3922
  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"
3707
3923
  }
3708
3924
  ),
3709
3925
  /* @__PURE__ */ r("span", { className: "rsp-absolute rsp-right-2 rsp-top-1/2 rsp-transform -rsp-translate-y-1/2 rsp-text-xs rsp-text-gray-400", children: [
3710
- (t.value || "").length,
3926
+ (c.value || "").length,
3711
3927
  "/",
3712
- t.type === "URL" ? 2e3 : 20
3928
+ c.type === "URL" ? 2e3 : 20
3713
3929
  ] })
3714
3930
  ] })
3715
3931
  ] })
3716
3932
  ] })
3717
3933
  ] })
3718
- ] }) }, t.id);
3934
+ ] }) }, c.id);
3719
3935
  }) })
3720
3936
  ] }),
3721
3937
  a.buttons.length === 0 && !i && /* @__PURE__ */ r("div", { className: "rsp-text-center rsp-py-12 rsp-bg-gray-50 rsp-rounded-xl rsp-border-2 rsp-border-dashed rsp-border-gray-300", children: [
3722
- /* @__PURE__ */ e("div", { className: "rsp-w-16 rsp-h-16 rsp-bg-white rsp-rounded-full rsp-flex rsp-items-center rsp-justify-center rsp-mx-auto rsp-mb-4 rsp-shadow-sm", children: /* @__PURE__ */ e(le, { className: "rsp-w-8 rsp-h-8 rsp-text-gray-400" }) }),
3938
+ /* @__PURE__ */ e("div", { className: "rsp-w-16 rsp-h-16 rsp-bg-white rsp-rounded-full rsp-flex rsp-items-center rsp-justify-center rsp-mx-auto rsp-mb-4 rsp-shadow-sm", children: /* @__PURE__ */ e(me, { className: "rsp-w-8 rsp-h-8 rsp-text-gray-400" }) }),
3723
3939
  /* @__PURE__ */ e("h3", { className: "rsp-text-lg rsp-font-medium rsp-text-gray-900 rsp-mb-2", children: "No buttons added yet" }),
3724
3940
  /* @__PURE__ */ e("p", { className: "rsp-text-gray-500 rsp-text-sm rsp-mb-4", children: "Add interactive buttons to make your message more engaging" }),
3725
3941
  /* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-gray-400", children: "Choose from Quick Reply, Web URL, Call, or Flow buttons above" })
3726
3942
  ] })
3727
3943
  ] });
3728
3944
  }
3729
- const la = async (a) => {
3945
+ const ba = async (a) => {
3730
3946
  try {
3731
3947
  if (!a)
3732
3948
  throw new Error("No file provided");
3733
- const n = 100 * 1024 * 1024;
3734
- if (a.size > n)
3735
- throw new Error(`File size too large. Maximum allowed size is ${n / (1024 * 1024)}MB`);
3949
+ const s = 100 * 1024 * 1024;
3950
+ if (a.size > s)
3951
+ throw new Error(`File size too large. Maximum allowed size is ${s / (1024 * 1024)}MB`);
3736
3952
  const i = new FormData();
3737
3953
  i.append("file", a), console.log("Uploading file:", a.name, "Size:", a.size, "Type:", a.type);
3738
- const l = await fetch("https://wiz.resul.io/Communication/UploadDocuments", {
3954
+ const n = await fetch("https://wiz.resul.io/Communication/UploadDocuments", {
3739
3955
  method: "POST",
3740
3956
  body: i
3741
3957
  });
3742
- console.log("Upload response status:", l.status), console.log("Upload response headers:", Object.fromEntries(l.headers.entries()));
3743
- const d = await l.text();
3744
- console.log("Raw upload response:", d);
3745
- let p;
3958
+ console.log("Upload response status:", n.status), console.log("Upload response headers:", Object.fromEntries(n.headers.entries()));
3959
+ const t = await n.text();
3960
+ console.log("Raw upload response:", t);
3961
+ let x;
3746
3962
  try {
3747
- p = JSON.parse(d);
3748
- } catch (m) {
3749
- throw console.error("Failed to parse upload response:", m), new Error("Invalid response from upload server");
3963
+ x = JSON.parse(t);
3964
+ } catch (l) {
3965
+ throw console.error("Failed to parse upload response:", l), new Error("Invalid response from upload server");
3750
3966
  }
3751
- if (console.log("Parsed upload response:", p), console.log("Upload status:", p.status), console.log("Upload message:", p.message), console.log("Upload data:", p.data), !p.status)
3752
- throw new Error(p.message || "Upload failed");
3753
- if (p.data && Array.isArray(p.data) && p.data.length > 0) {
3754
- const m = p.data[0];
3755
- if (m.url)
3967
+ if (console.log("Parsed upload response:", x), console.log("Upload status:", x.status), console.log("Upload message:", x.message), console.log("Upload data:", x.data), !x.status)
3968
+ throw new Error(x.message || "Upload failed");
3969
+ if (x.data && Array.isArray(x.data) && x.data.length > 0) {
3970
+ const l = x.data[0];
3971
+ if (l.url)
3756
3972
  return console.log("File uploaded successfully:", {
3757
- url: m.url,
3758
- filename: m.filename,
3759
- originalName: m.originalName,
3760
- size: m.size
3761
- }), m.url;
3973
+ url: l.url,
3974
+ filename: l.filename,
3975
+ originalName: l.originalName,
3976
+ size: l.size
3977
+ }), l.url;
3762
3978
  throw new Error("No file URL in upload response data");
3763
3979
  } else
3764
3980
  throw new Error("No files in upload response data");
3765
- } catch (n) {
3766
- throw console.error("File upload error:", n), n instanceof Error ? n : new Error("Unknown error occurred during file upload");
3981
+ } catch (s) {
3982
+ throw console.error("File upload error:", s), s instanceof Error ? s : new Error("Unknown error occurred during file upload");
3767
3983
  }
3768
- }, ia = (a, n) => {
3769
- const l = a.name.toLowerCase().split(".").pop();
3770
- switch (n) {
3984
+ }, ga = (a, s) => {
3985
+ const n = a.name.toLowerCase().split(".").pop();
3986
+ switch (s) {
3771
3987
  case "IMAGE":
3772
- return ["jpg", "jpeg", "png", "gif", "bmp", "tiff", "svg"].includes(l || "");
3988
+ return ["jpg", "jpeg", "png", "gif", "bmp", "tiff", "svg"].includes(n || "");
3773
3989
  case "VIDEO":
3774
- return ["mp4", "mov", "avi", "3gpp"].includes(l || "");
3990
+ return ["mp4", "mov", "avi", "3gpp"].includes(n || "");
3775
3991
  case "DOCUMENT":
3776
- return ["pdf", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "txt"].includes(l || "");
3992
+ return ["pdf", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "txt"].includes(n || "");
3777
3993
  default:
3778
3994
  return !1;
3779
3995
  }
3780
- }, ta = (a) => {
3996
+ }, ya = (a) => {
3781
3997
  switch (a) {
3782
3998
  case "IMAGE":
3783
3999
  return 5 * 1024 * 1024;
@@ -3789,138 +4005,161 @@ const la = async (a) => {
3789
4005
  return 10 * 1024 * 1024;
3790
4006
  }
3791
4007
  };
3792
- function ma({ template: a, setTemplate: n, onFileUpload: i }) {
3793
- var R, I, x, w, L;
3794
- const [l, d] = K.useState({}), [, p] = K.useState({}), [m, C] = K.useState(!1), [g, f] = K.useState(null), y = K.useRef({}), j = () => {
3795
- var b;
3796
- const s = {
4008
+ function wa({ template: a, setTemplate: s, onFileUpload: i }) {
4009
+ var E, A, O, R, _;
4010
+ const [n, t] = J.useState({}), [, x] = J.useState({}), [l, k] = J.useState({ open: !1, message: "" }), [w, o] = J.useState(!1), [N, U] = J.useState(null), f = J.useRef({}), b = () => {
4011
+ var C;
4012
+ const m = {
3797
4013
  id: Math.random().toString(36).substr(2, 9),
3798
4014
  headerType: "MEDIA",
3799
- mediaType: ((b = a.carousel) == null ? void 0 : b.type) === "VIDEO" ? "VIDEO" : "IMAGE",
4015
+ mediaType: ((C = a.carousel) == null ? void 0 : C.type) === "VIDEO" ? "VIDEO" : "IMAGE",
3800
4016
  body: "",
3801
4017
  buttons: []
3802
4018
  };
3803
- n((E) => {
3804
- var T, c;
4019
+ s((S) => {
4020
+ var j, I;
3805
4021
  return {
3806
- ...E,
4022
+ ...S,
3807
4023
  carousel: {
3808
- type: ((T = a.carousel) == null ? void 0 : T.type) || "IMAGE",
3809
- cards: [...((c = a.carousel) == null ? void 0 : c.cards) || [], s]
4024
+ type: ((j = a.carousel) == null ? void 0 : j.type) || "IMAGE",
4025
+ cards: [...((I = a.carousel) == null ? void 0 : I.cards) || [], m]
3810
4026
  }
3811
4027
  };
3812
4028
  });
3813
- }, U = (s) => {
3814
- n((b) => ({
3815
- ...b,
4029
+ }, M = (m) => {
4030
+ s((C) => ({
4031
+ ...C,
3816
4032
  carousel: {
3817
- ...b.carousel,
3818
- cards: b.carousel.cards.filter((E) => E.id !== s)
4033
+ ...C.carousel,
4034
+ cards: C.carousel.cards.filter((S) => S.id !== m)
3819
4035
  }
3820
4036
  }));
3821
- }, k = (s, b, E) => {
3822
- n((T) => ({
3823
- ...T,
4037
+ }, g = (m, C, S) => {
4038
+ s((j) => ({
4039
+ ...j,
3824
4040
  carousel: {
3825
- ...T.carousel,
3826
- cards: T.carousel.cards.map(
3827
- (c) => c.id === s ? { ...c, [b]: E } : c
4041
+ ...j.carousel,
4042
+ cards: j.carousel.cards.map(
4043
+ (I) => I.id === m ? { ...I, [C]: S } : I
3828
4044
  )
3829
4045
  }
3830
4046
  }));
3831
- }, N = (s, b) => {
3832
- var $;
3833
- const E = ($ = a.carousel) == null ? void 0 : $.cards.find((X) => X.id === s);
3834
- if (!E) return;
3835
- const M = `{{${u(s) + 1}}}`, O = E[b] + M;
3836
- k(s, b, O);
3837
- }, o = (s) => {
3838
- var O;
3839
- if (!g) return;
3840
- const b = y.current[g], E = (O = a.carousel) == null ? void 0 : O.cards.find(($) => $.id === g);
3841
- if (!E) return;
3842
- const T = b && typeof b.selectionStart == "number" ? b.selectionStart : E.body.length, c = E.body.substring(0, T), M = E.body.substring(T), A = c + s + M;
3843
- k(g, "body", A), setTimeout(() => {
3844
- const $ = y.current[g];
3845
- if ($) {
3846
- const X = T + s.length;
3847
- $.setSelectionRange(X, X), $.focus();
4047
+ }, v = (m) => {
4048
+ s((C) => {
4049
+ const j = ((C.carousel || { type: m, cards: [] }).cards || []).map((I) => ({
4050
+ ...I,
4051
+ mediaType: m,
4052
+ mediaUrl: ""
4053
+ }));
4054
+ return {
4055
+ ...C,
4056
+ carousel: {
4057
+ type: m,
4058
+ cards: j
4059
+ }
4060
+ };
4061
+ });
4062
+ }, c = (m, C) => {
4063
+ var q;
4064
+ const S = (q = a.carousel) == null ? void 0 : q.cards.find((X) => X.id === m);
4065
+ if (!S) return;
4066
+ const h = `{{${y(m) + 1}}}`, z = S[C] + h;
4067
+ g(m, C, z);
4068
+ }, p = (m) => {
4069
+ var z;
4070
+ if (!N) return;
4071
+ const C = f.current[N], S = (z = a.carousel) == null ? void 0 : z.cards.find((q) => q.id === N);
4072
+ if (!S) return;
4073
+ const j = C && typeof C.selectionStart == "number" ? C.selectionStart : S.body.length, I = S.body.substring(0, j), h = S.body.substring(j), L = I + m + h;
4074
+ g(N, "body", L), setTimeout(() => {
4075
+ const q = f.current[N];
4076
+ if (q) {
4077
+ const X = j + m.length;
4078
+ q.setSelectionRange(X, X), q.focus();
3848
4079
  }
3849
- }, 0), C(!1);
3850
- }, u = (s) => {
3851
- var M;
3852
- const b = (M = a.carousel) == null ? void 0 : M.cards.find((A) => A.id === s);
3853
- if (!b) return 0;
3854
- const T = (b.body || "").match(/\{\{(\d+)\}\}/g);
3855
- if (!T) return 0;
3856
- const c = T.map((A) => {
3857
- const O = A.match(/{{(\d+)}}/);
3858
- return O ? parseInt(O[1], 10) : 0;
4080
+ }, 0), o(!1);
4081
+ }, y = (m) => {
4082
+ var h;
4083
+ const C = (h = a.carousel) == null ? void 0 : h.cards.find((L) => L.id === m);
4084
+ if (!C) return 0;
4085
+ const j = (C.body || "").match(/\{\{(\d+)\}\}/g);
4086
+ if (!j) return 0;
4087
+ const I = j.map((L) => {
4088
+ const z = L.match(/{{(\d+)}}/);
4089
+ return z ? parseInt(z[1], 10) : 0;
3859
4090
  });
3860
- return c.length > 0 ? Math.max(...c) : 0;
3861
- }, t = (s, b) => {
3862
- var c;
3863
- const E = (c = a.carousel) == null ? void 0 : c.cards.find((M) => M.id === s);
3864
- if (!E || E.buttons.length >= 2) return;
3865
- const T = {
4091
+ return I.length > 0 ? Math.max(...I) : 0;
4092
+ }, u = (m, C) => {
4093
+ var I;
4094
+ const S = (I = a.carousel) == null ? void 0 : I.cards.find((h) => h.id === m);
4095
+ if (!S || S.buttons.length >= 2) return;
4096
+ const j = {
3866
4097
  id: Math.random().toString(36).substr(2, 9),
3867
- type: b,
4098
+ type: C,
3868
4099
  text: "",
3869
4100
  value: "",
3870
4101
  urlType: "static"
3871
4102
  };
3872
- k(s, "buttons", [...E.buttons, T]);
3873
- }, h = (s, b, E, T) => {
3874
- var A;
3875
- const c = (A = a.carousel) == null ? void 0 : A.cards.find((O) => O.id === s);
3876
- if (!c) return;
3877
- const M = c.buttons.map(
3878
- (O) => O.id === b ? { ...O, [E]: T } : O
4103
+ g(m, "buttons", [...S.buttons, j]);
4104
+ }, V = (m, C, S, j) => {
4105
+ var L;
4106
+ const I = (L = a.carousel) == null ? void 0 : L.cards.find((z) => z.id === m);
4107
+ if (!I) return;
4108
+ const h = I.buttons.map(
4109
+ (z) => z.id === C ? { ...z, [S]: j } : z
3879
4110
  );
3880
- k(s, "buttons", M);
3881
- }, v = (s, b) => {
3882
- var c;
3883
- const E = (c = a.carousel) == null ? void 0 : c.cards.find((M) => M.id === s);
3884
- if (!E) return;
3885
- const T = E.buttons.filter((M) => M.id !== b);
3886
- k(s, "buttons", T);
3887
- }, V = async (s, b) => {
3888
- var E;
4111
+ g(m, "buttons", h);
4112
+ }, B = (m, C) => {
4113
+ var I;
4114
+ const S = (I = a.carousel) == null ? void 0 : I.cards.find((h) => h.id === m);
4115
+ if (!S) return;
4116
+ const j = S.buttons.filter((h) => h.id !== C);
4117
+ g(m, "buttons", j);
4118
+ }, d = async (m, C) => {
4119
+ var S;
3889
4120
  try {
3890
- d((A) => ({ ...A, [s]: !0 })), p((A) => ({ ...A, [s]: !1 }));
3891
- const T = ((E = a.carousel) == null ? void 0 : E.type) === "VIDEO" ? "VIDEO" : "IMAGE";
3892
- if (!ia(b, T))
3893
- throw new Error(`Invalid file type. Expected ${T.toLowerCase()} file.`);
3894
- const c = ta(T);
3895
- if (b.size > c) {
3896
- const A = c / 1048576;
3897
- throw new Error(`File size too large. Maximum allowed size is ${A}MB.`);
4121
+ t((L) => ({ ...L, [m]: !0 })), x((L) => ({ ...L, [m]: !1 }));
4122
+ const j = ((S = a.carousel) == null ? void 0 : S.type) === "VIDEO" ? "VIDEO" : "IMAGE";
4123
+ if (!ga(C, j))
4124
+ throw new Error(`Invalid file type. Expected ${j.toLowerCase()} file.`);
4125
+ const I = ya(j);
4126
+ if (C.size > I) {
4127
+ const L = I / 1048576;
4128
+ throw new Error(`File size too large. Maximum allowed size is ${L}MB.`);
3898
4129
  }
3899
- const M = await i(b);
3900
- k(s, "mediaUrl", M);
3901
- } catch (T) {
3902
- console.error("File upload failed:", T), alert(T instanceof Error ? T.message : "File upload failed");
4130
+ const h = await i(C);
4131
+ g(m, "mediaUrl", h);
4132
+ } catch (j) {
4133
+ console.error("File upload failed:", j), k({ open: !0, message: j instanceof Error ? j.message : "File upload failed" });
3903
4134
  } finally {
3904
- d((T) => ({ ...T, [s]: !1 }));
4135
+ t((j) => ({ ...j, [m]: !1 }));
3905
4136
  }
3906
4137
  };
3907
4138
  return /* @__PURE__ */ r("div", { className: "rsp-space-y-6", children: [
4139
+ l.open && /* @__PURE__ */ r("div", { className: "rsp-fixed rsp-inset-0 rsp-z-50 rsp-flex rsp-items-center rsp-justify-center", children: [
4140
+ /* @__PURE__ */ e("div", { className: "rsp-absolute rsp-inset-0 rsp-bg-black rsp-bg-opacity-40", onClick: () => k({ open: !1, message: "" }) }),
4141
+ /* @__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: [
4142
+ /* @__PURE__ */ e("div", { className: "rsp-mb-3 rsp-text-lg rsp-font-semibold rsp-text-gray-900", children: "Upload Error" }),
4143
+ /* @__PURE__ */ e("div", { className: "rsp-text-sm rsp-text-gray-700 rsp-break-words rsp-whitespace-pre-wrap", children: l.message }),
4144
+ /* @__PURE__ */ e("div", { className: "rsp-flex rsp-justify-end rsp-mt-4", children: /* @__PURE__ */ e("button", { onClick: () => k({ 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" }) })
4145
+ ] })
4146
+ ] }),
3908
4147
  /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-justify-between", children: [
3909
4148
  /* @__PURE__ */ e("h3", { className: "rsp-text-lg rsp-font-semibold rsp-text-gray-900", children: "Carousel Cards" }),
3910
4149
  /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-4", children: [
3911
4150
  /* @__PURE__ */ r("span", { className: "rsp-text-sm rsp-text-gray-500", children: [
3912
4151
  "Total Cards: ",
3913
- ((R = a.carousel) == null ? void 0 : R.cards.length) || 0,
4152
+ ((E = a.carousel) == null ? void 0 : E.cards.length) || 0,
3914
4153
  "/10"
3915
4154
  ] }),
3916
4155
  /* @__PURE__ */ r(
3917
4156
  "button",
3918
4157
  {
3919
- onClick: j,
3920
- disabled: (((I = a.carousel) == null ? void 0 : I.cards.length) || 0) >= 10,
4158
+ onClick: b,
4159
+ disabled: (((A = a.carousel) == null ? void 0 : A.cards.length) || 0) >= 10,
3921
4160
  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",
3922
4161
  children: [
3923
- /* @__PURE__ */ e(de, { className: "rsp-w-4 rsp-h-4 rsp-inline rsp-mr-2" }),
4162
+ /* @__PURE__ */ e(Ae, { className: "rsp-w-4 rsp-h-4 rsp-inline rsp-mr-2" }),
3924
4163
  "Add Card"
3925
4164
  ]
3926
4165
  }
@@ -3937,17 +4176,8 @@ function ma({ template: a, setTemplate: n, onFileUpload: i }) {
3937
4176
  type: "radio",
3938
4177
  name: "carouselType",
3939
4178
  value: "IMAGE",
3940
- checked: ((x = a.carousel) == null ? void 0 : x.type) === "IMAGE",
3941
- onChange: (s) => n((b) => {
3942
- var E;
3943
- return {
3944
- ...b,
3945
- carousel: {
3946
- type: s.target.value,
3947
- cards: ((E = b.carousel) == null ? void 0 : E.cards) || []
3948
- }
3949
- };
3950
- }),
4179
+ checked: ((O = a.carousel) == null ? void 0 : O.type) === "IMAGE",
4180
+ onChange: (m) => v(m.target.value),
3951
4181
  className: "rsp-mr-2"
3952
4182
  }
3953
4183
  ),
@@ -3960,17 +4190,8 @@ function ma({ template: a, setTemplate: n, onFileUpload: i }) {
3960
4190
  type: "radio",
3961
4191
  name: "carouselType",
3962
4192
  value: "VIDEO",
3963
- checked: ((w = a.carousel) == null ? void 0 : w.type) === "VIDEO",
3964
- onChange: (s) => n((b) => {
3965
- var E;
3966
- return {
3967
- ...b,
3968
- carousel: {
3969
- type: s.target.value,
3970
- cards: ((E = b.carousel) == null ? void 0 : E.cards) || []
3971
- }
3972
- };
3973
- }),
4193
+ checked: ((R = a.carousel) == null ? void 0 : R.type) === "VIDEO",
4194
+ onChange: (m) => v(m.target.value),
3974
4195
  className: "rsp-mr-2"
3975
4196
  }
3976
4197
  ),
@@ -3978,98 +4199,98 @@ function ma({ template: a, setTemplate: n, onFileUpload: i }) {
3978
4199
  ] })
3979
4200
  ] })
3980
4201
  ] }),
3981
- /* @__PURE__ */ e("div", { className: "rsp-space-y-6", children: (L = a.carousel) == null ? void 0 : L.cards.map((s, b) => {
3982
- var E, T, c, M, A, O, $, X;
4202
+ /* @__PURE__ */ e("div", { className: "rsp-space-y-6", children: (_ = a.carousel) == null ? void 0 : _.cards.map((m, C) => {
4203
+ var S, j, I, h, L, z, q, X;
3983
4204
  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: [
3984
4205
  /* @__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: [
3985
4206
  /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-3", children: [
3986
- /* @__PURE__ */ e("div", { className: "rsp-w-8 rsp-h-8 rsp-bg-blue-500 rsp-text-white rsp-rounded-full rsp-flex rsp-items-center rsp-justify-center rsp-font-bold rsp-text-sm rsp-shadow-md", children: b + 1 }),
4207
+ /* @__PURE__ */ e("div", { className: "rsp-w-8 rsp-h-8 rsp-bg-blue-500 rsp-text-white rsp-rounded-full rsp-flex rsp-items-center rsp-justify-center rsp-font-bold rsp-text-sm rsp-shadow-md", children: C + 1 }),
3987
4208
  /* @__PURE__ */ r("h4", { className: "rsp-text-base rsp-font-semibold rsp-text-gray-800", children: [
3988
4209
  "Card ",
3989
- b + 1
4210
+ C + 1
3990
4211
  ] })
3991
4212
  ] }),
3992
4213
  /* @__PURE__ */ e(
3993
4214
  "button",
3994
4215
  {
3995
- onClick: () => U(s.id),
4216
+ onClick: () => M(m.id),
3996
4217
  className: "rsp-p-1.5 rsp-text-gray-500 hover:rsp-text-white hover:rsp-bg-red-500 rsp-rounded-full rsp-transition-colors",
3997
4218
  title: "Remove Card",
3998
- children: /* @__PURE__ */ e(ee, { className: "rsp-w-4 rsp-h-4" })
4219
+ children: /* @__PURE__ */ e(re, { className: "rsp-w-4 rsp-h-4" })
3999
4220
  }
4000
4221
  )
4001
4222
  ] }),
4002
4223
  /* @__PURE__ */ e("div", { className: "rsp-p-6", children: /* @__PURE__ */ r("div", { className: "rsp-grid rsp-grid-cols-1 lg:rsp-grid-cols-2 rsp-gap-6", children: [
4003
4224
  /* @__PURE__ */ r("div", { children: [
4004
4225
  /* @__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: [
4005
- /* @__PURE__ */ e("svg", { className: "rsp-w-4 rsp-h-4 rsp-text-blue-500", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: ((E = a.carousel) == null ? void 0 : E.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" }) }),
4006
- ((T = a.carousel) == null ? void 0 : T.type) === "VIDEO" ? "Video" : "Image",
4226
+ /* @__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" }) }),
4227
+ ((j = a.carousel) == null ? void 0 : j.type) === "VIDEO" ? "Video" : "Image",
4007
4228
  " Upload"
4008
4229
  ] }),
4009
4230
  /* @__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: [
4010
- s.mediaUrl ? /* @__PURE__ */ r("div", { className: "rsp-relative rsp-group", children: [
4011
- ((c = a.carousel) == null ? void 0 : c.type) === "IMAGE" ? /* @__PURE__ */ e(
4231
+ m.mediaUrl ? /* @__PURE__ */ r("div", { className: "rsp-relative rsp-group", children: [
4232
+ ((I = a.carousel) == null ? void 0 : I.type) === "IMAGE" ? /* @__PURE__ */ e(
4012
4233
  "img",
4013
4234
  {
4014
- src: s.mediaUrl,
4015
- alt: `Card ${b + 1}`,
4235
+ src: m.mediaUrl,
4236
+ alt: `Card ${C + 1}`,
4016
4237
  className: "rsp-w-full rsp-h-48 rsp-object-cover rsp-rounded-lg rsp-shadow-md",
4017
- onLoad: () => p((S) => ({ ...S, [s.id]: !0 })),
4018
- onError: () => p((S) => ({ ...S, [s.id]: !1 }))
4238
+ onLoad: () => x((T) => ({ ...T, [m.id]: !0 })),
4239
+ onError: () => x((T) => ({ ...T, [m.id]: !1 }))
4019
4240
  }
4020
4241
  ) : /* @__PURE__ */ e(
4021
4242
  "video",
4022
4243
  {
4023
- src: s.mediaUrl,
4244
+ src: m.mediaUrl,
4024
4245
  className: "rsp-w-full rsp-h-48 rsp-object-cover rsp-rounded-lg rsp-shadow-md",
4025
4246
  controls: !0,
4026
- onLoadedData: () => p((S) => ({ ...S, [s.id]: !0 })),
4027
- onError: () => p((S) => ({ ...S, [s.id]: !1 }))
4247
+ onLoadedData: () => x((T) => ({ ...T, [m.id]: !0 })),
4248
+ onError: () => x((T) => ({ ...T, [m.id]: !1 }))
4028
4249
  }
4029
4250
  ),
4030
4251
  /* @__PURE__ */ e(
4031
4252
  "button",
4032
4253
  {
4033
- onClick: () => k(s.id, "mediaUrl", ""),
4254
+ onClick: () => g(m.id, "mediaUrl", ""),
4034
4255
  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",
4035
4256
  title: "Remove media",
4036
- children: /* @__PURE__ */ e(ee, { className: "rsp-w-4 rsp-h-4" })
4257
+ children: /* @__PURE__ */ e(re, { className: "rsp-w-4 rsp-h-4" })
4037
4258
  }
4038
4259
  ),
4039
- /* @__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: ((M = a.carousel) == null ? void 0 : M.type) === "VIDEO" ? "📹 Video" : "🖼️ Image" })
4260
+ /* @__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: ((h = a.carousel) == null ? void 0 : h.type) === "VIDEO" ? "📹 Video" : "🖼️ Image" })
4040
4261
  ] }) : /* @__PURE__ */ r("div", { children: [
4041
- /* @__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: ((A = a.carousel) == null ? void 0 : A.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" }) }) }),
4262
+ /* @__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: ((L = a.carousel) == null ? void 0 : L.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" }) }) }),
4042
4263
  /* @__PURE__ */ e(
4043
4264
  "input",
4044
4265
  {
4045
4266
  type: "file",
4046
- accept: ((O = a.carousel) == null ? void 0 : O.type) === "VIDEO" ? "video/*" : "image/*",
4047
- onChange: (S) => {
4048
- var z;
4049
- const ae = (z = S.target.files) == null ? void 0 : z[0];
4050
- ae && !l[s.id] && V(s.id, ae);
4267
+ accept: ((z = a.carousel) == null ? void 0 : z.type) === "VIDEO" ? "video/*" : "image/*",
4268
+ onChange: (T) => {
4269
+ var D;
4270
+ const Y = (D = T.target.files) == null ? void 0 : D[0];
4271
+ Y && !n[m.id] && d(m.id, Y);
4051
4272
  },
4052
4273
  className: "rsp-hidden",
4053
- id: `file-upload-${s.id}`,
4054
- disabled: !!l[s.id]
4274
+ id: `file-upload-${m.id}`,
4275
+ disabled: !!n[m.id]
4055
4276
  }
4056
4277
  ),
4057
4278
  /* @__PURE__ */ r(
4058
4279
  "label",
4059
4280
  {
4060
- htmlFor: `file-upload-${s.id}`,
4061
- className: `rsp-inline-flex rsp-items-center rsp-gap-2 rsp-px-5 rsp-py-2.5 rsp-border rsp-border-blue-300 rsp-rounded-lg rsp-shadow-sm rsp-text-sm rsp-font-semibold rsp-text-blue-600 rsp-bg-white rsp-transition-colors ${l[s.id] ? "rsp-opacity-50 rsp-cursor-not-allowed" : "hover:rsp-bg-blue-50 rsp-cursor-pointer"}`,
4062
- "aria-disabled": !!l[s.id],
4281
+ htmlFor: `file-upload-${m.id}`,
4282
+ className: `rsp-inline-flex rsp-items-center rsp-gap-2 rsp-px-5 rsp-py-2.5 rsp-border rsp-border-blue-300 rsp-rounded-lg rsp-shadow-sm rsp-text-sm rsp-font-semibold rsp-text-blue-600 rsp-bg-white rsp-transition-colors ${n[m.id] ? "rsp-opacity-50 rsp-cursor-not-allowed" : "hover:rsp-bg-blue-50 rsp-cursor-pointer"}`,
4283
+ "aria-disabled": !!n[m.id],
4063
4284
  children: [
4064
4285
  /* @__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" }) }),
4065
4286
  "Upload ",
4066
- (($ = a.carousel) == null ? void 0 : $.type) === "VIDEO" ? "Video" : "Image"
4287
+ ((q = a.carousel) == null ? void 0 : q.type) === "VIDEO" ? "Video" : "Image"
4067
4288
  ]
4068
4289
  }
4069
4290
  ),
4070
4291
  /* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-gray-500 rsp-mt-3 rsp-px-2", children: ((X = a.carousel) == null ? void 0 : X.type) === "VIDEO" ? "📹 MP4, MOV, AVI (Max 16MB)" : "🖼️ PNG, JPG, GIF, TIFF, SVG, BMP (Max 5MB)" })
4071
4292
  ] }),
4072
- l[s.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: [
4293
+ n[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: [
4073
4294
  /* @__PURE__ */ r("svg", { className: "rsp-w-4 rsp-h-4 rsp-animate-spin", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", children: [
4074
4295
  /* @__PURE__ */ e("circle", { cx: "12", cy: "12", r: "10", strokeOpacity: "0.25", strokeWidth: "4" }),
4075
4296
  /* @__PURE__ */ e("path", { d: "M22 12a10 10 0 00-10-10", strokeWidth: "4" })
@@ -4088,11 +4309,11 @@ function ma({ template: a, setTemplate: n, onFileUpload: i }) {
4088
4309
  /* @__PURE__ */ e("div", { className: "rsp-relative", children: /* @__PURE__ */ e(
4089
4310
  "textarea",
4090
4311
  {
4091
- ref: (S) => {
4092
- y.current[s.id] = S;
4312
+ ref: (T) => {
4313
+ f.current[m.id] = T;
4093
4314
  },
4094
- value: s.body,
4095
- onChange: (S) => k(s.id, "body", S.target.value),
4315
+ value: m.body,
4316
+ onChange: (T) => g(m.id, "body", T.target.value),
4096
4317
  maxLength: 160,
4097
4318
  rows: 4,
4098
4319
  className: "rsp-w-full rsp-px-4 rsp-py-3 rsp-border-2 rsp-border-gray-200 rsp-rounded-lg rsp-text-sm focus:rsp-outline-none focus:rsp-border-blue-400 rsp-bg-white rsp-resize-none rsp-shadow-sm rsp-transition-colors",
@@ -4104,7 +4325,7 @@ function ma({ template: a, setTemplate: n, onFileUpload: i }) {
4104
4325
  /* @__PURE__ */ e(
4105
4326
  "button",
4106
4327
  {
4107
- onClick: () => N(s.id, "body"),
4328
+ onClick: () => c(m.id, "body"),
4108
4329
  className: "rsp-p-1.5 rsp-text-gray-500 hover:rsp-text-blue-600 hover:rsp-bg-blue-50 rsp-rounded rsp-transition-colors",
4109
4330
  title: "Add Variable",
4110
4331
  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" }) })
@@ -4114,29 +4335,29 @@ function ma({ template: a, setTemplate: n, onFileUpload: i }) {
4114
4335
  "button",
4115
4336
  {
4116
4337
  onClick: () => {
4117
- f(s.id), C(!0);
4338
+ U(m.id), o(!0);
4118
4339
  },
4119
4340
  className: "rsp-p-1.5 rsp-text-gray-500 hover:rsp-text-blue-600 hover:rsp-bg-blue-50 rsp-rounded rsp-transition-colors",
4120
4341
  title: "Add Emoji",
4121
- children: /* @__PURE__ */ e(xe, { className: "rsp-w-4 rsp-h-4" })
4342
+ children: /* @__PURE__ */ e(he, { className: "rsp-w-4 rsp-h-4" })
4122
4343
  }
4123
4344
  )
4124
4345
  ] }),
4125
- /* @__PURE__ */ r("span", { className: `rsp-text-xs rsp-font-medium ${s.body.length > 140 ? "rsp-text-orange-500" : "rsp-text-gray-500"}`, children: [
4126
- s.body.length,
4346
+ /* @__PURE__ */ r("span", { className: `rsp-text-xs rsp-font-medium ${m.body.length > 140 ? "rsp-text-orange-500" : "rsp-text-gray-500"}`, children: [
4347
+ m.body.length,
4127
4348
  "/160"
4128
4349
  ] })
4129
4350
  ] }),
4130
4351
  (() => {
4131
- const S = s.body.match(/\{\{(\d+)\}\}/g) || [], ae = [...new Set(S.map((z) => z.replace(/[{}]/g, "")))];
4132
- return ae.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: [
4352
+ const T = m.body.match(/\{\{(\d+)\}\}/g) || [], Y = [...new Set(T.map((D) => D.replace(/[{}]/g, "")))];
4353
+ 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: [
4133
4354
  /* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-font-semibold rsp-text-blue-800 rsp-mb-2", children: "Sample Values for This Card" }),
4134
- /* @__PURE__ */ e("div", { className: "rsp-grid rsp-grid-cols-1 rsp-gap-2", children: ae.map((z) => {
4135
- var Z, _;
4355
+ /* @__PURE__ */ e("div", { className: "rsp-grid rsp-grid-cols-1 rsp-gap-2", children: Y.map((D) => {
4356
+ var ie, G;
4136
4357
  return /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-2", children: [
4137
4358
  /* @__PURE__ */ r("label", { className: "rsp-text-xs rsp-text-gray-700 rsp-font-medium rsp-whitespace-nowrap", children: [
4138
4359
  "{{",
4139
- z,
4360
+ D,
4140
4361
  "}}",
4141
4362
  ":"
4142
4363
  ] }),
@@ -4144,24 +4365,24 @@ function ma({ template: a, setTemplate: n, onFileUpload: i }) {
4144
4365
  "input",
4145
4366
  {
4146
4367
  type: "text",
4147
- value: ((_ = (Z = s.sampleContent) == null ? void 0 : Z.bodyVariables) == null ? void 0 : _[z]) || "",
4148
- onChange: (Q) => {
4149
- const W = Q.target.value;
4150
- n((F) => ({
4151
- ...F,
4368
+ value: ((G = (ie = m.sampleContent) == null ? void 0 : ie.bodyVariables) == null ? void 0 : G[D]) || "",
4369
+ onChange: (se) => {
4370
+ const ae = se.target.value;
4371
+ s((K) => ({
4372
+ ...K,
4152
4373
  carousel: {
4153
- ...F.carousel,
4154
- cards: F.carousel.cards.map((P) => {
4155
- var D, q, Y;
4156
- return P.id !== s.id ? P : {
4157
- ...P,
4374
+ ...K.carousel,
4375
+ cards: K.carousel.cards.map((F) => {
4376
+ var H, W, Z;
4377
+ return F.id !== m.id ? F : {
4378
+ ...F,
4158
4379
  sampleContent: {
4159
- headerVariables: ((D = P.sampleContent) == null ? void 0 : D.headerVariables) || {},
4380
+ headerVariables: ((H = F.sampleContent) == null ? void 0 : H.headerVariables) || {},
4160
4381
  bodyVariables: {
4161
- ...((q = P.sampleContent) == null ? void 0 : q.bodyVariables) || {},
4162
- [z]: W
4382
+ ...((W = F.sampleContent) == null ? void 0 : W.bodyVariables) || {},
4383
+ [D]: ae
4163
4384
  },
4164
- buttonVariables: ((Y = P.sampleContent) == null ? void 0 : Y.buttonVariables) || {}
4385
+ buttonVariables: ((Z = F.sampleContent) == null ? void 0 : Z.buttonVariables) || {}
4165
4386
  }
4166
4387
  };
4167
4388
  })
@@ -4177,22 +4398,22 @@ function ma({ template: a, setTemplate: n, onFileUpload: i }) {
4177
4398
  {
4178
4399
  type: "button",
4179
4400
  onClick: () => {
4180
- const Q = new RegExp(`\\{\\{${z}\\}\\}`, "g"), W = (s.body || "").replace(Q, "");
4181
- n((F) => ({
4182
- ...F,
4401
+ const se = new RegExp(`\\{\\{${D}\\}\\}`, "g"), ae = (m.body || "").replace(se, "");
4402
+ s((K) => ({
4403
+ ...K,
4183
4404
  carousel: {
4184
- ...F.carousel,
4185
- cards: F.carousel.cards.map((P) => {
4186
- var D, q, Y;
4187
- if (P.id !== s.id) return P;
4188
- const G = Object.fromEntries(Object.entries(((D = P.sampleContent) == null ? void 0 : D.bodyVariables) || {}).filter(([re]) => re !== z));
4405
+ ...K.carousel,
4406
+ cards: K.carousel.cards.map((F) => {
4407
+ var H, W, Z;
4408
+ if (F.id !== m.id) return F;
4409
+ const Q = Object.fromEntries(Object.entries(((H = F.sampleContent) == null ? void 0 : H.bodyVariables) || {}).filter(([ne]) => ne !== D));
4189
4410
  return {
4190
- ...P,
4191
- body: W,
4411
+ ...F,
4412
+ body: ae,
4192
4413
  sampleContent: {
4193
- headerVariables: ((q = P.sampleContent) == null ? void 0 : q.headerVariables) || {},
4194
- bodyVariables: G,
4195
- buttonVariables: ((Y = P.sampleContent) == null ? void 0 : Y.buttonVariables) || {}
4414
+ headerVariables: ((W = F.sampleContent) == null ? void 0 : W.headerVariables) || {},
4415
+ bodyVariables: Q,
4416
+ buttonVariables: ((Z = F.sampleContent) == null ? void 0 : Z.buttonVariables) || {}
4196
4417
  }
4197
4418
  };
4198
4419
  })
@@ -4204,18 +4425,18 @@ function ma({ template: a, setTemplate: n, onFileUpload: i }) {
4204
4425
  children: "×"
4205
4426
  }
4206
4427
  )
4207
- ] }, `card-${s.id}-sample-${z}`);
4428
+ ] }, `card-${m.id}-sample-${D}`);
4208
4429
  }) })
4209
4430
  ] });
4210
4431
  })()
4211
4432
  ] }),
4212
- s.buttons.length < 2 && /* @__PURE__ */ r("div", { children: [
4433
+ m.buttons.length < 2 && /* @__PURE__ */ r("div", { children: [
4213
4434
  /* @__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: [
4214
4435
  /* @__PURE__ */ e("svg", { className: "rsp-w-4 rsp-h-4 rsp-text-blue-500", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 15l-2 5L9 9l11 4-5 2zm0 0l5 5M7.188 2.239l.777 2.897M5.136 7.965l-2.898-.777M13.95 4.05l-2.122 2.122m-5.657 5.656l-2.12 2.122" }) }),
4215
4436
  "Add Action Button",
4216
4437
  /* @__PURE__ */ r("span", { className: "rsp-text-xs rsp-text-gray-500 rsp-font-normal", children: [
4217
4438
  "(",
4218
- s.buttons.length,
4439
+ m.buttons.length,
4219
4440
  "/2)"
4220
4441
  ] })
4221
4442
  ] }),
@@ -4223,7 +4444,7 @@ function ma({ template: a, setTemplate: n, onFileUpload: i }) {
4223
4444
  /* @__PURE__ */ r(
4224
4445
  "button",
4225
4446
  {
4226
- onClick: () => t(s.id, "QUICK_REPLY"),
4447
+ onClick: () => u(m.id, "QUICK_REPLY"),
4227
4448
  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",
4228
4449
  children: [
4229
4450
  /* @__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" }) }),
@@ -4234,7 +4455,7 @@ function ma({ template: a, setTemplate: n, onFileUpload: i }) {
4234
4455
  /* @__PURE__ */ r(
4235
4456
  "button",
4236
4457
  {
4237
- onClick: () => t(s.id, "URL"),
4458
+ onClick: () => u(m.id, "URL"),
4238
4459
  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",
4239
4460
  children: [
4240
4461
  /* @__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" }) }),
@@ -4245,7 +4466,7 @@ function ma({ template: a, setTemplate: n, onFileUpload: i }) {
4245
4466
  /* @__PURE__ */ r(
4246
4467
  "button",
4247
4468
  {
4248
- onClick: () => t(s.id, "PHONE_NUMBER"),
4469
+ onClick: () => u(m.id, "PHONE_NUMBER"),
4249
4470
  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",
4250
4471
  children: [
4251
4472
  /* @__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" }) }),
@@ -4255,24 +4476,24 @@ function ma({ template: a, setTemplate: n, onFileUpload: i }) {
4255
4476
  )
4256
4477
  ] })
4257
4478
  ] }),
4258
- s.buttons.length > 0 && /* @__PURE__ */ r("div", { className: "rsp-space-y-3", children: [
4479
+ m.buttons.length > 0 && /* @__PURE__ */ r("div", { className: "rsp-space-y-3", children: [
4259
4480
  /* @__PURE__ */ r("label", { className: "rsp-text-sm rsp-font-semibold rsp-text-gray-800 rsp-flex rsp-items-center rsp-gap-2", children: [
4260
4481
  /* @__PURE__ */ e("svg", { className: "rsp-w-4 rsp-h-4 rsp-text-green-500", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" }) }),
4261
4482
  "Configured Buttons"
4262
4483
  ] }),
4263
- s.buttons.map((S, ae) => /* @__PURE__ */ r("div", { className: "rsp-p-4 rsp-border-2 rsp-border-blue-200 rsp-rounded-lg rsp-bg-gradient-to-br rsp-from-blue-50 rsp-to-white rsp-shadow-sm", children: [
4484
+ m.buttons.map((T, Y) => /* @__PURE__ */ r("div", { className: "rsp-p-4 rsp-border-2 rsp-border-blue-200 rsp-rounded-lg rsp-bg-gradient-to-br rsp-from-blue-50 rsp-to-white rsp-shadow-sm", children: [
4264
4485
  /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-justify-between rsp-mb-3", children: [
4265
4486
  /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-2", children: [
4266
- /* @__PURE__ */ e("div", { className: "rsp-w-6 rsp-h-6 rsp-bg-blue-500 rsp-text-white rsp-rounded rsp-flex rsp-items-center rsp-justify-center rsp-text-xs rsp-font-bold", children: ae + 1 }),
4267
- /* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-font-semibold rsp-text-gray-800", children: S.type === "QUICK_REPLY" ? "Quick Reply" : S.type === "URL" ? "Website" : "Phone" })
4487
+ /* @__PURE__ */ e("div", { className: "rsp-w-6 rsp-h-6 rsp-bg-blue-500 rsp-text-white rsp-rounded rsp-flex rsp-items-center rsp-justify-center rsp-text-xs rsp-font-bold", children: Y + 1 }),
4488
+ /* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-font-semibold rsp-text-gray-800", children: T.type === "QUICK_REPLY" ? "Quick Reply" : T.type === "URL" ? "Website" : "Phone" })
4268
4489
  ] }),
4269
4490
  /* @__PURE__ */ e(
4270
4491
  "button",
4271
4492
  {
4272
- onClick: () => v(s.id, S.id),
4493
+ onClick: () => B(m.id, T.id),
4273
4494
  className: "rsp-p-1 rsp-text-gray-400 hover:rsp-text-red-500 hover:rsp-bg-red-50 rsp-rounded rsp-transition-colors",
4274
4495
  title: "Remove button",
4275
- children: /* @__PURE__ */ e(ee, { className: "rsp-w-4 rsp-h-4" })
4496
+ children: /* @__PURE__ */ e(re, { className: "rsp-w-4 rsp-h-4" })
4276
4497
  }
4277
4498
  )
4278
4499
  ] }),
@@ -4283,15 +4504,15 @@ function ma({ template: a, setTemplate: n, onFileUpload: i }) {
4283
4504
  "input",
4284
4505
  {
4285
4506
  type: "text",
4286
- value: S.text,
4287
- onChange: (z) => h(s.id, S.id, "text", z.target.value),
4288
- placeholder: `Enter Button Text (Max ${S.type === "QUICK_REPLY" ? "25" : "20"} characters)`,
4289
- maxLength: S.type === "QUICK_REPLY" ? 25 : 20,
4507
+ value: T.text,
4508
+ onChange: (D) => V(m.id, T.id, "text", D.target.value),
4509
+ placeholder: `Enter Button Text (Max ${T.type === "QUICK_REPLY" ? "25" : "20"} characters)`,
4510
+ maxLength: T.type === "QUICK_REPLY" ? 25 : 20,
4290
4511
  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"
4291
4512
  }
4292
4513
  )
4293
4514
  ] }),
4294
- S.type === "URL" && /* @__PURE__ */ r("div", { className: "rsp-space-y-3", children: [
4515
+ T.type === "URL" && /* @__PURE__ */ r("div", { className: "rsp-space-y-3", children: [
4295
4516
  /* @__PURE__ */ r("div", { children: [
4296
4517
  /* @__PURE__ */ e("label", { className: "rsp-block rsp-text-xs rsp-font-medium rsp-text-gray-600 rsp-mb-2", children: "URL Type" }),
4297
4518
  /* @__PURE__ */ r("div", { className: "rsp-flex rsp-gap-4", children: [
@@ -4300,8 +4521,8 @@ function ma({ template: a, setTemplate: n, onFileUpload: i }) {
4300
4521
  "input",
4301
4522
  {
4302
4523
  type: "radio",
4303
- checked: S.urlType !== "dynamic",
4304
- onChange: () => h(s.id, S.id, "urlType", "static"),
4524
+ checked: T.urlType !== "dynamic",
4525
+ onChange: () => V(m.id, T.id, "urlType", "static"),
4305
4526
  className: "rsp-mr-2 rsp-text-blue-600"
4306
4527
  }
4307
4528
  ),
@@ -4312,8 +4533,8 @@ function ma({ template: a, setTemplate: n, onFileUpload: i }) {
4312
4533
  "input",
4313
4534
  {
4314
4535
  type: "radio",
4315
- checked: S.urlType === "dynamic",
4316
- onChange: () => h(s.id, S.id, "urlType", "dynamic"),
4536
+ checked: T.urlType === "dynamic",
4537
+ onChange: () => V(m.id, T.id, "urlType", "dynamic"),
4317
4538
  className: "rsp-mr-2 rsp-text-blue-600"
4318
4539
  }
4319
4540
  ),
@@ -4327,14 +4548,14 @@ function ma({ template: a, setTemplate: n, onFileUpload: i }) {
4327
4548
  "input",
4328
4549
  {
4329
4550
  type: "text",
4330
- value: S.value || "",
4331
- onChange: (z) => h(s.id, S.id, "value", z.target.value),
4332
- placeholder: S.urlType === "dynamic" ? "https://example.com/order/{{1}}" : "https://example.com",
4551
+ value: T.value || "",
4552
+ onChange: (D) => V(m.id, T.id, "value", D.target.value),
4553
+ placeholder: T.urlType === "dynamic" ? "https://example.com/order/{{1}}" : "https://example.com",
4333
4554
  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"
4334
4555
  }
4335
4556
  )
4336
4557
  ] }),
4337
- S.urlType === "dynamic" && /* @__PURE__ */ r("div", { className: "rsp-space-y-2", children: [
4558
+ T.urlType === "dynamic" && /* @__PURE__ */ r("div", { className: "rsp-space-y-2", children: [
4338
4559
  /* @__PURE__ */ e("div", { className: "rsp-p-2 rsp-bg-blue-50 rsp-rounded rsp-border rsp-border-blue-200", children: /* @__PURE__ */ r("p", { className: "rsp-text-xs rsp-text-blue-700", children: [
4339
4560
  /* @__PURE__ */ e("strong", { children: "Tip:" }),
4340
4561
  " Use ",
@@ -4353,71 +4574,54 @@ function ma({ template: a, setTemplate: n, onFileUpload: i }) {
4353
4574
  {
4354
4575
  type: "button",
4355
4576
  onClick: () => {
4356
- if (((S.value || "").match(/\{\{(\d+)\}\}/g) || []).length >= 3) return;
4357
- const _ = ((S.value || "").match(/\{\{(\d+)\}\}/g) || []).map((P) => {
4358
- const G = P.match(/{{(\d+)}}/);
4359
- return G ? parseInt(G[1], 10) : 0;
4360
- }), W = (_.length > 0 ? Math.max(..._) : 0) + 1, F = (S.value || "") + `{{${W}}}`;
4361
- h(s.id, S.id, "value", F);
4577
+ if (((T.value || "").match(/\{\{(\d+)\}\}/g) || []).length >= 3) return;
4578
+ const G = ((T.value || "").match(/\{\{(\d+)\}\}/g) || []).map((F) => {
4579
+ const Q = F.match(/{{(\d+)}}/);
4580
+ return Q ? parseInt(Q[1], 10) : 0;
4581
+ }), ae = (G.length > 0 ? Math.max(...G) : 0) + 1, K = (T.value || "") + `{{${ae}}}`;
4582
+ V(m.id, T.id, "value", K);
4362
4583
  },
4363
- disabled: ((S.value || "").match(/\{\{(\d+)\}\}/g) || []).length >= 3,
4584
+ disabled: ((T.value || "").match(/\{\{(\d+)\}\}/g) || []).length >= 3,
4364
4585
  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",
4365
4586
  children: "+ Add Variable"
4366
4587
  }
4367
4588
  ),
4368
- ((S.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" })
4589
+ ((T.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" })
4369
4590
  ] }),
4370
- /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(
4371
- "button",
4372
- {
4373
- type: "button",
4374
- onClick: () => {
4375
- const z = S.value || "", Z = /\{\{\d+\}\}/g;
4376
- let _ = -1, Q = "", W;
4377
- for (; (W = Z.exec(z)) !== null; )
4378
- _ = W.index, Q = W[0];
4379
- if (_ === -1) return;
4380
- const F = _, P = F + Q.length, G = z.slice(0, F) + z.slice(P);
4381
- h(s.id, S.id, "value", G);
4382
- },
4383
- className: "rsp-mt-2 rsp-px-3 rsp-py-1.5 rsp-text-xs rsp-bg-red-500 hover:rsp-bg-red-600 rsp-text-white rsp-rounded rsp-transition-colors",
4384
- children: "Remove Last"
4385
- }
4386
- ) }),
4387
4591
  (() => {
4388
- const z = (S.value || "").match(/\{\{(\d+)\}\}/g) || [], Z = [...new Set(z.map((_) => _.replace(/[{}]/g, "")))];
4389
- 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: [
4592
+ const D = (T.value || "").match(/\{\{(\d+)\}\}/g) || [], ie = [...new Set(D.map((G) => G.replace(/[{}]/g, "")))];
4593
+ return ie.length === 0 ? null : /* @__PURE__ */ r("div", { className: "rsp-p-3 rsp-bg-gray-50 rsp-rounded-lg rsp-border rsp-border-gray-200", children: [
4390
4594
  /* @__PURE__ */ e("h4", { className: "rsp-text-xs rsp-font-semibold rsp-text-gray-700 rsp-mb-2", children: "Sample Values for URL Variables" }),
4391
- /* @__PURE__ */ e("div", { className: "rsp-space-y-2", children: Z.map((_) => {
4392
- var Q, W;
4595
+ /* @__PURE__ */ e("div", { className: "rsp-space-y-2", children: ie.map((G) => {
4596
+ var se, ae;
4393
4597
  return /* @__PURE__ */ r("div", { className: "rsp-space-y-1", children: [
4394
4598
  /* @__PURE__ */ r("label", { className: "rsp-block rsp-text-xs rsp-text-gray-600 rsp-mb-1", children: [
4395
4599
  "Variable ",
4396
4600
  "{{",
4397
- _,
4601
+ G,
4398
4602
  "}}"
4399
4603
  ] }),
4400
4604
  /* @__PURE__ */ e(
4401
4605
  "input",
4402
4606
  {
4403
4607
  type: "text",
4404
- value: ((W = (Q = s.sampleContent) == null ? void 0 : Q.buttonVariables) == null ? void 0 : W[_]) || "",
4405
- onChange: (F) => {
4406
- const P = F.target.value;
4407
- n((G) => ({
4408
- ...G,
4608
+ value: ((ae = (se = m.sampleContent) == null ? void 0 : se.buttonVariables) == null ? void 0 : ae[G]) || "",
4609
+ onChange: (K) => {
4610
+ const F = K.target.value;
4611
+ s((Q) => ({
4612
+ ...Q,
4409
4613
  carousel: {
4410
- ...G.carousel,
4411
- cards: G.carousel.cards.map((D) => {
4412
- var q, Y, re;
4413
- return D.id !== s.id ? D : {
4414
- ...D,
4614
+ ...Q.carousel,
4615
+ cards: Q.carousel.cards.map((H) => {
4616
+ var W, Z, ne;
4617
+ return H.id !== m.id ? H : {
4618
+ ...H,
4415
4619
  sampleContent: {
4416
- headerVariables: ((q = D.sampleContent) == null ? void 0 : q.headerVariables) || {},
4417
- bodyVariables: ((Y = D.sampleContent) == null ? void 0 : Y.bodyVariables) || {},
4620
+ headerVariables: ((W = H.sampleContent) == null ? void 0 : W.headerVariables) || {},
4621
+ bodyVariables: ((Z = H.sampleContent) == null ? void 0 : Z.bodyVariables) || {},
4418
4622
  buttonVariables: {
4419
- ...((re = D.sampleContent) == null ? void 0 : re.buttonVariables) || {},
4420
- [_]: P
4623
+ ...((ne = H.sampleContent) == null ? void 0 : ne.buttonVariables) || {},
4624
+ [G]: F
4421
4625
  }
4422
4626
  }
4423
4627
  };
@@ -4426,7 +4630,7 @@ function ma({ template: a, setTemplate: n, onFileUpload: i }) {
4426
4630
  }));
4427
4631
  },
4428
4632
  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",
4429
- placeholder: `Sample value (e.g., ${_ === "1" ? "order123" : "user456"})`
4633
+ placeholder: `Sample value (e.g., ${G === "1" ? "order123" : "user456"})`
4430
4634
  }
4431
4635
  ),
4432
4636
  /* @__PURE__ */ e(
@@ -4434,57 +4638,57 @@ function ma({ template: a, setTemplate: n, onFileUpload: i }) {
4434
4638
  {
4435
4639
  type: "button",
4436
4640
  onClick: () => {
4437
- const F = S.value || "", P = new RegExp(`\\{\\{${_}\\}\\}`, "g"), G = F.replace(P, "");
4438
- h(s.id, S.id, "value", G), n((D) => ({
4439
- ...D,
4641
+ const K = T.value || "", F = new RegExp(`\\{\\{${G}\\}\\}`, "g"), Q = K.replace(F, "");
4642
+ V(m.id, T.id, "value", Q), s((H) => ({
4643
+ ...H,
4440
4644
  carousel: {
4441
- ...D.carousel,
4442
- cards: D.carousel.cards.map((q) => {
4443
- var re, he, ue;
4444
- if (q.id !== s.id) return q;
4445
- const Y = Object.fromEntries(Object.entries(((re = q.sampleContent) == null ? void 0 : re.buttonVariables) || {}).filter(([Ee]) => Ee !== _));
4645
+ ...H.carousel,
4646
+ cards: H.carousel.cards.map((W) => {
4647
+ var ne, ye, we;
4648
+ if (W.id !== m.id) return W;
4649
+ const Z = Object.fromEntries(Object.entries(((ne = W.sampleContent) == null ? void 0 : ne.buttonVariables) || {}).filter(([Be]) => Be !== G));
4446
4650
  return {
4447
- ...q,
4651
+ ...W,
4448
4652
  sampleContent: {
4449
- headerVariables: ((he = q.sampleContent) == null ? void 0 : he.headerVariables) || {},
4450
- bodyVariables: ((ue = q.sampleContent) == null ? void 0 : ue.bodyVariables) || {},
4451
- buttonVariables: Y
4653
+ headerVariables: ((ye = W.sampleContent) == null ? void 0 : ye.headerVariables) || {},
4654
+ bodyVariables: ((we = W.sampleContent) == null ? void 0 : we.bodyVariables) || {},
4655
+ buttonVariables: Z
4452
4656
  }
4453
4657
  };
4454
4658
  })
4455
4659
  }
4456
4660
  }));
4457
4661
  },
4458
- className: "rsp-px-2 rsp-py-1 rsp-text-xs rsp-text-red-600 hover:rsp-bg-red-50 rsp-rounded",
4662
+ className: "rsp-px-2 rsp-py-1 rsp-text- rsp-text-red-600 hover:rsp-bg-red-50 rsp-rounded",
4459
4663
  title: "Remove this variable",
4460
4664
  children: "×"
4461
4665
  }
4462
4666
  )
4463
- ] }, `button-${S.id}-sample-${_}`);
4667
+ ] }, `button-${T.id}-sample-${G}`);
4464
4668
  }) })
4465
4669
  ] });
4466
4670
  })()
4467
4671
  ] })
4468
4672
  ] }),
4469
- S.type === "PHONE_NUMBER" && /* @__PURE__ */ r("div", { children: [
4673
+ T.type === "PHONE_NUMBER" && /* @__PURE__ */ r("div", { children: [
4470
4674
  /* @__PURE__ */ e("label", { className: "rsp-block rsp-text-xs rsp-font-medium rsp-text-gray-600 rsp-mb-1", children: "Phone Number" }),
4471
4675
  /* @__PURE__ */ e(
4472
4676
  "input",
4473
4677
  {
4474
4678
  type: "text",
4475
- value: S.value || "",
4476
- onChange: (z) => h(s.id, S.id, "value", z.target.value),
4679
+ value: T.value || "",
4680
+ onChange: (D) => V(m.id, T.id, "value", D.target.value),
4477
4681
  placeholder: "+1234567890",
4478
4682
  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"
4479
4683
  }
4480
4684
  )
4481
4685
  ] })
4482
4686
  ] })
4483
- ] }, S.id))
4687
+ ] }, T.id))
4484
4688
  ] })
4485
4689
  ] })
4486
4690
  ] }) })
4487
- ] }, s.id);
4691
+ ] }, m.id);
4488
4692
  }) }),
4489
4693
  /* @__PURE__ */ e("div", { className: "rsp-bg-blue-50 rsp-border-l-4 rsp-border-blue-500 rsp-p-4 rsp-rounded-r-md", children: /* @__PURE__ */ r("div", { className: "rsp-flex", children: [
4490
4694
  /* @__PURE__ */ e("div", { className: "rsp-flex-shrink-0", children: /* @__PURE__ */ e("svg", { className: "rsp-h-5 rsp-w-5 rsp-text-blue-400", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ e("path", { fillRule: "evenodd", d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z", clipRule: "evenodd" }) }) }),
@@ -4501,52 +4705,52 @@ function ma({ template: a, setTemplate: n, onFileUpload: i }) {
4501
4705
  ] })
4502
4706
  ] }) }),
4503
4707
  /* @__PURE__ */ e(
4504
- fe,
4708
+ ge,
4505
4709
  {
4506
- isOpen: m,
4507
- onClose: () => C(!1),
4508
- onSelect: o
4710
+ isOpen: w,
4711
+ onClose: () => o(!1),
4712
+ onSelect: p
4509
4713
  }
4510
4714
  )
4511
4715
  ] });
4512
4716
  }
4513
- const ve = async (a) => {
4717
+ const Me = async (a) => {
4514
4718
  try {
4515
4719
  console.log(`Starting file upload: ${a.name}`);
4516
- const n = await la(a);
4517
- return console.log(`File uploaded successfully: ${n}`), n;
4518
- } catch (n) {
4519
- throw console.error("Upload failed in parent:", n), n;
4720
+ const s = await ba(a);
4721
+ return console.log(`File uploaded successfully: ${s}`), s;
4722
+ } catch (s) {
4723
+ throw console.error("Upload failed in parent:", s), s;
4520
4724
  }
4521
- }, ca = (a) => {
4725
+ }, va = (a) => {
4522
4726
  const i = (a.body || "").match(/\{\{(\d+)\}\}/g);
4523
4727
  if (!i) return 0;
4524
- const l = i.map((d) => {
4525
- const p = d.match(/{{(\d+)}}/);
4526
- return p ? parseInt(p[1], 10) : 0;
4728
+ const n = i.map((t) => {
4729
+ const x = t.match(/{{(\d+)}}/);
4730
+ return x ? parseInt(x[1], 10) : 0;
4527
4731
  });
4528
- return l.length > 0 ? Math.max(...l) : 0;
4732
+ return n.length > 0 ? Math.max(...n) : 0;
4529
4733
  };
4530
- function da({ template: a, setTemplate: n }) {
4531
- const [i, l] = K.useState(!1), d = K.useRef(null), p = () => {
4532
- l(!0), setTimeout(() => {
4533
- d.current && d.current.focus();
4734
+ function ka({ template: a, setTemplate: s }) {
4735
+ const [i, n] = J.useState(!1), t = J.useRef(null), x = () => {
4736
+ n(!0), setTimeout(() => {
4737
+ t.current && t.current.focus();
4534
4738
  }, 0);
4535
- }, m = (C) => {
4536
- const g = d.current, f = a.body, y = g && typeof g.selectionStart == "number" ? g.selectionStart : f.length, j = f.substring(0, y), U = f.substring(y), k = j + C + U;
4537
- n({ ...a, body: k }), setTimeout(() => {
4538
- if (d.current) {
4539
- const N = y + C.length;
4540
- d.current.setSelectionRange(N, N), d.current.focus();
4739
+ }, l = (k) => {
4740
+ const w = t.current, o = a.body, N = w && typeof w.selectionStart == "number" ? w.selectionStart : o.length, U = o.substring(0, N), f = o.substring(N), b = U + k + f;
4741
+ s({ ...a, body: b }), setTimeout(() => {
4742
+ if (t.current) {
4743
+ const M = N + k.length;
4744
+ t.current.setSelectionRange(M, M), t.current.focus();
4541
4745
  }
4542
- }, 0), l(!1);
4746
+ }, 0), n(!1);
4543
4747
  };
4544
4748
  return /* @__PURE__ */ r("div", { className: "rsp-space-y-6", children: [
4545
4749
  a.type !== "CAROUSEL" && /* @__PURE__ */ r("div", { className: "rsp-space-y-6", children: [
4546
4750
  /* @__PURE__ */ e("h2", { className: "rsp-text-lg rsp-font-semibold rsp-text-gray-900", children: "Message Content" }),
4547
4751
  /* @__PURE__ */ r("div", { className: "rsp-space-y-6", children: [
4548
- /* @__PURE__ */ e(aa, { template: a, setTemplate: n, onFileUpload: ve }),
4549
- /* @__PURE__ */ e(sa, { template: a, setTemplate: n })
4752
+ /* @__PURE__ */ e(oa, { template: a, setTemplate: s, onFileUpload: Me }),
4753
+ /* @__PURE__ */ e(ha, { template: a, setTemplate: s })
4550
4754
  ] })
4551
4755
  ] }),
4552
4756
  a.type === "CAROUSEL" && /* @__PURE__ */ r("div", { className: "rsp-space-y-6", children: [
@@ -4559,23 +4763,24 @@ function da({ template: a, setTemplate: n }) {
4559
4763
  /* @__PURE__ */ e("div", { className: "rsp-relative", children: /* @__PURE__ */ e(
4560
4764
  "textarea",
4561
4765
  {
4562
- ref: d,
4766
+ ref: t,
4563
4767
  value: a.body,
4564
- onChange: (C) => n({ ...a, body: C.target.value }),
4768
+ onChange: (k) => s({ ...a, body: k.target.value }),
4565
4769
  maxLength: 1024,
4566
4770
  rows: 4,
4567
4771
  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",
4568
4772
  placeholder: "Enter Template Message"
4569
4773
  }
4570
4774
  ) }),
4775
+ !a.body && /* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-red-600 rsp-mt-1", children: "Body is required." }),
4571
4776
  /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-justify-between rsp-mt-1", children: [
4572
4777
  /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-2", children: [
4573
4778
  /* @__PURE__ */ e(
4574
4779
  "button",
4575
4780
  {
4576
4781
  onClick: () => {
4577
- const f = `{{${ca(a) + 1}}}`;
4578
- n({ ...a, body: a.body + f });
4782
+ const o = `{{${va(a) + 1}}}`;
4783
+ s({ ...a, body: a.body + o });
4579
4784
  },
4580
4785
  className: "rsp-p-1 rsp-text-gray-500 hover:rsp-text-gray-700 hover:rsp-bg-gray-100 rsp-rounded",
4581
4786
  title: "Add Variable",
@@ -4585,10 +4790,10 @@ function da({ template: a, setTemplate: n }) {
4585
4790
  /* @__PURE__ */ e(
4586
4791
  "button",
4587
4792
  {
4588
- onClick: p,
4793
+ onClick: x,
4589
4794
  className: "rsp-p-1 rsp-text-gray-500 hover:rsp-text-gray-700 hover:rsp-bg-gray-100 rsp-rounded",
4590
4795
  title: "Add emoji",
4591
- children: /* @__PURE__ */ e(xe, { className: "rsp-w-4 rsp-h-4" })
4796
+ children: /* @__PURE__ */ e(he, { className: "rsp-w-4 rsp-h-4" })
4592
4797
  }
4593
4798
  )
4594
4799
  ] }),
@@ -4598,15 +4803,15 @@ function da({ template: a, setTemplate: n }) {
4598
4803
  ] })
4599
4804
  ] }),
4600
4805
  (() => {
4601
- const C = a.body.match(/\{\{(\d+)\}\}/g) || [], g = [...new Set(C.map((f) => f.replace(/[{}]/g, "")))];
4602
- return g.length === 0 ? null : /* @__PURE__ */ r("div", { className: "rsp-mt-3", children: [
4806
+ const k = a.body.match(/\{\{(\d+)\}\}/g) || [], w = [...new Set(k.map((o) => o.replace(/[{}]/g, "")))];
4807
+ return w.length === 0 ? null : /* @__PURE__ */ r("div", { className: "rsp-mt-3", children: [
4603
4808
  /* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-font-medium rsp-text-gray-600 rsp-mb-2", children: "Sample Values" }),
4604
- /* @__PURE__ */ e("div", { className: "rsp-grid rsp-grid-cols-3 rsp-gap-2", children: g.map((f) => {
4605
- var y, j;
4809
+ /* @__PURE__ */ e("div", { className: "rsp-grid rsp-grid-cols-3 rsp-gap-2", children: w.map((o) => {
4810
+ var N, U;
4606
4811
  return /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-gap-2", children: [
4607
4812
  /* @__PURE__ */ r("label", { className: "rsp-text-xs rsp-text-gray-500 rsp-whitespace-nowrap", children: [
4608
4813
  "{{",
4609
- f,
4814
+ o,
4610
4815
  "}}",
4611
4816
  ":"
4612
4817
  ] }),
@@ -4614,19 +4819,19 @@ function da({ template: a, setTemplate: n }) {
4614
4819
  "input",
4615
4820
  {
4616
4821
  type: "text",
4617
- value: ((j = (y = a.sampleContent) == null ? void 0 : y.bodyVariables) == null ? void 0 : j[f]) || "",
4618
- onChange: (U) => {
4619
- var N, o, u;
4620
- const k = {
4822
+ value: ((U = (N = a.sampleContent) == null ? void 0 : N.bodyVariables) == null ? void 0 : U[o]) || "",
4823
+ onChange: (f) => {
4824
+ var M, g, v;
4825
+ const b = {
4621
4826
  ...a.sampleContent,
4622
- headerVariables: ((N = a.sampleContent) == null ? void 0 : N.headerVariables) || {},
4827
+ headerVariables: ((M = a.sampleContent) == null ? void 0 : M.headerVariables) || {},
4623
4828
  bodyVariables: {
4624
- ...(o = a.sampleContent) == null ? void 0 : o.bodyVariables,
4625
- [f]: U.target.value
4829
+ ...(g = a.sampleContent) == null ? void 0 : g.bodyVariables,
4830
+ [o]: f.target.value
4626
4831
  },
4627
- buttonVariables: ((u = a.sampleContent) == null ? void 0 : u.buttonVariables) || {}
4832
+ buttonVariables: ((v = a.sampleContent) == null ? void 0 : v.buttonVariables) || {}
4628
4833
  };
4629
- n({ ...a, sampleContent: k });
4834
+ s({ ...a, sampleContent: b });
4630
4835
  },
4631
4836
  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",
4632
4837
  placeholder: "Sample"
@@ -4637,16 +4842,16 @@ function da({ template: a, setTemplate: n }) {
4637
4842
  {
4638
4843
  type: "button",
4639
4844
  onClick: () => {
4640
- var o, u, t;
4641
- const U = new RegExp(`\\{\\{${f}\\}\\}`, "g"), k = (a.body || "").replace(U, ""), N = Object.fromEntries(Object.entries(((o = a.sampleContent) == null ? void 0 : o.bodyVariables) || {}).filter(([h]) => h !== f));
4642
- n({
4845
+ var g, v, c;
4846
+ const f = new RegExp(`\\{\\{${o}\\}\\}`, "g"), b = (a.body || "").replace(f, ""), M = Object.fromEntries(Object.entries(((g = a.sampleContent) == null ? void 0 : g.bodyVariables) || {}).filter(([p]) => p !== o));
4847
+ s({
4643
4848
  ...a,
4644
- body: k,
4849
+ body: b,
4645
4850
  sampleContent: {
4646
4851
  ...a.sampleContent,
4647
- bodyVariables: N,
4648
- headerVariables: ((u = a.sampleContent) == null ? void 0 : u.headerVariables) || {},
4649
- buttonVariables: ((t = a.sampleContent) == null ? void 0 : t.buttonVariables) || {}
4852
+ bodyVariables: M,
4853
+ headerVariables: ((v = a.sampleContent) == null ? void 0 : v.headerVariables) || {},
4854
+ buttonVariables: ((c = a.sampleContent) == null ? void 0 : c.buttonVariables) || {}
4650
4855
  }
4651
4856
  });
4652
4857
  },
@@ -4655,74 +4860,74 @@ function da({ template: a, setTemplate: n }) {
4655
4860
  children: "×"
4656
4861
  }
4657
4862
  )
4658
- ] }, `global-body-sample-${f}`);
4863
+ ] }, `global-body-sample-${o}`);
4659
4864
  }) })
4660
4865
  ] });
4661
4866
  })()
4662
4867
  ] }) })
4663
4868
  ] }),
4664
4869
  a.type === "CAROUSEL" && /* @__PURE__ */ e("div", { className: "rsp-space-y-6", children: /* @__PURE__ */ e(
4665
- ma,
4870
+ wa,
4666
4871
  {
4667
4872
  template: a,
4668
- setTemplate: n,
4669
- onFileUpload: ve
4873
+ setTemplate: s,
4874
+ onFileUpload: Me
4670
4875
  }
4671
4876
  ) }),
4672
4877
  a.type !== "CAROUSEL" && /* @__PURE__ */ e("div", { className: "rsp-space-y-6", children: /* @__PURE__ */ e(
4673
- na,
4878
+ ua,
4674
4879
  {
4675
4880
  template: a,
4676
- setTemplate: n
4881
+ setTemplate: s
4677
4882
  }
4678
4883
  ) }),
4679
4884
  /* @__PURE__ */ e(
4680
- fe,
4885
+ ge,
4681
4886
  {
4682
4887
  isOpen: i,
4683
- onClose: () => l(!1),
4684
- onSelect: m
4888
+ onClose: () => n(!1),
4889
+ onSelect: l
4685
4890
  }
4686
4891
  )
4687
4892
  ] });
4688
4893
  }
4689
- function xa({ type: a }) {
4894
+ function Na({ type: a }) {
4690
4895
  switch (a) {
4691
4896
  case "QUICK_REPLY":
4692
- return /* @__PURE__ */ e(Pe, { className: "w-4 h-4" });
4897
+ return /* @__PURE__ */ e(Je, { className: "w-4 h-4" });
4693
4898
  case "URL":
4694
- return /* @__PURE__ */ e(Oe, { className: "w-4 h-4" });
4899
+ return /* @__PURE__ */ e(We, { className: "w-4 h-4" });
4695
4900
  case "CALL":
4696
- return /* @__PURE__ */ e(Me, { className: "w-4 h-4" });
4901
+ return /* @__PURE__ */ e(Ue, { className: "w-4 h-4" });
4697
4902
  case "FLOW":
4698
- return /* @__PURE__ */ e(Fe, { className: "w-4 h-4" });
4903
+ return /* @__PURE__ */ e(Qe, { className: "w-4 h-4" });
4699
4904
  default:
4700
4905
  return null;
4701
4906
  }
4702
4907
  }
4703
- function pa({ buttons: a, flowButtonText: n, onShowAllOptions: i }) {
4704
- const l = [...a];
4705
- n && l.push({
4908
+ function Ca({ buttons: a, flowButtonText: s, onShowAllOptions: i }) {
4909
+ const n = [...a];
4910
+ s && n.push({
4706
4911
  id: "flow-button",
4707
4912
  type: "QUICK_REPLY",
4708
- text: n
4913
+ text: s
4709
4914
  });
4710
- const d = l.slice(0, 2);
4915
+ const t = n.slice(0, 2);
4711
4916
  return /* @__PURE__ */ r("div", { className: "rsp-divide-y rsp-divide-gray-200", children: [
4712
- d.map((p) => /* @__PURE__ */ r(
4917
+ t.map((x) => /* @__PURE__ */ r(
4713
4918
  "button",
4714
4919
  {
4715
4920
  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",
4716
4921
  style: { fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif' },
4717
4922
  children: [
4718
- /* @__PURE__ */ e("div", { className: "rsp-text-[#128C7E]", children: /* @__PURE__ */ e(xa, { type: p.type }) }),
4719
- /* @__PURE__ */ e("span", { className: "rsp-flex-1 rsp-text-left rsp-break-words rsp-break-all rsp-whitespace-pre-wrap", children: p.text }),
4720
- p.id === "flow-button" && /* @__PURE__ */ e(Re, { className: "rsp-w-5 rsp-h-5 rsp-text-[#128C7E] rsp-ml-auto" })
4923
+ /* @__PURE__ */ e("div", { className: "rsp-text-[#128C7E]", children: /* @__PURE__ */ e(Na, { type: x.type }) }),
4924
+ /* @__PURE__ */ e("span", { className: "rsp-flex-1 rsp-text-left rsp-break-words rsp-break-all rsp-whitespace-pre-wrap", children: x.text }),
4925
+ x.id === "flow-button" && /* @__PURE__ */ e(qe, { className: "rsp-w-5 rsp-h-5 rsp-text-[#128C7E] rsp-ml-auto" })
4721
4926
  ]
4722
4927
  },
4723
- p.id
4928
+ x.id
4724
4929
  )),
4725
- l.length > 2 && /* @__PURE__ */ r(
4930
+ n.length > 2 && /* @__PURE__ */ r(
4726
4931
  "button",
4727
4932
  {
4728
4933
  onClick: i,
@@ -4736,25 +4941,25 @@ function pa({ buttons: a, flowButtonText: n, onShowAllOptions: i }) {
4736
4941
  )
4737
4942
  ] });
4738
4943
  }
4739
- function oa({ template: a }) {
4740
- var j, U, k, N;
4741
- const [n, i] = B(!1), [l, d] = B(0), p = (j = a.carousel) != null && j.cards ? a.carousel.cards.length : 0;
4742
- se(() => {
4743
- a.type === "CAROUSEL" && p > 0 ? l >= p && d(0) : d(0);
4744
- }, [p, a.type]);
4745
- const m = (o) => o ? o.replace(/\{\{(\d+)\}\}/g, (u, t) => {
4746
- var h, v;
4747
- return ((v = (h = a.sampleContent) == null ? void 0 : h.headerVariables) == null ? void 0 : v[t]) || `[Variable ${t}]`;
4748
- }) : "", C = (o) => o ? o.replace(/\{\{(\d+)\}\}/g, (u, t) => {
4749
- var h, v;
4750
- return ((v = (h = a.sampleContent) == null ? void 0 : h.bodyVariables) == null ? void 0 : v[t]) || `[Variable ${t}]`;
4751
- }) : "", g = (o) => {
4752
- var h;
4753
- const u = (o == null ? void 0 : o.body) ?? "";
4754
- if (!u) return "";
4755
- const t = ((h = o == null ? void 0 : o.sampleContent) == null ? void 0 : h.bodyVariables) ?? {};
4756
- return u.replace(/\{\{(\d+)\}\}/g, (v, V) => t[V] || `[Variable ${V}]`);
4757
- }, f = a.headerType !== "NONE" || a.body || a.footer || a.buttons.length > 0 || a.type === "CAROUSEL" && ((U = a.carousel) == null ? void 0 : U.cards.length), y = a.headerText || a.body || a.footer;
4944
+ function Ea({ template: a }) {
4945
+ var U, f, b, M;
4946
+ const [s, i] = P(!1), [n, t] = P(0), x = (U = a.carousel) != null && U.cards ? a.carousel.cards.length : 0;
4947
+ le(() => {
4948
+ a.type === "CAROUSEL" && x > 0 ? n >= x && t(0) : t(0);
4949
+ }, [x, a.type]);
4950
+ const l = (g) => g ? g.replace(/\{\{(\d+)\}\}/g, (v, c) => {
4951
+ var p, y;
4952
+ return ((y = (p = a.sampleContent) == null ? void 0 : p.headerVariables) == null ? void 0 : y[c]) || `[Variable ${c}]`;
4953
+ }) : "", k = (g) => g ? g.replace(/\{\{(\d+)\}\}/g, (v, c) => {
4954
+ var p, y;
4955
+ return ((y = (p = a.sampleContent) == null ? void 0 : p.bodyVariables) == null ? void 0 : y[c]) || `[Variable ${c}]`;
4956
+ }) : "", w = (g) => {
4957
+ var p;
4958
+ const v = (g == null ? void 0 : g.body) ?? "";
4959
+ if (!v) return "";
4960
+ const c = ((p = g == null ? void 0 : g.sampleContent) == null ? void 0 : p.bodyVariables) ?? {};
4961
+ return v.replace(/\{\{(\d+)\}\}/g, (y, u) => c[u] || `[Variable ${u}]`);
4962
+ }, o = a.headerType !== "NONE" || a.body || a.footer || a.buttons.length > 0 || a.type === "CAROUSEL" && ((f = a.carousel) == null ? void 0 : f.cards.length), N = a.headerText || a.body || a.footer;
4758
4963
  return /* @__PURE__ */ r("div", { className: "rsp-bg-white rsp-rounded-lg rsp-shadow-sm rsp-border rsp-border-gray-200", children: [
4759
4964
  /* @__PURE__ */ r("div", { className: "rsp-p-4 rsp-border-b rsp-border-gray-200", children: [
4760
4965
  /* @__PURE__ */ e("h3", { className: "rsp-text-lg rsp-font-semibold rsp-text-gray-900", children: "Preview" }),
@@ -4801,7 +5006,7 @@ function oa({ template: a }) {
4801
5006
  ] }),
4802
5007
  /* @__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: [
4803
5008
  /* @__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")` } }),
4804
- /* @__PURE__ */ e("div", { className: "rsp-relative rsp-px-4 rsp-py-4", children: f ? /* @__PURE__ */ r("div", { className: "rsp-flex rsp-flex-col rsp-items-start", children: [
5009
+ /* @__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: [
4805
5010
  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: [
4806
5011
  a.mediaType === "IMAGE" && /* @__PURE__ */ e(
4807
5012
  "img",
@@ -4809,8 +5014,8 @@ function oa({ template: a }) {
4809
5014
  src: a.mediaUrl,
4810
5015
  alt: "Header media",
4811
5016
  className: "rsp-w-full rsp-max-h-[150px] rsp-object-cover rsp-block",
4812
- onError: (o) => {
4813
- o.currentTarget.style.display = "none";
5017
+ onError: (g) => {
5018
+ g.currentTarget.style.display = "none";
4814
5019
  }
4815
5020
  }
4816
5021
  ),
@@ -4826,38 +5031,38 @@ function oa({ template: a }) {
4826
5031
  ] })
4827
5032
  ] }) })
4828
5033
  ] }),
4829
- y && /* @__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: [
4830
- 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: m(a.headerText) }) }),
4831
- 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: C(a.body) }) }),
5034
+ N && /* @__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: [
5035
+ 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) }) }),
5036
+ 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: k(a.body) }) }),
4832
5037
  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 }) }),
4833
5038
  /* @__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: [
4834
5039
  "9:41 AM",
4835
5040
  /* @__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" }) })
4836
5041
  ] }) })
4837
5042
  ] }) }),
4838
- a.type === "CAROUSEL" && (((N = (k = a.carousel) == null ? void 0 : k.cards) == null ? void 0 : N.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: [
5043
+ a.type === "CAROUSEL" && (((M = (b = a.carousel) == null ? void 0 : b.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: [
4839
5044
  (() => {
4840
- var u, t;
4841
- const o = a.carousel && a.carousel.cards.length > 0 ? a.carousel.cards[l] || a.carousel.cards[0] : void 0;
5045
+ var v, c;
5046
+ const g = a.carousel && a.carousel.cards.length > 0 ? a.carousel.cards[n] || a.carousel.cards[0] : void 0;
4842
5047
  return /* @__PURE__ */ r("div", { className: "rsp-flex rsp-flex-col rsp-h-full", children: [
4843
- /* @__PURE__ */ e("div", { className: "rsp-relative rsp-w-full rsp-h-[140px] rsp-bg-gray-100 rsp-group rsp-flex-shrink-0", children: o && o.mediaUrl ? /* @__PURE__ */ r(ne, { children: [
4844
- ((u = a.carousel) == null ? void 0 : u.type) === "IMAGE" ? /* @__PURE__ */ e(
5048
+ /* @__PURE__ */ e("div", { className: "rsp-relative rsp-w-full rsp-h-[140px] rsp-bg-gray-100 rsp-group rsp-flex-shrink-0", children: g && g.mediaUrl ? /* @__PURE__ */ r(ce, { children: [
5049
+ ((v = a.carousel) == null ? void 0 : v.type) === "IMAGE" ? /* @__PURE__ */ e(
4845
5050
  "img",
4846
5051
  {
4847
- src: o.mediaUrl,
5052
+ src: g.mediaUrl,
4848
5053
  alt: "Carousel card",
4849
5054
  className: "rsp-w-full rsp-h-full rsp-object-cover",
4850
- onError: (h) => {
4851
- h.currentTarget.style.display = "none";
5055
+ onError: (p) => {
5056
+ p.currentTarget.style.display = "none";
4852
5057
  }
4853
5058
  }
4854
5059
  ) : /* @__PURE__ */ e("div", { className: "rsp-relative rsp-w-full rsp-h-full rsp-bg-gradient-to-br rsp-from-gray-800 rsp-to-gray-900 rsp-flex rsp-items-center rsp-justify-center", children: /* @__PURE__ */ e("div", { className: "rsp-w-10 rsp-h-10 rsp-bg-black rsp-bg-opacity-70 rsp-rounded-full rsp-flex rsp-items-center rsp-justify-center rsp-shadow-lg", children: /* @__PURE__ */ e("div", { className: "rsp-w-0 rsp-h-0 rsp-border-l-[6px] rsp-border-l-white rsp-border-t-[5px] rsp-border-t-transparent rsp-border-b-[5px] rsp-border-b-transparent rsp-ml-1" }) }) }),
4855
- a.carousel && a.carousel.cards.length > 1 && /* @__PURE__ */ r(ne, { children: [
5060
+ a.carousel && a.carousel.cards.length > 1 && /* @__PURE__ */ r(ce, { children: [
4856
5061
  /* @__PURE__ */ e(
4857
5062
  "button",
4858
5063
  {
4859
- onClick: () => d(
4860
- (h) => h > 0 ? h - 1 : a.carousel.cards.length - 1
5064
+ onClick: () => t(
5065
+ (p) => p > 0 ? p - 1 : a.carousel.cards.length - 1
4861
5066
  ),
4862
5067
  className: "rsp-absolute rsp-left-1 rsp-top-1/2 rsp-transform -rsp-translate-y-1/2 rsp-z-20 rsp-w-6 rsp-h-6 rsp-bg-black rsp-bg-opacity-50 rsp-rounded-full rsp-flex rsp-items-center rsp-justify-center rsp-text-white hover:rsp-bg-opacity-80 rsp-transition-all rsp-opacity-0 group-hover:rsp-opacity-100",
4863
5068
  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: "M15 19l-7-7 7-7" }) })
@@ -4866,8 +5071,8 @@ function oa({ template: a }) {
4866
5071
  /* @__PURE__ */ e(
4867
5072
  "button",
4868
5073
  {
4869
- onClick: () => d(
4870
- (h) => h < a.carousel.cards.length - 1 ? h + 1 : 0
5074
+ onClick: () => t(
5075
+ (p) => p < a.carousel.cards.length - 1 ? p + 1 : 0
4871
5076
  ),
4872
5077
  className: "rsp-absolute rsp-right-1 rsp-top-1/2 rsp-transform -rsp-translate-y-1/2 rsp-z-20 rsp-w-6 rsp-h-6 rsp-bg-black rsp-bg-opacity-50 rsp-rounded-full rsp-flex rsp-items-center rsp-justify-center rsp-text-white hover:rsp-bg-opacity-80 rsp-transition-all rsp-opacity-0 group-hover:rsp-opacity-100",
4873
5078
  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: "M9 5l7 7-7 7" }) })
@@ -4875,41 +5080,41 @@ function oa({ template: a }) {
4875
5080
  )
4876
5081
  ] }),
4877
5082
  /* @__PURE__ */ r("div", { className: "rsp-absolute rsp-top-2 rsp-right-2 rsp-bg-black rsp-bg-opacity-60 rsp-text-white rsp-text-[10px] rsp-px-2 rsp-py-0.5 rsp-rounded-full rsp-backdrop-blur-sm", style: { fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif' }, children: [
4878
- l + 1,
5083
+ n + 1,
4879
5084
  "/",
4880
5085
  a.carousel ? a.carousel.cards.length : 0
4881
5086
  ] })
4882
5087
  ] }) : /* @__PURE__ */ e("div", { className: "rsp-w-full rsp-h-full rsp-flex rsp-items-center rsp-justify-center", children: /* @__PURE__ */ r("div", { className: "rsp-text-center", children: [
4883
- /* @__PURE__ */ e("svg", { className: "rsp-w-12 rsp-h-12 rsp-mx-auto rsp-text-gray-400 rsp-mb-2", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: ((t = a.carousel) == null ? void 0 : t.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" }) }),
5088
+ /* @__PURE__ */ e("svg", { className: "rsp-w-12 rsp-h-12 rsp-mx-auto rsp-text-gray-400 rsp-mb-2", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: ((c = a.carousel) == null ? void 0 : c.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" }) }),
4884
5089
  /* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-gray-500", style: { fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif' }, children: "No media" })
4885
5090
  ] }) }) }),
4886
- /* @__PURE__ */ e("div", { className: "rsp-px-4 rsp-py-3 rsp-flex-1 rsp-flex rsp-items-start", children: /* @__PURE__ */ e("p", { className: "rsp-text-[13px] rsp-text-[#111b21] rsp-leading-[1.4] rsp-line-clamp-3", style: { fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif' }, children: o ? g(o) : "Card body text..." }) }),
4887
- /* @__PURE__ */ e("div", { className: "rsp-border-t rsp-border-gray-100 rsp-mt-auto", children: o && o.buttons.length > 0 ? /* @__PURE__ */ e(ne, { children: o.buttons.map((h, v) => /* @__PURE__ */ e(
5091
+ /* @__PURE__ */ e("div", { className: "rsp-px-4 rsp-py-3 rsp-flex-1 rsp-flex rsp-items-start", children: /* @__PURE__ */ e("p", { className: "rsp-text-[13px] rsp-text-[#111b21] rsp-leading-[1.4] rsp-line-clamp-3", style: { fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif' }, children: g ? w(g) : "Card body text..." }) }),
5092
+ /* @__PURE__ */ e("div", { className: "rsp-border-t rsp-border-gray-100 rsp-mt-auto", children: g && g.buttons.length > 0 ? /* @__PURE__ */ e(ce, { children: g.buttons.map((p, y) => /* @__PURE__ */ e(
4888
5093
  "div",
4889
5094
  {
4890
- className: `rsp-px-4 rsp-py-3 rsp-text-center rsp-text-[14px] rsp-text-[#128C7E] rsp-font-medium rsp-break-words rsp-whitespace-pre-wrap ${v < o.buttons.length - 1 ? "rsp-border-b rsp-border-gray-100" : ""}`,
5095
+ className: `rsp-px-4 rsp-py-3 rsp-text-center rsp-text-[14px] rsp-text-[#128C7E] rsp-font-medium rsp-break-words rsp-whitespace-pre-wrap ${y < g.buttons.length - 1 ? "rsp-border-b rsp-border-gray-100" : ""}`,
4891
5096
  style: { fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif' },
4892
5097
  children: /* @__PURE__ */ r("div", { className: "rsp-flex rsp-items-center rsp-justify-center rsp-gap-2", children: [
4893
- h.type === "URL" && /* @__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: "M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" }) }),
4894
- (h.type === "CALL" || h.type === "PHONE_NUMBER") && /* @__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: "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" }) }),
4895
- /* @__PURE__ */ e("span", { className: "rsp-inline-block rsp-max-w-[180px] rsp-break-words rsp-break-all rsp-whitespace-pre-wrap rsp-text-center", children: h.text })
5098
+ p.type === "URL" && /* @__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: "M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" }) }),
5099
+ (p.type === "CALL" || p.type === "PHONE_NUMBER") && /* @__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: "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" }) }),
5100
+ /* @__PURE__ */ e("span", { className: "rsp-inline-block rsp-max-w-[180px] rsp-break-words rsp-break-all rsp-whitespace-pre-wrap rsp-text-center", children: p.text })
4896
5101
  ] })
4897
5102
  },
4898
- h.id
5103
+ p.id
4899
5104
  )) }) : /* @__PURE__ */ e("div", { className: "rsp-px-4 rsp-py-3 rsp-text-center rsp-text-xs rsp-text-gray-400", style: { fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif' }, children: "No buttons" }) })
4900
5105
  ] });
4901
5106
  })(),
4902
- a.carousel && a.carousel.cards.length > 1 && /* @__PURE__ */ e("div", { className: "rsp-flex rsp-items-center rsp-justify-center rsp-gap-1.5 rsp-py-3 rsp-bg-white rsp-border-t rsp-border-gray-100", children: a.carousel && a.carousel.cards.map((o, u) => /* @__PURE__ */ e(
5107
+ a.carousel && a.carousel.cards.length > 1 && /* @__PURE__ */ e("div", { className: "rsp-flex rsp-items-center rsp-justify-center rsp-gap-1.5 rsp-py-3 rsp-bg-white rsp-border-t rsp-border-gray-100", children: a.carousel && a.carousel.cards.map((g, v) => /* @__PURE__ */ e(
4903
5108
  "button",
4904
5109
  {
4905
- onClick: () => d(u),
4906
- className: `rsp-w-2 rsp-h-2 rsp-rounded-full rsp-transition-all ${u === l ? "rsp-bg-[#128C7E] rsp-w-6" : "rsp-bg-gray-300 hover:rsp-bg-gray-400"}`
5110
+ onClick: () => t(v),
5111
+ className: `rsp-w-2 rsp-h-2 rsp-rounded-full rsp-transition-all ${v === n ? "rsp-bg-[#128C7E] rsp-w-6" : "rsp-bg-gray-300 hover:rsp-bg-gray-400"}`
4907
5112
  },
4908
- u
5113
+ v
4909
5114
  )) })
4910
5115
  ] }) }) }) }),
4911
5116
  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(
4912
- pa,
5117
+ Ca,
4913
5118
  {
4914
5119
  buttons: a.buttons,
4915
5120
  onShowAllOptions: () => i(!0)
@@ -4926,20 +5131,20 @@ function oa({ template: a }) {
4926
5131
  /* @__PURE__ */ e("div", { className: "rsp-flex-1 rsp-bg-gradient-to-r rsp-from-white rsp-to-[#fafafa] rsp-rounded-[24px] rsp-px-4 rsp-py-2 rsp-flex rsp-items-center rsp-min-h-[36px] rsp-shadow-[0_1px_2px_rgba(0,0,0,0.1)] rsp-border rsp-border-gray-200", children: /* @__PURE__ */ e("span", { className: "rsp-text-[13px] rsp-text-[#667781] rsp-opacity-70 rsp-font-normal", children: "Type a message" }) }),
4927
5132
  /* @__PURE__ */ e("div", { className: "rsp-w-9 rsp-h-9 rsp-bg-gradient-to-br rsp-from-[#25D366] rsp-via-[#20c55e] rsp-to-[#00A884] rsp-rounded-full rsp-flex rsp-items-center rsp-justify-center rsp-shadow-[0_2px_6px_rgba(37,211,102,0.3)] rsp-border rsp-border-[#20c55e] rsp-border-opacity-30", children: /* @__PURE__ */ e("svg", { className: "rsp-w-4 rsp-h-4 rsp-text-white rsp-drop-shadow-sm", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ e("path", { d: "M2.01 21L23 12 2.01 3 2 10l15 2-15 2z" }) }) })
4928
5133
  ] }),
4929
- n && /* @__PURE__ */ e("div", { className: "rsp-absolute rsp-inset-0 rsp-bg-black rsp-bg-opacity-40 rsp-z-30 rsp-flex rsp-items-end rsp-animate-fade-in", children: /* @__PURE__ */ r(
5134
+ s && /* @__PURE__ */ e("div", { className: "rsp-absolute rsp-inset-0 rsp-bg-black rsp-bg-opacity-40 rsp-z-30 rsp-flex rsp-items-end rsp-animate-fade-in", children: /* @__PURE__ */ r(
4930
5135
  "div",
4931
5136
  {
4932
5137
  className: "rsp-w-full rsp-bg-[#F0F2F5] rsp-rounded-t-2xl rsp-shadow-lg rsp-animate-slide-up",
4933
5138
  children: [
4934
5139
  /* @__PURE__ */ e("div", { className: "rsp-p-4 rsp-border-b rsp-border-gray-300", children: /* @__PURE__ */ e("h4", { className: "rsp-font-bold rsp-text-center rsp-text-gray-800 rsp-text-md", children: a.body || "Options" }) }),
4935
- /* @__PURE__ */ e("div", { className: "rsp-max-h-[250px] rsp-overflow-y-auto", children: a.buttons.map((o, u) => /* @__PURE__ */ e(
5140
+ /* @__PURE__ */ e("div", { className: "rsp-max-h-[250px] rsp-overflow-y-auto", children: a.buttons.map((g, v) => /* @__PURE__ */ e(
4936
5141
  "div",
4937
5142
  {
4938
- className: `rsp-p-4 rsp-text-center rsp-text-[15px] rsp-text-[#128C7E] rsp-font-medium ${u < a.buttons.length - 1 ? "rsp-border-b rsp-border-gray-300" : ""}`,
5143
+ className: `rsp-p-4 rsp-text-center rsp-text-[15px] rsp-text-[#128C7E] rsp-font-medium ${v < a.buttons.length - 1 ? "rsp-border-b rsp-border-gray-300" : ""}`,
4939
5144
  style: { fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif' },
4940
- children: o.text
5145
+ children: g.text
4941
5146
  },
4942
- o.id
5147
+ g.id
4943
5148
  )) }),
4944
5149
  /* @__PURE__ */ e(
4945
5150
  "div",
@@ -4958,7 +5163,7 @@ function oa({ template: a }) {
4958
5163
  ] }) }) })
4959
5164
  ] });
4960
5165
  }
4961
- const ke = {
5166
+ const Te = {
4962
5167
  name: "",
4963
5168
  category: "MARKETING",
4964
5169
  type: "BASIC",
@@ -4970,76 +5175,73 @@ const ke = {
4970
5175
  footer: "",
4971
5176
  buttons: []
4972
5177
  };
4973
- function ya({ onCancel: a }) {
4974
- var V, R, I;
4975
- const i = (typeof ye == "function" ? ye() : !1) ? Ce() : void 0, [l, d] = B(ke), [p, m] = B(!0), [C, g] = B(!1), [f, y] = B(null), [j, U] = B({
5178
+ function Ua({ onCancel: a }) {
5179
+ var c, p, y;
5180
+ const s = typeof Ne == "function" ? Ne() : !1, i = Ve(), [n, t] = P(Te), [x, l] = P(!0), [k, w] = P(!1), [o, N] = P(!1), [U, f] = P(null), [b, M] = P({
4976
5181
  isOpen: !1
4977
- }), [k, N] = B({
5182
+ });
5183
+ P({
4978
5184
  isOpen: !1
4979
- }), o = () => {
4980
- if (!l.name || !l.body) return !1;
4981
- const x = u(l.body), w = u(l.headerText), L = t(), s = w.every(
4982
- (T) => {
4983
- var c, M, A;
4984
- return !!((A = (M = (c = l.sampleContent) == null ? void 0 : c.headerVariables) == null ? void 0 : M[T]) != null && A.trim());
4985
- }
4986
- ), b = x.every(
4987
- (T) => {
4988
- var c, M, A;
4989
- return !!((A = (M = (c = l.sampleContent) == null ? void 0 : c.bodyVariables) == null ? void 0 : M[T]) != null && A.trim());
4990
- }
4991
- ), E = L.every(
4992
- (T) => {
4993
- var c, M, A;
4994
- return !!((A = (M = (c = l.sampleContent) == null ? void 0 : c.buttonVariables) == null ? void 0 : M[T]) != null && A.trim());
4995
- }
4996
- );
4997
- return s && b && E;
4998
- }, u = (x) => {
4999
- if (!x) return [];
5000
- const w = x.match(/\{\{(\d+)\}\}/g) || [];
5001
- return [...new Set(w.map((L) => L.replace(/[{}]/g, "")))];
5002
- }, t = () => {
5003
- const x = l.buttons.find(
5004
- (L) => L.type === "URL" && L.urlType === "dynamic"
5005
- );
5006
- if (!(x != null && x.value)) return [];
5007
- const w = x.value.match(/\{\{(\d+)\}\}/g) || [];
5008
- return [...new Set(w.map((L) => L.replace(/[{}]/g, "")))];
5009
- };
5010
- se(() => {
5011
- if (f) {
5012
- const x = setTimeout(() => {
5013
- y(null);
5185
+ }), le(() => {
5186
+ if (U) {
5187
+ const u = setTimeout(() => {
5188
+ f(null);
5014
5189
  }, 5e3);
5015
- return () => clearTimeout(x);
5190
+ return () => clearTimeout(u);
5016
5191
  }
5017
- }, [f]);
5018
- const h = async () => {
5019
- var x, w, L;
5192
+ }, [U]);
5193
+ const g = async () => {
5194
+ var u, V, B;
5020
5195
  try {
5021
- if (g(!0), y(null), !l.name || !l.body)
5196
+ if (N(!0), f(null), !n.name || !n.body)
5022
5197
  throw new Error("Template name and body are required");
5023
- const s = localStorage.getItem("account"), b = s ? JSON.parse(s) : { apiKey: "" };
5024
- if (!b.apiKey)
5198
+ const d = localStorage.getItem("account"), E = d ? JSON.parse(d) : { apiKey: "" };
5199
+ if (!E.apiKey)
5025
5200
  throw new Error("Please set your API key in the dashboard first");
5026
- const E = await Ke(b, l);
5027
- if (E.status === "error")
5028
- throw new Error(E.message);
5029
- U({
5201
+ const O = new URLSearchParams(window.location.search).get("edit");
5202
+ let R;
5203
+ if (O) {
5204
+ const _ = await na(E.apiKey, O, n);
5205
+ if (!_.success)
5206
+ throw new Error(_.message || "Update failed");
5207
+ R = {
5208
+ status: "success",
5209
+ data: { details: [{ template_name: n.name, template_id: O }] }
5210
+ };
5211
+ } else if (R = await sa(E, n), R.status === "error")
5212
+ throw new Error(R.message);
5213
+ if (R.status === "error")
5214
+ throw new Error(R.message);
5215
+ M({
5030
5216
  isOpen: !0,
5031
- templateName: (x = E.data) == null ? void 0 : x.details[0].template_name,
5032
- templateId: (w = E.data) == null ? void 0 : w.details[0].template_id,
5033
- // @ts-ignore
5034
- template: (L = E.data) == null ? void 0 : L.template
5035
- }), d(ke);
5036
- } catch (s) {
5037
- y(s instanceof Error ? s.message : "An error occurred while creating the template");
5217
+ templateName: (u = R.data) == null ? void 0 : u.details[0].template_name,
5218
+ templateId: (V = R.data) == null ? void 0 : V.details[0].template_id,
5219
+ template: (B = R.data) == null ? void 0 : B.template
5220
+ }), t(Te);
5221
+ } catch (d) {
5222
+ f(d instanceof Error ? d.message : "An error occurred while creating the template");
5038
5223
  } finally {
5039
- g(!1);
5224
+ N(!1);
5040
5225
  }
5041
- }, v = () => {
5042
- U({ isOpen: !1 }), a ? a() : i ? i("/") : window.history.length > 1 && window.history.back();
5226
+ };
5227
+ le(() => {
5228
+ const V = new URLSearchParams(window.location.search).get("edit");
5229
+ if (!V) return;
5230
+ (async () => {
5231
+ try {
5232
+ const d = localStorage.getItem("account"), E = d ? JSON.parse(d) : { apiKey: "" };
5233
+ if (!E.apiKey)
5234
+ throw new Error("Please set your API key in the dashboard first");
5235
+ const A = await ia(E.apiKey, V);
5236
+ t((O) => ({ ...O, ...A }));
5237
+ } catch (d) {
5238
+ console.error("Failed to load template for edit", d), f(d instanceof Error ? d.message : "Failed to load template");
5239
+ } finally {
5240
+ }
5241
+ })();
5242
+ }, []);
5243
+ const v = () => {
5244
+ M({ isOpen: !1 }), a ? a() : s ? i("/") : window.history.length > 1 && window.history.back();
5043
5245
  };
5044
5246
  return /* @__PURE__ */ r("div", { className: "rsp-min-h-screen rsp-bg-[#f5f7fc] rsp-rounded-lg rsp-shadow-sm", children: [
5045
5247
  /* @__PURE__ */ r("div", { className: "rsp-max-w-[1200px] rsp-mx-auto rsp-px-6 rsp-h-full", children: [
@@ -5050,7 +5252,7 @@ function ya({ onCancel: a }) {
5050
5252
  "button",
5051
5253
  {
5052
5254
  onClick: () => {
5053
- a ? a() : i ? i("/") : window.history.length > 1 && window.history.back();
5255
+ a ? a() : s ? i("/") : window.history.length > 1 && window.history.back();
5054
5256
  },
5055
5257
  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 rsp-transition-colors",
5056
5258
  children: "Cancel"
@@ -5059,22 +5261,22 @@ function ya({ onCancel: a }) {
5059
5261
  /* @__PURE__ */ r(
5060
5262
  "button",
5061
5263
  {
5062
- onClick: () => m(!p),
5264
+ onClick: () => l(!x),
5063
5265
  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
5064
- ${p ? "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"}`,
5266
+ ${x ? "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"}`,
5065
5267
  children: [
5066
5268
  /* @__PURE__ */ r("svg", { className: "rsp-w-4 rsp-h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: [
5067
5269
  /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 12a3 3 0 11-6 0 3 3 0 016 0z" }),
5068
5270
  /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" })
5069
5271
  ] }),
5070
- p ? "Hide Preview" : "Show Preview"
5272
+ x ? "Hide Preview" : "Show Preview"
5071
5273
  ]
5072
5274
  }
5073
5275
  )
5074
5276
  ] })
5075
5277
  ] }) }),
5076
- /* @__PURE__ */ r("div", { className: `rsp-py-8 ${p ? "rsp-grid xl:rsp-grid-cols-[1fr,400px] rsp-gap-8" : ""}`, children: [
5077
- /* @__PURE__ */ r("div", { className: `rsp-space-y-8 ${p ? "" : "rsp-max-w-4xl rsp-mx-auto"}`, children: [
5278
+ /* @__PURE__ */ r("div", { className: `rsp-py-8 ${x ? "rsp-grid xl:rsp-grid-cols-[1fr,400px] rsp-gap-8" : ""}`, children: [
5279
+ /* @__PURE__ */ r("div", { className: `rsp-space-y-8 ${x ? "" : "rsp-max-w-4xl rsp-mx-auto"}`, children: [
5078
5280
  /* @__PURE__ */ r("div", { className: "rsp-bg-white rsp-p-6 rsp-rounded-lg rsp-shadow-sm rsp-space-y-6", children: [
5079
5281
  /* @__PURE__ */ r("div", { children: [
5080
5282
  /* @__PURE__ */ r("label", { className: "rsp-block rsp-text-sm rsp-font-medium rsp-text-gray-700 rsp-mb-2", children: [
@@ -5086,14 +5288,16 @@ function ya({ onCancel: a }) {
5086
5288
  "input",
5087
5289
  {
5088
5290
  type: "text",
5089
- value: l.name,
5090
- onChange: (x) => d({ ...l, name: x.target.value.replace(/\s/g, "_").replace(/[^a-zA-Z0-9_]/g, "").replace(/_+/g, "_") }),
5291
+ value: n.name,
5292
+ onChange: (u) => t({ ...n, name: u.target.value.replace(/\s/g, "_").replace(/[^a-zA-Z0-9_]/g, "").replace(/_+/g, "_") }),
5293
+ onBlur: () => w(!0),
5091
5294
  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",
5092
5295
  placeholder: "Template name cannot Have capital letters and space"
5093
5296
  }
5094
5297
  ),
5095
5298
  /* @__PURE__ */ e("div", { className: "rsp-absolute rsp-bottom-0 rsp-left-0 rsp-w-4 rsp-h-0.5 rsp-bg-red-500" })
5096
5299
  ] }),
5300
+ !n.name && k && /* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-red-600 rsp-mt-1", children: "Template name is required." }),
5097
5301
  /* @__PURE__ */ e("p", { className: "rsp-text-xs rsp-text-gray-500 rsp-mt-1", children: "Template name cannot Have capital letters and space" })
5098
5302
  ] }),
5099
5303
  /* @__PURE__ */ r("div", { className: "rsp-grid rsp-grid-cols-2 rsp-gap-6", children: [
@@ -5103,8 +5307,8 @@ function ya({ onCancel: a }) {
5103
5307
  /* @__PURE__ */ r(
5104
5308
  "select",
5105
5309
  {
5106
- value: l.category,
5107
- onChange: (x) => d({ ...l, category: x.target.value }),
5310
+ value: n.category,
5311
+ onChange: (u) => t({ ...n, category: u.target.value }),
5108
5312
  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",
5109
5313
  children: [
5110
5314
  /* @__PURE__ */ e("option", { value: "MARKETING", children: "Marketing" }),
@@ -5123,10 +5327,10 @@ function ya({ onCancel: a }) {
5123
5327
  /* @__PURE__ */ e(
5124
5328
  "select",
5125
5329
  {
5126
- value: l.language,
5127
- onChange: (x) => d({ ...l, language: x.target.value }),
5330
+ value: n.language,
5331
+ onChange: (u) => t({ ...n, language: u.target.value }),
5128
5332
  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",
5129
- children: Qe.map((x) => /* @__PURE__ */ e("option", { value: x.value, children: x.label }, x.value))
5333
+ children: ta.map((u) => /* @__PURE__ */ e("option", { value: u.value, children: u.label }, u.value))
5130
5334
  }
5131
5335
  ),
5132
5336
  /* @__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" }) }) }),
@@ -5141,12 +5345,12 @@ function ya({ onCancel: a }) {
5141
5345
  /* @__PURE__ */ r(
5142
5346
  "select",
5143
5347
  {
5144
- value: l.type,
5145
- onChange: (x) => {
5146
- const w = x.target.value;
5147
- w === "CAROUSEL" && !l.carousel ? d({
5148
- ...l,
5149
- type: w,
5348
+ value: n.type,
5349
+ onChange: (u) => {
5350
+ const V = u.target.value;
5351
+ V === "CAROUSEL" && !n.carousel ? t({
5352
+ ...n,
5353
+ type: V,
5150
5354
  carousel: {
5151
5355
  type: "IMAGE",
5152
5356
  cards: [{
@@ -5158,7 +5362,7 @@ function ya({ onCancel: a }) {
5158
5362
  buttons: []
5159
5363
  }]
5160
5364
  }
5161
- }) : d({ ...l, type: w });
5365
+ }) : t({ ...n, type: V });
5162
5366
  },
5163
5367
  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",
5164
5368
  children: [
@@ -5177,8 +5381,8 @@ function ya({ onCancel: a }) {
5177
5381
  /* @__PURE__ */ r(
5178
5382
  "select",
5179
5383
  {
5180
- value: l.enableClickTracking.toString(),
5181
- onChange: (x) => d({ ...l, enableClickTracking: x.target.value === "true" }),
5384
+ value: n.enableClickTracking.toString(),
5385
+ onChange: (u) => t({ ...n, enableClickTracking: u.target.value === "true" }),
5182
5386
  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",
5183
5387
  children: [
5184
5388
  /* @__PURE__ */ e("option", { value: "false", children: "False" }),
@@ -5191,70 +5395,73 @@ function ya({ onCancel: a }) {
5191
5395
  ] })
5192
5396
  ] })
5193
5397
  ] }),
5194
- /* @__PURE__ */ e("div", { className: "rsp-bg-white rsp-p-6 rsp-rounded-lg rsp-shadow-sm", children: /* @__PURE__ */ e(da, { template: l, setTemplate: d }) }),
5398
+ /* @__PURE__ */ e("div", { className: "rsp-bg-white rsp-p-6 rsp-rounded-lg rsp-shadow-sm", children: /* @__PURE__ */ e(ka, { template: n, setTemplate: t }) }),
5195
5399
  /* @__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: [
5196
- f && /* @__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: [
5197
- /* @__PURE__ */ e(ce, { className: "rsp-w-5 rsp-h-5 rsp-text-red-500 rsp-flex-shrink-0 rsp-mt-0.5" }),
5400
+ U && /* @__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: [
5401
+ /* @__PURE__ */ e(fe, { className: "rsp-w-5 rsp-h-5 rsp-text-red-500 rsp-flex-shrink-0 rsp-mt-0.5" }),
5198
5402
  /* @__PURE__ */ r("div", { children: [
5199
5403
  /* @__PURE__ */ e("h3", { className: "rsp-text-sm rsp-font-medium rsp-text-red-800", children: "Error" }),
5200
- /* @__PURE__ */ e("p", { className: "rsp-mt-1 rsp-text-sm rsp-text-red-700", children: f })
5404
+ /* @__PURE__ */ e("p", { className: "rsp-mt-1 rsp-text-sm rsp-text-red-700", children: U })
5201
5405
  ] }),
5202
5406
  /* @__PURE__ */ e(
5203
5407
  "button",
5204
5408
  {
5205
- onClick: () => y(null),
5409
+ onClick: () => f(null),
5206
5410
  className: "rsp-absolute rsp-top-2 rsp-right-2 rsp-p-1 hover:rsp-bg-red-100 rsp-rounded-full",
5207
- children: /* @__PURE__ */ e(ee, { className: "rsp-w-4 rsp-h-4 rsp-text-red-500" })
5411
+ children: /* @__PURE__ */ e(re, { className: "rsp-w-4 rsp-h-4 rsp-text-red-500" })
5208
5412
  }
5209
5413
  )
5210
5414
  ] }),
5211
5415
  /* @__PURE__ */ e("div", { className: "rsp-flex rsp-gap-4", children: /* @__PURE__ */ e(
5212
5416
  "button",
5213
5417
  {
5214
- onClick: h,
5215
- disabled: C || !o(),
5418
+ onClick: g,
5419
+ disabled: o,
5216
5420
  className: `rsp-flex-1 rsp-py-3 rsp-px-6 rsp-rounded-md rsp-transition-colors rsp-text-white rsp-font-medium rsp-text-sm
5217
- ${C || !o() ? "rsp-bg-blue-600 rsp-cursor-not-allowed" : "rsp-bg-blue-600 hover:rsp-bg-blue-700 active:rsp-bg-blue-800"}`,
5218
- children: C ? "Submitting for Approval..." : "Submit for Approval"
5421
+ ${o ? "rsp-bg-blue-600 rsp-cursor-not-allowed" : "rsp-bg-blue-600 hover:rsp-bg-blue-700 active:rsp-bg-blue-800"}`,
5422
+ children: (() => {
5423
+ const u = new URLSearchParams(window.location.search).get("edit");
5424
+ return o ? u ? "Resubmitting for Approval..." : "Submitting for Approval..." : u ? "Resubmit for Approval" : "Submit for Approval";
5425
+ })()
5219
5426
  }
5220
5427
  ) })
5221
5428
  ] })
5222
5429
  ] }),
5223
- p && /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e("div", { className: "rsp-sticky rsp-top-4", children: /* @__PURE__ */ e(oa, { template: l }) }) })
5430
+ x && /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e("div", { className: "rsp-sticky rsp-top-4", children: /* @__PURE__ */ e(Ea, { template: n }) }) })
5224
5431
  ] })
5225
5432
  ] }),
5226
5433
  /* @__PURE__ */ e(
5227
- pe,
5434
+ te,
5228
5435
  {
5229
- isOpen: j.isOpen,
5436
+ isOpen: b.isOpen,
5230
5437
  onClose: v,
5231
5438
  title: "Success",
5232
5439
  children: /* @__PURE__ */ r("div", { className: "rsp-space-y-4", children: [
5233
5440
  /* @__PURE__ */ e("div", { className: "rsp-text-center", children: /* @__PURE__ */ e("p", { className: "rsp-text-green-600 rsp-font-medium rsp-mb-4", children: "Template created successfully!" }) }),
5234
- j.templateId && /* @__PURE__ */ r("div", { className: "rsp-bg-gray-50 rsp-p-4 rsp-rounded-lg rsp-space-y-2", children: [
5441
+ b.templateId && /* @__PURE__ */ r("div", { className: "rsp-bg-gray-50 rsp-p-4 rsp-rounded-lg rsp-space-y-2", children: [
5235
5442
  /* @__PURE__ */ r("div", { className: "rsp-flex rsp-justify-between", children: [
5236
5443
  /* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-text-gray-600", children: "Template Name:" }),
5237
- /* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-font-medium", children: j.templateName })
5444
+ /* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-font-medium", children: b.templateName })
5238
5445
  ] }),
5239
5446
  /* @__PURE__ */ r("div", { className: "rsp-flex rsp-justify-between", children: [
5240
5447
  /* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-text-gray-600", children: "Template ID:" }),
5241
- /* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-font-medium rsp-font-mono", children: j.templateId })
5448
+ /* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-font-medium rsp-font-mono", children: b.templateId })
5242
5449
  ] }),
5243
- ((V = j.template) == null ? void 0 : V.meta_tid) && /* @__PURE__ */ r("div", { className: "rsp-flex rsp-justify-between", children: [
5450
+ ((c = b.template) == null ? void 0 : c.meta_tid) && /* @__PURE__ */ r("div", { className: "rsp-flex rsp-justify-between", children: [
5244
5451
  /* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-text-gray-600", children: "Meta TID:" }),
5245
- /* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-font-medium rsp-font-mono", children: j.template.meta_tid })
5452
+ /* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-font-medium rsp-font-mono", children: b.template.meta_tid })
5246
5453
  ] }),
5247
- ((R = j.template) == null ? void 0 : R.status) && /* @__PURE__ */ r("div", { className: "rsp-flex rsp-justify-between", children: [
5454
+ ((p = b.template) == null ? void 0 : p.status) && /* @__PURE__ */ r("div", { className: "rsp-flex rsp-justify-between", children: [
5248
5455
  /* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-text-gray-600", children: "Status:" }),
5249
5456
  /* @__PURE__ */ e("span", { className: `rsp-text-sm rsp-font-medium rsp-capitalize ${// @ts-ignore
5250
- j.template.status === "pending" ? "rsp-text-yellow-600" : (
5457
+ b.template.status === "pending" ? "rsp-text-yellow-600" : (
5251
5458
  // @ts-ignore
5252
- j.template.status === "approved" ? "rsp-text-green-600" : "rsp-text-red-600"
5253
- )}`, children: j.template.status })
5459
+ b.template.status === "approved" ? "rsp-text-green-600" : "rsp-text-red-600"
5460
+ )}`, children: b.template.status })
5254
5461
  ] }),
5255
- ((I = j.template) == null ? void 0 : I.quality) && /* @__PURE__ */ r("div", { className: "rsp-flex rsp-justify-between", children: [
5462
+ ((y = b.template) == null ? void 0 : y.quality) && /* @__PURE__ */ r("div", { className: "rsp-flex rsp-justify-between", children: [
5256
5463
  /* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-text-gray-600", children: "Quality:" }),
5257
- /* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-font-medium rsp-capitalize", children: j.template.quality })
5464
+ /* @__PURE__ */ e("span", { className: "rsp-text-sm rsp-font-medium rsp-capitalize", children: b.template.quality })
5258
5465
  ] })
5259
5466
  ] })
5260
5467
  ] })
@@ -5262,18 +5469,43 @@ function ya({ onCancel: a }) {
5262
5469
  )
5263
5470
  ] });
5264
5471
  }
5265
- const fa = Se({});
5266
- function wa({ apiKey: a, children: n }) {
5267
- const i = Ne(() => ({ apiKey: a }), [a]);
5268
- if (a)
5472
+ const Ma = Pe({});
5473
+ function Aa({ apiKey: a, pConfig: s, children: i }) {
5474
+ const n = Se(
5475
+ () => ({ apiKey: a, resulMeta: s }),
5476
+ [a, s]
5477
+ ), t = Le(null);
5478
+ return le(() => {
5479
+ if (typeof window > "u" || a === void 0 && !s)
5480
+ return;
5481
+ let x = {};
5269
5482
  try {
5270
- localStorage.setItem("account", JSON.stringify({ apiKey: a }));
5271
- } catch {
5483
+ const w = localStorage.getItem("account");
5484
+ w && (x = JSON.parse(w));
5485
+ } catch (w) {
5486
+ console.error(
5487
+ "TrustSignalProvider: Failed to read account from storage",
5488
+ w
5489
+ );
5272
5490
  }
5273
- return /* @__PURE__ */ e(fa.Provider, { value: i, children: n });
5491
+ const l = {
5492
+ ...x,
5493
+ ...a !== void 0 ? { apiKey: a } : {},
5494
+ ...s ? { resulMeta: s } : {}
5495
+ }, k = JSON.stringify(l);
5496
+ if (k !== t.current)
5497
+ try {
5498
+ localStorage.setItem("account", k), t.current = k;
5499
+ } catch (w) {
5500
+ console.error(
5501
+ "TrustSignalProvider: Failed to persist account to storage",
5502
+ w
5503
+ );
5504
+ }
5505
+ }, [a, s]), /* @__PURE__ */ e(Ma.Provider, { value: n, children: i });
5274
5506
  }
5275
5507
  export {
5276
- ya as CreateTemplate,
5277
- ga as Dashboard,
5278
- wa as TrustSignalProvider
5508
+ Ua as CreateTemplate,
5509
+ Va as Dashboard,
5510
+ Aa as TrustSignalProvider
5279
5511
  };