@commercelayer/app-elements 5.4.2 → 5.5.1

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.
Files changed (45) hide show
  1. package/dist/CodeEditorComponent-ioY-kydb.js +739 -0
  2. package/dist/{InputDateComponent-BB1cA4uH.js → InputDateComponent-BuVP44xp.js} +1174 -1301
  3. package/dist/RuleEngineComponent-CGOH-VpI.js +1376 -0
  4. package/dist/fetchCoreResourcesSuggestions-CZkDwjO2.js +126 -0
  5. package/dist/helpers/giftCards.d.ts +1 -0
  6. package/dist/helpers/giftCards.test.d.ts +1 -0
  7. package/dist/{main-DvygJyZL.js → main-Dncz1fnB.js} +8819 -8151
  8. package/dist/main.d.ts +3 -0
  9. package/dist/main.js +137 -133
  10. package/dist/parseISO-DFqToJvK.js +120 -0
  11. package/dist/style.css +1 -1
  12. package/dist/tailwind.config.js +5 -5
  13. package/dist/ui/atoms/Icon/icons.d.ts +5 -0
  14. package/dist/ui/composite/ListItem.d.ts +3 -1
  15. package/dist/ui/composite/Timeline.d.ts +1 -0
  16. package/dist/ui/composite/Toast.d.ts +8 -0
  17. package/dist/ui/forms/CodeEditor/CodeEditor.d.ts +2 -1
  18. package/dist/ui/forms/CodeEditor/CodeEditorComponent.d.ts +10 -1
  19. package/dist/ui/forms/CodeEditor/fetchCoreResourcesSuggestions.d.ts +34 -18
  20. package/dist/ui/forms/RuleEngine/Action/ActionListItem.d.ts +6 -0
  21. package/dist/ui/forms/RuleEngine/Action/ActionValue.d.ts +5 -0
  22. package/dist/ui/forms/RuleEngine/Action/index.d.ts +4 -0
  23. package/dist/ui/forms/RuleEngine/Condition/ConditionListItem.d.ts +8 -0
  24. package/dist/ui/forms/RuleEngine/Condition/ConditionMatcher.d.ts +6 -0
  25. package/dist/ui/forms/RuleEngine/Condition/ConditionValue.d.ts +12 -0
  26. package/dist/ui/forms/RuleEngine/Condition/ValueComponents/InputArrayMatch.d.ts +6 -0
  27. package/dist/ui/forms/RuleEngine/Condition/ValueComponents/InputNumberRange.d.ts +6 -0
  28. package/dist/ui/forms/RuleEngine/Condition/ValueComponents/InputTextRange.d.ts +6 -0
  29. package/dist/ui/forms/RuleEngine/Condition/hooks.d.ts +5 -0
  30. package/dist/ui/forms/RuleEngine/Condition/index.d.ts +8 -0
  31. package/dist/ui/forms/RuleEngine/Condition/utils.d.ts +3 -0
  32. package/dist/ui/forms/RuleEngine/RuleEngine.d.ts +3 -0
  33. package/dist/ui/forms/RuleEngine/RuleEngineComponent.d.ts +22 -0
  34. package/dist/ui/forms/RuleEngine/RuleEngineContext.d.ts +18 -0
  35. package/dist/ui/forms/RuleEngine/RuleName.d.ts +1 -0
  36. package/dist/ui/forms/RuleEngine/index.d.ts +2 -0
  37. package/dist/ui/forms/RuleEngine/schema.order_rules.d.ts +335 -0
  38. package/dist/ui/forms/RuleEngine/schema.price_rules.d.ts +286 -0
  39. package/dist/ui/forms/RuleEngine/utils.d.ts +24 -0
  40. package/dist/ui/internals/Overlay.d.ts +13 -0
  41. package/dist/ui/resources/ResourceLineItems/ResourceLineItems.mocks.d.ts +17 -0
  42. package/dist/ui/resources/ResourceListItem/ResourceListItem.mocks.d.ts +24 -0
  43. package/dist/vendor.css +1 -1
  44. package/package.json +6 -2
  45. package/dist/CodeEditorComponent-CZdWLH8G.js +0 -794
