@commercelayer/app-elements 6.0.1 → 6.0.3

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,58 +1,174 @@
1
1
  "use client";
2
- import { t as S, b as H, d as Z, j as e, i as V, g as G, e as Q, I as f, f as y, h as $, D as z, k as R, l as p, B as J, n as P, o as w, p as U, u as ee, q as te, r as ne, s as ae, v as _, w as le, C as se } from "./main-os-TPFjB.js";
3
- import I, { useReducer as re, useCallback as N, useMemo as ie, createContext as ue, useContext as ce, useState as g, useEffect as v, useRef as oe } from "react";
2
+ import { t as A, B as ee, D as ae, E as te, I as se, N as ne, O as le, P as re, Z as E, b as ie, d as oe, e as ue, f as ce, g as de, h as me, i as fe, j as pe, k as ye, l as Z, n as ge, o as be, p as he, q as xe, r as ve, s as je, u as Te, v as Ne, w as we, x as _e, y as $e, z as Ce, A as Ve, C as Ee, F as Se, G as Re, H as Ie, J as Ae, K as Ze, L as ke, M as Me, Q as De, R as qe, S as Oe, T as ze, U as Fe, V as Le, W as Ue, X as Je, Y as Ke, _ as Pe, $ as Be, a0 as Ye, a1 as We, a2 as Xe, a3 as He, a4 as Ge, a5 as Qe, a6 as ea, a7 as aa, a8 as ta, a9 as k, aa as sa, ab as na, ac as la, ad as ra, ae as ia, af as oa, ag as ua, ah as ca, ai as da, aj as ma, ak as fa, al as pa, am as ya, an as ga, ao as ba, ap as ha, aq as xa, ar as va, as as ja, at as Ta, au as Na, av as wa, aw as _a, ax as $a, ay as Ca, az as Va, aA as Ea, aB as Sa, aC as Ra, aD as Ia, aE as Aa, aF as Za, aG as ka, aH as Ma, aI as Da, aJ as qa, aK as Oa, aL as za, aM as Fa, aN as La, aO as Ua, aP as Ja, aQ as Ka, aR as Pa, aS as Ba, aT as e, aU as S, aV as Ya, aW as R, aX as p, aY as v, aZ as C, a_ as K, a$ as I, b0 as h, b1 as P, b2 as Wa, b3 as w, b4 as B, b5 as Y, b6 as W, b7 as Xa, b8 as Ha, b9 as Ga, ba as _, bb as Qa, bc as et, bd as at } from "./main-CuXYh6yM.js";
3
+ import M, { useReducer as tt, useCallback as N, useMemo as st, createContext as nt, useContext as lt, useState as f, useEffect as j, useRef as rt } from "react";
4
4
  import "react-hook-form";
5
- import { p as k } from "./parseISO-B-vBXvVj.js";
6
- function A(t, n) {
7
- const a = t.match(
5
+ import { p as D } from "./parseISO-Ccxkiq7f.js";
6
+ function q(a, t) {
7
+ const s = a.match(
8
8
  /(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2}):(\d{2})(?:\.(\d{0,7}))?(?:Z|(.)(\d{2}):?(\d{2})?)?/
9
9
  );
10
- return a ? S(
10
+ return s ? A(
11
11
  Date.UTC(
12
- +a[1],
13
- +a[2] - 1,
14
- +a[3],
15
- +a[4] - (+a[9] || 0) * (a[8] == "-" ? -1 : 1),
16
- +a[5] - (+a[10] || 0) * (a[8] == "-" ? -1 : 1),
17
- +a[6],
18
- +((a[7] || "0") + "00").substring(0, 3)
12
+ +s[1],
13
+ +s[2] - 1,
14
+ +s[3],
15
+ +s[4] - (+s[9] || 0) * (s[8] == "-" ? -1 : 1),
16
+ +s[5] - (+s[10] || 0) * (s[8] == "-" ? -1 : 1),
17
+ +s[6],
18
+ +((s[7] || "0") + "00").substring(0, 3)
19
19
  ),
20
- n?.in
21
- ) : S(NaN, n?.in);
20
+ t?.in
21
+ ) : A(NaN, t?.in);
22
22
  }
23
- function q(t, n, a) {
24
- return t == null ? t : H(t, n, a);
23
+ const y = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
24
+ __proto__: null,
25
+ BRAND: ee,
26
+ DIRTY: ae,
27
+ EMPTY_PATH: te,
28
+ INVALID: se,
29
+ NEVER: ne,
30
+ OK: le,
31
+ ParseStatus: re,
32
+ Schema: E,
33
+ ZodAny: ie,
34
+ ZodArray: oe,
35
+ ZodBigInt: ue,
36
+ ZodBoolean: ce,
37
+ ZodBranded: de,
38
+ ZodCatch: me,
39
+ ZodDate: fe,
40
+ ZodDefault: pe,
41
+ ZodDiscriminatedUnion: ye,
42
+ ZodEffects: Z,
43
+ ZodEnum: ge,
44
+ ZodError: be,
45
+ get ZodFirstPartyTypeKind() {
46
+ return he;
47
+ },
48
+ ZodFunction: xe,
49
+ ZodIntersection: ve,
50
+ ZodIssueCode: je,
51
+ ZodLazy: Te,
52
+ ZodLiteral: Ne,
53
+ ZodMap: we,
54
+ ZodNaN: _e,
55
+ ZodNativeEnum: $e,
56
+ ZodNever: Ce,
57
+ ZodNull: Ve,
58
+ ZodNullable: Ee,
59
+ ZodNumber: Se,
60
+ ZodObject: Re,
61
+ ZodOptional: Ie,
62
+ ZodParsedType: Ae,
63
+ ZodPipeline: Ze,
64
+ ZodPromise: ke,
65
+ ZodReadonly: Me,
66
+ ZodRecord: De,
67
+ ZodSchema: E,
68
+ ZodSet: qe,
69
+ ZodString: Oe,
70
+ ZodSymbol: ze,
71
+ ZodTransformer: Z,
72
+ ZodTuple: Fe,
73
+ ZodType: E,
74
+ ZodUndefined: Le,
75
+ ZodUnion: Ue,
76
+ ZodUnknown: Je,
77
+ ZodVoid: Ke,
78
+ addIssueToContext: Pe,
79
+ any: Be,
80
+ array: Ye,
81
+ bigint: We,
82
+ boolean: Xe,
83
+ coerce: He,
84
+ custom: Ge,
85
+ date: Qe,
86
+ datetimeRegex: ea,
87
+ defaultErrorMap: aa,
88
+ discriminatedUnion: ta,
89
+ effect: k,
90
+ enum: sa,
91
+ function: na,
92
+ getErrorMap: la,
93
+ getParsedType: ra,
94
+ instanceof: ia,
95
+ intersection: oa,
96
+ isAborted: ua,
97
+ isAsync: ca,
98
+ isDirty: da,
99
+ isValid: ma,
100
+ late: fa,
101
+ lazy: pa,
102
+ literal: ya,
103
+ makeIssue: ga,
104
+ map: ba,
105
+ nan: ha,
106
+ nativeEnum: xa,
107
+ never: va,
108
+ null: ja,
109
+ nullable: Ta,
110
+ number: Na,
111
+ object: wa,
112
+ get objectUtil() {
113
+ return _a;
114
+ },
115
+ oboolean: $a,
116
+ onumber: Ca,
117
+ optional: Va,
118
+ ostring: Ea,
119
+ pipeline: Sa,
120
+ preprocess: Ra,
121
+ promise: Ia,
122
+ quotelessJson: Aa,
123
+ record: Za,
124
+ set: ka,
125
+ setErrorMap: Ma,
126
+ strictObject: Da,
127
+ string: qa,
128
+ symbol: Oa,
129
+ transformer: k,
130
+ tuple: za,
131
+ undefined: Fa,
132
+ union: La,
133
+ unknown: Ua,
134
+ get util() {
135
+ return Ja;
136
+ },
137
+ void: Ka
138
+ }, Symbol.toStringTag, { value: "Module" }));
139
+ function O(a, t, s) {
140
+ return a == null ? a : Pa(a, t, s);
25
141
  }
