@enerex/template-studio 1.1.44 → 1.1.46

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,6 +1,6 @@
1
- import { jsx as t, jsxs as d, Fragment as ye } from "react/jsx-runtime";
2
- import G, { useContext as ke, useEffect as L, useState as C, useRef as te, useCallback as Se, createContext as He, memo as ze, useMemo as ae } from "react";
3
- import { QueryClient as Ge, QueryClientProvider as We, useQuery as ge, useMutation as ce, useQueryClient as Ye } from "@tanstack/react-query";
1
+ import { jsx as t, jsxs as d, Fragment as ge } from "react/jsx-runtime";
2
+ import G, { useContext as ke, useEffect as L, useState as x, useRef as te, useCallback as Se, createContext as He, memo as ze, useMemo as ae } from "react";
3
+ import { QueryClient as Ge, QueryClientProvider as We, useQuery as ye, useMutation as ce, useQueryClient as Ye } from "@tanstack/react-query";
4
4
  import we from "axios";
5
5
  import { Spinner as Qe } from "react-bootstrap";
6
6
  import { Controller as Xe, useForm as Je } from "react-hook-form";
@@ -13,10 +13,10 @@ const Fe = G.createContext(
13
13
  }) => {
14
14
  const [r, a] = G.useState(n.clientId), [i, s] = G.useState(n.apiKey), [l, o] = G.useState(
15
15
  n.enerexIdentifier
16
- ), [c, v] = G.useState(n.projectId), [E, I] = G.useState(n.userEmail), [b, x] = G.useState(n.isAdmin), [u, p] = G.useState(n.meBaseUrl), [T, h] = G.useState(
16
+ ), [c, v] = G.useState(n.projectId), [S, I] = G.useState(n.userEmail), [w, E] = G.useState(n.isAdmin), [m, p] = G.useState(n.meBaseUrl), [N, h] = G.useState(
17
17
  n.defaultSelector
18
- ), y = (g) => {
19
- s(g.apiKey), a(g.clientId), v(g.projectId), o(g.enerexIdentifier), I(g.userEmail), x(g.isAdmin), h(g.defaultSelector), p(g.meBaseUrl);
18
+ ), g = (y) => {
19
+ s(y.apiKey), a(y.clientId), v(y.projectId), o(y.enerexIdentifier), I(y.userEmail), E(y.isAdmin), h(y.defaultSelector), p(y.meBaseUrl);
20
20
  };
21
21
  return /* @__PURE__ */ t(
22
22
  Fe.Provider,
@@ -24,13 +24,13 @@ const Fe = G.createContext(
24
24
  value: {
25
25
  clientId: r,
26
26
  apiKey: i,
27
- setConfiguration: y,
27
+ setConfiguration: g,
28
28
  enerexIdentifier: l,
29
29
  projectId: c,
30
- userEmail: E,
31
- isAdmin: b,
32
- defaultSelector: T,
33
- meBaseUrl: u
30
+ userEmail: S,
31
+ isAdmin: w,
32
+ defaultSelector: N,
33
+ meBaseUrl: m
34
34
  },
35
35
  children: e
36
36
  }
@@ -52,7 +52,7 @@ const Fe = G.createContext(
52
52
  /* @__PURE__ */ t("span", { className: "ts-toast-message", children: e }),
53
53
  /* @__PURE__ */ t("button", { className: "ts-toast-close", onClick: a, children: "×" })
54
54
  ] })), tt = () => {
55
- const [e, n] = C(null), r = te(null);
55
+ const [e, n] = x(null), r = te(null);
56
56
  return { showNotification: Se(
57
57
  (s, l = "info") => {
58
58
  r.current !== s && (r.current = s, n({ message: s, type: l }));
@@ -156,7 +156,7 @@ const Fe = G.createContext(
156
156
  duplicateTemplate: "/Template/DuplicateTemplate/"
157
157
  }, at = () => {
158
158
  const e = Y(), { enerexIdentifier: n, projectId: r } = V();
159
- return ge({
159
+ return ye({
160
160
  queryKey: ["getTemplatesList"],
161
161
  queryFn: async (i) => await e.get(
162
162
  `${Q.Template_list}${r}/${n}`
@@ -167,7 +167,7 @@ const Fe = G.createContext(
167
167
  });
168
168
  }, it = () => {
169
169
  const e = Y(), { enerexIdentifier: n, projectId: r } = V();
170
- return ge({
170
+ return ye({
171
171
  queryKey: ["getTemplateTypes"],
172
172
  queryFn: async (i) => await e.get(
173
173
  `${Q.TemplateTypes}${n}/${r}`
@@ -306,7 +306,7 @@ const ct = (e) => {
306
306
  )
307
307
  }
308
308
  );
309
- function ut({
309
+ function mt({
310
310
  template: e,
311
311
  openActionId: n,
312
312
  setOpenActionId: r,
@@ -316,47 +316,47 @@ function ut({
316
316
  onPreview: l,
317
317
  onRefresh: o
318
318
  }) {
319
- const { isAdmin: c } = V(), v = n === e.id, E = te(null), I = te(null), [b, x, u] = e.categoryChain, { mutateAsync: p, isPending: T } = Ue(), { showNotification: h } = ve(), y = x?.key, g = u?.key, R = !c && y === 9, B = c || g !== 2, _ = c || g !== 2;
319
+ const { isAdmin: c } = V(), v = n === e.id, S = te(null), I = te(null), [w, E, m] = e.categoryChain, { mutateAsync: p, isPending: N } = Ue(), { showNotification: h } = ve(), g = E?.key, y = m?.key, R = !c && g === 9, B = c || y !== 2, _ = c || y !== 2;
320
320
  L(() => {
321
- function S(D) {
322
- v && E.current && !E.current.contains(D.target) && !I.current?.contains(D.target) && r(null);
321
+ function b(D) {
322
+ v && S.current && !S.current.contains(D.target) && !I.current?.contains(D.target) && r(null);
323
323
  }
324
- return document.addEventListener("mousedown", S), () => document.removeEventListener("mousedown", S);
324
+ return document.addEventListener("mousedown", b), () => document.removeEventListener("mousedown", b);
325
325
  }, [v, r]), L(() => {
326
- function S(D) {
326
+ function b(D) {
327
327
  D.key === "Escape" && r(null);
328
328
  }
329
- return v && document.addEventListener("keydown", S), () => document.removeEventListener("keydown", S);
329
+ return v && document.addEventListener("keydown", b), () => document.removeEventListener("keydown", b);
330
330
  }, [v, r]), L(() => {
331
- if (!v || !E.current) return;
332
- const S = Array.from(
333
- E.current.querySelectorAll('[role="menuitem"]')
331
+ if (!v || !S.current) return;
332
+ const b = Array.from(
333
+ S.current.querySelectorAll('[role="menuitem"]')
334
334
  );
335
- if (!S.length) return;
335
+ if (!b.length) return;
336
336
  let D = 0;
337
- S[0].focus();
338
- function M(w) {
339
- w.key === "ArrowDown" && (D = (D + 1) % S.length, S[D].focus(), w.preventDefault()), w.key === "ArrowUp" && (D = (D - 1 + S.length) % S.length, S[D].focus(), w.preventDefault());
337
+ b[0].focus();
338
+ function M(T) {
339
+ T.key === "ArrowDown" && (D = (D + 1) % b.length, b[D].focus(), T.preventDefault()), T.key === "ArrowUp" && (D = (D - 1 + b.length) % b.length, b[D].focus(), T.preventDefault());
340
340
  }
341
341
  return document.addEventListener("keydown", M), () => document.removeEventListener("keydown", M);
342
342
  }, [v]);
343
343
  const A = async () => {
344
344
  try {
345
345
  await p({
346
- categoryId: g?.toString() ?? "",
346
+ categoryId: y?.toString() ?? "",
347
347
  templateId: e.id ?? ""
348
348
  }), o(), h(
349
349
  `Template "${e?.name}" marked as favourite`,
350
350
  "success"
351
351
  );
352
- } catch (S) {
353
- console.error(S), h(
352
+ } catch (b) {
353
+ console.error(b), h(
354
354
  "Unable to mark template as favourite. Please try again.",
355
355
  "error"
356
356
  );
357
357
  }
358
358
  };
359
- return /* @__PURE__ */ t(ye, { children: /* @__PURE__ */ d("tr", { className: "ts-table-row", children: [
359
+ return /* @__PURE__ */ t(ge, { children: /* @__PURE__ */ d("tr", { className: "ts-table-row", children: [
360
360
  /* @__PURE__ */ d("td", { children: [
361
361
  " ",
362
362
  /* @__PURE__ */ d("div", { className: "ts-name-cell", children: [
@@ -368,7 +368,7 @@ function ut({
368
368
  disabled: e.is_favourite,
369
369
  onClick: A,
370
370
  title: "Mark as favourite",
371
- children: T ? /* @__PURE__ */ t(ie, { size: "sm" }) : e.is_favourite ? /* @__PURE__ */ t(Le, { variant: "filled" }) : /* @__PURE__ */ t(Le, { variant: "outlined" })
371
+ children: N ? /* @__PURE__ */ t(ie, { size: "sm" }) : e.is_favourite ? /* @__PURE__ */ t(Le, { variant: "filled" }) : /* @__PURE__ */ t(Le, { variant: "outlined" })
372
372
  }
373
373
  ),
374
374
  /* @__PURE__ */ t(
@@ -382,9 +382,9 @@ function ut({
382
382
  ] }),
383
383
  /* @__PURE__ */ t("td", { children: /* @__PURE__ */ t("div", { className: "", children: /* @__PURE__ */ t("span", { className: "ts-template-name", children: e.name }) }) }),
384
384
  c && /* @__PURE__ */ t("td", { children: e?.id ?? "" }),
385
- /* @__PURE__ */ t("td", { children: b?.name ?? "" }),
386
- /* @__PURE__ */ t("td", { children: x?.name ?? "" }),
387
- /* @__PURE__ */ t("td", { children: u?.name ?? "" }),
385
+ /* @__PURE__ */ t("td", { children: w?.name ?? "" }),
386
+ /* @__PURE__ */ t("td", { children: E?.name ?? "" }),
387
+ /* @__PURE__ */ t("td", { children: m?.name ?? "" }),
388
388
  c && /* @__PURE__ */ t("td", { children: e?.companyName ?? "" }),
389
389
  /* @__PURE__ */ t("td", { children: e?.updatedByName ?? "" }),
390
390
  /* @__PURE__ */ t("td", { children: ct(e.updatedDateTime) }),
@@ -403,54 +403,54 @@ function ut({
403
403
  /* @__PURE__ */ d(
404
404
  "div",
405
405
  {
406
- ref: E,
406
+ ref: S,
407
407
  className: `ts-actions-menu ${v ? "open" : ""}`,
408
408
  role: "menu",
409
409
  children: [
410
410
  /* @__PURE__ */ t(
411
- "button",
411
+ "a",
412
412
  {
413
- type: "button",
413
+ href: "#",
414
414
  role: "menuitem",
415
415
  className: "ts-menu-item",
416
- onClick: () => {
417
- r(null), l(e);
416
+ onClick: (b) => {
417
+ b.preventDefault(), r(null), l(e);
418
418
  },
419
419
  children: "Preview"
420
420
  }
421
421
  ),
422
422
  B && /* @__PURE__ */ t(
423
- "button",
423
+ "a",
424
424
  {
425
- type: "button",
425
+ href: "#",
426
426
  role: "menuitem",
427
427
  className: "ts-menu-item",
428
- onClick: () => {
429
- r(null), a(e);
428
+ onClick: (b) => {
429
+ b.preventDefault(), r(null), a(e);
430
430
  },
431
431
  children: "Edit"
432
432
  }
433
433
  ),
434
434
  /* @__PURE__ */ t(
435
- "button",
435
+ "a",
436
436
  {
437
- type: "button",
437
+ href: "#",
438
438
  role: "menuitem",
439
439
  className: "ts-menu-item",
440
- onClick: () => {
441
- r(null), i(e);
440
+ onClick: (b) => {
441
+ b.preventDefault(), r(null), i(e);
442
442
  },
443
443
  children: "Duplicate"
444
444
  }
445
445
  ),
446
446
  _ && /* @__PURE__ */ t(
447
- "button",
447
+ "a",
448
448
  {
449
- type: "button",
449
+ href: "#",
450
450
  role: "menuitem",
451
451
  className: "ts-menu-item danger",
452
- onClick: () => {
453
- r(null), s(e);
452
+ onClick: (b) => {
453
+ b.preventDefault(), r(null), s(e);
454
454
  },
455
455
  children: "Remove"
456
456
  }
@@ -461,7 +461,7 @@ function ut({
461
461
  ] }) })
462
462
  ] }) });
463
463
  }
464
- const mt = ze(ut), pt = (e) => /* @__PURE__ */ t(
464
+ const ut = ze(mt), pt = (e) => /* @__PURE__ */ t(
465
465
  "svg",
466
466
  {
467
467
  xmlns: "http://www.w3.org/2000/svg",
@@ -525,17 +525,17 @@ const mt = ze(ut), pt = (e) => /* @__PURE__ */ t(
525
525
  onPageChange: a,
526
526
  onPageSizeChange: i
527
527
  }) => {
528
- const s = Math.ceil(r / n), o = s <= Ce ? Array.from({ length: s }, (u, p) => p + 1) : Array.from({ length: Ce }, (u, p) => p + 1), c = s > Ce, v = s, { showNotification: E } = ve(), [I, b] = C(String(e));
528
+ const s = Math.ceil(r / n), o = s <= Ce ? Array.from({ length: s }, (m, p) => p + 1) : Array.from({ length: Ce }, (m, p) => p + 1), c = s > Ce, v = s, { showNotification: S } = ve(), [I, w] = x(String(e));
529
529
  L(() => {
530
- b(String(e));
530
+ w(String(e));
531
531
  }, [e]);
532
- const x = () => {
533
- const u = Number(I);
534
- if (!u || u < 1 || u > s) {
535
- E("Page out of range", "error"), b(String(e));
532
+ const E = () => {
533
+ const m = Number(I);
534
+ if (!m || m < 1 || m > s) {
535
+ S("Page out of range", "error"), w(String(e));
536
536
  return;
537
537
  }
538
- a(u);
538
+ a(m);
539
539
  };
540
540
  return /* @__PURE__ */ d("div", { className: "ts-pagination-bar", children: [
541
541
  /* @__PURE__ */ d("div", { className: "ts-page-container", children: [
@@ -545,10 +545,10 @@ const mt = ze(ut), pt = (e) => /* @__PURE__ */ t(
545
545
  "select",
546
546
  {
547
547
  value: n,
548
- onChange: (u) => {
549
- i(Number(u.target.value)), a(1);
548
+ onChange: (m) => {
549
+ i(Number(m.target.value)), a(1);
550
550
  },
551
- children: [10, 25, 50, 100].map((u) => /* @__PURE__ */ t("option", { value: u, children: u }, u))
551
+ children: [10, 25, 50, 100].map((m) => /* @__PURE__ */ t("option", { value: m, children: m }, m))
552
552
  }
553
553
  )
554
554
  ] }),
@@ -567,10 +567,10 @@ const mt = ze(ut), pt = (e) => /* @__PURE__ */ t(
567
567
  {
568
568
  type: "number",
569
569
  value: I,
570
- onChange: (u) => b(u.target.value),
571
- onBlur: x,
572
- onKeyDown: (u) => {
573
- u.key === "Enter" && x();
570
+ onChange: (m) => w(m.target.value),
571
+ onBlur: E,
572
+ onKeyDown: (m) => {
573
+ m.key === "Enter" && E();
574
574
  }
575
575
  }
576
576
  )
@@ -583,14 +583,14 @@ const mt = ze(ut), pt = (e) => /* @__PURE__ */ t(
583
583
  ] }),
584
584
  /* @__PURE__ */ d("div", { className: "ts-page-buttons", children: [
585
585
  /* @__PURE__ */ t("button", { disabled: e === 1, onClick: () => a(e - 1), children: "‹" }),
586
- o.map((u) => /* @__PURE__ */ t(
586
+ o.map((m) => /* @__PURE__ */ t(
587
587
  "button",
588
588
  {
589
- className: u === e ? "active" : "",
590
- onClick: () => a(u),
591
- children: u
589
+ className: m === e ? "active" : "",
590
+ onClick: () => a(m),
591
+ children: m
592
592
  },
593
- u
593
+ m
594
594
  )),
595
595
  c && /* @__PURE__ */ t("span", { style: { padding: "0 6px" }, children: "…" }),
596
596
  c && /* @__PURE__ */ t(
@@ -611,7 +611,7 @@ const mt = ze(ut), pt = (e) => /* @__PURE__ */ t(
611
611
  )
612
612
  ] })
613
613
  ] });
614
- }, yt = ({
614
+ }, gt = ({
615
615
  show: e,
616
616
  variant: n,
617
617
  title: r = "Are you sure?",
@@ -622,25 +622,25 @@ const mt = ze(ut), pt = (e) => /* @__PURE__ */ t(
622
622
  requiredMessage: o = "This field is required",
623
623
  externalError: c = !1,
624
624
  externalErrorMessage: v = "",
625
- confirmText: E = "Ok",
625
+ confirmText: S = "Ok",
626
626
  cancelText: I = "Cancel",
627
- confirmButtonVariant: b = "danger",
628
- disableConfirm: x = !1,
629
- onConfirm: u,
627
+ confirmButtonVariant: w = "danger",
628
+ disableConfirm: E = !1,
629
+ onConfirm: m,
630
630
  onCancel: p,
631
- onInputChange: T
631
+ onInputChange: N
632
632
  }) => {
633
- const [h, y] = C(s), [g, R] = C(!1), B = te(null);
633
+ const [h, g] = x(s), [y, R] = x(!1), B = te(null);
634
634
  if (L(() => {
635
635
  if (!e) return;
636
- const M = (w) => {
637
- w.key === "Escape" && p();
636
+ const M = (T) => {
637
+ T.key === "Escape" && p();
638
638
  };
639
639
  return document.addEventListener("keydown", M), () => document.removeEventListener("keydown", M);
640
640
  }, [e, p]), L(() => {
641
641
  if (!e) return;
642
- const M = (w) => {
643
- B.current && !B.current.contains(w.target) && p();
642
+ const M = (T) => {
643
+ B.current && !B.current.contains(T.target) && p();
644
644
  };
645
645
  return document.addEventListener("mousedown", M), () => document.removeEventListener("mousedown", M);
646
646
  }, [e, p]), L(() => {
@@ -649,16 +649,16 @@ const mt = ze(ut), pt = (e) => /* @__PURE__ */ t(
649
649
  document.body.style.overflow = "";
650
650
  };
651
651
  }, [e]), L(() => {
652
- e && (y(s), R(!1));
652
+ e && (g(s), R(!1));
653
653
  }, [e, s]), L(() => {
654
654
  c && R(!0);
655
655
  }, [c]), !e) return null;
656
- const _ = n === "input" && !h.trim(), A = n === "input" && (_ || c), S = _ ? o : c ? v : "", D = () => {
657
- if (A || x) {
656
+ const _ = n === "input" && !h.trim(), A = n === "input" && (_ || c), b = _ ? o : c ? v : "", D = () => {
657
+ if (A || E) {
658
658
  R(!0);
659
659
  return;
660
660
  }
661
- u(h.trim());
661
+ m(h.trim());
662
662
  };
663
663
  return /* @__PURE__ */ t("div", { className: "ts-modal-overlay", children: /* @__PURE__ */ d("div", { ref: B, className: "ts-modal", children: [
664
664
  /* @__PURE__ */ d("div", { className: "ts-modal-header", children: [
@@ -676,17 +676,17 @@ const mt = ze(ut), pt = (e) => /* @__PURE__ */ t(
676
676
  "input",
677
677
  {
678
678
  type: "text",
679
- className: `ts-input ${g && A ? "ts-input-error" : ""}`,
679
+ className: `ts-input ${y && A ? "ts-input-error" : ""}`,
680
680
  placeholder: l,
681
681
  value: h,
682
682
  onChange: (M) => {
683
- y(M.target.value), g && R(!1), T?.(M.target.value);
683
+ g(M.target.value), y && R(!1), N?.(M.target.value);
684
684
  },
685
685
  autoFocus: !0,
686
686
  style: { paddingBlock: "0", paddingInline: "0" }
687
687
  }
688
688
  ),
689
- g && A && /* @__PURE__ */ t("div", { className: "ts-error-text", children: S })
689
+ y && A && /* @__PURE__ */ t("div", { className: "ts-error-text", children: b })
690
690
  ] })
691
691
  ] }),
692
692
  /* @__PURE__ */ d("div", { className: "ts-modal-footer", children: [
@@ -703,15 +703,15 @@ const mt = ze(ut), pt = (e) => /* @__PURE__ */ t(
703
703
  "button",
704
704
  {
705
705
  type: "button",
706
- className: `ts-btn ts-btn-${b}`,
706
+ className: `ts-btn ts-btn-${w}`,
707
707
  onClick: D,
708
- disabled: x,
709
- children: E
708
+ disabled: E,
709
+ children: S
710
710
  }
711
711
  )
712
712
  ] })
713
713
  ] }) });
714
- }, gt = () => /* @__PURE__ */ t(
714
+ }, yt = () => /* @__PURE__ */ t(
715
715
  "svg",
716
716
  {
717
717
  xmlns: "http://www.w3.org/2000/svg",
@@ -757,105 +757,105 @@ const mt = ze(ut), pt = (e) => /* @__PURE__ */ t(
757
757
  onEdit: i,
758
758
  onPreview: s
759
759
  }) => {
760
- const { isAdmin: l } = V(), { mutateAsync: o, isPending: c } = vt(), { mutateAsync: v, isPending: E } = bt(), [I, b] = C(""), [x, u] = C(""), [p, T] = C(null), [h, y] = C(e), [g, R] = C(n), [B, _] = C(!1), [A, S] = C("input"), [D, M] = C(!1), [w, ne] = C(null), [U, W] = C("asc"), K = (m) => {
761
- w === m ? W((N) => N === "asc" ? "desc" : "asc") : (ne(m), W("asc")), ee(1);
762
- }, [O, re] = C(null);
760
+ const { isAdmin: l } = V(), { mutateAsync: o, isPending: c } = vt(), { mutateAsync: v, isPending: S } = bt(), [I, w] = x(""), [E, m] = x(""), [p, N] = x(null), [h, g] = x(e), [y, R] = x(n), [B, _] = x(!1), [A, b] = x("input"), [D, M] = x(!1), [T, ne] = x(null), [U, W] = x("asc"), K = (u) => {
761
+ T === u ? W((C) => C === "asc" ? "desc" : "asc") : (ne(u), W("asc")), ee(1);
762
+ }, [O, re] = x(null);
763
763
  L(() => {
764
- const m = [...e].sort((N, $) => {
765
- if (!l && N.is_favourite !== $.is_favourite)
766
- return Number($.is_favourite) - Number(N.is_favourite);
767
- const P = new Date($.updatedDateTime).getTime() - new Date(N.updatedDateTime).getTime();
768
- return P !== 0 ? P : N.readonly !== $.readonly ? Number(N.readonly) - Number($.readonly) : N.name.localeCompare($.name);
764
+ const u = [...e].sort((C, $) => {
765
+ if (!l && C.is_favourite !== $.is_favourite)
766
+ return Number($.is_favourite) - Number(C.is_favourite);
767
+ const P = new Date($.updatedDateTime).getTime() - new Date(C.updatedDateTime).getTime();
768
+ return P !== 0 ? P : C.readonly !== $.readonly ? Number(C.readonly) - Number($.readonly) : C.name.localeCompare($.name);
769
769
  });
770
- y(m), ne(null);
770
+ g(u), ne(null);
771
771
  }, [e]), L(() => {
772
- R(n.filter((m) => m.id != null));
772
+ R(n.filter((u) => u.id != null));
773
773
  }, [n]);
774
774
  const le = ae(() => {
775
- const m = /* @__PURE__ */ new Map();
776
- return g.forEach((N) => m.set(N.id, N)), m;
777
- }, [g]), de = Se(
778
- (m) => {
779
- const N = [], $ = /* @__PURE__ */ new Set();
780
- let P = le.get(m);
781
- for (; P && !($.has(P.id) || ($.add(P.id), N.push({ id: P.id, name: P.name, key: P.key }), !P.parent_id)); )
775
+ const u = /* @__PURE__ */ new Map();
776
+ return y.forEach((C) => u.set(C.id, C)), u;
777
+ }, [y]), de = Se(
778
+ (u) => {
779
+ const C = [], $ = /* @__PURE__ */ new Set();
780
+ let P = le.get(u);
781
+ for (; P && !($.has(P.id) || ($.add(P.id), C.push({ id: P.id, name: P.name, key: P.key }), !P.parent_id)); )
782
782
  P = le.get(P.parent_id);
783
- return N.reverse();
783
+ return C.reverse();
784
784
  },
785
785
  [le]
786
- ), Z = ae(() => !h.length || !g.length ? [] : h.map((m) => ({
787
- ...m,
788
- categoryChain: de(m.type)
789
- })), [h, g]);
786
+ ), Z = ae(() => !h.length || !y.length ? [] : h.map((u) => ({
787
+ ...u,
788
+ categoryChain: de(u.type)
789
+ })), [h, y]);
790
790
  L(() => {
791
- const m = setTimeout(() => {
792
- u(I), ee(1);
791
+ const u = setTimeout(() => {
792
+ m(I), ee(1);
793
793
  }, 300);
794
- return () => clearTimeout(m);
794
+ return () => clearTimeout(u);
795
795
  }, [I]);
796
- const [se, H] = C(25), [ue, ee] = C(1), me = ae(() => {
797
- const m = x.trim().toLowerCase();
798
- return m ? Z.filter((N) => {
799
- const $ = N.name.toLowerCase().includes(m), P = N.categoryChain?.some(
800
- (z) => z.name.toLowerCase().includes(m)
796
+ const [se, H] = x(25), [me, ee] = x(1), ue = ae(() => {
797
+ const u = E.trim().toLowerCase();
798
+ return u ? Z.filter((C) => {
799
+ const $ = C.name.toLowerCase().includes(u), P = C.categoryChain?.some(
800
+ (z) => z.name.toLowerCase().includes(u)
801
801
  );
802
802
  return $ || P;
803
803
  }) : Z;
804
- }, [Z, x]), pe = ae(() => {
805
- const m = [...me];
806
- return m.sort((N, $) => {
807
- if (w === "lastUpdatedOn") {
808
- const Ve = new Date(N.updatedDateTime).getTime(), Ke = new Date($.updatedDateTime).getTime(), Pe = Ve - Ke;
804
+ }, [Z, E]), pe = ae(() => {
805
+ const u = [...ue];
806
+ return u.sort((C, $) => {
807
+ if (T === "lastUpdatedOn") {
808
+ const Ve = new Date(C.updatedDateTime).getTime(), Ke = new Date($.updatedDateTime).getTime(), Pe = Ve - Ke;
809
809
  return U === "asc" ? Pe : -Pe;
810
810
  }
811
811
  let P = "", z = "";
812
- switch (w) {
812
+ switch (T) {
813
813
  case "name":
814
- P = N.name, z = $.name;
814
+ P = C.name, z = $.name;
815
815
  break;
816
816
  case "category":
817
- P = N.categoryChain?.[0]?.name ?? "", z = $.categoryChain?.[0]?.name ?? "";
817
+ P = C.categoryChain?.[0]?.name ?? "", z = $.categoryChain?.[0]?.name ?? "";
818
818
  break;
819
819
  case "type":
820
- P = N.categoryChain?.[1]?.name ?? "", z = $.categoryChain?.[1]?.name ?? "";
820
+ P = C.categoryChain?.[1]?.name ?? "", z = $.categoryChain?.[1]?.name ?? "";
821
821
  break;
822
822
  case "subtype":
823
- P = N.categoryChain?.[2]?.name ?? "", z = $.categoryChain?.[2]?.name ?? "";
823
+ P = C.categoryChain?.[2]?.name ?? "", z = $.categoryChain?.[2]?.name ?? "";
824
824
  break;
825
825
  case "templateId":
826
- P = N.id ?? "", z = $.id ?? "";
826
+ P = C.id ?? "", z = $.id ?? "";
827
827
  break;
828
828
  case "companyName":
829
- P = N.companyName ?? "", z = $.companyName ?? "";
829
+ P = C.companyName ?? "", z = $.companyName ?? "";
830
830
  break;
831
831
  case "lastUpdatedBy":
832
- P = N.updatedByName ?? "", z = $.updatedByName ?? "";
832
+ P = C.updatedByName ?? "", z = $.updatedByName ?? "";
833
833
  break;
834
834
  }
835
835
  const De = P.localeCompare(z, void 0, {
836
836
  sensitivity: "base"
837
837
  });
838
838
  return U === "asc" ? De : -De;
839
- }), m;
840
- }, [me, w, U]), { pagedData: be } = wt({
839
+ }), u;
840
+ }, [ue, T, U]), { pagedData: be } = wt({
841
841
  data: pe,
842
- page: ue,
842
+ page: me,
843
843
  pageSize: se
844
844
  }), f = Se(
845
- (m) => h.some(
846
- (N) => N.name.trim().toLowerCase() === m.trim().toLowerCase()
845
+ (u) => h.some(
846
+ (C) => C.name.trim().toLowerCase() === u.trim().toLowerCase()
847
847
  ),
848
848
  [h]
849
- ), k = (m) => {
850
- re(m), M(!1), S("input"), _(!0);
851
- }, F = (m) => {
852
- re(m), S("confirm"), _(!0);
853
- }, { showNotification: j } = ve(), X = async (m) => {
849
+ ), k = (u) => {
850
+ re(u), M(!1), b("input"), _(!0);
851
+ }, F = (u) => {
852
+ re(u), b("confirm"), _(!0);
853
+ }, { showNotification: j } = ve(), X = async (u) => {
854
854
  if (O)
855
855
  try {
856
856
  if (A === "input") {
857
- if (!m) return;
858
- if (f(m)) {
857
+ if (!u) return;
858
+ if (f(u)) {
859
859
  M(!0);
860
860
  return;
861
861
  }
@@ -864,11 +864,11 @@ const mt = ze(ut), pt = (e) => /* @__PURE__ */ t(
864
864
  request: {
865
865
  projectId: "",
866
866
  enerexIdentifier: "",
867
- newName: m,
867
+ newName: u,
868
868
  parent_id: O.id ?? null
869
869
  }
870
870
  }), j(
871
- `Template "${m}" duplicated successfully`,
871
+ `Template "${u}" duplicated successfully`,
872
872
  "success"
873
873
  );
874
874
  }
@@ -883,8 +883,8 @@ const mt = ze(ut), pt = (e) => /* @__PURE__ */ t(
883
883
  );
884
884
  }
885
885
  }, q = O?.categoryChain?.[2]?.name?.toLowerCase() ?? "this", oe = O?.name?.toLowerCase() ?? "";
886
- return /* @__PURE__ */ d(ye, { children: [
887
- (c || E) && /* @__PURE__ */ t(ie, { overlay: !0 }),
886
+ return /* @__PURE__ */ d(ge, { children: [
887
+ (c || S) && /* @__PURE__ */ t(ie, { overlay: !0 }),
888
888
  /* @__PURE__ */ d("div", { className: "ts-page", children: [
889
889
  /* @__PURE__ */ d("div", { className: "ts-header", children: [
890
890
  /* @__PURE__ */ t("h1", { className: "ts-title", children: "Templates" }),
@@ -898,10 +898,10 @@ const mt = ze(ut), pt = (e) => /* @__PURE__ */ t(
898
898
  type: "text",
899
899
  placeholder: "Search...",
900
900
  value: I,
901
- onChange: (m) => b(m.target.value)
901
+ onChange: (u) => w(u.target.value)
902
902
  }
903
903
  ),
904
- /* @__PURE__ */ t("button", { className: "ts-search-btn", "aria-label": "Search", children: /* @__PURE__ */ t(gt, {}) })
904
+ /* @__PURE__ */ t("button", { className: "ts-search-btn", "aria-label": "Search", children: /* @__PURE__ */ t(yt, {}) })
905
905
  ] }) }),
906
906
  /* @__PURE__ */ d("div", { className: "ts-table-wrapper", children: [
907
907
  /* @__PURE__ */ d("table", { className: "ts-table", children: [
@@ -912,7 +912,7 @@ const mt = ze(ut), pt = (e) => /* @__PURE__ */ t(
912
912
  {
913
913
  label: "Name",
914
914
  sortKey: "name",
915
- sortBy: w,
915
+ sortBy: T,
916
916
  sortOrder: U,
917
917
  onSort: K
918
918
  }
@@ -922,7 +922,7 @@ const mt = ze(ut), pt = (e) => /* @__PURE__ */ t(
922
922
  {
923
923
  label: "Template Id",
924
924
  sortKey: "templateId",
925
- sortBy: w,
925
+ sortBy: T,
926
926
  sortOrder: U,
927
927
  onSort: K
928
928
  }
@@ -932,7 +932,7 @@ const mt = ze(ut), pt = (e) => /* @__PURE__ */ t(
932
932
  {
933
933
  label: "Category",
934
934
  sortKey: "category",
935
- sortBy: w,
935
+ sortBy: T,
936
936
  sortOrder: U,
937
937
  onSort: K
938
938
  }
@@ -942,7 +942,7 @@ const mt = ze(ut), pt = (e) => /* @__PURE__ */ t(
942
942
  {
943
943
  label: "Type",
944
944
  sortKey: "type",
945
- sortBy: w,
945
+ sortBy: T,
946
946
  sortOrder: U,
947
947
  onSort: K
948
948
  }
@@ -952,7 +952,7 @@ const mt = ze(ut), pt = (e) => /* @__PURE__ */ t(
952
952
  {
953
953
  label: "Subtype",
954
954
  sortKey: "subtype",
955
- sortBy: w,
955
+ sortBy: T,
956
956
  sortOrder: U,
957
957
  onSort: K
958
958
  }
@@ -962,7 +962,7 @@ const mt = ze(ut), pt = (e) => /* @__PURE__ */ t(
962
962
  {
963
963
  label: "Company Name",
964
964
  sortKey: "companyName",
965
- sortBy: w,
965
+ sortBy: T,
966
966
  sortOrder: U,
967
967
  onSort: K
968
968
  }
@@ -972,7 +972,7 @@ const mt = ze(ut), pt = (e) => /* @__PURE__ */ t(
972
972
  {
973
973
  label: "Last Updated by",
974
974
  sortKey: "lastUpdatedBy",
975
- sortBy: w,
975
+ sortBy: T,
976
976
  sortOrder: U,
977
977
  onSort: K
978
978
  }
@@ -982,32 +982,32 @@ const mt = ze(ut), pt = (e) => /* @__PURE__ */ t(
982
982
  {
983
983
  label: "Last Updated on",
984
984
  sortKey: "lastUpdatedOn",
985
- sortBy: w,
985
+ sortBy: T,
986
986
  sortOrder: U,
987
987
  onSort: K
988
988
  }
989
989
  ),
990
990
  /* @__PURE__ */ t("th", { className: "ts-cursor-default", children: "Actions" })
991
991
  ] }) }),
992
- /* @__PURE__ */ t("tbody", { children: be.map((m) => /* @__PURE__ */ t(
993
- mt,
992
+ /* @__PURE__ */ t("tbody", { children: be.map((u) => /* @__PURE__ */ t(
993
+ ut,
994
994
  {
995
- template: m,
995
+ template: u,
996
996
  openActionId: p,
997
- setOpenActionId: T,
997
+ setOpenActionId: N,
998
998
  onDuplicate: k,
999
999
  onEdit: i,
1000
1000
  onRemove: F,
1001
1001
  onPreview: s,
1002
1002
  onRefresh: r
1003
1003
  },
1004
- m.id
1004
+ u.id
1005
1005
  )) })
1006
1006
  ] }),
1007
1007
  /* @__PURE__ */ t(
1008
1008
  ht,
1009
1009
  {
1010
- page: ue,
1010
+ page: me,
1011
1011
  pageSize: se,
1012
1012
  totalRecords: pe.length,
1013
1013
  onPageChange: ee,
@@ -1018,7 +1018,7 @@ const mt = ze(ut), pt = (e) => /* @__PURE__ */ t(
1018
1018
  ] }) })
1019
1019
  ] }),
1020
1020
  /* @__PURE__ */ t(
1021
- yt,
1021
+ gt,
1022
1022
  {
1023
1023
  show: B,
1024
1024
  variant: A,
@@ -1410,7 +1410,7 @@ const mt = ze(ut), pt = (e) => /* @__PURE__ */ t(
1410
1410
  }), r;
1411
1411
  }, Ct = () => {
1412
1412
  const e = Y(), { enerexIdentifier: n, projectId: r } = V();
1413
- return ge({
1413
+ return ye({
1414
1414
  queryKey: ["getTemplateTags"],
1415
1415
  queryFn: async (i) => await e.get(
1416
1416
  `${Q.MergeTags}${r}/${n}`
@@ -1418,7 +1418,7 @@ const mt = ze(ut), pt = (e) => /* @__PURE__ */ t(
1418
1418
  });
1419
1419
  }, xt = () => {
1420
1420
  const e = Y(), { enerexIdentifier: n, projectId: r } = V();
1421
- return ge({
1421
+ return ye({
1422
1422
  queryKey: ["getExcludeCategory"],
1423
1423
  queryFn: async (i) => await e.get(
1424
1424
  `${Q.ExcludeCategory}${r}/${n}`
@@ -1430,33 +1430,33 @@ const mt = ze(ut), pt = (e) => /* @__PURE__ */ t(
1430
1430
  loading: r = !1,
1431
1431
  onEditorInitialized: a
1432
1432
  }) => {
1433
- const { post: i } = je(), { data: s } = Ct(), { data: l } = xt(), [o, c] = C(
1433
+ const { post: i } = je(), { data: s } = Ct(), { data: l } = xt(), [o, c] = x(
1434
1434
  e ?? { html: he, css: "" }
1435
- ), { userEmail: v } = V(), E = te(null), I = "https://plugin.stripocdn.email/content/guids/CABINET_eab4e7d5a4603ac03f4120652a3a5a540f0c79c688514939f095f67433ed4a67/images/photo256.png", b = "https://plugins.stripo.email/api/v1/auth";
1435
+ ), { userEmail: v } = V(), S = te(null), I = "https://plugin.stripocdn.email/content/guids/CABINET_eab4e7d5a4603ac03f4120652a3a5a540f0c79c688514939f095f67433ed4a67/images/photo256.png", w = "https://plugins.stripo.email/api/v1/auth";
1436
1436
  L(() => {
1437
- (async () => (await x(), s && l && await u(xe.EDITOR_SCRIPT_URL)))();
1437
+ (async () => (await E(), s && l && await m(xe.EDITOR_SCRIPT_URL)))();
1438
1438
  }, [s, l]);
1439
- async function x() {
1440
- window.Zone || await new Promise((T, h) => {
1441
- const y = document.createElement("script");
1442
- y.src = "https://unpkg.com/zone.js@0.13.1/bundles/zone.umd.min.js";
1443
- const g = document.querySelector("script[nonce]")?.nonce;
1444
- g && y.setAttribute("nonce", g), y.onload = () => T(), y.onerror = () => h(new Error("Failed to load zone.js")), document.head.appendChild(y);
1439
+ async function E() {
1440
+ window.Zone || await new Promise((N, h) => {
1441
+ const g = document.createElement("script");
1442
+ g.src = "https://unpkg.com/zone.js@0.13.1/bundles/zone.umd.min.js";
1443
+ const y = document.querySelector("script[nonce]")?.nonce;
1444
+ y && g.setAttribute("nonce", y), g.onload = () => N(), g.onerror = () => h(new Error("Failed to load zone.js")), document.head.appendChild(g);
1445
1445
  });
1446
1446
  }
1447
- async function u(T) {
1447
+ async function m(N) {
1448
1448
  let h = document.getElementById(
1449
1449
  "UiEditorScript"
1450
1450
  );
1451
- h || (h = document.createElement("script"), h.id = "UiEditorScript", h.src = T, h.onload = async () => {
1451
+ h || (h = document.createElement("script"), h.id = "UiEditorScript", h.src = N, h.onload = async () => {
1452
1452
  await p();
1453
1453
  }, document.body.appendChild(h)), await new Promise(
1454
- (y) => h.addEventListener("load", () => y(), { once: !0 })
1454
+ (g) => h.addEventListener("load", () => g(), { once: !0 })
1455
1455
  );
1456
1456
  }
1457
1457
  const p = async () => {
1458
- const T = E.current;
1459
- if (!T) {
1458
+ const N = S.current;
1459
+ if (!N) {
1460
1460
  console.error("Missing #stripoEditorContainer in DOM");
1461
1461
  return;
1462
1462
  }
@@ -1476,32 +1476,32 @@ const mt = ze(ut), pt = (e) => /* @__PURE__ */ t(
1476
1476
  avatarUrl: I
1477
1477
  },
1478
1478
  locale: "en",
1479
- onTokenRefreshRequest: async (y) => {
1480
- const g = {
1479
+ onTokenRefreshRequest: async (g) => {
1480
+ const y = {
1481
1481
  pluginId: xe.EDITOR_PLUGIN_ID,
1482
1482
  secretKey: xe.EDITOR_SECRET_KEY,
1483
1483
  userId: v,
1484
1484
  role: "user"
1485
1485
  }, R = await i(
1486
- b,
1487
- g
1486
+ w,
1487
+ y
1488
1488
  );
1489
- R?.token && y(R.token);
1489
+ R?.token && g(R.token);
1490
1490
  },
1491
1491
  onTemplateLoaded: () => {
1492
1492
  a && a(!0);
1493
1493
  },
1494
1494
  mergeTags: Nt(s ?? [])
1495
1495
  };
1496
- for (const [y, g] of Object.entries({
1496
+ for (const [g, y] of Object.entries({
1497
1497
  codeEditorButtonSelector: "#codeEditor",
1498
1498
  undoButtonSelector: "#undoButton",
1499
1499
  redoButtonSelector: "#redoButton",
1500
1500
  mobileViewButtonSelector: "#mobileViewButton",
1501
1501
  desktopViewButtonSelector: "#desktopViewButton"
1502
1502
  }))
1503
- T.ownerDocument && T.getRootNode() instanceof ShadowRoot && T.getRootNode().querySelector(g) && (h[y] = g);
1504
- await window.UIEditor.initEditor(T, h);
1503
+ N.ownerDocument && N.getRootNode() instanceof ShadowRoot && N.getRootNode().querySelector(y) && (h[g] = y);
1504
+ await window.UIEditor.initEditor(N, h);
1505
1505
  };
1506
1506
  return /* @__PURE__ */ t("div", { className: "position-relative", children: /* @__PURE__ */ d("div", { className: `editor-container ${n}`, children: [
1507
1507
  r && /* @__PURE__ */ t("div", { className: "loading-overlay", children: /* @__PURE__ */ t(
@@ -1516,7 +1516,7 @@ const mt = ze(ut), pt = (e) => /* @__PURE__ */ t(
1516
1516
  }
1517
1517
  ) }),
1518
1518
  /* @__PURE__ */ t("div", { id: "externalSystemContainer" }),
1519
- /* @__PURE__ */ t("div", { id: "stripoEditorContainer", ref: E })
1519
+ /* @__PURE__ */ t("div", { id: "stripoEditorContainer", ref: S })
1520
1520
  ] }) });
1521
1521
  }, Me = ({
1522
1522
  label: e,
@@ -1617,12 +1617,12 @@ const Re = /* @__PURE__ */ St(kt), Be = (e) => e.data.isSeparator ? /* @__PURE__
1617
1617
  disabled: o,
1618
1618
  isInvalid: c,
1619
1619
  value: v,
1620
- onChange: E,
1620
+ onChange: S,
1621
1621
  uncontrolled: I,
1622
- menuPlacement: b = "auto",
1623
- closeOnSelect: x = !0
1622
+ menuPlacement: w = "auto",
1623
+ closeOnSelect: E = !0
1624
1624
  }) => {
1625
- const u = {
1625
+ const m = {
1626
1626
  control: (p) => ({
1627
1627
  ...p,
1628
1628
  minHeight: "33px",
@@ -1668,19 +1668,19 @@ const Re = /* @__PURE__ */ St(kt), Be = (e) => e.data.isSeparator ? /* @__PURE__
1668
1668
  className: Re({
1669
1669
  "is-invalid": c
1670
1670
  }),
1671
- styles: u,
1671
+ styles: m,
1672
1672
  classNamePrefix: "react-select",
1673
1673
  isMulti: a,
1674
1674
  options: r,
1675
- onChange: E,
1675
+ onChange: S,
1676
1676
  placeholder: i,
1677
1677
  menuPortalTarget: document.body,
1678
1678
  value: v,
1679
1679
  getOptionLabel: typeof l == "string" ? (p) => p[l] : l,
1680
1680
  getOptionValue: (p) => p.id,
1681
1681
  isDisabled: o,
1682
- menuPlacement: b,
1683
- closeMenuOnSelect: x
1682
+ menuPlacement: w,
1683
+ closeMenuOnSelect: E
1684
1684
  }
1685
1685
  ) : /* @__PURE__ */ t(
1686
1686
  Xe,
@@ -1688,15 +1688,15 @@ const Re = /* @__PURE__ */ St(kt), Be = (e) => e.data.isSeparator ? /* @__PURE__
1688
1688
  control: n,
1689
1689
  name: e,
1690
1690
  rules: s,
1691
- render: ({ field: { onChange: p, value: T, onBlur: h } }) => /* @__PURE__ */ t(
1691
+ render: ({ field: { onChange: p, value: N, onBlur: h } }) => /* @__PURE__ */ t(
1692
1692
  $e,
1693
1693
  {
1694
1694
  components: { Option: Be },
1695
- isOptionDisabled: (y) => !!y.isSeparator,
1695
+ isOptionDisabled: (g) => !!g.isSeparator,
1696
1696
  className: Re({
1697
1697
  "is-invalid": c
1698
1698
  }),
1699
- styles: u,
1699
+ styles: m,
1700
1700
  classNamePrefix: "react-select",
1701
1701
  isMulti: a,
1702
1702
  options: r,
@@ -1704,14 +1704,14 @@ const Re = /* @__PURE__ */ St(kt), Be = (e) => e.data.isSeparator ? /* @__PURE__
1704
1704
  onChange: p,
1705
1705
  placeholder: i,
1706
1706
  menuPortalTarget: document.body,
1707
- value: T,
1708
- getOptionLabel: typeof l == "string" ? (y) => y[l] : l,
1709
- getOptionValue: (y) => y.id,
1707
+ value: N,
1708
+ getOptionLabel: typeof l == "string" ? (g) => g[l] : l,
1709
+ getOptionValue: (g) => g.id,
1710
1710
  isDisabled: o,
1711
- menuPlacement: b,
1712
- closeMenuOnSelect: x
1711
+ menuPlacement: w,
1712
+ closeMenuOnSelect: E
1713
1713
  },
1714
- T ? T.id || T.value || JSON.stringify(T) : "reset"
1714
+ N ? N.id || N.value || JSON.stringify(N) : "reset"
1715
1715
  )
1716
1716
  }
1717
1717
  );
@@ -1769,14 +1769,14 @@ const Re = /* @__PURE__ */ St(kt), Be = (e) => e.data.isSeparator ? /* @__PURE__
1769
1769
  onRefresh: l,
1770
1770
  closeEditorModal: o
1771
1771
  }) => {
1772
- const { defaultSelector: c, isAdmin: v, userEmail: E } = V(), { mutateAsync: I, isPending: b } = Ue(), {
1773
- register: x,
1774
- handleSubmit: u,
1772
+ const { defaultSelector: c, isAdmin: v, userEmail: S } = V(), { mutateAsync: I, isPending: w } = Ue(), {
1773
+ register: E,
1774
+ handleSubmit: m,
1775
1775
  clearErrors: p,
1776
- setValue: T,
1776
+ setValue: N,
1777
1777
  control: h,
1778
- watch: y,
1779
- reset: g,
1778
+ watch: g,
1779
+ reset: y,
1780
1780
  setError: R,
1781
1781
  formState: { errors: B }
1782
1782
  } = Je({
@@ -1789,7 +1789,7 @@ const Re = /* @__PURE__ */ St(kt), Be = (e) => e.data.isSeparator ? /* @__PURE__
1789
1789
  template: Pt
1790
1790
  },
1791
1791
  mode: "onChange"
1792
- }), [_, A] = C([]), [S, D] = C(), { mutateAsync: M, isPending: w } = Dt(), [ne, U] = C([]), [W, K] = C([]), [O, re] = C([]), [le, de] = C(!1), Z = te(!1), { showNotification: se } = ve(), H = r === "edit", ue = le || w || b || !n;
1792
+ }), [_, A] = x([]), [b, D] = x(), { mutateAsync: M, isPending: T } = Dt(), [ne, U] = x([]), [W, K] = x([]), [O, re] = x([]), [le, de] = x(!1), Z = te(!1), { showNotification: se } = ve(), H = r === "edit", me = le || T || w || !n;
1793
1793
  L(() => {
1794
1794
  if (a) {
1795
1795
  let f = a.filter((F) => F.id != null), k = Ne(f, 0);
@@ -1802,7 +1802,7 @@ const Re = /* @__PURE__ */ St(kt), Be = (e) => e.data.isSeparator ? /* @__PURE__
1802
1802
  const f = _.find((q) => q.id === s.templateID);
1803
1803
  if (!f) return;
1804
1804
  const k = a.filter((q) => q.id != null), F = k.find((q) => `${q.id}` == `${f.type}`), j = F ? k.find((q) => `${q.id}` == `${F.parent_id}`) : void 0, X = j ? k.find((q) => `${q.id}` == `${j.parent_id}`) : void 0;
1805
- g({
1805
+ y({
1806
1806
  templateType: X ? ee(X) : void 0,
1807
1807
  subTemplateType: j ? ee(j) : void 0,
1808
1808
  subTemplateType2: F ? ee(F) : void 0,
@@ -1810,7 +1810,7 @@ const Re = /* @__PURE__ */ St(kt), Be = (e) => e.data.isSeparator ? /* @__PURE__
1810
1810
  templateName: s.name ?? "",
1811
1811
  subject: s.subject ?? ""
1812
1812
  }), D(f), Z.current = !0, de(!1);
1813
- }, [r, s, n, a, _, g]);
1813
+ }, [r, s, n, a, _, y]);
1814
1814
  const ee = (f) => ({
1815
1815
  id: String(f.id),
1816
1816
  name: f.name,
@@ -1819,50 +1819,50 @@ const Re = /* @__PURE__ */ St(kt), Be = (e) => e.data.isSeparator ? /* @__PURE__
1819
1819
  L(() => {
1820
1820
  i?.sort((f, k) => f.readonly !== k.readonly ? (f.readonly ? 0 : 1) - (k.readonly ? 0 : 1) : f.name.localeCompare(k.name)), A(i ?? []);
1821
1821
  }, [i]), L(() => {
1822
- if (!y("templateType")) return;
1822
+ if (!g("templateType")) return;
1823
1823
  const f = Ne(a, 1);
1824
1824
  K(
1825
1825
  Te(
1826
- f.filter((k) => `${k.parent_id}` == `${y("templateType")?.id}`)
1826
+ f.filter((k) => `${k.parent_id}` == `${g("templateType")?.id}`)
1827
1827
  )
1828
- ), T("subTemplateType", void 0);
1829
- }, [y("templateType"), a]), L(() => {
1830
- const f = y("subTemplateType");
1828
+ ), N("subTemplateType", void 0);
1829
+ }, [g("templateType"), a]), L(() => {
1830
+ const f = g("subTemplateType");
1831
1831
  if (!f) return;
1832
1832
  const k = Ne(a, 2);
1833
1833
  let F = Te(
1834
1834
  k.filter((j) => `${j.parent_id}` == `${f.id}`)
1835
1835
  );
1836
1836
  r !== "edit" && !v && (F = F.filter((j) => j.key !== 2)), re(F);
1837
- }, [y("subTemplateType"), a, r]), L(() => {
1837
+ }, [g("subTemplateType"), a, r]), L(() => {
1838
1838
  if (c && c.type1) {
1839
1839
  const f = ne?.find(
1840
1840
  (k) => `${k.id}` === c.type1
1841
1841
  );
1842
- T("templateType", f);
1842
+ N("templateType", f);
1843
1843
  }
1844
1844
  }, [a, ne]), L(() => {
1845
1845
  if (c && c.type2) {
1846
1846
  const f = W?.find(
1847
1847
  (k) => `${k.id}` === c.type2
1848
1848
  );
1849
- T("subTemplateType", f);
1849
+ N("subTemplateType", f);
1850
1850
  }
1851
1851
  }, [a, W]), L(() => {
1852
1852
  if (c && c.type3) {
1853
1853
  const f = O?.find(
1854
1854
  (k) => `${k.id}` === c.type3
1855
1855
  );
1856
- T("subTemplateType2", f);
1856
+ N("subTemplateType2", f);
1857
1857
  }
1858
1858
  }, [a, O]);
1859
- const me = (f) => {
1859
+ const ue = (f) => {
1860
1860
  window.StripoEditorApi.actionsApi.getTemplateData(
1861
1861
  async (k) => {
1862
1862
  try {
1863
1863
  let F = f.template.id, j = "";
1864
1864
  const X = f.templateName.trim(), q = _.find(
1865
- (N) => N.name === f.templateName.trim()
1865
+ (C) => C.name === f.templateName.trim()
1866
1866
  );
1867
1867
  if (q && q?.id !== f.template.id) {
1868
1868
  R("templateName", {
@@ -1883,7 +1883,7 @@ const Re = /* @__PURE__ */ St(kt), Be = (e) => e.data.isSeparator ? /* @__PURE__
1883
1883
  css: k.css,
1884
1884
  subject: f.templateType.id === "2" ? f?.subject ?? "" : "",
1885
1885
  parent_id: j,
1886
- updatedBy: E ?? ""
1886
+ updatedBy: S ?? ""
1887
1887
  };
1888
1888
  if (!await M(Ie)) {
1889
1889
  se(
@@ -1904,9 +1904,9 @@ const Re = /* @__PURE__ */ St(kt), Be = (e) => e.data.isSeparator ? /* @__PURE__
1904
1904
  }
1905
1905
  }
1906
1906
  );
1907
- }, pe = y("templateType"), be = y("subTemplateType");
1908
- return /* @__PURE__ */ d(ye, { children: [
1909
- ue && /* @__PURE__ */ t(ie, { overlay: !0 }),
1907
+ }, pe = g("templateType"), be = g("subTemplateType");
1908
+ return /* @__PURE__ */ d(ge, { children: [
1909
+ me && /* @__PURE__ */ t(ie, { overlay: !0 }),
1910
1910
  /* @__PURE__ */ t("div", { className: "ts-card", children: /* @__PURE__ */ t("div", { className: "ts-card-body", children: /* @__PURE__ */ t("form", { children: /* @__PURE__ */ t("div", { className: "template-list-container", children: /* @__PURE__ */ d("div", { className: "ts-row", children: [
1911
1911
  /* @__PURE__ */ t("div", { className: "ts-col", children: /* @__PURE__ */ t(
1912
1912
  fe,
@@ -1916,14 +1916,14 @@ const Re = /* @__PURE__ */ St(kt), Be = (e) => e.data.isSeparator ? /* @__PURE__
1916
1916
  error: B,
1917
1917
  options: ne,
1918
1918
  required: !0,
1919
- disabled: H || w || b || !n,
1919
+ disabled: H || T || w || !n,
1920
1920
  validation: {
1921
1921
  required: {
1922
1922
  value: !0,
1923
1923
  message: "Select a category"
1924
1924
  }
1925
1925
  },
1926
- ...x("templateType")
1926
+ ...E("templateType")
1927
1927
  }
1928
1928
  ) }),
1929
1929
  W && W.length > 0 && /* @__PURE__ */ t("div", { className: "ts-col", children: /* @__PURE__ */ t(
@@ -1934,14 +1934,14 @@ const Re = /* @__PURE__ */ St(kt), Be = (e) => e.data.isSeparator ? /* @__PURE__
1934
1934
  error: B,
1935
1935
  options: W,
1936
1936
  required: !0,
1937
- disabled: H || w || b || !n,
1937
+ disabled: H || T || w || !n,
1938
1938
  validation: {
1939
1939
  required: {
1940
1940
  value: !0,
1941
1941
  message: "Select a type"
1942
1942
  }
1943
1943
  },
1944
- ...x("subTemplateType")
1944
+ ...E("subTemplateType")
1945
1945
  }
1946
1946
  ) }),
1947
1947
  O && O.length > 0 && /* @__PURE__ */ t("div", { className: "ts-col", children: /* @__PURE__ */ t(
@@ -1952,14 +1952,14 @@ const Re = /* @__PURE__ */ St(kt), Be = (e) => e.data.isSeparator ? /* @__PURE__
1952
1952
  error: B,
1953
1953
  options: O,
1954
1954
  required: !0,
1955
- disabled: H || w || b || !n,
1955
+ disabled: H || T || w || !n,
1956
1956
  validation: {
1957
1957
  required: {
1958
1958
  value: !0,
1959
1959
  message: "Select a subtype"
1960
1960
  }
1961
1961
  },
1962
- ...x("subTemplateType2")
1962
+ ...E("subTemplateType2")
1963
1963
  }
1964
1964
  ) }),
1965
1965
  /* @__PURE__ */ t("div", { className: "ts-col", children: /* @__PURE__ */ t(
@@ -1968,10 +1968,10 @@ const Re = /* @__PURE__ */ St(kt), Be = (e) => e.data.isSeparator ? /* @__PURE__
1968
1968
  label: "Template",
1969
1969
  control: h,
1970
1970
  error: B,
1971
- disabled: H || !H || w || b || !n,
1971
+ disabled: H || !H || T || w || !n,
1972
1972
  options: [],
1973
1973
  required: !1,
1974
- ...x("template")
1974
+ ...E("template")
1975
1975
  }
1976
1976
  ) }),
1977
1977
  /* @__PURE__ */ d("div", { className: "ts-col ts-template-name-col", children: [
@@ -1979,7 +1979,7 @@ const Re = /* @__PURE__ */ St(kt), Be = (e) => e.data.isSeparator ? /* @__PURE__
1979
1979
  Me,
1980
1980
  {
1981
1981
  label: "Name",
1982
- register: x,
1982
+ register: E,
1983
1983
  error: B,
1984
1984
  required: !0,
1985
1985
  name: "templateName",
@@ -1991,13 +1991,13 @@ const Re = /* @__PURE__ */ St(kt), Be = (e) => e.data.isSeparator ? /* @__PURE__
1991
1991
  }
1992
1992
  }
1993
1993
  ),
1994
- be?.key?.toString() === "9" && H && !v && S?.is_favourite && /* @__PURE__ */ t("span", { className: "ts-favourite-icon", children: /* @__PURE__ */ t(Le, { variant: "filled" }) })
1994
+ be?.key?.toString() === "9" && H && !v && b?.is_favourite && /* @__PURE__ */ t("span", { className: "ts-favourite-icon", children: /* @__PURE__ */ t(Le, { variant: "filled" }) })
1995
1995
  ] }),
1996
1996
  pe?.key?.toString() === "12" && /* @__PURE__ */ t("div", { className: "ts-col", children: /* @__PURE__ */ t(
1997
1997
  Me,
1998
1998
  {
1999
1999
  label: "Subject",
2000
- register: x,
2000
+ register: E,
2001
2001
  error: B,
2002
2002
  required: !1,
2003
2003
  name: "subject"
@@ -2009,11 +2009,11 @@ const Re = /* @__PURE__ */ St(kt), Be = (e) => e.data.isSeparator ? /* @__PURE__
2009
2009
  {
2010
2010
  type: "button",
2011
2011
  className: "ts-btn ts-btn-primary",
2012
- disabled: w || b || !n,
2012
+ disabled: T || w || !n,
2013
2013
  onClick: () => {
2014
- D(void 0), g(), K([]), re([]), e();
2014
+ D(void 0), y(), K([]), re([]), e();
2015
2015
  },
2016
- children: w || b ? /* @__PURE__ */ t(ie, { size: "sm" }) : "Clear"
2016
+ children: T || w ? /* @__PURE__ */ t(ie, { size: "sm" }) : "Clear"
2017
2017
  }
2018
2018
  ),
2019
2019
  /* @__PURE__ */ t(
@@ -2021,9 +2021,9 @@ const Re = /* @__PURE__ */ St(kt), Be = (e) => e.data.isSeparator ? /* @__PURE__
2021
2021
  {
2022
2022
  type: "button",
2023
2023
  className: "ts-btn ts-btn-primary",
2024
- disabled: w || b || !n,
2025
- onClick: u(me),
2026
- children: w || b ? (
2024
+ disabled: T || w || !n,
2025
+ onClick: m(ue),
2026
+ children: T || w ? (
2027
2027
  // <span className="ts-spinner" />
2028
2028
  /* @__PURE__ */ t(ie, { size: "sm" })
2029
2029
  ) : "Save"
@@ -2044,7 +2044,7 @@ const Re = /* @__PURE__ */ St(kt), Be = (e) => e.data.isSeparator ? /* @__PURE__
2044
2044
  onClose: c,
2045
2045
  onRefresh: v
2046
2046
  }) => {
2047
- const E = te(null), [I, b] = C(!1);
2047
+ const S = te(null), [I, w] = x(!1);
2048
2048
  L(() => {
2049
2049
  e && s && window.StripoEditorApi?.actionsApi && (n === "add" ? window.StripoEditorApi.actionsApi.updateHtmlAndCss(he, "", "") : n === "edit" && r && window.StripoEditorApi.actionsApi.updateHtmlAndCss(
2050
2050
  r.html ?? he,
@@ -2052,16 +2052,16 @@ const Re = /* @__PURE__ */ St(kt), Be = (e) => e.data.isSeparator ? /* @__PURE__
2052
2052
  ""
2053
2053
  ));
2054
2054
  }, [e, s, n, r]), L(() => {
2055
- e || b(!1);
2055
+ e || w(!1);
2056
2056
  }, [e]);
2057
- const x = () => {
2057
+ const E = () => {
2058
2058
  window.StripoEditorApi.actionsApi.updateHtmlAndCss(he, "", "");
2059
2059
  };
2060
2060
  return e ? /* @__PURE__ */ t("div", { className: "ts-editor-modal-overlay", children: /* @__PURE__ */ d(
2061
2061
  "div",
2062
2062
  {
2063
2063
  className: `ts-editor-modal ${I ? "ts-editor-modal--fullscreen" : ""}`,
2064
- ref: E,
2064
+ ref: S,
2065
2065
  children: [
2066
2066
  /* @__PURE__ */ d("div", { className: "ts-editor-modal-header", children: [
2067
2067
  /* @__PURE__ */ d("h3", { className: "ts-modal-title", children: [
@@ -2074,7 +2074,7 @@ const Re = /* @__PURE__ */ St(kt), Be = (e) => e.data.isSeparator ? /* @__PURE__
2074
2074
  "button",
2075
2075
  {
2076
2076
  className: "ts-editor-fullscreen-btn",
2077
- onClick: () => b((u) => !u),
2077
+ onClick: () => w((m) => !m),
2078
2078
  "aria-label": "Toggle fullscreen",
2079
2079
  children: I ? /* @__PURE__ */ t(At, { style: { display: "block" } }) : /* @__PURE__ */ t(Mt, { style: { display: "block" } })
2080
2080
  }
@@ -2099,7 +2099,7 @@ const Re = /* @__PURE__ */ St(kt), Be = (e) => e.data.isSeparator ? /* @__PURE__
2099
2099
  templateTypes: a,
2100
2100
  templateList: i,
2101
2101
  editorInitialized: s,
2102
- onReset: x,
2102
+ onReset: E,
2103
2103
  onRefresh: v,
2104
2104
  closeEditorModal: c
2105
2105
  }
@@ -2133,19 +2133,19 @@ const Re = /* @__PURE__ */ St(kt), Be = (e) => e.data.isSeparator ? /* @__PURE__
2133
2133
  data: i,
2134
2134
  isLoading: s,
2135
2135
  isFetching: l
2136
- } = it(), { mutateAsync: o, isPending: c } = lt(), [v, E] = C(!1), [I, b] = C("add"), [x, u] = C(!1), [p, T] = C(""), [h, y] = C(), g = () => {
2137
- b("add"), E(!0);
2138
- }, R = async (S) => {
2139
- const D = await o({ id: S.id });
2140
- y({ ...D }), b("edit"), E(!0);
2141
- }, B = (S) => {
2136
+ } = it(), { mutateAsync: o, isPending: c } = lt(), [v, S] = x(!1), [I, w] = x("add"), [E, m] = x(!1), [p, N] = x(""), [h, g] = x(), y = () => {
2137
+ w("add"), S(!0);
2138
+ }, R = async (b) => {
2139
+ const D = await o({ id: b.id });
2140
+ g({ ...D }), w("edit"), S(!0);
2141
+ }, B = (b) => {
2142
2142
  if (!e || e.length === 0) return;
2143
- const D = e.find((M) => M.id === S.id);
2144
- T(D?.html + "<style>" + D?.css + "</style>"), b("preview"), E(!0);
2143
+ const D = e.find((M) => M.id === b.id);
2144
+ N(D?.html + "<style>" + D?.css + "</style>"), w("preview"), S(!0);
2145
2145
  }, _ = () => {
2146
- E(!1), u(!1), document.getElementById("UiEditorScript")?.remove();
2146
+ S(!1), m(!1), document.getElementById("UiEditorScript")?.remove();
2147
2147
  };
2148
- return /* @__PURE__ */ d(ye, { children: [
2148
+ return /* @__PURE__ */ d(ge, { children: [
2149
2149
  (n || s || r || l || c) && /* @__PURE__ */ t(ie, { overlay: !0 }),
2150
2150
  /* @__PURE__ */ t(
2151
2151
  Tt,
@@ -2153,7 +2153,7 @@ const Re = /* @__PURE__ */ St(kt), Be = (e) => e.data.isSeparator ? /* @__PURE__
2153
2153
  templates: e ?? [],
2154
2154
  templateTypes: i ?? [],
2155
2155
  onRefresh: a,
2156
- onAdd: g,
2156
+ onAdd: y,
2157
2157
  onEdit: R,
2158
2158
  onPreview: B
2159
2159
  }
@@ -2166,8 +2166,8 @@ const Re = /* @__PURE__ */ St(kt), Be = (e) => e.data.isSeparator ? /* @__PURE__
2166
2166
  template: h,
2167
2167
  templateTypes: i ?? [],
2168
2168
  templateList: e ?? [],
2169
- editorInitialized: x,
2170
- onEditorInitialized: u,
2169
+ editorInitialized: E,
2170
+ onEditorInitialized: m,
2171
2171
  onClose: _,
2172
2172
  onSaved: () => {
2173
2173
  _(), a();