@@ -0,0 +1,1376 @@
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-Dncz1fnB.js";
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";
5
+ import { a as de } from "./fetchCoreResourcesSuggestions-CZkDwjO2.js";
6
+ import { p as A } from "./parseISO-DFqToJvK.js";
7
+ function q(e, a) {
8
+ const l = e.match(
9
+ /(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2}):(\d{2})(?:\.(\d{0,7}))?(?:Z|(.)(\d{2}):?(\d{2})?)?/
10
+ );
11
+ return l ? k(
12
+ Date.UTC(
13
+ +l[1],
14
+ +l[2] - 1,
15
+ +l[3],
16
+ +l[4] - (+l[9] || 0) * (l[8] == "-" ? -1 : 1),
17
+ +l[5] - (+l[10] || 0) * (l[8] == "-" ? -1 : 1),
18
+ +l[6],
19
+ +((l[7] || "0") + "00").substring(0, 3)
20
+ ),
21
+ a == null ? void 0 : a.in
22
+ ) : k(NaN, a == null ? void 0 : a.in);
23
+ }
24
+ function D(e, a, l) {
25
+ return e == null ? e : H(e, a, l);
26
+ }
27
+ function M(e, a) {
28
+ return e == null ? !0 : Z(e, a);
29
+ }
30
+ const K = ie(
31
+ void 0
32
+ );
33
+ function oe(e, a) {
34
+ var l;
35
+ switch (a.type) {
36
+ case "SET_PATH": {
37
+ const i = { ...e.value };
38
+ if (a.value === null)
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);
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
+ } else
43
+ M(i, a.path);
44
+ else
45
+ D(i, a.path, a.value);
46
+ return {
47
+ ...e,
48
+ value: i
49
+ };
50
+ }
51
+ case "SET_SELECTED_RULE_INDEX":
52
+ return {
53
+ ...e,
54
+ selectedRuleIndex: a.index
55
+ };
56
+ case "SET_VALUE":
57
+ return E(e.value, a.value) ? e : a.value.rules.length === 0 ? {
58
+ selectedRuleIndex: 0,
59
+ value: {
60
+ rules: [
61
+ {
62
+ name: "Rule name",
63
+ // @ts-expect-error Setting `null` is intentional for rendering an empty action
64
+ actions: [null],
65
+ // @ts-expect-error Setting `null` is intentional for rendering an empty condition
66
+ conditions: [null]
67
+ }
68
+ ]
69
+ }
70
+ } : {
71
+ ...e,
72
+ value: a.value
73
+ };
74
+ default:
75
+ return e;
76
+ }
77
+ }
78
+ function fe({
79
+ children: e,
80
+ initialValue: a
81
+ }) {
82
+ const [l, i] = se(oe, {
83
+ value: a,
84
+ selectedRuleIndex: 0
85
+ }), u = w((d, c) => {
86
+ i({ type: "SET_PATH", path: d, value: c });
87
+ }, []), s = w((d) => {
88
+ i({ type: "SET_SELECTED_RULE_INDEX", index: d });
89
+ }, []), r = w((d) => {
90
+ i({ type: "SET_VALUE", value: d });
91
+ }, []), n = re(
92
+ () => ({
93
+ state: l,
94
+ setPath: u,
95
+ setSelectedRuleIndex: s,
96
+ setValue: r
97
+ }),
98
+ [l, u, s, r]
99
+ );
100
+ return /* @__PURE__ */ t.jsx(K.Provider, { value: n, children: e });
101
+ }
102
+ function p() {
103
+ const e = ue(K);
104
+ if (e === void 0)
105
+ throw new Error("useRuleEngine must be used within a RuleEngineProvider");
106
+ return e;
107
+ }
108
+ const W = Q([
109
+ "blank",
110
+ "present",
111
+ "null",
112
+ "not_null"
113
+ ]);
114
+ function R(e) {
115
+ return null;
116
+ }
117
+ function xe({
118
+ item: e,
119
+ pathPrefix: a
120
+ }) {
121
+ var i, u, s, r;
122
+ const { setPath: l } = p();
123
+ if (e == null)
124
+ return null;
125
+ switch (e.type) {
126
+ case "buy_x_pay_y":
127
+ return /* @__PURE__ */ t.jsxs("div", { className: "w-36 flex items-center gap-0.5", children: [
128
+ /* @__PURE__ */ t.jsx(
129
+ h,
130
+ {
131
+ type: "number",
132
+ suffix: "X",
133
+ defaultValue: (i = e.value) == null ? void 0 : i.x,
134
+ onChange: (n) => {
135
+ l(
136
+ `${a}.value.x`,
137
+ parseInt(n.currentTarget.value, 10)
138
+ );
139
+ }
140
+ }
141
+ ),
142
+ /* @__PURE__ */ t.jsx(
143
+ h,
144
+ {
145
+ type: "number",
146
+ suffix: "Y",
147
+ defaultValue: (u = e.value) == null ? void 0 : u.y,
148
+ onChange: (n) => {
149
+ l(
150
+ `${a}.value.y`,
151
+ parseInt(n.currentTarget.value, 10)
152
+ );
153
+ }
154
+ }
155
+ )
156
+ ] });
157
+ case "every_x_discount_y":
158
+ return /* @__PURE__ */ t.jsxs("div", { className: "w-36 flex items-center gap-0.5", children: [
159
+ /* @__PURE__ */ t.jsx(
160
+ h,
161
+ {
162
+ type: "number",
163
+ suffix: "X",
164
+ defaultValue: (s = e.value) == null ? void 0 : s.x,
165
+ onChange: (n) => {
166
+ l(
167
+ `${a}.value.x`,
168
+ parseInt(n.currentTarget.value, 10)
169
+ );
170
+ }
171
+ }
172
+ ),
173
+ /* @__PURE__ */ t.jsx(
174
+ h,
175
+ {
176
+ type: "number",
177
+ suffix: "Y",
178
+ defaultValue: (r = e.value) == null ? void 0 : r.y,
179
+ onChange: (n) => {
180
+ l(
181
+ `${a}.value.y`,
182
+ parseInt(n.currentTarget.value, 10)
183
+ );
184
+ }
185
+ }
186
+ )
187
+ ] });
188
+ case "fixed_amount":
189
+ case "fixed_price":
190
+ return /* @__PURE__ */ t.jsx("div", { className: "w-36", children: /* @__PURE__ */ t.jsx(
191
+ h,
192
+ {
193
+ type: "number",
194
+ defaultValue: e.value,
195
+ min: 0,
196
+ suffix: "cents",
197
+ onChange: (n) => {
198
+ l(
199
+ `${a}.value`,
200
+ parseInt(n.currentTarget.value, 10)
201
+ );
202
+ }
203
+ }
204
+ ) });
205
+ case "percentage": {
206
+ const n = (e.value * 100).toFixed(2);
207
+ return /* @__PURE__ */ t.jsx("div", { className: "w-24", children: /* @__PURE__ */ t.jsx(
208
+ h,
209
+ {
210
+ type: "number",
211
+ defaultValue: n.endsWith(".00") ? n.slice(0, -3) : n,
212
+ min: 0,
213
+ max: 100,
214
+ suffix: "%",
215
+ onChange: (d) => {
216
+ l(
217
+ `${a}.value`,
218
+ parseFloat(d.currentTarget.value) / 100
219
+ );
220
+ }
221
+ }
222
+ ) });
223
+ }
224
+ default:
225
+ return R();
226
+ }
227
+ }
228
+ function he({
229
+ item: e,
230
+ index: a,
231
+ onDelete: l
232
+ }) {
233
+ const {
234
+ setPath: i,
235
+ state: { selectedRuleIndex: u }
236
+ } = p(), s = {
237
+ percentage: "Percentage discount",
238
+ fixed_amount: "Fixed amount",
239
+ fixed_price: "Fixed price",
240
+ buy_x_pay_y: "Buy X, Pay Y",
241
+ every_x_discount_y: "Every X, Discount Y"
242
+ }, r = `rules.${u}.actions.${a}`;
243
+ return /* @__PURE__ */ t.jsx("div", { className: "mb-4 last:mb-0", children: /* @__PURE__ */ t.jsxs("div", { className: "bg-gray-50 rounded-md flex items-center", children: [
244
+ /* @__PURE__ */ t.jsxs("div", { className: "flex items-center justify-between gap-2 flex-grow p-2", children: [
245
+ /* @__PURE__ */ t.jsx("div", { className: "flex-1", children: /* @__PURE__ */ t.jsx(
246
+ j,
247
+ {
248
+ defaultValue: e != null ? {
249
+ label: s[e.type],
250
+ value: e.type
251
+ } : void 0,
252
+ initialValues: Object.entries(s).map(
253
+ ([n, d]) => ({ value: n, label: d })
254
+ ),
255
+ onSelect: (n) => {
256
+ $(n) && i(`${r}.type`, n.value);
257
+ }
258
+ }
259
+ ) }),
260
+ /* @__PURE__ */ t.jsx(xe, { item: e, pathPrefix: r }),
261
+ /* @__PURE__ */ t.jsx("div", { className: "text-black font-bold text-sm", children: "ON" }),
262
+ /* @__PURE__ */ t.jsx("div", { className: "flex-1", children: /* @__PURE__ */ t.jsx(
263
+ h,
264
+ {
265
+ type: "text",
266
+ defaultValue: e != null ? e.selector : void 0,
267
+ onChange: (n) => {
268
+ i(`${r}.selector`, n.currentTarget.value);
269
+ }
270
+ }
271
+ ) })
272
+ ] }),
273
+ l != null && /* @__PURE__ */ t.jsx(
274
+ P,
275
+ {
276
+ 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" }) }),
278
+ dropdownItems: /* @__PURE__ */ t.jsx(t.Fragment, { children: /* @__PURE__ */ t.jsx(
279
+ S,
280
+ {
281
+ label: "Delete",
282
+ onClick: () => {
283
+ i(`${r}`, null), l();
284
+ }
285
+ }
286
+ ) })
287
+ }
288
+ )
289
+ ] }) });
290
+ }
291
+ function ge({
292
+ actions: e
293
+ }) {
294
+ const [a, l] = g(0), {
295
+ setPath: i,
296
+ state: { selectedRuleIndex: u }
297
+ } = p();
298
+ return /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
299
+ /* @__PURE__ */ t.jsx("div", { children: e == null ? void 0 : e.map((s, r, n) => /* @__PURE__ */ t.jsx(
300
+ he,
301
+ {
302
+ item: s,
303
+ index: r,
304
+ onDelete: n.length > 1 ? () => {
305
+ l((d) => d + 1);
306
+ } : void 0
307
+ },
308
+ `${u}-${r}-${a}`
309
+ )) }),
310
+ /* @__PURE__ */ t.jsx("div", { className: "mt-6", children: /* @__PURE__ */ t.jsxs(
311
+ z,
312
+ {
313
+ size: "small",
314
+ variant: "secondary",
315
+ alignItems: "center",
316
+ onClick: () => {
317
+ i(
318
+ `rules.${u}.actions.${(e == null ? void 0 : e.length) ?? 0}`,
319
+ void 0
320
+ );
321
+ },
322
+ children: [
323
+ /* @__PURE__ */ t.jsx(v, { name: "plusCircle" }),
324
+ " Add action"
325
+ ]
326
+ }
327
+ ) })
328
+ ] });
329
+ }
330
+ function X(e) {
331
+ const [a, l] = g(void 0);
332
+ return N(() => {
333
+ (e == null ? void 0 : e.field) != null && de(e.field).then((i) => {
334
+ l(i);
335
+ }).catch((i) => {
336
+ console.error("Error fetching field info:", i);
337
+ });
338
+ }, [e == null ? void 0 : e.field]), { infos: a };
339
+ }
340
+ function Y(e) {
341
+ if (typeof e == "string")
342
+ return T(q(e)) ? "datetime" : "string";
343
+ if (typeof e == "number")
344
+ return "integer";
345
+ if (typeof e == "boolean")
346
+ return "boolean";
347
+ if (Array.isArray(e)) {
348
+ if (typeof e[0] == "string")
349
+ return T(q(e[0])) ? "datetime" : "string";
350
+ if (typeof e[0] == "number")
351
+ return "integer";
352
+ }
353
+ return "string";
354
+ }
355
+ function me({
356
+ item: e,
357
+ pathPrefix: a
358
+ }) {
359
+ var s, r;
360
+ const { setPath: l } = p(), { infos: i } = X(e);
361
+ 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(
363
+ j,
364
+ {
365
+ value: e != null ? {
366
+ 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
+ (e.matcher != null ? `⚠️   ${e.matcher}` : ""),
368
+ value: e.matcher
369
+ } : void 0,
370
+ initialValues: O.filter(({ fieldTypes: n, visible: d }) => d !== !1 && n.includes(u)).map(({ matcher: n, label: d }) => ({ value: n, label: d })),
371
+ onSelect: (n) => {
372
+ $(n) && (l(`${a}.matcher`, n.value), W.includes(
373
+ n.value
374
+ ) && l(`${a}.value`, null));
375
+ }
376
+ }
377
+ );
378
+ }
379
+ const O = [
380
+ {
381
+ /** Matches if field value equals provided value
382
+ * @field Integer, String, Datetime, Boolean
383
+ * @value Integer, String, Datetime, Boolean
384
+ */
385
+ matcher: "eq",
386
+ label: "equals",
387
+ fieldTypes: ["integer", "string", "datetime", "boolean"]
388
+ },
389
+ {
390
+ /** Matches if field value is not equal to provided value
391
+ * @field Integer, String, Datetime, Boolean
392
+ * @value Integer, String, Datetime, Boolean
393
+ */
394
+ matcher: "not_eq",
395
+ label: "not equals",
396
+ fieldTypes: ["integer", "string", "datetime", "boolean"]
397
+ },
398
+ {
399
+ /** Matches if field value is less than provided value
400
+ * @field Integer, Datetime
401
+ * @value Integer, Datetime
402
+ */
403
+ matcher: "lt",
404
+ label: "<",
405
+ fieldTypes: ["integer", "datetime"]
406
+ },
407
+ {
408
+ /** Matches if field value is less than or equal to provided value
409
+ * @field Integer, Datetime
410
+ * @value Integer, Datetime
411
+ */
412
+ matcher: "lteq",
413
+ label: "≤",
414
+ fieldTypes: ["integer", "datetime"]
415
+ },
416
+ {
417
+ /** Matches if field value is greater than provided value
418
+ * @field Integer, Datetime
419
+ * @value Integer, Datetime
420
+ */
421
+ matcher: "gt",
422
+ label: ">",
423
+ fieldTypes: ["integer", "datetime"]
424
+ },
425
+ {
426
+ /** Matches if field value is greater than or equal to provided value
427
+ * @field Integer, Datetime
428
+ * @value Integer, Datetime
429
+ */
430
+ matcher: "gteq",
431
+ label: "≥",
432
+ fieldTypes: ["integer", "datetime"]
433
+ },
434
+ {
435
+ /** Matches if field value is a multiple of provided value
436
+ * @field Integer
437
+ * @value Integer
438
+ */
439
+ matcher: "multiple",
440
+ label: "is a multiple of",
441
+ fieldTypes: ["integer"]
442
+ },
443
+ {
444
+ /** Matches if field value matches regex pattern
445
+ * @field String
446
+ * @value String
447
+ */
448
+ matcher: "matches",
449
+ label: "matches regex",
450
+ fieldTypes: ["string"]
451
+ },
452
+ {
453
+ /** Matches if field value does not match regex pattern
454
+ * @field String
455
+ * @value String
456
+ */
457
+ matcher: "does_not_match",
458
+ label: "doesn't match regex",
459
+ fieldTypes: ["string"]
460
+ },
461
+ {
462
+ /** Matches if field value starts with provided string
463
+ * @field String
464
+ * @value String
465
+ */
466
+ matcher: "start_with",
467
+ label: "starts with",
468
+ fieldTypes: ["string"]
469
+ },
470
+ {
471
+ /** Matches if field value does not start with provided string
472
+ * @field String
473
+ * @value String
474
+ */
475
+ matcher: "not_start_with",
476
+ label: "doesn't start with",
477
+ fieldTypes: ["string"]
478
+ },
479
+ {
480
+ /** Matches if field value ends with provided string
481
+ * @field String
482
+ * @value String
483
+ */
484
+ matcher: "end_with",
485
+ label: "ends with",
486
+ fieldTypes: ["string"]
487
+ },
488
+ {
489
+ /** Matches if field value does not end with provided string
490
+ * @field String
491
+ * @value String
492
+ */
493
+ matcher: "not_end_with",
494
+ label: "doesn't end with",
495
+ fieldTypes: ["string"]
496
+ },
497
+ {
498
+ /** Matches if field value is between two values (exclusive)
499
+ * @field Integer, Datetime
500
+ * @value Array
501
+ */
502
+ matcher: "gt_lt",
503
+ label: "> and <",
504
+ fieldTypes: ["integer"]
505
+ },
506
+ {
507
+ /** Matches if field value is between two values (inclusive start, exclusive end)
508
+ * @field Integer, Datetime
509
+ * @value Array
510
+ */
511
+ matcher: "gteq_lt",
512
+ label: "≥ and <",
513
+ fieldTypes: ["integer"]
514
+ },
515
+ {
516
+ /** Matches if field value is greater than first and less than or equal to second
517
+ * @field Integer, Datetime
518
+ * @value Array
519
+ */
520
+ matcher: "gt_lteq",
521
+ label: "> and ≤",
522
+ fieldTypes: ["integer"]
523
+ },
524
+ {
525
+ /** Matches if field value is between two values (inclusive)
526
+ * @field Integer, Datetime
527
+ * @value Array
528
+ */
529
+ matcher: "gteq_lteq",
530
+ label: "≥ and ≤",
531
+ fieldTypes: ["integer"]
532
+ },
533
+ {
534
+ /** Matches if field value is between two values (exclusive)
535
+ * @field Integer, Datetime
536
+ * @value Array
537
+ */
538
+ matcher: "gt_lt",
539
+ label: "date range",
540
+ visible: !1,
541
+ fieldTypes: ["datetime"]
542
+ },
543
+ {
544
+ /** Matches if field value is between two values (inclusive start, exclusive end)
545
+ * @field Integer, Datetime
546
+ * @value Array
547
+ */
548
+ matcher: "gteq_lt",
549
+ label: "date range",
550
+ visible: !1,
551
+ fieldTypes: ["datetime"]
552
+ },
553
+ {
554
+ /** Matches if field value is greater than first and less than or equal to second
555
+ * @field Integer, Datetime
556
+ * @value Array
557
+ */
558
+ matcher: "gt_lteq",
559
+ label: "date range",
560
+ visible: !1,
561
+ fieldTypes: ["datetime"]
562
+ },
563
+ {
564
+ /** Matches if field value is between two values (inclusive)
565
+ * @field Integer, Datetime
566
+ * @value Array
567
+ */
568
+ matcher: "gteq_lteq",
569
+ label: "date range",
570
+ visible: !0,
571
+ fieldTypes: ["datetime"]
572
+ },
573
+ {
574
+ /** Matches if field value is in provided array
575
+ * @field Integer, String, Datetime
576
+ * @value Array
577
+ */
578
+ matcher: "is_in",
579
+ label: "is one of",
580
+ fieldTypes: ["integer", "string", "datetime"]
581
+ },
582
+ {
583
+ /** Matches if field value is not in provided array
584
+ * @field Integer, String, Datetime
585
+ * @value Array
586
+ */
587
+ matcher: "is_not_in",
588
+ label: "is not one of",
589
+ fieldTypes: ["integer", "string", "datetime"]
590
+ },
591
+ {
592
+ /** Matches objects within arrays that meet specified requirements
593
+ * @field Array
594
+ * @value Object
595
+ */
596
+ matcher: "array_match",
597
+ label: "is",
598
+ fieldTypes: ["integer", "string", "datetime"]
599
+ },
600
+ {
601
+ /** Matches if field value is null or empty string */
602
+ matcher: "blank",
603
+ label: "is blank",
604
+ fieldTypes: ["integer", "string", "datetime", "boolean"]
605
+ },
606
+ {
607
+ /** Matches if field value is null */
608
+ matcher: "null",
609
+ label: "is null",
610
+ fieldTypes: ["integer", "string", "datetime", "boolean"]
611
+ },
612
+ {
613
+ /** Matches if field value is not null */
614
+ matcher: "not_null",
615
+ label: "is not null",
616
+ fieldTypes: ["integer", "string", "datetime", "boolean"]
617
+ },
618
+ {
619
+ /** Matches if field value is not null */
620
+ matcher: "present",
621
+ label: "is present",
622
+ fieldTypes: ["integer", "string", "datetime", "boolean"]
623
+ }
624
+ ], F = {
625
+ in_and: {
626
+ label: "all of"
627
+ },
628
+ in_or: {
629
+ label: "at least one of"
630
+ },
631
+ not_in_and: {
632
+ label: "not any of"
633
+ },
634
+ not_in_or: {
635
+ label: "not at least one of"
636
+ }
637
+ };
638
+ function be({
639
+ value: e,
640
+ pathPrefix: a
641
+ }) {
642
+ return (typeof e != "object" || Array.isArray(e) || e === null) && (e = {
643
+ in_and: []
644
+ }), /* @__PURE__ */ t.jsx("div", { children: Object.entries(e).map(([l, i], u) => /* @__PURE__ */ t.jsx(
645
+ pe,
646
+ {
647
+ pathPrefix: a,
648
+ defaultValue: i,
649
+ initialMatcher: l
650
+ },
651
+ `${a}.${u}`
652
+ )) });
653
+ }
654
+ function pe({
655
+ initialMatcher: e,
656
+ defaultValue: a,
657
+ pathPrefix: l
658
+ }) {
659
+ const [i, u] = g(e), [s, r] = g(e), [n, d] = g(a), { setPath: c } = p();
660
+ return N(() => {
661
+ i !== s && (c(`${l}.${i}`, null), u(s)), c(`${l}.${s}`, n);
662
+ }, [s, n, c]), /* @__PURE__ */ t.jsxs("div", { className: "flex gap-2 last-of-type:mt-2", children: [
663
+ /* @__PURE__ */ t.jsx("div", { className: "flex-shrink-0", children: /* @__PURE__ */ t.jsx(
664
+ j,
665
+ {
666
+ defaultValue: [
667
+ { value: s, label: F[s].label }
668
+ ],
669
+ initialValues: Object.entries(F).map(
670
+ ([o, { label: f }]) => ({
671
+ value: o,
672
+ label: f
673
+ })
674
+ ),
675
+ onSelect: (o) => {
676
+ $(o) && r(o.value);
677
+ }
678
+ }
679
+ ) }),
680
+ /* @__PURE__ */ t.jsx("div", { className: "flex-grow", children: /* @__PURE__ */ t.jsx(
681
+ j,
682
+ {
683
+ isMulti: !0,
684
+ isCreatable: !0,
685
+ defaultValue: (Array.isArray(n) ? n : []).map((o) => ({
686
+ value: o,
687
+ label: o.toString()
688
+ })),
689
+ initialValues: [],
690
+ onSelect: (o) => {
691
+ U(o) && d(
692
+ o.map(
693
+ (f) => typeof f.value == "boolean" ? f.value.toString() : f.value
694
+ )
695
+ );
696
+ }
697
+ }
698
+ ) })
699
+ ] });
700
+ }
701
+ function ye({
702
+ value: e,
703
+ onChange: a
704
+ }) {
705
+ const [l, i] = g(
706
+ Array.isArray(e) && typeof e[0] == "number" ? e[0] : null
707
+ ), [u, s] = g(
708
+ Array.isArray(e) && typeof e[1] == "number" ? e[1] : null
709
+ );
710
+ return /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-4", children: [
711
+ /* @__PURE__ */ t.jsx("div", { className: "flex-grow", children: /* @__PURE__ */ t.jsx(
712
+ h,
713
+ {
714
+ type: "number",
715
+ placeholder: "Min",
716
+ value: l ?? "",
717
+ onChange: (r) => {
718
+ const n = parseInt(r.currentTarget.value, 10);
719
+ i(isNaN(n) ? null : n), a([isNaN(n) ? null : n, u]);
720
+ }
721
+ }
722
+ ) }),
723
+ /* @__PURE__ */ t.jsx("span", { className: "text-gray-300", children: "to" }),
724
+ /* @__PURE__ */ t.jsx("div", { className: "flex-grow", children: /* @__PURE__ */ t.jsx(
725
+ h,
726
+ {
727
+ type: "number",
728
+ placeholder: "Max",
729
+ value: u ?? "",
730
+ onChange: (r) => {
731
+ const n = parseInt(r.currentTarget.value, 10);
732
+ s(isNaN(n) ? null : n), a([l, isNaN(n) ? null : n]);
733
+ }
734
+ }
735
+ ) })
736
+ ] });
737
+ }
738
+ function ve({
739
+ value: e,
740
+ onChange: a
741
+ }) {
742
+ const [l, i] = g(
743
+ Array.isArray(e) && typeof e[0] == "string" ? e[0] : null
744
+ ), [u, s] = g(
745
+ Array.isArray(e) && typeof e[1] == "string" ? e[1] : null
746
+ );
747
+ return /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-4", children: [
748
+ /* @__PURE__ */ t.jsx("div", { className: "flex-grow", children: /* @__PURE__ */ t.jsx(
749
+ h,
750
+ {
751
+ type: "text",
752
+ placeholder: "Min",
753
+ value: l ?? "",
754
+ onChange: (r) => {
755
+ const n = r.currentTarget.value;
756
+ i(n), a([n, u]);
757
+ }
758
+ }
759
+ ) }),
760
+ /* @__PURE__ */ t.jsx("span", { className: "text-gray-300", children: "to" }),
761
+ /* @__PURE__ */ t.jsx("div", { className: "flex-grow", children: /* @__PURE__ */ t.jsx(
762
+ h,
763
+ {
764
+ type: "text",
765
+ placeholder: "Max",
766
+ value: u ?? "",
767
+ onChange: (r) => {
768
+ const n = r.currentTarget.value;
769
+ s(n), a([l, n]);
770
+ }
771
+ }
772
+ ) })
773
+ ] });
774
+ }
775
+ function je({
776
+ item: e,
777
+ pathPrefix: a
778
+ }) {
779
+ var d;
780
+ const { setPath: l } = p(), { infos: i } = X(e), u = `${a}.value`;
781
+ if (e == null || W.includes(
782
+ e.matcher
783
+ ))
784
+ return null;
785
+ const s = e;
786
+ 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(
788
+ (c) => typeof c == "string" && /^{{.*}}$/.test(c)
789
+ )) && (r = "string");
790
+ let n = null;
791
+ switch (r) {
792
+ case "datetime": {
793
+ n = "date";
794
+ break;
795
+ }
796
+ case "boolean": {
797
+ n = "boolean";
798
+ break;
799
+ }
800
+ case "string": {
801
+ n = "text";
802
+ break;
803
+ }
804
+ case "integer":
805
+ case "float": {
806
+ n = "number";
807
+ break;
808
+ }
809
+ case "array":
810
+ case "json":
811
+ case "object":
812
+ break;
813
+ default: {
814
+ n = "text";
815
+ break;
816
+ }
817
+ }
818
+ switch (s.matcher) {
819
+ case "eq":
820
+ case "not_eq":
821
+ case "lt":
822
+ case "lteq":
823
+ case "gt":
824
+ case "gteq":
825
+ case "multiple":
826
+ case "start_with":
827
+ case "not_start_with":
828
+ case "end_with":
829
+ case "not_end_with":
830
+ break;
831
+ case "matches":
832
+ case "does_not_match":
833
+ break;
834
+ case "gt_lt":
835
+ case "gteq_lt":
836
+ case "gt_lteq":
837
+ case "gteq_lteq": {
838
+ n === "number" && (n = "numberRange"), n === "text" && (n = "textRange"), n === "date" && (n = "dateRange");
839
+ break;
840
+ }
841
+ case "is_in":
842
+ case "is_not_in": {
843
+ n = "tag";
844
+ break;
845
+ }
846
+ case "array_match": {
847
+ n = "arrayMatch";
848
+ break;
849
+ }
850
+ default: {
851
+ R(s.matcher);
852
+ break;
853
+ }
854
+ }
855
+ switch (n) {
856
+ case "date": {
857
+ const c = A(
858
+ typeof s.value == "string" ? s.value : ""
859
+ );
860
+ return /* @__PURE__ */ t.jsx(
861
+ te,
862
+ {
863
+ value: T(c) ? c : void 0,
864
+ showTimeSelect: !0,
865
+ placeholder: "Enter value",
866
+ onChange: (o) => {
867
+ l(u, o == null ? void 0 : o.toJSON());
868
+ }
869
+ }
870
+ );
871
+ }
872
+ case "dateRange": {
873
+ const c = Array.isArray(s.value) ? s.value.map((o) => {
874
+ const f = A(typeof o == "string" ? o : "");
875
+ return T(f) ? f : null;
876
+ }) : [null, null];
877
+ return /* @__PURE__ */ t.jsx(
878
+ ee,
879
+ {
880
+ value: c,
881
+ showTimeSelect: !0,
882
+ onChange: (o) => {
883
+ l(
884
+ `${a}.value`,
885
+ o.map((f) => (f == null ? void 0 : f.toJSON()) ?? null)
886
+ );
887
+ }
888
+ }
889
+ );
890
+ }
891
+ case "numberRange":
892
+ return /* @__PURE__ */ t.jsx(
893
+ ye,
894
+ {
895
+ value: s.value,
896
+ onChange: (c) => {
897
+ l(u, c);
898
+ }
899
+ }
900
+ );
901
+ case "textRange":
902
+ return /* @__PURE__ */ t.jsx(
903
+ ve,
904
+ {
905
+ value: s.value,
906
+ onChange: (c) => {
907
+ l(u, c);
908
+ }
909
+ }
910
+ );
911
+ case "arrayMatch":
912
+ return /* @__PURE__ */ t.jsx(
913
+ be,
914
+ {
915
+ value: s.value,
916
+ pathPrefix: `${a}.value`
917
+ }
918
+ );
919
+ case "tag":
920
+ return /* @__PURE__ */ t.jsx(
921
+ j,
922
+ {
923
+ isMulti: !0,
924
+ isClearable: !1,
925
+ isCreatable: !0,
926
+ defaultValue: Array.isArray(s.value) ? s.value.map((c) => ({
927
+ label: c.toString(),
928
+ value: c
929
+ })) : [],
930
+ initialValues: [],
931
+ onSelect: (c) => {
932
+ U(c) && l(
933
+ `${a}.value`,
934
+ c.map((o) => {
935
+ if (r === "integer") {
936
+ const f = parseInt(o.value.toString(), 10);
937
+ return isNaN(f) ? null : f;
938
+ }
939
+ return o.value;
940
+ }).filter((o) => o != null)
941
+ );
942
+ }
943
+ }
944
+ );
945
+ case "number":
946
+ return /* @__PURE__ */ t.jsx(
947
+ h,
948
+ {
949
+ type: "number",
950
+ defaultValue: typeof s.value == "number" ? s.value : "",
951
+ placeholder: "Enter value",
952
+ onChange: (c) => {
953
+ l(
954
+ `${a}.value`,
955
+ parseInt(c.currentTarget.value, 10)
956
+ );
957
+ }
958
+ }
959
+ );
960
+ case "boolean":
961
+ return /* @__PURE__ */ t.jsx(
962
+ j,
963
+ {
964
+ defaultValue: typeof s.value == "boolean" ? {
965
+ label: s.value ? "Yes" : "No",
966
+ value: s.value
967
+ } : void 0,
968
+ initialValues: [
969
+ { label: "Yes", value: !0 },
970
+ { label: "No", value: !1 }
971
+ ],
972
+ onSelect: (c) => {
973
+ $(c) && l(u, c.value);
974
+ }
975
+ }
976
+ );
977
+ case "text":
978
+ case null:
979
+ return /* @__PURE__ */ t.jsx(
980
+ h,
981
+ {
982
+ type: "text",
983
+ defaultValue: typeof s.value == "string" ? s.value : JSON.stringify(s.value),
984
+ placeholder: "Enter value",
985
+ onChange: (c) => {
986
+ l(u, c.currentTarget.value);
987
+ }
988
+ }
989
+ );
990
+ default:
991
+ return R();
992
+ }
993
+ }
994
+ function Ne({
995
+ item: e,
996
+ nestingLevel: a,
997
+ pathPrefix: l,
998
+ onDelete: i
999
+ }) {
1000
+ const { setPath: u } = p(), s = [];
1001
+ return a < 2 && (s[0] ?? (s[0] = []), s[0].push(
1002
+ /* @__PURE__ */ t.jsx(
1003
+ S,
1004
+ {
1005
+ label: "Nest conditions",
1006
+ onClick: () => {
1007
+ var r;
1008
+ u(
1009
+ `${l}.nested.conditions.${(((r = e == null ? void 0 : e.nested) == null ? void 0 : r.conditions) ?? []).length}`,
1010
+ void 0
1011
+ );
1012
+ }
1013
+ }
1014
+ )
1015
+ )), i != null && (s[1] ?? (s[1] = []), s[1].push(
1016
+ /* @__PURE__ */ t.jsx(
1017
+ S,
1018
+ {
1019
+ label: "Delete",
1020
+ onClick: () => {
1021
+ u(`${l}`, null), i();
1022
+ }
1023
+ }
1024
+ )
1025
+ )), /* @__PURE__ */ t.jsxs("div", { className: "bg-gray-50 rounded-md flex items-center", children: [
1026
+ /* @__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
+ /* @__PURE__ */ t.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
1028
+ /* @__PURE__ */ t.jsx("div", { className: "flex-1", children: /* @__PURE__ */ t.jsx(
1029
+ h,
1030
+ {
1031
+ type: "text",
1032
+ defaultValue: e != null ? e.field : void 0,
1033
+ onChange: (r) => {
1034
+ u(`${l}.field`, r.currentTarget.value);
1035
+ },
1036
+ onBlur: (r) => {
1037
+ u(`${l}.field`, r.currentTarget.value);
1038
+ }
1039
+ }
1040
+ ) }),
1041
+ /* @__PURE__ */ t.jsx("div", { className: "flex-14", children: /* @__PURE__ */ t.jsx(me, { item: e, pathPrefix: l }) })
1042
+ ] }),
1043
+ /* @__PURE__ */ t.jsx(je, { item: e, pathPrefix: l })
1044
+ ] }) }),
1045
+ s.length > 0 && /* @__PURE__ */ t.jsx(
1046
+ P,
1047
+ {
1048
+ 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" }) }),
1050
+ dropdownItems: s.map((r, n, d) => /* @__PURE__ */ t.jsxs(I.Fragment, { children: [
1051
+ r.map((c, o) => /* @__PURE__ */ t.jsx(I.Fragment, { children: c }, o)),
1052
+ n < d.length - 1 && /* @__PURE__ */ t.jsx(ae, {})
1053
+ ] }, n))
1054
+ }
1055
+ )
1056
+ ] });
1057
+ }
1058
+ function B({
1059
+ item: e,
1060
+ children: a,
1061
+ nestingLevel: l = 0,
1062
+ pathPrefix: i
1063
+ }) {
1064
+ var o, f;
1065
+ const {
1066
+ 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;
1068
+ return /* @__PURE__ */ t.jsxs(
1069
+ "div",
1070
+ {
1071
+ className: C("query-group", {
1072
+ "p-4 border border-gray-200 rounded-md": c
1073
+ }),
1074
+ children: [
1075
+ a,
1076
+ e != null && (e.conditions ?? []).length > 0 && /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
1077
+ /* @__PURE__ */ t.jsxs(
1078
+ "select",
1079
+ {
1080
+ onChange: (x) => {
1081
+ r(
1082
+ `${i}.conditions_logic`,
1083
+ x.currentTarget.value
1084
+ );
1085
+ },
1086
+ defaultValue: s,
1087
+ className: "pl-4 pr-8 py-2 font-bold focus:ring-0 focus:outline-none appearance-none bg-gray-50 border border-gray-200 rounded-md text-sm leading-4",
1088
+ children: [
1089
+ /* @__PURE__ */ t.jsxs("option", { value: "and", children: [
1090
+ c ? "Nested in " : "",
1091
+ "AND"
1092
+ ] }),
1093
+ /* @__PURE__ */ t.jsxs("option", { value: "or", children: [
1094
+ c ? "Nested in " : "",
1095
+ "OR"
1096
+ ] })
1097
+ ]
1098
+ }
1099
+ ),
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;
1102
+ return /* @__PURE__ */ t.jsxs(
1103
+ "div",
1104
+ {
1105
+ className: "flex items-center mb-4 last:mb-0 relative",
1106
+ children: [
1107
+ /* @__PURE__ */ t.jsx(_e, { rounded: y }),
1108
+ /* @__PURE__ */ t.jsx("div", { className: "ml-4 w-full", children: /* @__PURE__ */ t.jsx(
1109
+ B,
1110
+ {
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`,
1114
+ children: /* @__PURE__ */ t.jsx(
1115
+ "div",
1116
+ {
1117
+ className: C({
1118
+ "mb-4": (x == null ? void 0 : x.nested) != null
1119
+ }),
1120
+ children: /* @__PURE__ */ t.jsx(
1121
+ Ne,
1122
+ {
1123
+ item: x,
1124
+ nestingLevel: l,
1125
+ pathPrefix: `${i}.conditions.${m}`,
1126
+ onDelete: b.length > 1 || l > 0 ? () => {
1127
+ d((_) => _ + 1);
1128
+ } : void 0
1129
+ }
1130
+ )
1131
+ }
1132
+ )
1133
+ }
1134
+ ) })
1135
+ ]
1136
+ },
1137
+ `${u}-${m}-${n}`
1138
+ );
1139
+ }) })
1140
+ ] })
1141
+ ]
1142
+ }
1143
+ );
1144
+ }
1145
+ function _e({
1146
+ rounded: e = !1
1147
+ }) {
1148
+ return e ? /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
1149
+ /* @__PURE__ */ t.jsx("div", { className: "absolute -left-[1px] top-1/2 w-px h-1/2 bg-white" }),
1150
+ /* @__PURE__ */ t.jsx("div", { className: "absolute -left-[1px] top-1/2 -translate-y-1/2 w-3.5 h-3.5 border-l border-b rounded-es-sm bg-white border-gray-200" })
1151
+ ] }) : /* @__PURE__ */ t.jsx("div", { className: "absolute left-0 top-1/2 -translate-y-1/2 w-3.5 h-px bg-gray-200" });
1152
+ }
1153
+ function we() {
1154
+ var s;
1155
+ const {
1156
+ setPath: e,
1157
+ state: { value: a, selectedRuleIndex: l }
1158
+ } = p(), [i, u] = g(
1159
+ ((s = a.rules[l]) == null ? void 0 : s.name) ?? ""
1160
+ );
1161
+ return N(() => {
1162
+ var r;
1163
+ u(((r = a.rules[l]) == null ? void 0 : r.name) ?? "");
1164
+ }, [l]), /* @__PURE__ */ t.jsx(
1165
+ "div",
1166
+ {
1167
+ contentEditable: "plaintext-only",
1168
+ suppressContentEditableWarning: !0,
1169
+ onInput: (r) => {
1170
+ const d = r.currentTarget.innerText.replace(/[\n\s]+/g, " ").trim();
1171
+ e(`rules.${l}.name`, d);
1172
+ },
1173
+ onKeyDown: (r) => {
1174
+ r.key === "Enter" && (r.preventDefault(), r.currentTarget.blur());
1175
+ },
1176
+ onBlur: (r) => {
1177
+ const n = r.currentTarget;
1178
+ n.innerText = n.innerText.replace(/[\n\s]+/g, " ").trim();
1179
+ },
1180
+ children: i
1181
+ },
1182
+ l
1183
+ );
1184
+ }
1185
+ const L = {
1186
+ rules: []
1187
+ }, V = (e) => {
1188
+ try {
1189
+ return JSON.parse(e ?? JSON.stringify(L));
1190
+ } catch {
1191
+ return L;
1192
+ }
1193
+ }, Te = (e) => {
1194
+ try {
1195
+ return JSON.parse(e ?? "{}"), !0;
1196
+ } catch {
1197
+ return !1;
1198
+ }
1199
+ };
1200
+ function Ae(e) {
1201
+ const [a, l] = g(
1202
+ V(e.value ?? e.defaultValue)
1203
+ );
1204
+ return N(
1205
+ function() {
1206
+ a.rules.length === 0 && l(V(e.value));
1207
+ },
1208
+ [e.value]
1209
+ ), /* @__PURE__ */ t.jsx(fe, { initialValue: { rules: a.rules }, children: /* @__PURE__ */ t.jsx(Ce, { ...e }) });
1210
+ }
1211
+ function Ce(e) {
1212
+ const {
1213
+ state: { value: a, selectedRuleIndex: l },
1214
+ setSelectedRuleIndex: i,
1215
+ setValue: u,
1216
+ setPath: s
1217
+ } = p(), [r, n] = g(
1218
+ e.defaultCodeEditorVisible ?? !1
1219
+ ), d = a.rules[l], c = ce(null), [o, f] = g(0);
1220
+ N(
1221
+ 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);
1224
+ },
1225
+ [a]
1226
+ );
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));
1231
+ },
1232
+ [a]
1233
+ );
1234
+ return /* @__PURE__ */ t.jsx(
1235
+ le,
1236
+ {
1237
+ hint: e.hint,
1238
+ feedback: e.feedback,
1239
+ className: "h-full [&>div:first-of-type]:h-full",
1240
+ children: /* @__PURE__ */ t.jsxs("section", { className: "flex h-full", children: [
1241
+ /* @__PURE__ */ t.jsxs(
1242
+ "div",
1243
+ {
1244
+ className: `shrink-0 basis-3/5 overflow-x-auto relative flex flex-col ${r ? "" : "grow"}`,
1245
+ children: [
1246
+ /* @__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
+ /* @__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")}`;
1250
+ return /* @__PURE__ */ t.jsx(
1251
+ "button",
1252
+ {
1253
+ className: C("font-bold", {
1254
+ "text-black": l === b
1255
+ }),
1256
+ onClick: () => {
1257
+ i(b);
1258
+ },
1259
+ children: y
1260
+ },
1261
+ m.id
1262
+ );
1263
+ }),
1264
+ /* @__PURE__ */ t.jsx(
1265
+ "button",
1266
+ {
1267
+ className: C("font-bold", {
1268
+ "text-black": !0
1269
+ }),
1270
+ onClick: () => {
1271
+ s(`rules.${a.rules.length}`, {
1272
+ name: "Rule name",
1273
+ actions: [null],
1274
+ conditions: [null]
1275
+ }), i(a.rules.length);
1276
+ },
1277
+ children: /* @__PURE__ */ t.jsx(v, { name: "plus", size: 16, className: "shrink-0" })
1278
+ }
1279
+ )
1280
+ ] }),
1281
+ /* @__PURE__ */ t.jsx("div", { className: "flex-grow flex justify-end", children: /* @__PURE__ */ t.jsx(
1282
+ "button",
1283
+ {
1284
+ className: "text-blue-600 hover:text-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500",
1285
+ onClick: () => {
1286
+ n(!r);
1287
+ },
1288
+ children: /* @__PURE__ */ t.jsx(v, { name: "sidebarSimple", size: 16, color: "#101111" })
1289
+ }
1290
+ ) })
1291
+ ] }),
1292
+ /* @__PURE__ */ t.jsxs($e, { children: [
1293
+ /* @__PURE__ */ t.jsxs("div", { className: "mb-8 flex items-center gap-2", children: [
1294
+ /* @__PURE__ */ t.jsx(we, {}),
1295
+ /* @__PURE__ */ t.jsx(v, { name: "pencilSimple", size: 16, className: "shrink-0" })
1296
+ ] }),
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" }),
1299
+ /* @__PURE__ */ t.jsxs(J, { title: "Conditions", icon: "treeView", children: [
1300
+ /* @__PURE__ */ t.jsx(
1301
+ B,
1302
+ {
1303
+ item: d,
1304
+ pathPrefix: `rules.${l}`
1305
+ }
1306
+ ),
1307
+ /* @__PURE__ */ t.jsx("div", { className: "mt-6", children: /* @__PURE__ */ t.jsxs(
1308
+ z,
1309
+ {
1310
+ size: "small",
1311
+ variant: "secondary",
1312
+ alignItems: "center",
1313
+ onClick: () => {
1314
+ var m;
1315
+ s(
1316
+ `rules.${l}.conditions.${((m = d == null ? void 0 : d.conditions) == null ? void 0 : m.length) ?? 0}`,
1317
+ void 0
1318
+ );
1319
+ },
1320
+ children: [
1321
+ /* @__PURE__ */ t.jsx(v, { name: "plusCircle" }),
1322
+ " Add condition"
1323
+ ]
1324
+ }
1325
+ ) })
1326
+ ] })
1327
+ ] })
1328
+ ]
1329
+ },
1330
+ o
1331
+ ),
1332
+ r && /* @__PURE__ */ t.jsx("div", { className: "shrink-0 basis-2/5", children: /* @__PURE__ */ t.jsx(
1333
+ ne,
1334
+ {
1335
+ ref: c,
1336
+ name: e.id ?? e.name,
1337
+ height: "100%",
1338
+ language: "json",
1339
+ jsonSchema: "order-rules",
1340
+ defaultValue: JSON.stringify(a, null, 2),
1341
+ noRounding: !0,
1342
+ onChange: x
1343
+ }
1344
+ ) })
1345
+ ] })
1346
+ }
1347
+ );
1348
+ }
1349
+ function Ve({ children: e }) {
1350
+ return /* @__PURE__ */ t.jsxs("div", { className: "text-gray-500 flex items-center justify-center flex-col", children: [
1351
+ /* @__PURE__ */ t.jsx("div", { className: "h-6 w-[2px] bg-gray-200" }),
1352
+ /* @__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 }),
1353
+ /* @__PURE__ */ t.jsx("div", { className: "h-6 w-[2px] bg-gray-200" })
1354
+ ] });
1355
+ }
1356
+ function J({
1357
+ children: e,
1358
+ title: a,
1359
+ icon: l
1360
+ }) {
1361
+ return /* @__PURE__ */ t.jsxs("div", { className: "rounded-md bg-white shadow-sm", children: [
1362
+ /* @__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 }) }),
1364
+ /* @__PURE__ */ t.jsx("h2", { className: "text-lg font-semibold", children: a })
1365
+ ] }),
1366
+ /* @__PURE__ */ t.jsx("div", { className: "p-6", children: e })
1367
+ ] });
1368
+ }
1369
+ function $e({
1370
+ children: e
1371
+ }) {
1372
+ 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 }) });
1373
+ }
1374
+ export {
1375
+ Ae as RuleEngine
1376
+ };