@drawbridge/components 0.1.34 → 0.1.36

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.
Files changed (328) hide show
  1. package/components/styles.css +68 -355
  2. package/dist/advertisement.js +15 -20
  3. package/dist/advertisement.mjs +15 -20
  4. package/dist/bridge/advertisements.js +4 -2
  5. package/dist/bridge/advertisements.mjs +5 -3
  6. package/dist/bridge/fields.js +89 -6
  7. package/dist/bridge/fields.mjs +89 -7
  8. package/dist/bridge/form-subdomain-agreement.js +165 -0
  9. package/dist/bridge/form-subdomain-agreement.mjs +132 -0
  10. package/dist/bridge/form-subdomain-embed.js +5 -1
  11. package/dist/bridge/form-subdomain-embed.mjs +5 -1
  12. package/dist/bridge/form-subdomain-header.js +21 -14
  13. package/dist/bridge/form-subdomain-header.mjs +20 -14
  14. package/dist/bridge/form-subdomain-issue.js +17 -8
  15. package/dist/bridge/form-subdomain-issue.mjs +17 -8
  16. package/dist/bridge/form-subdomain-missions.js +58 -52
  17. package/dist/bridge/form-subdomain-missions.mjs +60 -54
  18. package/dist/bridge/form-subdomain.js +223 -94
  19. package/dist/bridge/form-subdomain.mjs +222 -96
  20. package/dist/bridge/lib/entry.js +61 -6
  21. package/dist/bridge/lib/entry.mjs +51 -5
  22. package/dist/bridge/lib/order.js +23 -0
  23. package/dist/bridge/lib/order.mjs +20 -0
  24. package/dist/bridge/template-layout.js +5 -2
  25. package/dist/bridge/template-layout.mjs +6 -3
  26. package/dist/bridge/template-modal.js +82 -15
  27. package/dist/bridge/template-modal.mjs +83 -16
  28. package/dist/bridge/template-subdomain-gallery.js +126 -75
  29. package/dist/bridge/template-subdomain-gallery.mjs +122 -75
  30. package/dist/bridge/template-subdomain.js +16 -14
  31. package/dist/bridge/template-subdomain.mjs +17 -15
  32. package/dist/dashboard/avatar.js +5 -0
  33. package/dist/dashboard/avatar.mjs +5 -0
  34. package/dist/dashboard/campaign-form.js +1798 -0
  35. package/dist/dashboard/campaign-form.mjs +1769 -0
  36. package/dist/dashboard/card-affiliate.js +3 -2
  37. package/dist/dashboard/card-affiliate.mjs +3 -2
  38. package/dist/dashboard/card-campaign-agreement.js +172 -0
  39. package/dist/dashboard/card-campaign-agreement.mjs +139 -0
  40. package/dist/dashboard/card-campaign-switch.js +34 -9
  41. package/dist/dashboard/card-campaign-switch.mjs +32 -8
  42. package/dist/dashboard/card-order.js +6 -14
  43. package/dist/dashboard/card-order.mjs +6 -14
  44. package/dist/dashboard/card-section.js +69 -26
  45. package/dist/dashboard/card-section.mjs +65 -26
  46. package/dist/dashboard/card-shortcut.js +181 -0
  47. package/dist/dashboard/card-shortcut.mjs +152 -0
  48. package/dist/dashboard/card-tile.js +3 -35
  49. package/dist/dashboard/card-tile.mjs +3 -34
  50. package/dist/dashboard/document-blocks.js +305 -0
  51. package/dist/dashboard/document-blocks.mjs +270 -0
  52. package/dist/dashboard/drawer-subscription.js +52 -14
  53. package/dist/dashboard/drawer-subscription.mjs +52 -14
  54. package/dist/dashboard/drawer.js +20 -3
  55. package/dist/dashboard/drawer.mjs +21 -4
  56. package/dist/dashboard/dropdown.js +6 -2
  57. package/dist/dashboard/dropdown.mjs +6 -2
  58. package/dist/dashboard/form-admin-subscription-custom.js +72 -8
  59. package/dist/dashboard/form-admin-subscription-custom.mjs +72 -8
  60. package/dist/dashboard/form-ai.js +0 -148
  61. package/dist/dashboard/form-ai.mjs +1 -148
  62. package/dist/dashboard/form-filters-analytics.js +88 -37
  63. package/dist/dashboard/form-filters-analytics.mjs +85 -38
  64. package/dist/dashboard/form-organization-brand.js +30 -13
  65. package/dist/dashboard/form-organization-brand.mjs +30 -13
  66. package/dist/dashboard/form-organization-campaign-advertisement.js +38 -112
  67. package/dist/dashboard/form-organization-campaign-advertisement.mjs +38 -112
  68. package/dist/dashboard/form-organization-campaign-advertisements.js +374 -0
  69. package/dist/dashboard/form-organization-campaign-advertisements.mjs +345 -0
  70. package/dist/dashboard/form-organization-campaign-agreement.js +402 -210
  71. package/dist/dashboard/form-organization-campaign-agreement.mjs +398 -211
  72. package/dist/dashboard/form-organization-campaign-design.js +258 -0
  73. package/dist/dashboard/form-organization-campaign-design.mjs +223 -0
  74. package/dist/dashboard/form-organization-campaign-field-item.js +585 -0
  75. package/dist/dashboard/form-organization-campaign-field-item.mjs +552 -0
  76. package/dist/dashboard/form-organization-campaign-field-number.js +48 -7
  77. package/dist/dashboard/form-organization-campaign-field-number.mjs +48 -7
  78. package/dist/dashboard/form-organization-campaign-field-select.js +15 -4
  79. package/dist/dashboard/form-organization-campaign-field-select.mjs +15 -4
  80. package/dist/dashboard/form-organization-campaign-field-skill.js +359 -0
  81. package/dist/dashboard/form-organization-campaign-field-skill.mjs +330 -0
  82. package/dist/dashboard/form-organization-campaign-field-text.js +46 -6
  83. package/dist/dashboard/form-organization-campaign-field-text.mjs +46 -6
  84. package/dist/dashboard/form-organization-campaign-field-textarea.js +22 -13
  85. package/dist/dashboard/form-organization-campaign-field-textarea.mjs +22 -13
  86. package/dist/dashboard/form-organization-campaign-footer.js +178 -0
  87. package/dist/dashboard/form-organization-campaign-footer.mjs +149 -0
  88. package/dist/dashboard/form-organization-campaign-integration-age.js +2 -35
  89. package/dist/dashboard/form-organization-campaign-integration-age.mjs +2 -35
  90. package/dist/dashboard/form-organization-campaign-integration-geocode.js +4 -1
  91. package/dist/dashboard/form-organization-campaign-integration-geocode.mjs +4 -1
  92. package/dist/dashboard/form-organization-campaign-page-embed.js +1 -1
  93. package/dist/dashboard/form-organization-campaign-page-embed.mjs +1 -1
  94. package/dist/dashboard/form-organization-campaign-page-preview.js +1 -2
  95. package/dist/dashboard/form-organization-campaign-page-preview.mjs +1 -2
  96. package/dist/dashboard/form-organization-campaign-page-qr.js +2 -2
  97. package/dist/dashboard/form-organization-campaign-page-qr.mjs +2 -2
  98. package/dist/dashboard/form-organization-campaign-page-share.js +5 -5
  99. package/dist/dashboard/form-organization-campaign-page-share.mjs +5 -5
  100. package/dist/dashboard/form-organization-campaign-page-slug.js +2 -3
  101. package/dist/dashboard/form-organization-campaign-page-slug.mjs +2 -3
  102. package/dist/dashboard/form-organization-campaign-page.js +168 -265
  103. package/dist/dashboard/form-organization-campaign-page.mjs +170 -266
  104. package/dist/dashboard/form-organization-campaign-section.js +125 -107
  105. package/dist/dashboard/form-organization-campaign-section.mjs +121 -107
  106. package/dist/dashboard/form-organization-campaign.js +119 -9
  107. package/dist/dashboard/form-organization-campaign.mjs +118 -9
  108. package/dist/dashboard/form-organization-file-frame.js +7 -1
  109. package/dist/dashboard/form-organization-file-frame.mjs +7 -1
  110. package/dist/dashboard/form-organization-workflow.js +587 -530
  111. package/dist/dashboard/form-organization-workflow.mjs +588 -531
  112. package/dist/dashboard/form-organization.js +22 -0
  113. package/dist/dashboard/form-organization.mjs +22 -0
  114. package/dist/dashboard/form-reposition.js +396 -0
  115. package/dist/dashboard/form-reposition.mjs +359 -0
  116. package/dist/dashboard/form-support.js +189 -0
  117. package/dist/dashboard/form-support.mjs +160 -0
  118. package/dist/dashboard/form-tests.js +683 -0
  119. package/dist/dashboard/form-tests.mjs +646 -0
  120. package/dist/dashboard/form-verify-prize.js +114 -34
  121. package/dist/dashboard/form-verify-prize.mjs +111 -34
  122. package/dist/dashboard/google.js +8 -1
  123. package/dist/dashboard/google.mjs +8 -1
  124. package/dist/dashboard/input-array.js +2 -0
  125. package/dist/dashboard/input-array.mjs +2 -0
  126. package/dist/dashboard/input-editor.js +17 -6
  127. package/dist/dashboard/input-editor.mjs +17 -6
  128. package/dist/dashboard/input-fields.js +287 -437
  129. package/dist/dashboard/input-fields.mjs +287 -436
  130. package/dist/dashboard/input-file.js +70 -2
  131. package/dist/dashboard/input-file.mjs +70 -2
  132. package/dist/dashboard/input-font.js +64 -55
  133. package/dist/dashboard/input-font.mjs +64 -55
  134. package/dist/dashboard/input-resource.js +4 -1
  135. package/dist/dashboard/input-resource.mjs +4 -1
  136. package/dist/dashboard/lib/ab-tests.js +130 -0
  137. package/dist/dashboard/lib/ab-tests.mjs +94 -0
  138. package/dist/dashboard/lib/features.js +1 -1
  139. package/dist/dashboard/lib/features.mjs +1 -1
  140. package/dist/dashboard/lib/focus.js +93 -0
  141. package/dist/dashboard/lib/focus.mjs +69 -0
  142. package/dist/dashboard/lib/form-page.js +203 -0
  143. package/dist/dashboard/lib/form-page.mjs +155 -0
  144. package/dist/dashboard/lib/item-list.js +0 -15
  145. package/dist/dashboard/lib/item-list.mjs +0 -14
  146. package/dist/dashboard/lib/rail.js +16 -17
  147. package/dist/dashboard/lib/rail.mjs +15 -16
  148. package/dist/dashboard/lib/sms.js +8 -2
  149. package/dist/dashboard/lib/sms.mjs +6 -1
  150. package/dist/dashboard/list-resource.js +2 -0
  151. package/dist/dashboard/list-resource.mjs +2 -0
  152. package/dist/dashboard/menu.js +54 -5
  153. package/dist/dashboard/menu.mjs +53 -5
  154. package/dist/dashboard/modal.js +19 -4
  155. package/dist/dashboard/modal.mjs +20 -5
  156. package/dist/dashboard/order-sections.js +4 -0
  157. package/dist/dashboard/order-sections.mjs +4 -0
  158. package/dist/dashboard/preview.js +838 -324
  159. package/dist/dashboard/preview.mjs +826 -324
  160. package/dist/dashboard/provider-ui.js +20 -12
  161. package/dist/dashboard/provider-ui.mjs +21 -13
  162. package/dist/dashboard/recharts.js +53 -28
  163. package/dist/dashboard/recharts.mjs +53 -28
  164. package/dist/dashboard/swatch.js +35 -0
  165. package/dist/dashboard/swatch.mjs +31 -0
  166. package/dist/dashboard/table-contacts.js +6 -10
  167. package/dist/dashboard/table-contacts.mjs +6 -10
  168. package/dist/dashboard/table.js +10 -3
  169. package/dist/dashboard/table.mjs +9 -3
  170. package/dist/dashboard/template-dashboard.js +12 -7
  171. package/dist/dashboard/template-dashboard.mjs +11 -7
  172. package/dist/dashboard/template-design.js +564 -0
  173. package/dist/dashboard/template-design.mjs +531 -0
  174. package/dist/dashboard/template-rail.js +198 -126
  175. package/dist/dashboard/template-rail.mjs +196 -125
  176. package/dist/dashboard/template-socket.js +0 -3
  177. package/dist/dashboard/template-socket.mjs +0 -3
  178. package/dist/dashboard/template-test-page.js +436 -0
  179. package/dist/dashboard/template-test-page.mjs +407 -0
  180. package/dist/dashboard/template-tests.js +141 -0
  181. package/dist/dashboard/template-tests.mjs +112 -0
  182. package/dist/dashboard/template-ui.js +20 -11
  183. package/dist/dashboard/template-ui.mjs +22 -13
  184. package/dist/dashboard/template-variant.js +185 -0
  185. package/dist/dashboard/template-variant.mjs +156 -0
  186. package/dist/icons/arrow-down-long.js +47 -0
  187. package/dist/icons/arrow-down-long.mjs +28 -0
  188. package/dist/icons/arrows-pointing-out.js +46 -0
  189. package/dist/icons/arrows-pointing-out.mjs +27 -0
  190. package/dist/icons/beaker.js +46 -0
  191. package/dist/icons/beaker.mjs +27 -0
  192. package/dist/icons/identification.js +46 -0
  193. package/dist/icons/identification.mjs +27 -0
  194. package/dist/icons/lifebuoy.js +46 -0
  195. package/dist/icons/lifebuoy.mjs +27 -0
  196. package/dist/icons/rectangle-group.js +46 -0
  197. package/dist/icons/rectangle-group.mjs +27 -0
  198. package/dist/icons/rectangle-stack.js +46 -0
  199. package/dist/icons/rectangle-stack.mjs +27 -0
  200. package/dist/icons/shopping-bag.js +46 -0
  201. package/dist/icons/shopping-bag.mjs +27 -0
  202. package/dist/icons/swatch.js +46 -0
  203. package/dist/icons/swatch.mjs +27 -0
  204. package/dist/icons/window.js +46 -0
  205. package/dist/icons/window.mjs +27 -0
  206. package/dist/icons/zoom-in.js +46 -0
  207. package/dist/icons/zoom-in.mjs +27 -0
  208. package/dist/input-answer.js +60 -0
  209. package/dist/input-answer.mjs +27 -0
  210. package/dist/input-checkbox.js +7 -1
  211. package/dist/input-checkbox.mjs +7 -1
  212. package/dist/input-name.js +3 -3
  213. package/dist/input-name.mjs +3 -3
  214. package/dist/input-select.js +3 -1
  215. package/dist/input-select.mjs +3 -1
  216. package/dist/provider-font.js +4 -3
  217. package/dist/provider-font.mjs +4 -3
  218. package/dist/shared/badge.js +15 -0
  219. package/dist/shared/badge.mjs +11 -0
  220. package/dist/shared/carousel.js +11 -7
  221. package/dist/shared/carousel.mjs +11 -7
  222. package/dist/shared/document-pieces.js +295 -0
  223. package/dist/shared/document-pieces.mjs +260 -0
  224. package/dist/shared/lib/campaign.js +3 -9
  225. package/dist/shared/lib/campaign.mjs +3 -9
  226. package/dist/shared/lib/helpers.js +24 -0
  227. package/dist/shared/lib/helpers.mjs +22 -0
  228. package/dist/shared/lib/video.js +6 -0
  229. package/dist/shared/lib/video.mjs +5 -0
  230. package/dist/shared/sortable.js +27 -10
  231. package/dist/shared/sortable.mjs +27 -10
  232. package/dist/shared/tabs.js +1 -1
  233. package/dist/shared/tabs.mjs +1 -1
  234. package/dist/video.js +127 -9
  235. package/dist/video.mjs +125 -11
  236. package/package.json +176 -20
  237. package/types/bridge/fields.d.ts +6 -1
  238. package/types/bridge/form-subdomain-agreement.d.ts +27 -0
  239. package/types/bridge/form-subdomain-missions.d.ts +2 -0
  240. package/types/bridge/form-subdomain.d.ts +62 -3
  241. package/types/bridge/lib/entry.d.ts +44 -7
  242. package/types/bridge/lib/order.d.ts +13 -2
  243. package/types/bridge/subdomain-content.d.ts +1 -0
  244. package/types/bridge/template-subdomain-gallery.d.ts +13 -1
  245. package/types/dashboard/campaign-form.d.ts +42 -0
  246. package/types/dashboard/card-campaign-agreement.d.ts +26 -0
  247. package/types/dashboard/card-campaign-switch.d.ts +20 -1
  248. package/types/dashboard/card-order.d.ts +2 -2
  249. package/types/dashboard/card-section.d.ts +9 -1
  250. package/types/dashboard/card-shortcut.d.ts +38 -0
  251. package/types/dashboard/card-tile.d.ts +4 -9
  252. package/types/dashboard/document-blocks.d.ts +14 -0
  253. package/types/dashboard/drawer.d.ts +3 -0
  254. package/types/dashboard/form-ai.d.ts +0 -17
  255. package/types/dashboard/form-organization-brand.d.ts +3 -0
  256. package/types/dashboard/form-organization-campaign-advertisements.d.ts +15 -0
  257. package/types/dashboard/form-organization-campaign-agreement.d.ts +53 -10
  258. package/types/dashboard/form-organization-campaign-design.d.ts +46 -0
  259. package/types/dashboard/form-organization-campaign-field-item.d.ts +36 -0
  260. package/types/dashboard/form-organization-campaign-field-number.d.ts +4 -1
  261. package/types/dashboard/form-organization-campaign-field-select.d.ts +6 -1
  262. package/types/dashboard/form-organization-campaign-field-skill.d.ts +36 -0
  263. package/types/dashboard/form-organization-campaign-field-text.d.ts +5 -1
  264. package/types/dashboard/form-organization-campaign-field-textarea.d.ts +4 -1
  265. package/types/dashboard/form-organization-campaign-footer.d.ts +23 -0
  266. package/types/dashboard/form-organization-campaign-integration-age.d.ts +2 -1
  267. package/types/dashboard/form-organization-campaign-integration-geocode.d.ts +2 -0
  268. package/types/dashboard/form-organization-campaign-page.d.ts +9 -15
  269. package/types/dashboard/form-organization-campaign-section.d.ts +24 -8
  270. package/types/dashboard/form-organization-campaign.d.ts +3 -0
  271. package/types/dashboard/form-organization-workflow.d.ts +3 -0
  272. package/types/dashboard/form-organization.d.ts +2 -2
  273. package/types/dashboard/form-reposition.d.ts +29 -0
  274. package/types/dashboard/form-support.d.ts +14 -0
  275. package/types/dashboard/form-tests.d.ts +78 -0
  276. package/types/dashboard/form-verify-prize.d.ts +30 -3
  277. package/types/dashboard/input-editor.d.ts +9 -0
  278. package/types/dashboard/input-fields.d.ts +8 -5
  279. package/types/dashboard/input-file.d.ts +4 -0
  280. package/types/dashboard/input-resource.d.ts +1 -0
  281. package/types/dashboard/lib/ab-tests.d.ts +50 -0
  282. package/types/dashboard/lib/escape.d.ts +4 -0
  283. package/types/dashboard/lib/focus.d.ts +16 -0
  284. package/types/dashboard/lib/form-page.d.ts +25 -0
  285. package/types/dashboard/lib/item-list.d.ts +10 -5
  286. package/types/dashboard/lib/rail.d.ts +0 -1
  287. package/types/dashboard/lib/sms.d.ts +7 -0
  288. package/types/dashboard/modal.d.ts +3 -1
  289. package/types/dashboard/preview.d.ts +65 -10
  290. package/types/dashboard/recharts.d.ts +3 -0
  291. package/types/dashboard/swatch.d.ts +4 -0
  292. package/types/dashboard/template-dashboard.d.ts +3 -0
  293. package/types/dashboard/template-design.d.ts +30 -0
  294. package/types/dashboard/template-test-page.d.ts +69 -0
  295. package/types/dashboard/template-tests.d.ts +30 -0
  296. package/types/dashboard/template-variant.d.ts +18 -0
  297. package/types/icons/arrow-down-long.d.ts +5 -0
  298. package/types/icons/arrows-pointing-out.d.ts +5 -0
  299. package/types/icons/beaker.d.ts +5 -0
  300. package/types/icons/identification.d.ts +5 -0
  301. package/types/icons/lifebuoy.d.ts +5 -0
  302. package/types/icons/rectangle-group.d.ts +5 -0
  303. package/types/icons/rectangle-stack.d.ts +5 -0
  304. package/types/icons/shopping-bag.d.ts +5 -0
  305. package/types/icons/swatch.d.ts +5 -0
  306. package/types/icons/window.d.ts +5 -0
  307. package/types/icons/zoom-in.d.ts +5 -0
  308. package/types/input-answer.d.ts +15 -0
  309. package/types/input-select.d.ts +2 -0
  310. package/types/shared/button.d.ts +1 -1
  311. package/types/shared/document-pieces.d.ts +34 -0
  312. package/types/shared/lib/helpers.d.ts +22 -1
  313. package/types/shared/lib/motion.d.ts +2 -0
  314. package/types/shared/lib/video.d.ts +3 -0
  315. package/types/shared/sortable.d.ts +6 -0
  316. package/types/video.d.ts +18 -2
  317. package/dist/bridge/template-preview.js +0 -208
  318. package/dist/bridge/template-preview.mjs +0 -173
  319. package/dist/dashboard/device.js +0 -95
  320. package/dist/dashboard/device.mjs +0 -72
  321. package/dist/dashboard/form-organization-campaign-field-list.js +0 -425
  322. package/dist/dashboard/form-organization-campaign-field-list.mjs +0 -396
  323. package/dist/dashboard/item-row.js +0 -92
  324. package/dist/dashboard/item-row.mjs +0 -63
  325. package/types/bridge/template-preview.d.ts +0 -10
  326. package/types/dashboard/device.d.ts +0 -12
  327. package/types/dashboard/form-organization-campaign-field-list.d.ts +0 -36
  328. package/types/dashboard/item-row.d.ts +0 -25
