@commercelayer/app-elements 5.5.0 → 5.5.2

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,9 +1,9 @@
1
1
  "use client";
2
- import { t as k, b as H, d as Z, j as t, i as E, g as G, e as Q, f as h, h as j, k as $, D as P, l as S, n as v, B as z, o as T, p as U, q as ee, r as te, s as ae, v as C, I as le, C as ne } from "./main-ClKWD_hr.js";
2
+ import { t as k, b as Z, d as G, j as t, i as E, g as Q, e as P, f as g, h as j, k as V, D as z, l as S, n as p, B as U, o as T, p as K, q as ee, r as te, s as ae, v as $, I as le, C as ne } from "./main-CMTD8EIQ.js";
3
3
  import "react-hook-form";
4
- import I, { useReducer as se, useCallback as w, useMemo as re, createContext as ie, useContext as ue, useState as g, useEffect as N, useRef as ce } from "react";
4
+ import I, { useReducer as se, useCallback as w, useMemo as re, createContext as ie, useContext as ue, useState as x, useEffect as N, useRef as ce } from "react";
5
5
  import { a as de } from "./fetchCoreResourcesSuggestions-CZkDwjO2.js";
6
- import { p as A } from "./parseISO-DltoM17h.js";
6
+ import { p as A } from "./parseISO-Du6lRb2h.js";
7
7
  function q(e, a) {
8
8
  const l = e.match(
9
9
  /(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2}):(\d{2})(?:\.(\d{0,7}))?(?:Z|(.)(\d{2}):?(\d{2})?)?/
@@ -22,12 +22,12 @@ function q(e, a) {
22
22
  ) : k(NaN, a == null ? void 0 : a.in);
23
23
  }
24
24
  function D(e, a, l) {
25
- return e == null ? e : H(e, a, l);
25
+ return e == null ? e : Z(e, a, l);
26
26
  }
27
27
  function M(e, a) {
28
- return e == null ? !0 : Z(e, a);
28
+ return e == null ? !0 : G(e, a);
29
29
  }
