@embedreach/components 0.3.43 → 0.3.44

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.
@@ -177,6 +177,21 @@ const Brain = createLucideIcon("Brain", [
177
177
  ["path", { d: "M6 18a4 4 0 0 1-1.967-.516", key: "2e4loj" }],
178
178
  ["path", { d: "M19.967 17.484A4 4 0 0 1 18 18", key: "159ez6" }]
179
179
  ]);
180
+ /**
181
+ * @license lucide-react v0.464.0 - ISC
182
+ *
183
+ * This source code is licensed under the ISC license.
184
+ * See the LICENSE file in the root directory of this source tree.
185
+ */
186
+ const Building2 = createLucideIcon("Building2", [
187
+ ["path", { d: "M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z", key: "1b4qmf" }],
188
+ ["path", { d: "M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2", key: "i71pzd" }],
189
+ ["path", { d: "M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2", key: "10jefs" }],
190
+ ["path", { d: "M10 6h4", key: "1itunk" }],
191
+ ["path", { d: "M10 10h4", key: "tcdvrf" }],
192
+ ["path", { d: "M10 14h4", key: "kelpxr" }],
193
+ ["path", { d: "M10 18h4", key: "1ulq68" }]
194
+ ]);
180
195
  /**
181
196
  * @license lucide-react v0.464.0 - ISC
182
197
  *
@@ -26730,24 +26745,25 @@ const useFeatureConfig = () => {
26730
26745
  const BrandColorsPreview = ({
26731
26746
  primaryColor = "var(--primary)",
26732
26747
  // secondaryColors = ['var(--secondary)', 'var(--accent)'],
26733
- hideLabel = false
26748
+ hideLabel = false,
26749
+ brandName,
26750
+ logoUrl
26734
26751
  }) => {
26735
26752
  const buttonColor = primaryColor;
26736
26753
  return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
26737
- !hideLabel && /* @__PURE__ */ jsx(FormLabel, { children: "This is how your brand colors will look on email" }),
26754
+ !hideLabel && /* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold", children: "Branding Preview" }),
26738
26755
  /* @__PURE__ */ jsx("div", { className: "bg-muted/50 p-6 rounded-lg w-full mx-auto border border-muted", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col bg-background items-center space-y-4 max-w-md border rounded-lg mx-auto pb-8 overflow-hidden", children: [
26739
- /* @__PURE__ */ jsx(
26740
- "div",
26741
- {
26742
- className: "h-20 w-full -mb-10 bg-secondary"
26743
- }
26744
- ),
26745
- /* @__PURE__ */ jsx(
26746
- "div",
26747
- {
26748
- className: "w-12 h-12 rounded-lg"
26749
- }
26750
- ),
26756
+ /* @__PURE__ */ jsx("div", { className: "w-full px-6 pt-6 pb-2", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
26757
+ /* @__PURE__ */ jsx("div", { className: "flex-shrink-0", children: logoUrl ? /* @__PURE__ */ jsx(
26758
+ "img",
26759
+ {
26760
+ src: logoUrl,
26761
+ alt: brandName || "Brand logo",
26762
+ className: "h-12 w-auto max-w-[80px] object-contain"
26763
+ }
26764
+ ) : /* @__PURE__ */ jsx("div", { className: "h-12 w-12 rounded bg-muted flex items-center justify-center", children: /* @__PURE__ */ jsx(Building2, { className: "h-6 w-6 text-muted-foreground" }) }) }),
26765
+ /* @__PURE__ */ jsx("div", { className: "flex-1 text-center", children: brandName ? /* @__PURE__ */ jsx("span", { className: "font-semibold text-lg text-foreground", children: brandName }) : /* @__PURE__ */ jsx("div", { className: "h-5 w-24 bg-muted rounded mx-auto" }) })
26766
+ ] }) }),
26751
26767
  /* @__PURE__ */ jsxs("div", { className: "w-full space-y-3 flex flex-col items-center px-8 pb-4 max-w-sm", children: [
26752
26768
  /* @__PURE__ */ jsx("div", { className: "h-2 rounded w-3/4 mx-auto bg-muted-foreground" }),
26753
26769
  /* @__PURE__ */ jsx("div", { className: "h-2 bg-muted rounded w-full" }),
@@ -39896,7 +39912,14 @@ const BrandSettingsForm = forwardRef(({ onSubmit, defaultValues }, ref) => {
39896
39912
  }
39897
39913
  )
39898
39914
  ] }) }),
39899
- /* @__PURE__ */ jsx(BrandColorsPreview, { primaryColor: form.watch("primaryColor") })
39915
+ /* @__PURE__ */ jsx(
39916
+ BrandColorsPreview,
39917
+ {
39918
+ primaryColor: form.watch("primaryColor"),
39919
+ brandName: form.watch("brandName"),
39920
+ logoUrl: imagePreview || void 0
39921
+ }
39922
+ )
39900
39923
  ]
39901
39924
  }
39902
39925
  ) })
@@ -55680,33 +55703,31 @@ const SMSChannelSettings = ({
55680
55703
  /* @__PURE__ */ jsx("span", { className: "w-2 h-2 bg-blue-500 rounded-full mr-2" }),
55681
55704
  "Ready to send"
55682
55705
  ] }),
55683
- /* @__PURE__ */ jsx("div", { className: "w-full flex flex-col gap-3 mx-auto", children: smsChannelSenders.map((sender) => {
55706
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center gap-3", children: smsChannelSenders.map((sender) => {
55684
55707
  const isPending = !!sender.channelSender.channelSenderMetadata.friendlyName?.toLowerCase().includes("pending approval");
55685
55708
  const displayName = sender.channelSender.channelSenderMetadata.friendlyName || sender.channelSender.channelSenderMetadata.from || "Unknown Number";
55686
- return /* @__PURE__ */ jsxs(
55709
+ return /* @__PURE__ */ jsx(
55687
55710
  "div",
55688
55711
  {
55689
55712
  className: cn$2(
55690
- "flex items-start rounded-xl px-4 py-3 border shadow-sm",
55713
+ "inline-flex items-center justify-center rounded-full px-5 py-2.5 border shadow-sm",
55691
55714
  isPending ? "bg-gray-50 border-gray-200 text-gray-500" : "bg-blue-50 border-blue-200 text-blue-900 font-semibold"
55692
55715
  ),
55693
- children: [
55694
- /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3 flex-1 min-w-0", children: [
55695
- isPending ? /* @__PURE__ */ jsx(IconDefinitions.AlertCircleIcon, { className: "w-5 h-5 text-yellow-500 shrink-0 mt-0.5" }) : /* @__PURE__ */ jsx(IconDefinitions.CheckIcon, { className: "w-5 h-5 text-blue-500 shrink-0 mt-0.5" }),
55696
- /* @__PURE__ */ jsx(
55697
- "span",
55698
- {
55699
- className: cn$2(
55700
- "text-sm leading-relaxed",
55701
- isPending ? "break-words" : "truncate"
55702
- ),
55703
- title: displayName,
55704
- children: displayName
55705
- }
55706
- )
55707
- ] }),
55716
+ children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
55717
+ isPending ? /* @__PURE__ */ jsx(IconDefinitions.AlertCircleIcon, { className: "w-5 h-5 text-yellow-500 shrink-0" }) : /* @__PURE__ */ jsx(IconDefinitions.CheckIcon, { className: "w-5 h-5 text-blue-500 shrink-0" }),
55718
+ /* @__PURE__ */ jsx(
55719
+ "span",
55720
+ {
55721
+ className: cn$2(
55722
+ "text-sm leading-relaxed",
55723
+ isPending ? "break-words" : ""
55724
+ ),
55725
+ title: displayName,
55726
+ children: displayName
55727
+ }
55728
+ ),
55708
55729
  !isPending && sender.channelSender.channelSenderMetadata.from && sender.channelSender.channelSenderMetadata.friendlyName !== sender.channelSender.channelSenderMetadata.from && /* @__PURE__ */ jsx("span", { className: "font-mono text-xs text-blue-700 ml-2 shrink-0", children: sender.channelSender.channelSenderMetadata.from })
55709
- ]
55730
+ ] })
55710
55731
  },
55711
55732
  sender.channelSender.id
55712
55733
  );
@@ -86570,6 +86591,363 @@ const previewSegmentRecipients = async (params) => {
86570
86591
  pagination: result2.data.pagination
86571
86592
  };
86572
86593
  };