26
- function D(t, n) {
27
- return t == null ? !0 : Z(t, n);
142
+ function z(a, t) {
143
+ return a == null ? !0 : Ba(a, t);
28
144
  }
29
- const K = ue(
145
+ const X = nt(
30
146
  void 0
31
147
  );
32
- function de(t, n) {
33
- switch (n.type) {
148
+ function it(a, t) {
149
+ switch (t.type) {
34
150
  case "SET_PATH": {
35
- const a = { ...t.value };
36
- if (n.value === null)
37
- if (/\.\d+$/.test(n.path)) {
38
- const r = n.path.replace(/\.\d+$/, ""), u = parseInt(n.path.match(/\d+$/)?.[0] ?? "0", 10), s = G(a, r);
39
- Array.isArray(s) && (s.splice(u, 1), q(a, r, s), s.length === 0 && r.endsWith(".nested.conditions") && D(a, r.replace(/\.conditions$/, "")));
151
+ const s = { ...a.value };
152
+ if (t.value === null)
153
+ if (/\.\d+$/.test(t.path)) {
154
+ const r = t.path.replace(/\.\d+$/, ""), o = parseInt(t.path.match(/\d+$/)?.[0] ?? "0", 10), l = Ya(s, r);
155
+ Array.isArray(l) && (l.splice(o, 1), O(s, r, l), l.length === 0 && r.endsWith(".nested.conditions") && z(s, r.replace(/\.conditions$/, "")));
40
156
  } else
41
- D(a, n.path);
157
+ z(s, t.path);
42
158
  else
43
- q(a, n.path, n.value);
159
+ O(s, t.path, t.value);
44
160
  return {
45
- ...t,
46
- value: a
161
+ ...a,
162
+ value: s
47
163
  };
48
164
  }
49
165
  case "SET_SELECTED_RULE_INDEX":
50
166
  return {
51
- ...t,
52
- selectedRuleIndex: n.index
167
+ ...a,
168
+ selectedRuleIndex: t.index
53
169
  };
54
170
  case "SET_VALUE":
55
- return V(t.value, n.value) ? t : n.value.rules.length === 0 ? {
171
+ return S(a.value, t.value) ? a : t.value.rules.length === 0 ? {
56
172
  selectedRuleIndex: 0,
57
173
  value: {
58
174
  rules: [
@@ -66,87 +182,85 @@ function de(t, n) {
66
182
  ]
67
183
  }
68
184
  } : {
69
- ...t,
70
- value: n.value
185
+ ...a,
186
+ value: t.value
71
187
  };
72
188
  default:
73
- return t;
189
+ return a;
74
190
  }
75
191
  }
76
- function me({
77
- children: t,
78
- initialValue: n
192
+ function ot({
193
+ children: a,
194
+ initialValue: t
79
195
  }) {
80
- const [a, r] = re(de, {
81
- value: n,
196
+ const [s, r] = tt(it, {
197
+ value: t.value,
82
198
  selectedRuleIndex: 0
83
- }), u = N((o, c) => {
84
- r({ type: "SET_PATH", path: o, value: c });
85
- }, []), s = N((o) => {
86
- r({ type: "SET_SELECTED_RULE_INDEX", index: o });
87
- }, []), l = N((o) => {
88
- r({ type: "SET_VALUE", value: o });
89
- }, []), i = ie(
199
+ }), o = N((c, u) => {
200
+ r({ type: "SET_PATH", path: c, value: u });
201
+ }, []), l = N((c) => {
202
+ r({ type: "SET_SELECTED_RULE_INDEX", index: c });
203
+ }, []), n = N((c) => {
204
+ r({ type: "SET_VALUE", value: c });
205
+ }, []), i = st(
90
206
  () => ({
91
- state: a,
92
- setPath: u,
93
- setSelectedRuleIndex: s,
94
- setValue: l
207
+ state: s,
208
+ setPath: o,
209
+ setSelectedRuleIndex: l,
210
+ setValue: n,
211
+ availableActionTypes: t.availableActionTypes
95
212
  }),
96
- [a, u, s, l]
213
+ [
214
+ s,
215
+ o,
216
+ l,
217
+ n,
218
+ t.availableActionTypes
219
+ ]
97
220
  );
98
- return /* @__PURE__ */ e.jsx(K.Provider, { value: i, children: t });
221
+ return /* @__PURE__ */ e.jsx(X.Provider, { value: i, children: a });
99
222
  }
100
- function h() {
101
- const t = ce(K);
102
- if (t === void 0)
223
+ function g() {
224
+ const a = lt(X);
225
+ if (a === void 0)
103
226
  throw new Error("useRuleEngine must be used within a RuleEngineProvider");
104
- return t;
105
- }
106
- const W = Q([
107
- "blank",
108
- "present",
109
- "null",
110
- "not_null"
111
- ]);
112
- function E(t) {
113
- return null;
227
+ return a;
114
228
  }
115
- function fe({
116
- item: t,
117
- pathPrefix: n
229
+ function ut({
230
+ item: a,
231
+ pathPrefix: t
118
232
  }) {
119
- const { setPath: a } = h();
120
- if (t == null)
233
+ const { setPath: s } = g();
234
+ if (a == null)
121
235
  return null;
122
- switch (t.type) {
236
+ switch (a.type) {
123
237
  case "buy_x_pay_y":
124
238
  return /* @__PURE__ */ e.jsxs("div", { className: "w-36 flex items-center gap-0.5", children: [
125
239
  /* @__PURE__ */ e.jsx(
126
- f,
240
+ p,
127
241
  {
128
- name: `${n}.value.x`,
242
+ name: `${t}.value.x`,
129
243
  type: "number",
130
244
  suffix: "X",
131
- defaultValue: t.value?.x,
245
+ defaultValue: a.value?.x,
132
246
  onChange: (r) => {
133
- a(
134
- `${n}.value.x`,
247
+ s(
248
+ `${t}.value.x`,
135
249
  parseInt(r.currentTarget.value, 10)
136
250
  );
137
251
  }
138
252
  }
139
253
  ),
140
254
  /* @__PURE__ */ e.jsx(
141
- f,
255
+ p,
142
256
  {
143
- name: `${n}.value.y`,
257
+ name: `${t}.value.y`,
144
258
  type: "number",
145
259
  suffix: "Y",
146
- defaultValue: t.value?.y,
260
+ defaultValue: a.value?.y,
147
261
  onChange: (r) => {
148
- a(
149
- `${n}.value.y`,
262
+ s(
263
+ `${t}.value.y`,
150
264
  parseInt(r.currentTarget.value, 10)
151
265
  );
152
266
  }
@@ -156,30 +270,30 @@ function fe({
156
270
  case "every_x_discount_y":
157
271
  return /* @__PURE__ */ e.jsxs("div", { className: "w-36 flex items-center gap-0.5", children: [
158
272
  /* @__PURE__ */ e.jsx(
159
- f,
273
+ p,
160
274
  {
161
- name: `${n}.value.x`,
275
+ name: `${t}.value.x`,
162
276
  type: "number",
163
277
  suffix: "X",
164
- defaultValue: t.value?.x,
278
+ defaultValue: a.value?.x,
165
279
  onChange: (r) => {
166
- a(
167
- `${n}.value.x`,
280
+ s(
281
+ `${t}.value.x`,
168
282
  parseInt(r.currentTarget.value, 10)
169
283
  );
170
284
  }
171
285
  }
172
286
  ),
173
287
  /* @__PURE__ */ e.jsx(
174
- f,
288
+ p,
175
289
  {
176
- name: `${n}.value.y`,
290
+ name: `${t}.value.y`,
177
291
  type: "number",
178
292
  suffix: "Y",
179
- defaultValue: t.value?.y,
293
+ defaultValue: a.value?.y,
180
294
  onChange: (r) => {
181
- a(
182
- `${n}.value.y`,
295
+ s(
296
+ `${t}.value.y`,
183
297
  parseInt(r.currentTarget.value, 10)
184
298
  );
185
299
  }
@@ -189,94 +303,96 @@ function fe({
189
303
  case "fixed_amount":
190
304
  case "fixed_price":
191
305
  return /* @__PURE__ */ e.jsx("div", { className: "w-36", children: /* @__PURE__ */ e.jsx(
192
- f,
306
+ p,
193
307
  {
194
- name: `${n}.value`,
308
+ name: `${t}.value`,
195
309
  type: "number",
196
- defaultValue: t.value,
310
+ defaultValue: a.value,
197
311
  min: 0,
198
312
  suffix: "cents",
199
313
  onChange: (r) => {
200
- a(
201
- `${n}.value`,
314
+ s(
315
+ `${t}.value`,
202
316
  parseInt(r.currentTarget.value, 10)
203
317
  );
204
318
  }
205
319
  }
206
320
  ) });
207
321
  case "percentage": {
208
- const r = (t.value * 100).toFixed(2);
322
+ const r = (a.value * 100).toFixed(2);
209
323
  return /* @__PURE__ */ e.jsx("div", { className: "w-24", children: /* @__PURE__ */ e.jsx(
210
- f,
324
+ p,
211
325
  {
212
- name: `${n}.value`,
326
+ name: `${t}.value`,
213
327
  type: "number",
214
328
  defaultValue: r.endsWith(".00") ? r.slice(0, -3) : r,
215
329
  min: 0,
216
330
  max: 100,
217
331
  suffix: "%",
218
- onChange: (u) => {
219
- a(
220
- `${n}.value`,
221
- parseFloat(u.currentTarget.value) / 100
332
+ onChange: (o) => {
333
+ s(
334
+ `${t}.value`,
335
+ parseFloat(o.currentTarget.value) / 100
222
336
  );
223
337
  }
224
338
  }
225
339
  ) });
226
340
  }
227
341
  default:
228
- return E();
342
+ return R();
229
343
  }
230
344
  }
231
- function ge({
232
- item: t,
233
- index: n,
234
- onDelete: a
345
+ function ct({
346
+ item: a,
347
+ index: t,
348
+ onDelete: s
235
349
  }) {
236
350
  const {
237
351
  setPath: r,
238
- state: { selectedRuleIndex: u }
239
- } = h(), s = {
352
+ state: { selectedRuleIndex: o },
353
+ availableActionTypes: l
354
+ } = g(), n = {
240
355
  percentage: "Percentage discount",
241
356
  fixed_amount: "Fixed amount",
242
357
  fixed_price: "Fixed price",
243
358
  buy_x_pay_y: "Buy X, Pay Y",
244
359
  every_x_discount_y: "Every X, Discount Y"
245
- }, l = `rules.${u}.actions.${n}`;
360
+ }, i = `rules.${o}.actions.${t}`;
246
361
  return /* @__PURE__ */ e.jsx("div", { className: "mb-4 last:mb-0", children: /* @__PURE__ */ e.jsxs("div", { className: "bg-gray-50 rounded-md flex items-center", children: [
247
362
  /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between gap-2 grow p-2", children: [
248
363
  /* @__PURE__ */ e.jsx("div", { className: "flex-1", children: /* @__PURE__ */ e.jsx(
249
- y,
364
+ v,
250
365
  {
251
- name: `${l}.type`,
252
- defaultValue: t != null ? {
253
- label: s[t.type],
254
- value: t.type
366
+ name: `${i}.type`,
367
+ defaultValue: a != null ? {
368
+ label: n[a.type],
369
+ value: a.type
255
370
  } : void 0,
256
- initialValues: Object.entries(s).map(
257
- ([i, o]) => ({ value: i, label: o })
258
- ),
259
- onSelect: (i) => {
260
- $(i) && r(`${l}.type`, i.value);
371
+ initialValues: l.map((c) => ({
372
+ value: c,
373
+ label: n[c]
374
+ })),
375
+ onSelect: (c) => {
376
+ C(c) && r(`${i}.type`, c.value);
261
377
  }
262
378
  }
263
379
  ) }),
264
- /* @__PURE__ */ e.jsx(fe, { item: t, pathPrefix: l }),
380
+ /* @__PURE__ */ e.jsx(ut, { item: a, pathPrefix: i }),
265
381
  /* @__PURE__ */ e.jsx("div", { className: "text-black font-bold text-sm", children: "ON" }),
266
382
  /* @__PURE__ */ e.jsx("div", { className: "flex-1", children: /* @__PURE__ */ e.jsx(
267
- f,
383
+ p,
268
384
  {
269
- name: `${l}.selector`,
385
+ name: `${i}.selector`,
270
386
  type: "text",
271
- defaultValue: t?.selector,
272
- onChange: (i) => {
273
- r(`${l}.selector`, i.currentTarget.value);
387
+ defaultValue: a?.selector,
388
+ onChange: (c) => {
389
+ r(`${i}.selector`, c.currentTarget.value);
274
390
  }
275
391
  }
276
392
  ) })
277
393
  ] }),
278
- a != null && /* @__PURE__ */ e.jsx(
279
- z,
394
+ s != null && /* @__PURE__ */ e.jsx(
395
+ K,
280
396
  {
281
397
  className: "w-8 border-l border-gray-100 flex items-center justify-center self-stretch",
282
398
  dropdownLabel: /* @__PURE__ */ e.jsx(
@@ -284,15 +400,15 @@ function ge({
284
400
  {
285
401
  type: "button",
286
402
  className: "flex items-center justify-center self-stretch grow",
287
- children: /* @__PURE__ */ e.jsx(p, { name: "dotsThreeVertical", size: 16, weight: "bold" })
403
+ children: /* @__PURE__ */ e.jsx(h, { name: "dotsThreeVertical", size: 16, weight: "bold" })
288
404
  }
289
405
  ),
290
406
  dropdownItems: /* @__PURE__ */ e.jsx(
291
- R,
407
+ I,
292
408
  {
293
409
  label: "Delete",
294
410
  onClick: () => {
295
- r(`${l}`, null), a();
411
+ r(`${i}`, null), s();
296
412
  }
297
413
  }
298
414
  )
@@ -300,94 +416,94 @@ function ge({
300
416
  )
301
417
  ] }) });
302
418
  }
303
- function he({
304
- actions: t
419
+ function dt({
420
+ actions: a
305
421
  }) {
306
- const [n, a] = g(0), {
422
+ const [t, s] = f(0), {
307
423
  setPath: r,
308
- state: { selectedRuleIndex: u }
309
- } = h();
424
+ state: { selectedRuleIndex: o }
425
+ } = g();
310
426
  return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
311
- /* @__PURE__ */ e.jsx("div", { children: t?.map((s, l, i) => /* @__PURE__ */ e.jsx(
312
- ge,
427
+ /* @__PURE__ */ e.jsx("div", { children: a?.map((l, n, i) => /* @__PURE__ */ e.jsx(
428
+ ct,
313
429
  {
314
- item: s,
315
- index: l,
430
+ item: l,
431
+ index: n,
316
432
  onDelete: i.length > 1 ? () => {
317
- a((o) => o + 1);
433
+ s((c) => c + 1);
318
434
  } : void 0
319
435
  },
320
- `${u}-${l}-${n}`
436
+ `${o}-${n}-${t}`
321
437
  )) }),
322
438
  /* @__PURE__ */ e.jsx("div", { className: "mt-6", children: /* @__PURE__ */ e.jsxs(
323
- J,
439
+ P,
324
440
  {
325
441
  size: "small",
326
442
  variant: "secondary",
327
443
  alignItems: "center",
328
444
  onClick: () => {
329
445
  r(
330
- `rules.${u}.actions.${t?.length ?? 0}`,
446
+ `rules.${o}.actions.${a?.length ?? 0}`,
331
447
  void 0
332
448
  );
333
449
  },
334
450
  children: [
335
- /* @__PURE__ */ e.jsx(p, { name: "plusCircle" }),
451
+ /* @__PURE__ */ e.jsx(h, { name: "plusCircle" }),
336
452
  " Add action"
337
453
  ]
338
454
  }
339
455
  ) })
340
456
  ] });
341
457
  }
342
- function X(t) {
343
- const [n, a] = g(void 0);
344
- return v(() => {
345
- t?.field != null && P(t.field).then((r) => {
346
- a(r);
458
+ function H(a) {
459
+ const [t, s] = f(void 0);
460
+ return j(() => {
461
+ a?.field != null && Wa(a.field).then((r) => {
462
+ s(r);
347
463
  }).catch((r) => {
348
464
  console.error("Error fetching field info:", r);
349
465
  });
350
- }, [t?.field]), { infos: n };
466
+ }, [a?.field]), { infos: t };
351
467
  }
352
- function Y(t) {
353
- if (typeof t == "string")
354
- return w(A(t)) ? "datetime" : "string";
355
- if (typeof t == "number")
468
+ function G(a) {
469
+ if (typeof a == "string")
470
+ return w(q(a)) ? "datetime" : "string";
471
+ if (typeof a == "number")
356
472
  return "integer";
357
- if (typeof t == "boolean")
473
+ if (typeof a == "boolean")
358
474
  return "boolean";
359
- if (Array.isArray(t)) {
360
- if (typeof t[0] == "string")
361
- return w(A(t[0])) ? "datetime" : "string";
362
- if (typeof t[0] == "number")
475
+ if (Array.isArray(a)) {
476
+ if (typeof a[0] == "string")
477
+ return w(q(a[0])) ? "datetime" : "string";
478
+ if (typeof a[0] == "number")
363
479
  return "integer";
364
480
  }
365
481
  return "string";
366
482
  }
367
- function xe({
368
- item: t,
369
- pathPrefix: n
483
+ function mt({
484
+ item: a,
485
+ pathPrefix: t
370
486
  }) {
371
- const { setPath: a } = h(), { infos: r } = X(t);
372
- let u = r?.field?.type;
373
- return u == null && (u = Y(t?.value)), /* @__PURE__ */ e.jsx(
374
- y,
487
+ const { setPath: s } = g(), { infos: r } = H(a);
488
+ let o = r?.field?.type;
489
+ return o == null && (o = G(a?.value)), /* @__PURE__ */ e.jsx(
490
+ v,
375
491
  {
376
- name: `${n}.matcher`,
377
- value: t != null ? {
378
- label: M.find((s) => s.matcher === t.matcher && (u != null && s.fieldTypes.includes(u) || u == null))?.label ?? (t.matcher != null ? `⚠️   ${t.matcher}` : ""),
379
- value: t.matcher
492
+ name: `${t}.matcher`,
493
+ value: a != null ? {
494
+ label: F.find((l) => l.matcher === a.matcher && (o != null && l.fieldTypes.includes(o) || o == null))?.label ?? (a.matcher != null ? `⚠️   ${a.matcher}` : ""),
495
+ value: a.matcher
380
496
  } : void 0,
381
- initialValues: M.filter(({ fieldTypes: s, visible: l }) => l !== !1 && s.includes(u)).map(({ matcher: s, label: l }) => ({ value: s, label: l })),
382
- onSelect: (s) => {
383
- $(s) && (a(`${n}.matcher`, s.value), W.includes(
384
- s.value
385
- ) && a(`${n}.value`, null));
497
+ initialValues: F.filter(({ fieldTypes: l, visible: n }) => n !== !1 && l.includes(o)).map(({ matcher: l, label: n }) => ({ value: l, label: n })),
498
+ onSelect: (l) => {
499
+ C(l) && (s(`${t}.matcher`, l.value), B.includes(
500
+ l.value
501
+ ) && s(`${t}.value`, null));
386
502
  }
387
503
  }
388
504
  );
389
505
  }
390
- const M = [
506
+ const F = [
391
507
  {
392
508
  /** Matches if field value equals provided value
393
509
  * @field Integer, String, Datetime, Boolean
@@ -632,7 +748,7 @@ const M = [
632
748
  label: "is present",
633
749
  fieldTypes: ["integer", "string", "datetime", "boolean"]
634
750
  }
635
- ], O = {
751
+ ], L = {
636
752
  in_and: {
637
753
  label: "all of"
638
754
  },
@@ -646,51 +762,51 @@ const M = [
646
762
  label: "not at least one of"
647
763
  }
648
764
  };
649
- function pe({
650
- value: t,
651
- pathPrefix: n
765
+ function ft({
766
+ value: a,
767
+ pathPrefix: t
652
768
  }) {
653
- return (typeof t != "object" || Array.isArray(t) || t === null) && (t = {
769
+ return (typeof a != "object" || Array.isArray(a) || a === null) && (a = {
654
770
  in_and: []
655
- }), /* @__PURE__ */ e.jsx("div", { children: Object.entries(t).map(([a, r], u) => /* @__PURE__ */ e.jsx(
656
- be,
771
+ }), /* @__PURE__ */ e.jsx("div", { children: Object.entries(a).map(([s, r], o) => /* @__PURE__ */ e.jsx(
772
+ pt,
657
773
  {
658
- pathPrefix: n,
774
+ pathPrefix: t,
659
775
  defaultValue: r,
660
- initialMatcher: a
776
+ initialMatcher: s
661
777
  },
662
- `${n}.${// biome-ignore lint/suspicious/noArrayIndexKey: Using index as key is acceptable here since items are static
663
- u}`
778
+ `${t}.${// biome-ignore lint/suspicious/noArrayIndexKey: Using index as key is acceptable here since items are static
779
+ o}`
664
780
  )) });
665
781
  }
666
- function be({
667
- initialMatcher: t,
668
- defaultValue: n,
669
- pathPrefix: a
782
+ function pt({
783
+ initialMatcher: a,
784
+ defaultValue: t,
785
+ pathPrefix: s
670
786
  }) {
671
- const [r, u] = g(t), [s, l] = g(t), [i, o] = g(n), { setPath: c } = h();
672
- return v(() => {
673
- r !== s && (c(`${a}.${r}`, null), u(s)), c(`${a}.${s}`, i);
674
- }, [s, i, c]), /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2 last-of-type:mt-2", children: [
787
+ const [r, o] = f(a), [l, n] = f(a), [i, c] = f(t), { setPath: u } = g();
788
+ return j(() => {
789
+ r !== l && (u(`${s}.${r}`, null), o(l)), u(`${s}.${l}`, i);
790
+ }, [l, i, u]), /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2 last-of-type:mt-2", children: [
675
791
  /* @__PURE__ */ e.jsx("div", { className: "shrink-0", children: /* @__PURE__ */ e.jsx(
676
- y,
792
+ v,
677
793
  {
678
794
  defaultValue: [
679
- { value: s, label: O[s].label }
795
+ { value: l, label: L[l].label }
680
796
  ],
681
- initialValues: Object.entries(O).map(
797
+ initialValues: Object.entries(L).map(
682
798
  ([d, { label: m }]) => ({
683
799
  value: d,
684
800
  label: m
685
801
  })
686
802
  ),
687
803
  onSelect: (d) => {
688
- $(d) && l(d.value);
804
+ C(d) && n(d.value);
689
805
  }
690
806
  }
691
807
  ) }),
692
808
  /* @__PURE__ */ e.jsx("div", { className: "grow", children: /* @__PURE__ */ e.jsx(
693
- y,
809
+ v,
694
810
  {
695
811
  isMulti: !0,
696
812
  isCreatable: !0,
@@ -700,7 +816,7 @@ function be({
700
816
  })),
701
817
  initialValues: [],
702
818
  onSelect: (d) => {
703
- U(d) && o(
819
+ Y(d) && c(
704
820
  d.map(
705
821
  (m) => typeof m.value == "boolean" ? m.value.toString() : m.value
706
822
  )
@@ -710,111 +826,111 @@ function be({
710
826
  ) })
711
827
  ] });
712
828
  }
713
- function ye({
714
- value: t,
715
- onChange: n
829
+ function yt({
830
+ value: a,
831
+ onChange: t
716
832
  }) {
717
- const [a, r] = g(
718
- Array.isArray(t) && typeof t[0] == "number" ? t[0] : null
719
- ), [u, s] = g(
720
- Array.isArray(t) && typeof t[1] == "number" ? t[1] : null
833
+ const [s, r] = f(
834
+ Array.isArray(a) && typeof a[0] == "number" ? a[0] : null
835
+ ), [o, l] = f(
836
+ Array.isArray(a) && typeof a[1] == "number" ? a[1] : null
721
837
  );
722
838
  return /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-4", children: [
723
839
  /* @__PURE__ */ e.jsx("div", { className: "grow", children: /* @__PURE__ */ e.jsx(
724
- f,
840
+ p,
725
841
  {
726
842
  type: "number",
727
843
  placeholder: "Min",
728
- value: a ?? "",
729
- onChange: (l) => {
730
- const i = parseInt(l.currentTarget.value, 10);
731
- r(Number.isNaN(i) ? null : i), n([Number.isNaN(i) ? null : i, u]);
844
+ value: s ?? "",
845
+ onChange: (n) => {
846
+ const i = parseInt(n.currentTarget.value, 10);
847
+ r(Number.isNaN(i) ? null : i), t([Number.isNaN(i) ? null : i, o]);
732
848
  }
733
849
  }
734
850
  ) }),
735
851
  /* @__PURE__ */ e.jsx("span", { className: "text-gray-300", children: "to" }),
736
852
  /* @__PURE__ */ e.jsx("div", { className: "grow", children: /* @__PURE__ */ e.jsx(
737
- f,
853
+ p,
738
854
  {
739
855
  type: "number",
740
856
  placeholder: "Max",
741
- value: u ?? "",
742
- onChange: (l) => {
743
- const i = parseInt(l.currentTarget.value, 10);
744
- s(Number.isNaN(i) ? null : i), n([a, Number.isNaN(i) ? null : i]);
857
+ value: o ?? "",
858
+ onChange: (n) => {
859
+ const i = parseInt(n.currentTarget.value, 10);
860
+ l(Number.isNaN(i) ? null : i), t([s, Number.isNaN(i) ? null : i]);
745
861
  }
746
862
  }
747
863
  ) })
748
864
  ] });
749
865
  }
750
- function ve({
751
- value: t,
752
- onChange: n
866
+ function gt({
867
+ value: a,
868
+ onChange: t
753
869
  }) {
754
- const [a, r] = g(
755
- Array.isArray(t) && typeof t[0] == "string" ? t[0] : null
756
- ), [u, s] = g(
757
- Array.isArray(t) && typeof t[1] == "string" ? t[1] : null
870
+ const [s, r] = f(
871
+ Array.isArray(a) && typeof a[0] == "string" ? a[0] : null
872
+ ), [o, l] = f(
873
+ Array.isArray(a) && typeof a[1] == "string" ? a[1] : null
758
874
  );
759
875
  return /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-4", children: [
760
876
  /* @__PURE__ */ e.jsx("div", { className: "grow", children: /* @__PURE__ */ e.jsx(
761
- f,
877
+ p,
762
878
  {
763
879
  type: "text",
764
880
  placeholder: "Min",
765
- value: a ?? "",
766
- onChange: (l) => {
767
- const i = l.currentTarget.value;
768
- r(i), n([i, u]);
881
+ value: s ?? "",
882
+ onChange: (n) => {
883
+ const i = n.currentTarget.value;
884
+ r(i), t([i, o]);
769
885
  }
770
886
  }
771
887
  ) }),
772
888
  /* @__PURE__ */ e.jsx("span", { className: "text-gray-300", children: "to" }),
773
889
  /* @__PURE__ */ e.jsx("div", { className: "grow", children: /* @__PURE__ */ e.jsx(
774
- f,
890
+ p,
775
891
  {
776
892
  type: "text",
777
893
  placeholder: "Max",
778
- value: u ?? "",
779
- onChange: (l) => {
780
- const i = l.currentTarget.value;
781
- s(i), n([a, i]);
894
+ value: o ?? "",
895
+ onChange: (n) => {
896
+ const i = n.currentTarget.value;
897
+ l(i), t([s, i]);
782
898
  }
783
899
  }
784
900
  ) })
785
901
  ] });
786
902
  }
787
- function je({
788
- item: t,
789
- pathPrefix: n
903
+ function bt({
904
+ item: a,
905
+ pathPrefix: t
790
906
  }) {
791
- const { setPath: a } = h(), { infos: r } = X(t), { user: u } = ee(), s = `${n}.value`;
792
- if (t == null || W.includes(
793
- t.matcher
907
+ const { setPath: s } = g(), { infos: r } = H(a), { user: o } = W(), l = `${t}.value`;
908
+ if (a == null || B.includes(
909
+ a.matcher
794
910
  ))
795
911
  return null;
796
- const l = t;
912
+ const n = a;
797
913
  let i = r?.field?.type;
798
- i == null && (i = Y(l.value)), (typeof l.value == "string" && /^{{.*}}$/.test(l.value) || Array.isArray(l.value) && l.value.some(
799
- (c) => typeof c == "string" && /^{{.*}}$/.test(c)
914
+ i == null && (i = G(n.value)), (typeof n.value == "string" && /^{{.*}}$/.test(n.value) || Array.isArray(n.value) && n.value.some(
915
+ (u) => typeof u == "string" && /^{{.*}}$/.test(u)
800
916
  )) && (i = "string");
801
- let o = null;
917
+ let c = null;
802
918
  switch (i) {
803
919
  case "datetime": {
804
- o = "date";
920
+ c = "date";
805
921
  break;
806
922
  }
807
923
  case "boolean": {
808
- o = "boolean";
924
+ c = "boolean";
809
925
  break;
810
926
  }
811
927
  case "string": {
812
- o = "text";
928
+ c = "text";
813
929
  break;
814
930
  }
815
931
  case "integer":
816
932
  case "float": {
817
- o = "number";
933
+ c = "number";
818
934
  break;
819
935
  }
820
936
  case "array":
@@ -822,11 +938,11 @@ function je({
822
938
  case "object":
823
939
  break;
824
940
  default: {
825
- o = "text";
941
+ c = "text";
826
942
  break;
827
943
  }
828
944
  }
829
- switch (l.matcher) {
945
+ switch (n.matcher) {
830
946
  case "eq":
831
947
  case "not_eq":
832
948
  case "lt":
@@ -846,54 +962,54 @@ function je({
846
962
  case "gteq_lt":
847
963
  case "gt_lteq":
848
964
  case "gteq_lteq": {
849
- o === "number" && (o = "numberRange"), o === "text" && (o = "textRange"), o === "date" && (o = "dateRange");
965
+ c === "number" && (c = "numberRange"), c === "text" && (c = "textRange"), c === "date" && (c = "dateRange");
850
966
  break;
851
967
  }
852
968
  case "is_in":
853
969
  case "is_not_in": {
854
- o = "tag";
970
+ c = "tag";
855
971
  break;
856
972
  }
857
973
  case "array_match": {
858
- o = "arrayMatch";
974
+ c = "arrayMatch";
859
975
  break;
860
976
  }
861
977
  default: {
862
- E(l.matcher);
978
+ R(n.matcher);
863
979
  break;
864
980
  }
865
981
  }
866
- switch (o) {
982
+ switch (c) {
867
983
  case "date": {
868
- const c = k(
869
- typeof l.value == "string" ? l.value : ""
984
+ const u = D(
985
+ typeof n.value == "string" ? n.value : ""
870
986
  );
871
987
  return /* @__PURE__ */ e.jsx(
872
- ne,
988
+ Ha,
873
989
  {
874
- value: w(c) ? c : void 0,
990
+ value: w(u) ? u : void 0,
875
991
  showTimeSelect: !0,
876
992
  placeholder: "Enter value",
877
993
  onChange: (d) => {
878
- a(s, d?.toJSON());
994
+ s(l, d?.toJSON());
879
995
  },
880
- timezone: u?.timezone
996
+ timezone: o?.timezone
881
997
  }
882
998
  );
883
999
  }
884
1000
  case "dateRange": {
885
- const c = Array.isArray(l.value) ? l.value.map((d) => {
886
- const m = k(typeof d == "string" ? d : "");
1001
+ const u = Array.isArray(n.value) ? n.value.map((d) => {
1002
+ const m = D(typeof d == "string" ? d : "");
887
1003
  return w(m) ? m : null;
888
1004
  }) : [null, null];
889
1005
  return /* @__PURE__ */ e.jsx(
890
- te,
1006
+ Xa,
891
1007
  {
892
- value: c,
1008
+ value: u,
893
1009
  showTimeSelect: !0,
894
1010
  onChange: (d) => {
895
- a(
896
- `${n}.value`,
1011
+ s(
1012
+ `${t}.value`,
897
1013
  d.map((m) => m?.toJSON() ?? null)
898
1014
  );
899
1015
  }
@@ -902,48 +1018,48 @@ function je({
902
1018
  }
903
1019
  case "numberRange":
904
1020
  return /* @__PURE__ */ e.jsx(
905
- ye,
1021
+ yt,
906
1022
  {
907
- value: l.value,
908
- onChange: (c) => {
909
- a(s, c);
1023
+ value: n.value,
1024
+ onChange: (u) => {
1025
+ s(l, u);
910
1026
  }
911
1027
  }
912
1028
  );
913
1029
  case "textRange":
914
1030
  return /* @__PURE__ */ e.jsx(
915
- ve,
1031
+ gt,
916
1032
  {
917
- value: l.value,
918
- onChange: (c) => {
919
- a(s, c);
1033
+ value: n.value,
1034
+ onChange: (u) => {
1035
+ s(l, u);
920
1036
  }
921
1037
  }
922
1038
  );
923
1039
  case "arrayMatch":
924
1040
  return /* @__PURE__ */ e.jsx(
925
- pe,
1041
+ ft,
926
1042
  {
927
- value: l.value,
928
- pathPrefix: `${n}.value`
1043
+ value: n.value,
1044
+ pathPrefix: `${t}.value`
929
1045
  }
930
1046
  );
931
1047
  case "tag":
932
1048
  return /* @__PURE__ */ e.jsx(
933
- y,
1049
+ v,
934
1050
  {
935
1051
  isMulti: !0,
936
1052
  isClearable: !1,
937
1053
  isCreatable: !0,
938
- defaultValue: Array.isArray(l.value) ? l.value.map((c) => ({
939
- label: c.toString(),
940
- value: c
1054
+ defaultValue: Array.isArray(n.value) ? n.value.map((u) => ({
1055
+ label: u.toString(),
1056
+ value: u
941
1057
  })) : [],
942
1058
  initialValues: [],
943
- onSelect: (c) => {
944
- U(c) && a(
945
- `${n}.value`,
946
- c.map((d) => {
1059
+ onSelect: (u) => {
1060
+ Y(u) && s(
1061
+ `${t}.value`,
1062
+ u.map((d) => {
947
1063
  if (i === "integer") {
948
1064
  const m = parseInt(d.value.toString(), 10);
949
1065
  return Number.isNaN(m) ? null : m;
@@ -956,83 +1072,83 @@ function je({
956
1072
  );
957
1073
  case "number":
958
1074
  return /* @__PURE__ */ e.jsx(
959
- f,
1075
+ p,
960
1076
  {
961
- name: `${n}.value`,
1077
+ name: `${t}.value`,
962
1078
  type: "number",
963
- defaultValue: typeof l.value == "number" ? l.value : "",
1079
+ defaultValue: typeof n.value == "number" ? n.value : "",
964
1080
  placeholder: "Enter value",
965
- onChange: (c) => {
966
- a(
967
- `${n}.value`,
968
- parseInt(c.currentTarget.value, 10)
1081
+ onChange: (u) => {
1082
+ s(
1083
+ `${t}.value`,
1084
+ parseInt(u.currentTarget.value, 10)
969
1085
  );
970
1086
  }
971
1087
  }
972
1088
  );
973
1089
  case "boolean":
974
1090
  return /* @__PURE__ */ e.jsx(
975
- y,
1091
+ v,
976
1092
  {
977
- name: `${n}.value`,
978
- defaultValue: typeof l.value == "boolean" ? {
979
- label: l.value ? "Yes" : "No",
980
- value: l.value
1093
+ name: `${t}.value`,
1094
+ defaultValue: typeof n.value == "boolean" ? {
1095
+ label: n.value ? "Yes" : "No",
1096
+ value: n.value
981
1097
  } : void 0,
982
1098
  initialValues: [
983
1099
  { label: "Yes", value: !0 },
984
1100
  { label: "No", value: !1 }
985
1101
  ],
986
- onSelect: (c) => {
987
- $(c) && a(s, c.value);
1102
+ onSelect: (u) => {
1103
+ C(u) && s(l, u.value);
988
1104
  }
989
1105
  }
990
1106
  );
991
1107
  case "text":
992
1108
  case null:
993
1109
  return /* @__PURE__ */ e.jsx(
994
- f,
1110
+ p,
995
1111
  {
996
- name: `${n}.value`,
1112
+ name: `${t}.value`,
997
1113
  type: "text",
998
- defaultValue: typeof l.value == "string" ? l.value : JSON.stringify(l.value),
1114
+ defaultValue: typeof n.value == "string" ? n.value : JSON.stringify(n.value),
999
1115
  placeholder: "Enter value",
1000
- onChange: (c) => {
1001
- a(s, c.currentTarget.value);
1116
+ onChange: (u) => {
1117
+ s(l, u.currentTarget.value);
1002
1118
  }
1003
1119
  }
1004
1120
  );
1005
1121
  default:
1006
- return E();
1122
+ return R();
1007
1123
  }
1008
1124
  }
1009
- function Ne({
1010
- item: t,
1011
- nestingLevel: n,
1012
- pathPrefix: a,
1125
+ function ht({
1126
+ item: a,
1127
+ nestingLevel: t,
1128
+ pathPrefix: s,
1013
1129
  onDelete: r
1014
1130
  }) {
1015
- const { setPath: u } = h(), s = [];
1016
- return n < 2 && (s[0] ??= [], s[0].push(
1131
+ const { setPath: o } = g(), l = [];
1132
+ return t < 2 && (l[0] ??= [], l[0].push(
1017
1133
  /* @__PURE__ */ e.jsx(
1018
- R,
1134
+ I,
1019
1135
  {
1020
1136
  label: "Nest conditions",
1021
1137
  onClick: () => {
1022
- u(
1023
- `${a}.nested.conditions.${(t?.nested?.conditions ?? []).length}`,
1138
+ o(
1139
+ `${s}.nested.conditions.${(a?.nested?.conditions ?? []).length}`,
1024
1140
  void 0
1025
1141
  );
1026
1142
  }
1027
1143
  }
1028
1144
  )
1029
- )), r != null && (s[1] ??= [], s[1].push(
1145
+ )), r != null && (l[1] ??= [], l[1].push(
1030
1146
  /* @__PURE__ */ e.jsx(
1031
- R,
1147
+ I,
1032
1148
  {
1033
1149
  label: "Delete",
1034
1150
  onClick: () => {
1035
- u(`${a}`, null), r();
1151
+ o(`${s}`, null), r();
1036
1152
  }
1037
1153
  }
1038
1154
  )
@@ -1040,25 +1156,25 @@ function Ne({
1040
1156
  /* @__PURE__ */ e.jsx("div", { className: "flex items-center justify-between gap-2 grow p-2", children: /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-2 grow", children: [
1041
1157
  /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
1042
1158
  /* @__PURE__ */ e.jsx("div", { className: "flex-1", children: /* @__PURE__ */ e.jsx(
1043
- f,
1159
+ p,
1044
1160
  {
1045
- name: `${a}.field`,
1161
+ name: `${s}.field`,
1046
1162
  type: "text",
1047
- defaultValue: t?.field,
1048
- onChange: (l) => {
1049
- u(`${a}.field`, l.currentTarget.value);
1163
+ defaultValue: a?.field,
1164
+ onChange: (n) => {
1165
+ o(`${s}.field`, n.currentTarget.value);
1050
1166
  },
1051
- onBlur: (l) => {
1052
- u(`${a}.field`, l.currentTarget.value);
1167
+ onBlur: (n) => {
1168
+ o(`${s}.field`, n.currentTarget.value);
1053
1169
  }
1054
1170
  }
1055
1171
  ) }),
1056
- /* @__PURE__ */ e.jsx("div", { children: /* @__PURE__ */ e.jsx(xe, { item: t, pathPrefix: a }) })
1172
+ /* @__PURE__ */ e.jsx("div", { children: /* @__PURE__ */ e.jsx(mt, { item: a, pathPrefix: s }) })
1057
1173
  ] }),
1058
- /* @__PURE__ */ e.jsx(je, { item: t, pathPrefix: a })
1174
+ /* @__PURE__ */ e.jsx(bt, { item: a, pathPrefix: s })
1059
1175
  ] }) }),
1060
- s.length > 0 && /* @__PURE__ */ e.jsx(
1061
- z,
1176
+ l.length > 0 && /* @__PURE__ */ e.jsx(
1177
+ K,
1062
1178
  {
1063
1179
  className: "w-8 border-l border-gray-100 flex items-center justify-center self-stretch",
1064
1180
  dropdownLabel: /* @__PURE__ */ e.jsx(
@@ -1066,77 +1182,77 @@ function Ne({
1066
1182
  {
1067
1183
  type: "button",
1068
1184
  className: "flex items-center justify-center self-stretch grow",
1069
- children: /* @__PURE__ */ e.jsx(p, { name: "dotsThreeVertical", size: 16, weight: "bold" })
1185
+ children: /* @__PURE__ */ e.jsx(h, { name: "dotsThreeVertical", size: 16, weight: "bold" })
1070
1186
  }
1071
1187
  ),
1072
- dropdownItems: s.map((l, i, o) => (
1188
+ dropdownItems: l.map((n, i, c) => (
1073
1189
  // biome-ignore lint/suspicious/noArrayIndexKey: Using index as key is acceptable here since items are static
1074
- /* @__PURE__ */ e.jsxs(I.Fragment, { children: [
1075
- l.map((c, d) => (
1190
+ /* @__PURE__ */ e.jsxs(M.Fragment, { children: [
1191
+ n.map((u, d) => (
1076
1192
  // biome-ignore lint/suspicious/noArrayIndexKey: Using index as key is acceptable here since items are static
1077
- /* @__PURE__ */ e.jsx(I.Fragment, { children: c }, d)
1193
+ /* @__PURE__ */ e.jsx(M.Fragment, { children: u }, d)
1078
1194
  )),
1079
- i < o.length - 1 && /* @__PURE__ */ e.jsx(ae, {})
1195
+ i < c.length - 1 && /* @__PURE__ */ e.jsx(Ga, {})
1080
1196
  ] }, i)
1081
1197
  ))
1082
1198
  }
1083
1199
  )
1084
1200
  ] });
1085
1201
  }
1086
- function B({
1087
- item: t,
1088
- children: n,
1089
- nestingLevel: a = 0,
1202
+ function Q({
1203
+ item: a,
1204
+ children: t,
1205
+ nestingLevel: s = 0,
1090
1206
  pathPrefix: r
1091
1207
  }) {
1092
1208
  const {
1093
- state: { selectedRuleIndex: u }
1094
- } = h(), s = t?.conditions_logic?.toLowerCase() ?? "and", { setPath: l } = h(), [i, o] = g(0), c = a > 0;
1209
+ state: { selectedRuleIndex: o }
1210
+ } = g(), l = a?.conditions_logic?.toLowerCase() ?? "and", { setPath: n } = g(), [i, c] = f(0), u = s > 0;
1095
1211
  return /* @__PURE__ */ e.jsxs(
1096
1212
  "div",
1097
1213
  {
1098
1214
  className: _("query-group", {
1099
- "p-4 border border-gray-200 rounded-md": c
1215
+ "p-4 border border-gray-200 rounded-md": u
1100
1216
  }),
1101
1217
  children: [
1102
- n,
1103
- t != null && (t.conditions ?? []).length > 0 && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1218
+ t,
1219
+ a != null && (a.conditions ?? []).length > 0 && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1104
1220
  /* @__PURE__ */ e.jsxs(
1105
1221
  "select",
1106
1222
  {
1107
1223
  onChange: (d) => {
1108
- l(
1224
+ n(
1109
1225
  `${r}.conditions_logic`,
1110
1226
  d.currentTarget.value
1111
1227
  );
1112
1228
  },
1113
- defaultValue: s,
1229
+ defaultValue: l,
1114
1230
  className: "pl-4 pr-8 py-2 font-bold focus:ring-0 focus:outline-hidden appearance-none bg-gray-50 border border-gray-200 rounded-md text-sm leading-4",
1115
1231
  children: [
1116
1232
  /* @__PURE__ */ e.jsxs("option", { value: "and", children: [
1117
- c ? "Nested in " : "",
1233
+ u ? "Nested in " : "",
1118
1234
  "AND"
1119
1235
  ] }),
1120
1236
  /* @__PURE__ */ e.jsxs("option", { value: "or", children: [
1121
- c ? "Nested in " : "",
1237
+ u ? "Nested in " : "",
1122
1238
  "OR"
1123
1239
  ] })
1124
1240
  ]
1125
1241
  }
1126
1242
  ),
1127
- /* @__PURE__ */ e.jsx("div", { className: "border-l border-gray-200 ml-3 pt-3", children: t?.conditions?.map((d, m, j) => {
1128
- const b = m === j.length - 1;
1243
+ /* @__PURE__ */ e.jsx("div", { className: "border-l border-gray-200 ml-3 pt-3", children: a?.conditions?.map((d, m, T) => {
1244
+ const x = m === T.length - 1;
1129
1245
  return /* @__PURE__ */ e.jsxs(
1130
1246
  "div",
1131
1247
  {
1132
1248
  className: "flex items-center mb-4 last:mb-0 relative",
1133
1249
  children: [
1134
- /* @__PURE__ */ e.jsx(we, { rounded: b }),
1250
+ /* @__PURE__ */ e.jsx(xt, { rounded: x }),
1135
1251
  /* @__PURE__ */ e.jsx("div", { className: "ml-4 w-full", children: /* @__PURE__ */ e.jsx(
1136
- B,
1252
+ Q,
1137
1253
  {
1138
1254
  item: d?.nested ?? void 0,
1139
- nestingLevel: d?.nested != null ? a + 1 : 0,
1255
+ nestingLevel: d?.nested != null ? s + 1 : 0,
1140
1256
  pathPrefix: `${r}.conditions.${m}.nested`,
1141
1257
  children: /* @__PURE__ */ e.jsx(
1142
1258
  "div",
@@ -1145,13 +1261,13 @@ function B({
1145
1261
  "mb-4": d?.nested != null
1146
1262
  }),
1147
1263
  children: /* @__PURE__ */ e.jsx(
1148
- Ne,
1264
+ ht,
1149
1265
  {
1150
1266
  item: d,
1151
- nestingLevel: a,
1267
+ nestingLevel: s,
1152
1268
  pathPrefix: `${r}.conditions.${m}`,
1153
- onDelete: j.length > 1 || a > 0 ? () => {
1154
- o((x) => x + 1);
1269
+ onDelete: T.length > 1 || s > 0 ? () => {
1270
+ c((b) => b + 1);
1155
1271
  } : void 0
1156
1272
  }
1157
1273
  )
@@ -1161,7 +1277,7 @@ function B({
1161
1277
  ) })
1162
1278
  ]
1163
1279
  },
1164
- `${u}-${m}-${i}`
1280
+ `${o}-${m}-${i}`
1165
1281
  );
1166
1282
  }) })
1167
1283
  ] })
@@ -1169,122 +1285,165 @@ function B({
1169
1285
  }
1170
1286
  );
1171
1287
  }
1172
- function we({
1173
- rounded: t = !1
1288
+ function xt({
1289
+ rounded: a = !1
1174
1290
  }) {
1175
- return t ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1291
+ return a ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1176
1292
  /* @__PURE__ */ e.jsx("div", { className: "absolute -left-px top-1/2 w-px h-1/2 bg-white" }),
1177
1293
  /* @__PURE__ */ e.jsx("div", { className: "absolute -left-px 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" })
1178
1294
  ] }) : /* @__PURE__ */ e.jsx("div", { className: "absolute left-0 top-1/2 -translate-y-1/2 w-3.5 h-px bg-gray-200" });
1179
1295
  }
1180
- function _e() {
1296
+ function vt() {
1181
1297
  const {
1182
- setPath: t,
1183
- state: { value: n, selectedRuleIndex: a }
1184
- } = h(), [r, u] = g(
1185
- n.rules[a]?.name ?? ""
1298
+ setPath: a,
1299
+ state: { value: t, selectedRuleIndex: s }
1300
+ } = g(), [r, o] = f(
1301
+ t.rules[s]?.name ?? ""
1186
1302
  );
1187
- return v(() => {
1188
- u(n.rules[a]?.name ?? "");
1189
- }, [a]), // biome-ignore lint/a11y/noStaticElementInteractions: This <div> is used with contentEditable
1303
+ return j(() => {
1304
+ o(t.rules[s]?.name ?? "");
1305
+ }, [s]), // biome-ignore lint/a11y/noStaticElementInteractions: This <div> is used with contentEditable
1190
1306
  /* @__PURE__ */ e.jsx(
1191
1307
  "div",
1192
1308
  {
1193
1309
  contentEditable: "plaintext-only",
1194
1310
  suppressContentEditableWarning: !0,
1195
- onInput: (s) => {
1196
- const i = s.currentTarget.innerText.replace(/[\n\s]+/g, " ").trim();
1197
- t(`rules.${a}.name`, i);
1311
+ onInput: (l) => {
1312
+ const i = l.currentTarget.innerText.replace(/[\n\s]+/g, " ").trim();
1313
+ a(`rules.${s}.name`, i);
1198
1314
  },
1199
- onKeyDown: (s) => {
1200
- s.key === "Enter" && (s.preventDefault(), s.currentTarget.blur());
1315
+ onKeyDown: (l) => {
1316
+ l.key === "Enter" && (l.preventDefault(), l.currentTarget.blur());
1201
1317
  },
1202
- onBlur: (s) => {
1203
- const l = s.currentTarget;
1204
- l.innerText = l.innerText.replace(/[\n\s]+/g, " ").trim();
1318
+ onBlur: (l) => {
1319
+ const n = l.currentTarget;
1320
+ n.innerText = n.innerText.replace(/[\n\s]+/g, " ").trim();
1205
1321
  },
1206
1322
  children: r
1207
1323
  },
1208
- a
1324
+ s
1209
1325
  );
1210
1326
  }
1211
- const F = {
1327
+ const U = {
1212
1328
  rules: []
1213
- }, T = (t) => {
1329
+ }, $ = (a) => {
1214
1330
  try {
1215
- return JSON.parse(t ?? JSON.stringify(F));
1331
+ return JSON.parse(a ?? JSON.stringify(U));
1216
1332
  } catch {
1217
- return F;
1333
+ return U;
1218
1334
  }
1219
- }, Te = (t) => {
1335
+ }, jt = (a) => {
1220
1336
  try {
1221
- return JSON.parse(t ?? "{}"), !0;
1337
+ return JSON.parse(a ?? "{}"), !0;
1222
1338
  } catch {
1223
1339
  return !1;
1224
1340
  }
1225
1341
  };
1226
- function ke(t) {
1227
- const [n, a] = g(
1228
- T(t.value ?? t.defaultValue)
1342
+ function Et(a) {
1343
+ const {
1344
+ settings: { domain: t }
1345
+ } = W(), [s, r] = f([]), [o, l] = f(
1346
+ $(a.value ?? a.defaultValue)
1229
1347
  );
1230
- return v(
1348
+ return j(
1349
+ function() {
1350
+ o.rules.length === 0 && l($(a.value));
1351
+ },
1352
+ [a.value]
1353
+ ), j(
1231
1354
  function() {
1232
- n.rules.length === 0 && a(T(t.value));
1355
+ Qa(a.schemaType, t).then((i) => {
1356
+ const u = y.object({
1357
+ properties: y.object({
1358
+ rules: y.object({
1359
+ items: y.object({
1360
+ properties: y.object({
1361
+ actions: y.object({
1362
+ items: y.object({
1363
+ anyOf: y.array(
1364
+ y.object({
1365
+ properties: y.object({
1366
+ type: y.object({
1367
+ enum: y.string().array()
1368
+ })
1369
+ })
1370
+ })
1371
+ )
1372
+ })
1373
+ })
1374
+ })
1375
+ })
1376
+ })
1377
+ })
1378
+ }).parse(i).properties.rules.items.properties.actions.items.anyOf.flatMap(
1379
+ (d) => d.properties.type.enum
1380
+ );
1381
+ r([...new Set(u)]);
1382
+ });
1233
1383
  },
1234
- [t.value]
1235
- ), /* @__PURE__ */ e.jsx(me, { initialValue: { rules: n.rules }, children: /* @__PURE__ */ e.jsx($e, { ...t }) });
1384
+ [t]
1385
+ ), /* @__PURE__ */ e.jsx(
1386
+ ot,
1387
+ {
1388
+ initialValue: {
1389
+ value: { rules: o.rules },
1390
+ availableActionTypes: s
1391
+ },
1392
+ children: /* @__PURE__ */ e.jsx(Tt, { ...a })
1393
+ }
1394
+ );
1236
1395
  }
1237
- function $e(t) {
1396
+ function Tt(a) {
1238
1397
  const {
1239
- state: { value: n, selectedRuleIndex: a },
1398
+ state: { value: t, selectedRuleIndex: s },
1240
1399
  setSelectedRuleIndex: r,
1241
- setValue: u,
1242
- setPath: s
1243
- } = h(), [l, i] = g(
1244
- t.defaultCodeEditorVisible ?? !1
1245
- ), o = n.rules[a], c = oe(null), [d, m] = g(0);
1246
- v(
1400
+ setValue: o,
1401
+ setPath: l
1402
+ } = g(), [n, i] = f(
1403
+ a.defaultCodeEditorVisible ?? !1
1404
+ ), c = t.rules[s], u = rt(null), [d, m] = f(0);
1405
+ j(
1247
1406
  function() {
1248
- V(T(c.current?.getValue()), n) || c.current?.setValue(JSON.stringify(n, null, 2)), t.onChange?.(n);
1407
+ S($(u.current?.getValue()), t) || u.current?.setValue(JSON.stringify(t, null, 2)), a.onChange?.(t);
1249
1408
  },
1250
- [n]
1409
+ [t]
1251
1410
  );
1252
- const j = N(
1253
- (b) => {
1254
- const x = T(b);
1255
- c.current?.hasTextFocus() && Te(b) && !V(x, n) && (u(x), m((C) => C + 1));
1411
+ const T = N(
1412
+ (x) => {
1413
+ const b = $(x);
1414
+ u.current?.hasTextFocus() && jt(x) && !S(b, t) && (o(b), m((V) => V + 1));
1256
1415
  },
1257
- [n]
1416
+ [t]
1258
1417
  );
1259
1418
  return /* @__PURE__ */ e.jsx(
1260
- le,
1419
+ et,
1261
1420
  {
1262
- hint: t.hint,
1263
- feedback: t.feedback,
1421
+ hint: a.hint,
1422
+ feedback: a.feedback,
1264
1423
  className: "h-full [&>div:first-of-type]:h-full",
1265
1424
  children: /* @__PURE__ */ e.jsxs("section", { className: "flex h-full", children: [
1266
1425
  /* @__PURE__ */ e.jsxs(
1267
1426
  "div",
1268
1427
  {
1269
- className: `shrink-0 basis-3/5 overflow-x-auto relative flex flex-col ${l ? "" : "grow"}`,
1428
+ className: `shrink-0 basis-3/5 overflow-x-auto relative flex flex-col ${n ? "" : "grow"}`,
1270
1429
  children: [
1271
1430
  /* @__PURE__ */ e.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: [
1272
1431
  /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-4 flex-wrap", children: [
1273
- n.rules.map((b, x) => {
1274
- const C = `#${(x + 1).toString().padStart(2, "0")}`;
1432
+ t.rules.map((x, b) => {
1433
+ const V = `#${(b + 1).toString().padStart(2, "0")}`;
1275
1434
  return /* @__PURE__ */ e.jsx(
1276
1435
  "button",
1277
1436
  {
1278
1437
  type: "button",
1279
1438
  className: _("font-bold", {
1280
- "text-black": a === x
1439
+ "text-black": s === b
1281
1440
  }),
1282
1441
  onClick: () => {
1283
- r(x);
1442
+ r(b);
1284
1443
  },
1285
- children: C
1444
+ children: V
1286
1445
  },
1287
- `${a}-${b.id}`
1446
+ `${s}-${x.id}`
1288
1447
  );
1289
1448
  }),
1290
1449
  /* @__PURE__ */ e.jsx(
@@ -1295,13 +1454,13 @@ function $e(t) {
1295
1454
  "text-black": !0
1296
1455
  }),
1297
1456
  onClick: () => {
1298
- s(`rules.${n.rules.length}`, {
1457
+ l(`rules.${t.rules.length}`, {
1299
1458
  name: "Rule name",
1300
1459
  actions: [null],
1301
1460
  conditions: [null]
1302
- }), r(n.rules.length);
1461
+ }), r(t.rules.length);
1303
1462
  },
1304
- children: /* @__PURE__ */ e.jsx(p, { name: "plus", size: 16, className: "shrink-0" })
1463
+ children: /* @__PURE__ */ e.jsx(h, { name: "plus", size: 16, className: "shrink-0" })
1305
1464
  }
1306
1465
  )
1307
1466
  ] }),
@@ -1311,41 +1470,41 @@ function $e(t) {
1311
1470
  type: "button",
1312
1471
  className: "text-blue-600 hover:text-blue-700 focus:outline-hidden focus:ring-2 focus:ring-blue-500",
1313
1472
  onClick: () => {
1314
- i(!l);
1473
+ i(!n);
1315
1474
  },
1316
- children: /* @__PURE__ */ e.jsx(p, { name: "sidebarSimple", size: 16, color: "#101111" })
1475
+ children: /* @__PURE__ */ e.jsx(h, { name: "sidebarSimple", size: 16, color: "#101111" })
1317
1476
  }
1318
1477
  ) })
1319
1478
  ] }),
1320
- /* @__PURE__ */ e.jsxs(Ve, { children: [
1479
+ /* @__PURE__ */ e.jsxs(wt, { children: [
1321
1480
  /* @__PURE__ */ e.jsxs("div", { className: "mb-8 flex items-center gap-2", children: [
1322
- /* @__PURE__ */ e.jsx(_e, {}),
1323
- /* @__PURE__ */ e.jsx(p, { name: "pencilSimple", size: 16, className: "shrink-0" })
1481
+ /* @__PURE__ */ e.jsx(vt, {}),
1482
+ /* @__PURE__ */ e.jsx(h, { name: "pencilSimple", size: 16, className: "shrink-0" })
1324
1483
  ] }),
1325
- /* @__PURE__ */ e.jsx(L, { title: "Actions", icon: "lightning", children: /* @__PURE__ */ e.jsx(he, { actions: o?.actions }) }),
1326
- /* @__PURE__ */ e.jsx(Ce, { children: "when" }),
1327
- /* @__PURE__ */ e.jsxs(L, { title: "Conditions", icon: "treeView", children: [
1484
+ /* @__PURE__ */ e.jsx(J, { title: "Actions", icon: "lightning", children: /* @__PURE__ */ e.jsx(dt, { actions: c?.actions }) }),
1485
+ /* @__PURE__ */ e.jsx(Nt, { children: "when" }),
1486
+ /* @__PURE__ */ e.jsxs(J, { title: "Conditions", icon: "treeView", children: [
1328
1487
  /* @__PURE__ */ e.jsx(
1329
- B,
1488
+ Q,
1330
1489
  {
1331
- item: o,
1332
- pathPrefix: `rules.${a}`
1490
+ item: c,
1491
+ pathPrefix: `rules.${s}`
1333
1492
  }
1334
1493
  ),
1335
1494
  /* @__PURE__ */ e.jsx("div", { className: "mt-6", children: /* @__PURE__ */ e.jsxs(
1336
- J,
1495
+ P,
1337
1496
  {
1338
1497
  size: "small",
1339
1498
  variant: "secondary",
1340
1499
  alignItems: "center",
1341
1500
  onClick: () => {
1342
- s(
1343
- `rules.${a}.conditions.${o?.conditions?.length ?? 0}`,
1501
+ l(
1502
+ `rules.${s}.conditions.${c?.conditions?.length ?? 0}`,
1344
1503
  void 0
1345
1504
  );
1346
1505
  },
1347
1506
  children: [
1348
- /* @__PURE__ */ e.jsx(p, { name: "plusCircle" }),
1507
+ /* @__PURE__ */ e.jsx(h, { name: "plusCircle" }),
1349
1508
  " Add condition"
1350
1509
  ]
1351
1510
  }
@@ -1356,48 +1515,48 @@ function $e(t) {
1356
1515
  },
1357
1516
  d
1358
1517
  ),
1359
- l && /* @__PURE__ */ e.jsx("div", { className: "shrink-0 basis-2/5", children: /* @__PURE__ */ e.jsx(
1360
- se,
1518
+ n && /* @__PURE__ */ e.jsx("div", { className: "shrink-0 basis-2/5", children: /* @__PURE__ */ e.jsx(
1519
+ at,
1361
1520
  {
1362
- ref: c,
1363
- name: t.id ?? t.name,
1521
+ ref: u,
1522
+ name: a.id ?? a.name,
1364
1523
  height: "100%",
1365
1524
  language: "json",
1366
- jsonSchema: "order-rules",
1367
- defaultValue: JSON.stringify(n, null, 2),
1525
+ jsonSchema: a.schemaType,
1526
+ defaultValue: JSON.stringify(t, null, 2),
1368
1527
  noRounding: !0,
1369
- onChange: j
1528
+ onChange: T
1370
1529
  }
1371
1530
  ) })
1372
1531
  ] })
1373
1532
  }
1374
1533
  );
1375
1534
  }
1376
- function Ce({ children: t }) {
1535
+ function Nt({ children: a }) {
1377
1536
  return /* @__PURE__ */ e.jsxs("div", { className: "text-gray-500 flex items-center justify-center flex-col", children: [
1378
1537
  /* @__PURE__ */ e.jsx("div", { className: "h-6 w-[2px] bg-gray-200" }),
1379
- /* @__PURE__ */ e.jsx("span", { className: "font-bold my-1 bg-gray-200 px-3 relative uppercase rounded h-[25px] items-center flex text-sm", children: t }),
1538
+ /* @__PURE__ */ e.jsx("span", { className: "font-bold my-1 bg-gray-200 px-3 relative uppercase rounded h-[25px] items-center flex text-sm", children: a }),
1380
1539
  /* @__PURE__ */ e.jsx("div", { className: "h-6 w-[2px] bg-gray-200" })
1381
1540
  ] });
1382
1541
  }
1383
- function L({
1384
- children: t,
1385
- title: n,
1386
- icon: a
1542
+ function J({
1543
+ children: a,
1544
+ title: t,
1545
+ icon: s
1387
1546
  }) {
1388
1547
  return /* @__PURE__ */ e.jsxs("div", { className: "rounded-md bg-white shadow-xs", children: [
1389
1548
  /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-4 py-4 border-b border-gray-100", children: [
1390
- /* @__PURE__ */ e.jsx("div", { className: "w-8 h-8 -ml-4 bg-white rounded-full border border-gray-200 flex items-center justify-center shadow-xs shadow-primary-200", children: /* @__PURE__ */ e.jsx(p, { name: a }) }),
1391
- /* @__PURE__ */ e.jsx("h2", { className: "text-lg font-semibold", children: n })
1549
+ /* @__PURE__ */ e.jsx("div", { className: "w-8 h-8 -ml-4 bg-white rounded-full border border-gray-200 flex items-center justify-center shadow-xs shadow-primary-200", children: /* @__PURE__ */ e.jsx(h, { name: s }) }),
1550
+ /* @__PURE__ */ e.jsx("h2", { className: "text-lg font-semibold", children: t })
1392
1551
  ] }),
1393
- /* @__PURE__ */ e.jsx("div", { className: "p-6", children: t })
1552
+ /* @__PURE__ */ e.jsx("div", { className: "p-6", children: a })
1394
1553
  ] });
1395
1554
  }
1396
- function Ve({
1397
- children: t
1555
+ function wt({
1556
+ children: a
1398
1557
  }) {
1399
- return /* @__PURE__ */ e.jsx("div", { className: "h-full w-full bg-gray-50 p-8 bg-[radial-gradient(#d6d6d6_1px,transparent_1px)] bg-size-[16px_16px] overflow-auto", children: /* @__PURE__ */ e.jsx("div", { className: "max-w-[900px] mx-auto", children: t }) });
1558
+ return /* @__PURE__ */ e.jsx("div", { className: "h-full w-full bg-gray-50 p-8 bg-[radial-gradient(#d6d6d6_1px,transparent_1px)] bg-size-[16px_16px] overflow-auto", children: /* @__PURE__ */ e.jsx("div", { className: "max-w-[900px] mx-auto", children: a }) });
1400
1559
  }
1401
1560
  export {
1402
- ke as RuleEngine
1561
+ Et as RuleEngine
1403
1562
  };