@commercelayer/app-elements 6.0.3 → 6.1.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.
@@ -1,13 +1,14 @@
1
1
  "use client";
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";
2
+ import { t as D, B as re, D as le, E as ie, I as oe, N as ce, O as ue, P as de, Z as S, b as me, d as pe, e as fe, f as he, g as ye, h as ge, i as be, j as xe, k as ve, l as M, n as je, o as _e, p as Te, q as Ne, r as we, s as $e, u as Ce, v as Ee, w as ke, x as Se, y as Ve, z as Re, A as Ae, C as Ie, F as Ze, G as De, H as Me, J as qe, K as Oe, L as Le, M as Fe, Q as Pe, R as ze, S as Ue, T as Je, U as We, V as Be, W as Ke, X as Ye, Y as Xe, _ as He, $ as Ge, a0 as Qe, a1 as et, a2 as tt, a3 as at, a4 as st, a5 as nt, a6 as rt, a7 as lt, a8 as it, a9 as q, aa as ot, ab as ct, ac as ut, ad as dt, ae as mt, af as pt, ag as ft, ah as ht, ai as yt, aj as gt, ak as bt, al as xt, am as vt, an as jt, ao as _t, ap as Tt, aq as Nt, ar as wt, as as $t, at as Ct, au as Et, av as kt, aw as St, ax as Vt, ay as Rt, az as At, aA as It, aB as Zt, aC as Dt, aD as Mt, aE as qt, aF as Ot, aG as Lt, aH as Ft, aI as Pt, aJ as zt, aK as Ut, aL as Jt, aM as Wt, aN as Bt, aO as Kt, aP as Yt, aQ as Xt, aR as Ht, aS as Gt, aT as Qt, aU as e, aV as V, aW as ea, aX as ta, aY as aa, aZ as v, a_ as $, a$ as sa, b0 as R, b1 as g, b2 as I, b3 as w, b4 as x, b5 as N, b6 as na, b7 as E, b8 as K, b9 as Y, ba as X, bb as ra, bc as la, bd as H, be as A, bf as ia, bg as oa, bh as ca } from "./main-Dv_RZ0zk.js";
3
+ import O, { useReducer as ua, useCallback as C, useMemo as da, createContext as ma, useContext as pa, useRef as G, useState as f, useEffect as T } from "react";
4
4
  import "react-hook-form";
5
- import { p as D } from "./parseISO-Ccxkiq7f.js";
6
- function q(a, t) {
7
- const s = a.match(
5
+ import "wouter";
6
+ import { p as L } from "./parseISO-BVgVyT7w.js";
7
+ function F(t, a) {
8
+ const s = t.match(
8
9
  /(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2}):(\d{2})(?:\.(\d{0,7}))?(?:Z|(.)(\d{2}):?(\d{2})?)?/
9
10
  );
10
- return s ? A(
11
+ return s ? D(
11
12
  Date.UTC(
12
13
  +s[1],
13
14
  +s[2] - 1,
@@ -17,158 +18,162 @@ function q(a, t) {
17
18
  +s[6],
18
19
  +((s[7] || "0") + "00").substring(0, 3)
19
20
  ),
20
- t?.in
21
- ) : A(NaN, t?.in);
21
+ a?.in
22
+ ) : D(NaN, a?.in);
22
23
  }
23
24
  const y = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
24
25
  __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,
26
+ BRAND: re,
27
+ DIRTY: le,
28
+ EMPTY_PATH: ie,
29
+ INVALID: oe,
30
+ NEVER: ce,
31
+ OK: ue,
32
+ ParseStatus: de,
33
+ Schema: S,
34
+ ZodAny: me,
35
+ ZodArray: pe,
36
+ ZodBigInt: fe,
37
+ ZodBoolean: he,
38
+ ZodBranded: ye,
39
+ ZodCatch: ge,
40
+ ZodDate: be,
41
+ ZodDefault: xe,
42
+ ZodDiscriminatedUnion: ve,
43
+ ZodEffects: M,
44
+ ZodEnum: je,
45
+ ZodError: _e,
45
46
  get ZodFirstPartyTypeKind() {
46
- return he;
47
+ return Te;
47
48
  },
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,
49
+ ZodFunction: Ne,
50
+ ZodIntersection: we,
51
+ ZodIssueCode: $e,
52
+ ZodLazy: Ce,
53
+ ZodLiteral: Ee,
54
+ ZodMap: ke,
55
+ ZodNaN: Se,
56
+ ZodNativeEnum: Ve,
57
+ ZodNever: Re,
58
+ ZodNull: Ae,
59
+ ZodNullable: Ie,
60
+ ZodNumber: Ze,
61
+ ZodObject: De,
62
+ ZodOptional: Me,
63
+ ZodParsedType: qe,
64
+ ZodPipeline: Oe,
65
+ ZodPromise: Le,
66
+ ZodReadonly: Fe,
67
+ ZodRecord: Pe,
68
+ ZodSchema: S,
69
+ ZodSet: ze,
70
+ ZodString: Ue,
71
+ ZodSymbol: Je,
72
+ ZodTransformer: M,
73
+ ZodTuple: We,
74
+ ZodType: S,
75
+ ZodUndefined: Be,
76
+ ZodUnion: Ke,
77
+ ZodUnknown: Ye,
78
+ ZodVoid: Xe,
79
+ addIssueToContext: He,
80
+ any: Ge,
81
+ array: Qe,
82
+ bigint: et,
83
+ boolean: tt,
84
+ coerce: at,
85
+ custom: st,
86
+ date: nt,
87
+ datetimeRegex: rt,
88
+ defaultErrorMap: lt,
89
+ discriminatedUnion: it,
90
+ effect: q,
91
+ enum: ot,
92
+ function: ct,
93
+ getErrorMap: ut,
94
+ getParsedType: dt,
95
+ instanceof: mt,
96
+ intersection: pt,
97
+ isAborted: ft,
98
+ isAsync: ht,
99
+ isDirty: yt,
100
+ isValid: gt,
101
+ late: bt,
102
+ lazy: xt,
103
+ literal: vt,
104
+ makeIssue: jt,
105
+ map: _t,
106
+ nan: Tt,
107
+ nativeEnum: Nt,
108
+ never: wt,
109
+ null: $t,
110
+ nullable: Ct,
111
+ number: Et,
112
+ object: kt,
112
113
  get objectUtil() {
113
- return _a;
114
+ return St;
114
115
  },
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,
116
+ oboolean: Vt,
117
+ onumber: Rt,
118
+ optional: At,
119
+ ostring: It,
120
+ pipeline: Zt,
121
+ preprocess: Dt,
122
+ promise: Mt,
123
+ quotelessJson: qt,
124
+ record: Ot,
125
+ set: Lt,
126
+ setErrorMap: Ft,
127
+ strictObject: Pt,
128
+ string: zt,
129
+ symbol: Ut,
130
+ transformer: q,
131
+ tuple: Jt,
132
+ undefined: Wt,
133
+ union: Bt,
134
+ unknown: Kt,
134
135
  get util() {
135
- return Ja;
136
+ return Yt;
136
137
  },
137
- void: Ka
138
+ void: Xt
138
139
  }, Symbol.toStringTag, { value: "Module" }));