@@ -2,8 +2,9 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import Image from "next/image";
3
3
  import Link from "./link.mjs";
4
4
  import { Fragment, useCallback, useEffect, useRef, useState } from "react";
5
- import { constants } from "@drawbridge/drawbridge-utils";
6
- import { request } from "@drawbridge/drawbridge-utils/fetch";
5
+ import { constants, getPlanFeature } from "@drawbridge/drawbridge-utils";
6
+ import { organization as organizationFeatures } from "@drawbridge/drawbridge-utils/features";
7
+ import { isTransientError, request } from "@drawbridge/drawbridge-utils/fetch";
7
8
  import { escapeHtml } from "@drawbridge/drawbridge-utils/html";
8
9
  import { useForm, useWatch, Controller } from "../shared/lib/form.mjs";
9
10
  import { keepPreviousData, useQuery, useQueryClient } from "@tanstack/react-query";
@@ -23,12 +24,13 @@ import Badge from "../shared/badge.mjs";
23
24
  import InputSwitch from "../shared/input-switch.mjs";
24
25
  import CardSection from "./card-section.mjs";
25
26
  import Accordion from "./accordion.mjs";
26
- import Preview from "./preview.mjs";
27
+ import Preview, { Mail, NoPreview, SliderLayout, useCard } from "./preview.mjs";
27
28
  import CardTask from "./card-task.mjs";