86594
+ var SegmentDefinitionsStatusEnum;
86595
+ (function(SegmentDefinitionsStatusEnum2) {
86596
+ SegmentDefinitionsStatusEnum2["ACTIVE"] = "active";
86597
+ SegmentDefinitionsStatusEnum2["DEACTIVATED"] = "deactivated";
86598
+ })(SegmentDefinitionsStatusEnum || (SegmentDefinitionsStatusEnum = {}));
86599
+ var SegmentDefinitionTypeEnum;
86600
+ (function(SegmentDefinitionTypeEnum2) {
86601
+ SegmentDefinitionTypeEnum2["ALL_USERS"] = "all_users";
86602
+ SegmentDefinitionTypeEnum2["MANAGED"] = "managed";
86603
+ SegmentDefinitionTypeEnum2["CUSTOM"] = "custom";
86604
+ SegmentDefinitionTypeEnum2["ONE_OFF"] = "one_off";
86605
+ SegmentDefinitionTypeEnum2["SQL"] = "sql";
86606
+ })(SegmentDefinitionTypeEnum || (SegmentDefinitionTypeEnum = {}));
86607
+ const segmentKeys = {
86608
+ all: ["segments"],
86609
+ lists: (params) => [
86610
+ ...segmentKeys.all,
86611
+ "list",
86612
+ ...params?.cursor ? [params.cursor] : [],
86613
+ ...params?.limit ? [params.limit] : [],
86614
+ ...params?.search ? [params.search] : []
86615
+ ],
86616
+ detail: (id2) => [...segmentKeys.all, id2]
86617
+ };
86618
+ const useSegment = () => {
86619
+ const queryClient = useQueryClient();
86620
+ const createMutation = useMutation({
86621
+ mutationFn: (params) => createSegment(params),
86622
+ onSuccess: () => {
86623
+ queryClient.invalidateQueries({ queryKey: ["segments"] });
86624
+ }
86625
+ });
86626
+ const segmentsConditionsQuery = useQuery({
86627
+ queryKey: ["segments-conditions"],
86628
+ queryFn: () => getSegmentConditions()
86629
+ });
86630
+ return {
86631
+ // Create segment mutation
86632
+ createSegment: createMutation.mutate,
86633
+ createSegmentAsync: createMutation.mutateAsync,
86634
+ isCreating: createMutation.isPending,
86635
+ createError: createMutation.error,
86636
+ isCreateSuccess: createMutation.isSuccess,
86637
+ // Fetch segments query
86638
+ segmentsConditions: segmentsConditionsQuery.data,
86639
+ isFetching: segmentsConditionsQuery.isFetching,
86640
+ isLoading: segmentsConditionsQuery.isLoading,
86641
+ fetchError: segmentsConditionsQuery.error,
86642
+ refetchSegmentsConditions: segmentsConditionsQuery.refetch
86643
+ };
86644
+ };
86645
+ const useListSegments = (params) => {
86646
+ const query = useQuery({
86647
+ queryKey: segmentKeys.lists(params),
86648
+ queryFn: () => getSegments(params),
86649
+ // placeholderData: keepPreviousData is a powerful feature from TanStack Query.
86650
+ // What it does:
86651
+ // 1. When new data is being fetched for a query (e.g., due to a queryKey change like a new cursor),
86652
+ // TanStack Query will continue to show the data from the previous successful fetch (the "placeholder" data)
86653
+ // until the new data arrives.
86654
+ // 2. While this placeholder data is being shown, `isPlaceholderData` will be true.
86655
+ // 3. `isLoading` will only be true if there's no data at all (initial fetch or hard refresh with no cache).
86656
+ // It will be false if placeholder data is being shown, even though a new fetch is in progress (`isFetching` will be true).
86657
+ // This provides a much smoother UX, as the UI doesn't jump to a loading state on pagination or filter changes
86658
+ // if previous data is available to show in the meantime.
86659
+ placeholderData: keepPreviousData,
86660
+ ...CACHE_STANDARD
86661
+ });
86662
+ return {
86663
+ segments: query.data?.results ?? [],
86664
+ // The cursor to be used to fetch the *next* page of results.
86665
+ // Null or undefined if there are no more pages.
86666
+ nextCursor: query.data?.pagination.cursor ?? null,
86667
+ // Total count of items for pagination display
86668
+ totalCount: query.data?.pagination.total ?? null,
86669
+ isLoading: query.isLoading,
86670
+ error: query.error,
86671
+ isFetching: query.isFetching,
86672
+ // isPlaceholderData is true when the data currently displayed is from a previous query key,
86673
+ // and new data for the current query key is being fetched.
86674
+ isPlaceholderData: query.isPlaceholderData
86675
+ };
86676
+ };
86677
+ const useGetCountOfBusinessAutomationRecipients = (args) => {
86678
+ const queryClient = useQueryClient();
86679
+ const getCountOfBusinessAutomationRecipientsQuery = useQuery({
86680
+ queryKey: automationKeys.recipients(
86681
+ args.automationId,
86682
+ args.includeSegments,
86683
+ args.excludeSegments
86684
+ ),
86685
+ queryFn: () => getCountOfBusinessAutomationRecipients(args)
86686
+ });
86687
+ return {
86688
+ data: getCountOfBusinessAutomationRecipientsQuery.data,
86689
+ isFetching: getCountOfBusinessAutomationRecipientsQuery.isFetching,
86690
+ isLoading: getCountOfBusinessAutomationRecipientsQuery.isLoading,
86691
+ fetchError: getCountOfBusinessAutomationRecipientsQuery.error,
86692
+ refetchCount: () => {
86693
+ queryClient.invalidateQueries({
86694
+ queryKey: automationKeys.recipients(
86695
+ args.automationId,
86696
+ args.includeSegments,
86697
+ args.excludeSegments
86698
+ )
86699
+ });
86700
+ }
86701
+ };
86702
+ };
86703
+ const useGetCountOfBusinessAutomationRecipientsDebounced = (includeSegments, excludeSegments, automationId, options) => {
86704
+ const [debouncedIncludeSegments, setDebouncedIncludeSegments] = useState(includeSegments);
86705
+ const [debouncedExcludeSegments, setDebouncedExcludeSegments] = useState(excludeSegments);
86706
+ const [debouncedSearch, setDebouncedSearch] = useState(options?.search || "");
86707
+ const [accumulatedRecipients, setAccumulatedRecipients] = useState([]);
86708
+ const [currentCursor, setCurrentCursor] = useState(
86709
+ options?.cursor
86710
+ );
86711
+ const includeSegmentsKey = JSON.stringify(debouncedIncludeSegments);
86712
+ const excludeSegmentsKey = JSON.stringify(debouncedExcludeSegments);
86713
+ useEffect(() => {
86714
+ setAccumulatedRecipients([]);
86715
+ setCurrentCursor(void 0);
86716
+ }, [
86717
+ includeSegmentsKey,
86718
+ excludeSegmentsKey,
86719
+ debouncedSearch,
86720
+ options?.filter
86721
+ ]);
86722
+ useEffect(() => {
86723
+ const timer = setTimeout(() => {
86724
+ setDebouncedIncludeSegments(includeSegments);
86725
+ setDebouncedExcludeSegments(excludeSegments);
86726
+ }, options?.debounceMs ?? 500);
86727
+ return () => clearTimeout(timer);
86728
+ }, [includeSegments, excludeSegments, options?.debounceMs]);
86729
+ useEffect(() => {
86730
+ const timer = setTimeout(() => {
86731
+ setDebouncedSearch(options?.search || "");
86732
+ }, 150);
86733
+ return () => clearTimeout(timer);
86734
+ }, [options?.search]);
86735
+ const filter2 = options?.filter ?? "all";
86736
+ const query = useQuery({
86737
+ queryKey: [
86738
+ ...automationKeys.recipients(
86739
+ automationId,
86740
+ debouncedIncludeSegments,
86741
+ debouncedExcludeSegments,
86742
+ debouncedSearch
86743
+ ),
86744
+ filter2,
86745
+ currentCursor || "initial",
86746
+ options?.limit ?? 100
86747
+ ],
86748
+ queryFn: () => getCountOfBusinessAutomationRecipients({
86749
+ includeSegments: debouncedIncludeSegments,
86750
+ excludeSegments: debouncedExcludeSegments,
86751
+ automationId,
86752
+ search: debouncedSearch || void 0,
86753
+ limit: options?.limit ?? 100,
86754
+ filter: filter2,
86755
+ cursor: currentCursor
86756
+ }),
86757
+ enabled: (options?.enabled ?? true) && !!automationId,
86758
+ staleTime: 0,
86759
+ // Always refetch when query key changes (including filter changes)
86760
+ placeholderData: keepPreviousData
86761
+ // Keep previous data while fetching
86762
+ });
86763
+ useEffect(() => {
86764
+ if (query.data?.recipients) {
86765
+ if (currentCursor) {
86766
+ setAccumulatedRecipients((prev) => [...prev, ...query.data.recipients]);
86767
+ } else {
86768
+ setAccumulatedRecipients(query.data.recipients);
86769
+ }
86770
+ }
86771
+ }, [query.data, currentCursor]);
86772
+ const handleLoadMore = () => {
86773
+ if (query.data?.pagination.hasNextPage && query.data.pagination.cursor && !query.isFetching) {
86774
+ setCurrentCursor(query.data.pagination.cursor);
86775
+ options?.onLoadMore?.(query.data.pagination.cursor);
86776
+ }
86777
+ };
86778
+ return {
86779
+ data: query.data ? {
86780
+ ...query.data,
86781
+ recipients: accumulatedRecipients
86782
+ } : void 0,
86783
+ isLoading: query.isLoading && accumulatedRecipients.length === 0,
86784
+ isFetching: query.isFetching,
86785
+ error: query.error,
86786
+ refetch: query.refetch,
86787
+ hasMore: query.data?.pagination.hasNextPage ?? false,
86788
+ loadMore: handleLoadMore
86789
+ };
86790
+ };
86791
+ const useGetSegment = (segmentId) => {
86792
+ const segmentQuery = useQuery({
86793
+ queryKey: segmentKeys.detail(segmentId),
86794
+ queryFn: () => getSegment(segmentId),
86795
+ ...CACHE_STANDARD,
86796
+ enabled: !!segmentId
86797
+ });
86798
+ return {
86799
+ segment: segmentQuery.data,
86800
+ isFetching: segmentQuery.isFetching,
86801
+ isLoading: segmentQuery.isLoading
86802
+ };
86803
+ };
86804
+ const useUpdateSegment = (segmentId) => {
86805
+ const queryClient = useQueryClient();
86806
+ const updateSegmentMutation = useMutation({
86807
+ mutationFn: (params) => {
86808
+ if (!segmentId) {
86809
+ throw new Error("Segment ID is required");
86810
+ }
86811
+ return updateSegment(segmentId, params);
86812
+ },
86813
+ onSuccess: () => {
86814
+ queryClient.invalidateQueries({ queryKey: segmentKeys.all });
86815
+ }
86816
+ });
86817
+ return {
86818
+ updateSegment: updateSegmentMutation.mutate,
86819
+ updateSegmentAsync: updateSegmentMutation.mutateAsync,
86820
+ isUpdating: updateSegmentMutation.isPending,
86821
+ updateError: updateSegmentMutation.error,
86822
+ isUpdateSuccess: updateSegmentMutation.isSuccess
86823
+ };
86824
+ };
86825
+ const useUpdateSegmentDynamic = () => {
86826
+ const queryClient = useQueryClient();
86827
+ const updateSegmentMutation = useMutation({
86828
+ mutationFn: ({
86829
+ segmentId,
86830
+ params
86831
+ }) => {
86832
+ return updateSegment(segmentId, params);
86833
+ },
86834
+ onSuccess: () => {
86835
+ queryClient.invalidateQueries({ queryKey: segmentKeys.all });
86836
+ }
86837
+ });
86838
+ return {
86839
+ updateSegmentAsync: updateSegmentMutation.mutateAsync,
86840
+ isUpdating: updateSegmentMutation.isPending,
86841
+ updateError: updateSegmentMutation.error,
86842
+ isUpdateSuccess: updateSegmentMutation.isSuccess
86843
+ };
86844
+ };
86845
+ const useDeleteSegment = (segmentId) => {
86846
+ const queryClient = useQueryClient();
86847
+ const deleteSegmentMutation = useMutation({
86848
+ mutationFn: () => {
86849
+ if (!segmentId) {
86850
+ throw new Error("Segment ID is required");
86851
+ }
86852
+ return deleteSegment(segmentId);
86853
+ },
86854
+ onSuccess: () => {
86855
+ queryClient.invalidateQueries({ queryKey: segmentKeys.all });
86856
+ }
86857
+ });
86858
+ return {
86859
+ deleteSegment: deleteSegmentMutation.mutate,
86860
+ isDeleting: deleteSegmentMutation.isPending,
86861
+ deleteError: deleteSegmentMutation.error,
86862
+ isDeleteSuccess: deleteSegmentMutation.isSuccess
86863
+ };
86864
+ };
86865
+ const useParseDate = () => {
86866
+ const parseDateMutation = useMutation({
86867
+ mutationFn: (params) => parseDate(params)
86868
+ });
86869
+ return {
86870
+ parseDate: parseDateMutation.mutate,
86871
+ isParsing: parseDateMutation.isPending,
86872
+ parseError: parseDateMutation.error,
86873
+ isParseSuccess: parseDateMutation.isSuccess,
86874
+ parseResult: parseDateMutation.data
86875
+ };
86876
+ };
86877
+ const usePreviewSegmentRecipients = (type, conditions, businessId, options, existingSegmentConditions) => {
86878
+ const [debouncedConditions, setDebouncedConditions] = useState(conditions);
86879
+ const [debouncedSearch, setDebouncedSearch] = useState(options?.search || "");
86880
+ useEffect(() => {
86881
+ const timer = setTimeout(() => {
86882
+ setDebouncedConditions(conditions);
86883
+ }, options?.debounceMs);
86884
+ return () => clearTimeout(timer);
86885
+ }, [conditions, options?.debounceMs]);
86886
+ useEffect(() => {
86887
+ const timer = setTimeout(() => {
86888
+ setDebouncedSearch(options?.search || "");
86889
+ }, 600);
86890
+ return () => clearTimeout(timer);
86891
+ }, [options?.search]);
86892
+ const areConditionsValid = (conditions2, type2) => {
86893
+ if (type2 === SegmentDefinitionTypeEnum.SQL) {
86894
+ return true;
86895
+ }
86896
+ if (conditions2.length === 0) {
86897
+ return false;
86898
+ }
86899
+ const isValid2 = conditions2.every((condition) => {
86900
+ if (!condition.field || !condition.operator) {
86901
+ return false;
86902
+ }
86903
+ if (condition.operator !== "exists" && condition.operator !== "not_exists" && (!condition.value || condition.value.length === 0)) {
86904
+ return false;
86905
+ }
86906
+ return true;
86907
+ });
86908
+ return isValid2;
86909
+ };
86910
+ const conditionsKey = JSON.stringify(debouncedConditions);
86911
+ const existingConditionsKey = JSON.stringify(existingSegmentConditions || []);
86912
+ const query = useQuery({
86913
+ queryKey: [
86914
+ "preview-segment-recipients",
86915
+ businessId,
86916
+ type,
86917
+ conditionsKey,
86918
+ existingConditionsKey,
86919
+ debouncedSearch || "",
86920
+ options?.limit ?? 100
86921
+ ],
86922
+ queryFn: () => {
86923
+ return previewSegmentRecipients({
86924
+ businessId,
86925
+ // If the segment is a SQL segment, use the existing segment conditions
86926
+ conditions: type === SegmentDefinitionTypeEnum.SQL && existingSegmentConditions ? existingSegmentConditions : debouncedConditions,
86927
+ limit: options?.limit ?? 100,
86928
+ search: debouncedSearch || void 0
86929
+ });
86930
+ },
86931
+ enabled: (options?.enabled ?? true) && areConditionsValid(debouncedConditions, type),
86932
+ staleTime: 3e4,
86933
+ // 30 seconds
86934
+ gcTime: 5 * 60 * 1e3,
86935
+ // 5 minutes - keep in cache longer
86936
+ placeholderData: keepPreviousData,
86937
+ // Keep previous data while fetching to prevent re-renders
86938
+ refetchOnWindowFocus: false,
86939
+ // Don't refetch on window focus
86940
+ refetchOnMount: false
86941
+ // Don't refetch on mount if data exists
86942
+ });
86943
+ return {
86944
+ data: query.data,
86945
+ isLoading: query.isLoading,
86946
+ isFetching: query.isFetching,
86947
+ error: query.error,
86948
+ refetch: query.refetch
86949
+ };
86950
+ };
86573
86951
  var DateUnit;
