@commercelayer/app-elements 6.1.2 → 6.2.0

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