139
- function O(a, t, s) {
140
- return a == null ? a : Pa(a, t, s);
140
+ var fa = 1, ha = 4;
141
+ function ya(t) {
142
+ return Ht(t, fa | ha);
141
143
  }
142
- function z(a, t) {
143
- return a == null ? !0 : Ba(a, t);
144
+ function P(t, a, s) {
145
+ return t == null ? t : Gt(t, a, s);
144
146
  }
145
- const X = nt(
147
+ function z(t, a) {
148
+ return t == null ? !0 : Qt(t, a);
149
+ }
150
+ const Q = ma(
146
151
  void 0
147
152
  );
148
- function it(a, t) {
149
- switch (t.type) {
153
+ function ga(t, a) {
154
+ switch (a.type) {
150
155
  case "SET_PATH": {
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$/, "")));
156
+ const s = ya(t.value);
157
+ if (a.value === null)
158
+ if (/\.\d+$/.test(a.path)) {
159
+ const l = a.path.replace(/\.\d+$/, ""), c = parseInt(a.path.match(/\d+$/)?.[0] ?? "0", 10), n = ea(s, l);
160
+ Array.isArray(n) && (n.splice(c, 1), P(s, l, n), n.length === 0 && l.endsWith(".nested.conditions") && z(s, l.replace(/\.conditions$/, "")));
156
161
  } else
157
- z(s, t.path);
162
+ z(s, a.path);
158
163
  else
159
- O(s, t.path, t.value);
164
+ P(s, a.path, a.value);
160
165
  return {
161
- ...a,
166
+ ...t,
162
167
  value: s
163
168
  };
164
169
  }
165
170
  case "SET_SELECTED_RULE_INDEX":
166
171
  return {
167
- ...a,
168
- selectedRuleIndex: t.index
172
+ ...t,
173
+ selectedRuleIndex: a.index
169
174
  };
170
175
  case "SET_VALUE":
171
- return S(a.value, t.value) ? a : t.value.rules.length === 0 ? {
176
+ return V(t.value, a.value) ? t : (a.value.rules?.length ?? 0) === 0 ? {
172
177
  selectedRuleIndex: 0,
173
178
  value: {
174
179
  rules: [
@@ -182,86 +187,194 @@ function it(a, t) {
182
187
  ]
183
188
  }
184
189
  } : {
185
- ...a,
186
- value: t.value
190
+ ...t,
191
+ value: a.value
187
192
  };
188
193
  default:
189
- return a;
194
+ return t;
190
195
  }
191
196
  }
192
- function ot({
193
- children: a,
194
- initialValue: t
197
+ function ba({
198
+ children: t,
199
+ initialValue: a
195
200
  }) {
196
- const [s, r] = tt(it, {
197
- value: t.value,
201
+ const [s, l] = ua(ga, {
202
+ value: a.value,
198
203
  selectedRuleIndex: 0
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(
204
+ }), c = C((u, i) => {
205
+ l({ type: "SET_PATH", path: u, value: i });
206
+ }, []), n = C((u) => {
207
+ l({ type: "SET_SELECTED_RULE_INDEX", index: u }), u < 0 && setTimeout(() => {
208
+ l({ type: "SET_SELECTED_RULE_INDEX", index: 0 });
209
+ }, 50);
210
+ }, []), r = C((u) => {
211
+ l({ type: "SET_VALUE", value: u });
212
+ }, []), o = da(
206
213
  () => ({
207
214
  state: s,
208
- setPath: o,
209
- setSelectedRuleIndex: l,
210
- setValue: n,
211
- availableActionTypes: t.availableActionTypes
215
+ setPath: c,
216
+ setSelectedRuleIndex: n,
217
+ setValue: r,
218
+ availableActionTypes: a.availableActionTypes,
219
+ schemaType: a.schemaType
212
220
  }),
213
221
  [
214
222
  s,
215
- o,
216
- l,
223
+ c,
217
224
  n,
218
- t.availableActionTypes
225
+ r,
226
+ a.availableActionTypes,
227
+ a.schemaType
219
228
  ]
220
229
  );
221
- return /* @__PURE__ */ e.jsx(X.Provider, { value: i, children: a });
230
+ return /* @__PURE__ */ e.jsx(Q.Provider, { value: o, children: t });
222
231
  }
223
- function g() {
224
- const a = lt(X);
225
- if (a === void 0)
232
+ function b() {
233
+ const t = pa(Q);
234
+ if (t === void 0)
226
235
  throw new Error("useRuleEngine must be used within a RuleEngineProvider");
227
- return a;
236
+ return t;
228
237
  }
229
- function ut({
230
- item: a,
231
- pathPrefix: t
238
+ function ee({
239
+ value: t,
240
+ name: a,
241
+ preset: s
232
242
  }) {
233
- const { setPath: s } = g();
234
- if (a == null)
243
+ const { setPath: l, schemaType: c } = b(), { t: n } = ta(), r = G(null), o = c === "order-rules" ? "order" : c === "price-rules" ? "price" : void 0, u = aa(
244
+ (s === "condition" ? xa : s === "action" ? va : []).filter(
245
+ (i) => o != null && i.startsWith(o)
246
+ ).map((i) => ({
247
+ value: i,
248
+ label: n(`resource_paths.${i}`).replace(
249
+ "resource_paths.",
250
+ ""
251
+ )
252
+ })),
253
+ "label"
254
+ );
255
+ return /* @__PURE__ */ e.jsx(
256
+ v,
257
+ {
258
+ ref: r,
259
+ name: a,
260
+ initialValues: u,
261
+ defaultValue: t != null ? u.find((i) => i.value === t) ?? {
262
+ value: t,
263
+ label: t
264
+ } : void 0,
265
+ asTextSearch: !0,
266
+ isCreatable: !0,
267
+ loadAsyncValues: async (i) => {
268
+ if (o == null)
269
+ return [];
270
+ const d = u.filter(
271
+ (p) => p.label.includes(i)
272
+ ), m = (await sa([o], i)).filter((p) => p.value.startsWith(i)).map((p) => {
273
+ const _ = p.type === "relationship" || p.value.endsWith(".metadata") ? `${p.value}.` : p.value;
274
+ return {
275
+ value: _,
276
+ label: _
277
+ };
278
+ }), j = i.includes(".metadata") ? [{ label: i, value: i }] : [], h = [...d, ...m, ...j];
279
+ return console.log("results", h), h;
280
+ },
281
+ onSelect: async (i) => {
282
+ $(i) && (l(a, i.value), i.value.toString().endsWith(".") && r.current?.openMenu("first"));
283
+ }
284
+ }
285
+ );
286
+ }
287
+ const xa = [
288
+ "order.billing_address.country_code",
289
+ "order.country_code",
290
+ "order.currency_code",
291
+ "order.customer_email",
292
+ "order.customer.email",
293
+ "order.customer.customer_group.id",
294
+ "order.customer.customer_group.name",
295
+ "order.customer.tags.id",
296
+ "order.customer.tags.name",
297
+ "order.line_items.item_type",
298
+ "order.line_items.line_item_options.sku_option.tags.name",
299
+ "order.line_items.options_amount_cents",
300
+ "order.line_items.quantity",
301
+ "order.line_items.reference",
302
+ "order.line_items.shipment.id",
303
+ "order.line_items.shipment.shipping_method.id",
304
+ "order.line_items.shipment.shipping_method.name",
305
+ "order.line_items.shipment.shipping_method.reference",
306
+ "order.line_items.sku_code",
307
+ "order.line_items.sku.code",
308
+ "order.line_items.sku.id",
309
+ "order.line_items.sku.inventory.quantity",
310
+ "order.line_items.sku.name",
311
+ "order.line_items.sku.shipping_category.id",
312
+ "order.line_items.sku.sku_lists.id",
313
+ "order.line_items.sku.sku_lists.name",
314
+ "order.line_items.sku.tags.name",
315
+ "order.line_items.unit_amount_cents",
316
+ "order.market.code",
317
+ "order.market.id",
318
+ "order.shipments_count",
319
+ "order.shipping_address.country_code",
320
+ "order.subtotal_amount_cents",
321
+ "order.tags.name",
322
+ "order.total_amount_cents",
323
+ "price.jwt_customer.email",
324
+ "price.jwt_customer.tags.name",
325
+ "price.sku.sku_list_items.sku_list.name",
326
+ "price.sku.code",
327
+ "price.sku.tags.name",
328
+ "price.processed_at",
329
+ "price.amount_cents"
330
+ ], va = [
331
+ "order.line_items.line_item_options",
332
+ "order.line_items.shipment",
333
+ "order.line_items.sku_code",
334
+ "order.line_items.sku.code",
335
+ "order.line_items.sku",
336
+ "order.line_items",
337
+ "order.subtotal_amount_cents",
338
+ "order.total_amount_cents",
339
+ "order",
340
+ "price"
341
+ ];
342
+ function ja({
343
+ item: t,
344
+ pathPrefix: a
345
+ }) {
346
+ const { setPath: s } = b();
347
+ if (t == null)
235
348
  return null;
236
- switch (a.type) {
349
+ switch (t.type) {
237
350
  case "buy_x_pay_y":
238
351
  return /* @__PURE__ */ e.jsxs("div", { className: "w-36 flex items-center gap-0.5", children: [
239
352
  /* @__PURE__ */ e.jsx(
240
- p,
353
+ g,
241
354
  {
242
- name: `${t}.value.x`,
355
+ name: `${a}.value.x`,
243
356
  type: "number",
244
357
  suffix: "X",
245
- defaultValue: a.value?.x,
246
- onChange: (r) => {
358
+ defaultValue: t.value?.x,
359
+ onChange: (l) => {
247
360
  s(
248
- `${t}.value.x`,
249
- parseInt(r.currentTarget.value, 10)
361
+ `${a}.value.x`,
362
+ parseInt(l.currentTarget.value, 10)
250
363
  );
251
364
  }
252
365
  }
253
366
  ),
254
367
  /* @__PURE__ */ e.jsx(
255
- p,
368
+ g,
256
369
  {
257
- name: `${t}.value.y`,
370
+ name: `${a}.value.y`,
258
371
  type: "number",
259
372
  suffix: "Y",
260
- defaultValue: a.value?.y,
261
- onChange: (r) => {
373
+ defaultValue: t.value?.y,
374
+ onChange: (l) => {
262
375
  s(
263
- `${t}.value.y`,
264
- parseInt(r.currentTarget.value, 10)
376
+ `${a}.value.y`,
377
+ parseInt(l.currentTarget.value, 10)
265
378
  );
266
379
  }
267
380
  }
@@ -270,31 +383,31 @@ function ut({
270
383
  case "every_x_discount_y":
271
384
  return /* @__PURE__ */ e.jsxs("div", { className: "w-36 flex items-center gap-0.5", children: [
272
385
  /* @__PURE__ */ e.jsx(
273
- p,
386
+ g,
274
387
  {
275
- name: `${t}.value.x`,
388
+ name: `${a}.value.x`,
276
389
  type: "number",
277
390
  suffix: "X",
278
- defaultValue: a.value?.x,
279
- onChange: (r) => {
391
+ defaultValue: t.value?.x,
392
+ onChange: (l) => {
280
393
  s(
281
- `${t}.value.x`,
282
- parseInt(r.currentTarget.value, 10)
394
+ `${a}.value.x`,
395
+ parseInt(l.currentTarget.value, 10)
283
396
  );
284
397
  }
285
398
  }
286
399
  ),
287
400
  /* @__PURE__ */ e.jsx(
288
- p,
401
+ g,
289
402
  {
290
- name: `${t}.value.y`,
403
+ name: `${a}.value.y`,
291
404
  type: "number",
292
405
  suffix: "Y",
293
- defaultValue: a.value?.y,
294
- onChange: (r) => {
406
+ defaultValue: t.value?.y,
407
+ onChange: (l) => {
295
408
  s(
296
- `${t}.value.y`,
297
- parseInt(r.currentTarget.value, 10)
409
+ `${a}.value.y`,
410
+ parseInt(l.currentTarget.value, 10)
298
411
  );
299
412
  }
300
413
  }
@@ -303,36 +416,36 @@ function ut({
303
416
  case "fixed_amount":
304
417
  case "fixed_price":
305
418
  return /* @__PURE__ */ e.jsx("div", { className: "w-36", children: /* @__PURE__ */ e.jsx(
306
- p,
419
+ g,
307
420
  {
308
- name: `${t}.value`,
421
+ name: `${a}.value`,
309
422
  type: "number",
310
- defaultValue: a.value,
423
+ defaultValue: t.value,
311
424
  min: 0,
312
425
  suffix: "cents",
313
- onChange: (r) => {
426
+ onChange: (l) => {
314
427
  s(
315
- `${t}.value`,
316
- parseInt(r.currentTarget.value, 10)
428
+ `${a}.value`,
429
+ parseInt(l.currentTarget.value, 10)
317
430
  );
318
431
  }
319
432
  }
320
433
  ) });
321
434
  case "percentage": {
322
- const r = (a.value * 100).toFixed(2);
435
+ const l = (t.value * 100).toFixed(2);
323
436
  return /* @__PURE__ */ e.jsx("div", { className: "w-24", children: /* @__PURE__ */ e.jsx(
324
- p,
437
+ g,
325
438
  {
326
- name: `${t}.value`,
439
+ name: `${a}.value`,
327
440
  type: "number",
328
- defaultValue: r.endsWith(".00") ? r.slice(0, -3) : r,
441
+ defaultValue: l.endsWith(".00") ? l.slice(0, -3) : l,
329
442
  min: 0,
330
443
  max: 100,
331
444
  suffix: "%",
332
- onChange: (o) => {
445
+ onChange: (c) => {
333
446
  s(
334
- `${t}.value`,
335
- parseFloat(o.currentTarget.value) / 100
447
+ `${a}.value`,
448
+ parseFloat(c.currentTarget.value) / 100
336
449
  );
337
450
  }
338
451
  }
@@ -342,57 +455,54 @@ function ut({
342
455
  return R();
343
456
  }
344
457
  }
345
- function ct({
346
- item: a,
347
- index: t,
458
+ function _a({
459
+ item: t,
460
+ index: a,
348
461
  onDelete: s
349
462
  }) {
350
463
  const {
351
- setPath: r,
352
- state: { selectedRuleIndex: o },
353
- availableActionTypes: l
354
- } = g(), n = {
464
+ setPath: l,
465
+ state: { selectedRuleIndex: c },
466
+ availableActionTypes: n
467
+ } = b(), r = {
355
468
  percentage: "Percentage discount",
356
469
  fixed_amount: "Fixed amount",
357
470
  fixed_price: "Fixed price",
358
471
  buy_x_pay_y: "Buy X, Pay Y",
359
472
  every_x_discount_y: "Every X, Discount Y"
360
- }, i = `rules.${o}.actions.${t}`;
473
+ }, o = `rules.${c}.actions.${a}`;
361
474
  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: [
362
475
  /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between gap-2 grow p-2", children: [
363
476
  /* @__PURE__ */ e.jsx("div", { className: "flex-1", children: /* @__PURE__ */ e.jsx(
364
477
  v,
365
478
  {
366
- name: `${i}.type`,
367
- defaultValue: a != null ? {
368
- label: n[a.type],
369
- value: a.type
479
+ name: `${o}.type`,
480
+ defaultValue: t != null ? {
481
+ label: r[t.type],
482
+ value: t.type
370
483
  } : void 0,
371
- initialValues: l.map((c) => ({
372
- value: c,
373
- label: n[c]
484
+ initialValues: n.map((u) => ({
485
+ value: u,
486
+ label: r[u]
374
487
  })),
375
- onSelect: (c) => {
376
- C(c) && r(`${i}.type`, c.value);
488
+ onSelect: (u) => {
489
+ $(u) && l(`${o}.type`, u.value);
377
490
  }
378
491
  }
379
492
  ) }),
380
- /* @__PURE__ */ e.jsx(ut, { item: a, pathPrefix: i }),
493
+ /* @__PURE__ */ e.jsx(ja, { item: t, pathPrefix: o }),
381
494
  /* @__PURE__ */ e.jsx("div", { className: "text-black font-bold text-sm", children: "ON" }),
382
495
  /* @__PURE__ */ e.jsx("div", { className: "flex-1", children: /* @__PURE__ */ e.jsx(
383
- p,
496
+ ee,
384
497
  {
385
- name: `${i}.selector`,
386
- type: "text",
387
- defaultValue: a?.selector,
388
- onChange: (c) => {
389
- r(`${i}.selector`, c.currentTarget.value);
390
- }
498
+ preset: "action",
499
+ value: t?.selector,
500
+ name: `${o}.selector`
391
501
  }
392
502
  ) })
393
503
  ] }),
394
504
  s != null && /* @__PURE__ */ e.jsx(
395
- K,
505
+ I,
396
506
  {
397
507
  className: "w-8 border-l border-gray-100 flex items-center justify-center self-stretch",
398
508
  dropdownLabel: /* @__PURE__ */ e.jsx(
@@ -400,15 +510,15 @@ function ct({
400
510
  {
401
511
  type: "button",
402
512
  className: "flex items-center justify-center self-stretch grow",
403
- children: /* @__PURE__ */ e.jsx(h, { name: "dotsThreeVertical", size: 16, weight: "bold" })
513
+ children: /* @__PURE__ */ e.jsx(x, { name: "dotsThreeVertical", size: 16, weight: "bold" })
404
514
  }
405
515
  ),
406
516
  dropdownItems: /* @__PURE__ */ e.jsx(
407
- I,
517
+ w,
408
518
  {
409
519
  label: "Delete",
410
520
  onClick: () => {
411
- r(`${i}`, null), s();
521
+ l(`${o}`, null), s();
412
522
  }
413
523
  }
414
524
  )
@@ -416,94 +526,94 @@ function ct({
416
526
  )
417
527
  ] }) });
418
528
  }
419
- function dt({
420
- actions: a
529
+ function Ta({
530
+ actions: t
421
531
  }) {
422
- const [t, s] = f(0), {
423
- setPath: r,
424
- state: { selectedRuleIndex: o }
425
- } = g();
532
+ const [a, s] = f(0), {
533
+ setPath: l,
534
+ state: { selectedRuleIndex: c }
535
+ } = b();
426
536
  return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
427
- /* @__PURE__ */ e.jsx("div", { children: a?.map((l, n, i) => /* @__PURE__ */ e.jsx(
428
- ct,
537
+ /* @__PURE__ */ e.jsx("div", { children: t?.map((n, r, o) => /* @__PURE__ */ e.jsx(
538
+ _a,
429
539
  {
430
- item: l,
431
- index: n,
432
- onDelete: i.length > 1 ? () => {
433
- s((c) => c + 1);
540
+ item: n,
541
+ index: r,
542
+ onDelete: o.length > 1 ? () => {
543
+ s((u) => u + 1);
434
544
  } : void 0
435
545
  },
436
- `${o}-${n}-${t}`
546
+ `${c}-${r}-${a}`
437
547
  )) }),
438
548
  /* @__PURE__ */ e.jsx("div", { className: "mt-6", children: /* @__PURE__ */ e.jsxs(
439
- P,
549
+ N,
440
550
  {
441
551
  size: "small",
442
552
  variant: "secondary",
443
553
  alignItems: "center",
444
554
  onClick: () => {
445
- r(
446
- `rules.${o}.actions.${a?.length ?? 0}`,
555
+ l(
556
+ `rules.${c}.actions.${t?.length ?? 0}`,
447
557
  void 0
448
558
  );
449
559
  },
450
560
  children: [
451
- /* @__PURE__ */ e.jsx(h, { name: "plusCircle" }),
561
+ /* @__PURE__ */ e.jsx(x, { name: "plusCircle" }),
452
562
  " Add action"
453
563
  ]
454
564
  }
455
565
  ) })
456
566
  ] });
457
567
  }
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);
463
- }).catch((r) => {
464
- console.error("Error fetching field info:", r);
568
+ function te(t) {
569
+ const [a, s] = f(void 0);
570
+ return T(() => {
571
+ t?.field != null && na(t.field).then((l) => {
572
+ s(l);
573
+ }).catch((l) => {
574
+ console.error("Error fetching field info:", l);
465
575
  });
466
- }, [a?.field]), { infos: t };
576
+ }, [t?.field]), { infos: a };
467
577
  }
468
- function G(a) {
469
- if (typeof a == "string")
470
- return w(q(a)) ? "datetime" : "string";
471
- if (typeof a == "number")
578
+ function ae(t) {
579
+ if (typeof t == "string")
580
+ return E(F(t)) ? "datetime" : "string";
581
+ if (typeof t == "number")
472
582
  return "integer";
473
- if (typeof a == "boolean")
583
+ if (typeof t == "boolean")
474
584
  return "boolean";
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")
585
+ if (Array.isArray(t)) {
586
+ if (typeof t[0] == "string")
587
+ return E(F(t[0])) ? "datetime" : "string";
588
+ if (typeof t[0] == "number")
479
589
  return "integer";
480
590
  }
481
591
  return "string";
482
592
  }
483
- function mt({
484
- item: a,
485
- pathPrefix: t
593
+ function Na({
594
+ item: t,
595
+ pathPrefix: a
486
596
  }) {
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(
597
+ const { setPath: s } = b(), { infos: l } = te(t);
598
+ let c = l?.field?.type;
599
+ return c == null && (c = ae(t?.value)), /* @__PURE__ */ e.jsx(
490
600
  v,
491
601
  {
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
602
+ name: `${a}.matcher`,
603
+ value: t != null ? {
604
+ label: U.find((n) => n.matcher === t.matcher && (c != null && n.fieldTypes.includes(c) || c == null))?.label ?? (t.matcher != null ? `⚠️   ${t.matcher}` : ""),
605
+ value: t.matcher
496
606
  } : void 0,
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));
607
+ initialValues: U.filter(({ fieldTypes: n, visible: r }) => r !== !1 && n.includes(c)).map(({ matcher: n, label: r }) => ({ value: n, label: r })),
608
+ onSelect: (n) => {
609
+ $(n) && (s(`${a}.matcher`, n.value), K.includes(
610
+ n.value
611
+ ) && s(`${a}.value`, null));
502
612
  }
503
613
  }
504
614
  );
505
615
  }
506
- const F = [
616
+ const U = [
507
617
  {
508
618
  /** Matches if field value equals provided value
509
619
  * @field Integer, String, Datetime, Boolean
@@ -748,7 +858,7 @@ const F = [
748
858
  label: "is present",
749
859
  fieldTypes: ["integer", "string", "datetime", "boolean"]
750
860
  }
751
- ], L = {
861
+ ], J = {
752
862
  in_and: {
753
863
  label: "all of"
754
864
  },
@@ -762,46 +872,46 @@ const F = [
762
872
  label: "not at least one of"
763
873
  }
764
874
  };
765
- function ft({
766
- value: a,
767
- pathPrefix: t
875
+ function wa({
876
+ value: t,
877
+ pathPrefix: a
768
878
  }) {
769
- return (typeof a != "object" || Array.isArray(a) || a === null) && (a = {
879
+ return (typeof t != "object" || Array.isArray(t) || t === null) && (t = {
770
880
  in_and: []
771
- }), /* @__PURE__ */ e.jsx("div", { children: Object.entries(a).map(([s, r], o) => /* @__PURE__ */ e.jsx(
772
- pt,
881
+ }), /* @__PURE__ */ e.jsx("div", { children: Object.entries(t).map(([s, l], c) => /* @__PURE__ */ e.jsx(
882
+ $a,
773
883
  {
774
- pathPrefix: t,
775
- defaultValue: r,
884
+ pathPrefix: a,
885
+ defaultValue: l,
776
886
  initialMatcher: s
777
887
  },
778
- `${t}.${// biome-ignore lint/suspicious/noArrayIndexKey: Using index as key is acceptable here since items are static
779
- o}`
888
+ `${a}.${// biome-ignore lint/suspicious/noArrayIndexKey: Using index as key is acceptable here since items are static
889
+ c}`
780
890
  )) });
781
891
  }
782
- function pt({
783
- initialMatcher: a,
784
- defaultValue: t,
892
+ function $a({
893
+ initialMatcher: t,
894
+ defaultValue: a,
785
895
  pathPrefix: s
786
896
  }) {
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: [
897
+ const [l, c] = f(t), [n, r] = f(t), [o, u] = f(a), { setPath: i } = b();
898
+ return T(() => {
899
+ l !== n && (i(`${s}.${l}`, null), c(n)), i(`${s}.${n}`, o);
900
+ }, [n, o, i]), /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2 last-of-type:mt-2", children: [
791
901
  /* @__PURE__ */ e.jsx("div", { className: "shrink-0", children: /* @__PURE__ */ e.jsx(
792
902
  v,
793
903
  {
794
904
  defaultValue: [
795
- { value: l, label: L[l].label }
905
+ { value: n, label: J[n].label }
796
906
  ],
797
- initialValues: Object.entries(L).map(
907
+ initialValues: Object.entries(J).map(
798
908
  ([d, { label: m }]) => ({
799
909
  value: d,
800
910
  label: m
801
911
  })
802
912
  ),
803
913
  onSelect: (d) => {
804
- C(d) && n(d.value);
914
+ $(d) && r(d.value);
805
915
  }
806
916
  }
807
917
  ) }),
@@ -810,13 +920,13 @@ function pt({
810
920
  {
811
921
  isMulti: !0,
812
922
  isCreatable: !0,
813
- defaultValue: (Array.isArray(i) ? i : []).map((d) => ({
923
+ defaultValue: (Array.isArray(o) ? o : []).map((d) => ({
814
924
  value: d,
815
925
  label: d.toString()
816
926
  })),
817
927
  initialValues: [],
818
928
  onSelect: (d) => {
819
- Y(d) && c(
929
+ Y(d) && u(
820
930
  d.map(
821
931
  (m) => typeof m.value == "boolean" ? m.value.toString() : m.value
822
932
  )
@@ -826,111 +936,111 @@ function pt({
826
936
  ) })
827
937
  ] });
828
938
  }
829
- function yt({
830
- value: a,
831
- onChange: t
939
+ function Ca({
940
+ value: t,
941
+ onChange: a
832
942
  }) {
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
943
+ const [s, l] = f(
944
+ Array.isArray(t) && typeof t[0] == "number" ? t[0] : null
945
+ ), [c, n] = f(
946
+ Array.isArray(t) && typeof t[1] == "number" ? t[1] : null
837
947
  );
838
948
  return /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-4", children: [
839
949
  /* @__PURE__ */ e.jsx("div", { className: "grow", children: /* @__PURE__ */ e.jsx(
840
- p,
950
+ g,
841
951
  {
842
952
  type: "number",
843
953
  placeholder: "Min",
844
954
  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]);
955
+ onChange: (r) => {
956
+ const o = parseInt(r.currentTarget.value, 10);
957
+ l(Number.isNaN(o) ? null : o), a([Number.isNaN(o) ? null : o, c]);
848
958
  }
849
959
  }
850
960
  ) }),
851
961
  /* @__PURE__ */ e.jsx("span", { className: "text-gray-300", children: "to" }),
852
962
  /* @__PURE__ */ e.jsx("div", { className: "grow", children: /* @__PURE__ */ e.jsx(
853
- p,
963
+ g,
854
964
  {
855
965
  type: "number",
856
966
  placeholder: "Max",
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]);
967
+ value: c ?? "",
968
+ onChange: (r) => {
969
+ const o = parseInt(r.currentTarget.value, 10);
970
+ n(Number.isNaN(o) ? null : o), a([s, Number.isNaN(o) ? null : o]);
861
971
  }
862
972
  }
863
973
  ) })
864
974
  ] });
865
975
  }
866
- function gt({
867
- value: a,
868
- onChange: t
976
+ function Ea({
977
+ value: t,
978
+ onChange: a
869
979
  }) {
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
980
+ const [s, l] = f(
981
+ Array.isArray(t) && typeof t[0] == "string" ? t[0] : null
982
+ ), [c, n] = f(
983
+ Array.isArray(t) && typeof t[1] == "string" ? t[1] : null
874
984
  );
875
985
  return /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-4", children: [
876
986
  /* @__PURE__ */ e.jsx("div", { className: "grow", children: /* @__PURE__ */ e.jsx(
877
- p,
987
+ g,
878
988
  {
879
989
  type: "text",
880
990
  placeholder: "Min",
881
991
  value: s ?? "",
882
- onChange: (n) => {
883
- const i = n.currentTarget.value;
884
- r(i), t([i, o]);
992
+ onChange: (r) => {
993
+ const o = r.currentTarget.value;
994
+ l(o), a([o, c]);
885
995
  }
886
996
  }
887
997
  ) }),
888
998
  /* @__PURE__ */ e.jsx("span", { className: "text-gray-300", children: "to" }),
889
999
  /* @__PURE__ */ e.jsx("div", { className: "grow", children: /* @__PURE__ */ e.jsx(
890
- p,
1000
+ g,
891
1001
  {
892
1002
  type: "text",
893
1003
  placeholder: "Max",
894
- value: o ?? "",
895
- onChange: (n) => {
896
- const i = n.currentTarget.value;
897
- l(i), t([s, i]);
1004
+ value: c ?? "",
1005
+ onChange: (r) => {
1006
+ const o = r.currentTarget.value;
1007
+ n(o), a([s, o]);
898
1008
  }
899
1009
  }
900
1010
  ) })
901
1011
  ] });
902
1012
  }
903
- function bt({
904
- item: a,
905
- pathPrefix: t
1013
+ function ka({
1014
+ item: t,
1015
+ pathPrefix: a
906
1016
  }) {
907
- const { setPath: s } = g(), { infos: r } = H(a), { user: o } = W(), l = `${t}.value`;
908
- if (a == null || B.includes(
909
- a.matcher
1017
+ const { setPath: s } = b(), { infos: l } = te(t), { user: c } = X(), n = `${a}.value`;
1018
+ if (t == null || K.includes(
1019
+ t.matcher
910
1020
  ))
911
1021
  return null;
912
- const n = a;
913
- let i = r?.field?.type;
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)
916
- )) && (i = "string");
917
- let c = null;
918
- switch (i) {
1022
+ const r = t;
1023
+ let o = l?.field?.type;
1024
+ o == null && (o = ae(r.value)), (typeof r.value == "string" && /^{{.*}}$/.test(r.value) || Array.isArray(r.value) && r.value.some(
1025
+ (i) => typeof i == "string" && /^{{.*}}$/.test(i)
1026
+ )) && (o = "string");
1027
+ let u = null;
1028
+ switch (o) {
919
1029
  case "datetime": {
920
- c = "date";
1030
+ u = "date";
921
1031
  break;
922
1032
  }
923
1033
  case "boolean": {
924
- c = "boolean";
1034
+ u = "boolean";
925
1035
  break;
926
1036
  }
927
1037
  case "string": {
928
- c = "text";
1038
+ u = "text";
929
1039
  break;
930
1040
  }
931
1041
  case "integer":
932
1042
  case "float": {
933
- c = "number";
1043
+ u = "number";
934
1044
  break;
935
1045
  }
936
1046
  case "array":
@@ -938,11 +1048,11 @@ function bt({
938
1048
  case "object":
939
1049
  break;
940
1050
  default: {
941
- c = "text";
1051
+ u = "text";
942
1052
  break;
943
1053
  }
944
1054
  }
945
- switch (n.matcher) {
1055
+ switch (r.matcher) {
946
1056
  case "eq":
947
1057
  case "not_eq":
948
1058
  case "lt":
@@ -962,54 +1072,54 @@ function bt({
962
1072
  case "gteq_lt":
963
1073
  case "gt_lteq":
964
1074
  case "gteq_lteq": {
965
- c === "number" && (c = "numberRange"), c === "text" && (c = "textRange"), c === "date" && (c = "dateRange");
1075
+ u === "number" && (u = "numberRange"), u === "text" && (u = "textRange"), u === "date" && (u = "dateRange");
966
1076
  break;
967
1077
  }
968
1078
  case "is_in":
969
1079
  case "is_not_in": {
970
- c = "tag";
1080
+ u = "tag";
971
1081
  break;
972
1082
  }
973
1083
  case "array_match": {
974
- c = "arrayMatch";
1084
+ u = "arrayMatch";
975
1085
  break;
976
1086
  }
977
1087
  default: {
978
- R(n.matcher);
1088
+ R(r.matcher);
979
1089
  break;
980
1090
  }
981
1091
  }
982
- switch (c) {
1092
+ switch (u) {
983
1093
  case "date": {
984
- const u = D(
985
- typeof n.value == "string" ? n.value : ""
1094
+ const i = L(
1095
+ typeof r.value == "string" ? r.value : ""
986
1096
  );
987
1097
  return /* @__PURE__ */ e.jsx(
988
- Ha,
1098
+ la,
989
1099
  {
990
- value: w(u) ? u : void 0,
1100
+ value: E(i) ? i : void 0,
991
1101
  showTimeSelect: !0,
992
1102
  placeholder: "Enter value",
993
1103
  onChange: (d) => {
994
- s(l, d?.toJSON());
1104
+ s(n, d?.toJSON());
995
1105
  },
996
- timezone: o?.timezone
1106
+ timezone: c?.timezone
997
1107
  }
998
1108
  );
999
1109
  }
1000
1110
  case "dateRange": {
1001
- const u = Array.isArray(n.value) ? n.value.map((d) => {
1002
- const m = D(typeof d == "string" ? d : "");
1003
- return w(m) ? m : null;
1111
+ const i = Array.isArray(r.value) ? r.value.map((d) => {
1112
+ const m = L(typeof d == "string" ? d : "");
1113
+ return E(m) ? m : null;
1004
1114
  }) : [null, null];
1005
1115
  return /* @__PURE__ */ e.jsx(
1006
- Xa,
1116
+ ra,
1007
1117
  {
1008
- value: u,
1118
+ value: i,
1009
1119
  showTimeSelect: !0,
1010
1120
  onChange: (d) => {
1011
1121
  s(
1012
- `${t}.value`,
1122
+ `${a}.value`,
1013
1123
  d.map((m) => m?.toJSON() ?? null)
1014
1124
  );
1015
1125
  }
@@ -1018,30 +1128,30 @@ function bt({
1018
1128
  }
1019
1129
  case "numberRange":
1020
1130
  return /* @__PURE__ */ e.jsx(
1021
- yt,
1131
+ Ca,
1022
1132
  {
1023
- value: n.value,
1024
- onChange: (u) => {
1025
- s(l, u);
1133
+ value: r.value,
1134
+ onChange: (i) => {
1135
+ s(n, i);
1026
1136
  }
1027
1137
  }
1028
1138
  );
1029
1139
  case "textRange":
1030
1140
  return /* @__PURE__ */ e.jsx(
1031
- gt,
1141
+ Ea,
1032
1142
  {
1033
- value: n.value,
1034
- onChange: (u) => {
1035
- s(l, u);
1143
+ value: r.value,
1144
+ onChange: (i) => {
1145
+ s(n, i);
1036
1146
  }
1037
1147
  }
1038
1148
  );
1039
1149
  case "arrayMatch":
1040
1150
  return /* @__PURE__ */ e.jsx(
1041
- ft,
1151
+ wa,
1042
1152
  {
1043
- value: n.value,
1044
- pathPrefix: `${t}.value`
1153
+ value: r.value,
1154
+ pathPrefix: `${a}.value`
1045
1155
  }
1046
1156
  );
1047
1157
  case "tag":
@@ -1051,16 +1161,16 @@ function bt({
1051
1161
  isMulti: !0,
1052
1162
  isClearable: !1,
1053
1163
  isCreatable: !0,
1054
- defaultValue: Array.isArray(n.value) ? n.value.map((u) => ({
1055
- label: u.toString(),
1056
- value: u
1164
+ defaultValue: Array.isArray(r.value) ? r.value.map((i) => ({
1165
+ label: i.toString(),
1166
+ value: i
1057
1167
  })) : [],
1058
1168
  initialValues: [],
1059
- onSelect: (u) => {
1060
- Y(u) && s(
1061
- `${t}.value`,
1062
- u.map((d) => {
1063
- if (i === "integer") {
1169
+ onSelect: (i) => {
1170
+ Y(i) && s(
1171
+ `${a}.value`,
1172
+ i.map((d) => {
1173
+ if (o === "integer") {
1064
1174
  const m = parseInt(d.value.toString(), 10);
1065
1175
  return Number.isNaN(m) ? null : m;
1066
1176
  }
@@ -1072,16 +1182,16 @@ function bt({
1072
1182
  );
1073
1183
  case "number":
1074
1184
  return /* @__PURE__ */ e.jsx(
1075
- p,
1185
+ g,
1076
1186
  {
1077
- name: `${t}.value`,
1187
+ name: `${a}.value`,
1078
1188
  type: "number",
1079
- defaultValue: typeof n.value == "number" ? n.value : "",
1189
+ defaultValue: typeof r.value == "number" ? r.value : "",
1080
1190
  placeholder: "Enter value",
1081
- onChange: (u) => {
1191
+ onChange: (i) => {
1082
1192
  s(
1083
- `${t}.value`,
1084
- parseInt(u.currentTarget.value, 10)
1193
+ `${a}.value`,
1194
+ parseInt(i.currentTarget.value, 10)
1085
1195
  );
1086
1196
  }
1087
1197
  }
@@ -1090,31 +1200,31 @@ function bt({
1090
1200
  return /* @__PURE__ */ e.jsx(
1091
1201
  v,
1092
1202
  {
1093
- name: `${t}.value`,
1094
- defaultValue: typeof n.value == "boolean" ? {
1095
- label: n.value ? "Yes" : "No",
1096
- value: n.value
1203
+ name: `${a}.value`,
1204
+ defaultValue: typeof r.value == "boolean" ? {
1205
+ label: r.value ? "Yes" : "No",
1206
+ value: r.value
1097
1207
  } : void 0,
1098
1208
  initialValues: [
1099
1209
  { label: "Yes", value: !0 },
1100
1210
  { label: "No", value: !1 }
1101
1211
  ],
1102
- onSelect: (u) => {
1103
- C(u) && s(l, u.value);
1212
+ onSelect: (i) => {
1213
+ $(i) && s(n, i.value);
1104
1214
  }
1105
1215
  }
1106
1216
  );
1107
1217
  case "text":
1108
1218
  case null:
1109
1219
  return /* @__PURE__ */ e.jsx(
1110
- p,
1220
+ g,
1111
1221
  {
1112
- name: `${t}.value`,
1222
+ name: `${a}.value`,
1113
1223
  type: "text",
1114
- defaultValue: typeof n.value == "string" ? n.value : JSON.stringify(n.value),
1224
+ defaultValue: typeof r.value == "string" ? r.value : JSON.stringify(r.value),
1115
1225
  placeholder: "Enter value",
1116
- onChange: (u) => {
1117
- s(l, u.currentTarget.value);
1226
+ onChange: (i) => {
1227
+ s(n, i.currentTarget.value);
1118
1228
  }
1119
1229
  }
1120
1230
  );
@@ -1122,33 +1232,33 @@ function bt({
1122
1232
  return R();
1123
1233
  }
1124
1234
  }
1125
- function ht({
1126
- item: a,
1127
- nestingLevel: t,
1235
+ function Sa({
1236
+ item: t,
1237
+ nestingLevel: a,
1128
1238
  pathPrefix: s,
1129
- onDelete: r
1239
+ onDelete: l
1130
1240
  }) {
1131
- const { setPath: o } = g(), l = [];
1132
- return t < 2 && (l[0] ??= [], l[0].push(
1241
+ const { setPath: c } = b(), n = [];
1242
+ return a < 2 && (n[0] ??= [], n[0].push(
1133
1243
  /* @__PURE__ */ e.jsx(
1134
- I,
1244
+ w,
1135
1245
  {
1136
1246
  label: "Nest conditions",
1137
1247
  onClick: () => {
1138
- o(
1139
- `${s}.nested.conditions.${(a?.nested?.conditions ?? []).length}`,
1248
+ c(
1249
+ `${s}.nested.conditions.${(t?.nested?.conditions ?? []).length}`,
1140
1250
  void 0
1141
1251
  );
1142
1252
  }
1143
1253
  }
1144
1254
  )
1145
- )), r != null && (l[1] ??= [], l[1].push(
1255
+ )), l != null && (n[1] ??= [], n[1].push(
1146
1256
  /* @__PURE__ */ e.jsx(
1147
- I,
1257
+ w,
1148
1258
  {
1149
1259
  label: "Delete",
1150
1260
  onClick: () => {
1151
- o(`${s}`, null), r();
1261
+ c(`${s}`, null), l();
1152
1262
  }
1153
1263
  }
1154
1264
  )
@@ -1156,25 +1266,19 @@ function ht({
1156
1266
  /* @__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: [
1157
1267
  /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
1158
1268
  /* @__PURE__ */ e.jsx("div", { className: "flex-1", children: /* @__PURE__ */ e.jsx(
1159
- p,
1269
+ ee,
1160
1270
  {
1161
- name: `${s}.field`,
1162
- type: "text",
1163
- defaultValue: a?.field,
1164
- onChange: (n) => {
1165
- o(`${s}.field`, n.currentTarget.value);
1166
- },
1167
- onBlur: (n) => {
1168
- o(`${s}.field`, n.currentTarget.value);
1169
- }
1271
+ preset: "condition",
1272
+ value: t?.field,
1273
+ name: `${s}.field`
1170
1274
  }
1171
1275
  ) }),
1172
- /* @__PURE__ */ e.jsx("div", { children: /* @__PURE__ */ e.jsx(mt, { item: a, pathPrefix: s }) })
1276
+ /* @__PURE__ */ e.jsx("div", { children: /* @__PURE__ */ e.jsx(Na, { item: t, pathPrefix: s }) })
1173
1277
  ] }),
1174
- /* @__PURE__ */ e.jsx(bt, { item: a, pathPrefix: s })
1278
+ /* @__PURE__ */ e.jsx(ka, { item: t, pathPrefix: s })
1175
1279
  ] }) }),
1176
- l.length > 0 && /* @__PURE__ */ e.jsx(
1177
- K,
1280
+ n.length > 0 && /* @__PURE__ */ e.jsx(
1281
+ I,
1178
1282
  {
1179
1283
  className: "w-8 border-l border-gray-100 flex items-center justify-center self-stretch",
1180
1284
  dropdownLabel: /* @__PURE__ */ e.jsx(
@@ -1182,92 +1286,92 @@ function ht({
1182
1286
  {
1183
1287
  type: "button",
1184
1288
  className: "flex items-center justify-center self-stretch grow",
1185
- children: /* @__PURE__ */ e.jsx(h, { name: "dotsThreeVertical", size: 16, weight: "bold" })
1289
+ children: /* @__PURE__ */ e.jsx(x, { name: "dotsThreeVertical", size: 16, weight: "bold" })
1186
1290
  }
1187
1291
  ),
1188
- dropdownItems: l.map((n, i, c) => (
1292
+ dropdownItems: n.map((r, o, u) => (
1189
1293
  // biome-ignore lint/suspicious/noArrayIndexKey: Using index as key is acceptable here since items are static
1190
- /* @__PURE__ */ e.jsxs(M.Fragment, { children: [
1191
- n.map((u, d) => (
1294
+ /* @__PURE__ */ e.jsxs(O.Fragment, { children: [
1295
+ r.map((i, d) => (
1192
1296
  // biome-ignore lint/suspicious/noArrayIndexKey: Using index as key is acceptable here since items are static
1193
- /* @__PURE__ */ e.jsx(M.Fragment, { children: u }, d)
1297
+ /* @__PURE__ */ e.jsx(O.Fragment, { children: i }, d)
1194
1298
  )),
1195
- i < c.length - 1 && /* @__PURE__ */ e.jsx(Ga, {})
1196
- ] }, i)
1299
+ o < u.length - 1 && /* @__PURE__ */ e.jsx(H, {})
1300
+ ] }, o)
1197
1301
  ))
1198
1302
  }
1199
1303
  )
1200
1304
  ] });
1201
1305
  }
1202
- function Q({
1203
- item: a,
1204
- children: t,
1306
+ function se({
1307
+ item: t,
1308
+ children: a,
1205
1309
  nestingLevel: s = 0,
1206
- pathPrefix: r
1310
+ pathPrefix: l
1207
1311
  }) {
1208
1312
  const {
1209
- state: { selectedRuleIndex: o }
1210
- } = g(), l = a?.conditions_logic?.toLowerCase() ?? "and", { setPath: n } = g(), [i, c] = f(0), u = s > 0;
1313
+ state: { selectedRuleIndex: c }
1314
+ } = b(), n = t?.conditions_logic?.toLowerCase() ?? "and", { setPath: r } = b(), [o, u] = f(0), i = s > 0;
1211
1315
  return /* @__PURE__ */ e.jsxs(
1212
1316
  "div",
1213
1317
  {
1214
- className: _("query-group", {
1215
- "p-4 border border-gray-200 rounded-md": u
1318
+ className: A("query-group", {
1319
+ "p-4 border border-gray-200 rounded-md": i
1216
1320
  }),
1217
1321
  children: [
1218
- t,
1219
- a != null && (a.conditions ?? []).length > 0 && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1322
+ a,
1323
+ t != null && (t.conditions ?? []).length > 0 && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1220
1324
  /* @__PURE__ */ e.jsxs(
1221
1325
  "select",
1222
1326
  {
1223
1327
  onChange: (d) => {
1224
- n(
1225
- `${r}.conditions_logic`,
1328
+ r(
1329
+ `${l}.conditions_logic`,
1226
1330
  d.currentTarget.value
1227
1331
  );
1228
1332
  },
1229
- defaultValue: l,
1333
+ defaultValue: n,
1230
1334
  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",
1231
1335
  children: [
1232
1336
  /* @__PURE__ */ e.jsxs("option", { value: "and", children: [
1233
- u ? "Nested in " : "",
1337
+ i ? "Nested in " : "",
1234
1338
  "AND"
1235
1339
  ] }),
1236
1340
  /* @__PURE__ */ e.jsxs("option", { value: "or", children: [
1237
- u ? "Nested in " : "",
1341
+ i ? "Nested in " : "",
1238
1342
  "OR"
1239
1343
  ] })
1240
1344
  ]
1241
1345
  }
1242
1346
  ),
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;
1347
+ /* @__PURE__ */ e.jsx("div", { className: "border-l border-gray-200 ml-3 pt-3", children: t?.conditions?.map((d, m, j) => {
1348
+ const h = m === j.length - 1;
1245
1349
  return /* @__PURE__ */ e.jsxs(
1246
1350
  "div",
1247
1351
  {
1248
1352
  className: "flex items-center mb-4 last:mb-0 relative",
1249
1353
  children: [
1250
- /* @__PURE__ */ e.jsx(xt, { rounded: x }),
1354
+ /* @__PURE__ */ e.jsx(Va, { rounded: h }),
1251
1355
  /* @__PURE__ */ e.jsx("div", { className: "ml-4 w-full", children: /* @__PURE__ */ e.jsx(
1252
- Q,
1356
+ se,
1253
1357
  {
1254
1358
  item: d?.nested ?? void 0,
1255
1359
  nestingLevel: d?.nested != null ? s + 1 : 0,
1256
- pathPrefix: `${r}.conditions.${m}.nested`,
1360
+ pathPrefix: `${l}.conditions.${m}.nested`,
1257
1361
  children: /* @__PURE__ */ e.jsx(
1258
1362
  "div",
1259
1363
  {
1260
- className: _({
1364
+ className: A({
1261
1365
  "mb-4": d?.nested != null
1262
1366
  }),
1263
1367
  children: /* @__PURE__ */ e.jsx(
1264
- ht,
1368
+ Sa,
1265
1369
  {
1266
1370
  item: d,
1267
1371
  nestingLevel: s,
1268
- pathPrefix: `${r}.conditions.${m}`,
1269
- onDelete: T.length > 1 || s > 0 ? () => {
1270
- c((b) => b + 1);
1372
+ pathPrefix: `${l}.conditions.${m}`,
1373
+ onDelete: j.length > 1 || s > 0 ? () => {
1374
+ u((p) => p + 1);
1271
1375
  } : void 0
1272
1376
  }
1273
1377
  )
@@ -1277,7 +1381,7 @@ function Q({
1277
1381
  ) })
1278
1382
  ]
1279
1383
  },
1280
- `${o}-${m}-${i}`
1384
+ `${c}-${m}-${o}`
1281
1385
  );
1282
1386
  }) })
1283
1387
  ] })
@@ -1285,75 +1389,84 @@ function Q({
1285
1389
  }
1286
1390
  );
1287
1391
  }
1288
- function xt({
1289
- rounded: a = !1
1392
+ function Va({
1393
+ rounded: t = !1
1290
1394
  }) {
1291
- return a ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1395
+ return t ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1292
1396
  /* @__PURE__ */ e.jsx("div", { className: "absolute -left-px top-1/2 w-px h-1/2 bg-white" }),
1293
1397
  /* @__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" })
1294
1398
  ] }) : /* @__PURE__ */ e.jsx("div", { className: "absolute left-0 top-1/2 -translate-y-1/2 w-3.5 h-px bg-gray-200" });
1295
1399
  }
1296
- function vt() {
1400
+ function Ra() {
1297
1401
  const {
1298
- setPath: a,
1299
- state: { value: t, selectedRuleIndex: s }
1300
- } = g(), [r, o] = f(
1301
- t.rules[s]?.name ?? ""
1402
+ setPath: t,
1403
+ state: { value: a, selectedRuleIndex: s }
1404
+ } = b(), [l, c] = f(
1405
+ a.rules?.[s]?.name ?? ""
1302
1406
  );
1303
- return j(() => {
1304
- o(t.rules[s]?.name ?? "");
1305
- }, [s]), // biome-ignore lint/a11y/noStaticElementInteractions: This <div> is used with contentEditable
1407
+ return T(() => {
1408
+ c(a.rules?.[s]?.name ?? "");
1409
+ }, [s]), // <Input
1410
+ // value={value.rules?.[selectedRuleIndex]?.name}
1411
+ // onChange={(event) => {
1412
+ // const target = event.currentTarget
1413
+ // const value = target.value.replace(/[\n\s]+/g, " ").trim()
1414
+ // setPath(`rules.${selectedRuleIndex}.name`, value)
1415
+ // }}
1416
+ // className="bg-transparent border-0 shadow-none field-sizing-content"
1417
+ // />
1418
+ // biome-ignore lint/a11y/noStaticElementInteractions: This <div> is used with contentEditable
1306
1419
  /* @__PURE__ */ e.jsx(
1307
1420
  "div",
1308
1421
  {
1309
1422
  contentEditable: "plaintext-only",
1310
1423
  suppressContentEditableWarning: !0,
1311
- onInput: (l) => {
1312
- const i = l.currentTarget.innerText.replace(/[\n\s]+/g, " ").trim();
1313
- a(`rules.${s}.name`, i);
1424
+ onInput: (n) => {
1425
+ const o = n.currentTarget.innerText.replace(/[\n\s]+/g, " ").trim();
1426
+ t(`rules.${s}.name`, o);
1314
1427
  },
1315
- onKeyDown: (l) => {
1316
- l.key === "Enter" && (l.preventDefault(), l.currentTarget.blur());
1428
+ onKeyDown: (n) => {
1429
+ n.key === "Enter" && (n.preventDefault(), n.currentTarget.blur());
1317
1430
  },
1318
- onBlur: (l) => {
1319
- const n = l.currentTarget;
1320
- n.innerText = n.innerText.replace(/[\n\s]+/g, " ").trim();
1431
+ onBlur: (n) => {
1432
+ const r = n.currentTarget;
1433
+ r.innerText = r.innerText.replace(/[\n\s]+/g, " ").trim();
1321
1434
  },
1322
- children: r
1435
+ children: l
1323
1436
  },
1324
1437
  s
1325
1438
  );
1326
1439
  }
1327
- const U = {
1440
+ const W = {
1328
1441
  rules: []
1329
- }, $ = (a) => {
1442
+ }, k = (t) => {
1330
1443
  try {
1331
- return JSON.parse(a ?? JSON.stringify(U));
1444
+ return JSON.parse(t ?? JSON.stringify(W));
1332
1445
  } catch {
1333
- return U;
1446
+ return W;
1334
1447
  }
1335
- }, jt = (a) => {
1448
+ }, Aa = (t) => {
1336
1449
  try {
1337
- return JSON.parse(a ?? "{}"), !0;
1450
+ return JSON.parse(t ?? "{}"), !0;
1338
1451
  } catch {
1339
1452
  return !1;
1340
1453
  }
1341
1454
  };
1342
- function Et(a) {
1455
+ function Pa(t) {
1343
1456
  const {
1344
- settings: { domain: t }
1345
- } = W(), [s, r] = f([]), [o, l] = f(
1346
- $(a.value ?? a.defaultValue)
1457
+ settings: { domain: a }
1458
+ } = X(), [s, l] = f([]), [c, n] = f(
1459
+ k(t.value ?? t.defaultValue)
1347
1460
  );
1348
- return j(
1461
+ return T(
1349
1462
  function() {
1350
- o.rules.length === 0 && l($(a.value));
1463
+ c.rules?.length === 0 && n(k(t.value));
1351
1464
  },
1352
- [a.value]
1353
- ), j(
1465
+ [t.value]
1466
+ ), T(
1354
1467
  function() {
1355
- Qa(a.schemaType, t).then((i) => {
1356
- const u = y.object({
1468
+ ia(t.schemaType, a).then((o) => {
1469
+ const i = y.object({
1357
1470
  properties: y.object({
1358
1471
  rules: y.object({
1359
1472
  items: y.object({
@@ -1375,188 +1488,227 @@ function Et(a) {
1375
1488
  })
1376
1489
  })
1377
1490
  })
1378
- }).parse(i).properties.rules.items.properties.actions.items.anyOf.flatMap(
1491
+ }).parse(o).properties.rules.items.properties.actions.items.anyOf.flatMap(
1379
1492
  (d) => d.properties.type.enum
1380
1493
  );
1381
- r([...new Set(u)]);
1494
+ l([...new Set(i)]);
1382
1495
  });
1383
1496
  },
1384
- [t]
1497
+ [a]
1385
1498
  ), /* @__PURE__ */ e.jsx(
1386
- ot,
1499
+ ba,
1387
1500
  {
1388
1501
  initialValue: {
1389
- value: { rules: o.rules },
1390
- availableActionTypes: s
1502
+ value: { rules: c.rules },
1503
+ availableActionTypes: s,
1504
+ schemaType: t.schemaType
1391
1505
  },
1392
- children: /* @__PURE__ */ e.jsx(Tt, { ...a })
1506
+ children: /* @__PURE__ */ e.jsx(Ia, { ...t })
1393
1507
  }
1394
1508
  );
1395
1509
  }
1396
- function Tt(a) {
1510
+ function Ia(t) {
1397
1511
  const {
1398
- state: { value: t, selectedRuleIndex: s },
1399
- setSelectedRuleIndex: r,
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(
1512
+ state: { value: a, selectedRuleIndex: s },
1513
+ setSelectedRuleIndex: l,
1514
+ setValue: c,
1515
+ setPath: n
1516
+ } = b(), [r, o] = f(
1517
+ t.defaultCodeEditorVisible ?? !1
1518
+ ), u = a.rules?.[s], i = G(null), [d, m] = f(0);
1519
+ T(
1406
1520
  function() {
1407
- S($(u.current?.getValue()), t) || u.current?.setValue(JSON.stringify(t, null, 2)), a.onChange?.(t);
1521
+ V(k(i.current?.getValue()), a) || i.current?.setValue(JSON.stringify(a, null, 2)), t.onChange?.(a);
1408
1522
  },
1409
- [t]
1523
+ [a]
1410
1524
  );
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));
1525
+ const j = C(
1526
+ (h) => {
1527
+ const p = k(h);
1528
+ i.current?.hasTextFocus() && Aa(h) && !V(p, a) && (c(p), m((_) => _ + 1));
1415
1529
  },
1416
- [t]
1530
+ [a]
1417
1531
  );
1418
1532
  return /* @__PURE__ */ e.jsx(
1419
- et,
1533
+ oa,
1420
1534
  {
1421
- hint: a.hint,
1422
- feedback: a.feedback,
1535
+ hint: t.hint,
1536
+ feedback: t.feedback,
1423
1537
  className: "h-full [&>div:first-of-type]:h-full",
1424
1538
  children: /* @__PURE__ */ e.jsxs("section", { className: "flex h-full", children: [
1425
1539
  /* @__PURE__ */ e.jsxs(
1426
1540
  "div",
1427
1541
  {
1428
- className: `shrink-0 basis-3/5 overflow-x-auto relative flex flex-col ${n ? "" : "grow"}`,
1542
+ className: `shrink-0 basis-3/5 overflow-x-auto relative flex flex-col ${r ? "" : "grow"}`,
1429
1543
  children: [
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: [
1431
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-4 flex-wrap", children: [
1432
- t.rules.map((x, b) => {
1433
- const V = `#${(b + 1).toString().padStart(2, "0")}`;
1434
- return /* @__PURE__ */ e.jsx(
1435
- "button",
1544
+ /* @__PURE__ */ e.jsxs("header", { className: "w-full bg-white border-b border-gray-200 px-4 flex text-[13px] gap-4 text-gray-400 font-semibold items-center", children: [
1545
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center flex-wrap basis-full", children: [
1546
+ a.rules?.map((h, p, _) => {
1547
+ const ne = `#${(p + 1).toString().padStart(2, "0")}`;
1548
+ return /* @__PURE__ */ e.jsxs(
1549
+ "div",
1436
1550
  {
1437
- type: "button",
1438
- className: _("font-bold", {
1439
- "text-black": s === b
1440
- }),
1441
- onClick: () => {
1442
- r(b);
1443
- },
1444
- children: V
1551
+ className: "flex items-center py-3 pl-4 pr-2 border-r basis-[88px] justify-center",
1552
+ children: [
1553
+ /* @__PURE__ */ e.jsx(
1554
+ "button",
1555
+ {
1556
+ type: "button",
1557
+ className: A("font-bold mr-2", {
1558
+ "text-black": s === p
1559
+ }),
1560
+ onClick: () => {
1561
+ l(p);
1562
+ },
1563
+ children: ne
1564
+ }
1565
+ ),
1566
+ /* @__PURE__ */ e.jsx(
1567
+ I,
1568
+ {
1569
+ menuPosition: p === 0 ? "bottom-left" : "bottom-right",
1570
+ dropdownLabel: /* @__PURE__ */ e.jsx(N, { variant: "circle", children: /* @__PURE__ */ e.jsx(x, { name: "dotsThreeVertical", size: 16 }) }),
1571
+ dropdownItems: /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1572
+ /* @__PURE__ */ e.jsx(
1573
+ w,
1574
+ {
1575
+ onClick: () => {
1576
+ const Z = a.rules?.length ?? 0;
1577
+ n(`rules.${Z}`, {
1578
+ ...h,
1579
+ name: `${h.name} (copy)`
1580
+ }), l(Z);
1581
+ },
1582
+ label: "Duplicate"
1583
+ }
1584
+ ),
1585
+ /* @__PURE__ */ e.jsx(H, {}),
1586
+ /* @__PURE__ */ e.jsx(
1587
+ w,
1588
+ {
1589
+ disabled: _.length === 1,
1590
+ onClick: () => {
1591
+ n(`rules.${p}`, null), s >= p && l(s - 1);
1592
+ },
1593
+ label: "Delete"
1594
+ }
1595
+ )
1596
+ ] })
1597
+ }
1598
+ )
1599
+ ]
1445
1600
  },
1446
- `${s}-${x.id}`
1601
+ `${p}-${h.id}`
1447
1602
  );
1448
1603
  }),
1449
- /* @__PURE__ */ e.jsx(
1450
- "button",
1604
+ /* @__PURE__ */ e.jsx("div", { className: "min-h-[49px] flex items-center", children: /* @__PURE__ */ e.jsx(
1605
+ N,
1451
1606
  {
1452
- type: "button",
1453
- className: _("font-bold", {
1454
- "text-black": !0
1455
- }),
1607
+ variant: "circle",
1608
+ className: "mx-4",
1456
1609
  onClick: () => {
1457
- l(`rules.${t.rules.length}`, {
1610
+ n(`rules.${a.rules?.length ?? 0}`, {
1458
1611
  name: "Rule name",
1459
1612
  actions: [null],
1460
1613
  conditions: [null]
1461
- }), r(t.rules.length);
1614
+ }), l(a.rules?.length ?? 0);
1462
1615
  },
1463
- children: /* @__PURE__ */ e.jsx(h, { name: "plus", size: 16, className: "shrink-0" })
1616
+ children: /* @__PURE__ */ e.jsx(x, { name: "plus", size: 16, className: "shrink-0" })
1464
1617
  }
1465
- )
1618
+ ) })
1466
1619
  ] }),
1467
1620
  /* @__PURE__ */ e.jsx("div", { className: "grow flex justify-end", children: /* @__PURE__ */ e.jsx(
1468
- "button",
1621
+ N,
1469
1622
  {
1470
- type: "button",
1471
- className: "text-blue-600 hover:text-blue-700 focus:outline-hidden focus:ring-2 focus:ring-blue-500",
1623
+ variant: "circle",
1472
1624
  onClick: () => {
1473
- i(!n);
1625
+ o(!r);
1474
1626
  },
1475
- children: /* @__PURE__ */ e.jsx(h, { name: "sidebarSimple", size: 16, color: "#101111" })
1627
+ children: /* @__PURE__ */ e.jsx(x, { name: "sidebarSimple", size: 16 })
1476
1628
  }
1477
1629
  ) })
1478
1630
  ] }),
1479
- /* @__PURE__ */ e.jsxs(wt, { children: [
1631
+ /* @__PURE__ */ e.jsx(Da, { children: u && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1480
1632
  /* @__PURE__ */ e.jsxs("div", { className: "mb-8 flex items-center gap-2", children: [
1481
- /* @__PURE__ */ e.jsx(vt, {}),
1482
- /* @__PURE__ */ e.jsx(h, { name: "pencilSimple", size: 16, className: "shrink-0" })
1633
+ /* @__PURE__ */ e.jsx(Ra, {}),
1634
+ /* @__PURE__ */ e.jsx(x, { name: "pencilSimple", size: 16, className: "shrink-0" })
1483
1635
  ] }),
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: [
1636
+ /* @__PURE__ */ e.jsx(B, { title: "Actions", icon: "lightning", children: /* @__PURE__ */ e.jsx(Ta, { actions: u?.actions }) }),
1637
+ /* @__PURE__ */ e.jsx(Za, { children: "when" }),
1638
+ /* @__PURE__ */ e.jsxs(B, { title: "Conditions", icon: "treeView", children: [
1487
1639
  /* @__PURE__ */ e.jsx(
1488
- Q,
1640
+ se,
1489
1641
  {
1490
- item: c,
1642
+ item: u,
1491
1643
  pathPrefix: `rules.${s}`
1492
1644
  }
1493
1645
  ),
1494
1646
  /* @__PURE__ */ e.jsx("div", { className: "mt-6", children: /* @__PURE__ */ e.jsxs(
1495
- P,
1647
+ N,
1496
1648
  {
1497
1649
  size: "small",
1498
1650
  variant: "secondary",
1499
1651
  alignItems: "center",
1500
1652
  onClick: () => {
1501
- l(
1502
- `rules.${s}.conditions.${c?.conditions?.length ?? 0}`,
1653
+ n(
1654
+ `rules.${s}.conditions.${u?.conditions?.length ?? 0}`,
1503
1655
  void 0
1504
1656
  );
1505
1657
  },
1506
1658
  children: [
1507
- /* @__PURE__ */ e.jsx(h, { name: "plusCircle" }),
1659
+ /* @__PURE__ */ e.jsx(x, { name: "plusCircle" }),
1508
1660
  " Add condition"
1509
1661
  ]
1510
1662
  }
1511
1663
  ) })
1512
1664
  ] })
1513
- ] })
1665
+ ] }) })
1514
1666
  ]
1515
1667
  },
1516
1668
  d
1517
1669
  ),
1518
- n && /* @__PURE__ */ e.jsx("div", { className: "shrink-0 basis-2/5", children: /* @__PURE__ */ e.jsx(
1519
- at,
1670
+ r && /* @__PURE__ */ e.jsx("div", { className: "shrink-0 basis-2/5", children: /* @__PURE__ */ e.jsx(
1671
+ ca,
1520
1672
  {
1521
- ref: u,
1522
- name: a.id ?? a.name,
1673
+ ref: i,
1674
+ name: t.id ?? t.name,
1523
1675
  height: "100%",
1524
1676
  language: "json",
1525
- jsonSchema: a.schemaType,
1526
- defaultValue: JSON.stringify(t, null, 2),
1677
+ jsonSchema: t.schemaType,
1678
+ defaultValue: JSON.stringify(a, null, 2),
1527
1679
  noRounding: !0,
1528
- onChange: T
1680
+ onChange: j
1529
1681
  }
1530
1682
  ) })
1531
1683
  ] })
1532
1684
  }
1533
1685
  );
1534
1686
  }
1535
- function Nt({ children: a }) {
1687
+ function Za({ children: t }) {
1536
1688
  return /* @__PURE__ */ e.jsxs("div", { className: "text-gray-500 flex items-center justify-center flex-col", children: [
1537
1689
  /* @__PURE__ */ e.jsx("div", { className: "h-6 w-[2px] bg-gray-200" }),
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 }),
1690
+ /* @__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 }),
1539
1691
  /* @__PURE__ */ e.jsx("div", { className: "h-6 w-[2px] bg-gray-200" })
1540
1692
  ] });
1541
1693
  }
1542
- function J({
1543
- children: a,
1544
- title: t,
1694
+ function B({
1695
+ children: t,
1696
+ title: a,
1545
1697
  icon: s
1546
1698
  }) {
1547
1699
  return /* @__PURE__ */ e.jsxs("div", { className: "rounded-md bg-white shadow-xs", children: [
1548
1700
  /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-4 py-4 border-b border-gray-100", children: [
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 })
1701
+ /* @__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(x, { name: s }) }),
1702
+ /* @__PURE__ */ e.jsx("h2", { className: "text-lg font-semibold", children: a })
1551
1703
  ] }),
1552
- /* @__PURE__ */ e.jsx("div", { className: "p-6", children: a })
1704
+ /* @__PURE__ */ e.jsx("div", { className: "p-6", children: t })
1553
1705
  ] });
1554
1706
  }
1555
- function wt({
1556
- children: a
1707
+ function Da({
1708
+ children: t
1557
1709
  }) {
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 }) });
1710
+ 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 }) });
1559
1711
  }
1560
1712
  export {
1561
- Et as RuleEngine
1713
+ Pa as RuleEngine
1562
1714
  };