@inspirer-dev/crm-dashboard 1.0.10 → 1.0.12

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.
@@ -0,0 +1,377 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const React = require("react");
5
+ const designSystem = require("@strapi/design-system");
6
+ const icons = require("@strapi/icons");
7
+ const styled = require("styled-components");
8
+ const utils = require("./utils-CmonL0io.js");
9
+ const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
10
+ const React__default = /* @__PURE__ */ _interopDefault(React);
11
+ const ValueInput = ({ metric, value, operator, onChange, disabled }) => {
12
+ if (operator === "$exists") {
13
+ const boolVal = value === true || value === "true";
14
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", children: [
15
+ /* @__PURE__ */ jsxRuntime.jsx(
16
+ designSystem.Switch,
17
+ {
18
+ label: "",
19
+ selected: boolVal,
20
+ onChange: () => onChange(!boolVal),
21
+ disabled
22
+ }
23
+ ),
24
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral600", children: boolVal ? "exists" : "not exists" })
25
+ ] });
26
+ }
27
+ if (metric.valueType === "boolean") {
28
+ const boolVal = value === true || value === "true";
29
+ return /* @__PURE__ */ jsxRuntime.jsxs(
30
+ designSystem.SingleSelect,
31
+ {
32
+ value: boolVal ? "true" : "false",
33
+ onChange: (val) => onChange(val === "true"),
34
+ disabled,
35
+ size: "S",
36
+ children: [
37
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "true", children: "Yes" }),
38
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "false", children: "No" })
39
+ ]
40
+ }
41
+ );
42
+ }
43
+ if (metric.valueType === "time_ago") {
44
+ const { amount, unit } = utils.parseTimeAgoValue(value);
45
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", children: [
46
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { width: "80px" }, children: /* @__PURE__ */ jsxRuntime.jsx(
47
+ designSystem.TextInput,
48
+ {
49
+ type: "number",
50
+ value: String(amount),
51
+ onChange: (e) => {
52
+ const num = parseInt(e.target.value, 10) || 0;
53
+ onChange(utils.createTimeAgoValue(num, unit));
54
+ },
55
+ disabled,
56
+ size: "S",
57
+ "aria-label": "Time amount"
58
+ }
59
+ ) }),
60
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { width: "120px" }, children: /* @__PURE__ */ jsxRuntime.jsx(
61
+ designSystem.SingleSelect,
62
+ {
63
+ value: unit,
64
+ onChange: (val) => onChange(utils.createTimeAgoValue(amount, val)),
65
+ disabled,
66
+ size: "S",
67
+ children: utils.TIME_UNITS.map((u) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: u.value, children: u.label }, u.value))
68
+ }
69
+ ) })
70
+ ] });
71
+ }
72
+ if (metric.key === "lifecycle_stage") {
73
+ return /* @__PURE__ */ jsxRuntime.jsx(
74
+ designSystem.SingleSelect,
75
+ {
76
+ value: String(value || ""),
77
+ onChange: (val) => onChange(val),
78
+ disabled,
79
+ size: "S",
80
+ children: utils.LIFECYCLE_STAGES.map((stage) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: stage, children: stage.charAt(0).toUpperCase() + stage.slice(1) }, stage))
81
+ }
82
+ );
83
+ }
84
+ if (metric.valueType === "number") {
85
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { width: "120px" }, children: /* @__PURE__ */ jsxRuntime.jsx(
86
+ designSystem.TextInput,
87
+ {
88
+ type: "number",
89
+ value: String(value ?? ""),
90
+ onChange: (e) => {
91
+ const num = parseFloat(e.target.value);
92
+ onChange(isNaN(num) ? 0 : num);
93
+ },
94
+ disabled,
95
+ size: "S",
96
+ "aria-label": "Value"
97
+ }
98
+ ) });
99
+ }
100
+ if (operator === "$in" || operator === "$nin") {
101
+ const arrVal = Array.isArray(value) ? value.join(", ") : String(value || "");
102
+ return /* @__PURE__ */ jsxRuntime.jsx(
103
+ designSystem.TextInput,
104
+ {
105
+ value: arrVal,
106
+ onChange: (e) => {
107
+ const arr = e.target.value.split(",").map((s) => s.trim()).filter(Boolean);
108
+ onChange(arr);
109
+ },
110
+ placeholder: "value1, value2, ...",
111
+ disabled,
112
+ size: "S",
113
+ "aria-label": "Values"
114
+ }
115
+ );
116
+ }
117
+ return /* @__PURE__ */ jsxRuntime.jsx(
118
+ designSystem.TextInput,
119
+ {
120
+ value: String(value ?? ""),
121
+ onChange: (e) => onChange(e.target.value),
122
+ disabled,
123
+ size: "S",
124
+ "aria-label": "Value"
125
+ }
126
+ );
127
+ };
128
+ const RuleRow = ({ rule, onUpdate, onDelete, disabled }) => {
129
+ const theme = styled.useTheme();
130
+ const colors = theme?.colors;
131
+ const metric = utils.getMetricDefinition(rule.field);
132
+ const availableOperators = metric?.operators || utils.OPERATORS.map((o) => o.value);
133
+ const handleFieldChange = (fieldKey) => {
134
+ const newMetric = utils.getMetricDefinition(fieldKey);
135
+ let newValue = 0;
136
+ if (newMetric?.valueType === "boolean") {
137
+ newValue = false;
138
+ } else if (newMetric?.valueType === "time_ago") {
139
+ newValue = { hours_ago: 24 };
140
+ } else if (newMetric?.valueType === "string") {
141
+ newValue = "";
142
+ }
143
+ const newOp = newMetric?.operators[0] || "$eq";
144
+ onUpdate({ ...rule, field: fieldKey, operator: newOp, value: newValue });
145
+ };
146
+ const handleOperatorChange = (op) => {
147
+ let newValue = rule.value;
148
+ if (op === "$exists") {
149
+ newValue = true;
150
+ } else if ((op === "$in" || op === "$nin") && !Array.isArray(rule.value)) {
151
+ newValue = [];
152
+ }
153
+ onUpdate({ ...rule, operator: op, value: newValue });
154
+ };
155
+ return /* @__PURE__ */ jsxRuntime.jsxs(
156
+ designSystem.Flex,
157
+ {
158
+ gap: 2,
159
+ alignItems: "center",
160
+ padding: 2,
161
+ background: "neutral0",
162
+ hasRadius: true,
163
+ style: { border: `1px solid ${colors?.neutral200 || "#dcdce4"}` },
164
+ children: [
165
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flex: "1 1 200px", minWidth: "180px" }, children: /* @__PURE__ */ jsxRuntime.jsx(
166
+ designSystem.SingleSelect,
167
+ {
168
+ value: rule.field,
169
+ onChange: (val) => handleFieldChange(val),
170
+ disabled,
171
+ size: "S",
172
+ children: Object.entries(utils.METRICS_BY_CATEGORY).map(([category, metrics]) => /* @__PURE__ */ jsxRuntime.jsxs(React__default.default.Fragment, { children: [
173
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: `__header_${category}`, disabled: true, children: utils.CATEGORY_LABELS[category] || category }),
174
+ metrics.map((m) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: m.key, children: m.label }, m.key))
175
+ ] }, category))
176
+ }
177
+ ) }),
178
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { width: "100px" }, children: /* @__PURE__ */ jsxRuntime.jsx(
179
+ designSystem.SingleSelect,
180
+ {
181
+ value: rule.operator,
182
+ onChange: (val) => handleOperatorChange(val),
183
+ disabled,
184
+ size: "S",
185
+ children: utils.OPERATORS.filter((op) => availableOperators.includes(op.value)).map((op) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: op.value, children: op.label }, op.value))
186
+ }
187
+ ) }),
188
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { style: { flex: "1 1 150px", minWidth: "120px" }, children: metric && /* @__PURE__ */ jsxRuntime.jsx(
189
+ ValueInput,
190
+ {
191
+ metric,
192
+ value: rule.value,
193
+ operator: rule.operator,
194
+ onChange: (val) => onUpdate({ ...rule, value: val }),
195
+ disabled
196
+ }
197
+ ) }),
198
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tooltip, { label: "Delete rule", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.IconButton, { onClick: onDelete, label: "Delete rule", variant: "ghost", disabled, children: /* @__PURE__ */ jsxRuntime.jsx(icons.Trash, {}) }) })
199
+ ]
200
+ }
201
+ );
202
+ };
203
+ const RuleGroupComponent = ({
204
+ group,
205
+ onUpdate,
206
+ onDelete,
207
+ depth = 0,
208
+ disabled
209
+ }) => {
210
+ const theme = styled.useTheme();
211
+ const colors = theme?.colors;
212
+ const borderColors = {
213
+ 0: colors?.primary200 || "#d9d8ff",
214
+ 1: colors?.success200 || "#c6f0c2",
215
+ 2: colors?.warning200 || "#fae7b9",
216
+ 3: colors?.danger200 || "#f5c0b8"
217
+ };
218
+ const borderColor = borderColors[depth % 4] || borderColors[0];
219
+ const handleAddRule = () => {
220
+ onUpdate(utils.addRuleToGroup(group, group.id, utils.createEmptyRule()));
221
+ };
222
+ const handleAddGroup = () => {
223
+ const newLogic = group.logic === "$and" ? "$or" : "$and";
224
+ onUpdate(utils.addRuleToGroup(group, group.id, utils.createEmptyGroup(newLogic)));
225
+ };
226
+ const handleLogicToggle = () => {
227
+ onUpdate(utils.updateGroupLogic(group, group.id, group.logic === "$and" ? "$or" : "$and"));
228
+ };
229
+ const handleRuleUpdate = (ruleId, updatedRule) => {
230
+ onUpdate(utils.updateRuleInGroup(group, ruleId, () => updatedRule));
231
+ };
232
+ const handleRuleDelete = (ruleId) => {
233
+ onUpdate(utils.deleteRuleFromGroup(group, ruleId));
234
+ };
235
+ const handleNestedGroupUpdate = (nestedGroup) => {
236
+ onUpdate({
237
+ ...group,
238
+ rules: group.rules.map(
239
+ (item) => utils.isRuleGroup(item) && item.id === nestedGroup.id ? nestedGroup : item
240
+ )
241
+ });
242
+ };
243
+ const handleNestedGroupDelete = (groupId) => {
244
+ onUpdate(utils.deleteGroupFromParent(group, groupId));
245
+ };
246
+ return /* @__PURE__ */ jsxRuntime.jsxs(
247
+ designSystem.Box,
248
+ {
249
+ padding: 3,
250
+ background: depth === 0 ? "neutral100" : "neutral0",
251
+ hasRadius: true,
252
+ style: {
253
+ borderLeft: `3px solid ${borderColor}`,
254
+ marginLeft: depth > 0 ? "12px" : 0
255
+ },
256
+ children: [
257
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", marginBottom: 3, children: [
258
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", children: [
259
+ /* @__PURE__ */ jsxRuntime.jsx(
260
+ designSystem.Button,
261
+ {
262
+ variant: group.logic === "$and" ? "default" : "secondary",
263
+ size: "S",
264
+ onClick: handleLogicToggle,
265
+ disabled,
266
+ children: group.logic === "$and" ? "AND" : "OR"
267
+ }
268
+ ),
269
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: group.logic === "$and" ? "All conditions must match" : "Any condition can match" })
270
+ ] }),
271
+ depth > 0 && onDelete && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tooltip, { label: "Delete group", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.IconButton, { onClick: onDelete, label: "Delete group", variant: "ghost", disabled, children: /* @__PURE__ */ jsxRuntime.jsx(icons.Trash, {}) }) })
272
+ ] }),
273
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", gap: 2, children: group.rules.map((item, index) => {
274
+ if (utils.isRuleGroup(item)) {
275
+ return /* @__PURE__ */ jsxRuntime.jsx(
276
+ RuleGroupComponent,
277
+ {
278
+ group: item,
279
+ onUpdate: handleNestedGroupUpdate,
280
+ onDelete: () => handleNestedGroupDelete(item.id),
281
+ depth: depth + 1,
282
+ disabled
283
+ },
284
+ item.id
285
+ );
286
+ }
287
+ return /* @__PURE__ */ jsxRuntime.jsx(
288
+ RuleRow,
289
+ {
290
+ rule: item,
291
+ onUpdate: (updated) => handleRuleUpdate(item.id, updated),
292
+ onDelete: () => handleRuleDelete(item.id),
293
+ disabled
294
+ },
295
+ item.id
296
+ );
297
+ }) }),
298
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, marginTop: 3, children: [
299
+ /* @__PURE__ */ jsxRuntime.jsx(
300
+ designSystem.Button,
301
+ {
302
+ variant: "secondary",
303
+ size: "S",
304
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Plus, {}),
305
+ onClick: handleAddRule,
306
+ disabled,
307
+ children: "Add condition"
308
+ }
309
+ ),
310
+ depth < 2 && /* @__PURE__ */ jsxRuntime.jsxs(
311
+ designSystem.Button,
312
+ {
313
+ variant: "tertiary",
314
+ size: "S",
315
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Layout, {}),
316
+ onClick: handleAddGroup,
317
+ disabled,
318
+ children: [
319
+ "Add ",
320
+ group.logic === "$and" ? "OR" : "AND",
321
+ " group"
322
+ ]
323
+ }
324
+ )
325
+ ] })
326
+ ]
327
+ }
328
+ );
329
+ };
330
+ const RulesBuilder = React.forwardRef(
331
+ ({ name, value, onChange, intlLabel, disabled, error, required, hint }, ref) => {
332
+ const [config, setConfig] = React.useState(() => utils.deserializeConfig(value));
333
+ const displayLabel = React.useMemo(() => {
334
+ if (intlLabel?.defaultMessage && !intlLabel.defaultMessage.includes(".")) {
335
+ return intlLabel.defaultMessage;
336
+ }
337
+ return "Segment Rules";
338
+ }, [intlLabel]);
339
+ const rulesCount = React.useMemo(() => utils.countRules(config), [config]);
340
+ const handleConfigUpdate = React.useCallback(
341
+ (newConfig) => {
342
+ setConfig(newConfig);
343
+ onChange({ target: { name, value: utils.serializeConfig(newConfig) } });
344
+ },
345
+ [name, onChange]
346
+ );
347
+ const handleClear = () => {
348
+ handleConfigUpdate(utils.createInitialConfig());
349
+ };
350
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name, error, hint, required, children: [
351
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", children: [
352
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: displayLabel }),
353
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", children: [
354
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { children: [
355
+ rulesCount,
356
+ " rule",
357
+ rulesCount !== 1 ? "s" : ""
358
+ ] }),
359
+ rulesCount > 0 && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "ghost", size: "S", onClick: handleClear, disabled, children: "Clear all" })
360
+ ] })
361
+ ] }),
362
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 2, ref, children: /* @__PURE__ */ jsxRuntime.jsx(
363
+ RuleGroupComponent,
364
+ {
365
+ group: config,
366
+ onUpdate: handleConfigUpdate,
367
+ depth: 0,
368
+ disabled
369
+ }
370
+ ) }),
371
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {}),
372
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
373
+ ] });
374
+ }
375
+ );
376
+ RulesBuilder.displayName = "RulesBuilder";
377
+ exports.default = RulesBuilder;
@@ -0,0 +1,253 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useState, useEffect } from "react";
3
+ import { Field, Flex, Box, Typography, Card, CardContent, TextInput, SingleSelect, SingleSelectOption } from "@strapi/design-system";
4
+ const DEFAULT_CONFIG = {
5
+ type: "event_based",
6
+ eventName: "",
7
+ delayValue: 10,
8
+ delayUnit: "minutes",
9
+ scheduleType: "daily",
10
+ scheduleTime: "12:00",
11
+ scheduleDays: [1, 2, 3, 4, 5],
12
+ scheduleCron: "0 12 * * *"
13
+ };
14
+ const WEEKDAYS = [
15
+ { value: 0, label: "Sun" },
16
+ { value: 1, label: "Mon" },
17
+ { value: 2, label: "Tue" },
18
+ { value: 3, label: "Wed" },
19
+ { value: 4, label: "Thu" },
20
+ { value: 5, label: "Fri" },
21
+ { value: 6, label: "Sat" }
22
+ ];
23
+ const parseConfig = (value) => {
24
+ if (!value) return DEFAULT_CONFIG;
25
+ try {
26
+ const parsed = JSON.parse(value);
27
+ return {
28
+ type: parsed.type || "event_based",
29
+ eventName: parsed.eventName || "",
30
+ delayValue: parsed.delayValue ?? 10,
31
+ delayUnit: parsed.delayUnit || "minutes",
32
+ scheduleType: parsed.scheduleType || "daily",
33
+ scheduleTime: parsed.scheduleTime || "12:00",
34
+ scheduleDays: parsed.scheduleDays || [1, 2, 3, 4, 5],
35
+ scheduleCron: parsed.scheduleCron || "0 12 * * *"
36
+ };
37
+ } catch {
38
+ return DEFAULT_CONFIG;
39
+ }
40
+ };
41
+ const serializeConfig = (config) => {
42
+ return JSON.stringify(config);
43
+ };
44
+ const TriggerConfigField = forwardRef(
45
+ ({ name, value, onChange, intlLabel, disabled, error, required, hint }, ref) => {
46
+ const [config, setConfig] = useState(() => parseConfig(value));
47
+ useEffect(() => {
48
+ const parsed = parseConfig(value);
49
+ setConfig(parsed);
50
+ }, [value]);
51
+ const handleUpdate = (updates) => {
52
+ const newConfig = { ...config, ...updates };
53
+ setConfig(newConfig);
54
+ onChange({
55
+ target: {
56
+ name,
57
+ value: serializeConfig(newConfig)
58
+ }
59
+ });
60
+ };
61
+ const toggleDay = (day) => {
62
+ const days = config.scheduleDays || [];
63
+ const newDays = days.includes(day) ? days.filter((d) => d !== day) : [...days, day].sort((a, b) => a - b);
64
+ handleUpdate({ scheduleDays: newDays });
65
+ };
66
+ const isEventBased = config.type === "event_based";
67
+ const isDbBased = config.type === "db_based";
68
+ return /* @__PURE__ */ jsx(Field.Root, { name, error, required, hint, ref, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 3, children: [
69
+ /* @__PURE__ */ jsx(Field.Label, { children: intlLabel?.defaultMessage || "Trigger Configuration" }),
70
+ /* @__PURE__ */ jsxs(Box, { children: [
71
+ /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { marginBottom: "8px", display: "block" }, children: "Campaign Type" }),
72
+ /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
73
+ /* @__PURE__ */ jsxs(
74
+ Box,
75
+ {
76
+ padding: 3,
77
+ background: isEventBased ? "primary100" : "neutral100",
78
+ hasRadius: true,
79
+ style: {
80
+ cursor: disabled ? "not-allowed" : "pointer",
81
+ border: `2px solid ${isEventBased ? "#4945ff" : "#dcdce4"}`,
82
+ flex: 1,
83
+ textAlign: "center"
84
+ },
85
+ onClick: () => !disabled && handleUpdate({ type: "event_based" }),
86
+ children: [
87
+ /* @__PURE__ */ jsx(
88
+ Typography,
89
+ {
90
+ variant: "omega",
91
+ fontWeight: isEventBased ? "bold" : "regular",
92
+ textColor: isEventBased ? "primary600" : "neutral600",
93
+ children: "Event-Based"
94
+ }
95
+ ),
96
+ /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral500", children: "Fires on user action" })
97
+ ]
98
+ }
99
+ ),
100
+ /* @__PURE__ */ jsxs(
101
+ Box,
102
+ {
103
+ padding: 3,
104
+ background: isDbBased ? "primary100" : "neutral100",
105
+ hasRadius: true,
106
+ style: {
107
+ cursor: disabled ? "not-allowed" : "pointer",
108
+ border: `2px solid ${isDbBased ? "#4945ff" : "#dcdce4"}`,
109
+ flex: 1,
110
+ textAlign: "center"
111
+ },
112
+ onClick: () => !disabled && handleUpdate({ type: "db_based" }),
113
+ children: [
114
+ /* @__PURE__ */ jsx(
115
+ Typography,
116
+ {
117
+ variant: "omega",
118
+ fontWeight: isDbBased ? "bold" : "regular",
119
+ textColor: isDbBased ? "primary600" : "neutral600",
120
+ children: "DB-Based (Scheduled)"
121
+ }
122
+ ),
123
+ /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral500", children: "Runs on schedule" })
124
+ ]
125
+ }
126
+ )
127
+ ] })
128
+ ] }),
129
+ isEventBased && /* @__PURE__ */ jsx(Card, { background: "neutral100", children: /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 4, padding: 4, children: [
130
+ /* @__PURE__ */ jsx(Typography, { variant: "delta", children: "Event Configuration" }),
131
+ /* @__PURE__ */ jsxs(Field.Root, { name: `${name}-eventName`, children: [
132
+ /* @__PURE__ */ jsx(Field.Label, { children: "Event Name" }),
133
+ /* @__PURE__ */ jsx(
134
+ TextInput,
135
+ {
136
+ placeholder: "e.g., gg-case-deposit",
137
+ value: config.eventName || "",
138
+ onChange: (e) => handleUpdate({ eventName: e.target.value }),
139
+ disabled
140
+ }
141
+ ),
142
+ /* @__PURE__ */ jsx(Field.Hint, { children: "The event that triggers this campaign (e.g., gg-case-deposit, gg-deposit-suggestion-selected)" })
143
+ ] }),
144
+ /* @__PURE__ */ jsxs(Box, { children: [
145
+ /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral800", style: { marginBottom: "8px", display: "block" }, children: "Delay Before Sending" }),
146
+ /* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "flex-start", children: [
147
+ /* @__PURE__ */ jsx(Box, { style: { width: "120px" }, children: /* @__PURE__ */ jsx(
148
+ TextInput,
149
+ {
150
+ type: "number",
151
+ value: String(config.delayValue || 0),
152
+ onChange: (e) => handleUpdate({ delayValue: parseInt(e.target.value, 10) || 0 }),
153
+ disabled,
154
+ "aria-label": "Delay value"
155
+ }
156
+ ) }),
157
+ /* @__PURE__ */ jsx(Box, { style: { width: "150px" }, children: /* @__PURE__ */ jsxs(
158
+ SingleSelect,
159
+ {
160
+ value: config.delayUnit || "minutes",
161
+ onChange: (val) => handleUpdate({ delayUnit: val }),
162
+ disabled,
163
+ children: [
164
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "seconds", children: "seconds" }),
165
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "minutes", children: "minutes" }),
166
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "hours", children: "hours" })
167
+ ]
168
+ }
169
+ ) })
170
+ ] }),
171
+ /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral500", style: { marginTop: "4px" }, children: "Wait this long after the event before checking segment rules and sending" })
172
+ ] })
173
+ ] }) }) }),
174
+ isDbBased && /* @__PURE__ */ jsx(Card, { background: "neutral100", children: /* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 4, padding: 4, children: [
175
+ /* @__PURE__ */ jsx(Typography, { variant: "delta", children: "Schedule Configuration" }),
176
+ /* @__PURE__ */ jsxs(Field.Root, { name: `${name}-scheduleType`, children: [
177
+ /* @__PURE__ */ jsx(Field.Label, { children: "Schedule Type" }),
178
+ /* @__PURE__ */ jsxs(
179
+ SingleSelect,
180
+ {
181
+ value: config.scheduleType || "daily",
182
+ onChange: (val) => handleUpdate({ scheduleType: val }),
183
+ disabled,
184
+ children: [
185
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "daily", children: "Daily" }),
186
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "weekly", children: "Weekly" }),
187
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "cron", children: "Custom (Cron)" })
188
+ ]
189
+ }
190
+ )
191
+ ] }),
192
+ (config.scheduleType === "daily" || config.scheduleType === "weekly") && /* @__PURE__ */ jsxs(Field.Root, { name: `${name}-scheduleTime`, children: [
193
+ /* @__PURE__ */ jsx(Field.Label, { children: "Time of Day (UTC)" }),
194
+ /* @__PURE__ */ jsx(
195
+ TextInput,
196
+ {
197
+ type: "time",
198
+ value: config.scheduleTime || "12:00",
199
+ onChange: (e) => handleUpdate({ scheduleTime: e.target.value }),
200
+ disabled
201
+ }
202
+ )
203
+ ] }),
204
+ config.scheduleType === "weekly" && /* @__PURE__ */ jsxs(Box, { children: [
205
+ /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral800", style: { marginBottom: "8px", display: "block" }, children: "Days of Week" }),
206
+ /* @__PURE__ */ jsx(Flex, { gap: 2, wrap: "wrap", children: WEEKDAYS.map((day) => /* @__PURE__ */ jsx(
207
+ Box,
208
+ {
209
+ padding: 2,
210
+ background: (config.scheduleDays || []).includes(day.value) ? "primary100" : "neutral100",
211
+ hasRadius: true,
212
+ style: {
213
+ cursor: disabled ? "not-allowed" : "pointer",
214
+ border: `1px solid ${(config.scheduleDays || []).includes(day.value) ? "#4945ff" : "#dcdce4"}`,
215
+ minWidth: "50px",
216
+ textAlign: "center"
217
+ },
218
+ onClick: () => !disabled && toggleDay(day.value),
219
+ children: /* @__PURE__ */ jsx(
220
+ Typography,
221
+ {
222
+ variant: "omega",
223
+ textColor: (config.scheduleDays || []).includes(day.value) ? "primary600" : "neutral600",
224
+ children: day.label
225
+ }
226
+ )
227
+ },
228
+ day.value
229
+ )) })
230
+ ] }),
231
+ config.scheduleType === "cron" && /* @__PURE__ */ jsxs(Field.Root, { name: `${name}-scheduleCron`, children: [
232
+ /* @__PURE__ */ jsx(Field.Label, { children: "Cron Expression" }),
233
+ /* @__PURE__ */ jsx(
234
+ TextInput,
235
+ {
236
+ placeholder: "0 12 * * *",
237
+ value: config.scheduleCron || "",
238
+ onChange: (e) => handleUpdate({ scheduleCron: e.target.value }),
239
+ disabled
240
+ }
241
+ ),
242
+ /* @__PURE__ */ jsx(Field.Hint, { children: 'Standard cron format: minute hour day month weekday (e.g., "0 12 * * *" = daily at 12:00 UTC)' })
243
+ ] })
244
+ ] }) }) }),
245
+ error && /* @__PURE__ */ jsx(Field.Error, { children: error }),
246
+ hint && /* @__PURE__ */ jsx(Field.Hint, { children: hint })
247
+ ] }) });
248
+ }
249
+ );
250
+ TriggerConfigField.displayName = "TriggerConfigField";
251
+ export {
252
+ TriggerConfigField as default
253
+ };