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