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