28
29
  import { LoaderDynamic } from "../shared/loader.mjs";
29
30
  import { smsBrandLine, smsNumberActive } from "./lib/sms.mjs";
30
31
  import Trash from "../icons/trash.mjs";
31
32
  import Button from "../shared/button.mjs";
33
+ import { hasCapability } from "../shared/lib/helpers.mjs";
32
34
  const emailSteps = ["step.email.send"];
33
35
  const teamSteps = ["step.email.notify"];
34
36
  const messageSteps = [...emailSteps, "step.sms.send"];
@@ -59,6 +61,10 @@ const memberParams = {
59
61
  createdAt: -1
60
62
  }
61
63
  };
64
+ const listsMembers = (organization) => {
65
+ var _a;
66
+ return hasCapability(organization, "members") && (getPlanFeature(organization == null ? void 0 : organization.plan, organizationFeatures.members.key).granted || ((_a = organization == null ? void 0 : organization.totals) == null ? void 0 : _a.members) > 0);
67
+ };
62
68
  const memberOptions = (organization) => ({
63
69
  queryKey: ["organization-members", organization, "options"],
64
70
  queryFn: async () => {
@@ -71,11 +77,11 @@ const memberOptions = (organization) => ({
71
77
  },
72
78
  staleTime: Infinity
73
79
  });
74
- const useOrganizationMembers = (organization) => {
80
+ const useOrganizationMembers = (organization, listed) => {
75
81
  var _a;
76
82
  const members = useQuery({
77
83
  ...memberOptions(organization),
78
- enabled: Boolean(organization)
84
+ enabled: Boolean(organization) && listed
79
85
  });
80
86
  return {
81
87
  items: ((_a = members.data) == null ? void 0 : _a.items) || [],
@@ -338,9 +344,10 @@ const workflowSchema = yup.object({
338
344
  )
339
345
  });
340
346
  const useEmailPreview = ({ campaign, event, message, organization, subject, text, type }) => {
347
+ const queryClient = useQueryClient();
341
348
  const asked = JSON.stringify(teamSteps.includes(type) ? { type } : { message, subject, text });
342
349
  const [settled, setSettled] = useState(asked);
343
- const last = useRef();
350
+ const held = ["workflow-email-preview-shown", organization, campaign, event, type || null];
344
351
  useEffect(() => {
345
352
  const timer = setTimeout(() => setSettled(asked), 400);
346
353
  return () => clearTimeout(timer);
@@ -354,22 +361,33 @@ const useEmailPreview = ({ campaign, event, message, organization, subject, text
354
361
  endpoint: "/organization/" + organization + "/campaign/" + campaign + "/workflow/" + event + "/preview",
355
362
  method: "POST"
356
363
  });
364
+ queryClient.setQueryData(held, result);
357
365
  return result;
358
366
  },
359
367
  // Stale at once ( the dashboard's default is never ): the key holds the
360
368
  // step's copy only, and the placeholder under it is the campaign's, so
361
369
  // each visit to the trigger page asks again (Asana 1217773117236699).
362
370
  queryKey: ["workflow-email-preview", organization, campaign, event, settled],
371
+ retry: (count, error) => count < 5 && isTransientError(error),
363
372
  staleTime: 0
364
373
  });
365
- if (preview.data) last.current = preview.data;
366
- return last.current;
374
+ return preview.data || queryClient.getQueryData(held);
367
375
  };
376
+ const Shown = ({ children, off }) => /* @__PURE__ */ jsx(
377
+ "div",
378
+ {
379
+ ...{
380
+ className: "mx-auto w-full max-w-[600px] px-6 space-y-4" + (off ? " opacity-50" : "")
381
+ },
382
+ children
383
+ }
384
+ );
368
385
  const EmailStepCard = ({
369
386
  card,
370
387
  children,
371
388
  control,
372
389
  off,
390
+ slide,
373
391
  email: {
374
392
  campaign,
375
393
  event,
@@ -384,12 +402,14 @@ const EmailStepCard = ({
384
402
  name: [name + ".subject", name + ".message", name + ".text"]
385
403
  });
386
404
  const preview = useEmailPreview({ campaign, event, message, organization, subject, text, type });
405
+ const target = useCard(slide);
387
406
  return /* @__PURE__ */ jsxs(
388
407
  CardSection,
389
408
  {
390
409
  ...{
391
410
  ...card,
392
- columns: 2
411
+ ...target.props,
412
+ className: "relative shrink-0" + target.className
393
413
  },
394
414
  children: [
395
415
  /* @__PURE__ */ jsxs(
@@ -423,46 +443,36 @@ const EmailStepCard = ({
423
443
  }
424
444
  ),
425
445
  /* @__PURE__ */ jsx(
426
- "div",
446
+ Preview,
427
447
  {
428
448
  ...{
429
- className: off ? "opacity-50" : ""
449
+ id: slide
430
450
  },
431
- children: /* @__PURE__ */ jsx(Preview, { children: /* @__PURE__ */ jsx(
432
- "iframe",
451
+ children: /* @__PURE__ */ jsx(
452
+ Shown,
433
453
  {
434
454
  ...{
435
- // The rendered email, as a mail app shows it.
436
- className: "block w-full h-full border-0 bg-white",
437
- srcDoc: (preview == null ? void 0 : preview.html) || "",
438
- title
439
- }
455
+ off
456
+ },
457
+ children: /* @__PURE__ */ jsx(
458
+ Mail,
459
+ {
460
+ ...{
461
+ // The rendered email, as a mail app shows it.
462
+ html: preview == null ? void 0 : preview.html,
463
+ title
464
+ }
465
+ }
466
+ )
440
467
  }
441
- ) })
468
+ )
442
469
  }
443
470
  )
444
471
  ]
445
472
  }
446
473
  );
447
474
  };
448
- const SAMPLE = {
449
- email: "sam.rivera@example.com",
450
- name: "Sam Rivera",
451
- phone: "+14165550142"
452
- };
453
- const webhookSample = ({ campaign }) => JSON.stringify({
454
- campaign: {
455
- id: (campaign == null ? void 0 : campaign.id) || "cmp_sample",
456
- title: (campaign == null ? void 0 : campaign.title) || "Your campaign"
457
- },
458
- email: SAMPLE.email,
459
- id: "lead_sample",
460
- name: SAMPLE.name,
461
- phone: {
462
- number: SAMPLE.phone
463
- }
464
- }, null, 2);
465
- const TextPreview = ({ children }) => /* @__PURE__ */ jsx("div", { className: "p-6 font-sans", children: /* @__PURE__ */ jsx("div", { className: "max-w-xs px-4 py-3 rounded-2xl rounded-bl-sm bg-gray-light text-black break-words", children }) });
475
+ const TextPreview = ({ children }) => /* @__PURE__ */ jsx("div", { className: "p-6 font-sans", children: /* @__PURE__ */ jsx("div", { className: "max-w-xs px-4 py-3 rounded-2xl rounded-bl-sm bg-white text-black break-words", children }) });
466
476
  const StepPreview = ({ campaign, control, image, name, organization, type }) => {
467
477
  const [message] = useWatch({
468
478
  control,
@@ -475,23 +485,20 @@ const StepPreview = ({ campaign, control, image, name, organization, type }) =>
475
485
  (campaign == null ? void 0 : campaign.awarding) && /* @__PURE__ */ jsx("p", { className: "mt-2 px-2 py-1 rounded border border-dashed border-gray-dark text-gray-dark", children: "The entrant's missions appear here" }),
476
486
  /* @__PURE__ */ jsx("p", { className: "mt-2", children: "Reply STOP to opt out" })
477
487
  ] });
478
- if (type === "step.webhook.send") return /* @__PURE__ */ jsx("pre", { className: "p-6 text-xs whitespace-pre-wrap break-all font-mono", children: "X-Drawbridge-Signature: t=\u2026,v1=\u2026\n\n" + webhookSample({ campaign }) });
479
- return /* @__PURE__ */ jsxs("div", { className: "min-h-screen flex flex-col items-center justify-center gap-3 p-6 text-gray-dark", children: [
480
- image && /* @__PURE__ */ jsx(
481
- Image,
482
- {
483
- ...{
484
- alt: "",
485
- className: "w-12 h-12 object-contain",
486
- height: 48,
487
- src: image,
488
- unoptimized: true,
489
- width: 48
490
- }
488
+ if (type === "step.webhook.send") return /* @__PURE__ */ jsx(NoPreview, {});
489
+ return /* @__PURE__ */ jsx(NoPreview, { children: image && /* @__PURE__ */ jsx(
490
+ Image,
491
+ {
492
+ ...{
493
+ alt: "",
494
+ className: "w-12 h-12 object-contain",
495
+ height: 48,
496
+ src: image,
497
+ unoptimized: true,
498
+ width: 48
491
499
  }
492
- ),
493
- /* @__PURE__ */ jsx("p", { children: "No preview available" })
494
- ] });
500
+ }
501
+ ) });
495
502
  };
496
503
  const LeadEmailNote = () => /* @__PURE__ */ jsx(
497
504
  "p",
@@ -537,6 +544,7 @@ const ResponseStepCard = ({
537
544
  formState,
538
545
  off,
539
546
  onChecking,
547
+ slide,
540
548
  response: {
541
549
  autoResponse,
542
550
  campaign,
@@ -545,6 +553,8 @@ const ResponseStepCard = ({
545
553
  id,
546
554
  index,
547
555
  organization,
556
+ picked,
557
+ setPicked,
548
558
  settings,
549
559
  title,
550
560
  variables
@@ -552,7 +562,6 @@ const ResponseStepCard = ({
552
562
  setValue
553
563
  }) => {
554
564
  var _a, _b, _c, _d, _e;
555
- const [picked, setPicked] = useState("email");
556
565
  const name = `steps.${index}`;
557
566
  const parts = responseParts({ autoResponse, campaign, organization, settings });
558
567
  const shown = parts.sms.absent ? "email" : parts.email.hidden ? "sms" : parts.sms.hidden ? "email" : picked;
@@ -566,6 +575,7 @@ const ResponseStepCard = ({
566
575
  text: (_c = settings == null ? void 0 : settings.email) == null ? void 0 : _c.text
567
576
  });
568
577
  const brand = smsBrandLine(title, (_d = settings == null ? void 0 : settings.sms) == null ? void 0 : _d.message);
578
+ const target = useCard(slide);
569
579
  const partSwitch = ({ label, message, other, part }) => /* @__PURE__ */ jsx(
570
580
  Controller,
571
581
  {
@@ -605,7 +615,8 @@ const ResponseStepCard = ({
605
615
  {
606
616
  ...{
607
617
  ...card,
608
- columns: 2
618
+ ...target.props,
619
+ className: "relative shrink-0" + target.className
609
620
  },
610
621
  children: [
611
622
  /* @__PURE__ */ jsxs(
@@ -743,29 +754,29 @@ const ResponseStepCard = ({
743
754
  }
744
755
  ),
745
756
  /* @__PURE__ */ jsx(
746
- "div",
757
+ Preview,
747
758
  {
748
759
  ...{
749
- className: off || !parts[shown].on ? "opacity-50" : ""
760
+ id: slide,
761
+ ...!parts.email.hidden && !parts.sms.hidden && {
762
+ states: {
763
+ onChange: setPicked,
764
+ options: RESPONSE_STATES,
765
+ value: shown
766
+ }
767
+ }
750
768
  },
751
769
  children: /* @__PURE__ */ jsx(
752
- Preview,
770
+ Shown,
753
771
  {
754
772
  ...{
755
- ...!parts.email.hidden && !parts.sms.hidden && {
756
- states: {
757
- onChange: setPicked,
758
- options: RESPONSE_STATES,
759
- value: shown
760
- }
761
- }
773
+ off: off || !parts[shown].on
762
774
  },
763
775
  children: shown === "email" ? /* @__PURE__ */ jsx(
764
- "iframe",
776
+ Mail,
765
777
  {
766
778
  ...{
767
- className: "block w-full h-full border-0 bg-white",
768
- srcDoc: (preview == null ? void 0 : preview.html) || "",
779
+ html: preview == null ? void 0 : preview.html,
769
780
  title: "Auto response"
770
781
  }
771
782
  }
@@ -799,6 +810,54 @@ const ResponseStepCard = ({
799
810
  }
800
811
  );
801
812
  };
813
+ const PlainStepCard = ({
814
+ children,
815
+ control,
816
+ off,
817
+ preview,
818
+ slide,
819
+ ...card
820
+ }) => {
821
+ const target = useCard(slide);
822
+ return /* @__PURE__ */ jsxs(
823
+ CardSection,
824
+ {
825
+ ...{
826
+ ...card,
827
+ ...target.props,
828
+ className: "relative shrink-0" + target.className
829
+ },
830
+ children: [
831
+ children,
832
+ /* @__PURE__ */ jsx(
833
+ Preview,
834
+ {
835
+ ...{
836
+ id: slide
837
+ },
838
+ children: /* @__PURE__ */ jsx(
839
+ Shown,
840
+ {
841
+ ...{
842
+ off
843
+ },
844
+ children: preview ? /* @__PURE__ */ jsx(
845
+ StepPreview,
846
+ {
847
+ ...{
848
+ control,
849
+ ...preview
850
+ }
851
+ }
852
+ ) : /* @__PURE__ */ jsx(NoPreview, {})
853
+ }
854
+ )
855
+ }
856
+ )
857
+ ]
858
+ }
859
+ );
860
+ };
802
861
  const StepCard = ({
803
862
  children,
804
863
  control,
@@ -810,6 +869,7 @@ const StepCard = ({
810
869
  preview,
811
870
  response,
812
871
  setValue,
872
+ slide,
813
873
  ...card
814
874
  }) => response ? /* @__PURE__ */ jsx(
815
875
  ResponseStepCard,
@@ -822,7 +882,8 @@ const StepCard = ({
822
882
  off,
823
883
  onChecking,
824
884
  response,
825
- setValue
885
+ setValue,
886
+ slide
826
887
  },
827
888
  children
828
889
  }
@@ -833,37 +894,22 @@ const StepCard = ({
833
894
  card,
834
895
  control,
835
896
  email,
836
- off
897
+ off,
898
+ slide
837
899
  },
838
900
  children
839
901
  }
840
- ) : /* @__PURE__ */ jsxs(
841
- CardSection,
902
+ ) : /* @__PURE__ */ jsx(
903
+ PlainStepCard,
842
904
  {
843
905
  ...{
844
906
  ...card,
845
- columns: preview ? 2 : 1
907
+ control,
908
+ off,
909
+ preview,
910
+ slide
846
911
  },
847
- children: [
848
- children,
849
- preview && /* @__PURE__ */ jsx(
850
- "div",
851
- {
852
- ...{
853
- className: off ? "opacity-50" : ""
854
- },
855
- children: /* @__PURE__ */ jsx(Preview, { children: /* @__PURE__ */ jsx(
856
- StepPreview,
857
- {
858
- ...{
859
- control,
860
- ...preview
861
- }
862
- }
863
- ) })
864
- }
865
- )
866
- ]
912
+ children
867
913
  }
868
914
  );
869
915
  const FormOrganizationWorkflowEdit = ({
@@ -875,9 +921,10 @@ const FormOrganizationWorkflowEdit = ({
875
921
  }) => {
876
922
  var _a, _b, _c, _d, _e, _f, _g, _h;
877
923
  const event = (_a = values == null ? void 0 : values.trigger) == null ? void 0 : _a.event;
878
- const { items: memberItems, loading: membersLoading } = useOrganizationMembers(values == null ? void 0 : values.organization);
879
924
  const queryClient = useQueryClient();
880
925
  const organizationData = queryClient.getQueryData(["organization", values == null ? void 0 : values.organization]);
926
+ const membersListed = listsMembers(organizationData);
927
+ const { items: memberItems, loading: membersLoading } = useOrganizationMembers(values == null ? void 0 : values.organization, membersListed);
881
928
  const ownerEmail = organizationData.owner.email;
882
929
  const smsActive = smsNumberActive(organizationData);
883
930
  const campaignData = queryClient.getQueryData(["campaign", values == null ? void 0 : values.campaign]);
@@ -898,6 +945,7 @@ const FormOrganizationWorkflowEdit = ({
898
945
  const commerceDomain = ((_d = (_c = commerceConnection.data) == null ? void 0 : _c.source) == null ? void 0 : _d.domain) || ((_f = (_e = commerceConnection.data) == null ? void 0 : _e.settings) == null ? void 0 : _f.domain) || null;
899
946
  const defaultSteps = ((values == null ? void 0 : values.steps) || []).map((s) => stepRow(s, memberItems));
900
947
  const [checking, setChecking] = useState({});
948
+ const [responsePart, setResponsePart] = useState("email");
901
949
  const checkingAny = Object.values(checking).some(Boolean);
902
950
  const onChecking = useCallback(
903
951
  (id, value) => setChecking(
@@ -905,16 +953,13 @@ const FormOrganizationWorkflowEdit = ({
905
953
  ),
906
954
  []
907
955
  );
908
- const { control, formState, getValues, handleSubmit, setValue } = useForm({
956
+ const { control, formState, getValues, handleSubmit, reset, setValue, watch } = useForm({
909
957
  values: {
910
958
  steps: defaultSteps
911
959
  },
912
960
  resolver: resolver(workflowSchema)
913
961
  });
914
- const watchedSteps = useWatch({
915
- control,
916
- name: "steps"
917
- });
962
+ const watchedSteps = watch("steps");
918
963
  const issueIndex = issueRow({ issue: values == null ? void 0 : values.issue, steps: watchedSteps || [] });
919
964
  const getAvailableVariables = (index) => stepVariables(catalog, watchedSteps, index);
920
965
  const loading = membersLoading || commerceConnection.isLoading;
@@ -1102,6 +1147,7 @@ const FormOrganizationWorkflowEdit = ({
1102
1147
  setValue("steps." + index + ".connectionId", step.connectionId || "");
1103
1148
  setValue("steps." + index + ".slug", step.slug || "");
1104
1149
  });
1150
+ reset(getValues());
1105
1151
  onSuccess(response);
1106
1152
  } catch (error) {
1107
1153
  onError(error);
@@ -1110,6 +1156,13 @@ const FormOrganizationWorkflowEdit = ({
1110
1156
  if (loading) {
1111
1157
  return /* @__PURE__ */ jsx(LoaderDynamic, {});
1112
1158
  }
1159
+ const slides = (watchedSteps || []).map((step, index) => {
1160
+ var _a2;
1161
+ return {
1162
+ id: "step-" + index,
1163
+ title: ["Step " + (index + 1), (_a2 = ((catalog == null ? void 0 : catalog.steps) || []).find((entry) => entry.value === (step == null ? void 0 : step.type))) == null ? void 0 : _a2.key].filter(Boolean).join(" \xB7 ")
1164
+ };
1165
+ });
1113
1166
  return /* @__PURE__ */ jsx(
1114
1167
  Form,
1115
1168
  {
@@ -1117,484 +1170,488 @@ const FormOrganizationWorkflowEdit = ({
1117
1170
  className: "relative w-full",
1118
1171
  onSubmit: handleSubmit(onSubmit)
1119
1172
  },
1120
- children: /* @__PURE__ */ jsxs(
1121
- Fieldset,
1173
+ children: /* @__PURE__ */ jsx(
1174
+ SliderLayout,
1122
1175
  {
1123
1176
  ...{
1124
- disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
1177
+ plain: true,
1178
+ slides
1125
1179
  },
1126
- children: [
1127
- /* @__PURE__ */ jsx(
1128
- CardTask,
1129
- {
1130
- ...{
1131
- message: "Workflows run sequences that increase action usage.",
1132
- title: "Workflows count towards actions",
1133
- type: "warning"
1134
- }
1135
- }
1136
- ),
1137
- /* @__PURE__ */ jsxs(
1138
- CardSection,
1139
- {
1140
- ...{
1141
- "data-trigger": true,
1142
- title: "Trigger"
1143
- },
1144
- children: [
1145
- /* @__PURE__ */ jsx("p", { children: values == null ? void 0 : values.title }),
1146
- (values == null ? void 0 : values.description) && /* @__PURE__ */ jsx(
1147
- "p",
1148
- {
1149
- ...{
1150
- className: "text-sm text-gray-dark"
1151
- },
1152
- children: values.description
1153
- }
1154
- )
1155
- ]
1156
- }
1157
- ),
1158
- /* @__PURE__ */ jsx(
1159
- InputGroup,
1160
- {
1161
- ...{
1162
- error: (_h = (_g = formState == null ? void 0 : formState.errors) == null ? void 0 : _g.steps) == null ? void 0 : _h.message,
1163
- input: /* @__PURE__ */ jsx(
1164
- InputArraySortable,
1165
- {
1166
- ...{
1167
- control,
1168
- empty: null,
1169
- name: "steps",
1170
- renderButton: (append) => /* @__PURE__ */ jsx(
1171
- InputArrayButton,
1172
- {
1173
- ...{
1174
- disabled: !canAddStep,
1175
- onClick: () => append(stepRow()),
1176
- text: "Add step"
1177
- }
1178
- }
1179
- )
1180
- },
1181
- children: ({ field, handle, index, remove }) => {
1182
- var _a2;
1183
- const step = (watchedSteps == null ? void 0 : watchedSteps[index]) || field;
1184
- const parts = step.type === RESPONSE && responseParts({
1185
- autoResponse: values == null ? void 0 : values.autoResponse,
1186
- campaign: values == null ? void 0 : values.campaign,
1187
- organization: values == null ? void 0 : values.organization,
1188
- settings: step.settings
1189
- });
1190
- const stepOptions = getStepOptions(index);
1191
- return (
1192
- // @story workflows/edit
1193
- // EACH STEP IS ITS OWN CARD in the flow under the Trigger card,
1194
- // edited in place: the drag handle left of Step N, as every
1195
- // sortable list has it, then its connection badge and Remove
1196
- // in the card's head, its fields in the body.
1197
- /* @__PURE__ */ jsx(
1198
- StepCard,
1180
+ children: /* @__PURE__ */ jsx(
1181
+ Fieldset,
1182
+ {
1183
+ ...{
1184
+ disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
1185
+ },
1186
+ children: /* @__PURE__ */ jsxs(
1187
+ CardSection,
1188
+ {
1189
+ ...{
1190
+ title: "Sequence",
1191
+ variant: "gray"
1192
+ },
1193
+ children: [
1194
+ /* @__PURE__ */ jsx(
1195
+ InputGroup,
1196
+ {
1197
+ ...{
1198
+ error: (_h = (_g = formState == null ? void 0 : formState.errors) == null ? void 0 : _g.steps) == null ? void 0 : _h.message,
1199
+ input: /* @__PURE__ */ jsx(
1200
+ InputArraySortable,
1199
1201
  {
1200
1202
  ...{
1201
1203
  control,
1202
- disabled: disabled || (formState == null ? void 0 : formState.isSubmitting),
1203
- formState,
1204
- onChecking,
1205
- setValue,
1206
- // @story workflows/auto-response
1207
- response: step.type === RESPONSE && {
1208
- autoResponse: values == null ? void 0 : values.autoResponse,
1209
- campaign: values == null ? void 0 : values.campaign,
1210
- enabled: step.enabled,
1211
- event,
1212
- id: field.id,
1213
- index,
1214
- organization: values == null ? void 0 : values.organization,
1215
- settings: step.settings,
1216
- title: organizationData == null ? void 0 : organizationData.title,
1217
- variables: getAvailableVariables(index)
1218
- },
1219
- // @story workflows/send-email
1220
- // A Send email step shows its email beside its form.
1221
- off: step.enabled === false,
1222
- // Every other step with a type has its preview too.
1223
- preview: step.type && !renderedSteps.includes(step.type) && {
1224
- campaign: campaignData,
1225
- image: ((_a2 = ((catalog == null ? void 0 : catalog.steps) || []).find((entry) => entry.value === step.type)) == null ? void 0 : _a2.image) || null,
1226
- name: `steps.${index}`,
1227
- organization: organizationData,
1228
- type: step.type
1204
+ empty: null,
1205
+ // Each handle says which step it moves.
1206
+ handleLabel: (field) => {
1207
+ var _a2;
1208
+ return "Move " + (((_a2 = ((catalog == null ? void 0 : catalog.steps) || []).find((entry) => entry.value === (field == null ? void 0 : field.type))) == null ? void 0 : _a2.key) || "step");
1229
1209
  },
1230
- // Send email and Email notification show the email the api renders.
1231
- email: renderedSteps.includes(step.type) && {
1232
- campaign: values == null ? void 0 : values.campaign,
1233
- event,
1234
- name: `steps.${index}`,
1235
- organization: values == null ? void 0 : values.organization,
1236
- title: emailSteps.includes(step.type) ? "Send email" : "Email notification",
1237
- type: step.type
1238
- },
1239
- cta: /* @__PURE__ */ jsxs(
1240
- "span",
1210
+ name: "steps",
1211
+ renderButton: (append) => /* @__PURE__ */ jsx(
1212
+ InputArrayButton,
1241
1213
  {
1242
1214
  ...{
1243
- className: "flex items-center gap-2"
1244
- },
1245
- children: [
1246
- renderStepBadge(step, index),
1247
- !lockedStep(index) && /* @__PURE__ */ jsx(
1248
- InputArrayControl,
1249
- {
1250
- ...{
1251
- onClick: () => remove(index),
1252
- icon: Trash
1253
- }
1215
+ disabled: !canAddStep,
1216
+ onClick: () => append(stepRow()),
1217
+ text: "Add step"
1218
+ }
1219
+ }
1220
+ )
1221
+ },
1222
+ children: ({ field, handle, index, remove }) => {
1223
+ var _a2;
1224
+ const step = (watchedSteps == null ? void 0 : watchedSteps[index]) || field;
1225
+ const parts = step.type === RESPONSE && responseParts({
1226
+ autoResponse: values == null ? void 0 : values.autoResponse,
1227
+ campaign: values == null ? void 0 : values.campaign,
1228
+ organization: values == null ? void 0 : values.organization,
1229
+ settings: step.settings
1230
+ });
1231
+ const stepOptions = getStepOptions(index);
1232
+ return (
1233
+ // @story workflows/edit
1234
+ // EACH STEP IS ITS OWN CARD in the flow under the Trigger card,
1235
+ // edited in place: the drag handle left of Step N, as every
1236
+ // sortable list has it, then its connection badge and Remove
1237
+ // in the card's head, its fields in the body.
1238
+ /* @__PURE__ */ jsx(
1239
+ StepCard,
1240
+ {
1241
+ ...{
1242
+ control,
1243
+ disabled: disabled || (formState == null ? void 0 : formState.isSubmitting),
1244
+ formState,
1245
+ onChecking,
1246
+ setValue,
1247
+ // @story workflows/auto-response
1248
+ response: step.type === RESPONSE && {
1249
+ autoResponse: values == null ? void 0 : values.autoResponse,
1250
+ campaign: values == null ? void 0 : values.campaign,
1251
+ enabled: step.enabled,
1252
+ event,
1253
+ id: field.id,
1254
+ index,
1255
+ organization: values == null ? void 0 : values.organization,
1256
+ picked: responsePart,
1257
+ setPicked: setResponsePart,
1258
+ settings: step.settings,
1259
+ title: organizationData == null ? void 0 : organizationData.title,
1260
+ variables: getAvailableVariables(index)
1254
1261
  },
1255
- "remove"
1256
- ),
1257
- /* @__PURE__ */ jsx(
1258
- Controller,
1259
- {
1260
- ...{
1261
- control,
1262
- name: `steps.${index}.enabled`,
1263
- render: ({ field: { onChange, value } }) => {
1264
- var _a3;
1265
- return /* @__PURE__ */ jsx(
1266
- InputSwitch,
1262
+ // @story workflows/send-email
1263
+ // A Send email step shows its email beside its form.
1264
+ off: step.enabled === false,
1265
+ // Every other step with a type has its preview too.
1266
+ preview: step.type && !renderedSteps.includes(step.type) && {
1267
+ campaign: campaignData,
1268
+ image: ((_a2 = ((catalog == null ? void 0 : catalog.steps) || []).find((entry) => entry.value === step.type)) == null ? void 0 : _a2.image) || null,
1269
+ name: `steps.${index}`,
1270
+ organization: organizationData,
1271
+ type: step.type
1272
+ },
1273
+ // Send email and Email notification show the email the api renders.
1274
+ email: renderedSteps.includes(step.type) && {
1275
+ campaign: values == null ? void 0 : values.campaign,
1276
+ event,
1277
+ name: `steps.${index}`,
1278
+ organization: values == null ? void 0 : values.organization,
1279
+ title: emailSteps.includes(step.type) ? "Send email" : "Email notification",
1280
+ type: step.type
1281
+ },
1282
+ cta: /* @__PURE__ */ jsxs(
1283
+ "span",
1284
+ {
1285
+ ...{
1286
+ className: "flex items-center gap-2"
1287
+ },
1288
+ children: [
1289
+ renderStepBadge(step, index),
1290
+ !lockedStep(index) && /* @__PURE__ */ jsx(
1291
+ InputArrayControl,
1267
1292
  {
1268
1293
  ...{
1269
- "aria-label": ((_a3 = ((catalog == null ? void 0 : catalog.steps) || []).find((entry) => entry.value === step.type)) == null ? void 0 : _a3.key) || "Step " + (index + 1),
1270
- disabled: disabled || (formState == null ? void 0 : formState.isSubmitting) || lockedStep(index) || parts && !parts.can,
1271
- onChange: (next) => {
1272
- onChange(next);
1273
- if (parts && next && partToStart(parts)) setValue(`steps.${index}.settings.${partToStart(parts)}.enabled`, true);
1274
- },
1275
- small: true,
1276
- value: value !== false && (!parts || parts.can)
1294
+ onClick: () => remove(index),
1295
+ icon: Trash
1296
+ }
1297
+ },
1298
+ "remove"
1299
+ ),
1300
+ /* @__PURE__ */ jsx(
1301
+ Controller,
1302
+ {
1303
+ ...{
1304
+ control,
1305
+ name: `steps.${index}.enabled`,
1306
+ render: ({ field: { onChange, value } }) => {
1307
+ var _a3;
1308
+ return /* @__PURE__ */ jsx(
1309
+ InputSwitch,
1310
+ {
1311
+ ...{
1312
+ "aria-label": ((_a3 = ((catalog == null ? void 0 : catalog.steps) || []).find((entry) => entry.value === step.type)) == null ? void 0 : _a3.key) || "Step " + (index + 1),
1313
+ disabled: disabled || (formState == null ? void 0 : formState.isSubmitting) || lockedStep(index) || parts && !parts.can,
1314
+ onChange: (next) => {
1315
+ onChange(next);
1316
+ if (parts && next && partToStart(parts)) setValue(`steps.${index}.settings.${partToStart(parts)}.enabled`, true);
1317
+ },
1318
+ small: true,
1319
+ value: value !== false && (!parts || parts.can)
1320
+ }
1321
+ }
1322
+ );
1323
+ }
1277
1324
  }
1278
1325
  }
1279
- );
1280
- }
1326
+ )
1327
+ ]
1281
1328
  }
1282
- }
1283
- )
1284
- ]
1285
- }
1286
- ),
1287
- "data-step": index + 1,
1288
- title: /* @__PURE__ */ jsxs(
1289
- "span",
1290
- {
1291
- ...{
1292
- className: "flex items-center gap-2"
1293
- },
1294
- children: [
1295
- handle,
1296
- "Step " + (index + 1)
1297
- ]
1298
- }
1299
- )
1300
- },
1301
- children: /* @__PURE__ */ jsxs(
1302
- "div",
1303
- {
1304
- ...{
1305
- // A step switched off is greyed; its settings are kept.
1306
- // Auto response's whole card greys, its parts as well.
1307
- className: "space-y-3" + (step.enabled === false && !parts ? " opacity-50" : "")
1308
- },
1309
- children: [
1310
- issueIndex === index && /* @__PURE__ */ jsx(
1311
- Error,
1312
- {
1313
- ...{
1314
- error: values.issue.message
1315
- }
1316
- }
1317
- ),
1318
- /* @__PURE__ */ jsx(
1319
- Controller,
1320
- {
1321
- ...{
1322
- control,
1323
- name: `steps.${index}.type`,
1324
- render: ({ field: { onChange } }) => {
1325
- var _a3, _b2, _c2, _d2;
1326
- return /* @__PURE__ */ jsx(
1327
- InputGroup,
1329
+ ),
1330
+ "data-step": index + 1,
1331
+ slide: "step-" + index,
1332
+ title: /* @__PURE__ */ jsxs(
1333
+ "span",
1334
+ {
1335
+ ...{
1336
+ className: "flex items-center gap-2"
1337
+ },
1338
+ children: [
1339
+ handle,
1340
+ "Step " + (index + 1)
1341
+ ]
1342
+ }
1343
+ )
1344
+ },
1345
+ children: /* @__PURE__ */ jsxs(
1346
+ "div",
1347
+ {
1348
+ ...{
1349
+ // A step switched off is greyed; its settings are kept.
1350
+ // Auto response's whole card greys, its parts as well.
1351
+ className: "space-y-3" + (step.enabled === false && !parts ? " opacity-50" : "")
1352
+ },
1353
+ children: [
1354
+ issueIndex === index && /* @__PURE__ */ jsx(
1355
+ Error,
1328
1356
  {
1329
1357
  ...{
1330
- error: (_d2 = (_c2 = (_b2 = (_a3 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a3.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.type) == null ? void 0 : _d2.message,
1331
- input: /* @__PURE__ */ jsx(
1332
- InputCombobox,
1333
- {
1334
- ...{
1335
- onChange: (val) => {
1336
- var _a4;
1337
- const [type] = val.split("::");
1338
- const option = getStepOptions(index).find((o) => o.value === val);
1339
- const copy = pickedCopy({ row: getValues(`steps.${index}`), type });
1340
- setValue(`steps.${index}.settings`, type === RESPONSE ? responseStart((_a4 = values == null ? void 0 : values.autoResponse) == null ? void 0 : _a4.number) : null);
1341
- onChange(type);
1342
- setValue(`steps.${index}.connectionId`, (option == null ? void 0 : option.connectionId) || "");
1343
- setValue(`steps.${index}.slug`, (option == null ? void 0 : option.slug) || "");
1344
- if (copy) Object.entries(copy).forEach(([key, value]) => setValue(`steps.${index}.${key}`, value));
1345
- },
1346
- // Locked for a member on the owner's step; disabled
1347
- // with nothing left to pick.
1348
- disabled: lockedStep(index) || !hasStepOptions(stepOptions),
1349
- options: stepOptions,
1350
- // Resolved from the WHOLE ROW, not from this path: the
1351
- // option value carries a connection the type alone cannot
1352
- // name.
1353
- value: getStepValue(step, index)
1358
+ error: values.issue.message
1359
+ }
1360
+ }
1361
+ ),
1362
+ /* @__PURE__ */ jsx(
1363
+ Controller,
1364
+ {
1365
+ ...{
1366
+ control,
1367
+ name: `steps.${index}.type`,
1368
+ render: ({ field: { onChange } }) => {
1369
+ var _a3, _b2, _c2, _d2;
1370
+ return /* @__PURE__ */ jsx(
1371
+ InputGroup,
1372
+ {
1373
+ ...{
1374
+ error: (_d2 = (_c2 = (_b2 = (_a3 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a3.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.type) == null ? void 0 : _d2.message,
1375
+ input: /* @__PURE__ */ jsx(
1376
+ InputCombobox,
1377
+ {
1378
+ ...{
1379
+ onChange: (val) => {
1380
+ var _a4;
1381
+ const [type] = val.split("::");
1382
+ const option = getStepOptions(index).find((o) => o.value === val);
1383
+ const copy = pickedCopy({ row: getValues(`steps.${index}`), type });
1384
+ setValue(`steps.${index}.settings`, type === RESPONSE ? responseStart((_a4 = values == null ? void 0 : values.autoResponse) == null ? void 0 : _a4.number) : null);
1385
+ onChange(type);
1386
+ setValue(`steps.${index}.connectionId`, (option == null ? void 0 : option.connectionId) || "");
1387
+ setValue(`steps.${index}.slug`, (option == null ? void 0 : option.slug) || "");
1388
+ if (copy) Object.entries(copy).forEach(([key, value]) => setValue(`steps.${index}.${key}`, value));
1389
+ },
1390
+ // Locked for a member on the owner's step; disabled
1391
+ // with nothing left to pick.
1392
+ disabled: lockedStep(index) || !hasStepOptions(stepOptions),
1393
+ options: stepOptions,
1394
+ // Resolved from the WHOLE ROW, not from this path: the
1395
+ // option value carries a connection the type alone cannot
1396
+ // name.
1397
+ value: getStepValue(step, index)
1398
+ }
1399
+ }
1400
+ ),
1401
+ label: "Step"
1402
+ }
1354
1403
  }
1355
- }
1356
- ),
1357
- label: "Step"
1404
+ );
1405
+ }
1358
1406
  }
1359
1407
  }
1360
- );
1361
- }
1362
- }
1363
- }
1364
- ),
1365
- firstEntryOnly({ campaign: campaignData, event, type: step.type }) && /* @__PURE__ */ jsx(
1366
- "p",
1367
- {
1368
- ...{
1369
- className: "text-sm text-gray-dark"
1370
- },
1371
- children: "Runs on a person's first entry only."
1372
- }
1373
- ),
1374
- step.type === "step.webhook.send" && /* @__PURE__ */ jsx(
1375
- Controller,
1376
- {
1377
- ...{
1378
- control,
1379
- name: `steps.${index}.url`,
1380
- render: ({ field: { value, onChange } }) => {
1381
- var _a3, _b2, _c2, _d2;
1382
- return /* @__PURE__ */ jsx(
1383
- InputGroup,
1408
+ ),
1409
+ firstEntryOnly({ campaign: campaignData, event, type: step.type }) && /* @__PURE__ */ jsx(
1410
+ "p",
1411
+ {
1412
+ ...{
1413
+ className: "text-sm text-gray-dark"
1414
+ },
1415
+ children: "Runs on a person's first entry only."
1416
+ }
1417
+ ),
1418
+ step.type === "step.webhook.send" && /* @__PURE__ */ jsx(
1419
+ Controller,
1384
1420
  {
1385
1421
  ...{
1386
- error: (_d2 = (_c2 = (_b2 = (_a3 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a3.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.url) == null ? void 0 : _d2.message,
1387
- input: /* @__PURE__ */ jsx(
1388
- InputUrl,
1389
- {
1390
- ...{
1391
- onChange,
1392
- value: value || ""
1422
+ control,
1423
+ name: `steps.${index}.url`,
1424
+ render: ({ field: { value, onChange } }) => {
1425
+ var _a3, _b2, _c2, _d2;
1426
+ return /* @__PURE__ */ jsx(
1427
+ InputGroup,
1428
+ {
1429
+ ...{
1430
+ error: (_d2 = (_c2 = (_b2 = (_a3 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a3.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.url) == null ? void 0 : _d2.message,
1431
+ input: /* @__PURE__ */ jsx(
1432
+ InputUrl,
1433
+ {
1434
+ ...{
1435
+ onChange,
1436
+ value: value || ""
1437
+ }
1438
+ }
1439
+ ),
1440
+ label: "Webhook URL"
1441
+ }
1393
1442
  }
1394
- }
1395
- ),
1396
- label: "Webhook URL"
1443
+ );
1444
+ }
1397
1445
  }
1398
1446
  }
1399
- );
1400
- }
1401
- }
1402
- }
1403
- ),
1404
- teamSteps.includes(step.type) && lockedStep(index) && /* @__PURE__ */ jsx("p", { className: "text-sm text-gray-500", children: "Recipients are chosen by the organization owner." }),
1405
- teamSteps.includes(step.type) && !lockedStep(index) && /* @__PURE__ */ jsx(
1406
- Controller,
1407
- {
1408
- ...{
1409
- control,
1410
- name: `steps.${index}.members`,
1411
- render: ({ field: { value, onChange } }) => {
1412
- var _a3, _b2, _c2, _d2;
1413
- return /* @__PURE__ */ jsx(
1414
- InputGroup,
1447
+ ),
1448
+ teamSteps.includes(step.type) && lockedStep(index) && /* @__PURE__ */ jsx("p", { className: "text-sm text-gray-500", children: "Recipients are chosen by the organization owner." }),
1449
+ teamSteps.includes(step.type) && !lockedStep(index) && /* @__PURE__ */ jsx(
1450
+ Controller,
1415
1451
  {
1416
1452
  ...{
1417
- error: (_d2 = (_c2 = (_b2 = (_a3 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a3.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.members) == null ? void 0 : _d2.message,
1418
- input: /* @__PURE__ */ jsx(
1419
- InputResource,
1420
- {
1421
- ...{
1422
- empty: "No members to add",
1423
- endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/members",
1424
- // The owner is a chip like the others, only it cannot be
1425
- // removed: they are always a recipient and it is resolved
1426
- // in sync. Shaped like a member so `render` labels it the
1427
- // same way.
1428
- fixed: [{ email: ownerEmail }],
1429
- model: "member",
1430
- multiple: true,
1431
- onChange,
1432
- params: memberParams,
1433
- render: memberLabel,
1434
- // The row shows the name ( memberLabel ), so the search has
1435
- // to hit the name too. The members endpoint joins `user`
1436
- // before its search stage, so the nested keys resolve.
1437
- // Email stays for invitees who have not registered yet.
1438
- // ponytail: a full "First Last" query matches neither key;
1439
- // a $concat'd name on the API side if that comes up.
1440
- searchKeys: ["email", "user.firstName", "user.lastName"],
1441
- value: value || []
1453
+ control,
1454
+ name: `steps.${index}.members`,
1455
+ render: ({ field: { value, onChange } }) => {
1456
+ var _a3, _b2, _c2, _d2;
1457
+ return /* @__PURE__ */ jsx(
1458
+ InputGroup,
1459
+ {
1460
+ ...{
1461
+ error: (_d2 = (_c2 = (_b2 = (_a3 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a3.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.members) == null ? void 0 : _d2.message,
1462
+ input: /* @__PURE__ */ jsx(
1463
+ InputResource,
1464
+ {
1465
+ ...{
1466
+ empty: "No members to add",
1467
+ endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/members",
1468
+ // The owner is a chip like the others, only it cannot be
1469
+ // removed: they are always a recipient and it is resolved
1470
+ // in sync. Shaped like a member so `render` labels it the
1471
+ // same way.
1472
+ fixed: [{ email: ownerEmail }],
1473
+ model: "member",
1474
+ multiple: true,
1475
+ onChange,
1476
+ params: memberParams,
1477
+ // No Add member where the list cannot be read.
1478
+ picker: membersListed,
1479
+ render: memberLabel,
1480
+ // The row shows the name ( memberLabel ), so the search has
1481
+ // to hit the name too. The members endpoint joins `user`
1482
+ // before its search stage, so the nested keys resolve.
1483
+ // Email stays for invitees who have not registered yet.
1484
+ // ponytail: a full "First Last" query matches neither key;
1485
+ // a $concat'd name on the API side if that comes up.
1486
+ searchKeys: ["email", "user.firstName", "user.lastName"],
1487
+ value: value || []
1488
+ }
1489
+ }
1490
+ ),
1491
+ label: "Recipients"
1492
+ }
1442
1493
  }
1443
- }
1444
- ),
1445
- label: "Recipients"
1494
+ );
1495
+ }
1446
1496
  }
1447
1497
  }
1448
- );
1449
- }
1450
- }
1451
- }
1452
- ),
1453
- emailSteps.includes(step.type) && /* @__PURE__ */ jsx(
1454
- FormNotification,
1455
- {
1456
- ...{
1457
- control,
1458
- // As the Fieldset above: the Message editor is a
1459
- // contenteditable, which a disabled fieldset never reaches.
1460
- disabled: disabled || (formState == null ? void 0 : formState.isSubmitting),
1461
- formState,
1462
- onChecking,
1463
- setValue,
1464
- values: {
1465
- id: field.id,
1466
- name: `steps.${index}`,
1467
- organization: values == null ? void 0 : values.organization,
1468
- variables: getAvailableVariables(index)
1469
- }
1470
- }
1471
- }
1472
- ),
1473
- event === "lead.insert" && emailSteps.includes(step.type) && /* @__PURE__ */ jsx(LeadEmailNote, {}),
1474
- step.type === "step.sms.send" && /* @__PURE__ */ jsx(
1475
- Controller,
1476
- {
1477
- ...{
1478
- control,
1479
- name: `steps.${index}.message`,
1480
- render: ({ field: { value, onChange } }) => {
1481
- var _a3, _b2, _c2, _d2;
1482
- return /* @__PURE__ */ jsx(
1483
- InputGroup,
1498
+ ),
1499
+ emailSteps.includes(step.type) && /* @__PURE__ */ jsx(
1500
+ FormNotification,
1501
+ {
1502
+ ...{
1503
+ control,
1504
+ // As the Fieldset above: the Message editor is a
1505
+ // contenteditable, which a disabled fieldset never reaches.
1506
+ disabled: disabled || (formState == null ? void 0 : formState.isSubmitting),
1507
+ formState,
1508
+ onChecking,
1509
+ setValue,
1510
+ values: {
1511
+ id: field.id,
1512
+ name: `steps.${index}`,
1513
+ organization: values == null ? void 0 : values.organization,
1514
+ variables: getAvailableVariables(index)
1515
+ }
1516
+ }
1517
+ }
1518
+ ),
1519
+ event === "lead.insert" && emailSteps.includes(step.type) && /* @__PURE__ */ jsx(LeadEmailNote, {}),
1520
+ step.type === "step.sms.send" && /* @__PURE__ */ jsx(
1521
+ Controller,
1484
1522
  {
1485
1523
  ...{
1486
- error: (_d2 = (_c2 = (_b2 = (_a3 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a3.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.message) == null ? void 0 : _d2.message,
1487
- input: /* @__PURE__ */ jsx(
1488
- InputTextarea,
1489
- {
1490
- ...{
1491
- onChange,
1492
- rows: 3,
1493
- value: value || ""
1524
+ control,
1525
+ name: `steps.${index}.message`,
1526
+ render: ({ field: { value, onChange } }) => {
1527
+ var _a3, _b2, _c2, _d2;
1528
+ return /* @__PURE__ */ jsx(
1529
+ InputGroup,
1530
+ {
1531
+ ...{
1532
+ error: (_d2 = (_c2 = (_b2 = (_a3 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a3.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.message) == null ? void 0 : _d2.message,
1533
+ input: /* @__PURE__ */ jsx(
1534
+ InputTextarea,
1535
+ {
1536
+ ...{
1537
+ onChange,
1538
+ rows: 3,
1539
+ value: value || ""
1540
+ }
1541
+ }
1542
+ ),
1543
+ label: "Message"
1544
+ }
1494
1545
  }
1495
- }
1496
- ),
1497
- label: "Message"
1546
+ );
1547
+ }
1498
1548
  }
1499
1549
  }
1500
- );
1501
- }
1502
- }
1503
- }
1504
- ),
1505
- step.type === "step.commerce.code.issue" && /* @__PURE__ */ jsx(
1506
- Controller,
1507
- {
1508
- ...{
1509
- control,
1510
- name: `steps.${index}.discount`,
1511
- render: ({ field: { value, onChange } }) => {
1512
- var _a3, _b2, _c2, _d2;
1513
- return /* @__PURE__ */ jsx(
1514
- InputGroup,
1550
+ ),
1551
+ step.type === "step.commerce.code.issue" && /* @__PURE__ */ jsx(
1552
+ Controller,
1515
1553
  {
1516
1554
  ...{
1517
- error: (_d2 = (_c2 = (_b2 = (_a3 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a3.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.discount) == null ? void 0 : _d2.message,
1518
- input: /* @__PURE__ */ jsx(
1519
- InputResource,
1520
- {
1521
- ...{
1522
- endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/connection/" + commerceConnectionId + "/hook/browse.promotions",
1523
- model: "discount",
1524
- onChange,
1525
- // A DISCOUNT THE STORE CANNOT BACK IS SHOWN AND EXPLAINED, never
1526
- // filtered out. The merchant can see it in Shopify admin, so a row
1527
- // missing here with no reason reads as our bug rather than their
1528
- // setting — and the reason names the fix.
1529
- render: (item) => /* @__PURE__ */ jsxs("div", { children: [
1530
- /* @__PURE__ */ jsx("span", { className: (item == null ? void 0 : item.blocked) ? "text-gray-dark" : void 0, children: item == null ? void 0 : item.title }),
1531
- ((item == null ? void 0 : item.blocked) || (item == null ? void 0 : item.warning)) && /* @__PURE__ */ jsx("span", { className: "block text-sm text-gray-dark", children: item.blocked || item.warning })
1532
- ] }),
1533
- renderButton: ({ button, item }) => (
1534
- // The list's small inline Add, unless the list says otherwise.
1535
- /* @__PURE__ */ jsx(
1536
- Button,
1555
+ control,
1556
+ name: `steps.${index}.discount`,
1557
+ render: ({ field: { value, onChange } }) => {
1558
+ var _a3, _b2, _c2, _d2;
1559
+ return /* @__PURE__ */ jsx(
1560
+ InputGroup,
1561
+ {
1562
+ ...{
1563
+ error: (_d2 = (_c2 = (_b2 = (_a3 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a3.steps) == null ? void 0 : _b2[index]) == null ? void 0 : _c2.discount) == null ? void 0 : _d2.message,
1564
+ input: /* @__PURE__ */ jsx(
1565
+ InputResource,
1537
1566
  {
1538
1567
  ...{
1539
- inline: true,
1540
- size: "small",
1541
- ...button.props,
1542
- disabled: Boolean(item == null ? void 0 : item.blocked),
1543
- title: (item == null ? void 0 : item.blocked) || void 0
1544
- },
1545
- children: button.text
1568
+ endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/connection/" + commerceConnectionId + "/hook/browse.promotions",
1569
+ model: "discount",
1570
+ onChange,
1571
+ // A DISCOUNT THE STORE CANNOT BACK IS SHOWN AND EXPLAINED, never
1572
+ // filtered out. The merchant can see it in Shopify admin, so a row
1573
+ // missing here with no reason reads as our bug rather than their
1574
+ // setting — and the reason names the fix.
1575
+ render: (item) => /* @__PURE__ */ jsxs("div", { children: [
1576
+ /* @__PURE__ */ jsx("span", { className: (item == null ? void 0 : item.blocked) ? "text-gray-dark" : void 0, children: item == null ? void 0 : item.title }),
1577
+ ((item == null ? void 0 : item.blocked) || (item == null ? void 0 : item.warning)) && /* @__PURE__ */ jsx("span", { className: "block text-sm text-gray-dark", children: item.blocked || item.warning })
1578
+ ] }),
1579
+ renderButton: ({ button, item }) => (
1580
+ // The list's small inline Add, unless the list says otherwise.
1581
+ /* @__PURE__ */ jsx(
1582
+ Button,
1583
+ {
1584
+ ...{
1585
+ inline: true,
1586
+ size: "small",
1587
+ ...button.props,
1588
+ disabled: Boolean(item == null ? void 0 : item.blocked),
1589
+ title: (item == null ? void 0 : item.blocked) || void 0
1590
+ },
1591
+ children: button.text
1592
+ }
1593
+ )
1594
+ ),
1595
+ value: value || null
1596
+ }
1546
1597
  }
1547
- )
1548
- ),
1549
- value: value || null
1598
+ ),
1599
+ label: "Discount",
1600
+ // "Issue" means MINT, not send — this step creates the code and saves
1601
+ // it to the lead, and nothing reaches them until a later email step
1602
+ // names the variable. Said here because the step picker says nothing:
1603
+ // QA read "Issue a discount code", built the one-step workflow that
1604
+ // describes, and reported the codes as never arriving.
1605
+ message: /* @__PURE__ */ jsxs(Fragment, { children: [
1606
+ "Creates the code and saves it to the lead. To send it, keep this step before Auto response and add Shopify Discount Code to its message.",
1607
+ commerceDomain ? /* @__PURE__ */ jsxs(Fragment, { children: [
1608
+ " ",
1609
+ /* @__PURE__ */ jsx("a", { href: "https://" + commerceDomain + "/admin/discounts", rel: "noopener noreferrer", target: "_blank", children: "Manage discounts" })
1610
+ ] }) : null
1611
+ ] })
1612
+ }
1550
1613
  }
1551
- }
1552
- ),
1553
- label: "Discount",
1554
- // "Issue" means MINT, not send — this step creates the code and saves
1555
- // it to the lead, and nothing reaches them until a later email step
1556
- // names the variable. Said here because the step picker says nothing:
1557
- // QA read "Issue a discount code", built the one-step workflow that
1558
- // describes, and reported the codes as never arriving.
1559
- message: /* @__PURE__ */ jsxs(Fragment, { children: [
1560
- "Creates the code and saves it to the lead. To send it, keep this step before Auto response and add Shopify Discount Code to its message.",
1561
- commerceDomain ? /* @__PURE__ */ jsxs(Fragment, { children: [
1562
- " ",
1563
- /* @__PURE__ */ jsx("a", { href: "https://" + commerceDomain + "/admin/discounts", rel: "noopener noreferrer", target: "_blank", children: "Manage discounts" })
1564
- ] }) : null
1565
- ] })
1614
+ );
1615
+ }
1566
1616
  }
1567
1617
  }
1568
- );
1569
- }
1618
+ )
1619
+ ]
1570
1620
  }
1571
- }
1572
- )
1573
- ]
1574
- }
1575
- )
1621
+ )
1622
+ }
1623
+ )
1624
+ );
1625
+ }
1576
1626
  }
1577
1627
  )
1578
- );
1628
+ }
1579
1629
  }
1580
- }
1581
- ),
1582
- label: "Sequence"
1630
+ ),
1631
+ /* @__PURE__ */ jsx(
1632
+ "div",
1633
+ {
1634
+ ...{
1635
+ className: "pt-6"
1636
+ },
1637
+ children: /* @__PURE__ */ jsx(
1638
+ Button,
1639
+ {
1640
+ ...{
1641
+ disabled: checkingAny,
1642
+ loading: (formState == null ? void 0 : formState.isSubmitting) || checkingAny,
1643
+ type: "submit"
1644
+ },
1645
+ children: "Save"
1646
+ }
1647
+ )
1648
+ }
1649
+ )
1650
+ ]
1583
1651
  }
1584
- }
1585
- ),
1586
- /* @__PURE__ */ jsx(
1587
- Button,
1588
- {
1589
- ...{
1590
- disabled: checkingAny,
1591
- loading: (formState == null ? void 0 : formState.isSubmitting) || checkingAny,
1592
- type: "submit"
1593
- },
1594
- children: "Save"
1595
- }
1596
- )
1597
- ]
1652
+ )
1653
+ }
1654
+ )
1598
1655
  }
1599
1656
  )
1600
1657
  }
@@ -1603,11 +1660,11 @@ const FormOrganizationWorkflowEdit = ({
1603
1660
  export {
1604
1661
  FormOrganizationWorkflowEdit,
1605
1662
  RESPONSE,
1606
- SAMPLE,
1607
1663
  TextPreview,
1608
1664
  firstEntryOnly,
1609
1665
  hasStepOptions,
1610
1666
  issueRow,
1667
+ listsMembers,
1611
1668
  memberOptions,
1612
1669
  partToStart,
1613
1670
  pickedCopy,
@@ -1620,7 +1677,7 @@ export {
1620
1677
  stepReason,
1621
1678
  stepRow,
1622
1679
  stepVariables,
1680
+ useEmailPreview,
1623
1681
  useStepPrefill,
1624
- webhookSample,
1625
1682
  workflowSchema
1626
1683
  };