30
- const K = ie(
30
+ const W = ie(
31
31
  void 0
32
32
  );
33
33
  function oe(e, a) {
@@ -37,7 +37,7 @@ function oe(e, a) {
37
37
  const i = { ...e.value };
38
38
  if (a.value === null)
39
39
  if (/\.\d+$/.test(a.path)) {
40
- const u = a.path.replace(/\.\d+$/, ""), s = parseInt(((l = a.path.match(/\d+$/)) == null ? void 0 : l[0]) ?? "0", 10), r = G(i, u);
40
+ const u = a.path.replace(/\.\d+$/, ""), s = parseInt(((l = a.path.match(/\d+$/)) == null ? void 0 : l[0]) ?? "0", 10), r = Q(i, u);
41
41
  Array.isArray(r) && (r.splice(s, 1), D(i, u, r), r.length === 0 && u.endsWith(".nested.conditions") && M(i, u.replace(/\.conditions$/, "")));
42
42
  } else
43
43
  M(i, a.path);
@@ -97,15 +97,15 @@ function fe({
97
97
  }),
98
98
  [l, u, s, r]
99
99
  );
100
- return /* @__PURE__ */ t.jsx(K.Provider, { value: n, children: e });
100
+ return /* @__PURE__ */ t.jsx(W.Provider, { value: n, children: e });
101
101
  }
102
- function p() {
103
- const e = ue(K);
102
+ function y() {
103
+ const e = ue(W);
104
104
  if (e === void 0)
105
105
  throw new Error("useRuleEngine must be used within a RuleEngineProvider");
106
106
  return e;
107
107
  }
108
- const W = Q([
108
+ const X = P([
109
109
  "blank",
110
110
  "present",
111
111
  "null",
@@ -114,20 +114,21 @@ const W = Q([
114
114
  function R(e) {
115
115
  return null;
116
116
  }
117
- function xe({
117
+ function me({
118
118
  item: e,
119
119
  pathPrefix: a
120
120
  }) {
121
121
  var i, u, s, r;
122
- const { setPath: l } = p();
122
+ const { setPath: l } = y();
123
123
  if (e == null)
124
124
  return null;
125
125
  switch (e.type) {
126
126
  case "buy_x_pay_y":
127
127
  return /* @__PURE__ */ t.jsxs("div", { className: "w-36 flex items-center gap-0.5", children: [
128
128
  /* @__PURE__ */ t.jsx(
129
- h,
129
+ g,
130
130
  {
131
+ name: `${a}.value.x`,
131
132
  type: "number",
132
133
  suffix: "X",
133
134
  defaultValue: (i = e.value) == null ? void 0 : i.x,
@@ -140,8 +141,9 @@ function xe({
140
141
  }
141
142
  ),
142
143
  /* @__PURE__ */ t.jsx(
143
- h,
144
+ g,
144
145
  {
146
+ name: `${a}.value.y`,
145
147
  type: "number",
146
148
  suffix: "Y",
147
149
  defaultValue: (u = e.value) == null ? void 0 : u.y,
@@ -157,8 +159,9 @@ function xe({
157
159
  case "every_x_discount_y":
158
160
  return /* @__PURE__ */ t.jsxs("div", { className: "w-36 flex items-center gap-0.5", children: [
159
161
  /* @__PURE__ */ t.jsx(
160
- h,
162
+ g,
161
163
  {
164
+ name: `${a}.value.x`,
162
165
  type: "number",
163
166
  suffix: "X",
164
167
  defaultValue: (s = e.value) == null ? void 0 : s.x,
@@ -171,8 +174,9 @@ function xe({
171
174
  }
172
175
  ),
173
176
  /* @__PURE__ */ t.jsx(
174
- h,
177
+ g,
175
178
  {
179
+ name: `${a}.value.y`,
176
180
  type: "number",
177
181
  suffix: "Y",
178
182
  defaultValue: (r = e.value) == null ? void 0 : r.y,
@@ -188,8 +192,9 @@ function xe({
188
192
  case "fixed_amount":
189
193
  case "fixed_price":
190
194
  return /* @__PURE__ */ t.jsx("div", { className: "w-36", children: /* @__PURE__ */ t.jsx(
191
- h,
195
+ g,
192
196
  {
197
+ name: `${a}.value`,
193
198
  type: "number",
194
199
  defaultValue: e.value,
195
200
  min: 0,
@@ -205,8 +210,9 @@ function xe({
205
210
  case "percentage": {
206
211
  const n = (e.value * 100).toFixed(2);
207
212
  return /* @__PURE__ */ t.jsx("div", { className: "w-24", children: /* @__PURE__ */ t.jsx(
208
- h,
213
+ g,
209
214
  {
215
+ name: `${a}.value`,
210
216
  type: "number",
211
217
  defaultValue: n.endsWith(".00") ? n.slice(0, -3) : n,
212
218
  min: 0,
@@ -225,7 +231,7 @@ function xe({
225
231
  return R();
226
232
  }
227
233
  }
228
- function he({
234
+ function ge({
229
235
  item: e,
230
236
  index: a,
231
237
  onDelete: l
@@ -233,7 +239,7 @@ function he({
233
239
  const {
234
240
  setPath: i,
235
241
  state: { selectedRuleIndex: u }
236
- } = p(), s = {
242
+ } = y(), s = {
237
243
  percentage: "Percentage discount",
238
244
  fixed_amount: "Fixed amount",
239
245
  fixed_price: "Fixed price",
@@ -245,6 +251,7 @@ function he({
245
251
  /* @__PURE__ */ t.jsx("div", { className: "flex-1", children: /* @__PURE__ */ t.jsx(
246
252
  j,
247
253
  {
254
+ name: `${r}.type`,
248
255
  defaultValue: e != null ? {
249
256
  label: s[e.type],
250
257
  value: e.type
@@ -253,15 +260,16 @@ function he({
253
260
  ([n, d]) => ({ value: n, label: d })
254
261
  ),
255
262
  onSelect: (n) => {
256
- $(n) && i(`${r}.type`, n.value);
263
+ V(n) && i(`${r}.type`, n.value);
257
264
  }
258
265
  }
259
266
  ) }),
260
- /* @__PURE__ */ t.jsx(xe, { item: e, pathPrefix: r }),
267
+ /* @__PURE__ */ t.jsx(me, { item: e, pathPrefix: r }),
261
268
  /* @__PURE__ */ t.jsx("div", { className: "text-black font-bold text-sm", children: "ON" }),
262
269
  /* @__PURE__ */ t.jsx("div", { className: "flex-1", children: /* @__PURE__ */ t.jsx(
263
- h,
270
+ g,
264
271
  {
272
+ name: `${r}.selector`,
265
273
  type: "text",
266
274
  defaultValue: e != null ? e.selector : void 0,
267
275
  onChange: (n) => {
@@ -271,10 +279,10 @@ function he({
271
279
  ) })
272
280
  ] }),
273
281
  l != null && /* @__PURE__ */ t.jsx(
274
- P,
282
+ z,
275
283
  {
276
284
  className: "w-8 border-l border-gray-100 flex items-center justify-center self-stretch",
277
- dropdownLabel: /* @__PURE__ */ t.jsx("button", { className: "flex items-center justify-center self-stretch flex-grow", children: /* @__PURE__ */ t.jsx(v, { name: "dotsThreeVertical", size: 16, weight: "bold" }) }),
285
+ dropdownLabel: /* @__PURE__ */ t.jsx("button", { className: "flex items-center justify-center self-stretch flex-grow", children: /* @__PURE__ */ t.jsx(p, { name: "dotsThreeVertical", size: 16, weight: "bold" }) }),
278
286
  dropdownItems: /* @__PURE__ */ t.jsx(t.Fragment, { children: /* @__PURE__ */ t.jsx(
279
287
  S,
280
288
  {
@@ -288,16 +296,16 @@ function he({
288
296
  )
289
297
  ] }) });
290
298
  }
291
- function ge({
299
+ function xe({
292
300
  actions: e
293
301
  }) {
294
- const [a, l] = g(0), {
302
+ const [a, l] = x(0), {
295
303
  setPath: i,
296
304
  state: { selectedRuleIndex: u }
297
- } = p();
305
+ } = y();
298
306
  return /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
299
307
  /* @__PURE__ */ t.jsx("div", { children: e == null ? void 0 : e.map((s, r, n) => /* @__PURE__ */ t.jsx(
300
- he,
308
+ ge,
301
309
  {
302
310
  item: s,
303
311
  index: r,
@@ -308,7 +316,7 @@ function ge({
308
316
  `${u}-${r}-${a}`
309
317
  )) }),
310
318
  /* @__PURE__ */ t.jsx("div", { className: "mt-6", children: /* @__PURE__ */ t.jsxs(
311
- z,
319
+ U,
312
320
  {
313
321
  size: "small",
314
322
  variant: "secondary",
@@ -320,15 +328,15 @@ function ge({
320
328
  );
321
329
  },
322
330
  children: [
323
- /* @__PURE__ */ t.jsx(v, { name: "plusCircle" }),
331
+ /* @__PURE__ */ t.jsx(p, { name: "plusCircle" }),
324
332
  " Add action"
325
333
  ]
326
334
  }
327
335
  ) })
328
336
  ] });
329
337
  }
330
- function X(e) {
331
- const [a, l] = g(void 0);
338
+ function Y(e) {
339
+ const [a, l] = x(void 0);
332
340
  return N(() => {
333
341
  (e == null ? void 0 : e.field) != null && de(e.field).then((i) => {
334
342
  l(i);
@@ -337,7 +345,7 @@ function X(e) {
337
345
  });
338
346
  }, [e == null ? void 0 : e.field]), { infos: a };
339
347
  }
340
- function Y(e) {
348
+ function B(e) {
341
349
  if (typeof e == "string")
342
350
  return T(q(e)) ? "datetime" : "string";
343
351
  if (typeof e == "number")
@@ -352,16 +360,17 @@ function Y(e) {
352
360
  }
353
361
  return "string";
354
362
  }
355
- function me({
363
+ function he({
356
364
  item: e,
357
365
  pathPrefix: a
358
366
  }) {
359
367
  var s, r;
360
- const { setPath: l } = p(), { infos: i } = X(e);
368
+ const { setPath: l } = y(), { infos: i } = Y(e);
361
369
  let u = (s = i == null ? void 0 : i.field) == null ? void 0 : s.type;
362
- return u == null && (u = Y(e == null ? void 0 : e.value)), /* @__PURE__ */ t.jsx(
370
+ return u == null && (u = B(e == null ? void 0 : e.value)), /* @__PURE__ */ t.jsx(
363
371
  j,
364
372
  {
373
+ name: `${a}.matcher`,
365
374
  value: e != null ? {
366
375
  label: ((r = O.find((n) => n.matcher === e.matcher && (u != null && n.fieldTypes.includes(u) || u == null))) == null ? void 0 : r.label) ?? // eslint-disable-next-line no-irregular-whitespace
367
376
  (e.matcher != null ? `⚠️   ${e.matcher}` : ""),
@@ -369,7 +378,7 @@ function me({
369
378
  } : void 0,
370
379
  initialValues: O.filter(({ fieldTypes: n, visible: d }) => d !== !1 && n.includes(u)).map(({ matcher: n, label: d }) => ({ value: n, label: d })),
371
380
  onSelect: (n) => {
372
- $(n) && (l(`${a}.matcher`, n.value), W.includes(
381
+ V(n) && (l(`${a}.matcher`, n.value), X.includes(
373
382
  n.value
374
383
  ) && l(`${a}.value`, null));
375
384
  }
@@ -642,7 +651,7 @@ function be({
642
651
  return (typeof e != "object" || Array.isArray(e) || e === null) && (e = {
643
652
  in_and: []
644
653
  }), /* @__PURE__ */ t.jsx("div", { children: Object.entries(e).map(([l, i], u) => /* @__PURE__ */ t.jsx(
645
- pe,
654
+ ye,
646
655
  {
647
656
  pathPrefix: a,
648
657
  defaultValue: i,
@@ -651,12 +660,12 @@ function be({
651
660
  `${a}.${u}`
652
661
  )) });
653
662
  }
654
- function pe({
663
+ function ye({
655
664
  initialMatcher: e,
656
665
  defaultValue: a,
657
666
  pathPrefix: l
658
667
  }) {
659
- const [i, u] = g(e), [s, r] = g(e), [n, d] = g(a), { setPath: c } = p();
668
+ const [i, u] = x(e), [s, r] = x(e), [n, d] = x(a), { setPath: c } = y();
660
669
  return N(() => {
661
670
  i !== s && (c(`${l}.${i}`, null), u(s)), c(`${l}.${s}`, n);
662
671
  }, [s, n, c]), /* @__PURE__ */ t.jsxs("div", { className: "flex gap-2 last-of-type:mt-2", children: [
@@ -673,7 +682,7 @@ function pe({
673
682
  })
674
683
  ),
675
684
  onSelect: (o) => {
676
- $(o) && r(o.value);
685
+ V(o) && r(o.value);
677
686
  }
678
687
  }
679
688
  ) }),
@@ -688,7 +697,7 @@ function pe({
688
697
  })),
689
698
  initialValues: [],
690
699
  onSelect: (o) => {
691
- U(o) && d(
700
+ K(o) && d(
692
701
  o.map(
693
702
  (f) => typeof f.value == "boolean" ? f.value.toString() : f.value
694
703
  )
@@ -698,18 +707,18 @@ function pe({
698
707
  ) })
699
708
  ] });
700
709
  }
701
- function ye({
710
+ function ve({
702
711
  value: e,
703
712
  onChange: a
704
713
  }) {
705
- const [l, i] = g(
714
+ const [l, i] = x(
706
715
  Array.isArray(e) && typeof e[0] == "number" ? e[0] : null
707
- ), [u, s] = g(
716
+ ), [u, s] = x(
708
717
  Array.isArray(e) && typeof e[1] == "number" ? e[1] : null
709
718
  );
710
719
  return /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-4", children: [
711
720
  /* @__PURE__ */ t.jsx("div", { className: "flex-grow", children: /* @__PURE__ */ t.jsx(
712
- h,
721
+ g,
713
722
  {
714
723
  type: "number",
715
724
  placeholder: "Min",
@@ -722,7 +731,7 @@ function ye({
722
731
  ) }),
723
732
  /* @__PURE__ */ t.jsx("span", { className: "text-gray-300", children: "to" }),
724
733
  /* @__PURE__ */ t.jsx("div", { className: "flex-grow", children: /* @__PURE__ */ t.jsx(
725
- h,
734
+ g,
726
735
  {
727
736
  type: "number",
728
737
  placeholder: "Max",
@@ -735,18 +744,18 @@ function ye({
735
744
  ) })
736
745
  ] });
737
746
  }
738
- function ve({
747
+ function pe({
739
748
  value: e,
740
749
  onChange: a
741
750
  }) {
742
- const [l, i] = g(
751
+ const [l, i] = x(
743
752
  Array.isArray(e) && typeof e[0] == "string" ? e[0] : null
744
- ), [u, s] = g(
753
+ ), [u, s] = x(
745
754
  Array.isArray(e) && typeof e[1] == "string" ? e[1] : null
746
755
  );
747
756
  return /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-4", children: [
748
757
  /* @__PURE__ */ t.jsx("div", { className: "flex-grow", children: /* @__PURE__ */ t.jsx(
749
- h,
758
+ g,
750
759
  {
751
760
  type: "text",
752
761
  placeholder: "Min",
@@ -759,7 +768,7 @@ function ve({
759
768
  ) }),
760
769
  /* @__PURE__ */ t.jsx("span", { className: "text-gray-300", children: "to" }),
761
770
  /* @__PURE__ */ t.jsx("div", { className: "flex-grow", children: /* @__PURE__ */ t.jsx(
762
- h,
771
+ g,
763
772
  {
764
773
  type: "text",
765
774
  placeholder: "Max",
@@ -777,14 +786,14 @@ function je({
777
786
  pathPrefix: a
778
787
  }) {
779
788
  var d;
780
- const { setPath: l } = p(), { infos: i } = X(e), u = `${a}.value`;
781
- if (e == null || W.includes(
789
+ const { setPath: l } = y(), { infos: i } = Y(e), u = `${a}.value`;
790
+ if (e == null || X.includes(
782
791
  e.matcher
783
792
  ))
784
793
  return null;
785
794
  const s = e;
786
795
  let r = (d = i == null ? void 0 : i.field) == null ? void 0 : d.type;
787
- r == null && (r = Y(s.value)), (typeof s.value == "string" && /^{{.*}}$/.test(s.value) || Array.isArray(s.value) && s.value.some(
796
+ r == null && (r = B(s.value)), (typeof s.value == "string" && /^{{.*}}$/.test(s.value) || Array.isArray(s.value) && s.value.some(
788
797
  (c) => typeof c == "string" && /^{{.*}}$/.test(c)
789
798
  )) && (r = "string");
790
799
  let n = null;
@@ -890,7 +899,7 @@ function je({
890
899
  }
891
900
  case "numberRange":
892
901
  return /* @__PURE__ */ t.jsx(
893
- ye,
902
+ ve,
894
903
  {
895
904
  value: s.value,
896
905
  onChange: (c) => {
@@ -900,7 +909,7 @@ function je({
900
909
  );
901
910
  case "textRange":
902
911
  return /* @__PURE__ */ t.jsx(
903
- ve,
912
+ pe,
904
913
  {
905
914
  value: s.value,
906
915
  onChange: (c) => {
@@ -929,7 +938,7 @@ function je({
929
938
  })) : [],
930
939
  initialValues: [],
931
940
  onSelect: (c) => {
932
- U(c) && l(
941
+ K(c) && l(
933
942
  `${a}.value`,
934
943
  c.map((o) => {
935
944
  if (r === "integer") {
@@ -944,8 +953,9 @@ function je({
944
953
  );
945
954
  case "number":
946
955
  return /* @__PURE__ */ t.jsx(
947
- h,
956
+ g,
948
957
  {
958
+ name: `${a}.value`,
949
959
  type: "number",
950
960
  defaultValue: typeof s.value == "number" ? s.value : "",
951
961
  placeholder: "Enter value",
@@ -961,6 +971,7 @@ function je({
961
971
  return /* @__PURE__ */ t.jsx(
962
972
  j,
963
973
  {
974
+ name: `${a}.value`,
964
975
  defaultValue: typeof s.value == "boolean" ? {
965
976
  label: s.value ? "Yes" : "No",
966
977
  value: s.value
@@ -970,15 +981,16 @@ function je({
970
981
  { label: "No", value: !1 }
971
982
  ],
972
983
  onSelect: (c) => {
973
- $(c) && l(u, c.value);
984
+ V(c) && l(u, c.value);
974
985
  }
975
986
  }
976
987
  );
977
988
  case "text":
978
989
  case null:
979
990
  return /* @__PURE__ */ t.jsx(
980
- h,
991
+ g,
981
992
  {
993
+ name: `${a}.value`,
982
994
  type: "text",
983
995
  defaultValue: typeof s.value == "string" ? s.value : JSON.stringify(s.value),
984
996
  placeholder: "Enter value",
@@ -997,7 +1009,7 @@ function Ne({
997
1009
  pathPrefix: l,
998
1010
  onDelete: i
999
1011
  }) {
1000
- const { setPath: u } = p(), s = [];
1012
+ const { setPath: u } = y(), s = [];
1001
1013
  return a < 2 && (s[0] ?? (s[0] = []), s[0].push(
1002
1014
  /* @__PURE__ */ t.jsx(
1003
1015
  S,
@@ -1026,8 +1038,9 @@ function Ne({
1026
1038
  /* @__PURE__ */ t.jsx("div", { className: "flex items-center justify-between gap-2 flex-grow p-2", children: /* @__PURE__ */ t.jsxs("div", { className: "flex flex-col gap-2 flex-grow", children: [
1027
1039
  /* @__PURE__ */ t.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
1028
1040
  /* @__PURE__ */ t.jsx("div", { className: "flex-1", children: /* @__PURE__ */ t.jsx(
1029
- h,
1041
+ g,
1030
1042
  {
1043
+ name: `${l}.field`,
1031
1044
  type: "text",
1032
1045
  defaultValue: e != null ? e.field : void 0,
1033
1046
  onChange: (r) => {
@@ -1038,15 +1051,15 @@ function Ne({
1038
1051
  }
1039
1052
  }
1040
1053
  ) }),
1041
- /* @__PURE__ */ t.jsx("div", { className: "flex-14", children: /* @__PURE__ */ t.jsx(me, { item: e, pathPrefix: l }) })
1054
+ /* @__PURE__ */ t.jsx("div", { className: "flex-14", children: /* @__PURE__ */ t.jsx(he, { item: e, pathPrefix: l }) })
1042
1055
  ] }),
1043
1056
  /* @__PURE__ */ t.jsx(je, { item: e, pathPrefix: l })
1044
1057
  ] }) }),
1045
1058
  s.length > 0 && /* @__PURE__ */ t.jsx(
1046
- P,
1059
+ z,
1047
1060
  {
1048
1061
  className: "w-8 border-l border-gray-100 flex items-center justify-center self-stretch",
1049
- dropdownLabel: /* @__PURE__ */ t.jsx("button", { className: "flex items-center justify-center self-stretch flex-grow", children: /* @__PURE__ */ t.jsx(v, { name: "dotsThreeVertical", size: 16, weight: "bold" }) }),
1062
+ dropdownLabel: /* @__PURE__ */ t.jsx("button", { className: "flex items-center justify-center self-stretch flex-grow", children: /* @__PURE__ */ t.jsx(p, { name: "dotsThreeVertical", size: 16, weight: "bold" }) }),
1050
1063
  dropdownItems: s.map((r, n, d) => /* @__PURE__ */ t.jsxs(I.Fragment, { children: [
1051
1064
  r.map((c, o) => /* @__PURE__ */ t.jsx(I.Fragment, { children: c }, o)),
1052
1065
  n < d.length - 1 && /* @__PURE__ */ t.jsx(ae, {})
@@ -1055,7 +1068,7 @@ function Ne({
1055
1068
  )
1056
1069
  ] });
1057
1070
  }
1058
- function B({
1071
+ function H({
1059
1072
  item: e,
1060
1073
  children: a,
1061
1074
  nestingLevel: l = 0,
@@ -1064,11 +1077,11 @@ function B({
1064
1077
  var o, f;
1065
1078
  const {
1066
1079
  state: { selectedRuleIndex: u }
1067
- } = p(), s = ((o = e == null ? void 0 : e.conditions_logic) == null ? void 0 : o.toLowerCase()) ?? "and", { setPath: r } = p(), [n, d] = g(0), c = l > 0;
1080
+ } = y(), s = ((o = e == null ? void 0 : e.conditions_logic) == null ? void 0 : o.toLowerCase()) ?? "and", { setPath: r } = y(), [n, d] = x(0), c = l > 0;
1068
1081
  return /* @__PURE__ */ t.jsxs(
1069
1082
  "div",
1070
1083
  {
1071
- className: C("query-group", {
1084
+ className: $("query-group", {
1072
1085
  "p-4 border border-gray-200 rounded-md": c
1073
1086
  }),
1074
1087
  children: [
@@ -1077,10 +1090,10 @@ function B({
1077
1090
  /* @__PURE__ */ t.jsxs(
1078
1091
  "select",
1079
1092
  {
1080
- onChange: (x) => {
1093
+ onChange: (m) => {
1081
1094
  r(
1082
1095
  `${i}.conditions_logic`,
1083
- x.currentTarget.value
1096
+ m.currentTarget.value
1084
1097
  );
1085
1098
  },
1086
1099
  defaultValue: s,
@@ -1097,32 +1110,32 @@ function B({
1097
1110
  ]
1098
1111
  }
1099
1112
  ),
1100
- /* @__PURE__ */ t.jsx("div", { className: "border-l border-gray-200 ml-3 pt-3", children: (f = e == null ? void 0 : e.conditions) == null ? void 0 : f.map((x, m, b) => {
1101
- const y = m === b.length - 1;
1113
+ /* @__PURE__ */ t.jsx("div", { className: "border-l border-gray-200 ml-3 pt-3", children: (f = e == null ? void 0 : e.conditions) == null ? void 0 : f.map((m, h, b) => {
1114
+ const v = h === b.length - 1;
1102
1115
  return /* @__PURE__ */ t.jsxs(
1103
1116
  "div",
1104
1117
  {
1105
1118
  className: "flex items-center mb-4 last:mb-0 relative",
1106
1119
  children: [
1107
- /* @__PURE__ */ t.jsx(_e, { rounded: y }),
1120
+ /* @__PURE__ */ t.jsx(_e, { rounded: v }),
1108
1121
  /* @__PURE__ */ t.jsx("div", { className: "ml-4 w-full", children: /* @__PURE__ */ t.jsx(
1109
- B,
1122
+ H,
1110
1123
  {
1111
- item: (x == null ? void 0 : x.nested) ?? void 0,
1112
- nestingLevel: (x == null ? void 0 : x.nested) != null ? l + 1 : 0,
1113
- pathPrefix: `${i}.conditions.${m}.nested`,
1124
+ item: (m == null ? void 0 : m.nested) ?? void 0,
1125
+ nestingLevel: (m == null ? void 0 : m.nested) != null ? l + 1 : 0,
1126
+ pathPrefix: `${i}.conditions.${h}.nested`,
1114
1127
  children: /* @__PURE__ */ t.jsx(
1115
1128
  "div",
1116
1129
  {
1117
- className: C({
1118
- "mb-4": (x == null ? void 0 : x.nested) != null
1130
+ className: $({
1131
+ "mb-4": (m == null ? void 0 : m.nested) != null
1119
1132
  }),
1120
1133
  children: /* @__PURE__ */ t.jsx(
1121
1134
  Ne,
1122
1135
  {
1123
- item: x,
1136
+ item: m,
1124
1137
  nestingLevel: l,
1125
- pathPrefix: `${i}.conditions.${m}`,
1138
+ pathPrefix: `${i}.conditions.${h}`,
1126
1139
  onDelete: b.length > 1 || l > 0 ? () => {
1127
1140
  d((_) => _ + 1);
1128
1141
  } : void 0
@@ -1134,7 +1147,7 @@ function B({
1134
1147
  ) })
1135
1148
  ]
1136
1149
  },
1137
- `${u}-${m}-${n}`
1150
+ `${u}-${h}-${n}`
1138
1151
  );
1139
1152
  }) })
1140
1153
  ] })
@@ -1155,7 +1168,7 @@ function we() {
1155
1168
  const {
1156
1169
  setPath: e,
1157
1170
  state: { value: a, selectedRuleIndex: l }
1158
- } = p(), [i, u] = g(
1171
+ } = y(), [i, u] = x(
1159
1172
  ((s = a.rules[l]) == null ? void 0 : s.name) ?? ""
1160
1173
  );
1161
1174
  return N(() => {
@@ -1184,7 +1197,7 @@ function we() {
1184
1197
  }
1185
1198
  const L = {
1186
1199
  rules: []
1187
- }, V = (e) => {
1200
+ }, C = (e) => {
1188
1201
  try {
1189
1202
  return JSON.parse(e ?? JSON.stringify(L));
1190
1203
  } catch {
@@ -1198,36 +1211,36 @@ const L = {
1198
1211
  }
1199
1212
  };
1200
1213
  function Ae(e) {
1201
- const [a, l] = g(
1202
- V(e.value ?? e.defaultValue)
1214
+ const [a, l] = x(
1215
+ C(e.value ?? e.defaultValue)
1203
1216
  );
1204
1217
  return N(
1205
1218
  function() {
1206
- a.rules.length === 0 && l(V(e.value));
1219
+ a.rules.length === 0 && l(C(e.value));
1207
1220
  },
1208
1221
  [e.value]
1209
- ), /* @__PURE__ */ t.jsx(fe, { initialValue: { rules: a.rules }, children: /* @__PURE__ */ t.jsx(Ce, { ...e }) });
1222
+ ), /* @__PURE__ */ t.jsx(fe, { initialValue: { rules: a.rules }, children: /* @__PURE__ */ t.jsx($e, { ...e }) });
1210
1223
  }
1211
- function Ce(e) {
1224
+ function $e(e) {
1212
1225
  const {
1213
1226
  state: { value: a, selectedRuleIndex: l },
1214
1227
  setSelectedRuleIndex: i,
1215
1228
  setValue: u,
1216
1229
  setPath: s
1217
- } = p(), [r, n] = g(
1230
+ } = y(), [r, n] = x(
1218
1231
  e.defaultCodeEditorVisible ?? !1
1219
- ), d = a.rules[l], c = ce(null), [o, f] = g(0);
1232
+ ), d = a.rules[l], c = ce(null), [o, f] = x(0);
1220
1233
  N(
1221
1234
  function() {
1222
- var b, y, _;
1223
- E(V((b = c.current) == null ? void 0 : b.getValue()), a) || (y = c.current) == null || y.setValue(JSON.stringify(a, null, 2)), (_ = e.onChange) == null || _.call(e, a);
1235
+ var b, v, _;
1236
+ E(C((b = c.current) == null ? void 0 : b.getValue()), a) || (v = c.current) == null || v.setValue(JSON.stringify(a, null, 2)), (_ = e.onChange) == null || _.call(e, a);
1224
1237
  },
1225
1238
  [a]
1226
1239
  );
1227
- const x = w(
1228
- (m) => {
1229
- const b = V(m);
1230
- c.current != null && c.current.hasTextFocus() && Te(m) && !E(b, a) && (u(b), f((y) => y + 1));
1240
+ const m = w(
1241
+ (h) => {
1242
+ const b = C(h);
1243
+ c.current != null && c.current.hasTextFocus() && Te(h) && !E(b, a) && (u(b), f((v) => v + 1));
1231
1244
  },
1232
1245
  [a]
1233
1246
  );
@@ -1245,26 +1258,26 @@ function Ce(e) {
1245
1258
  children: [
1246
1259
  /* @__PURE__ */ t.jsxs("header", { className: "w-full bg-white border-b border-gray-200 py-3 px-8 flex text-[13px] gap-4 text-gray-400 font-semibold items-center", children: [
1247
1260
  /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-4 flex-wrap", children: [
1248
- a.rules.map((m, b) => {
1249
- const y = `#${(b + 1).toString().padStart(2, "0")}`;
1261
+ a.rules.map((h, b) => {
1262
+ const v = `#${(b + 1).toString().padStart(2, "0")}`;
1250
1263
  return /* @__PURE__ */ t.jsx(
1251
1264
  "button",
1252
1265
  {
1253
- className: C("font-bold", {
1266
+ className: $("font-bold", {
1254
1267
  "text-black": l === b
1255
1268
  }),
1256
1269
  onClick: () => {
1257
1270
  i(b);
1258
1271
  },
1259
- children: y
1272
+ children: v
1260
1273
  },
1261
- m.id
1274
+ `${l}-${h.id}`
1262
1275
  );
1263
1276
  }),
1264
1277
  /* @__PURE__ */ t.jsx(
1265
1278
  "button",
1266
1279
  {
1267
- className: C("font-bold", {
1280
+ className: $("font-bold", {
1268
1281
  "text-black": !0
1269
1282
  }),
1270
1283
  onClick: () => {
@@ -1274,7 +1287,7 @@ function Ce(e) {
1274
1287
  conditions: [null]
1275
1288
  }), i(a.rules.length);
1276
1289
  },
1277
- children: /* @__PURE__ */ t.jsx(v, { name: "plus", size: 16, className: "shrink-0" })
1290
+ children: /* @__PURE__ */ t.jsx(p, { name: "plus", size: 16, className: "shrink-0" })
1278
1291
  }
1279
1292
  )
1280
1293
  ] }),
@@ -1285,40 +1298,40 @@ function Ce(e) {
1285
1298
  onClick: () => {
1286
1299
  n(!r);
1287
1300
  },
1288
- children: /* @__PURE__ */ t.jsx(v, { name: "sidebarSimple", size: 16, color: "#101111" })
1301
+ children: /* @__PURE__ */ t.jsx(p, { name: "sidebarSimple", size: 16, color: "#101111" })
1289
1302
  }
1290
1303
  ) })
1291
1304
  ] }),
1292
- /* @__PURE__ */ t.jsxs($e, { children: [
1305
+ /* @__PURE__ */ t.jsxs(Ve, { children: [
1293
1306
  /* @__PURE__ */ t.jsxs("div", { className: "mb-8 flex items-center gap-2", children: [
1294
1307
  /* @__PURE__ */ t.jsx(we, {}),
1295
- /* @__PURE__ */ t.jsx(v, { name: "pencilSimple", size: 16, className: "shrink-0" })
1308
+ /* @__PURE__ */ t.jsx(p, { name: "pencilSimple", size: 16, className: "shrink-0" })
1296
1309
  ] }),
1297
- /* @__PURE__ */ t.jsx(J, { title: "Actions", icon: "lightning", children: /* @__PURE__ */ t.jsx(ge, { actions: d == null ? void 0 : d.actions }) }),
1298
- /* @__PURE__ */ t.jsx(Ve, { children: "when" }),
1310
+ /* @__PURE__ */ t.jsx(J, { title: "Actions", icon: "lightning", children: /* @__PURE__ */ t.jsx(xe, { actions: d == null ? void 0 : d.actions }) }),
1311
+ /* @__PURE__ */ t.jsx(Ce, { children: "when" }),
1299
1312
  /* @__PURE__ */ t.jsxs(J, { title: "Conditions", icon: "treeView", children: [
1300
1313
  /* @__PURE__ */ t.jsx(
1301
- B,
1314
+ H,
1302
1315
  {
1303
1316
  item: d,
1304
1317
  pathPrefix: `rules.${l}`
1305
1318
  }
1306
1319
  ),
1307
1320
  /* @__PURE__ */ t.jsx("div", { className: "mt-6", children: /* @__PURE__ */ t.jsxs(
1308
- z,
1321
+ U,
1309
1322
  {
1310
1323
  size: "small",
1311
1324
  variant: "secondary",
1312
1325
  alignItems: "center",
1313
1326
  onClick: () => {
1314
- var m;
1327
+ var h;
1315
1328
  s(
1316
- `rules.${l}.conditions.${((m = d == null ? void 0 : d.conditions) == null ? void 0 : m.length) ?? 0}`,
1329
+ `rules.${l}.conditions.${((h = d == null ? void 0 : d.conditions) == null ? void 0 : h.length) ?? 0}`,
1317
1330
  void 0
1318
1331
  );
1319
1332
  },
1320
1333
  children: [
1321
- /* @__PURE__ */ t.jsx(v, { name: "plusCircle" }),
1334
+ /* @__PURE__ */ t.jsx(p, { name: "plusCircle" }),
1322
1335
  " Add condition"
1323
1336
  ]
1324
1337
  }
@@ -1339,14 +1352,14 @@ function Ce(e) {
1339
1352
  jsonSchema: "order-rules",
1340
1353
  defaultValue: JSON.stringify(a, null, 2),
1341
1354
  noRounding: !0,
1342
- onChange: x
1355
+ onChange: m
1343
1356
  }
1344
1357
  ) })
1345
1358
  ] })
1346
1359
  }
1347
1360
  );
1348
1361
  }
1349
- function Ve({ children: e }) {
1362
+ function Ce({ children: e }) {
1350
1363
  return /* @__PURE__ */ t.jsxs("div", { className: "text-gray-500 flex items-center justify-center flex-col", children: [
1351
1364
  /* @__PURE__ */ t.jsx("div", { className: "h-6 w-[2px] bg-gray-200" }),
1352
1365
  /* @__PURE__ */ t.jsx("span", { className: "font-bold my-1 bg-gray-200 px-3 relative uppercase rounded h-[25px] items-center flex text-sm", children: e }),
@@ -1360,13 +1373,13 @@ function J({
1360
1373
  }) {
1361
1374
  return /* @__PURE__ */ t.jsxs("div", { className: "rounded-md bg-white shadow-sm", children: [
1362
1375
  /* @__PURE__ */ t.jsxs("div", { className: "flex items-center space-x-4 py-4 border-b border-gray-100", children: [
1363
- /* @__PURE__ */ t.jsx("div", { className: "w-8 h-8 -ml-4 bg-white rounded-full border border-gray-200 flex items-center justify-center shadow-sm shadow-primary-200", children: /* @__PURE__ */ t.jsx(v, { name: l }) }),
1376
+ /* @__PURE__ */ t.jsx("div", { className: "w-8 h-8 -ml-4 bg-white rounded-full border border-gray-200 flex items-center justify-center shadow-sm shadow-primary-200", children: /* @__PURE__ */ t.jsx(p, { name: l }) }),
1364
1377
  /* @__PURE__ */ t.jsx("h2", { className: "text-lg font-semibold", children: a })
1365
1378
  ] }),
1366
1379
  /* @__PURE__ */ t.jsx("div", { className: "p-6", children: e })
1367
1380
  ] });
1368
1381
  }
1369
- function $e({
1382
+ function Ve({
1370
1383
  children: e
1371
1384
  }) {
1372
1385
  return /* @__PURE__ */ t.jsx("div", { className: "h-full w-full bg-gray-50 p-8 [background-image:radial-gradient(#d6d6d6_1px,transparent_1px)] [background-size:16px_16px] overflow-auto", children: /* @__PURE__ */ t.jsx("div", { className: "max-w-[900px] mx-auto", children: e }) });