86574
86952
  (function(DateUnit2) {
86575
86953
  DateUnit2["DAYS"] = "days";
@@ -86911,451 +87289,6 @@ z$2.object({
86911
87289
  customSchema: z$2.array(customEventSchema).optional(),
86912
87290
  locationsSchema: z$2.array(locationSourceSchema).optional()
86913
87291
  });
86914
- var BusinessSegmentTypeEnum;
86915
- (function(BusinessSegmentTypeEnum2) {
86916
- BusinessSegmentTypeEnum2["ALL_USERS"] = "all_users";
86917
- BusinessSegmentTypeEnum2["MANAGED"] = "managed";
86918
- BusinessSegmentTypeEnum2["CUSTOM"] = "custom";
86919
- BusinessSegmentTypeEnum2["ONE_OFF"] = "one_off";
86920
- BusinessSegmentTypeEnum2["SQL"] = "sql";
86921
- })(BusinessSegmentTypeEnum || (BusinessSegmentTypeEnum = {}));
86922
- z$2.object({
86923
- name: z$2.string().describe("A friendly name for the segment"),
86924
- description: z$2.string().describe("A friendly description for the segment").optional(),
86925
- conditions: z$2.array(ConditionSchema).describe("The conditions to include in the segment"),
86926
- type: z$2.enum([BusinessSegmentTypeEnum.CUSTOM, BusinessSegmentTypeEnum.ONE_OFF]).describe("The type of segment").default(BusinessSegmentTypeEnum.CUSTOM).optional()
86927
- });
86928
- z$2.object({
86929
- id: z$2.string().describe("The id of the segment"),
86930
- name: z$2.string().describe("A friendly name for the segment"),
86931
- description: z$2.string().describe("A friendly description for the segment").optional(),
86932
- createdAt: z$2.date().nullable().describe("The date and time the segment was created"),
86933
- type: z$2.nativeEnum(BusinessSegmentTypeEnum).describe("The type of segment")
86934
- });
86935
- z$2.object({
86936
- name: z$2.string().optional().describe("A friendly name for the segment"),
86937
- description: z$2.string().optional().describe("A friendly description for the segment"),
86938
- conditions: z$2.array(ConditionSchema).optional().describe("The conditions to include in the segment")
86939
- });
86940
- z$2.object({
86941
- id: z$2.string().describe("The id of the segment"),
86942
- name: z$2.string().describe("A friendly name for the segment"),
86943
- description: z$2.string().describe("A friendly description for the segment").optional(),
86944
- createdAt: z$2.date().nullable().describe("The date and time the segment was created"),
86945
- type: z$2.nativeEnum(BusinessSegmentTypeEnum).describe("The type of segment")
86946
- });
86947
- z$2.object({
86948
- results: z$2.array(z$2.object({
86949
- id: z$2.string().describe("The id of the segment"),
86950
- name: z$2.string().describe("A friendly name for the segment"),
86951
- description: z$2.string().describe("A friendly description for the segment").optional(),
86952
- createdAt: z$2.date().nullable().describe("The date and time the segment was created"),
86953
- type: z$2.nativeEnum(BusinessSegmentTypeEnum).describe("The type of segment"),
86954
- userCount: z$2.number().describe("The number of users in the segment"),
86955
- phoneCount: z$2.number().describe("The number of phone numbers in the segment"),
86956
- emailCount: z$2.number().describe("The number of emails in the segment"),
86957
- userCountUpdatedAt: z$2.date().describe("The date and time the user count was updated")
86958
- })).describe("The segments"),
86959
- pagination: z$2.object({
86960
- hasNextPage: z$2.boolean().nullable().describe("Whether there is a next page"),
86961
- cursor: z$2.string().nullable().describe("The cursor to start from"),
86962
- total: z$2.number().nullable().describe("The total number of segments")
86963
- })
86964
- });
86965
- z$2.object({
86966
- id: z$2.string().describe("The id of the segment"),
86967
- name: z$2.string().describe("A friendly name for the segment"),
86968
- description: z$2.string().describe("A friendly description for the segment").optional(),
86969
- createdAt: z$2.date().nullable().describe("The date and time the segment was created"),
86970
- type: z$2.nativeEnum(BusinessSegmentTypeEnum).describe("The type of segment"),
86971
- conditions: z$2.array(ConditionSchema).describe("The conditions to include in the segment")
86972
- });
86973
- z$2.object({
86974
- conditions: z$2.array(z$2.object({
86975
- field: z$2.string().describe("The field to include in the segment"),
86976
- operators: z$2.array(ConditionOperatorEnum).describe("The operators to include in the segment"),
86977
- type: z$2.nativeEnum(JSONSchemaType).describe("The type of segment"),
86978
- itemType: z$2.nativeEnum(JSONSchemaType).optional().describe("If the type is an array, this is the type of the items"),
86979
- options: z$2.array(z$2.object({
86980
- displayName: z$2.string().describe("The display name of the option"),
86981
- id: z$2.string().describe("The id of the option")
86982
- })).optional().describe("The options to include in the segment"),
86983
- description: z$2.string().optional().describe("The description of the condition")
86984
- })).describe("The conditions to include in the segment")
86985
- });
86986
- z$2.object({
86987
- count: z$2.number().describe("The number of users in the segment"),
86988
- recipients: z$2.array(z$2.object({
86989
- firstName: z$2.string().nullable().describe("The first name of the recipient"),
86990
- lastName: z$2.string().nullable().describe("The last name of the recipient"),
86991
- email: z$2.string().nullable().describe("The email of the recipient"),
86992
- phone: z$2.string().nullable().describe("The phone of the recipient"),
86993
- id: z$2.string().nullable().describe("The reach id of the recipient"),
86994
- externalId: z$2.string().nullable().describe("The external id of the recipient"),
86995
- emailOptedOut: z$2.boolean().optional().describe("Whether the user has opted out of email"),
86996
- smsOptedOut: z$2.boolean().optional().describe("Whether the user has opted out of SMS")
86997
- })).describe("The recipients in the segment (paginated)"),
86998
- pagination: z$2.object({
86999
- hasNextPage: z$2.boolean().describe("Whether there are more pages"),
87000
- cursor: z$2.string().nullable().describe("Cursor for the next page (null if no more pages)")
87001
- }).describe("Pagination metadata")
87002
- });
87003
- z$2.object({
87004
- success: z$2.boolean().describe("Whether the text to segment was successful"),
87005
- failureReason: z$2.string().optional().describe("The reason the text to segment was not successful."),
87006
- conditions: z$2.array(ConditionSchema).optional().describe("The conditions to include in the segment. If the text to segment was not successful, this will be null"),
87007
- title: z$2.string().optional().describe("A suggested title for the segment generated by AI"),
87008
- description: z$2.string().optional().describe("A suggested description for the segment generated by AI")
87009
- });
87010
- z$2.object({
87011
- cursor: z$2.string().optional().describe("The cursor to start from"),
87012
- limit: z$2.coerce.number().optional().describe("The limit of items to return, default is 100"),
87013
- search: z$2.string().optional().describe("The search query to filter by segment name")
87014
- });
87015
- const segmentKeys = {
87016
- all: ["segments"],
87017
- lists: (params) => [
87018
- ...segmentKeys.all,
87019
- "list",
87020
- ...params?.cursor ? [params.cursor] : [],
87021
- ...params?.limit ? [params.limit] : [],
87022
- ...params?.search ? [params.search] : []
87023
- ],
87024
- detail: (id2) => [...segmentKeys.all, id2]
87025
- };
87026
- const useSegment = () => {
87027
- const queryClient = useQueryClient();
87028
- const createMutation = useMutation({
87029
- mutationFn: (params) => createSegment(params),
87030
- onSuccess: () => {
87031
- queryClient.invalidateQueries({ queryKey: ["segments"] });
87032
- }
87033
- });
87034
- const segmentsConditionsQuery = useQuery({
87035
- queryKey: ["segments-conditions"],
87036
- queryFn: () => getSegmentConditions()
87037
- });
87038
- return {
87039
- // Create segment mutation
87040
- createSegment: createMutation.mutate,
87041
- createSegmentAsync: createMutation.mutateAsync,
87042
- isCreating: createMutation.isPending,
87043
- createError: createMutation.error,
87044
- isCreateSuccess: createMutation.isSuccess,
87045
- // Fetch segments query
87046
- segmentsConditions: segmentsConditionsQuery.data,
87047
- isFetching: segmentsConditionsQuery.isFetching,
87048
- isLoading: segmentsConditionsQuery.isLoading,
87049
- fetchError: segmentsConditionsQuery.error,
87050
- refetchSegmentsConditions: segmentsConditionsQuery.refetch
87051
- };
87052
- };
87053
- const useListSegments = (params) => {
87054
- const query = useQuery({
87055
- queryKey: segmentKeys.lists(params),
87056
- queryFn: () => getSegments(params),
87057
- // placeholderData: keepPreviousData is a powerful feature from TanStack Query.
87058
- // What it does:
87059
- // 1. When new data is being fetched for a query (e.g., due to a queryKey change like a new cursor),
87060
- // TanStack Query will continue to show the data from the previous successful fetch (the "placeholder" data)
87061
- // until the new data arrives.
87062
- // 2. While this placeholder data is being shown, `isPlaceholderData` will be true.
87063
- // 3. `isLoading` will only be true if there's no data at all (initial fetch or hard refresh with no cache).
87064
- // It will be false if placeholder data is being shown, even though a new fetch is in progress (`isFetching` will be true).
87065
- // This provides a much smoother UX, as the UI doesn't jump to a loading state on pagination or filter changes
87066
- // if previous data is available to show in the meantime.
87067
- placeholderData: keepPreviousData,
87068
- ...CACHE_STANDARD
87069
- });
87070
- return {
87071
- segments: query.data?.results ?? [],
87072
- // The cursor to be used to fetch the *next* page of results.
87073
- // Null or undefined if there are no more pages.
87074
- nextCursor: query.data?.pagination.cursor ?? null,
87075
- // Total count of items for pagination display
87076
- totalCount: query.data?.pagination.total ?? null,
87077
- isLoading: query.isLoading,
87078
- error: query.error,
87079
- isFetching: query.isFetching,
87080
- // isPlaceholderData is true when the data currently displayed is from a previous query key,
87081
- // and new data for the current query key is being fetched.
87082
- isPlaceholderData: query.isPlaceholderData
87083
- };
87084
- };
87085
- const useGetCountOfBusinessAutomationRecipients = (args) => {
87086
- const queryClient = useQueryClient();
87087
- const getCountOfBusinessAutomationRecipientsQuery = useQuery({
87088
- queryKey: automationKeys.recipients(
87089
- args.automationId,
87090
- args.includeSegments,
87091
- args.excludeSegments
87092
- ),
87093
- queryFn: () => getCountOfBusinessAutomationRecipients(args)
87094
- });
87095
- return {
87096
- data: getCountOfBusinessAutomationRecipientsQuery.data,
87097
- isFetching: getCountOfBusinessAutomationRecipientsQuery.isFetching,
87098
- isLoading: getCountOfBusinessAutomationRecipientsQuery.isLoading,
87099
- fetchError: getCountOfBusinessAutomationRecipientsQuery.error,
87100
- refetchCount: () => {
87101
- queryClient.invalidateQueries({
87102
- queryKey: automationKeys.recipients(
87103
- args.automationId,
87104
- args.includeSegments,
87105
- args.excludeSegments
87106
- )
87107
- });
87108
- }
87109
- };
87110
- };
87111
- const useGetCountOfBusinessAutomationRecipientsDebounced = (includeSegments, excludeSegments, automationId, options) => {
87112
- const [debouncedIncludeSegments, setDebouncedIncludeSegments] = useState(includeSegments);
87113
- const [debouncedExcludeSegments, setDebouncedExcludeSegments] = useState(excludeSegments);
87114
- const [debouncedSearch, setDebouncedSearch] = useState(options?.search || "");
87115
- const [accumulatedRecipients, setAccumulatedRecipients] = useState([]);
87116
- const [currentCursor, setCurrentCursor] = useState(
87117
- options?.cursor
87118
- );
87119
- const includeSegmentsKey = JSON.stringify(debouncedIncludeSegments);
87120
- const excludeSegmentsKey = JSON.stringify(debouncedExcludeSegments);
87121
- useEffect(() => {
87122
- setAccumulatedRecipients([]);
87123
- setCurrentCursor(void 0);
87124
- }, [
87125
- includeSegmentsKey,
87126
- excludeSegmentsKey,
87127
- debouncedSearch,
87128
- options?.filter
87129
- ]);
87130
- useEffect(() => {
87131
- const timer = setTimeout(() => {
87132
- setDebouncedIncludeSegments(includeSegments);
87133
- setDebouncedExcludeSegments(excludeSegments);
87134
- }, options?.debounceMs ?? 500);
87135
- return () => clearTimeout(timer);
87136
- }, [includeSegments, excludeSegments, options?.debounceMs]);
87137
- useEffect(() => {
87138
- const timer = setTimeout(() => {
87139
- setDebouncedSearch(options?.search || "");
87140
- }, 150);
87141
- return () => clearTimeout(timer);
87142
- }, [options?.search]);
87143
- const filter2 = options?.filter ?? "all";
87144
- const query = useQuery({
87145
- queryKey: [
87146
- ...automationKeys.recipients(
87147
- automationId,
87148
- debouncedIncludeSegments,
87149
- debouncedExcludeSegments,
87150
- debouncedSearch
87151
- ),
87152
- filter2,
87153
- currentCursor || "initial",
87154
- options?.limit ?? 100
87155
- ],
87156
- queryFn: () => getCountOfBusinessAutomationRecipients({
87157
- includeSegments: debouncedIncludeSegments,
87158
- excludeSegments: debouncedExcludeSegments,
87159
- automationId,
87160
- search: debouncedSearch || void 0,
87161
- limit: options?.limit ?? 100,
87162
- filter: filter2,
87163
- cursor: currentCursor
87164
- }),
87165
- enabled: (options?.enabled ?? true) && !!automationId,
87166
- staleTime: 0,
87167
- // Always refetch when query key changes (including filter changes)
87168
- placeholderData: keepPreviousData
87169
- // Keep previous data while fetching
87170
- });
87171
- useEffect(() => {
87172
- if (query.data?.recipients) {
87173
- if (currentCursor) {
87174
- setAccumulatedRecipients((prev) => [...prev, ...query.data.recipients]);
87175
- } else {
87176
- setAccumulatedRecipients(query.data.recipients);
87177
- }
87178
- }
87179
- }, [query.data, currentCursor]);
87180
- const handleLoadMore = () => {
87181
- if (query.data?.pagination.hasNextPage && query.data.pagination.cursor && !query.isFetching) {
87182
- setCurrentCursor(query.data.pagination.cursor);
87183
- options?.onLoadMore?.(query.data.pagination.cursor);
87184
- }
87185
- };
87186
- return {
87187
- data: query.data ? {
87188
- ...query.data,
87189
- recipients: accumulatedRecipients
87190
- } : void 0,
87191
- isLoading: query.isLoading && accumulatedRecipients.length === 0,
87192
- isFetching: query.isFetching,
87193
- error: query.error,
87194
- refetch: query.refetch,
87195
- hasMore: query.data?.pagination.hasNextPage ?? false,
87196
- loadMore: handleLoadMore
87197
- };
87198
- };
87199
- const useGetSegment = (segmentId) => {
87200
- const segmentQuery = useQuery({
87201
- queryKey: segmentKeys.detail(segmentId),
87202
- queryFn: () => getSegment(segmentId),
87203
- ...CACHE_STANDARD,
87204
- enabled: !!segmentId
87205
- });
87206
- return {
87207
- segment: segmentQuery.data,
87208
- isFetching: segmentQuery.isFetching,
87209
- isLoading: segmentQuery.isLoading
87210
- };
87211
- };
87212
- const useUpdateSegment = (segmentId) => {
87213
- const queryClient = useQueryClient();
87214
- const updateSegmentMutation = useMutation({
87215
- mutationFn: (params) => {
87216
- if (!segmentId) {
87217
- throw new Error("Segment ID is required");
87218
- }
87219
- return updateSegment(segmentId, params);
87220
- },
87221
- onSuccess: () => {
87222
- queryClient.invalidateQueries({ queryKey: segmentKeys.all });
87223
- }
87224
- });
87225
- return {
87226
- updateSegment: updateSegmentMutation.mutate,
87227
- updateSegmentAsync: updateSegmentMutation.mutateAsync,
87228
- isUpdating: updateSegmentMutation.isPending,
87229
- updateError: updateSegmentMutation.error,
87230
- isUpdateSuccess: updateSegmentMutation.isSuccess
87231
- };
87232
- };
87233
- const useUpdateSegmentDynamic = () => {
87234
- const queryClient = useQueryClient();
87235
- const updateSegmentMutation = useMutation({
87236
- mutationFn: ({
87237
- segmentId,
87238
- params
87239
- }) => {
87240
- return updateSegment(segmentId, params);
87241
- },
87242
- onSuccess: () => {
87243
- queryClient.invalidateQueries({ queryKey: segmentKeys.all });
87244
- }
87245
- });
87246
- return {
87247
- updateSegmentAsync: updateSegmentMutation.mutateAsync,
87248
- isUpdating: updateSegmentMutation.isPending,
87249
- updateError: updateSegmentMutation.error,
87250
- isUpdateSuccess: updateSegmentMutation.isSuccess
87251
- };
87252
- };
87253
- const useDeleteSegment = (segmentId) => {
87254
- const queryClient = useQueryClient();
87255
- const deleteSegmentMutation = useMutation({
87256
- mutationFn: () => {
87257
- if (!segmentId) {
87258
- throw new Error("Segment ID is required");
87259
- }
87260
- return deleteSegment(segmentId);
87261
- },
87262
- onSuccess: () => {
87263
- queryClient.invalidateQueries({ queryKey: segmentKeys.all });
87264
- }
87265
- });
87266
- return {
87267
- deleteSegment: deleteSegmentMutation.mutate,
87268
- isDeleting: deleteSegmentMutation.isPending,
87269
- deleteError: deleteSegmentMutation.error,
87270
- isDeleteSuccess: deleteSegmentMutation.isSuccess
87271
- };
87272
- };
87273
- const useParseDate = () => {
87274
- const parseDateMutation = useMutation({
87275
- mutationFn: (params) => parseDate(params)
87276
- });
87277
- return {
87278
- parseDate: parseDateMutation.mutate,
87279
- isParsing: parseDateMutation.isPending,
87280
- parseError: parseDateMutation.error,
87281
- isParseSuccess: parseDateMutation.isSuccess,
87282
- parseResult: parseDateMutation.data
87283
- };
87284
- };
87285
- const usePreviewSegmentRecipients = (type, conditions, businessId, options, existingSegmentConditions) => {
87286
- const [debouncedConditions, setDebouncedConditions] = useState(conditions);
87287
- const [debouncedSearch, setDebouncedSearch] = useState(options?.search || "");
87288
- useEffect(() => {
87289
- const timer = setTimeout(() => {
87290
- setDebouncedConditions(conditions);
87291
- }, options?.debounceMs);
87292
- return () => clearTimeout(timer);
87293
- }, [conditions, options?.debounceMs]);
87294
- useEffect(() => {
87295
- const timer = setTimeout(() => {
87296
- setDebouncedSearch(options?.search || "");
87297
- }, 600);
87298
- return () => clearTimeout(timer);
87299
- }, [options?.search]);
87300
- const areConditionsValid = (conditions2, type2) => {
87301
- if (type2 === BusinessSegmentTypeEnum.SQL) {
87302
- return true;
87303
- }
87304
- if (conditions2.length === 0) {
87305
- return false;
87306
- }
87307
- const isValid2 = conditions2.every((condition) => {
87308
- if (!condition.field || !condition.operator) {
87309
- return false;
87310
- }
87311
- if (condition.operator !== "exists" && condition.operator !== "not_exists" && (!condition.value || condition.value.length === 0)) {
87312
- return false;
87313
- }
87314
- return true;
87315
- });
87316
- return isValid2;
87317
- };
87318
- const conditionsKey = JSON.stringify(debouncedConditions);
87319
- const existingConditionsKey = JSON.stringify(existingSegmentConditions || []);
87320
- const query = useQuery({
87321
- queryKey: [
87322
- "preview-segment-recipients",
87323
- businessId,
87324
- type,
87325
- conditionsKey,
87326
- existingConditionsKey,
87327
- debouncedSearch || "",
87328
- options?.limit ?? 100
87329
- ],
87330
- queryFn: () => {
87331
- return previewSegmentRecipients({
87332
- businessId,
87333
- // If the segment is a SQL segment, use the existing segment conditions
87334
- conditions: type === BusinessSegmentTypeEnum.SQL && existingSegmentConditions ? existingSegmentConditions : debouncedConditions,
87335
- limit: options?.limit ?? 100,
87336
- search: debouncedSearch || void 0
87337
- });
87338
- },
87339
- enabled: (options?.enabled ?? true) && areConditionsValid(debouncedConditions, type),
87340
- staleTime: 3e4,
87341
- // 30 seconds
87342
- gcTime: 5 * 60 * 1e3,
87343
- // 5 minutes - keep in cache longer
87344
- placeholderData: keepPreviousData,
87345
- // Keep previous data while fetching to prevent re-renders
87346
- refetchOnWindowFocus: false,
87347
- // Don't refetch on window focus
87348
- refetchOnMount: false
87349
- // Don't refetch on mount if data exists
87350
- });
87351
- return {
87352
- data: query.data,
87353
- isLoading: query.isLoading,
87354
- isFetching: query.isFetching,
87355
- error: query.error,
87356
- refetch: query.refetch
87357
- };
87358
- };
87359
87292
  const useRecipientStats$1 = (automation2) => {
87360
87293
  const { data: estimatedMatches } = useGetCountOfBusinessAutomationRecipients({
87361
87294
  includeSegments: automation2?.includeSegmentIds ?? [],
@@ -94503,33 +94436,33 @@ const getAutomationStatusVariant = (status) => {
94503
94436
  };
94504
94437
  const getTypeDescription = (type) => {
94505
94438
  switch (type) {
94506
- case BusinessSegmentTypeEnum.ALL_USERS:
94439
+ case SegmentDefinitionTypeEnum.ALL_USERS:
94507
94440
  return `Default ${t$2("engage:segment").toLowerCase()} that contains all ${t$2("engage:user", { count: 2 }).toLowerCase()}. This is not editable or deletable.`;
94508
- case BusinessSegmentTypeEnum.MANAGED:
94441
+ case SegmentDefinitionTypeEnum.MANAGED:
94509
94442
  return `System-defined ${t$2("engage:segment").toLowerCase()} that are not editable or deletable.`;
94510
- case BusinessSegmentTypeEnum.CUSTOM:
94443
+ case SegmentDefinitionTypeEnum.CUSTOM:
94511
94444
  return `Custom ${t$2("engage:segment").toLowerCase()} that you can edit and delete as needed.`;
94512
- case BusinessSegmentTypeEnum.SQL:
94445
+ case SegmentDefinitionTypeEnum.SQL:
94513
94446
  return `SQL-defined ${t$2("engage:segment").toLowerCase()} that are not editable or deletable.`;
94514
- case BusinessSegmentTypeEnum.ONE_OFF:
94447
+ case SegmentDefinitionTypeEnum.ONE_OFF:
94515
94448
  return `One-off ${t$2("engage:segment").toLowerCase()} that are not editable or deletable.`;
94516
94449
  default:
94517
- throw UnreachableCaseStatement(type, BusinessSegmentTypeEnum);
94450
+ throw UnreachableCaseStatement(type, SegmentDefinitionTypeEnum);
94518
94451
  }
94519
94452
  };
94520
94453
  const getSegmentTypeVariant = (type) => {
94521
94454
  switch (type) {
94522
- case BusinessSegmentTypeEnum.ALL_USERS:
94455
+ case SegmentDefinitionTypeEnum.ALL_USERS:
94523
94456
  return "segmentAllUsers";
94524
- case BusinessSegmentTypeEnum.MANAGED:
94457
+ case SegmentDefinitionTypeEnum.MANAGED:
94525
94458
  return "segmentManaged";
94526
- case BusinessSegmentTypeEnum.CUSTOM:
94459
+ case SegmentDefinitionTypeEnum.CUSTOM:
94527
94460
  return "segmentCustom";
94528
- case BusinessSegmentTypeEnum.ONE_OFF:
94529
- case BusinessSegmentTypeEnum.SQL:
94461
+ case SegmentDefinitionTypeEnum.ONE_OFF:
94462
+ case SegmentDefinitionTypeEnum.SQL:
94530
94463
  return "segmentManaged";
94531
94464
  default:
94532
- throw UnreachableCaseStatement(type, BusinessSegmentTypeEnum);
94465
+ throw UnreachableCaseStatement(type, SegmentDefinitionTypeEnum);
94533
94466
  }
94534
94467
  };
94535
94468
  function createNameColumn(nameAccessor = "name", headerText, showDescription = false) {
@@ -94562,12 +94495,12 @@ function createNameColumn(nameAccessor = "name", headerText, showDescription = f
94562
94495
  [AutomationStatus.ARCHIVED]: "bg-gray-500"
94563
94496
  };
94564
94497
  const typeDotStyles = {
94565
- [BusinessSegmentTypeEnum.ALL_USERS]: "bg-purple-500",
94566
- [BusinessSegmentTypeEnum.MANAGED]: "bg-teal-500",
94567
- [BusinessSegmentTypeEnum.CUSTOM]: "bg-amber-500",
94568
- [BusinessSegmentTypeEnum.SQL]: "bg-teal-500",
94498
+ [SegmentDefinitionTypeEnum.ALL_USERS]: "bg-purple-500",
94499
+ [SegmentDefinitionTypeEnum.MANAGED]: "bg-teal-500",
94500
+ [SegmentDefinitionTypeEnum.CUSTOM]: "bg-amber-500",
94501
+ [SegmentDefinitionTypeEnum.SQL]: "bg-teal-500",
94569
94502
  // Same as managed
94570
- [BusinessSegmentTypeEnum.ONE_OFF]: "bg-orange-500"
94503
+ [SegmentDefinitionTypeEnum.ONE_OFF]: "bg-orange-500"
94571
94504
  };
94572
94505
  const dotColor = type ? typeDotStyles[type] : status ? badgeStyles[status] : "bg-blue-500";
94573
94506
  return /* @__PURE__ */ jsx("div", { className: "w-full flex gap-2 sm:gap-4 md:gap-6 justify-between items-center", children: /* @__PURE__ */ jsxs("div", { className: "flex gap-1 items-center w-full min-w-0", children: [
@@ -94621,15 +94554,15 @@ function createTypeColumn() {
94621
94554
  cellClassName: "pr-2 sm:pr-3 md:pr-4",
94622
94555
  cellFormatter: (info) => {
94623
94556
  const typeFromCell = info.getValue();
94624
- const displayText = typeFromCell ? typeFromCell === BusinessSegmentTypeEnum.SQL ? "Managed" : typeFromCell.split("_").map((word) => word[0].toUpperCase() + word.slice(1).toLowerCase()).join(" ") : "Unknown";
94557
+ const displayText = typeFromCell ? typeFromCell === SegmentDefinitionTypeEnum.SQL ? "Managed" : typeFromCell.split("_").map((word) => word[0].toUpperCase() + word.slice(1).toLowerCase()).join(" ") : "Unknown";
94625
94558
  let badgeVariant;
94626
- if (typeFromCell && (typeFromCell === BusinessSegmentTypeEnum.ALL_USERS || typeFromCell === BusinessSegmentTypeEnum.MANAGED || typeFromCell === BusinessSegmentTypeEnum.CUSTOM || typeFromCell === BusinessSegmentTypeEnum.SQL)) {
94559
+ if (typeFromCell && (typeFromCell === SegmentDefinitionTypeEnum.ALL_USERS || typeFromCell === SegmentDefinitionTypeEnum.MANAGED || typeFromCell === SegmentDefinitionTypeEnum.CUSTOM || typeFromCell === SegmentDefinitionTypeEnum.SQL)) {
94627
94560
  try {
94628
94561
  badgeVariant = getSegmentTypeVariant(typeFromCell);
94629
94562
  } catch (e4) {
94630
94563
  if (e4 instanceof UnreachableCaseStatement) {
94631
94564
  console.error(
94632
- `Unhandled BusinessSegmentTypeEnum member in getSegmentTypeVariant: ${typeFromCell}`,
94565
+ `Unhandled SegmentDefinitionTypeEnum member in getSegmentTypeVariant: ${typeFromCell}`,
94633
94566
  e4
94634
94567
  );
94635
94568
  badgeVariant = "statusDraft";
@@ -94846,6 +94779,57 @@ function createColumns(args) {
94846
94779
  ];
94847
94780
  }
94848
94781
  const DEFAULT_LOGO_URL = "https://assets.embedreach.com/defaults/logo-placeholder-128.png";
94782
+ var ChannelType = /* @__PURE__ */ ((ChannelType2) => {
94783
+ ChannelType2["EMAIL"] = "email";
94784
+ ChannelType2["SMS"] = "sms";
94785
+ return ChannelType2;
94786
+ })(ChannelType || {});
94787
+ var CommunicationSubStepType$1 = /* @__PURE__ */ ((CommunicationSubStepType2) => {
94788
+ CommunicationSubStepType2["EMAIL"] = "email";
94789
+ CommunicationSubStepType2["SMS"] = "sms";
94790
+ return CommunicationSubStepType2;
94791
+ })(CommunicationSubStepType$1 || {});
94792
+ const capitalize = (str) => {
94793
+ if (!str) return str;
94794
+ return str.charAt(0).toUpperCase() + str.slice(1);
94795
+ };
94796
+ const getDisplayName = (recipient, fallbackText = "Unnamed User") => {
94797
+ const fullName = `${recipient.firstName || ""} ${recipient.lastName || ""}`.trim();
94798
+ if (fullName) return fullName;
94799
+ if (recipient.firstName) return recipient.firstName;
94800
+ if (recipient.lastName) return recipient.lastName;
94801
+ if (recipient.email) return recipient.email;
94802
+ if (recipient.phone) return recipient.phone;
94803
+ return fallbackText;
94804
+ };
94805
+ const RECIPIENT_SEARCH_PLACEHOLDER = `Search by name, email, or phone...`;
94806
+ const getMergeFieldsFromUrl = (url, getMergeFields2) => {
94807
+ if (!url || !getMergeFields2) return [];
94808
+ const regex = /\{\{([^}]+)\}\}/g;
94809
+ const matches2 = [...url.matchAll(regex)];
94810
+ return matches2.map((match2) => {
94811
+ const mergeFieldValue = match2[1];
94812
+ const mergeField = getMergeFields2.mergeFields?.flatMap((f2) => f2.entries).find((entry) => entry.value === `{{${mergeFieldValue}}}`);
94813
+ return mergeField ? mergeField.label : mergeFieldValue;
94814
+ }).filter(Boolean);
94815
+ };
94816
+ const convertScheduledAtToScheduleSendAt = (scheduledAt) => {
94817
+ if (scheduledAt === null || scheduledAt === void 0) {
94818
+ return null;
94819
+ }
94820
+ if (scheduledAt === "now") {
94821
+ return (/* @__PURE__ */ new Date()).toISOString();
94822
+ }
94823
+ return scheduledAt;
94824
+ };
94825
+ const getScheduleSendAtFromAutomation = (automation2) => {
94826
+ if (automation2?.triggerMetadata && automation2.triggerMetadata.triggerType === AutomationTriggerType.ONE_TIME && "scheduledAt" in automation2.triggerMetadata) {
94827
+ return convertScheduledAtToScheduleSendAt(
94828
+ automation2.triggerMetadata.scheduledAt
94829
+ );
94830
+ }
94831
+ return null;
94832
+ };
94849
94833
  const BackNextButtonGroup = ({
94850
94834
  handleBack,
94851
94835
  handleNext,
@@ -95455,27 +95439,17 @@ var BuiltInActionIds = /* @__PURE__ */ ((BuiltInActionIds2) => {
95455
95439
  BuiltInActionIds2["EditTime"] = "edit-time";
95456
95440
  return BuiltInActionIds2;
95457
95441
  })(BuiltInActionIds || {});
95458
- var CommunicationSubStepType$1 = /* @__PURE__ */ ((CommunicationSubStepType2) => {
95442
+ var CommunicationSubStepType = /* @__PURE__ */ ((CommunicationSubStepType2) => {
95459
95443
  CommunicationSubStepType2["EMAIL"] = "email";
95460
95444
  CommunicationSubStepType2["SMS"] = "sms";
95461
95445
  return CommunicationSubStepType2;
95462
- })(CommunicationSubStepType$1 || {});
95446
+ })(CommunicationSubStepType || {});
95463
95447
  var AutomationTabs = /* @__PURE__ */ ((AutomationTabs2) => {
95464
95448
  AutomationTabs2["WORKFLOW"] = "workflow";
95465
95449
  AutomationTabs2["RECIPIENTS"] = "recipients";
95466
95450
  AutomationTabs2["INSIGHTS"] = "insights";
95467
95451
  return AutomationTabs2;
95468
95452
  })(AutomationTabs || {});
95469
- var ChannelType = /* @__PURE__ */ ((ChannelType2) => {
95470
- ChannelType2["EMAIL"] = "email";
95471
- ChannelType2["SMS"] = "sms";
95472
- return ChannelType2;
95473
- })(ChannelType || {});
95474
- var CommunicationSubStepType = /* @__PURE__ */ ((CommunicationSubStepType2) => {
95475
- CommunicationSubStepType2["EMAIL"] = "email";
95476
- CommunicationSubStepType2["SMS"] = "sms";
95477
- return CommunicationSubStepType2;
95478
- })(CommunicationSubStepType || {});
95479
95453
  const DEFAULT_EMAIL_PREVIEW_HEIGHT = 400;
95480
95454
  const SMS_LIMITS = {
95481
95455
  ABSOLUTE_LIMIT: 1500,
@@ -96017,7 +95991,7 @@ const SendPreviewPopup = ({ type, setOpenSendPreviewPopup, open }) => {
96017
95991
  setIsLoadingUsers(true);
96018
95992
  try {
96019
95993
  const allUsersSegment = segments.find(
96020
- (segment2) => segment2.type === BusinessSegmentTypeEnum.ALL_USERS
95994
+ (segment2) => segment2.type === SegmentDefinitionTypeEnum.ALL_USERS
96021
95995
  );
96022
95996
  if (allUsersSegment) {
96023
95997
  const searchResponse = await getCountOfBusinessAutomationRecipients({
@@ -117090,30 +117064,6 @@ const extractMergeFieldNamesUtil = (text2) => {
117090
117064
  if (!matches2) return [];
117091
117065
  return matches2.map((match2) => match2.slice(2, -2));
117092
117066
  };
117093
- const capitalize = (str) => {
117094
- if (!str) return str;
117095
- return str.charAt(0).toUpperCase() + str.slice(1);
117096
- };
117097
- const getDisplayName = (recipient, fallbackText = "Unnamed User") => {
117098
- const fullName = `${recipient.firstName || ""} ${recipient.lastName || ""}`.trim();
117099
- if (fullName) return fullName;
117100
- if (recipient.firstName) return recipient.firstName;
117101
- if (recipient.lastName) return recipient.lastName;
117102
- if (recipient.email) return recipient.email;
117103
- if (recipient.phone) return recipient.phone;
117104
- return fallbackText;
117105
- };
117106
- const RECIPIENT_SEARCH_PLACEHOLDER = `Search by name, email, or phone...`;
117107
- const getMergeFieldsFromUrl = (url, getMergeFields2) => {
117108
- if (!url || !getMergeFields2) return [];
117109
- const regex = /\{\{([^}]+)\}\}/g;
117110
- const matches2 = [...url.matchAll(regex)];
117111
- return matches2.map((match2) => {
117112
- const mergeFieldValue = match2[1];
117113
- const mergeField = getMergeFields2.mergeFields?.flatMap((f2) => f2.entries).find((entry) => entry.value === `{{${mergeFieldValue}}}`);
117114
- return mergeField ? mergeField.label : mergeFieldValue;
117115
- }).filter(Boolean);
117116
- };
117117
117067
  const convertToHtml = (text2, mergeFields, variant) => {
117118
117068
  if (!text2) return "";
117119
117069
  const regex = /\{\{.*?\}\}/g;
@@ -118008,7 +117958,9 @@ const SMSEditor = ({
118008
117958
  isUpdating,
118009
117959
  hasUnsavedChanges,
118010
117960
  communicationGroupId,
118011
- hasDynamicMergeFieldImage = false
117961
+ hasDynamicMergeFieldImage = false,
117962
+ hasAttachedImage = false,
117963
+ extraMergeFields = null
118012
117964
  }) => {
118013
117965
  const [characterCount, setCharacterCount] = useState(0);
118014
117966
  const [isAddImagePopoverOpen, setIsAddImagePopoverOpen] = useState(false);
@@ -118075,6 +118027,24 @@ const SMSEditor = ({
118075
118027
  if (selected.length > 0 && editor) {
118076
118028
  const mergeField = allMergeFields.flatMap((f2) => f2.entries).find((f2) => f2.value === selected[0]);
118077
118029
  if (mergeField) {
118030
+ if (hasAttachedImage && extraMergeFields) {
118031
+ const normalizedTemplateName = mergeField.value.startsWith("{{") && mergeField.value.endsWith("}}") ? mergeField.value.slice(2, -2) : mergeField.value;
118032
+ for (const extraMergeField of extraMergeFields) {
118033
+ if (extraMergeField.type === ReachMergeFieldTypeEnum.DYNAMIC) {
118034
+ const foundField = extraMergeField.mergeFields.find(
118035
+ (field) => field.templateName === normalizedTemplateName
118036
+ );
118037
+ if (foundField?.image) {
118038
+ toast2({
118039
+ title: "Cannot add QR code merge field",
118040
+ description: "An image is already attached to this message. To ensure image quality, we don't allow adding QR code merge fields when an image is already attached.",
118041
+ variant: "destructive"
118042
+ });
118043
+ return;
118044
+ }
118045
+ }
118046
+ }
118047
+ }
118078
118048
  editor.chain().focus().insertContent({
118079
118049
  type: "mergeField",
118080
118050
  attrs: {
@@ -118085,7 +118055,7 @@ const SMSEditor = ({
118085
118055
  }
118086
118056
  }
118087
118057
  },
118088
- [editor, allMergeFields]
118058
+ [editor, allMergeFields, hasAttachedImage, extraMergeFields, toast2]
118089
118059
  );
118090
118060
  const mergeFieldOptions = useMemo(
118091
118061
  () => allMergeFields.map((entry) => ({
@@ -119067,7 +119037,9 @@ const SMSEditorContent = React__default.memo(
119067
119037
  isUpdating: isUpdatingCommunicationGroup || isUploadingImage,
119068
119038
  hasUnsavedChanges,
119069
119039
  communicationGroupId,
119070
- hasDynamicMergeFieldImage: dynamicMergeFieldImages.length > 0
119040
+ hasDynamicMergeFieldImage: dynamicMergeFieldImages.length > 0,
119041
+ hasAttachedImage: !!imagePreview || (initialImageUrls?.length ?? 0) > 0 || imageBase64 !== null,
119042
+ extraMergeFields: communicationGroup?.extraMergeFields ?? null
119071
119043
  }
119072
119044
  )
119073
119045
  ] }),
@@ -123217,7 +123189,7 @@ const ConditionRow = ({
123217
123189
  const hoverTimeoutRef = useRef(null);
123218
123190
  const { segments } = useListSegments();
123219
123191
  const allUsersSegment = segments?.find(
123220
- (segment2) => segment2.type === BusinessSegmentTypeEnum.ALL_USERS
123192
+ (segment2) => segment2.type === SegmentDefinitionTypeEnum.ALL_USERS
123221
123193
  );
123222
123194
  const totalCount = condition.field === "userId" ? allUsersSegment?.userCount : void 0;
123223
123195
  const getMetadataForField = (field) => {
@@ -124056,7 +124028,7 @@ function SegmentBuilder({
124056
124028
  value: []
124057
124029
  }
124058
124030
  ],
124059
- type: BusinessSegmentTypeEnum.CUSTOM
124031
+ type: SegmentDefinitionTypeEnum.CUSTOM
124060
124032
  }));
124061
124033
  }
124062
124034
  }, [existingSegment, segmentsConditions]);
@@ -124913,7 +124885,7 @@ const SelectIndividualUsersContent = ({
124913
124885
  const { segments } = useListSegments();
124914
124886
  const allUsersSegment = React__default.useMemo(
124915
124887
  () => segments?.find(
124916
- (segment2) => segment2.type === BusinessSegmentTypeEnum.ALL_USERS
124888
+ (segment2) => segment2.type === SegmentDefinitionTypeEnum.ALL_USERS
124917
124889
  ),
124918
124890
  [segments]
124919
124891
  );
@@ -125474,11 +125446,11 @@ const AutomationAudienceSelectorMain = ({ title: title2 = "Preview Audience" })
125474
125446
  filterChanged
125475
125447
  ]);
125476
125448
  const allUsersSelected = includedSegments.length === 1 && excludedSegments.length === 0 && segments?.find(
125477
- (segment2) => segment2.type === BusinessSegmentTypeEnum.ALL_USERS && segment2.id === includedSegments[0]
125449
+ (segment2) => segment2.type === SegmentDefinitionTypeEnum.ALL_USERS && segment2.id === includedSegments[0]
125478
125450
  ) !== void 0;
125479
125451
  const segmentIdToFetch = includedSegments.length === 1 && excludedSegments.length === 0 && !allUsersSelected ? includedSegments[0] : "";
125480
125452
  const { segment: singleSegment } = useGetSegment(segmentIdToFetch);
125481
- const oneOffSegmentSelected = singleSegment?.type === BusinessSegmentTypeEnum.ONE_OFF;
125453
+ const oneOffSegmentSelected = singleSegment?.type === SegmentDefinitionTypeEnum.ONE_OFF;
125482
125454
  const finalCountResponse = React__default.useMemo(() => {
125483
125455
  if (selectedAudience === AutomationAudienceSelectorType.INDIVIDUAL) {
125484
125456
  if (selectedIndividualUserData.length > 0) {
@@ -125545,7 +125517,7 @@ const AutomationAudienceSelectorMain = ({ title: title2 = "Preview Audience" })
125545
125517
  const initializeState = async () => {
125546
125518
  if (automation2 && !initialStateSet && isLoading === false) {
125547
125519
  if (includedSegments.length === 1 && excludedSegments.length === 0 && segments.find(
125548
- (segment2) => segment2.type === BusinessSegmentTypeEnum.ALL_USERS && segment2.id === includedSegments[0]
125520
+ (segment2) => segment2.type === SegmentDefinitionTypeEnum.ALL_USERS && segment2.id === includedSegments[0]
125549
125521
  ) !== void 0) {
125550
125522
  setSelectedAudience(AutomationAudienceSelectorType.ALL);
125551
125523
  } else if (oneOffSegmentSelected && singleSegment) {
@@ -125611,7 +125583,7 @@ const AutomationAudienceSelectorMain = ({ title: title2 = "Preview Audience" })
125611
125583
  setSelectedAudience(value);
125612
125584
  if (value === AutomationAudienceSelectorType.ALL) {
125613
125585
  const allUsersSegment = segments?.find(
125614
- (segment2) => segment2.type === BusinessSegmentTypeEnum.ALL_USERS
125586
+ (segment2) => segment2.type === SegmentDefinitionTypeEnum.ALL_USERS
125615
125587
  );
125616
125588
  if (!allUsersSegment) {
125617
125589
  console.error("All users segment not found");
@@ -125680,7 +125652,7 @@ const AutomationAudienceSelectorMain = ({ title: title2 = "Preview Audience" })
125680
125652
  const newSegment = await createSegmentAsync({
125681
125653
  name: segmentName,
125682
125654
  description: "One-off segment for individual user selection",
125683
- type: BusinessSegmentTypeEnum.ONE_OFF,
125655
+ type: SegmentDefinitionTypeEnum.ONE_OFF,
125684
125656
  conditions: [
125685
125657
  {
125686
125658
  field: "userId",
@@ -125754,7 +125726,7 @@ const AutomationAudienceSelectorMain = ({ title: title2 = "Preview Audience" })
125754
125726
  segment2 = await createSegmentAsync({
125755
125727
  name: segmentName,
125756
125728
  description: "One-off segment for individual user selection",
125757
- type: BusinessSegmentTypeEnum.ONE_OFF,
125729
+ type: SegmentDefinitionTypeEnum.ONE_OFF,
125758
125730
  conditions: userIds.length > 0 ? [
125759
125731
  {
125760
125732
  field: "userId",
@@ -127013,9 +126985,11 @@ const OneTimeWizardMain = ({ onFinish, getExtraMergeFields, onBeforeSchedule, hi
127013
126985
  await new Promise((resolve) => setTimeout(resolve, 250));
127014
126986
  attempts++;
127015
126987
  }
126988
+ const scheduleSendAt = getScheduleSendAtFromAutomation(automation2);
127016
126989
  const result2 = await onBeforeSchedule({
127017
126990
  estimatedEmailRecipients: estimatedMatchesStats?.estimatedEmails || 0,
127018
- estimatedSmsRecipients: estimatedMatchesStats?.estimatedSms || 0
126991
+ estimatedSmsRecipients: estimatedMatchesStats?.estimatedSms || 0,
126992
+ scheduleSendAt
127019
126993
  });
127020
126994
  if (result2 === true) {
127021
126995
  updateAutomation2(
@@ -129222,9 +129196,9 @@ function SegmentList() {
129222
129196
  isPlaceholderData
129223
129197
  },
129224
129198
  onQueryParametersChange: handleQueryParametersChange,
129225
- getRowClassName: (row) => row.type === BusinessSegmentTypeEnum.ALL_USERS ? "cursor-not-allowed opacity-60" : "",
129199
+ getRowClassName: (row) => row.type === SegmentDefinitionTypeEnum.ALL_USERS ? "cursor-not-allowed opacity-60" : "",
129226
129200
  onRowClick: (row) => {
129227
- if (row.type === BusinessSegmentTypeEnum.ALL_USERS) {
129201
+ if (row.type === SegmentDefinitionTypeEnum.ALL_USERS) {
129228
129202
  toast2({
129229
129203
  title: "Read-only segment",
129230
129204
  description: "This segment cannot be edited.",
@@ -129232,7 +129206,7 @@ function SegmentList() {
129232
129206
  });
129233
129207
  return;
129234
129208
  }
129235
- if (row.type !== BusinessSegmentTypeEnum.CUSTOM) {
129209
+ if (row.type !== SegmentDefinitionTypeEnum.CUSTOM) {
129236
129210
  setSelectedSegment(row.id);
129237
129211
  setCreateDialogOpen(true);
129238
129212
  return;
@@ -129251,7 +129225,7 @@ function SegmentList() {
129251
129225
  setOpen: setCreateDialogOpen,
129252
129226
  segmentId: selectedSegment ?? void 0,
129253
129227
  onSegmentUpdated: onDialogClose,
129254
- viewOnly: selectedSegment ? segments?.find((s4) => s4.id === selectedSegment)?.type !== BusinessSegmentTypeEnum.CUSTOM : false
129228
+ viewOnly: selectedSegment ? segments?.find((s4) => s4.id === selectedSegment)?.type !== SegmentDefinitionTypeEnum.CUSTOM : false
129255
129229
  }
129256
129230
  )
129257
129231
  ] });
@@ -130000,9 +129974,11 @@ const AutomationsEditorHeader = ({ showBackButton, onDuplicationCreated, onBefor
130000
129974
  });
130001
129975
  return;
130002
129976
  }
129977
+ const scheduleSendAt = getScheduleSendAtFromAutomation(automation2);
130003
129978
  const result2 = await onBeforeSchedule({
130004
129979
  estimatedEmailRecipients: estimatedMatchesStats?.emails ?? 0,
130005
- estimatedSmsRecipients: estimatedMatchesStats?.phones ?? 0
129980
+ estimatedSmsRecipients: estimatedMatchesStats?.phones ?? 0,
129981
+ scheduleSendAt
130006
129982
  });
130007
129983
  if (result2 !== true) {
130008
129984
  toast2({
@@ -133466,10 +133442,10 @@ const AutomationAudienceSelector = () => {
133466
133442
  const excludeSegmentIds = automation2.excludeSegmentIds;
133467
133443
  let copyText;
133468
133444
  let showSegmentPills = true;
133469
- if (singleSegment?.type === BusinessSegmentTypeEnum.ALL_USERS) {
133445
+ if (singleSegment?.type === SegmentDefinitionTypeEnum.ALL_USERS) {
133470
133446
  copyText = `Send to all ${t$2("engage:user", { count: 2 })}`;
133471
133447
  showSegmentPills = false;
133472
- } else if (singleSegment?.type === BusinessSegmentTypeEnum.ONE_OFF) {
133448
+ } else if (singleSegment?.type === SegmentDefinitionTypeEnum.ONE_OFF) {
133473
133449
  copyText = `Send to specific ${t$2("engage:user", { count: 2 })}`;
133474
133450
  showSegmentPills = false;
133475
133451
  } else {
@@ -133880,15 +133856,15 @@ const AutomationEditorSubStep = ({
133880
133856
  const channelEnabled = (() => {
133881
133857
  if (!communicationGroup) return false;
133882
133858
  switch (type) {
133883
- case CommunicationSubStepType$1.EMAIL:
133859
+ case CommunicationSubStepType.EMAIL:
133884
133860
  return !!communicationGroup.emailChannelSenderId;
133885
- case CommunicationSubStepType$1.SMS:
133861
+ case CommunicationSubStepType.SMS:
133886
133862
  return !!communicationGroup.smsChannelSenderId;
133887
133863
  }
133888
133864
  })();
133889
133865
  const getIcon = (type2, isSelected2) => {
133890
133866
  switch (type2) {
133891
- case CommunicationSubStepType$1.EMAIL:
133867
+ case CommunicationSubStepType.EMAIL:
133892
133868
  return /* @__PURE__ */ jsx(
133893
133869
  IconDefinitions.EmailIcon,
133894
133870
  {
@@ -133898,7 +133874,7 @@ const AutomationEditorSubStep = ({
133898
133874
  )
133899
133875
  }
133900
133876
  );
133901
- case CommunicationSubStepType$1.SMS:
133877
+ case CommunicationSubStepType.SMS:
133902
133878
  return /* @__PURE__ */ jsx(
133903
133879
  IconDefinitions.SmsIcon,
133904
133880
  {
@@ -133912,16 +133888,16 @@ const AutomationEditorSubStep = ({
133912
133888
  };
133913
133889
  const getSubStepLabel = () => {
133914
133890
  switch (type) {
133915
- case CommunicationSubStepType$1.EMAIL:
133891
+ case CommunicationSubStepType.EMAIL:
133916
133892
  return "Email";
133917
- case CommunicationSubStepType$1.SMS:
133893
+ case CommunicationSubStepType.SMS:
133918
133894
  return "SMS";
133919
133895
  }
133920
133896
  };
133921
133897
  const contentNeeded = (() => {
133922
133898
  if (!communicationGroup) return "Need to select a channel";
133923
133899
  switch (type) {
133924
- case CommunicationSubStepType$1.EMAIL:
133900
+ case CommunicationSubStepType.EMAIL:
133925
133901
  if (!communicationGroup.emailChannelSenderId) {
133926
133902
  return "Please select a email sender";
133927
133903
  }
@@ -133932,7 +133908,7 @@ const AutomationEditorSubStep = ({
133932
133908
  return "Please add a subject to the email";
133933
133909
  }
133934
133910
  return true;
133935
- case CommunicationSubStepType$1.SMS:
133911
+ case CommunicationSubStepType.SMS:
133936
133912
  if (!communicationGroup.smsChannelSenderId) {
133937
133913
  return "Please select a sms sender";
133938
133914
  }
@@ -133983,7 +133959,7 @@ const AutomationEditorSubStep = ({
133983
133959
  children: /* @__PURE__ */ jsx(MinorText, { className: "text-xs", children: getSubStepLabel() })
133984
133960
  }
133985
133961
  ),
133986
- channelEnabled && /* @__PURE__ */ jsx("div", { className: "text-[10px] font-medium text-muted-foreground", children: type === CommunicationSubStepType$1.EMAIL ? isGettingMergeFields ? /* @__PURE__ */ jsx("span", { className: "text-[10px] font-medium text-muted-foreground", children: "..." }) : /* @__PURE__ */ jsx(
133962
+ channelEnabled && /* @__PURE__ */ jsx("div", { className: "text-[10px] font-medium text-muted-foreground", children: type === CommunicationSubStepType.EMAIL ? isGettingMergeFields ? /* @__PURE__ */ jsx("span", { className: "text-[10px] font-medium text-muted-foreground", children: "..." }) : /* @__PURE__ */ jsx(
133987
133963
  MergeFieldRenderer,
133988
133964
  {
133989
133965
  content: communicationGroup?.emailSubject || "No subject set",
@@ -134322,9 +134298,9 @@ const AutomationFlowMain = ({
134322
134298
  );
134323
134299
  if (selectedAction?.actionData.actionType === ActionType.SEND_COMMUNICATION) {
134324
134300
  if (communicationGroup?.emailChannelSenderId) {
134325
- setSelectedSubStepType2(CommunicationSubStepType$1.EMAIL);
134301
+ setSelectedSubStepType2(CommunicationSubStepType.EMAIL);
134326
134302
  } else {
134327
- setSelectedSubStepType2(CommunicationSubStepType$1.SMS);
134303
+ setSelectedSubStepType2(CommunicationSubStepType.SMS);
134328
134304
  }
134329
134305
  }
134330
134306
  }
@@ -134413,14 +134389,14 @@ const AutomationFlowMain = ({
134413
134389
  /* @__PURE__ */ jsx(
134414
134390
  AutomationEditorSubStep,
134415
134391
  {
134416
- type: CommunicationSubStepType$1.EMAIL,
134392
+ type: CommunicationSubStepType.EMAIL,
134417
134393
  actionId: actionData.actionData.actionMetadata.currentActionId
134418
134394
  }
134419
134395
  ),
134420
134396
  !hideSms && /* @__PURE__ */ jsx(
134421
134397
  AutomationEditorSubStep,
134422
134398
  {
134423
- type: CommunicationSubStepType$1.SMS,
134399
+ type: CommunicationSubStepType.SMS,
134424
134400
  actionId: actionData.actionData.actionMetadata.currentActionId
134425
134401
  }
134426
134402
  )
@@ -134640,9 +134616,9 @@ const useChannelToggle = (type) => {
134640
134616
  const isChannelEnabled = useCallback(() => {
134641
134617
  if (!communicationGroup) return false;
134642
134618
  switch (type) {
134643
- case CommunicationSubStepType$1.EMAIL:
134619
+ case CommunicationSubStepType.EMAIL:
134644
134620
  return !!communicationGroup.emailChannelSenderId;
134645
- case CommunicationSubStepType$1.SMS:
134621
+ case CommunicationSubStepType.SMS:
134646
134622
  return !!communicationGroup.smsChannelSenderId;
134647
134623
  }
134648
134624
  }, [communicationGroup, type]);
@@ -134655,7 +134631,7 @@ const useChannelToggle = (type) => {
134655
134631
  smsChannelSenderId: communicationGroup.smsChannelSenderId
134656
134632
  };
134657
134633
  switch (type) {
134658
- case CommunicationSubStepType$1.EMAIL:
134634
+ case CommunicationSubStepType.EMAIL:
134659
134635
  if (channelEnabled && communicationGroup.emailChannelSenderId) {
134660
134636
  params.emailChannelSenderId = null;
134661
134637
  } else {
@@ -134665,7 +134641,7 @@ const useChannelToggle = (type) => {
134665
134641
  }
134666
134642
  }
134667
134643
  break;
134668
- case CommunicationSubStepType$1.SMS:
134644
+ case CommunicationSubStepType.SMS:
134669
134645
  if (channelEnabled && communicationGroup.smsChannelSenderId) {
134670
134646
  params.smsChannelSenderId = null;
134671
134647
  } else {
@@ -135723,7 +135699,7 @@ const AutomationEditorEmailPreview = ({
135723
135699
  channelEnabled,
135724
135700
  isUpdating: isUpdatingChannel,
135725
135701
  handleToggleChannel
135726
- } = useChannelToggle(CommunicationSubStepType$1.EMAIL);
135702
+ } = useChannelToggle(CommunicationSubStepType.EMAIL);
135727
135703
  const [openPreviewDialog, setOpenPreviewDialog] = useState(false);
135728
135704
  const [showStripoEditor, setShowStripoEditor] = useState(false);
135729
135705
  const [showHelpDialog, setShowHelpDialog] = useState(null);
@@ -136079,7 +136055,7 @@ const AutomationEditorSMSPreview = ({
136079
136055
  channelEnabled,
136080
136056
  isUpdating: isUpdatingChannel,
136081
136057
  handleToggleChannel
136082
- } = useChannelToggle(CommunicationSubStepType.SMS);
136058
+ } = useChannelToggle(CommunicationSubStepType$1.SMS);
136083
136059
  const { updateCommunicationGroup: updateCommunicationGroup2, isUpdating: isUpdatingCommunicationGroup } = useUpdateCommunicationGroup();
136084
136060
  const smsChannelSenders = getSmsChannelSenders({
136085
136061
  channelSenders: channelSenders?.results ?? [],
@@ -136420,8 +136396,8 @@ const AutomationEditorCommunicationPreview = ({
136420
136396
  disablePreviewSubtext
136421
136397
  };
136422
136398
  return /* @__PURE__ */ jsxs("div", { className: "flex flex-col flex-1 bg-muted rounded-md", children: [
136423
- selectedSubStepType === CommunicationSubStepType$1.EMAIL && /* @__PURE__ */ jsx(AutomationEditorEmailPreview, { ...commonProps }),
136424
- selectedSubStepType === CommunicationSubStepType$1.SMS && !hideSms && /* @__PURE__ */ jsx(AutomationEditorSMSPreview, { ...commonProps })
136399
+ selectedSubStepType === CommunicationSubStepType.EMAIL && /* @__PURE__ */ jsx(AutomationEditorEmailPreview, { ...commonProps }),
136400
+ selectedSubStepType === CommunicationSubStepType.SMS && !hideSms && /* @__PURE__ */ jsx(AutomationEditorSMSPreview, { ...commonProps })
136425
136401
  ] });
136426
136402
  };
136427
136403
  const AutomationsEditorMain = () => {