@shware/workflow-ui 0.0.0-stage → 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +180 -2
- package/dist/assets/iphone-17-pro-DzaacWSl.png +0 -0
- package/dist/assets/pixel-10-pro-back-7MDj1_lz.webp +0 -0
- package/dist/assets/pixel-10-pro-mask-Bi1deQ9Y.webp +0 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +673 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/config.d.mts +247 -0
- package/dist/config.d.mts.map +1 -0
- package/dist/config.mjs +27 -0
- package/dist/config.mjs.map +1 -0
- package/dist/index.d.mts +451 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2722 -0
- package/dist/index.mjs.map +1 -0
- package/dist/postgres.d.mts +34 -0
- package/dist/postgres.d.mts.map +1 -0
- package/dist/postgres.mjs +313 -0
- package/dist/postgres.mjs.map +1 -0
- package/package.json +93 -3
- package/src/app/assets/devices/iphone-17-pro.png +0 -0
- package/src/app/assets/devices/pixel-10-pro-back.webp +0 -0
- package/src/app/assets/devices/pixel-10-pro-mask.webp +0 -0
- package/src/app/assets/flags/AC.svg +1 -0
- package/src/app/assets/flags/AD.svg +1 -0
- package/src/app/assets/flags/AE.svg +1 -0
- package/src/app/assets/flags/AF.svg +1 -0
- package/src/app/assets/flags/AG.svg +1 -0
- package/src/app/assets/flags/AI.svg +1 -0
- package/src/app/assets/flags/AL.svg +1 -0
- package/src/app/assets/flags/AM.svg +1 -0
- package/src/app/assets/flags/AO.svg +1 -0
- package/src/app/assets/flags/AQ.svg +1 -0
- package/src/app/assets/flags/AR.svg +1 -0
- package/src/app/assets/flags/AS.svg +1 -0
- package/src/app/assets/flags/AT.svg +1 -0
- package/src/app/assets/flags/AU.svg +1 -0
- package/src/app/assets/flags/AW.svg +1 -0
- package/src/app/assets/flags/AX.svg +1 -0
- package/src/app/assets/flags/AZ.svg +1 -0
- package/src/app/assets/flags/BA.svg +1 -0
- package/src/app/assets/flags/BB.svg +1 -0
- package/src/app/assets/flags/BD.svg +1 -0
- package/src/app/assets/flags/BE.svg +1 -0
- package/src/app/assets/flags/BF.svg +1 -0
- package/src/app/assets/flags/BG.svg +1 -0
- package/src/app/assets/flags/BH.svg +1 -0
- package/src/app/assets/flags/BI.svg +1 -0
- package/src/app/assets/flags/BJ.svg +1 -0
- package/src/app/assets/flags/BL.svg +1 -0
- package/src/app/assets/flags/BM.svg +1 -0
- package/src/app/assets/flags/BN.svg +1 -0
- package/src/app/assets/flags/BO.svg +1 -0
- package/src/app/assets/flags/BQ-BO.svg +1 -0
- package/src/app/assets/flags/BQ-SA.svg +1 -0
- package/src/app/assets/flags/BQ-SE.svg +1 -0
- package/src/app/assets/flags/BQ.svg +1 -0
- package/src/app/assets/flags/BR.svg +1 -0
- package/src/app/assets/flags/BS.svg +1 -0
- package/src/app/assets/flags/BT.svg +1 -0
- package/src/app/assets/flags/BV.svg +1 -0
- package/src/app/assets/flags/BW.svg +1 -0
- package/src/app/assets/flags/BY.svg +1 -0
- package/src/app/assets/flags/BZ.svg +1 -0
- package/src/app/assets/flags/CA.svg +1 -0
- package/src/app/assets/flags/CC.svg +1 -0
- package/src/app/assets/flags/CD.svg +1 -0
- package/src/app/assets/flags/CF.svg +1 -0
- package/src/app/assets/flags/CG.svg +1 -0
- package/src/app/assets/flags/CH.svg +1 -0
- package/src/app/assets/flags/CI.svg +1 -0
- package/src/app/assets/flags/CK.svg +1 -0
- package/src/app/assets/flags/CL.svg +1 -0
- package/src/app/assets/flags/CM.svg +1 -0
- package/src/app/assets/flags/CN.svg +1 -0
- package/src/app/assets/flags/CO.svg +1 -0
- package/src/app/assets/flags/CR.svg +1 -0
- package/src/app/assets/flags/CU.svg +1 -0
- package/src/app/assets/flags/CV.svg +1 -0
- package/src/app/assets/flags/CW.svg +1 -0
- package/src/app/assets/flags/CX.svg +1 -0
- package/src/app/assets/flags/CY.svg +1 -0
- package/src/app/assets/flags/CZ.svg +1 -0
- package/src/app/assets/flags/DE.svg +1 -0
- package/src/app/assets/flags/DJ.svg +1 -0
- package/src/app/assets/flags/DK.svg +1 -0
- package/src/app/assets/flags/DM.svg +1 -0
- package/src/app/assets/flags/DO.svg +1 -0
- package/src/app/assets/flags/DZ.svg +1 -0
- package/src/app/assets/flags/EC.svg +1 -0
- package/src/app/assets/flags/EE.svg +1 -0
- package/src/app/assets/flags/EG.svg +1 -0
- package/src/app/assets/flags/EH.svg +1 -0
- package/src/app/assets/flags/ER.svg +1 -0
- package/src/app/assets/flags/ES-CT.svg +1 -0
- package/src/app/assets/flags/ES.svg +1 -0
- package/src/app/assets/flags/ET.svg +1 -0
- package/src/app/assets/flags/EU.svg +1 -0
- package/src/app/assets/flags/FI.svg +1 -0
- package/src/app/assets/flags/FJ.svg +1 -0
- package/src/app/assets/flags/FK.svg +1 -0
- package/src/app/assets/flags/FM.svg +1 -0
- package/src/app/assets/flags/FO.svg +1 -0
- package/src/app/assets/flags/FR.svg +1 -0
- package/src/app/assets/flags/GA.svg +1 -0
- package/src/app/assets/flags/GB-ENG.svg +1 -0
- package/src/app/assets/flags/GB-NIR.svg +1 -0
- package/src/app/assets/flags/GB-SCT.svg +1 -0
- package/src/app/assets/flags/GB-WLS.svg +1 -0
- package/src/app/assets/flags/GB.svg +1 -0
- package/src/app/assets/flags/GD.svg +1 -0
- package/src/app/assets/flags/GE.svg +1 -0
- package/src/app/assets/flags/GF.svg +1 -0
- package/src/app/assets/flags/GG.svg +1 -0
- package/src/app/assets/flags/GH.svg +1 -0
- package/src/app/assets/flags/GI.svg +1 -0
- package/src/app/assets/flags/GL.svg +1 -0
- package/src/app/assets/flags/GM.svg +1 -0
- package/src/app/assets/flags/GN.svg +1 -0
- package/src/app/assets/flags/GP.svg +1 -0
- package/src/app/assets/flags/GQ.svg +1 -0
- package/src/app/assets/flags/GR.svg +1 -0
- package/src/app/assets/flags/GS.svg +1 -0
- package/src/app/assets/flags/GT.svg +1 -0
- package/src/app/assets/flags/GU.svg +1 -0
- package/src/app/assets/flags/GW.svg +1 -0
- package/src/app/assets/flags/GY.svg +1 -0
- package/src/app/assets/flags/HK.svg +1 -0
- package/src/app/assets/flags/HM.svg +1 -0
- package/src/app/assets/flags/HN.svg +1 -0
- package/src/app/assets/flags/HR.svg +1 -0
- package/src/app/assets/flags/HT.svg +1 -0
- package/src/app/assets/flags/HU.svg +1 -0
- package/src/app/assets/flags/IC.svg +1 -0
- package/src/app/assets/flags/ID.svg +1 -0
- package/src/app/assets/flags/IE.svg +1 -0
- package/src/app/assets/flags/IL.svg +1 -0
- package/src/app/assets/flags/IM.svg +1 -0
- package/src/app/assets/flags/IN.svg +1 -0
- package/src/app/assets/flags/IO.svg +1 -0
- package/src/app/assets/flags/IQ.svg +1 -0
- package/src/app/assets/flags/IR.svg +1 -0
- package/src/app/assets/flags/IS.svg +1 -0
- package/src/app/assets/flags/IT.svg +1 -0
- package/src/app/assets/flags/JE.svg +1 -0
- package/src/app/assets/flags/JM.svg +1 -0
- package/src/app/assets/flags/JO.svg +1 -0
- package/src/app/assets/flags/JP.svg +1 -0
- package/src/app/assets/flags/KE.svg +1 -0
- package/src/app/assets/flags/KG.svg +1 -0
- package/src/app/assets/flags/KH.svg +1 -0
- package/src/app/assets/flags/KI.svg +1 -0
- package/src/app/assets/flags/KM.svg +1 -0
- package/src/app/assets/flags/KN.svg +1 -0
- package/src/app/assets/flags/KP.svg +1 -0
- package/src/app/assets/flags/KR.svg +1 -0
- package/src/app/assets/flags/KW.svg +1 -0
- package/src/app/assets/flags/KY.svg +1 -0
- package/src/app/assets/flags/KZ.svg +1 -0
- package/src/app/assets/flags/LA.svg +1 -0
- package/src/app/assets/flags/LB.svg +1 -0
- package/src/app/assets/flags/LC.svg +1 -0
- package/src/app/assets/flags/LI.svg +1 -0
- package/src/app/assets/flags/LK.svg +1 -0
- package/src/app/assets/flags/LR.svg +1 -0
- package/src/app/assets/flags/LS.svg +1 -0
- package/src/app/assets/flags/LT.svg +1 -0
- package/src/app/assets/flags/LU.svg +1 -0
- package/src/app/assets/flags/LV.svg +1 -0
- package/src/app/assets/flags/LY.svg +1 -0
- package/src/app/assets/flags/MA.svg +1 -0
- package/src/app/assets/flags/MC.svg +1 -0
- package/src/app/assets/flags/MD.svg +1 -0
- package/src/app/assets/flags/ME.svg +1 -0
- package/src/app/assets/flags/MF.svg +1 -0
- package/src/app/assets/flags/MG.svg +1 -0
- package/src/app/assets/flags/MH.svg +1 -0
- package/src/app/assets/flags/MK.svg +1 -0
- package/src/app/assets/flags/ML.svg +1 -0
- package/src/app/assets/flags/MM.svg +1 -0
- package/src/app/assets/flags/MN.svg +1 -0
- package/src/app/assets/flags/MO.svg +1 -0
- package/src/app/assets/flags/MP.svg +1 -0
- package/src/app/assets/flags/MQ.svg +1 -0
- package/src/app/assets/flags/MR.svg +1 -0
- package/src/app/assets/flags/MS.svg +1 -0
- package/src/app/assets/flags/MT.svg +1 -0
- package/src/app/assets/flags/MU.svg +1 -0
- package/src/app/assets/flags/MV.svg +1 -0
- package/src/app/assets/flags/MW.svg +1 -0
- package/src/app/assets/flags/MX.svg +1 -0
- package/src/app/assets/flags/MY.svg +1 -0
- package/src/app/assets/flags/MZ.svg +1 -0
- package/src/app/assets/flags/NA.svg +1 -0
- package/src/app/assets/flags/NC.svg +1 -0
- package/src/app/assets/flags/NE.svg +1 -0
- package/src/app/assets/flags/NF.svg +1 -0
- package/src/app/assets/flags/NG.svg +1 -0
- package/src/app/assets/flags/NI.svg +1 -0
- package/src/app/assets/flags/NL.svg +1 -0
- package/src/app/assets/flags/NO.svg +1 -0
- package/src/app/assets/flags/NP.svg +1 -0
- package/src/app/assets/flags/NR.svg +1 -0
- package/src/app/assets/flags/NU.svg +1 -0
- package/src/app/assets/flags/NZ.svg +1 -0
- package/src/app/assets/flags/OM.svg +1 -0
- package/src/app/assets/flags/PA.svg +1 -0
- package/src/app/assets/flags/PE.svg +1 -0
- package/src/app/assets/flags/PF.svg +1 -0
- package/src/app/assets/flags/PG.svg +1 -0
- package/src/app/assets/flags/PH.svg +1 -0
- package/src/app/assets/flags/PK.svg +1 -0
- package/src/app/assets/flags/PL.svg +1 -0
- package/src/app/assets/flags/PM.svg +1 -0
- package/src/app/assets/flags/PN.svg +1 -0
- package/src/app/assets/flags/PR.svg +1 -0
- package/src/app/assets/flags/PS.svg +1 -0
- package/src/app/assets/flags/PT.svg +1 -0
- package/src/app/assets/flags/PW.svg +1 -0
- package/src/app/assets/flags/PY.svg +1 -0
- package/src/app/assets/flags/QA.svg +1 -0
- package/src/app/assets/flags/RE.svg +1 -0
- package/src/app/assets/flags/README.md +6 -0
- package/src/app/assets/flags/RO.svg +1 -0
- package/src/app/assets/flags/RS.svg +1 -0
- package/src/app/assets/flags/RU.svg +1 -0
- package/src/app/assets/flags/RW.svg +1 -0
- package/src/app/assets/flags/SA.svg +1 -0
- package/src/app/assets/flags/SB.svg +1 -0
- package/src/app/assets/flags/SC.svg +1 -0
- package/src/app/assets/flags/SD.svg +1 -0
- package/src/app/assets/flags/SE.svg +1 -0
- package/src/app/assets/flags/SG.svg +1 -0
- package/src/app/assets/flags/SH.svg +1 -0
- package/src/app/assets/flags/SI.svg +1 -0
- package/src/app/assets/flags/SJ.svg +1 -0
- package/src/app/assets/flags/SK.svg +1 -0
- package/src/app/assets/flags/SL.svg +1 -0
- package/src/app/assets/flags/SM.svg +1 -0
- package/src/app/assets/flags/SN.svg +1 -0
- package/src/app/assets/flags/SO.svg +1 -0
- package/src/app/assets/flags/SR.svg +1 -0
- package/src/app/assets/flags/SS.svg +1 -0
- package/src/app/assets/flags/ST.svg +1 -0
- package/src/app/assets/flags/SV.svg +1 -0
- package/src/app/assets/flags/SX.svg +1 -0
- package/src/app/assets/flags/SY.svg +1 -0
- package/src/app/assets/flags/SZ.svg +1 -0
- package/src/app/assets/flags/TA.svg +1 -0
- package/src/app/assets/flags/TC.svg +1 -0
- package/src/app/assets/flags/TD.svg +1 -0
- package/src/app/assets/flags/TF.svg +1 -0
- package/src/app/assets/flags/TG.svg +1 -0
- package/src/app/assets/flags/TH.svg +1 -0
- package/src/app/assets/flags/TJ.svg +1 -0
- package/src/app/assets/flags/TK.svg +1 -0
- package/src/app/assets/flags/TL.svg +1 -0
- package/src/app/assets/flags/TM.svg +1 -0
- package/src/app/assets/flags/TN.svg +1 -0
- package/src/app/assets/flags/TO.svg +1 -0
- package/src/app/assets/flags/TR.svg +1 -0
- package/src/app/assets/flags/TT.svg +1 -0
- package/src/app/assets/flags/TV.svg +1 -0
- package/src/app/assets/flags/TW.svg +1 -0
- package/src/app/assets/flags/TZ.svg +1 -0
- package/src/app/assets/flags/UA.svg +1 -0
- package/src/app/assets/flags/UG.svg +1 -0
- package/src/app/assets/flags/UM.svg +1 -0
- package/src/app/assets/flags/US.svg +1 -0
- package/src/app/assets/flags/UY.svg +1 -0
- package/src/app/assets/flags/UZ.svg +1 -0
- package/src/app/assets/flags/VA.svg +1 -0
- package/src/app/assets/flags/VC.svg +1 -0
- package/src/app/assets/flags/VE.svg +1 -0
- package/src/app/assets/flags/VG.svg +1 -0
- package/src/app/assets/flags/VI.svg +1 -0
- package/src/app/assets/flags/VN.svg +1 -0
- package/src/app/assets/flags/VU.svg +1 -0
- package/src/app/assets/flags/WF.svg +1 -0
- package/src/app/assets/flags/WS.svg +1 -0
- package/src/app/assets/flags/XA.svg +1 -0
- package/src/app/assets/flags/XC.svg +1 -0
- package/src/app/assets/flags/XK.svg +1 -0
- package/src/app/assets/flags/XO.svg +1 -0
- package/src/app/assets/flags/YE.svg +1 -0
- package/src/app/assets/flags/YT.svg +1 -0
- package/src/app/assets/flags/ZA.svg +1 -0
- package/src/app/assets/flags/ZM.svg +1 -0
- package/src/app/assets/flags/ZW.svg +1 -0
- package/src/app/email-preview.ts +46 -0
- package/src/app/index.css +203 -0
- package/src/app/index.html +12 -0
- package/src/app/integrations/i18n/react-i18next.d.ts +11 -0
- package/src/app/integrations/i18n/root-provider.tsx +62 -0
- package/src/app/integrations/tanstack-query/devtools.tsx +6 -0
- package/src/app/integrations/tanstack-query/root-provider.tsx +37 -0
- package/src/app/integrations/theme/root-provider.tsx +75 -0
- package/src/app/integrations/toast/toast-provider.tsx +46 -0
- package/src/app/locales/en-US/common.ts +268 -0
- package/src/app/locales/zh-CN/common.ts +263 -0
- package/src/app/main.tsx +40 -0
- package/src/app/page-chrome.tsx +79 -0
- package/src/app/router.tsx +40 -0
- package/src/app/routes/__root.tsx +293 -0
- package/src/app/routes/emails.tsx +199 -0
- package/src/app/routes/home.tsx +87 -0
- package/src/app/routes/index.ts +19 -0
- package/src/app/routes/metrics.tsx +541 -0
- package/src/app/routes/segment-overview.tsx +211 -0
- package/src/app/routes/segments.tsx +236 -0
- package/src/app/routes/settings.tsx +90 -0
- package/src/app/routes/workflows.tsx +348 -0
- package/src/app/studio.ts +16 -0
- package/src/app/svg.d.ts +17 -0
- package/src/app/virtual-config.d.ts +6 -0
- package/src/cli.ts +110 -0
- package/src/components/avatar.tsx +57 -0
- package/src/components/breadcrumb.tsx +49 -0
- package/src/components/button/index.tsx +86 -0
- package/src/components/channel-icon.ts +39 -0
- package/src/components/chat-markup.tsx +109 -0
- package/src/components/corner-shape.ts +13 -0
- package/src/components/date-range.tsx +181 -0
- package/src/components/discord-preview.tsx +165 -0
- package/src/components/dropdown/index.tsx +172 -0
- package/src/components/email-defaults.tsx +40 -0
- package/src/components/email-list.tsx +149 -0
- package/src/components/email-thumbnail.tsx +123 -0
- package/src/components/flag.tsx +40 -0
- package/src/components/input/index.tsx +40 -0
- package/src/components/input/search-input.tsx +24 -0
- package/src/components/layout.ts +403 -0
- package/src/components/menu/index.tsx +118 -0
- package/src/components/metric-card.tsx +321 -0
- package/src/components/modal/index.tsx +70 -0
- package/src/components/nav-drawer.tsx +84 -0
- package/src/components/node-inspector.tsx +242 -0
- package/src/components/profile-drawer.tsx +331 -0
- package/src/components/push-preview.tsx +470 -0
- package/src/components/push-thumbnail.tsx +78 -0
- package/src/components/segment-list.tsx +184 -0
- package/src/components/select/index.tsx +70 -0
- package/src/components/series-chart.tsx +120 -0
- package/src/components/slack-preview.tsx +223 -0
- package/src/components/sparkline.tsx +58 -0
- package/src/components/tabs/index.tsx +45 -0
- package/src/components/template-refs.ts +110 -0
- package/src/components/templates-page.tsx +601 -0
- package/src/components/textarea/index.tsx +37 -0
- package/src/components/thumbnail-window.tsx +65 -0
- package/src/components/workflow-canvas.tsx +503 -0
- package/src/components/workflow-list.tsx +231 -0
- package/src/config.ts +288 -0
- package/src/generate.ts +56 -0
- package/src/index.ts +35 -0
- package/src/postgres.ts +415 -0
- package/src/server/project.ts +290 -0
- package/src/server.ts +500 -0
- package/src/utils/cn.ts +6 -0
- package/src/utils/label.ts +12 -0
- package/src/utils/lookup.ts +11 -0
- package/src/utils/template-content.ts +213 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2722 @@
|
|
|
1
|
+
import { METRIC_CHANNELS, defineStats } from "./config.mjs";
|
|
2
|
+
import { clsx } from "clsx";
|
|
3
|
+
import { twMerge } from "tailwind-merge";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { Background, BaseEdge, Controls, EdgeLabelRenderer, Handle, Position, ReactFlow } from "@xyflow/react";
|
|
6
|
+
import { AlarmClock, AppWindow, ArrowDown, ArrowUp, BellRing, Bot, Calendar, CalendarClock, Camera, ChevronDown, ClipboardList, Filter, Flashlight, GitBranch, Globe, Hourglass, Lock, LogOut, Mail, MessageCircle, MessageSquareText, MessagesSquare, Minus, Monitor, Moon, Plus, Send, Shuffle, Smartphone, SquareFunction, Sun, User, Webhook, Workflow, Zap } from "lucide-react";
|
|
7
|
+
import { Fragment as Fragment$1, createContext, useContext, useId, useMemo, useState } from "react";
|
|
8
|
+
import { useTranslation } from "react-i18next";
|
|
9
|
+
import { TemplateValidationError, renderDiscordContent, renderPushContent, renderSlackContent } from "@shware/workflow";
|
|
10
|
+
import { FloatingFocusManager, autoUpdate, flip, offset, shift, useClick, useDismiss, useFloating, useInteractions, useRole } from "@floating-ui/react";
|
|
11
|
+
//#region \0rolldown/runtime.js
|
|
12
|
+
var __create = Object.create;
|
|
13
|
+
var __defProp = Object.defineProperty;
|
|
14
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
15
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
16
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
17
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
18
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
19
|
+
var __copyProps = (to, from, except, desc) => {
|
|
20
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
21
|
+
key = keys[i];
|
|
22
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
23
|
+
get: ((k) => from[k]).bind(null, key),
|
|
24
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return to;
|
|
28
|
+
};
|
|
29
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
30
|
+
value: mod,
|
|
31
|
+
enumerable: true
|
|
32
|
+
}) : target, mod));
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/utils/cn.ts
|
|
35
|
+
function cn(...inputs) {
|
|
36
|
+
return twMerge(clsx(inputs));
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/components/corner-shape.ts
|
|
40
|
+
/**
|
|
41
|
+
* Every rounded surface that is not a full pill carries this.
|
|
42
|
+
*
|
|
43
|
+
* A plain border-radius leaves a visible curvature break where the arc meets
|
|
44
|
+
* the straight edge; a superellipse blends the two, which is what the canvas
|
|
45
|
+
* cards already do. Pills (`rounded-full`) are continuous by construction, so
|
|
46
|
+
* they skip it.
|
|
47
|
+
*
|
|
48
|
+
* Cast because `corner-shape` is not in React's CSSProperties yet.
|
|
49
|
+
*/
|
|
50
|
+
const superellipse = { cornerShape: "superellipse(1.2)" };
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/components/button/index.tsx
|
|
53
|
+
const SIZE_STYLE$2 = {
|
|
54
|
+
xs: "h-7 px-3 text-xs rounded-md focus-visible:ring-2",
|
|
55
|
+
sm: "h-9 px-3 text-sm rounded-lg focus-visible:ring-3",
|
|
56
|
+
md: "h-10 px-4 text-sm rounded-xl focus-visible:ring-3",
|
|
57
|
+
lg: "h-12 px-6 text-base rounded-xl focus-visible:ring-4",
|
|
58
|
+
xl: "h-14 px-8 text-lg rounded-2xl focus-visible:ring-4"
|
|
59
|
+
};
|
|
60
|
+
const VARIANT_STYLE = {
|
|
61
|
+
text: clsx("text-primary border-none bg-transparent", "hover:bg-gray-100 focus-visible:ring-black/10 active:bg-gray-200/80", "dark:hover:bg-gray-800 dark:focus-visible:ring-white/20 dark:active:bg-gray-700/80"),
|
|
62
|
+
accent: clsx("bg-accent active:bg-accent/80 text-white", "focus-visible:ring-accent/40 dark:focus-visible:ring-accent/50"),
|
|
63
|
+
default: clsx("border-none bg-black text-white focus-visible:ring-black/20 dark:bg-white dark:text-black", "active:bg-black/80 dark:focus-visible:ring-white/30 dark:active:bg-white/80"),
|
|
64
|
+
secondary: clsx("text-primary bg-gray-100 focus-visible:ring-black/10 active:bg-gray-200/80", "dark:bg-gray-800 dark:focus-visible:ring-white/20 dark:active:bg-gray-700/80"),
|
|
65
|
+
destructive: clsx("text-white focus-visible:ring-red-400/40", "bg-red-400 active:bg-red-500/90", "dark:bg-red-400/70 dark:active:bg-red-400/90"),
|
|
66
|
+
outline: clsx("text-primary border", "bg-white focus-visible:ring-black/10 active:bg-gray-100/70", "dark:bg-gray-900/70 dark:focus-visible:ring-white/30 dark:active:bg-gray-900")
|
|
67
|
+
};
|
|
68
|
+
function Button({ children, className, size = "md", style, type = "button", variant = "default", ...props }) {
|
|
69
|
+
return /* @__PURE__ */ jsx("button", {
|
|
70
|
+
type,
|
|
71
|
+
style: {
|
|
72
|
+
...superellipse,
|
|
73
|
+
...style
|
|
74
|
+
},
|
|
75
|
+
className: cn(SIZE_STYLE$2[size], VARIANT_STYLE[variant], "inline-flex items-center justify-center", "text-center font-medium transition-all duration-100 focus:outline-none", "disabled:pointer-events-none disabled:opacity-50", className),
|
|
76
|
+
...props,
|
|
77
|
+
children
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/components/layout.ts
|
|
82
|
+
/** Card sizes: the single source shared by layout and renderer, all on the 16/8 grid. */
|
|
83
|
+
const CARD_SIZE = {
|
|
84
|
+
w: 288,
|
|
85
|
+
h: 64
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* The icon variant renders as an auto-width pill, so only its height is known
|
|
89
|
+
* here. It is laid out in a card-width box and centred inside it: guessing the
|
|
90
|
+
* pill's width instead put its visual centre a couple of pixels off the column
|
|
91
|
+
* the connectors are drawn down, which reads as a crooked line.
|
|
92
|
+
*/
|
|
93
|
+
const ICON_SIZE = {
|
|
94
|
+
w: CARD_SIZE.w,
|
|
95
|
+
h: 32
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Tiered spacing: straight sequences stay tight, forks open up (room for the
|
|
99
|
+
* rounded split, the hanging labels, and a future insert-action button), and
|
|
100
|
+
* rejoins get slightly more than a sequence gap so merge lines have space.
|
|
101
|
+
*/
|
|
102
|
+
const W = CARD_SIZE.w;
|
|
103
|
+
const VGAP = 48;
|
|
104
|
+
const FORK_GAP = 112;
|
|
105
|
+
const REJOIN_EXTRA = 24;
|
|
106
|
+
const HGAP = 88;
|
|
107
|
+
function nodeSize(n) {
|
|
108
|
+
return n.type === "exit" ? ICON_SIZE : CARD_SIZE;
|
|
109
|
+
}
|
|
110
|
+
/** Property operator → label symbol (math signs for eq/ne/gt/lt; set and text operators keep short words). */
|
|
111
|
+
const OP_LABEL = {
|
|
112
|
+
eq: "=",
|
|
113
|
+
ne: "≠",
|
|
114
|
+
gt: ">",
|
|
115
|
+
lt: "<",
|
|
116
|
+
between: "between",
|
|
117
|
+
in_array: "in",
|
|
118
|
+
not_in_array: "not in",
|
|
119
|
+
exists: "exists",
|
|
120
|
+
not_exists: "not exists",
|
|
121
|
+
contains: "contains",
|
|
122
|
+
not_contains: "not contains"
|
|
123
|
+
};
|
|
124
|
+
function conditionLabel(c, fallback) {
|
|
125
|
+
if (c.type === "segment") return c.segment;
|
|
126
|
+
if (c.type === "not") return `not ${conditionLabel(c.condition, fallback)}`;
|
|
127
|
+
if (c.type === "property") {
|
|
128
|
+
const op = OP_LABEL[c.op] ?? c.op;
|
|
129
|
+
const value = c.op === "between" ? `${c.values?.[0]} – ${c.values?.[1]}` : c.op === "in_array" || c.op === "not_in_array" ? `[${c.values?.join(", ")}]` : c.value !== void 0 ? String(c.value) : "";
|
|
130
|
+
return value === "" ? `${c.path} ${op}` : `${c.path} ${op} ${value}`;
|
|
131
|
+
}
|
|
132
|
+
if (c.type === "performed") return `did ${c.event}`;
|
|
133
|
+
if (c.type === "reachable") return `reachable by ${c.channel}`;
|
|
134
|
+
if (c.type === "and" || c.type === "or") return c.conditions.map((child) => conditionLabel(child, fallback)).join(` ${c.type} `);
|
|
135
|
+
return fallback;
|
|
136
|
+
}
|
|
137
|
+
function groupsOf(n) {
|
|
138
|
+
switch (n.type) {
|
|
139
|
+
case "branch": {
|
|
140
|
+
const groups = n.cases.map((c, i) => ({
|
|
141
|
+
label: c.label ?? conditionLabel(c.condition, `case ${i + 1}`),
|
|
142
|
+
nodes: c.flow
|
|
143
|
+
}));
|
|
144
|
+
groups.push({
|
|
145
|
+
label: "else",
|
|
146
|
+
nodes: n.otherwise ?? []
|
|
147
|
+
});
|
|
148
|
+
return groups;
|
|
149
|
+
}
|
|
150
|
+
case "cohort": return n.arms.map((a) => ({
|
|
151
|
+
label: `${a.name} · ${a.weight}%`,
|
|
152
|
+
nodes: a.flow
|
|
153
|
+
}));
|
|
154
|
+
case "wait_until":
|
|
155
|
+
if (Array.isArray(n.onTimeout)) return [{
|
|
156
|
+
label: "met",
|
|
157
|
+
nodes: []
|
|
158
|
+
}, {
|
|
159
|
+
label: "timeout",
|
|
160
|
+
nodes: n.onTimeout
|
|
161
|
+
}];
|
|
162
|
+
return null;
|
|
163
|
+
default: return null;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function seqWidth(nodes) {
|
|
167
|
+
return nodes.length === 0 ? W : Math.max(...nodes.map(nodeWidth));
|
|
168
|
+
}
|
|
169
|
+
function nodeWidth(n) {
|
|
170
|
+
const groups = groupsOf(n);
|
|
171
|
+
if (!groups) return nodeSize(n).w;
|
|
172
|
+
return groups.reduce((sum, g) => sum + Math.max(W, seqWidth(g.nodes)), 0) + HGAP * (groups.length - 1);
|
|
173
|
+
}
|
|
174
|
+
const CHANNEL_TITLE = {
|
|
175
|
+
email: "Email",
|
|
176
|
+
sms: "SMS",
|
|
177
|
+
push: "Push Notification",
|
|
178
|
+
in_app: "In-App Message",
|
|
179
|
+
slack: "Slack Message",
|
|
180
|
+
discord: "Discord Message",
|
|
181
|
+
survey: "Survey"
|
|
182
|
+
};
|
|
183
|
+
function nodeData(n) {
|
|
184
|
+
switch (n.type) {
|
|
185
|
+
case "message": return {
|
|
186
|
+
title: CHANNEL_TITLE[n.channel] ?? n.channel,
|
|
187
|
+
subtitle: n.devices === "latest" ? `${n.template} · latest device` : n.template,
|
|
188
|
+
category: "message",
|
|
189
|
+
variant: "card",
|
|
190
|
+
icon: n.channel
|
|
191
|
+
};
|
|
192
|
+
case "delay": return {
|
|
193
|
+
title: "Time Delay",
|
|
194
|
+
subtitle: `Wait ${n.duration.value}`,
|
|
195
|
+
category: "delay",
|
|
196
|
+
variant: "card",
|
|
197
|
+
icon: "delay"
|
|
198
|
+
};
|
|
199
|
+
case "random_delay": return {
|
|
200
|
+
title: "Randomized Delay",
|
|
201
|
+
subtitle: `Wait ${n.min.value} – ${n.max.value}`,
|
|
202
|
+
category: "delay",
|
|
203
|
+
variant: "card",
|
|
204
|
+
icon: "delay"
|
|
205
|
+
};
|
|
206
|
+
case "time_window": return {
|
|
207
|
+
title: "Time Window",
|
|
208
|
+
subtitle: `${n.days.join(" ")} ${n.between[0]}–${n.between[1]}`,
|
|
209
|
+
category: "delay",
|
|
210
|
+
variant: "card",
|
|
211
|
+
icon: "time_window"
|
|
212
|
+
};
|
|
213
|
+
case "wait_until": return {
|
|
214
|
+
title: `Wait until ${conditionLabel(n.condition, "…")}`,
|
|
215
|
+
subtitle: `timeout ${n.timeout.value}`,
|
|
216
|
+
category: "delay",
|
|
217
|
+
variant: "card",
|
|
218
|
+
icon: "wait_until"
|
|
219
|
+
};
|
|
220
|
+
case "branch": {
|
|
221
|
+
const arms = n.cases.length + 1;
|
|
222
|
+
return {
|
|
223
|
+
title: n.label ?? (n.cases.length > 1 ? "Multi-Split Branch" : "True/False Branch"),
|
|
224
|
+
subtitle: `${arms} arms, first match`,
|
|
225
|
+
category: "control",
|
|
226
|
+
variant: "card",
|
|
227
|
+
icon: "branch"
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
case "filter": return {
|
|
231
|
+
title: "Filter",
|
|
232
|
+
subtitle: n.reason ?? "only continue if…",
|
|
233
|
+
category: "control",
|
|
234
|
+
variant: "card",
|
|
235
|
+
icon: "filter"
|
|
236
|
+
};
|
|
237
|
+
case "cohort": return {
|
|
238
|
+
title: "Random Cohort",
|
|
239
|
+
subtitle: n.arms.map((a) => `${a.name} ${a.weight}%`).join(" / "),
|
|
240
|
+
category: "control",
|
|
241
|
+
variant: "card",
|
|
242
|
+
icon: "cohort"
|
|
243
|
+
};
|
|
244
|
+
case "exit": return {
|
|
245
|
+
title: "Exit",
|
|
246
|
+
...n.reason !== void 0 ? { subtitle: n.reason } : {},
|
|
247
|
+
category: "exit",
|
|
248
|
+
variant: "icon",
|
|
249
|
+
icon: "exit"
|
|
250
|
+
};
|
|
251
|
+
case "send_event": return {
|
|
252
|
+
title: "Send Event",
|
|
253
|
+
subtitle: n.event,
|
|
254
|
+
category: "data",
|
|
255
|
+
variant: "card",
|
|
256
|
+
icon: "send_event"
|
|
257
|
+
};
|
|
258
|
+
case "action": return {
|
|
259
|
+
title: "Custom Action",
|
|
260
|
+
subtitle: n.action,
|
|
261
|
+
category: "data",
|
|
262
|
+
variant: "card",
|
|
263
|
+
icon: "action"
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
function layout(ir, stats) {
|
|
268
|
+
const nodes = [];
|
|
269
|
+
const edges = [];
|
|
270
|
+
let edgeSeq = 0;
|
|
271
|
+
const addNode = (id, x, y, data) => {
|
|
272
|
+
const count = stats?.[id];
|
|
273
|
+
nodes.push({
|
|
274
|
+
id,
|
|
275
|
+
type: "wf",
|
|
276
|
+
position: {
|
|
277
|
+
x,
|
|
278
|
+
y
|
|
279
|
+
},
|
|
280
|
+
data: count === void 0 ? data : {
|
|
281
|
+
...data,
|
|
282
|
+
count
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
};
|
|
286
|
+
const addEdges = (tails, target) => {
|
|
287
|
+
for (const t of tails) edges.push({
|
|
288
|
+
id: `e${edgeSeq++}`,
|
|
289
|
+
source: t.id,
|
|
290
|
+
target,
|
|
291
|
+
...t.label !== void 0 ? { label: t.label } : {},
|
|
292
|
+
...t.anchor !== void 0 ? { data: { anchor: t.anchor } } : {}
|
|
293
|
+
});
|
|
294
|
+
};
|
|
295
|
+
/** Lay out one sequence recursively: `cx` is the centre line; returns the bottom y and the tails that continue downward. */
|
|
296
|
+
function layoutSeq(seq, cx, y, incoming) {
|
|
297
|
+
let curY = y;
|
|
298
|
+
let tails = incoming;
|
|
299
|
+
for (const n of seq) {
|
|
300
|
+
const size = nodeSize(n);
|
|
301
|
+
addNode(n.id, cx - size.w / 2, curY, nodeData(n));
|
|
302
|
+
addEdges(tails, n.id);
|
|
303
|
+
const bottom = curY + size.h;
|
|
304
|
+
if (n.type === "exit") {
|
|
305
|
+
tails = [];
|
|
306
|
+
curY = bottom + VGAP;
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
const groups = groupsOf(n);
|
|
310
|
+
if (!groups) {
|
|
311
|
+
tails = [{ id: n.id }];
|
|
312
|
+
curY = bottom + VGAP;
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
const widths = groups.map((g) => Math.max(W, seqWidth(g.nodes)));
|
|
316
|
+
let gx = cx - (widths.reduce((a, b) => a + b, 0) + HGAP * (groups.length - 1)) / 2;
|
|
317
|
+
const groupTop = bottom + FORK_GAP;
|
|
318
|
+
let maxBottom = groupTop;
|
|
319
|
+
const groupTails = [];
|
|
320
|
+
groups.forEach((g, gi) => {
|
|
321
|
+
const center = gx + (widths[gi] ?? W) / 2;
|
|
322
|
+
if (g.nodes.length === 0) groupTails.push({
|
|
323
|
+
id: n.id,
|
|
324
|
+
label: g.label,
|
|
325
|
+
anchor: "source"
|
|
326
|
+
});
|
|
327
|
+
else {
|
|
328
|
+
const r = layoutSeq(g.nodes, center, groupTop, [{
|
|
329
|
+
id: n.id,
|
|
330
|
+
label: g.label,
|
|
331
|
+
anchor: "target"
|
|
332
|
+
}]);
|
|
333
|
+
groupTails.push(...r.tails);
|
|
334
|
+
maxBottom = Math.max(maxBottom, r.bottom);
|
|
335
|
+
}
|
|
336
|
+
gx += (widths[gi] ?? W) + HGAP;
|
|
337
|
+
});
|
|
338
|
+
tails = groupTails;
|
|
339
|
+
curY = maxBottom + REJOIN_EXTRA;
|
|
340
|
+
}
|
|
341
|
+
return {
|
|
342
|
+
bottom: curY,
|
|
343
|
+
tails
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
const t = ir.trigger;
|
|
347
|
+
const triggerSubtitle = t.type === "event" ? `${t.event}${t.filter ? " · +filter" : ""}` : t.type === "segment" ? `enters ${t.segment}` : t.type === "date" ? t.at : "webhook";
|
|
348
|
+
addNode("__trigger", -CARD_SIZE.w / 2, 0, {
|
|
349
|
+
title: "Trigger",
|
|
350
|
+
subtitle: triggerSubtitle,
|
|
351
|
+
category: "trigger",
|
|
352
|
+
variant: "card",
|
|
353
|
+
icon: "trigger"
|
|
354
|
+
});
|
|
355
|
+
const { bottom, tails } = layoutSeq(ir.flow, 0, CARD_SIZE.h + VGAP, [{ id: "__trigger" }]);
|
|
356
|
+
if (tails.length > 0) {
|
|
357
|
+
addNode("__end", -ICON_SIZE.w / 2, bottom, {
|
|
358
|
+
title: "Exit",
|
|
359
|
+
category: "exit",
|
|
360
|
+
variant: "icon",
|
|
361
|
+
icon: "exit"
|
|
362
|
+
});
|
|
363
|
+
addEdges(tails, "__end");
|
|
364
|
+
}
|
|
365
|
+
return {
|
|
366
|
+
nodes,
|
|
367
|
+
edges
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
//#endregion
|
|
371
|
+
//#region src/components/workflow-canvas.tsx
|
|
372
|
+
/** The callback travels by context: react-flow node data should carry serializable data only. */
|
|
373
|
+
/** Same reason: selection is view state, not node data, so it must not enter the layout. */
|
|
374
|
+
const SelectedContext = createContext(void 0);
|
|
375
|
+
/**
|
|
376
|
+
* One hue per category, not per icon: six colours make a message, a wait and a
|
|
377
|
+
* branch tell themselves apart at a glance; fifteen would just be noise. Values
|
|
378
|
+
* live in CSS so they shift with the theme.
|
|
379
|
+
*/
|
|
380
|
+
const CATEGORY_COLOR = {
|
|
381
|
+
trigger: "var(--color-icon-trigger)",
|
|
382
|
+
message: "var(--color-icon-message)",
|
|
383
|
+
delay: "var(--color-icon-delay)",
|
|
384
|
+
control: "var(--color-icon-control)",
|
|
385
|
+
data: "var(--color-icon-data)",
|
|
386
|
+
exit: "var(--color-icon-exit)"
|
|
387
|
+
};
|
|
388
|
+
const ICONS = {
|
|
389
|
+
trigger: Zap,
|
|
390
|
+
email: Mail,
|
|
391
|
+
sms: MessageSquareText,
|
|
392
|
+
push: BellRing,
|
|
393
|
+
in_app: AppWindow,
|
|
394
|
+
slack: MessagesSquare,
|
|
395
|
+
discord: MessageCircle,
|
|
396
|
+
survey: ClipboardList,
|
|
397
|
+
delay: AlarmClock,
|
|
398
|
+
time_window: CalendarClock,
|
|
399
|
+
wait_until: Hourglass,
|
|
400
|
+
branch: GitBranch,
|
|
401
|
+
filter: Filter,
|
|
402
|
+
cohort: Shuffle,
|
|
403
|
+
exit: LogOut,
|
|
404
|
+
send_event: Send,
|
|
405
|
+
action: SquareFunction
|
|
406
|
+
};
|
|
407
|
+
/**
|
|
408
|
+
* A 1px border and nothing else — no drop shadow. It takes --color-edge rather
|
|
409
|
+
* than --color-border, so a card's outline and the connectors between cards are
|
|
410
|
+
* the same weight: on a canvas the wiring is as much a first-class line as the
|
|
411
|
+
* boxes, and one darker step is what replaces the lift the shadow used to give.
|
|
412
|
+
* boxSizing is border-box, so the border sits inside CARD_SIZE and the layout
|
|
413
|
+
* stays on its 8px steps.
|
|
414
|
+
*/
|
|
415
|
+
const baseCard = {
|
|
416
|
+
boxSizing: "border-box",
|
|
417
|
+
background: "var(--color-card)",
|
|
418
|
+
borderWidth: 1,
|
|
419
|
+
borderStyle: "solid",
|
|
420
|
+
borderColor: "var(--color-edge)",
|
|
421
|
+
fontFamily: "'Inter Variable', Inter, ui-sans-serif, system-ui, sans-serif",
|
|
422
|
+
overflow: "hidden",
|
|
423
|
+
...superellipse
|
|
424
|
+
};
|
|
425
|
+
/** Flex column, centred: top and bottom whitespace stay equal without hand-balancing padding against line height. */
|
|
426
|
+
const cardStyle = {
|
|
427
|
+
...baseCard,
|
|
428
|
+
display: "flex",
|
|
429
|
+
flexDirection: "column",
|
|
430
|
+
justifyContent: "center",
|
|
431
|
+
width: CARD_SIZE.w,
|
|
432
|
+
height: CARD_SIZE.h,
|
|
433
|
+
padding: "0 16px",
|
|
434
|
+
borderRadius: 12
|
|
435
|
+
};
|
|
436
|
+
/**
|
|
437
|
+
* The pill sits in a card-width box and centres itself in it. react-flow anchors
|
|
438
|
+
* handles at the measured box's midpoint, so letting the auto-width pill *be*
|
|
439
|
+
* the box put its centre wherever the label happened to end — a couple of
|
|
440
|
+
* pixels off the column the connectors run down.
|
|
441
|
+
*/
|
|
442
|
+
const iconWrapStyle = {
|
|
443
|
+
display: "flex",
|
|
444
|
+
justifyContent: "center",
|
|
445
|
+
width: ICON_SIZE.w,
|
|
446
|
+
height: ICON_SIZE.h
|
|
447
|
+
};
|
|
448
|
+
const iconStyle = {
|
|
449
|
+
...baseCard,
|
|
450
|
+
display: "flex",
|
|
451
|
+
alignItems: "center",
|
|
452
|
+
justifyContent: "center",
|
|
453
|
+
gap: 6,
|
|
454
|
+
width: "fit-content",
|
|
455
|
+
height: ICON_SIZE.h,
|
|
456
|
+
padding: "0 16px 0 12px",
|
|
457
|
+
borderRadius: 16,
|
|
458
|
+
cornerShape: "round",
|
|
459
|
+
fontSize: 12,
|
|
460
|
+
lineHeight: "16px",
|
|
461
|
+
fontWeight: 600,
|
|
462
|
+
color: "var(--color-secondary)"
|
|
463
|
+
};
|
|
464
|
+
const headerStyle = {
|
|
465
|
+
display: "flex",
|
|
466
|
+
alignItems: "center",
|
|
467
|
+
gap: 8
|
|
468
|
+
};
|
|
469
|
+
const titleStyle = {
|
|
470
|
+
flex: 1,
|
|
471
|
+
minWidth: 0,
|
|
472
|
+
fontSize: 14,
|
|
473
|
+
lineHeight: "20px",
|
|
474
|
+
fontWeight: 600,
|
|
475
|
+
color: "var(--color-primary)",
|
|
476
|
+
whiteSpace: "nowrap",
|
|
477
|
+
overflow: "hidden",
|
|
478
|
+
textOverflow: "ellipsis"
|
|
479
|
+
};
|
|
480
|
+
const countStyle = {
|
|
481
|
+
display: "flex",
|
|
482
|
+
alignItems: "center",
|
|
483
|
+
gap: 4,
|
|
484
|
+
fontSize: 14,
|
|
485
|
+
lineHeight: "20px",
|
|
486
|
+
fontWeight: 600,
|
|
487
|
+
color: "var(--color-primary)"
|
|
488
|
+
};
|
|
489
|
+
const subtitleStyle = {
|
|
490
|
+
marginTop: 4,
|
|
491
|
+
fontSize: 12,
|
|
492
|
+
lineHeight: "16px",
|
|
493
|
+
color: "var(--color-muted)",
|
|
494
|
+
whiteSpace: "nowrap",
|
|
495
|
+
overflow: "hidden",
|
|
496
|
+
textOverflow: "ellipsis"
|
|
497
|
+
};
|
|
498
|
+
const handleStyle = {
|
|
499
|
+
opacity: 0,
|
|
500
|
+
width: 1,
|
|
501
|
+
height: 1,
|
|
502
|
+
minWidth: 0,
|
|
503
|
+
minHeight: 0
|
|
504
|
+
};
|
|
505
|
+
function WorkflowNode({ id, data }) {
|
|
506
|
+
const Icon = ICONS[data.icon];
|
|
507
|
+
const selected = useContext(SelectedContext) === id ? {
|
|
508
|
+
borderColor: "var(--color-accent)",
|
|
509
|
+
boxShadow: "0 0 0 3px var(--color-accent-ring)"
|
|
510
|
+
} : void 0;
|
|
511
|
+
const body = data.variant === "icon" ? /* @__PURE__ */ jsx("div", {
|
|
512
|
+
style: iconWrapStyle,
|
|
513
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
514
|
+
style: {
|
|
515
|
+
...iconStyle,
|
|
516
|
+
...selected
|
|
517
|
+
},
|
|
518
|
+
title: data.subtitle ? `${data.title} · ${data.subtitle}` : data.title,
|
|
519
|
+
children: [/* @__PURE__ */ jsx(Icon, {
|
|
520
|
+
size: 16,
|
|
521
|
+
color: CATEGORY_COLOR[data.category],
|
|
522
|
+
strokeWidth: 2,
|
|
523
|
+
"aria-hidden": true
|
|
524
|
+
}), data.title]
|
|
525
|
+
})
|
|
526
|
+
}) : /* @__PURE__ */ jsxs("div", {
|
|
527
|
+
style: {
|
|
528
|
+
...cardStyle,
|
|
529
|
+
...selected
|
|
530
|
+
},
|
|
531
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
532
|
+
style: headerStyle,
|
|
533
|
+
children: [
|
|
534
|
+
/* @__PURE__ */ jsx(Icon, {
|
|
535
|
+
size: 16,
|
|
536
|
+
color: CATEGORY_COLOR[data.category],
|
|
537
|
+
strokeWidth: 2,
|
|
538
|
+
"aria-hidden": true
|
|
539
|
+
}),
|
|
540
|
+
/* @__PURE__ */ jsx("span", {
|
|
541
|
+
style: titleStyle,
|
|
542
|
+
children: data.title
|
|
543
|
+
}),
|
|
544
|
+
data.count !== void 0 && /* @__PURE__ */ jsxs("span", {
|
|
545
|
+
style: countStyle,
|
|
546
|
+
children: [/* @__PURE__ */ jsx(User, {
|
|
547
|
+
size: 16,
|
|
548
|
+
color: "var(--color-muted)",
|
|
549
|
+
strokeWidth: 2,
|
|
550
|
+
"aria-hidden": true
|
|
551
|
+
}), data.count]
|
|
552
|
+
})
|
|
553
|
+
]
|
|
554
|
+
}), data.subtitle !== void 0 && /* @__PURE__ */ jsx("div", {
|
|
555
|
+
style: subtitleStyle,
|
|
556
|
+
children: data.subtitle
|
|
557
|
+
})]
|
|
558
|
+
});
|
|
559
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
560
|
+
/* @__PURE__ */ jsx(Handle, {
|
|
561
|
+
type: "target",
|
|
562
|
+
position: Position.Top,
|
|
563
|
+
style: handleStyle,
|
|
564
|
+
isConnectable: false
|
|
565
|
+
}),
|
|
566
|
+
body,
|
|
567
|
+
/* @__PURE__ */ jsx(Handle, {
|
|
568
|
+
type: "source",
|
|
569
|
+
position: Position.Bottom,
|
|
570
|
+
style: handleStyle,
|
|
571
|
+
isConnectable: false
|
|
572
|
+
})
|
|
573
|
+
] });
|
|
574
|
+
}
|
|
575
|
+
const nodeTypes = { wf: WorkflowNode };
|
|
576
|
+
/**
|
|
577
|
+
* Edge label pill: 32px tall (8-grid), fully rounded, typography on tailwind's
|
|
578
|
+
* text-xs (12px / 16px). Border on --color-edge like every other outline on the
|
|
579
|
+
* canvas — cards, the exit pill and the connectors all draw at one weight.
|
|
580
|
+
*/
|
|
581
|
+
const edgeLabelStyle = {
|
|
582
|
+
position: "absolute",
|
|
583
|
+
display: "flex",
|
|
584
|
+
alignItems: "center",
|
|
585
|
+
height: 32,
|
|
586
|
+
padding: "0 12px",
|
|
587
|
+
borderRadius: 16,
|
|
588
|
+
background: "var(--color-card)",
|
|
589
|
+
border: "1px solid var(--color-edge)",
|
|
590
|
+
fontFamily: "'Inter Variable', Inter, ui-sans-serif, system-ui, sans-serif",
|
|
591
|
+
fontSize: 12,
|
|
592
|
+
lineHeight: "16px",
|
|
593
|
+
fontWeight: 500,
|
|
594
|
+
color: "var(--color-secondary)",
|
|
595
|
+
pointerEvents: "none"
|
|
596
|
+
};
|
|
597
|
+
/** One bend radius for every corner. */
|
|
598
|
+
const BEND = 16;
|
|
599
|
+
/** How far a labelled fork runs straight down before it turns. */
|
|
600
|
+
const FORK_STEM = 28;
|
|
601
|
+
/** Where a label pill hangs below the deciding node. */
|
|
602
|
+
const LABEL_DROP = 56;
|
|
603
|
+
const DOT_R = 3.5;
|
|
604
|
+
/**
|
|
605
|
+
* react-flow anchors its 1px handles just outside the node box, so both ends of
|
|
606
|
+
* a connector stop one pixel short of the card: the line leaves the bottom edge
|
|
607
|
+
* with a visible hairline under it, and the endpoint dot floats above the top
|
|
608
|
+
* edge. Growing the path by this much at each end — and placing the dot's
|
|
609
|
+
* bottom at the same point — closes both seams.
|
|
610
|
+
*/
|
|
611
|
+
const HANDLE_INSET = 1;
|
|
612
|
+
/** Endpoint dot, sized off DOT_R so the SVG geometry and the HTML marker agree. */
|
|
613
|
+
const dotStyle = {
|
|
614
|
+
position: "absolute",
|
|
615
|
+
boxSizing: "border-box",
|
|
616
|
+
width: DOT_R * 2,
|
|
617
|
+
height: DOT_R * 2,
|
|
618
|
+
borderRadius: "50%",
|
|
619
|
+
background: "var(--color-card)",
|
|
620
|
+
border: "1px solid var(--color-edge)",
|
|
621
|
+
pointerEvents: "none"
|
|
622
|
+
};
|
|
623
|
+
/**
|
|
624
|
+
* Corner control-point factor. A circular arc's classic value is 0.552; pulling
|
|
625
|
+
* it out to 0.9 squares the shoulder off, approximating the look of
|
|
626
|
+
* corner-shape: superellipse. (CSS corner-shape does not apply to SVG paths, so
|
|
627
|
+
* the shape is built by hand from cubic béziers.)
|
|
628
|
+
*/
|
|
629
|
+
const SQUIRCLE = .9;
|
|
630
|
+
/** A superellipse shoulder bending from (x1,y1) through the corner (cx,cy) to (x2,y2). */
|
|
631
|
+
function corner(x1, y1, cx, cy, x2, y2) {
|
|
632
|
+
return `C ${x1 + (cx - x1) * SQUIRCLE} ${y1 + (cy - y1) * SQUIRCLE}, ${x2 + (cx - x2) * SQUIRCLE} ${y2 + (cy - y2) * SQUIRCLE}, ${x2} ${y2}`;
|
|
633
|
+
}
|
|
634
|
+
/** Three-segment orthogonal route (down, across, down); `splitY` is where the horizontal run sits. */
|
|
635
|
+
function orthogonalPath(sx, sy, tx, ty, splitY) {
|
|
636
|
+
const dx = tx - sx;
|
|
637
|
+
if (Math.abs(dx) < 1) return `M ${sx} ${sy} L ${tx} ${ty}`;
|
|
638
|
+
const dir = Math.sign(dx);
|
|
639
|
+
const r = Math.max(0, Math.min(BEND, Math.abs(dx) / 2, splitY - sy, ty - splitY));
|
|
640
|
+
return [
|
|
641
|
+
`M ${sx} ${sy}`,
|
|
642
|
+
`L ${sx} ${splitY - r}`,
|
|
643
|
+
corner(sx, splitY - r, sx, splitY, sx + dir * r, splitY),
|
|
644
|
+
`L ${tx - dir * r} ${splitY}`,
|
|
645
|
+
corner(tx - dir * r, splitY, tx, splitY, tx, splitY + r),
|
|
646
|
+
`L ${tx} ${ty}`
|
|
647
|
+
].join(" ");
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* Custom edge with an HTML label: SVG EdgeText's height floats with the font's
|
|
651
|
+
* bounding box, and only HTML can be pinned to exact pixels.
|
|
652
|
+
*
|
|
653
|
+
* Labels anchor one of two ways — never at the path midpoint, since a short
|
|
654
|
+
* horizontal run would disappear entirely behind the pill:
|
|
655
|
+
* - target: above the arm's entry corner (a real arm; customer.io's position)
|
|
656
|
+
* - source: right below the deciding node (empty pass-through arm, which also
|
|
657
|
+
* keeps several merge-edge labels from colliding at the far end)
|
|
658
|
+
*/
|
|
659
|
+
function WorkflowEdge({ id, sourceX, sourceY, targetX, targetY, label, style, data }) {
|
|
660
|
+
const anchoredAtSource = data?.anchor === "source";
|
|
661
|
+
const splitY = label ? sourceY + (anchoredAtSource ? LABEL_DROP : FORK_STEM) : (sourceY + targetY) / 2;
|
|
662
|
+
const path = orthogonalPath(sourceX, sourceY - HANDLE_INSET, targetX, targetY + HANDLE_INSET, splitY);
|
|
663
|
+
const labelPos = {
|
|
664
|
+
x: anchoredAtSource ? sourceX : targetX,
|
|
665
|
+
y: sourceY + LABEL_DROP
|
|
666
|
+
};
|
|
667
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(BaseEdge, {
|
|
668
|
+
id,
|
|
669
|
+
path,
|
|
670
|
+
style
|
|
671
|
+
}), /* @__PURE__ */ jsxs(EdgeLabelRenderer, { children: [/* @__PURE__ */ jsx("div", { style: {
|
|
672
|
+
...dotStyle,
|
|
673
|
+
transform: `translate(-50%, -50%) translate(${targetX}px, ${targetY + HANDLE_INSET - DOT_R}px)`
|
|
674
|
+
} }), !!label && /* @__PURE__ */ jsx("div", {
|
|
675
|
+
style: {
|
|
676
|
+
...edgeLabelStyle,
|
|
677
|
+
transform: `translate(-50%, -50%) translate(${labelPos.x}px, ${labelPos.y}px)`
|
|
678
|
+
},
|
|
679
|
+
children: label
|
|
680
|
+
})] })] });
|
|
681
|
+
}
|
|
682
|
+
const edgeTypes = { wf: WorkflowEdge };
|
|
683
|
+
function WorkflowCanvas({ ir, stats, colorMode = "light", selectedId, onSelectNode }) {
|
|
684
|
+
const { nodes, edges } = useMemo(() => layout(ir, stats), [ir, stats]);
|
|
685
|
+
return /* @__PURE__ */ jsx(SelectedContext, {
|
|
686
|
+
value: selectedId,
|
|
687
|
+
children: /* @__PURE__ */ jsx(CanvasSurface, {
|
|
688
|
+
nodes,
|
|
689
|
+
edges,
|
|
690
|
+
colorMode,
|
|
691
|
+
...onSelectNode !== void 0 ? { onSelectNode } : {}
|
|
692
|
+
})
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
function CanvasSurface({ nodes, edges, colorMode, onSelectNode }) {
|
|
696
|
+
return /* @__PURE__ */ jsx("div", {
|
|
697
|
+
style: {
|
|
698
|
+
width: "100%",
|
|
699
|
+
height: "100%"
|
|
700
|
+
},
|
|
701
|
+
children: /* @__PURE__ */ jsxs(ReactFlow, {
|
|
702
|
+
nodes,
|
|
703
|
+
edges,
|
|
704
|
+
nodeTypes,
|
|
705
|
+
edgeTypes,
|
|
706
|
+
colorMode,
|
|
707
|
+
onNodeClick: (_event, node) => onSelectNode?.(node.id),
|
|
708
|
+
onPaneClick: () => onSelectNode?.(void 0),
|
|
709
|
+
style: { background: "var(--color-canvas)" },
|
|
710
|
+
fitView: true,
|
|
711
|
+
minZoom: .2,
|
|
712
|
+
nodesDraggable: false,
|
|
713
|
+
nodesConnectable: false,
|
|
714
|
+
elementsSelectable: false,
|
|
715
|
+
defaultEdgeOptions: {
|
|
716
|
+
type: "wf",
|
|
717
|
+
style: { stroke: "var(--color-edge)" }
|
|
718
|
+
},
|
|
719
|
+
children: [/* @__PURE__ */ jsx(Background, {
|
|
720
|
+
gap: 16,
|
|
721
|
+
color: "var(--color-grid)"
|
|
722
|
+
}), /* @__PURE__ */ jsx(Controls, { showInteractive: false })]
|
|
723
|
+
})
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
//#endregion
|
|
727
|
+
//#region src/utils/template-content.ts
|
|
728
|
+
/** The sample props the studio renders with: the template's `preview`. */
|
|
729
|
+
function previewPropsOf(entry) {
|
|
730
|
+
return { ...entry.preview };
|
|
731
|
+
}
|
|
732
|
+
function failureOf(error, phase) {
|
|
733
|
+
if (error instanceof TemplateValidationError) return {
|
|
734
|
+
phase: error.phase,
|
|
735
|
+
issues: error.issues
|
|
736
|
+
};
|
|
737
|
+
return {
|
|
738
|
+
phase,
|
|
739
|
+
issues: [{
|
|
740
|
+
path: "",
|
|
741
|
+
message: error instanceof Error ? error.message : String(error)
|
|
742
|
+
}]
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
/**
|
|
746
|
+
* The notification a push template produces for some props: its `content`
|
|
747
|
+
* over the parsed props, through the SDK (output checked, nothing
|
|
748
|
+
* placeholder-filled afterwards).
|
|
749
|
+
*/
|
|
750
|
+
function resolvePush(entry, key, props) {
|
|
751
|
+
try {
|
|
752
|
+
return {
|
|
753
|
+
ok: true,
|
|
754
|
+
push: renderPushContent(entry, key, props ?? previewPropsOf(entry))
|
|
755
|
+
};
|
|
756
|
+
} catch (error) {
|
|
757
|
+
return {
|
|
758
|
+
ok: false,
|
|
759
|
+
failure: failureOf(error, "content")
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
/** The Discord message a template posts for some props, checked like a send checks it. */
|
|
764
|
+
function resolveDiscord(entry, key, props) {
|
|
765
|
+
try {
|
|
766
|
+
return {
|
|
767
|
+
ok: true,
|
|
768
|
+
message: renderDiscordContent(entry, key, props ?? previewPropsOf(entry))
|
|
769
|
+
};
|
|
770
|
+
} catch (error) {
|
|
771
|
+
return {
|
|
772
|
+
ok: false,
|
|
773
|
+
failure: failureOf(error, "content")
|
|
774
|
+
};
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
/** The Slack message a template posts for some props, checked like a send checks it. */
|
|
778
|
+
function resolveSlack(entry, key, props) {
|
|
779
|
+
try {
|
|
780
|
+
return {
|
|
781
|
+
ok: true,
|
|
782
|
+
message: renderSlackContent(entry, key, props ?? previewPropsOf(entry))
|
|
783
|
+
};
|
|
784
|
+
} catch (error) {
|
|
785
|
+
return {
|
|
786
|
+
ok: false,
|
|
787
|
+
failure: failureOf(error, "content")
|
|
788
|
+
};
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
//#endregion
|
|
792
|
+
//#region src/components/chat-markup.tsx
|
|
793
|
+
const code = (text, key) => /* @__PURE__ */ jsx("code", {
|
|
794
|
+
className: "rounded bg-black/10 px-1 py-px font-mono text-[0.85em] dark:bg-white/10",
|
|
795
|
+
children: text
|
|
796
|
+
}, key);
|
|
797
|
+
const link = (href, text, key, className) => /* @__PURE__ */ jsx("a", {
|
|
798
|
+
href,
|
|
799
|
+
target: "_blank",
|
|
800
|
+
rel: "noreferrer",
|
|
801
|
+
className,
|
|
802
|
+
children: text
|
|
803
|
+
}, key);
|
|
804
|
+
const RULES = {
|
|
805
|
+
discord: [
|
|
806
|
+
{
|
|
807
|
+
pattern: /`([^`]+)`/,
|
|
808
|
+
render: (m, key) => code(m[1] ?? "", key)
|
|
809
|
+
},
|
|
810
|
+
{
|
|
811
|
+
pattern: /\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/,
|
|
812
|
+
render: (m, key, linkClass) => link(m[2] ?? "", m[1] ?? "", key, linkClass)
|
|
813
|
+
},
|
|
814
|
+
{
|
|
815
|
+
pattern: /\*\*([^*]+)\*\*/,
|
|
816
|
+
render: (m, key) => /* @__PURE__ */ jsx("strong", { children: m[1] }, key)
|
|
817
|
+
},
|
|
818
|
+
{
|
|
819
|
+
pattern: /(?<!\w)__([^_]+)__(?!\w)/,
|
|
820
|
+
render: (m, key) => /* @__PURE__ */ jsx("u", { children: m[1] }, key)
|
|
821
|
+
},
|
|
822
|
+
{
|
|
823
|
+
pattern: /~~([^~]+)~~/,
|
|
824
|
+
render: (m, key) => /* @__PURE__ */ jsx("s", { children: m[1] }, key)
|
|
825
|
+
},
|
|
826
|
+
{
|
|
827
|
+
pattern: /\*([^*]+)\*|(?<!\w)_([^_]+)_(?!\w)/,
|
|
828
|
+
render: (m, key) => /* @__PURE__ */ jsx("em", { children: m[1] ?? m[2] }, key)
|
|
829
|
+
},
|
|
830
|
+
{
|
|
831
|
+
pattern: /(https?:\/\/[^\s<]+)/,
|
|
832
|
+
render: (m, key, linkClass) => link(m[1] ?? "", m[1] ?? "", key, linkClass)
|
|
833
|
+
}
|
|
834
|
+
],
|
|
835
|
+
slack: [
|
|
836
|
+
{
|
|
837
|
+
pattern: /`([^`]+)`/,
|
|
838
|
+
render: (m, key) => code(m[1] ?? "", key)
|
|
839
|
+
},
|
|
840
|
+
{
|
|
841
|
+
pattern: /<((?:https?:\/\/|mailto:|tel:)[^|>]+)(?:\|([^>]+))?>/,
|
|
842
|
+
render: (m, key, linkClass) => link(m[1] ?? "", m[2] ?? m[1] ?? "", key, linkClass)
|
|
843
|
+
},
|
|
844
|
+
{
|
|
845
|
+
pattern: /(?<!\w)\*([^*]+)\*(?!\w)/,
|
|
846
|
+
render: (m, key) => /* @__PURE__ */ jsx("strong", { children: m[1] }, key)
|
|
847
|
+
},
|
|
848
|
+
{
|
|
849
|
+
pattern: /(?<!\w)_([^_]+)_(?!\w)/,
|
|
850
|
+
render: (m, key) => /* @__PURE__ */ jsx("em", { children: m[1] }, key)
|
|
851
|
+
},
|
|
852
|
+
{
|
|
853
|
+
pattern: /(?<!\w)~([^~]+)~(?!\w)/,
|
|
854
|
+
render: (m, key) => /* @__PURE__ */ jsx("s", { children: m[1] }, key)
|
|
855
|
+
}
|
|
856
|
+
]
|
|
857
|
+
};
|
|
858
|
+
function inline(text, dialect, linkClass, prefix) {
|
|
859
|
+
const out = [];
|
|
860
|
+
let rest = text;
|
|
861
|
+
let index = 0;
|
|
862
|
+
while (rest !== "") {
|
|
863
|
+
let best;
|
|
864
|
+
for (const rule of RULES[dialect]) {
|
|
865
|
+
const match = rule.pattern.exec(rest);
|
|
866
|
+
if (match !== null && (best === void 0 || match.index < best.match.index)) best = {
|
|
867
|
+
match,
|
|
868
|
+
rule
|
|
869
|
+
};
|
|
870
|
+
}
|
|
871
|
+
if (best === void 0) {
|
|
872
|
+
out.push(rest);
|
|
873
|
+
break;
|
|
874
|
+
}
|
|
875
|
+
if (best.match.index > 0) out.push(rest.slice(0, best.match.index));
|
|
876
|
+
out.push(best.rule.render(best.match, `${prefix}${index++}`, linkClass));
|
|
877
|
+
rest = rest.slice(best.match.index + best.match[0].length);
|
|
878
|
+
}
|
|
879
|
+
return out;
|
|
880
|
+
}
|
|
881
|
+
/** Lines kept as lines; each formatted inline. */
|
|
882
|
+
function ChatMarkup({ text, dialect, linkClass }) {
|
|
883
|
+
const lines = text.split("\n");
|
|
884
|
+
return /* @__PURE__ */ jsx(Fragment, { children: lines.map((line, i) => /* @__PURE__ */ jsxs("span", { children: [inline(line, dialect, linkClass, `${i}-`), i < lines.length - 1 && /* @__PURE__ */ jsx("br", {})] }, i)) });
|
|
885
|
+
}
|
|
886
|
+
//#endregion
|
|
887
|
+
//#region src/components/discord-preview.tsx
|
|
888
|
+
const PALETTE$1 = {
|
|
889
|
+
dark: {
|
|
890
|
+
bg: "#313338",
|
|
891
|
+
text: "#dbdee1",
|
|
892
|
+
muted: "#949ba4",
|
|
893
|
+
name: "#f2f3f5",
|
|
894
|
+
embed: "#2b2d31"
|
|
895
|
+
},
|
|
896
|
+
light: {
|
|
897
|
+
bg: "#ffffff",
|
|
898
|
+
text: "#313338",
|
|
899
|
+
muted: "#5c5e66",
|
|
900
|
+
name: "#060607",
|
|
901
|
+
embed: "#f2f3f5"
|
|
902
|
+
}
|
|
903
|
+
};
|
|
904
|
+
const hex = (color) => color === void 0 || color === null ? "#1e1f22" : `#${color.toString(16).padStart(6, "0")}`;
|
|
905
|
+
function DiscordPreview({ message, appName, scheme, zoom }) {
|
|
906
|
+
const { t } = useTranslation();
|
|
907
|
+
const colors = PALETTE$1[scheme];
|
|
908
|
+
const name = message.username ?? appName;
|
|
909
|
+
const linkClass = "text-[#00a8fc] hover:underline";
|
|
910
|
+
return /* @__PURE__ */ jsx("div", {
|
|
911
|
+
className: "mx-auto w-full max-w-2xl overflow-hidden rounded-2xl shadow-sm",
|
|
912
|
+
style: {
|
|
913
|
+
...superellipse,
|
|
914
|
+
background: colors.bg,
|
|
915
|
+
transform: `scale(${zoom})`,
|
|
916
|
+
transformOrigin: "top center"
|
|
917
|
+
},
|
|
918
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
919
|
+
className: "flex gap-4 px-4 py-4",
|
|
920
|
+
style: { color: colors.text },
|
|
921
|
+
children: [message.avatar_url ? /* @__PURE__ */ jsx("img", {
|
|
922
|
+
src: message.avatar_url,
|
|
923
|
+
alt: "",
|
|
924
|
+
className: "size-10 shrink-0 rounded-full object-cover"
|
|
925
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
926
|
+
className: "flex size-10 shrink-0 items-center justify-center rounded-full bg-[#5865f2] text-sm font-semibold text-white",
|
|
927
|
+
children: name.slice(0, 1).toUpperCase()
|
|
928
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
929
|
+
className: "min-w-0 flex-1 text-[15px] leading-[1.375]",
|
|
930
|
+
children: [
|
|
931
|
+
/* @__PURE__ */ jsxs("div", {
|
|
932
|
+
className: "flex items-center gap-1.5",
|
|
933
|
+
children: [
|
|
934
|
+
/* @__PURE__ */ jsx("span", {
|
|
935
|
+
className: "font-medium",
|
|
936
|
+
style: { color: colors.name },
|
|
937
|
+
children: name
|
|
938
|
+
}),
|
|
939
|
+
/* @__PURE__ */ jsx("span", {
|
|
940
|
+
className: "rounded-[3px] bg-[#5865f2] px-1 text-[10px] leading-4 font-semibold text-white",
|
|
941
|
+
children: "APP"
|
|
942
|
+
}),
|
|
943
|
+
/* @__PURE__ */ jsx("span", {
|
|
944
|
+
className: "text-xs",
|
|
945
|
+
style: { color: colors.muted },
|
|
946
|
+
children: t("emails.chatNow")
|
|
947
|
+
})
|
|
948
|
+
]
|
|
949
|
+
}),
|
|
950
|
+
message.content !== void 0 && message.content !== "" && /* @__PURE__ */ jsx("div", {
|
|
951
|
+
className: "break-words whitespace-pre-wrap",
|
|
952
|
+
children: /* @__PURE__ */ jsx(ChatMarkup, {
|
|
953
|
+
text: message.content,
|
|
954
|
+
dialect: "discord",
|
|
955
|
+
linkClass
|
|
956
|
+
})
|
|
957
|
+
}),
|
|
958
|
+
(message.embeds ?? []).map((embed, index) => /* @__PURE__ */ jsxs("div", {
|
|
959
|
+
className: "mt-1.5 grid max-w-[516px] grid-cols-[1fr_auto] gap-x-4 rounded-[4px] border-l-4 py-2 pr-4 pl-3",
|
|
960
|
+
style: {
|
|
961
|
+
borderLeftColor: hex(embed.color),
|
|
962
|
+
background: colors.embed
|
|
963
|
+
},
|
|
964
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
965
|
+
className: "min-w-0",
|
|
966
|
+
children: [
|
|
967
|
+
embed.author !== void 0 && /* @__PURE__ */ jsxs("div", {
|
|
968
|
+
className: "mt-1 flex items-center gap-2 text-sm font-semibold",
|
|
969
|
+
style: { color: colors.name },
|
|
970
|
+
children: [embed.author.icon_url !== void 0 && /* @__PURE__ */ jsx("img", {
|
|
971
|
+
src: embed.author.icon_url,
|
|
972
|
+
alt: "",
|
|
973
|
+
className: "size-6 rounded-full"
|
|
974
|
+
}), embed.author.name]
|
|
975
|
+
}),
|
|
976
|
+
embed.title !== void 0 && /* @__PURE__ */ jsx("div", {
|
|
977
|
+
className: "mt-1 font-semibold",
|
|
978
|
+
style: { color: embed.url ? void 0 : colors.name },
|
|
979
|
+
children: embed.url ? /* @__PURE__ */ jsx("a", {
|
|
980
|
+
href: embed.url,
|
|
981
|
+
target: "_blank",
|
|
982
|
+
rel: "noreferrer",
|
|
983
|
+
className: linkClass,
|
|
984
|
+
children: embed.title
|
|
985
|
+
}) : embed.title
|
|
986
|
+
}),
|
|
987
|
+
embed.description !== void 0 && /* @__PURE__ */ jsx("div", {
|
|
988
|
+
className: "mt-1 text-sm break-words whitespace-pre-wrap",
|
|
989
|
+
children: /* @__PURE__ */ jsx(ChatMarkup, {
|
|
990
|
+
text: embed.description,
|
|
991
|
+
dialect: "discord",
|
|
992
|
+
linkClass
|
|
993
|
+
})
|
|
994
|
+
}),
|
|
995
|
+
(embed.fields ?? []).length > 0 && /* @__PURE__ */ jsx("div", {
|
|
996
|
+
className: "mt-2 grid grid-cols-3 gap-2",
|
|
997
|
+
children: (embed.fields ?? []).map((field, i) => /* @__PURE__ */ jsxs("div", {
|
|
998
|
+
className: field.inline ? "col-span-1" : "col-span-3",
|
|
999
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
1000
|
+
className: "text-sm font-semibold",
|
|
1001
|
+
style: { color: colors.name },
|
|
1002
|
+
children: field.name
|
|
1003
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
1004
|
+
className: "text-sm whitespace-pre-wrap",
|
|
1005
|
+
children: /* @__PURE__ */ jsx(ChatMarkup, {
|
|
1006
|
+
text: field.value,
|
|
1007
|
+
dialect: "discord",
|
|
1008
|
+
linkClass
|
|
1009
|
+
})
|
|
1010
|
+
})]
|
|
1011
|
+
}, i))
|
|
1012
|
+
}),
|
|
1013
|
+
embed.image?.url !== void 0 && /* @__PURE__ */ jsx("img", {
|
|
1014
|
+
src: embed.image.url,
|
|
1015
|
+
alt: "",
|
|
1016
|
+
className: "mt-4 max-h-[300px] rounded-[4px] object-contain"
|
|
1017
|
+
}),
|
|
1018
|
+
(embed.footer !== void 0 || embed.timestamp !== void 0) && /* @__PURE__ */ jsxs("div", {
|
|
1019
|
+
className: "mt-2 flex items-center gap-2 text-xs",
|
|
1020
|
+
style: { color: colors.muted },
|
|
1021
|
+
children: [embed.footer?.icon_url !== void 0 && /* @__PURE__ */ jsx("img", {
|
|
1022
|
+
src: embed.footer.icon_url,
|
|
1023
|
+
alt: "",
|
|
1024
|
+
className: "size-5 rounded-full"
|
|
1025
|
+
}), [embed.footer?.text, embed.timestamp && new Date(embed.timestamp).toLocaleString()].filter(Boolean).join(" • ")]
|
|
1026
|
+
})
|
|
1027
|
+
]
|
|
1028
|
+
}), embed.thumbnail?.url !== void 0 && /* @__PURE__ */ jsx("img", {
|
|
1029
|
+
src: embed.thumbnail.url,
|
|
1030
|
+
alt: "",
|
|
1031
|
+
className: "mt-2 size-20 rounded-[4px] object-cover"
|
|
1032
|
+
})]
|
|
1033
|
+
}, index))
|
|
1034
|
+
]
|
|
1035
|
+
})]
|
|
1036
|
+
})
|
|
1037
|
+
});
|
|
1038
|
+
}
|
|
1039
|
+
//#endregion
|
|
1040
|
+
//#region src/components/email-thumbnail.tsx
|
|
1041
|
+
/**
|
|
1042
|
+
* Dark-mode simulation for a rendered email: emails are authored light, so a
|
|
1043
|
+
* dark stage inverts the document and re-inverts imagery. Shared with the
|
|
1044
|
+
* templates page so the thumbnail and the full preview agree.
|
|
1045
|
+
*/
|
|
1046
|
+
const DARK_SIMULATION = "<style>html{background:#fff;filter:invert(0.92) hue-rotate(180deg)}img,video{filter:invert(1) hue-rotate(180deg)}</style>";
|
|
1047
|
+
//#endregion
|
|
1048
|
+
//#region src/app/assets/devices/iphone-17-pro.png
|
|
1049
|
+
var require_iphone_17_pro = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1050
|
+
module.exports = "./assets/iphone-17-pro-DzaacWSl.png";
|
|
1051
|
+
}));
|
|
1052
|
+
//#endregion
|
|
1053
|
+
//#region src/app/assets/devices/pixel-10-pro-back.webp
|
|
1054
|
+
var require_pixel_10_pro_back = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1055
|
+
module.exports = "./assets/pixel-10-pro-back-7MDj1_lz.webp";
|
|
1056
|
+
}));
|
|
1057
|
+
//#endregion
|
|
1058
|
+
//#region src/app/assets/devices/pixel-10-pro-mask.webp
|
|
1059
|
+
var require_pixel_10_pro_mask = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1060
|
+
module.exports = "./assets/pixel-10-pro-mask-Bi1deQ9Y.webp";
|
|
1061
|
+
}));
|
|
1062
|
+
//#endregion
|
|
1063
|
+
//#region src/components/push-preview.tsx
|
|
1064
|
+
var import_iphone_17_pro = /* @__PURE__ */ __toESM(require_iphone_17_pro(), 1);
|
|
1065
|
+
var import_pixel_10_pro_back = /* @__PURE__ */ __toESM(require_pixel_10_pro_back(), 1);
|
|
1066
|
+
var import_pixel_10_pro_mask = /* @__PURE__ */ __toESM(require_pixel_10_pro_mask(), 1);
|
|
1067
|
+
/** The keynote clock: every device mockup shows 9:41. */
|
|
1068
|
+
const CLOCK = "9:41";
|
|
1069
|
+
/** Rendered device width; the frames' aspect ratios set everything else. */
|
|
1070
|
+
const DEVICE_W = 300;
|
|
1071
|
+
/** Measured from the bezel PNG (alpha scan of the transparent cutout). */
|
|
1072
|
+
const IPHONE = {
|
|
1073
|
+
w: 1350,
|
|
1074
|
+
h: 2760,
|
|
1075
|
+
screen: {
|
|
1076
|
+
x: 72,
|
|
1077
|
+
y: 69,
|
|
1078
|
+
w: 1206,
|
|
1079
|
+
h: 2622
|
|
1080
|
+
},
|
|
1081
|
+
screenRadius: 185,
|
|
1082
|
+
logicalW: 402
|
|
1083
|
+
};
|
|
1084
|
+
/** From the frame's layout descriptor (display size/offset, corner_radius). */
|
|
1085
|
+
const PIXEL = {
|
|
1086
|
+
w: 1410,
|
|
1087
|
+
h: 2968,
|
|
1088
|
+
screen: {
|
|
1089
|
+
x: 59,
|
|
1090
|
+
y: 60,
|
|
1091
|
+
w: 1280,
|
|
1092
|
+
h: 2856
|
|
1093
|
+
},
|
|
1094
|
+
screenRadius: 99,
|
|
1095
|
+
logicalW: 412
|
|
1096
|
+
};
|
|
1097
|
+
/**
|
|
1098
|
+
* Apple's continuous corner — a true squircle, not the studio's subtler 1.2.
|
|
1099
|
+
* Falls back to plain border-radius where `corner-shape` is unsupported.
|
|
1100
|
+
*/
|
|
1101
|
+
const squircle = { cornerShape: "superellipse(2)" };
|
|
1102
|
+
/** App icon stand-in: initial on a gradient, sized by the caller. */
|
|
1103
|
+
function AppIcon({ name, size, radius, shape, className }) {
|
|
1104
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1105
|
+
"aria-hidden": true,
|
|
1106
|
+
className: `flex shrink-0 items-center justify-center font-semibold text-white ${className ?? ""}`,
|
|
1107
|
+
style: {
|
|
1108
|
+
width: size,
|
|
1109
|
+
height: size,
|
|
1110
|
+
borderRadius: radius,
|
|
1111
|
+
fontSize: size * .48,
|
|
1112
|
+
background: "linear-gradient(135deg,#6366f1 0%,#8b5cf6 55%,#d946ef 100%)",
|
|
1113
|
+
...shape
|
|
1114
|
+
},
|
|
1115
|
+
children: (name.trim().charAt(0) || "A").toUpperCase()
|
|
1116
|
+
});
|
|
1117
|
+
}
|
|
1118
|
+
/**
|
|
1119
|
+
* One device: platform label above, then the frame artwork with the software
|
|
1120
|
+
* screen composited into its window. Children render at the device's logical
|
|
1121
|
+
* resolution and are scaled to fit, so their styles use real pt / dp values.
|
|
1122
|
+
*/
|
|
1123
|
+
function Device({ label, dark, geometry, underlay, overlay, overlayPlacement = "frame", screenShape, wallpaper, children }) {
|
|
1124
|
+
const scale = DEVICE_W / geometry.w;
|
|
1125
|
+
const screenRect = {
|
|
1126
|
+
position: "absolute",
|
|
1127
|
+
left: geometry.screen.x * scale,
|
|
1128
|
+
top: geometry.screen.y * scale,
|
|
1129
|
+
width: geometry.screen.w * scale,
|
|
1130
|
+
height: geometry.screen.h * scale
|
|
1131
|
+
};
|
|
1132
|
+
const frameRect = {
|
|
1133
|
+
position: "absolute",
|
|
1134
|
+
inset: 0,
|
|
1135
|
+
width: "100%",
|
|
1136
|
+
height: "100%"
|
|
1137
|
+
};
|
|
1138
|
+
const logicalScale = geometry.screen.w * scale / geometry.logicalW;
|
|
1139
|
+
const logicalH = geometry.screen.h / geometry.screen.w * geometry.logicalW;
|
|
1140
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1141
|
+
className: "shrink-0",
|
|
1142
|
+
style: { width: DEVICE_W },
|
|
1143
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
1144
|
+
className: "mb-3 text-center text-[14px] font-semibold",
|
|
1145
|
+
style: { color: dark ? "var(--color-gray-400)" : "var(--color-gray-500)" },
|
|
1146
|
+
children: label
|
|
1147
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
1148
|
+
className: "relative",
|
|
1149
|
+
style: {
|
|
1150
|
+
width: DEVICE_W,
|
|
1151
|
+
height: Math.round(geometry.h * scale),
|
|
1152
|
+
filter: dark ? "drop-shadow(0 20px 40px rgba(0,0,0,0.55))" : "drop-shadow(0 20px 40px rgba(15,23,42,0.3))"
|
|
1153
|
+
},
|
|
1154
|
+
children: [
|
|
1155
|
+
underlay !== void 0 && /* @__PURE__ */ jsx("img", {
|
|
1156
|
+
src: underlay,
|
|
1157
|
+
alt: "",
|
|
1158
|
+
style: frameRect
|
|
1159
|
+
}),
|
|
1160
|
+
/* @__PURE__ */ jsx("div", {
|
|
1161
|
+
className: "overflow-hidden",
|
|
1162
|
+
style: {
|
|
1163
|
+
...screenRect,
|
|
1164
|
+
borderRadius: geometry.screenRadius * scale,
|
|
1165
|
+
background: wallpaper,
|
|
1166
|
+
...screenShape
|
|
1167
|
+
},
|
|
1168
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
1169
|
+
className: "flex flex-col",
|
|
1170
|
+
style: {
|
|
1171
|
+
width: geometry.logicalW,
|
|
1172
|
+
height: logicalH,
|
|
1173
|
+
transform: `scale(${logicalScale})`,
|
|
1174
|
+
transformOrigin: "top left"
|
|
1175
|
+
},
|
|
1176
|
+
children
|
|
1177
|
+
})
|
|
1178
|
+
}),
|
|
1179
|
+
/* @__PURE__ */ jsx("img", {
|
|
1180
|
+
src: overlay,
|
|
1181
|
+
alt: "",
|
|
1182
|
+
className: "pointer-events-none",
|
|
1183
|
+
style: overlayPlacement === "screen" ? screenRect : frameRect
|
|
1184
|
+
})
|
|
1185
|
+
]
|
|
1186
|
+
})]
|
|
1187
|
+
});
|
|
1188
|
+
}
|
|
1189
|
+
/** iOS lock-screen wallpaper; the inspector's push thumbnail uses the same one. */
|
|
1190
|
+
const IOS_WALLPAPER = {
|
|
1191
|
+
light: "linear-gradient(170deg,#a9c4ff 0%,#d5b3f7 52%,#ffc0d3 100%)",
|
|
1192
|
+
dark: "linear-gradient(170deg,#26355f 0%,#45296b 52%,#131625 100%)"
|
|
1193
|
+
};
|
|
1194
|
+
const IOS_FACE = { fontFamily: "-apple-system, 'SF Pro Text', system-ui, sans-serif" };
|
|
1195
|
+
/**
|
|
1196
|
+
* The banner alone, to the iOS 26 kit: 8pt side margins (386 wide on a 402pt
|
|
1197
|
+
* screen), padding 14/12, a 10pt gap after the 38pt icon, and the time
|
|
1198
|
+
* top-right. The lock screen composes it; the inspector thumbnail shows it bare.
|
|
1199
|
+
*/
|
|
1200
|
+
function IosBanner({ appName, title, body, dark }) {
|
|
1201
|
+
const primary = dark ? "rgba(255,255,255,0.96)" : "rgba(0,0,0,0.9)";
|
|
1202
|
+
const secondary = dark ? "rgba(235,235,245,0.6)" : "#4D4D4D";
|
|
1203
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1204
|
+
className: "relative mx-[8px] shrink-0 rounded-[40px] px-[14px] py-[12px]",
|
|
1205
|
+
style: {
|
|
1206
|
+
...IOS_FACE,
|
|
1207
|
+
background: dark ? "rgba(110,115,135,0.34)" : "rgba(250,250,252,0.5)",
|
|
1208
|
+
backdropFilter: "blur(28px) saturate(180%)",
|
|
1209
|
+
WebkitBackdropFilter: "blur(28px) saturate(180%)",
|
|
1210
|
+
boxShadow: dark ? "0 8px 32px rgba(0,0,0,0.35), inset 0 0 0 1px rgba(255,255,255,0.16)" : "0 8px 32px rgba(0,0,0,0.12), inset 0 0 0 1px rgba(255,255,255,0.55)",
|
|
1211
|
+
...squircle
|
|
1212
|
+
},
|
|
1213
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
1214
|
+
className: "flex gap-[10px]",
|
|
1215
|
+
children: [
|
|
1216
|
+
/* @__PURE__ */ jsx(AppIcon, {
|
|
1217
|
+
name: appName,
|
|
1218
|
+
size: 38,
|
|
1219
|
+
radius: 12,
|
|
1220
|
+
shape: squircle,
|
|
1221
|
+
className: "self-center"
|
|
1222
|
+
}),
|
|
1223
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1224
|
+
className: "min-w-0 flex-1 self-center",
|
|
1225
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
1226
|
+
className: "truncate text-[15px] leading-[17px] font-semibold tracking-[-0.23px]",
|
|
1227
|
+
style: { color: primary },
|
|
1228
|
+
children: title
|
|
1229
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
1230
|
+
className: "line-clamp-4 text-[15px] leading-[18px] tracking-[-0.23px]",
|
|
1231
|
+
style: { color: primary },
|
|
1232
|
+
children: body
|
|
1233
|
+
})]
|
|
1234
|
+
}),
|
|
1235
|
+
/* @__PURE__ */ jsx("span", {
|
|
1236
|
+
className: "shrink-0 self-start text-[15px] leading-[17px]",
|
|
1237
|
+
style: { color: secondary },
|
|
1238
|
+
children: "now"
|
|
1239
|
+
})
|
|
1240
|
+
]
|
|
1241
|
+
})
|
|
1242
|
+
});
|
|
1243
|
+
}
|
|
1244
|
+
function IosDevice({ appName, title, body, dark }) {
|
|
1245
|
+
return /* @__PURE__ */ jsx(Device, {
|
|
1246
|
+
label: "iOS",
|
|
1247
|
+
dark,
|
|
1248
|
+
geometry: IPHONE,
|
|
1249
|
+
overlay: import_iphone_17_pro.default,
|
|
1250
|
+
screenShape: squircle,
|
|
1251
|
+
wallpaper: dark ? IOS_WALLPAPER.dark : IOS_WALLPAPER.light,
|
|
1252
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
1253
|
+
className: "relative flex min-h-0 flex-1 flex-col",
|
|
1254
|
+
style: IOS_FACE,
|
|
1255
|
+
children: [
|
|
1256
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1257
|
+
"aria-hidden": true,
|
|
1258
|
+
className: "pointer-events-none absolute inset-0",
|
|
1259
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
1260
|
+
className: "absolute rounded-full",
|
|
1261
|
+
style: {
|
|
1262
|
+
left: 20,
|
|
1263
|
+
top: 540,
|
|
1264
|
+
width: 240,
|
|
1265
|
+
height: 240,
|
|
1266
|
+
background: `radial-gradient(circle, ${dark ? "rgba(125,110,255,0.4)" : "rgba(255,255,255,0.75)"}, transparent 65%)`
|
|
1267
|
+
}
|
|
1268
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
1269
|
+
className: "absolute rounded-full",
|
|
1270
|
+
style: {
|
|
1271
|
+
right: -40,
|
|
1272
|
+
top: 640,
|
|
1273
|
+
width: 280,
|
|
1274
|
+
height: 280,
|
|
1275
|
+
background: `radial-gradient(circle, ${dark ? "rgba(70,150,255,0.32)" : "rgba(255,170,205,0.7)"}, transparent 65%)`
|
|
1276
|
+
}
|
|
1277
|
+
})]
|
|
1278
|
+
}),
|
|
1279
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1280
|
+
className: "mt-[76px] shrink-0 text-center",
|
|
1281
|
+
style: {
|
|
1282
|
+
color: "rgba(255,255,255,0.95)",
|
|
1283
|
+
textShadow: "0 1px 18px rgba(0,0,0,0.18)"
|
|
1284
|
+
},
|
|
1285
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
1286
|
+
className: "text-[22px] leading-[26px] font-medium",
|
|
1287
|
+
children: "Monday, June 9"
|
|
1288
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
1289
|
+
className: "mt-[3px] text-[100px] leading-[100px] font-semibold tracking-[-2px]",
|
|
1290
|
+
children: CLOCK
|
|
1291
|
+
})]
|
|
1292
|
+
}),
|
|
1293
|
+
/* @__PURE__ */ jsx("div", { className: "min-h-0 flex-1" }),
|
|
1294
|
+
/* @__PURE__ */ jsx(IosBanner, {
|
|
1295
|
+
appName,
|
|
1296
|
+
title,
|
|
1297
|
+
body,
|
|
1298
|
+
dark
|
|
1299
|
+
}),
|
|
1300
|
+
/* @__PURE__ */ jsx("div", {
|
|
1301
|
+
className: "mt-[24px] mb-[12px] flex shrink-0 items-center justify-between px-[52px]",
|
|
1302
|
+
children: [Flashlight, Camera].map((Icon, index) => /* @__PURE__ */ jsx("span", {
|
|
1303
|
+
className: "flex size-[50px] items-center justify-center rounded-full backdrop-blur-md",
|
|
1304
|
+
style: {
|
|
1305
|
+
background: "rgba(20,20,24,0.34)",
|
|
1306
|
+
color: "rgba(255,255,255,0.92)"
|
|
1307
|
+
},
|
|
1308
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
1309
|
+
size: 22,
|
|
1310
|
+
strokeWidth: 2,
|
|
1311
|
+
"aria-hidden": true
|
|
1312
|
+
})
|
|
1313
|
+
}, index))
|
|
1314
|
+
}),
|
|
1315
|
+
/* @__PURE__ */ jsx("div", {
|
|
1316
|
+
className: "mx-auto mb-[9px] h-[5px] w-[148px] shrink-0 rounded-full",
|
|
1317
|
+
style: { background: "rgba(255,255,255,0.9)" }
|
|
1318
|
+
})
|
|
1319
|
+
]
|
|
1320
|
+
})
|
|
1321
|
+
});
|
|
1322
|
+
}
|
|
1323
|
+
function AndroidDevice({ appName, title, body, dark }) {
|
|
1324
|
+
const face = { fontFamily: "Roboto, 'Google Sans', system-ui, sans-serif" };
|
|
1325
|
+
const primary = dark ? "rgba(255,255,255,0.95)" : "rgba(27,27,31,0.95)";
|
|
1326
|
+
const secondary = dark ? "rgba(255,255,255,0.65)" : "rgba(68,71,78,0.8)";
|
|
1327
|
+
return /* @__PURE__ */ jsx(Device, {
|
|
1328
|
+
label: "Android",
|
|
1329
|
+
dark,
|
|
1330
|
+
geometry: PIXEL,
|
|
1331
|
+
underlay: import_pixel_10_pro_back.default,
|
|
1332
|
+
overlay: import_pixel_10_pro_mask.default,
|
|
1333
|
+
overlayPlacement: "screen",
|
|
1334
|
+
wallpaper: dark ? "linear-gradient(170deg,#1d2b33 0%,#262040 58%,#0f1317 100%)" : "linear-gradient(170deg,#b6d2c8 0%,#a3c2b4 55%,#ddd3c0 100%)",
|
|
1335
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
1336
|
+
className: "flex min-h-0 flex-1 flex-col",
|
|
1337
|
+
style: face,
|
|
1338
|
+
children: [
|
|
1339
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1340
|
+
className: "mt-[88px] shrink-0 text-center",
|
|
1341
|
+
style: { color: dark ? "rgba(255,255,255,0.95)" : "rgba(28,44,40,0.9)" },
|
|
1342
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
1343
|
+
className: "text-[16px] leading-[22px] font-medium",
|
|
1344
|
+
children: "Mon, Jun 9"
|
|
1345
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
1346
|
+
className: "text-[64px] leading-[1.1] font-normal",
|
|
1347
|
+
children: CLOCK
|
|
1348
|
+
})]
|
|
1349
|
+
}),
|
|
1350
|
+
/* @__PURE__ */ jsx("div", {
|
|
1351
|
+
className: "mx-[12px] mt-[28px] shrink-0 rounded-[16px] p-[12px] backdrop-blur-md",
|
|
1352
|
+
style: {
|
|
1353
|
+
background: dark ? "rgba(64,68,76,0.78)" : "rgba(255,255,255,0.92)",
|
|
1354
|
+
boxShadow: dark ? "0 4px 16px rgba(0,0,0,0.3), inset 0 0 0 1px rgba(255,255,255,0.08)" : "0 4px 16px rgba(0,0,0,0.12)"
|
|
1355
|
+
},
|
|
1356
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
1357
|
+
className: "flex items-center gap-[12px]",
|
|
1358
|
+
children: [
|
|
1359
|
+
/* @__PURE__ */ jsx(AppIcon, {
|
|
1360
|
+
name: appName,
|
|
1361
|
+
size: 40,
|
|
1362
|
+
radius: 12
|
|
1363
|
+
}),
|
|
1364
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1365
|
+
className: "min-w-0 flex-1",
|
|
1366
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
1367
|
+
className: "flex items-baseline gap-[6px]",
|
|
1368
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1369
|
+
className: "min-w-0 truncate text-[14px] leading-[20px] font-bold",
|
|
1370
|
+
style: { color: primary },
|
|
1371
|
+
children: title
|
|
1372
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
1373
|
+
className: "shrink-0 text-[14px] leading-[20px]",
|
|
1374
|
+
style: { color: secondary },
|
|
1375
|
+
children: "• now"
|
|
1376
|
+
})]
|
|
1377
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
1378
|
+
className: "line-clamp-2 text-[14px] leading-[20px]",
|
|
1379
|
+
style: { color: primary },
|
|
1380
|
+
children: body
|
|
1381
|
+
})]
|
|
1382
|
+
}),
|
|
1383
|
+
/* @__PURE__ */ jsx("span", {
|
|
1384
|
+
className: "flex size-[28px] shrink-0 items-center justify-center rounded-full",
|
|
1385
|
+
style: {
|
|
1386
|
+
background: dark ? "rgba(255,255,255,0.12)" : "rgba(27,27,31,0.08)",
|
|
1387
|
+
color: secondary
|
|
1388
|
+
},
|
|
1389
|
+
children: /* @__PURE__ */ jsx(ChevronDown, {
|
|
1390
|
+
size: 16,
|
|
1391
|
+
strokeWidth: 2.5,
|
|
1392
|
+
"aria-hidden": true
|
|
1393
|
+
})
|
|
1394
|
+
})
|
|
1395
|
+
]
|
|
1396
|
+
})
|
|
1397
|
+
}),
|
|
1398
|
+
/* @__PURE__ */ jsx("div", { className: "min-h-0 flex-1" }),
|
|
1399
|
+
/* @__PURE__ */ jsx("div", {
|
|
1400
|
+
className: "mb-[18px] flex shrink-0 justify-center",
|
|
1401
|
+
style: { color: dark ? "rgba(255,255,255,0.85)" : "rgba(28,44,40,0.8)" },
|
|
1402
|
+
children: /* @__PURE__ */ jsx(Lock, {
|
|
1403
|
+
size: 18,
|
|
1404
|
+
strokeWidth: 2.5,
|
|
1405
|
+
"aria-hidden": true
|
|
1406
|
+
})
|
|
1407
|
+
})
|
|
1408
|
+
]
|
|
1409
|
+
})
|
|
1410
|
+
});
|
|
1411
|
+
}
|
|
1412
|
+
function PushPreview({ appName, title, body, scheme, zoom }) {
|
|
1413
|
+
const dark = scheme === "dark";
|
|
1414
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1415
|
+
className: "flex flex-wrap items-start justify-center gap-12 pt-2",
|
|
1416
|
+
style: {
|
|
1417
|
+
transform: `scale(${zoom})`,
|
|
1418
|
+
transformOrigin: "top center"
|
|
1419
|
+
},
|
|
1420
|
+
children: [/* @__PURE__ */ jsx(IosDevice, {
|
|
1421
|
+
appName,
|
|
1422
|
+
title,
|
|
1423
|
+
body,
|
|
1424
|
+
dark
|
|
1425
|
+
}), /* @__PURE__ */ jsx(AndroidDevice, {
|
|
1426
|
+
appName,
|
|
1427
|
+
title,
|
|
1428
|
+
body,
|
|
1429
|
+
dark
|
|
1430
|
+
})]
|
|
1431
|
+
});
|
|
1432
|
+
}
|
|
1433
|
+
//#endregion
|
|
1434
|
+
//#region src/components/slack-preview.tsx
|
|
1435
|
+
const PALETTE = {
|
|
1436
|
+
dark: {
|
|
1437
|
+
bg: "#1a1d21",
|
|
1438
|
+
text: "#d1d2d3",
|
|
1439
|
+
muted: "#ababad",
|
|
1440
|
+
name: "#ffffff",
|
|
1441
|
+
border: "#35373b"
|
|
1442
|
+
},
|
|
1443
|
+
light: {
|
|
1444
|
+
bg: "#ffffff",
|
|
1445
|
+
text: "#1d1c1d",
|
|
1446
|
+
muted: "#616061",
|
|
1447
|
+
name: "#1d1c1d",
|
|
1448
|
+
border: "#dddddd"
|
|
1449
|
+
}
|
|
1450
|
+
};
|
|
1451
|
+
const textOf = (value) => {
|
|
1452
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
1453
|
+
const object = value;
|
|
1454
|
+
return typeof object.text === "string" ? object : void 0;
|
|
1455
|
+
};
|
|
1456
|
+
function SlackPreview({ message, appName, scheme, zoom }) {
|
|
1457
|
+
const { t } = useTranslation();
|
|
1458
|
+
const colors = PALETTE[scheme];
|
|
1459
|
+
const name = message.username ?? appName;
|
|
1460
|
+
const linkClass = "text-[#1d9bd1] hover:underline";
|
|
1461
|
+
const Text = ({ value, className }) => value === void 0 ? null : /* @__PURE__ */ jsx("div", {
|
|
1462
|
+
className: `break-words whitespace-pre-wrap ${className ?? ""}`,
|
|
1463
|
+
children: value.type === "mrkdwn" ? /* @__PURE__ */ jsx(ChatMarkup, {
|
|
1464
|
+
text: value.text,
|
|
1465
|
+
dialect: "slack",
|
|
1466
|
+
linkClass
|
|
1467
|
+
}) : value.text
|
|
1468
|
+
});
|
|
1469
|
+
const Button = ({ element }) => {
|
|
1470
|
+
const style = element.style;
|
|
1471
|
+
return /* @__PURE__ */ jsx("span", {
|
|
1472
|
+
className: "inline-flex h-8 items-center rounded-lg border px-3 text-[13px] font-bold",
|
|
1473
|
+
style: style === "primary" ? {
|
|
1474
|
+
background: "#007a5a",
|
|
1475
|
+
borderColor: "#007a5a",
|
|
1476
|
+
color: "#fff"
|
|
1477
|
+
} : style === "danger" ? {
|
|
1478
|
+
background: "#e01e5a",
|
|
1479
|
+
borderColor: "#e01e5a",
|
|
1480
|
+
color: "#fff"
|
|
1481
|
+
} : {
|
|
1482
|
+
borderColor: colors.border,
|
|
1483
|
+
color: colors.name
|
|
1484
|
+
},
|
|
1485
|
+
children: textOf(element.text)?.text
|
|
1486
|
+
});
|
|
1487
|
+
};
|
|
1488
|
+
const blocks = message.blocks ?? [];
|
|
1489
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1490
|
+
className: "mx-auto w-full max-w-2xl overflow-hidden rounded-2xl border shadow-sm",
|
|
1491
|
+
style: {
|
|
1492
|
+
...superellipse,
|
|
1493
|
+
background: colors.bg,
|
|
1494
|
+
borderColor: colors.border,
|
|
1495
|
+
transform: `scale(${zoom})`,
|
|
1496
|
+
transformOrigin: "top center"
|
|
1497
|
+
},
|
|
1498
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
1499
|
+
className: "flex gap-2 px-5 py-4 text-[15px] leading-[1.46668]",
|
|
1500
|
+
style: { color: colors.text },
|
|
1501
|
+
children: [message.icon_url ? /* @__PURE__ */ jsx("img", {
|
|
1502
|
+
src: message.icon_url,
|
|
1503
|
+
alt: "",
|
|
1504
|
+
className: "size-9 shrink-0 rounded-lg object-cover"
|
|
1505
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
1506
|
+
className: "flex size-9 shrink-0 items-center justify-center rounded-lg bg-[#4a154b] text-sm font-bold text-white",
|
|
1507
|
+
children: message.icon_emoji === void 0 ? name.slice(0, 1).toUpperCase() : "🙂"
|
|
1508
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
1509
|
+
className: "flex min-w-0 flex-1 flex-col gap-1",
|
|
1510
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
1511
|
+
className: "flex items-baseline gap-1.5",
|
|
1512
|
+
children: [
|
|
1513
|
+
/* @__PURE__ */ jsx("span", {
|
|
1514
|
+
className: "font-black",
|
|
1515
|
+
style: { color: colors.name },
|
|
1516
|
+
children: name
|
|
1517
|
+
}),
|
|
1518
|
+
/* @__PURE__ */ jsx("span", {
|
|
1519
|
+
className: "rounded-[3px] px-1 text-[10px] font-bold",
|
|
1520
|
+
style: {
|
|
1521
|
+
background: scheme === "dark" ? "#35373b" : "#e8e8e8",
|
|
1522
|
+
color: colors.muted
|
|
1523
|
+
},
|
|
1524
|
+
children: "APP"
|
|
1525
|
+
}),
|
|
1526
|
+
/* @__PURE__ */ jsx("span", {
|
|
1527
|
+
className: "text-xs",
|
|
1528
|
+
style: { color: colors.muted },
|
|
1529
|
+
children: t("emails.chatNow")
|
|
1530
|
+
})
|
|
1531
|
+
]
|
|
1532
|
+
}), blocks.length === 0 ? /* @__PURE__ */ jsx(Text, { value: {
|
|
1533
|
+
type: message.mrkdwn === false ? "plain_text" : "mrkdwn",
|
|
1534
|
+
text: message.text
|
|
1535
|
+
} }) : blocks.map((block, index) => {
|
|
1536
|
+
const key = index;
|
|
1537
|
+
switch (block.type) {
|
|
1538
|
+
case "header": return /* @__PURE__ */ jsx("div", {
|
|
1539
|
+
className: "mt-1 text-lg font-black",
|
|
1540
|
+
style: { color: colors.name },
|
|
1541
|
+
children: textOf(block.text)?.text
|
|
1542
|
+
}, key);
|
|
1543
|
+
case "divider": return /* @__PURE__ */ jsx("hr", {
|
|
1544
|
+
className: "my-2",
|
|
1545
|
+
style: { borderColor: colors.border }
|
|
1546
|
+
}, key);
|
|
1547
|
+
case "section": {
|
|
1548
|
+
const fields = block.fields ?? [];
|
|
1549
|
+
const accessory = block.accessory;
|
|
1550
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1551
|
+
className: "flex gap-3",
|
|
1552
|
+
children: [
|
|
1553
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1554
|
+
className: "min-w-0 flex-1",
|
|
1555
|
+
children: [/* @__PURE__ */ jsx(Text, { value: textOf(block.text) }), fields.length > 0 && /* @__PURE__ */ jsx("div", {
|
|
1556
|
+
className: "mt-2 grid grid-cols-2 gap-x-4 gap-y-2",
|
|
1557
|
+
children: fields.map((field, i) => /* @__PURE__ */ jsx(Text, { value: textOf(field) }, i))
|
|
1558
|
+
})]
|
|
1559
|
+
}),
|
|
1560
|
+
accessory?.type === "image" && /* @__PURE__ */ jsx("img", {
|
|
1561
|
+
src: accessory.image_url,
|
|
1562
|
+
alt: accessory.alt_text ?? "",
|
|
1563
|
+
className: "size-[88px] shrink-0 rounded-lg object-cover"
|
|
1564
|
+
}),
|
|
1565
|
+
accessory?.type === "button" && /* @__PURE__ */ jsx(Button, { element: accessory })
|
|
1566
|
+
]
|
|
1567
|
+
}, key);
|
|
1568
|
+
}
|
|
1569
|
+
case "context": return /* @__PURE__ */ jsx("div", {
|
|
1570
|
+
className: "flex flex-wrap items-center gap-1.5 text-xs",
|
|
1571
|
+
style: { color: colors.muted },
|
|
1572
|
+
children: (block.elements ?? []).map((element, i) => element.type === "image" ? /* @__PURE__ */ jsx("img", {
|
|
1573
|
+
src: element.image_url,
|
|
1574
|
+
alt: "",
|
|
1575
|
+
className: "size-4 rounded"
|
|
1576
|
+
}, i) : /* @__PURE__ */ jsx(Text, { value: textOf(element) }, i))
|
|
1577
|
+
}, key);
|
|
1578
|
+
case "actions": return /* @__PURE__ */ jsx("div", {
|
|
1579
|
+
className: "mt-1 flex flex-wrap gap-2",
|
|
1580
|
+
children: (block.elements ?? []).map((element, i) => element.type === "button" ? /* @__PURE__ */ jsx(Button, { element }, i) : null)
|
|
1581
|
+
}, key);
|
|
1582
|
+
case "image": return /* @__PURE__ */ jsxs("figure", {
|
|
1583
|
+
className: "mt-1",
|
|
1584
|
+
children: [textOf(block.title) !== void 0 && /* @__PURE__ */ jsx("figcaption", {
|
|
1585
|
+
className: "mb-1 text-sm",
|
|
1586
|
+
style: { color: colors.muted },
|
|
1587
|
+
children: textOf(block.title)?.text
|
|
1588
|
+
}), /* @__PURE__ */ jsx("img", {
|
|
1589
|
+
src: block.image_url,
|
|
1590
|
+
alt: block.alt_text ?? "",
|
|
1591
|
+
className: "max-h-[300px] rounded-lg object-contain"
|
|
1592
|
+
})]
|
|
1593
|
+
}, key);
|
|
1594
|
+
default: return /* @__PURE__ */ jsx("div", {
|
|
1595
|
+
className: "text-xs italic",
|
|
1596
|
+
style: { color: colors.muted },
|
|
1597
|
+
children: t("emails.slackBlockUnsupported", { type: block.type })
|
|
1598
|
+
}, key);
|
|
1599
|
+
}
|
|
1600
|
+
})]
|
|
1601
|
+
})]
|
|
1602
|
+
})
|
|
1603
|
+
});
|
|
1604
|
+
}
|
|
1605
|
+
//#endregion
|
|
1606
|
+
//#region src/components/textarea/index.tsx
|
|
1607
|
+
const SIZE_STYLE$1 = {
|
|
1608
|
+
xs: "px-2 py-[5px] text-xs rounded-md focus-visible:ring-2",
|
|
1609
|
+
sm: "px-2 py-[7px] text-sm rounded-lg focus-visible:ring-3",
|
|
1610
|
+
md: "px-3 py-[9px] text-sm rounded-xl focus-visible:ring-3",
|
|
1611
|
+
lg: "px-4 py-[11px] text-md rounded-xl focus-visible:ring-4",
|
|
1612
|
+
xl: "px-4 py-[13px] text-lg rounded-2xl focus-visible:ring-4"
|
|
1613
|
+
};
|
|
1614
|
+
function Textarea({ size = "md", className, ...props }) {
|
|
1615
|
+
return /* @__PURE__ */ jsx("textarea", {
|
|
1616
|
+
...props,
|
|
1617
|
+
className: cn("transition-colors duration-100 focus:outline-none", "placeholder-placeholder bg-textfield focus-visible:border-accent border", "dark:focus-visible:ring-accent/50 focus-visible:ring-accent/40", SIZE_STYLE$1[size], className)
|
|
1618
|
+
});
|
|
1619
|
+
}
|
|
1620
|
+
//#endregion
|
|
1621
|
+
//#region src/components/templates-page.tsx
|
|
1622
|
+
/**
|
|
1623
|
+
* One label/value row. A fragment rather than a wrapper so the rows land
|
|
1624
|
+
* directly in the parent grid: the label column then sizes to the longest label
|
|
1625
|
+
* — a custom header name can be any length and must not wrap — and every row
|
|
1626
|
+
* stays aligned with the others. One face, one size throughout.
|
|
1627
|
+
*/
|
|
1628
|
+
function Field({ label, children }) {
|
|
1629
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("dt", {
|
|
1630
|
+
className: "text-muted whitespace-nowrap",
|
|
1631
|
+
children: label
|
|
1632
|
+
}), /* @__PURE__ */ jsx("dd", {
|
|
1633
|
+
className: "text-secondary min-w-0 break-words",
|
|
1634
|
+
children
|
|
1635
|
+
})] });
|
|
1636
|
+
}
|
|
1637
|
+
const NO_SCROLL = "<style>html,body{overflow:hidden}</style>";
|
|
1638
|
+
/** A refused render: which phase, then every failing field path with its message. */
|
|
1639
|
+
function TemplateFailurePanel({ failure }) {
|
|
1640
|
+
const { t } = useTranslation();
|
|
1641
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1642
|
+
role: "alert",
|
|
1643
|
+
className: "mx-auto max-w-xl rounded-2xl border border-red-200 bg-red-50 p-6 text-sm text-red-700 dark:border-red-400/20 dark:bg-red-400/10 dark:text-red-300",
|
|
1644
|
+
style: superellipse,
|
|
1645
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
1646
|
+
className: "font-medium",
|
|
1647
|
+
children: t(`emails.failure.${failure.phase}`)
|
|
1648
|
+
}), /* @__PURE__ */ jsx("ul", {
|
|
1649
|
+
className: "mt-2 flex flex-col gap-1",
|
|
1650
|
+
children: failure.issues.map((issue, index) => /* @__PURE__ */ jsxs("li", { children: [issue.path !== "" && /* @__PURE__ */ jsx("code", {
|
|
1651
|
+
className: "mr-2 font-mono",
|
|
1652
|
+
children: issue.path
|
|
1653
|
+
}), issue.message] }, `${issue.path}:${index}`))
|
|
1654
|
+
})]
|
|
1655
|
+
});
|
|
1656
|
+
}
|
|
1657
|
+
/**
|
|
1658
|
+
* The preview props as JSON, editable in memory. Text that is not a JSON
|
|
1659
|
+
* object is reported here and handed up as a failure, so the preview never
|
|
1660
|
+
* goes on showing the last good render as if it were this one.
|
|
1661
|
+
*/
|
|
1662
|
+
function PreviewPropsEditor({ initial, onChange, onInvalid, onReset }) {
|
|
1663
|
+
const { t } = useTranslation();
|
|
1664
|
+
const [draft, setDraft] = useState(void 0);
|
|
1665
|
+
const text = draft ?? JSON.stringify(initial, null, 2);
|
|
1666
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1667
|
+
className: "border-border bg-card border-b px-6 py-4",
|
|
1668
|
+
children: [
|
|
1669
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1670
|
+
className: "flex items-center justify-between",
|
|
1671
|
+
children: [/* @__PURE__ */ jsx("label", {
|
|
1672
|
+
htmlFor: "preview-props",
|
|
1673
|
+
className: "text-muted text-sm",
|
|
1674
|
+
children: t("emails.previewProps")
|
|
1675
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
1676
|
+
type: "button",
|
|
1677
|
+
onClick: () => {
|
|
1678
|
+
setDraft(void 0);
|
|
1679
|
+
onReset();
|
|
1680
|
+
},
|
|
1681
|
+
className: "text-muted hover:text-primary text-xs transition-colors",
|
|
1682
|
+
children: t("emails.previewPropsReset")
|
|
1683
|
+
})]
|
|
1684
|
+
}),
|
|
1685
|
+
/* @__PURE__ */ jsx(Textarea, {
|
|
1686
|
+
id: "preview-props",
|
|
1687
|
+
size: "sm",
|
|
1688
|
+
rows: Math.min(8, Math.max(2, text.split("\n").length)),
|
|
1689
|
+
spellCheck: false,
|
|
1690
|
+
className: "mt-2 w-full font-mono text-xs",
|
|
1691
|
+
value: text,
|
|
1692
|
+
onChange: (event) => {
|
|
1693
|
+
const next = event.target.value;
|
|
1694
|
+
setDraft(next);
|
|
1695
|
+
let parsed;
|
|
1696
|
+
try {
|
|
1697
|
+
parsed = JSON.parse(next);
|
|
1698
|
+
} catch (error) {
|
|
1699
|
+
onInvalid(error instanceof Error ? error.message : String(error));
|
|
1700
|
+
return;
|
|
1701
|
+
}
|
|
1702
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
1703
|
+
onInvalid(t("emails.previewPropsNotObject"));
|
|
1704
|
+
return;
|
|
1705
|
+
}
|
|
1706
|
+
onChange(parsed);
|
|
1707
|
+
}
|
|
1708
|
+
}),
|
|
1709
|
+
/* @__PURE__ */ jsx("p", {
|
|
1710
|
+
className: "text-muted mt-1.5 text-xs",
|
|
1711
|
+
children: t("emails.previewPropsHint")
|
|
1712
|
+
})
|
|
1713
|
+
]
|
|
1714
|
+
});
|
|
1715
|
+
}
|
|
1716
|
+
/** One control on the floating preview toolbar: a round 32px icon button. */
|
|
1717
|
+
function ToolButton({ active = false, label, onClick, children }) {
|
|
1718
|
+
return /* @__PURE__ */ jsx("button", {
|
|
1719
|
+
type: "button",
|
|
1720
|
+
title: label,
|
|
1721
|
+
"aria-label": label,
|
|
1722
|
+
"aria-pressed": active,
|
|
1723
|
+
onClick,
|
|
1724
|
+
className: cn("flex size-8 items-center justify-center rounded-full transition-colors", active ? "bg-selected text-primary" : "text-muted hover:bg-hover hover:text-primary"),
|
|
1725
|
+
children
|
|
1726
|
+
});
|
|
1727
|
+
}
|
|
1728
|
+
function TemplatesPage({ refs, emails, pushes = {}, discords = {}, slacks = {}, appName, selected, selectedChannel, preview, emailDefaults, previewProps, onPreviewPropsChange, defaultScheme }) {
|
|
1729
|
+
const { t } = useTranslation();
|
|
1730
|
+
const [schemeOverride, setSchemeOverride] = useState(void 0);
|
|
1731
|
+
const scheme = schemeOverride ?? defaultScheme ?? "light";
|
|
1732
|
+
const setScheme = setSchemeOverride;
|
|
1733
|
+
const [device, setDevice] = useState("desktop");
|
|
1734
|
+
const [zoom, setZoom] = useState(1);
|
|
1735
|
+
const active = refs.find((ref) => ref.key === selected && (selectedChannel === void 0 || ref.channel === selectedChannel));
|
|
1736
|
+
const [jsonError, setJsonError] = useState();
|
|
1737
|
+
const isPush = active?.channel === "push";
|
|
1738
|
+
const isEmail = active?.channel === "email";
|
|
1739
|
+
const activeEmail = active !== void 0 && isEmail ? emails[active.key] : void 0;
|
|
1740
|
+
const activePush = active !== void 0 && isPush ? pushes[active.key] : void 0;
|
|
1741
|
+
const isDiscord = active?.channel === "discord";
|
|
1742
|
+
const isSlack = active?.channel === "slack";
|
|
1743
|
+
const isChat = isDiscord || isSlack;
|
|
1744
|
+
const activeDiscord = active !== void 0 && isDiscord ? discords[active.key] : void 0;
|
|
1745
|
+
const activeSlack = active !== void 0 && isSlack ? slacks[active.key] : void 0;
|
|
1746
|
+
const { html, subject, error, loading } = preview;
|
|
1747
|
+
const activeId = active === void 0 ? "" : `${active.channel}:${active.key}`;
|
|
1748
|
+
if (jsonError !== void 0 && jsonError.for !== activeId) setJsonError(void 0);
|
|
1749
|
+
const propsFailure = jsonError?.for === activeId ? {
|
|
1750
|
+
phase: "json",
|
|
1751
|
+
issues: [{
|
|
1752
|
+
path: "",
|
|
1753
|
+
message: jsonError.message
|
|
1754
|
+
}]
|
|
1755
|
+
} : void 0;
|
|
1756
|
+
const failure = propsFailure ?? preview.failure;
|
|
1757
|
+
const pushResolution = active !== void 0 && activePush !== void 0 ? resolvePush(activePush, active.key, previewProps) : void 0;
|
|
1758
|
+
const push = propsFailure === void 0 && pushResolution?.ok === true ? pushResolution.push : void 0;
|
|
1759
|
+
const pushFailure = propsFailure ?? (pushResolution?.ok === false ? pushResolution.failure : void 0);
|
|
1760
|
+
const discordResolution = active !== void 0 && activeDiscord !== void 0 ? resolveDiscord(activeDiscord, active.key, previewProps) : void 0;
|
|
1761
|
+
const slackResolution = active !== void 0 && activeSlack !== void 0 ? resolveSlack(activeSlack, active.key, previewProps) : void 0;
|
|
1762
|
+
const chatResolution = discordResolution ?? slackResolution;
|
|
1763
|
+
const chatFailure = propsFailure ?? (chatResolution?.ok === false ? chatResolution.failure : void 0);
|
|
1764
|
+
const chatReady = propsFailure === void 0 && chatResolution?.ok === true;
|
|
1765
|
+
const editedEntry = isPush ? activePush : isDiscord ? activeDiscord : isSlack ? activeSlack : activeEmail;
|
|
1766
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1767
|
+
className: "flex flex-1",
|
|
1768
|
+
children: /* @__PURE__ */ jsx("section", {
|
|
1769
|
+
className: "bg-page flex min-w-0 flex-1 flex-col",
|
|
1770
|
+
children: active === void 0 ? /* @__PURE__ */ jsx("div", {
|
|
1771
|
+
className: "text-muted flex flex-1 items-center justify-center text-sm",
|
|
1772
|
+
children: selected === void 0 ? t("emails.empty") : t("emails.notFound", { key: selected })
|
|
1773
|
+
}) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1774
|
+
(isEmail && activeEmail !== void 0 || push !== void 0) && /* @__PURE__ */ jsx("div", {
|
|
1775
|
+
className: "border-border bg-card border-b px-6 py-4",
|
|
1776
|
+
children: /* @__PURE__ */ jsxs("dl", {
|
|
1777
|
+
className: "grid grid-cols-[max-content_1fr] gap-x-8 gap-y-2.5 text-sm",
|
|
1778
|
+
children: [isEmail && activeEmail !== void 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1779
|
+
/* @__PURE__ */ jsx(Field, {
|
|
1780
|
+
label: t("emails.from"),
|
|
1781
|
+
children: emailDefaults?.from ?? t("common.none")
|
|
1782
|
+
}),
|
|
1783
|
+
emailDefaults?.replyTo !== void 0 && /* @__PURE__ */ jsx(Field, {
|
|
1784
|
+
label: t("emails.replyTo"),
|
|
1785
|
+
children: emailDefaults.replyTo
|
|
1786
|
+
}),
|
|
1787
|
+
/* @__PURE__ */ jsx(Field, {
|
|
1788
|
+
label: t("emails.subject"),
|
|
1789
|
+
children: subject ?? activeEmail.subject
|
|
1790
|
+
})
|
|
1791
|
+
] }), push !== void 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1792
|
+
/* @__PURE__ */ jsx(Field, {
|
|
1793
|
+
label: t("emails.contentTitle"),
|
|
1794
|
+
children: push.title
|
|
1795
|
+
}),
|
|
1796
|
+
/* @__PURE__ */ jsx(Field, {
|
|
1797
|
+
label: t("emails.contentBody"),
|
|
1798
|
+
children: push.body
|
|
1799
|
+
}),
|
|
1800
|
+
push.image !== void 0 && /* @__PURE__ */ jsx(Field, {
|
|
1801
|
+
label: t("emails.contentImage"),
|
|
1802
|
+
children: push.image
|
|
1803
|
+
})
|
|
1804
|
+
] })]
|
|
1805
|
+
})
|
|
1806
|
+
}),
|
|
1807
|
+
onPreviewPropsChange !== void 0 && editedEntry !== void 0 && /* @__PURE__ */ jsx(PreviewPropsEditor, {
|
|
1808
|
+
initial: previewProps ?? previewPropsOf(editedEntry),
|
|
1809
|
+
onChange: (next) => {
|
|
1810
|
+
setJsonError(void 0);
|
|
1811
|
+
onPreviewPropsChange(next);
|
|
1812
|
+
},
|
|
1813
|
+
onInvalid: (message) => setJsonError({
|
|
1814
|
+
for: activeId,
|
|
1815
|
+
message
|
|
1816
|
+
}),
|
|
1817
|
+
onReset: () => {
|
|
1818
|
+
setJsonError(void 0);
|
|
1819
|
+
onPreviewPropsChange(void 0);
|
|
1820
|
+
}
|
|
1821
|
+
}, activeId),
|
|
1822
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1823
|
+
className: "relative flex flex-1 flex-col",
|
|
1824
|
+
style: {
|
|
1825
|
+
backgroundColor: scheme === "dark" ? "#000" : "var(--color-gray-50)",
|
|
1826
|
+
backgroundImage: `radial-gradient(${scheme === "dark" ? "var(--color-gray-700)" : "var(--color-gray-400)"} 0.5px, transparent 0.5px)`,
|
|
1827
|
+
backgroundSize: "16px 16px"
|
|
1828
|
+
},
|
|
1829
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
1830
|
+
className: "flex-1 p-6 pb-4",
|
|
1831
|
+
children: isChat ? (isDiscord ? activeDiscord : activeSlack) === void 0 ? /* @__PURE__ */ jsxs("div", {
|
|
1832
|
+
className: "border-border bg-card mx-auto max-w-xl rounded-2xl border border-dashed p-8 text-center",
|
|
1833
|
+
style: superellipse,
|
|
1834
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
1835
|
+
className: "text-primary text-sm font-medium",
|
|
1836
|
+
children: t("emails.notRegistered")
|
|
1837
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
1838
|
+
className: "text-muted mt-2 text-sm",
|
|
1839
|
+
children: t("emails.chatNotRegisteredHint", {
|
|
1840
|
+
key: active.key,
|
|
1841
|
+
channel: isDiscord ? "discord" : "slack"
|
|
1842
|
+
})
|
|
1843
|
+
})]
|
|
1844
|
+
}) : chatFailure !== void 0 ? /* @__PURE__ */ jsx(TemplateFailurePanel, { failure: chatFailure }) : discordResolution?.ok === true ? /* @__PURE__ */ jsx(DiscordPreview, {
|
|
1845
|
+
message: discordResolution.message,
|
|
1846
|
+
appName: appName ?? "App",
|
|
1847
|
+
scheme,
|
|
1848
|
+
zoom
|
|
1849
|
+
}) : slackResolution?.ok === true ? /* @__PURE__ */ jsx(SlackPreview, {
|
|
1850
|
+
message: slackResolution.message,
|
|
1851
|
+
appName: appName ?? "App",
|
|
1852
|
+
scheme,
|
|
1853
|
+
zoom
|
|
1854
|
+
}) : null : isPush ? activePush === void 0 ? /* @__PURE__ */ jsxs("div", {
|
|
1855
|
+
className: "border-border bg-card mx-auto max-w-xl rounded-2xl border border-dashed p-8 text-center",
|
|
1856
|
+
style: superellipse,
|
|
1857
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
1858
|
+
className: "text-primary text-sm font-medium",
|
|
1859
|
+
children: t("emails.notRegistered")
|
|
1860
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
1861
|
+
className: "text-muted mt-2 text-sm",
|
|
1862
|
+
children: t("emails.pushNotRegisteredHint", { key: active.key })
|
|
1863
|
+
})]
|
|
1864
|
+
}) : pushFailure !== void 0 ? /* @__PURE__ */ jsx(TemplateFailurePanel, { failure: pushFailure }) : /* @__PURE__ */ jsx(PushPreview, {
|
|
1865
|
+
appName: appName ?? "App",
|
|
1866
|
+
title: push?.title ?? "",
|
|
1867
|
+
body: push?.body ?? "",
|
|
1868
|
+
scheme,
|
|
1869
|
+
zoom
|
|
1870
|
+
}) : activeEmail === void 0 ? /* @__PURE__ */ jsxs("div", {
|
|
1871
|
+
className: "border-border bg-card mx-auto max-w-xl rounded-2xl border border-dashed p-8 text-center",
|
|
1872
|
+
style: superellipse,
|
|
1873
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
1874
|
+
className: "text-primary text-sm font-medium",
|
|
1875
|
+
children: t("emails.notRegistered")
|
|
1876
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
1877
|
+
className: "text-muted mt-2 text-sm",
|
|
1878
|
+
children: t("emails.notRegisteredHint", { key: active.key })
|
|
1879
|
+
})]
|
|
1880
|
+
}) : failure !== void 0 ? /* @__PURE__ */ jsx(TemplateFailurePanel, { failure }) : loading ? /* @__PURE__ */ jsx("div", {
|
|
1881
|
+
className: "text-muted text-center text-sm",
|
|
1882
|
+
children: t("emails.rendering")
|
|
1883
|
+
}) : error !== void 0 ? /* @__PURE__ */ jsx("div", {
|
|
1884
|
+
className: "mx-auto max-w-xl rounded-2xl border border-red-200 bg-red-50 p-6 text-sm text-red-700 dark:border-red-400/20 dark:bg-red-400/10 dark:text-red-300",
|
|
1885
|
+
style: superellipse,
|
|
1886
|
+
children: error
|
|
1887
|
+
}) : /* @__PURE__ */ jsx("iframe", {
|
|
1888
|
+
title: `${active.key} preview`,
|
|
1889
|
+
srcDoc: `${html ?? ""}${NO_SCROLL}${scheme === "dark" ? DARK_SIMULATION : ""}`,
|
|
1890
|
+
onLoad: (event) => {
|
|
1891
|
+
const frame = event.currentTarget;
|
|
1892
|
+
const root = frame.contentDocument?.documentElement ?? void 0;
|
|
1893
|
+
if (root === void 0) return;
|
|
1894
|
+
const height = Math.ceil(root.getBoundingClientRect().height);
|
|
1895
|
+
if (height > 0) frame.style.height = `${height}px`;
|
|
1896
|
+
},
|
|
1897
|
+
className: "mx-auto min-h-40 border",
|
|
1898
|
+
style: {
|
|
1899
|
+
borderColor: scheme === "dark" ? "var(--color-gray-700)" : "var(--color-gray-300)",
|
|
1900
|
+
backgroundColor: "#fff",
|
|
1901
|
+
width: device === "mobile" ? 375 : "100%",
|
|
1902
|
+
maxWidth: device === "mobile" ? 375 : 672,
|
|
1903
|
+
transform: `scale(${zoom})`,
|
|
1904
|
+
transformOrigin: "top center"
|
|
1905
|
+
}
|
|
1906
|
+
})
|
|
1907
|
+
}), (isChat ? chatReady : isPush ? push !== void 0 : activeEmail !== void 0 && !loading && error === void 0 && failure === void 0) && /* @__PURE__ */ jsx("div", {
|
|
1908
|
+
className: "pointer-events-none sticky bottom-0 z-10 flex justify-center pt-2 pb-4",
|
|
1909
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
1910
|
+
className: "border-border bg-card pointer-events-auto flex items-center gap-0.5 rounded-full border p-1 shadow-lg",
|
|
1911
|
+
children: [
|
|
1912
|
+
/* @__PURE__ */ jsx(ToolButton, {
|
|
1913
|
+
active: scheme === "light",
|
|
1914
|
+
label: t("emails.previewLight"),
|
|
1915
|
+
onClick: () => setScheme("light"),
|
|
1916
|
+
children: /* @__PURE__ */ jsx(Sun, {
|
|
1917
|
+
size: 16,
|
|
1918
|
+
strokeWidth: 2,
|
|
1919
|
+
"aria-hidden": true
|
|
1920
|
+
})
|
|
1921
|
+
}),
|
|
1922
|
+
/* @__PURE__ */ jsx(ToolButton, {
|
|
1923
|
+
active: scheme === "dark",
|
|
1924
|
+
label: t("emails.previewDark"),
|
|
1925
|
+
onClick: () => setScheme("dark"),
|
|
1926
|
+
children: /* @__PURE__ */ jsx(Moon, {
|
|
1927
|
+
size: 16,
|
|
1928
|
+
strokeWidth: 2,
|
|
1929
|
+
"aria-hidden": true
|
|
1930
|
+
})
|
|
1931
|
+
}),
|
|
1932
|
+
isEmail && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1933
|
+
/* @__PURE__ */ jsx("div", { className: "bg-border mx-1 h-4 w-px" }),
|
|
1934
|
+
/* @__PURE__ */ jsx(ToolButton, {
|
|
1935
|
+
active: device === "desktop",
|
|
1936
|
+
label: t("emails.previewDesktop"),
|
|
1937
|
+
onClick: () => setDevice("desktop"),
|
|
1938
|
+
children: /* @__PURE__ */ jsx(Monitor, {
|
|
1939
|
+
size: 16,
|
|
1940
|
+
strokeWidth: 2,
|
|
1941
|
+
"aria-hidden": true
|
|
1942
|
+
})
|
|
1943
|
+
}),
|
|
1944
|
+
/* @__PURE__ */ jsx(ToolButton, {
|
|
1945
|
+
active: device === "mobile",
|
|
1946
|
+
label: t("emails.previewMobile"),
|
|
1947
|
+
onClick: () => setDevice("mobile"),
|
|
1948
|
+
children: /* @__PURE__ */ jsx(Smartphone, {
|
|
1949
|
+
size: 16,
|
|
1950
|
+
strokeWidth: 2,
|
|
1951
|
+
"aria-hidden": true
|
|
1952
|
+
})
|
|
1953
|
+
})
|
|
1954
|
+
] }),
|
|
1955
|
+
/* @__PURE__ */ jsx("div", { className: "bg-border mx-1 h-4 w-px" }),
|
|
1956
|
+
/* @__PURE__ */ jsx(ToolButton, {
|
|
1957
|
+
label: t("emails.zoomOut"),
|
|
1958
|
+
onClick: () => setZoom((level) => Math.max(.5, level - .25)),
|
|
1959
|
+
children: /* @__PURE__ */ jsx(Minus, {
|
|
1960
|
+
size: 16,
|
|
1961
|
+
strokeWidth: 2,
|
|
1962
|
+
"aria-hidden": true
|
|
1963
|
+
})
|
|
1964
|
+
}),
|
|
1965
|
+
/* @__PURE__ */ jsxs("button", {
|
|
1966
|
+
type: "button",
|
|
1967
|
+
title: t("emails.zoomReset"),
|
|
1968
|
+
onClick: () => setZoom(1),
|
|
1969
|
+
className: "text-secondary hover:text-primary w-11 text-center text-xs font-medium tabular-nums transition-colors",
|
|
1970
|
+
children: [Math.round(zoom * 100), "%"]
|
|
1971
|
+
}),
|
|
1972
|
+
/* @__PURE__ */ jsx(ToolButton, {
|
|
1973
|
+
label: t("emails.zoomIn"),
|
|
1974
|
+
onClick: () => setZoom((level) => Math.min(1.5, level + .25)),
|
|
1975
|
+
children: /* @__PURE__ */ jsx(Plus, {
|
|
1976
|
+
size: 16,
|
|
1977
|
+
strokeWidth: 2,
|
|
1978
|
+
"aria-hidden": true
|
|
1979
|
+
})
|
|
1980
|
+
})
|
|
1981
|
+
]
|
|
1982
|
+
})
|
|
1983
|
+
})]
|
|
1984
|
+
})
|
|
1985
|
+
] })
|
|
1986
|
+
})
|
|
1987
|
+
});
|
|
1988
|
+
}
|
|
1989
|
+
//#endregion
|
|
1990
|
+
//#region src/utils/label.ts
|
|
1991
|
+
/**
|
|
1992
|
+
* What to call a code-owned asset in the UI.
|
|
1993
|
+
*
|
|
1994
|
+
* Keys are wire identity — referenced by name in IR, keyed on by the engine —
|
|
1995
|
+
* and nothing anyone should have to read. The label is `meta.name` when set;
|
|
1996
|
+
* when it is not, an explicit placeholder, because a blank is easy to miss and
|
|
1997
|
+
* "Untitled" is an invitation to name the thing.
|
|
1998
|
+
*/
|
|
1999
|
+
function displayName(name, untitled) {
|
|
2000
|
+
const trimmed = name?.trim();
|
|
2001
|
+
return trimmed !== void 0 && trimmed !== "" ? trimmed : untitled;
|
|
2002
|
+
}
|
|
2003
|
+
//#endregion
|
|
2004
|
+
//#region src/components/sparkline.tsx
|
|
2005
|
+
function Sparkline({ values, width = 76, height = 26, className }) {
|
|
2006
|
+
if (values.length < 2) return /* @__PURE__ */ jsx("svg", {
|
|
2007
|
+
width,
|
|
2008
|
+
height,
|
|
2009
|
+
className,
|
|
2010
|
+
"aria-hidden": true,
|
|
2011
|
+
children: /* @__PURE__ */ jsx("line", {
|
|
2012
|
+
x1: 0,
|
|
2013
|
+
y1: height - 1,
|
|
2014
|
+
x2: width,
|
|
2015
|
+
y2: height - 1,
|
|
2016
|
+
stroke: "var(--color-border)",
|
|
2017
|
+
strokeWidth: 1.5
|
|
2018
|
+
})
|
|
2019
|
+
});
|
|
2020
|
+
const max = Math.max(...values);
|
|
2021
|
+
const min = Math.min(...values);
|
|
2022
|
+
const span = max - min || 1;
|
|
2023
|
+
const stepX = width / (values.length - 1);
|
|
2024
|
+
const points = values.map((value, index) => {
|
|
2025
|
+
const x = index * stepX;
|
|
2026
|
+
const y = height - 1 - (value - min) / span * (height - 2);
|
|
2027
|
+
return `${x.toFixed(1)},${y.toFixed(1)}`;
|
|
2028
|
+
}).join(" ");
|
|
2029
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
2030
|
+
width,
|
|
2031
|
+
height,
|
|
2032
|
+
className,
|
|
2033
|
+
"aria-hidden": true,
|
|
2034
|
+
children: /* @__PURE__ */ jsx("polyline", {
|
|
2035
|
+
points,
|
|
2036
|
+
fill: "none",
|
|
2037
|
+
stroke: max === min ? "var(--color-border)" : "var(--color-primary)",
|
|
2038
|
+
strokeWidth: 1.5,
|
|
2039
|
+
strokeLinejoin: "round",
|
|
2040
|
+
strokeLinecap: "round"
|
|
2041
|
+
})
|
|
2042
|
+
});
|
|
2043
|
+
}
|
|
2044
|
+
//#endregion
|
|
2045
|
+
//#region src/components/workflow-list.tsx
|
|
2046
|
+
/** Count message and delay nodes across the whole tree, arms included. */
|
|
2047
|
+
function countNodes(nodes, acc = {
|
|
2048
|
+
messages: 0,
|
|
2049
|
+
delays: 0
|
|
2050
|
+
}) {
|
|
2051
|
+
for (const node of nodes) {
|
|
2052
|
+
if (node.type === "message") acc.messages++;
|
|
2053
|
+
if (node.type === "delay" || node.type === "random_delay" || node.type === "wait_until") acc.delays++;
|
|
2054
|
+
if (node.type === "branch") {
|
|
2055
|
+
for (const branchCase of node.cases) countNodes(branchCase.flow, acc);
|
|
2056
|
+
if (node.otherwise) countNodes(node.otherwise, acc);
|
|
2057
|
+
}
|
|
2058
|
+
if (node.type === "cohort") for (const arm of node.arms) countNodes(arm.flow, acc);
|
|
2059
|
+
if (node.type === "wait_until" && Array.isArray(node.onTimeout)) countNodes(node.onTimeout, acc);
|
|
2060
|
+
}
|
|
2061
|
+
return acc;
|
|
2062
|
+
}
|
|
2063
|
+
const compact = (value) => value >= 1e3 ? `${(value / 1e3).toFixed(2).replace(/0+$/, "").replace(/\.$/, "")}k` : `${value}`;
|
|
2064
|
+
const rate = (part, whole) => part === void 0 || whole === void 0 || whole === 0 ? "—" : `${(part / whole * 100).toFixed(1)}%`;
|
|
2065
|
+
const COLUMNS = [
|
|
2066
|
+
"delivered",
|
|
2067
|
+
"opened",
|
|
2068
|
+
"clicked",
|
|
2069
|
+
"converted"
|
|
2070
|
+
];
|
|
2071
|
+
const HEAD_CELL = "border-border border-b py-3 first:rounded-tl-2xl last:rounded-tr-2xl";
|
|
2072
|
+
const CELL = "border-border border-b py-4 max-md:border-b-0 max-md:px-3";
|
|
2073
|
+
function WorkflowList({ items, reports, onOpen }) {
|
|
2074
|
+
const { t } = useTranslation();
|
|
2075
|
+
const byId = new Map((reports ?? []).map((report) => [report.id, report]));
|
|
2076
|
+
return /* @__PURE__ */ jsx("div", {
|
|
2077
|
+
className: "border-border bg-card rounded-2xl border",
|
|
2078
|
+
style: superellipse,
|
|
2079
|
+
children: /* @__PURE__ */ jsxs("table", {
|
|
2080
|
+
className: "w-full table-fixed border-separate border-spacing-0 text-sm max-md:block",
|
|
2081
|
+
children: [/* @__PURE__ */ jsx("thead", {
|
|
2082
|
+
className: "max-md:hidden",
|
|
2083
|
+
children: /* @__PURE__ */ jsxs("tr", {
|
|
2084
|
+
className: "text-muted text-left text-xs font-medium",
|
|
2085
|
+
children: [
|
|
2086
|
+
/* @__PURE__ */ jsx("th", {
|
|
2087
|
+
className: clsx(HEAD_CELL, "min-w-0 px-6"),
|
|
2088
|
+
style: superellipse,
|
|
2089
|
+
children: t("common.name")
|
|
2090
|
+
}),
|
|
2091
|
+
/* @__PURE__ */ jsx("th", {
|
|
2092
|
+
className: clsx(HEAD_CELL, "w-28 px-3"),
|
|
2093
|
+
style: superellipse
|
|
2094
|
+
}),
|
|
2095
|
+
COLUMNS.map((column) => /* @__PURE__ */ jsx("th", {
|
|
2096
|
+
className: clsx(HEAD_CELL, "w-28 px-3"),
|
|
2097
|
+
style: superellipse,
|
|
2098
|
+
children: t(`workflows.columns.${column}`)
|
|
2099
|
+
}, column))
|
|
2100
|
+
]
|
|
2101
|
+
})
|
|
2102
|
+
}), /* @__PURE__ */ jsx("tbody", {
|
|
2103
|
+
className: "max-md:block",
|
|
2104
|
+
children: items.map(({ key, ir }) => {
|
|
2105
|
+
const shape = countNodes(ir.flow);
|
|
2106
|
+
const report = byId.get(ir.id);
|
|
2107
|
+
const values = {
|
|
2108
|
+
delivered: report?.delivered === void 0 ? "—" : compact(report.delivered),
|
|
2109
|
+
opened: rate(report?.opened, report?.delivered),
|
|
2110
|
+
clicked: rate(report?.clicked, report?.delivered),
|
|
2111
|
+
converted: rate(report?.converted, report?.entered)
|
|
2112
|
+
};
|
|
2113
|
+
return /* @__PURE__ */ jsxs("tr", {
|
|
2114
|
+
onClick: () => onOpen(key),
|
|
2115
|
+
className: clsx("cursor-pointer align-top [&>td]:transition-colors", "md:hover:[&>td]:bg-hover md:last:[&>td]:border-b-0", "md:last:[&>td:first-child]:rounded-bl-2xl md:last:[&>td:last-child]:rounded-br-2xl", "border-border max-md:hover:bg-hover max-md:grid max-md:grid-cols-6", "max-md:border-b max-md:px-3 max-md:first:rounded-t-2xl", "max-md:last:rounded-b-2xl max-md:last:border-b-0"),
|
|
2116
|
+
style: superellipse,
|
|
2117
|
+
children: [
|
|
2118
|
+
/* @__PURE__ */ jsx("td", {
|
|
2119
|
+
className: clsx(CELL, "px-6 max-md:order-1 max-md:col-span-6 max-md:pb-2"),
|
|
2120
|
+
style: superellipse,
|
|
2121
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
2122
|
+
className: "flex items-start gap-3",
|
|
2123
|
+
children: [/* @__PURE__ */ jsx(Workflow, {
|
|
2124
|
+
className: "text-muted mt-0.5 size-4 shrink-0",
|
|
2125
|
+
strokeWidth: 2
|
|
2126
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
2127
|
+
className: "min-w-0",
|
|
2128
|
+
children: [
|
|
2129
|
+
/* @__PURE__ */ jsx("div", {
|
|
2130
|
+
className: clsx("truncate font-medium", ir.meta?.name === void 0 ? "text-muted italic" : "text-primary"),
|
|
2131
|
+
children: displayName(ir.meta?.name, t("common.untitled"))
|
|
2132
|
+
}),
|
|
2133
|
+
ir.meta?.description !== void 0 && /* @__PURE__ */ jsx("p", {
|
|
2134
|
+
className: "text-muted mt-1 truncate text-sm max-md:-ml-7",
|
|
2135
|
+
children: ir.meta.description
|
|
2136
|
+
}),
|
|
2137
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2138
|
+
className: "text-muted mt-2 flex items-center gap-3 text-xs max-md:-ml-7",
|
|
2139
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
2140
|
+
className: "flex items-center gap-1",
|
|
2141
|
+
children: [/* @__PURE__ */ jsx(Mail, {
|
|
2142
|
+
className: "size-3.5",
|
|
2143
|
+
strokeWidth: 2
|
|
2144
|
+
}), shape.messages]
|
|
2145
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
2146
|
+
className: "flex items-center gap-1",
|
|
2147
|
+
children: [/* @__PURE__ */ jsx(AlarmClock, {
|
|
2148
|
+
className: "size-3.5",
|
|
2149
|
+
strokeWidth: 2
|
|
2150
|
+
}), shape.delays]
|
|
2151
|
+
})]
|
|
2152
|
+
})
|
|
2153
|
+
]
|
|
2154
|
+
})]
|
|
2155
|
+
})
|
|
2156
|
+
}),
|
|
2157
|
+
/* @__PURE__ */ jsx("td", {
|
|
2158
|
+
className: clsx(CELL, "px-3 max-md:order-3 max-md:col-span-6 max-md:pt-0 max-md:pb-3"),
|
|
2159
|
+
style: superellipse,
|
|
2160
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
2161
|
+
className: clsx("inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium whitespace-nowrap", report ? "bg-green-50 text-green-700 dark:bg-green-400/10 dark:text-green-300" : "bg-selected text-muted"),
|
|
2162
|
+
children: [/* @__PURE__ */ jsx("span", { className: clsx("size-1.5 rounded-full", report ? "bg-green-500" : "bg-muted") }), report ? t("status.running") : t("status.draft")]
|
|
2163
|
+
})
|
|
2164
|
+
}),
|
|
2165
|
+
COLUMNS.map((column) => /* @__PURE__ */ jsxs("td", {
|
|
2166
|
+
className: clsx(CELL, "px-3 max-md:order-4 max-md:col-span-3 max-md:pt-0 max-md:pb-4"),
|
|
2167
|
+
style: superellipse,
|
|
2168
|
+
children: [
|
|
2169
|
+
/* @__PURE__ */ jsx("div", {
|
|
2170
|
+
className: "text-muted mb-1 truncate text-xs md:hidden",
|
|
2171
|
+
children: t(`workflows.columns.${column}`)
|
|
2172
|
+
}),
|
|
2173
|
+
/* @__PURE__ */ jsx("div", {
|
|
2174
|
+
className: "tabular-nums",
|
|
2175
|
+
children: values[column]
|
|
2176
|
+
}),
|
|
2177
|
+
/* @__PURE__ */ jsx(Sparkline, {
|
|
2178
|
+
values: report?.series?.[column] ?? [],
|
|
2179
|
+
className: "mt-1"
|
|
2180
|
+
})
|
|
2181
|
+
]
|
|
2182
|
+
}, column))
|
|
2183
|
+
]
|
|
2184
|
+
}, key);
|
|
2185
|
+
})
|
|
2186
|
+
})]
|
|
2187
|
+
})
|
|
2188
|
+
});
|
|
2189
|
+
}
|
|
2190
|
+
//#endregion
|
|
2191
|
+
//#region src/components/metric-card.tsx
|
|
2192
|
+
/**
|
|
2193
|
+
* viewBox units; `preserveAspectRatio="none"` stretches them to the card.
|
|
2194
|
+
*
|
|
2195
|
+
* The height doubles as the plot's pixel height, which is what lets the hover
|
|
2196
|
+
* indicator place its dots with a y taken straight from the viewBox. The two
|
|
2197
|
+
* are the same number on purpose — move one and the other has to follow, or
|
|
2198
|
+
* the curve stretches vertically and the dots leave it.
|
|
2199
|
+
*/
|
|
2200
|
+
const VIEW_WIDTH = 320;
|
|
2201
|
+
const VIEW_HEIGHT = 120;
|
|
2202
|
+
/** Headroom above the peak so the max label never sits on the curve. */
|
|
2203
|
+
const TOP_PAD = 22;
|
|
2204
|
+
/**
|
|
2205
|
+
* Successive series, each mixed further toward the card it sits on.
|
|
2206
|
+
*
|
|
2207
|
+
* Mixing with the surface — rather than stepping down a fixed ramp — is what
|
|
2208
|
+
* makes one set of shades work in both themes: it pales toward the white card
|
|
2209
|
+
* in light mode and darkens toward the near-black one in dark mode, so the
|
|
2210
|
+
* head series is the highest-contrast line either way and the components read
|
|
2211
|
+
* as subordinate to it. A second hue was the other option and is not on the
|
|
2212
|
+
* table: accent is the only colour in the studio.
|
|
2213
|
+
*/
|
|
2214
|
+
const seriesColor = (index) => `color-mix(in oklab, var(--color-accent) ${Math.round(100 * .7 ** index)}%, var(--color-card))`;
|
|
2215
|
+
/**
|
|
2216
|
+
* A cardinal spline through every point. The samples are daily counts, not a
|
|
2217
|
+
* continuous signal, so the curve is a reading aid rather than interpolation —
|
|
2218
|
+
* which is why it is allowed to overshoot slightly between points.
|
|
2219
|
+
*/
|
|
2220
|
+
function splinePath(points) {
|
|
2221
|
+
if (points.length === 0) return "";
|
|
2222
|
+
const first = points[0];
|
|
2223
|
+
let d = `M ${first.x.toFixed(1)} ${first.y.toFixed(1)}`;
|
|
2224
|
+
for (let i = 0; i < points.length - 1; i++) {
|
|
2225
|
+
const p0 = points[Math.max(0, i - 1)];
|
|
2226
|
+
const p1 = points[i];
|
|
2227
|
+
const p2 = points[i + 1];
|
|
2228
|
+
const p3 = points[Math.min(points.length - 1, i + 2)];
|
|
2229
|
+
const c1x = p1.x + (p2.x - p0.x) / 6;
|
|
2230
|
+
const c1y = p1.y + (p2.y - p0.y) / 6;
|
|
2231
|
+
const c2x = p2.x - (p3.x - p1.x) / 6;
|
|
2232
|
+
const c2y = p2.y - (p3.y - p1.y) / 6;
|
|
2233
|
+
d += ` C ${c1x.toFixed(1)} ${c1y.toFixed(1)}, ${c2x.toFixed(1)} ${c2y.toFixed(1)}, ${p2.x.toFixed(1)} ${p2.y.toFixed(1)}`;
|
|
2234
|
+
}
|
|
2235
|
+
return d;
|
|
2236
|
+
}
|
|
2237
|
+
const TREND_STYLE = {
|
|
2238
|
+
up: "text-emerald-600 dark:text-emerald-400",
|
|
2239
|
+
down: "text-red-600 dark:text-red-400",
|
|
2240
|
+
flat: "text-secondary"
|
|
2241
|
+
};
|
|
2242
|
+
const TREND_ICON = {
|
|
2243
|
+
up: ArrowUp,
|
|
2244
|
+
down: ArrowDown,
|
|
2245
|
+
flat: Minus
|
|
2246
|
+
};
|
|
2247
|
+
function MetricCard({ label, value, delta, dates, series, format }) {
|
|
2248
|
+
const gradientId = useId();
|
|
2249
|
+
/** Which bucket the cursor is over; null once it leaves the plot. */
|
|
2250
|
+
const [active, setActive] = useState(null);
|
|
2251
|
+
const all = series.flatMap((one) => [...one.values]);
|
|
2252
|
+
const max = Math.max(...all, 0);
|
|
2253
|
+
const min = Math.min(...all, max);
|
|
2254
|
+
const span = max - min || 1;
|
|
2255
|
+
const stepX = dates.length > 1 ? VIEW_WIDTH / (dates.length - 1) : 0;
|
|
2256
|
+
const yOf = (point) => TOP_PAD + (1 - (point - min) / span) * 98;
|
|
2257
|
+
const plotted = series.map((one) => one.values.map((point, index) => ({
|
|
2258
|
+
x: index * stepX,
|
|
2259
|
+
y: yOf(point)
|
|
2260
|
+
})));
|
|
2261
|
+
const line = splinePath(plotted.length > 0 ? plotted[0] : []);
|
|
2262
|
+
const area = line === "" ? "" : `${line} L ${VIEW_WIDTH} ${VIEW_HEIGHT} L 0 ${VIEW_HEIGHT} Z`;
|
|
2263
|
+
const DeltaIcon = delta ? TREND_ICON[delta.trend] : void 0;
|
|
2264
|
+
const hovered = active !== null && active < dates.length ? active : void 0;
|
|
2265
|
+
/**
|
|
2266
|
+
* Cursor → bucket. The plot is `preserveAspectRatio="none"`, so its viewBox
|
|
2267
|
+
* is stretched to whatever width the card ended up with; only the rendered
|
|
2268
|
+
* box knows the real scale, and reading x in viewBox units would leave the
|
|
2269
|
+
* indicator a growing distance behind the pointer.
|
|
2270
|
+
*/
|
|
2271
|
+
const trackPointer = (event) => {
|
|
2272
|
+
const { left, width } = event.currentTarget.getBoundingClientRect();
|
|
2273
|
+
if (width === 0 || dates.length === 0) return;
|
|
2274
|
+
const index = Math.round((event.clientX - left) / width * (dates.length - 1));
|
|
2275
|
+
setActive(Math.min(Math.max(index, 0), dates.length - 1));
|
|
2276
|
+
};
|
|
2277
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
2278
|
+
className: "border-border bg-card flex flex-col overflow-hidden rounded-2xl border",
|
|
2279
|
+
style: superellipse,
|
|
2280
|
+
children: [
|
|
2281
|
+
/* @__PURE__ */ jsx("div", {
|
|
2282
|
+
className: "px-4 pt-4",
|
|
2283
|
+
children: /* @__PURE__ */ jsx("h3", {
|
|
2284
|
+
className: "text-sm font-medium",
|
|
2285
|
+
children: label
|
|
2286
|
+
})
|
|
2287
|
+
}),
|
|
2288
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2289
|
+
className: "flex flex-wrap items-baseline gap-x-2 gap-y-1 px-4 pt-3",
|
|
2290
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
2291
|
+
className: "text-2xl font-semibold tracking-tight tabular-nums",
|
|
2292
|
+
children: value
|
|
2293
|
+
}), delta !== void 0 && DeltaIcon !== void 0 && /* @__PURE__ */ jsxs("span", {
|
|
2294
|
+
className: cn("inline-flex items-center gap-1 text-xs", TREND_STYLE[delta.trend]),
|
|
2295
|
+
children: [/* @__PURE__ */ jsx(DeltaIcon, {
|
|
2296
|
+
size: 12,
|
|
2297
|
+
strokeWidth: 2.5,
|
|
2298
|
+
"aria-hidden": true
|
|
2299
|
+
}), delta.text]
|
|
2300
|
+
})]
|
|
2301
|
+
}),
|
|
2302
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2303
|
+
className: "relative mt-3",
|
|
2304
|
+
onPointerMove: trackPointer,
|
|
2305
|
+
onPointerLeave: () => setActive(null),
|
|
2306
|
+
children: [
|
|
2307
|
+
/* @__PURE__ */ jsxs("svg", {
|
|
2308
|
+
viewBox: `0 0 ${VIEW_WIDTH} ${VIEW_HEIGHT}`,
|
|
2309
|
+
preserveAspectRatio: "none",
|
|
2310
|
+
className: "block w-full",
|
|
2311
|
+
style: { height: VIEW_HEIGHT },
|
|
2312
|
+
role: "img",
|
|
2313
|
+
"aria-label": label,
|
|
2314
|
+
children: [
|
|
2315
|
+
/* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("linearGradient", {
|
|
2316
|
+
id: gradientId,
|
|
2317
|
+
x1: "0",
|
|
2318
|
+
y1: "0",
|
|
2319
|
+
x2: "0",
|
|
2320
|
+
y2: "1",
|
|
2321
|
+
children: [/* @__PURE__ */ jsx("stop", {
|
|
2322
|
+
offset: "0%",
|
|
2323
|
+
stopColor: "var(--color-accent)",
|
|
2324
|
+
stopOpacity: .22
|
|
2325
|
+
}), /* @__PURE__ */ jsx("stop", {
|
|
2326
|
+
offset: "100%",
|
|
2327
|
+
stopColor: "var(--color-accent)",
|
|
2328
|
+
stopOpacity: 0
|
|
2329
|
+
})]
|
|
2330
|
+
}) }),
|
|
2331
|
+
area !== "" && /* @__PURE__ */ jsx("path", {
|
|
2332
|
+
d: area,
|
|
2333
|
+
fill: `url(#${gradientId})`
|
|
2334
|
+
}),
|
|
2335
|
+
plotted.map((points, index) => ({
|
|
2336
|
+
d: splinePath(points),
|
|
2337
|
+
index
|
|
2338
|
+
})).filter((entry) => entry.d !== "").reverse().map((entry) => /* @__PURE__ */ jsx("path", {
|
|
2339
|
+
d: entry.d,
|
|
2340
|
+
fill: "none",
|
|
2341
|
+
style: { stroke: seriesColor(entry.index) },
|
|
2342
|
+
strokeWidth: 1.75,
|
|
2343
|
+
strokeLinejoin: "round",
|
|
2344
|
+
strokeLinecap: "round",
|
|
2345
|
+
vectorEffect: "non-scaling-stroke"
|
|
2346
|
+
}, entry.index))
|
|
2347
|
+
]
|
|
2348
|
+
}),
|
|
2349
|
+
all.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
2350
|
+
className: "text-muted pointer-events-none absolute top-0 left-4 text-xs tabular-nums",
|
|
2351
|
+
children: format(max)
|
|
2352
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
2353
|
+
className: "text-muted pointer-events-none absolute right-4 bottom-1 text-xs tabular-nums",
|
|
2354
|
+
children: format(min)
|
|
2355
|
+
})] }),
|
|
2356
|
+
hovered !== void 0 && /* @__PURE__ */ jsx(HoverReadout, {
|
|
2357
|
+
x: dates.length > 1 ? hovered / (dates.length - 1) : 0,
|
|
2358
|
+
date: dates[hovered],
|
|
2359
|
+
rows: series.map((one, index) => ({
|
|
2360
|
+
color: seriesColor(index),
|
|
2361
|
+
label: one.label,
|
|
2362
|
+
value: format(one.values[hovered]),
|
|
2363
|
+
y: plotted[index][hovered].y
|
|
2364
|
+
}))
|
|
2365
|
+
})
|
|
2366
|
+
]
|
|
2367
|
+
})
|
|
2368
|
+
]
|
|
2369
|
+
});
|
|
2370
|
+
}
|
|
2371
|
+
/**
|
|
2372
|
+
* Rule, dots and panel for the bucket under the cursor.
|
|
2373
|
+
*
|
|
2374
|
+
* HTML rather than SVG: a circle drawn in the stretched viewBox renders as an
|
|
2375
|
+
* ellipse and the panel would shear with it. A percentage rides the same
|
|
2376
|
+
* stretch the curve does, so `x` is a 0–1 fraction of the plot's width, while
|
|
2377
|
+
* each `y` is plain pixels.
|
|
2378
|
+
*
|
|
2379
|
+
* Every card uses the same layout, one line per series, whether it plots one
|
|
2380
|
+
* or three. A single line's swatch and name are redundant on their own card,
|
|
2381
|
+
* but four cards sit side by side: reading across them, a row that suddenly
|
|
2382
|
+
* loses its columns costs more than the redundancy does.
|
|
2383
|
+
*/
|
|
2384
|
+
function HoverReadout({ x, date, rows }) {
|
|
2385
|
+
const left = `${x * 100}%`;
|
|
2386
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
2387
|
+
"aria-hidden": true,
|
|
2388
|
+
className: "pointer-events-none",
|
|
2389
|
+
children: [
|
|
2390
|
+
/* @__PURE__ */ jsx("div", {
|
|
2391
|
+
className: "bg-border absolute inset-y-0 w-px",
|
|
2392
|
+
style: { left }
|
|
2393
|
+
}),
|
|
2394
|
+
rows.map((row) => /* @__PURE__ */ jsx("div", {
|
|
2395
|
+
className: "border-card absolute size-2.5 rounded-full border-2",
|
|
2396
|
+
style: {
|
|
2397
|
+
left,
|
|
2398
|
+
top: row.y,
|
|
2399
|
+
background: row.color,
|
|
2400
|
+
transform: "translate(-50%, -50%)"
|
|
2401
|
+
}
|
|
2402
|
+
}, row.label)),
|
|
2403
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2404
|
+
className: "border-border bg-card shadow-card-shadow absolute top-0 grid w-max items-center gap-x-3 gap-y-1 rounded-lg border px-2.5 py-2 text-xs shadow-md",
|
|
2405
|
+
style: {
|
|
2406
|
+
...superellipse,
|
|
2407
|
+
left,
|
|
2408
|
+
transform: `translateX(-${x * 100}%)`,
|
|
2409
|
+
gridTemplateColumns: "auto 1fr auto"
|
|
2410
|
+
},
|
|
2411
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
2412
|
+
className: "col-span-full font-medium whitespace-nowrap",
|
|
2413
|
+
children: date
|
|
2414
|
+
}), rows.map((row) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
2415
|
+
/* @__PURE__ */ jsx("span", {
|
|
2416
|
+
className: "size-3 rounded-sm",
|
|
2417
|
+
style: {
|
|
2418
|
+
...superellipse,
|
|
2419
|
+
background: row.color
|
|
2420
|
+
}
|
|
2421
|
+
}),
|
|
2422
|
+
/* @__PURE__ */ jsx("span", {
|
|
2423
|
+
className: "text-secondary whitespace-nowrap",
|
|
2424
|
+
children: row.label
|
|
2425
|
+
}),
|
|
2426
|
+
/* @__PURE__ */ jsx("span", {
|
|
2427
|
+
className: "text-right font-medium tabular-nums",
|
|
2428
|
+
children: row.value
|
|
2429
|
+
})
|
|
2430
|
+
] }, row.label))]
|
|
2431
|
+
})
|
|
2432
|
+
]
|
|
2433
|
+
});
|
|
2434
|
+
}
|
|
2435
|
+
//#endregion
|
|
2436
|
+
//#region src/components/input/index.tsx
|
|
2437
|
+
const SIZE_STYLE = {
|
|
2438
|
+
xs: "h-7 px-2 text-xs rounded-md focus-visible:ring-2",
|
|
2439
|
+
sm: "h-9 px-2 text-sm rounded-lg focus-visible:ring-3",
|
|
2440
|
+
md: "h-10 px-3 text-sm rounded-xl focus-visible:ring-3",
|
|
2441
|
+
lg: "h-12 px-4 text-md rounded-xl focus-visible:ring-4",
|
|
2442
|
+
xl: "h-14 px-4 text-lg rounded-2xl focus-visible:ring-4"
|
|
2443
|
+
};
|
|
2444
|
+
function Input({ size = "md", type = "text", htmlSize, className, ...props }) {
|
|
2445
|
+
return /* @__PURE__ */ jsx("input", {
|
|
2446
|
+
...props,
|
|
2447
|
+
type,
|
|
2448
|
+
size: htmlSize,
|
|
2449
|
+
className: cn("transition-colors duration-100 focus:outline-none", "placeholder-placeholder bg-textfield focus-visible:border-accent border", "dark:focus-visible:ring-accent/50 focus-visible:ring-accent/40", SIZE_STYLE[size], className)
|
|
2450
|
+
});
|
|
2451
|
+
}
|
|
2452
|
+
//#endregion
|
|
2453
|
+
//#region src/components/date-range.tsx
|
|
2454
|
+
/**
|
|
2455
|
+
* A local calendar day, not a UTC instant. `toISOString().slice(0, 10)` is the
|
|
2456
|
+
* usual shortcut and it is wrong west of Greenwich for most of the day: it
|
|
2457
|
+
* reports yesterday, so "last 30 days" silently ends a day early.
|
|
2458
|
+
*/
|
|
2459
|
+
function isoDay(date) {
|
|
2460
|
+
return `${date.getFullYear()}-${`${date.getMonth() + 1}`.padStart(2, "0")}-${`${date.getDate()}`.padStart(2, "0")}`;
|
|
2461
|
+
}
|
|
2462
|
+
/** Parse an ISO day back to local midnight — `new Date(iso)` would read it as UTC. */
|
|
2463
|
+
function parseIsoDay(iso) {
|
|
2464
|
+
const [year = 1970, month = 1, day = 1] = iso.split("-").map(Number);
|
|
2465
|
+
return new Date(year, month - 1, day);
|
|
2466
|
+
}
|
|
2467
|
+
/** The inclusive range of the `count` days ending today. */
|
|
2468
|
+
function lastDays(count) {
|
|
2469
|
+
const to = /* @__PURE__ */ new Date();
|
|
2470
|
+
const from = /* @__PURE__ */ new Date();
|
|
2471
|
+
from.setDate(from.getDate() - (count - 1));
|
|
2472
|
+
return {
|
|
2473
|
+
from: isoDay(from),
|
|
2474
|
+
to: isoDay(to)
|
|
2475
|
+
};
|
|
2476
|
+
}
|
|
2477
|
+
/** 'Aug 21, 2026' — the compact form, for the toolbar trigger. */
|
|
2478
|
+
function formatDay(iso, locale) {
|
|
2479
|
+
return parseIsoDay(iso).toLocaleDateString(locale, {
|
|
2480
|
+
year: "numeric",
|
|
2481
|
+
month: "short",
|
|
2482
|
+
day: "numeric"
|
|
2483
|
+
});
|
|
2484
|
+
}
|
|
2485
|
+
const PRESETS = [
|
|
2486
|
+
7,
|
|
2487
|
+
14,
|
|
2488
|
+
30,
|
|
2489
|
+
90
|
|
2490
|
+
];
|
|
2491
|
+
/**
|
|
2492
|
+
* Presets plus two date fields, rather than a drawn calendar.
|
|
2493
|
+
*
|
|
2494
|
+
* Reporting ranges are chosen by duration ("the last month"), not by hunting
|
|
2495
|
+
* for a Tuesday, so the presets answer nearly every case; the two fields cover
|
|
2496
|
+
* the rest at a fraction of a calendar widget's weight — and the native picker
|
|
2497
|
+
* they carry is already localized and keyboard-accessible.
|
|
2498
|
+
*/
|
|
2499
|
+
function DateRangePicker({ value, onChange, className }) {
|
|
2500
|
+
const { t, i18n } = useTranslation();
|
|
2501
|
+
const [open, setOpen] = useState(false);
|
|
2502
|
+
const { refs, floatingStyles, context } = useFloating({
|
|
2503
|
+
open,
|
|
2504
|
+
onOpenChange: setOpen,
|
|
2505
|
+
placement: "bottom-start",
|
|
2506
|
+
whileElementsMounted: autoUpdate,
|
|
2507
|
+
middleware: [
|
|
2508
|
+
offset(4),
|
|
2509
|
+
flip({ padding: 8 }),
|
|
2510
|
+
shift({ padding: 8 })
|
|
2511
|
+
]
|
|
2512
|
+
});
|
|
2513
|
+
const { getReferenceProps, getFloatingProps } = useInteractions([
|
|
2514
|
+
useClick(context),
|
|
2515
|
+
useDismiss(context),
|
|
2516
|
+
useRole(context, { role: "dialog" })
|
|
2517
|
+
]);
|
|
2518
|
+
const isDay = (value) => /^\d{4}-\d{2}-\d{2}$/.test(value);
|
|
2519
|
+
const setFrom = (from) => {
|
|
2520
|
+
if (isDay(from)) onChange({
|
|
2521
|
+
from,
|
|
2522
|
+
to: from > value.to ? from : value.to
|
|
2523
|
+
});
|
|
2524
|
+
};
|
|
2525
|
+
const setTo = (to) => {
|
|
2526
|
+
if (isDay(to)) onChange({
|
|
2527
|
+
from: to < value.from ? to : value.from,
|
|
2528
|
+
to
|
|
2529
|
+
});
|
|
2530
|
+
};
|
|
2531
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Button, {
|
|
2532
|
+
ref: refs.setReference,
|
|
2533
|
+
size: "sm",
|
|
2534
|
+
variant: "outline",
|
|
2535
|
+
className: cn("gap-2 font-normal", className),
|
|
2536
|
+
...getReferenceProps(),
|
|
2537
|
+
children: [/* @__PURE__ */ jsx(Calendar, {
|
|
2538
|
+
size: 16,
|
|
2539
|
+
strokeWidth: 2,
|
|
2540
|
+
"aria-hidden": true,
|
|
2541
|
+
className: "text-secondary shrink-0"
|
|
2542
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
2543
|
+
className: "tabular-nums",
|
|
2544
|
+
children: [
|
|
2545
|
+
formatDay(value.from, i18n.language),
|
|
2546
|
+
" – ",
|
|
2547
|
+
formatDay(value.to, i18n.language)
|
|
2548
|
+
]
|
|
2549
|
+
})]
|
|
2550
|
+
}), open && /* @__PURE__ */ jsx(FloatingFocusManager, {
|
|
2551
|
+
context,
|
|
2552
|
+
modal: false,
|
|
2553
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
2554
|
+
ref: refs.setFloating,
|
|
2555
|
+
style: {
|
|
2556
|
+
...floatingStyles,
|
|
2557
|
+
...superellipse
|
|
2558
|
+
},
|
|
2559
|
+
className: "border-border bg-card shadow-card-shadow z-50 w-64 rounded-xl border p-2 shadow-lg",
|
|
2560
|
+
...getFloatingProps(),
|
|
2561
|
+
children: [PRESETS.map((days) => /* @__PURE__ */ jsx("button", {
|
|
2562
|
+
type: "button",
|
|
2563
|
+
className: "hover:bg-hover block w-full rounded-lg px-2.5 py-1.5 text-left text-sm",
|
|
2564
|
+
style: superellipse,
|
|
2565
|
+
onClick: () => {
|
|
2566
|
+
onChange(lastDays(days));
|
|
2567
|
+
setOpen(false);
|
|
2568
|
+
},
|
|
2569
|
+
children: t("metrics.range.lastDays", { count: days })
|
|
2570
|
+
}, days)), /* @__PURE__ */ jsxs("div", {
|
|
2571
|
+
className: "border-border mt-2 space-y-2 border-t pt-2",
|
|
2572
|
+
children: [/* @__PURE__ */ jsxs("label", {
|
|
2573
|
+
className: "block",
|
|
2574
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
2575
|
+
className: "text-muted text-xs",
|
|
2576
|
+
children: t("metrics.range.from")
|
|
2577
|
+
}), /* @__PURE__ */ jsx(Input, {
|
|
2578
|
+
size: "sm",
|
|
2579
|
+
type: "date",
|
|
2580
|
+
max: value.to,
|
|
2581
|
+
value: value.from,
|
|
2582
|
+
className: "mt-1 w-full",
|
|
2583
|
+
onChange: (event) => setFrom(event.target.value)
|
|
2584
|
+
})]
|
|
2585
|
+
}), /* @__PURE__ */ jsxs("label", {
|
|
2586
|
+
className: "block",
|
|
2587
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
2588
|
+
className: "text-muted text-xs",
|
|
2589
|
+
children: t("metrics.range.to")
|
|
2590
|
+
}), /* @__PURE__ */ jsx(Input, {
|
|
2591
|
+
size: "sm",
|
|
2592
|
+
type: "date",
|
|
2593
|
+
min: value.from,
|
|
2594
|
+
value: value.to,
|
|
2595
|
+
className: "mt-1 w-full",
|
|
2596
|
+
onChange: (event) => setTo(event.target.value)
|
|
2597
|
+
})]
|
|
2598
|
+
})]
|
|
2599
|
+
})]
|
|
2600
|
+
})
|
|
2601
|
+
})] });
|
|
2602
|
+
}
|
|
2603
|
+
//#endregion
|
|
2604
|
+
//#region src/components/channel-icon.ts
|
|
2605
|
+
/**
|
|
2606
|
+
* One glyph per delivery channel, shared by the chart cards, the channel
|
|
2607
|
+
* pickers and the message table — a channel has to read the same everywhere or
|
|
2608
|
+
* the eye stops using the icon as an index.
|
|
2609
|
+
*
|
|
2610
|
+
* lucide dropped brand marks, so iOS and Android borrow the nearest generic
|
|
2611
|
+
* pair (a handset, a robot) and a browser push a globe: what matters here is that the two platforms are
|
|
2612
|
+
* told apart at a glance, not that the logo is right.
|
|
2613
|
+
*/
|
|
2614
|
+
const CHANNEL_ICON = {
|
|
2615
|
+
email: Mail,
|
|
2616
|
+
push_ios: Smartphone,
|
|
2617
|
+
push_android: Bot,
|
|
2618
|
+
push_web: Globe,
|
|
2619
|
+
slack: MessagesSquare,
|
|
2620
|
+
discord: MessageCircle,
|
|
2621
|
+
sms: MessageSquareText,
|
|
2622
|
+
webhook: Webhook
|
|
2623
|
+
};
|
|
2624
|
+
/** Stand-in for "every channel": still a send, just not one transport. */
|
|
2625
|
+
const ALL_CHANNELS_ICON = Send;
|
|
2626
|
+
const channelIcon = (channel) => channel === void 0 ? ALL_CHANNELS_ICON : CHANNEL_ICON[channel];
|
|
2627
|
+
//#endregion
|
|
2628
|
+
//#region src/components/avatar.tsx
|
|
2629
|
+
const SIZES = {
|
|
2630
|
+
sm: "size-6 text-xs",
|
|
2631
|
+
md: "size-9 text-sm"
|
|
2632
|
+
};
|
|
2633
|
+
function Avatar({ picture, label, size = "md" }) {
|
|
2634
|
+
const [failed, setFailed] = useState(false);
|
|
2635
|
+
const src = typeof picture === "string" && picture !== "" ? picture : void 0;
|
|
2636
|
+
if (src !== void 0 && !failed) return /* @__PURE__ */ jsx("img", {
|
|
2637
|
+
src,
|
|
2638
|
+
alt: "",
|
|
2639
|
+
onError: () => setFailed(true),
|
|
2640
|
+
className: cn("shrink-0 rounded-full object-cover", SIZES[size])
|
|
2641
|
+
});
|
|
2642
|
+
return /* @__PURE__ */ jsx("div", {
|
|
2643
|
+
"aria-hidden": true,
|
|
2644
|
+
className: cn("bg-selected text-secondary flex shrink-0 items-center justify-center rounded-full font-medium", SIZES[size]),
|
|
2645
|
+
children: label.trim().charAt(0).toUpperCase()
|
|
2646
|
+
});
|
|
2647
|
+
}
|
|
2648
|
+
//#endregion
|
|
2649
|
+
//#region src/components/template-refs.ts
|
|
2650
|
+
const TEMPLATE_CHANNELS = /* @__PURE__ */ new Set([
|
|
2651
|
+
"email",
|
|
2652
|
+
"push",
|
|
2653
|
+
"discord",
|
|
2654
|
+
"slack"
|
|
2655
|
+
]);
|
|
2656
|
+
/** Walk the IR node tree depth-first (branch arms, cohort arms and waitUntil timeout flows all included). */
|
|
2657
|
+
function walk(nodes, visit) {
|
|
2658
|
+
for (const node of nodes) {
|
|
2659
|
+
visit(node);
|
|
2660
|
+
switch (node.type) {
|
|
2661
|
+
case "branch":
|
|
2662
|
+
for (const branchCase of node.cases) walk(branchCase.flow, visit);
|
|
2663
|
+
if (node.otherwise) walk(node.otherwise, visit);
|
|
2664
|
+
break;
|
|
2665
|
+
case "cohort":
|
|
2666
|
+
for (const arm of node.arms) walk(arm.flow, visit);
|
|
2667
|
+
break;
|
|
2668
|
+
case "wait_until": if (Array.isArray(node.onTimeout)) walk(node.onTimeout, visit);
|
|
2669
|
+
}
|
|
2670
|
+
}
|
|
2671
|
+
}
|
|
2672
|
+
/**
|
|
2673
|
+
* One entry per template — per channel and key, since one key can name an
|
|
2674
|
+
* email and a push, and their usages must not run together.
|
|
2675
|
+
*/
|
|
2676
|
+
function collectTemplateRefs(irs) {
|
|
2677
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
2678
|
+
for (const ir of irs) walk(ir.flow, (node) => {
|
|
2679
|
+
if (node.type !== "message" || !TEMPLATE_CHANNELS.has(node.channel)) return;
|
|
2680
|
+
const usage = {
|
|
2681
|
+
workflow: ir.id,
|
|
2682
|
+
nodeId: node.id,
|
|
2683
|
+
props: node.props
|
|
2684
|
+
};
|
|
2685
|
+
const id = `${node.channel}:${node.template}`;
|
|
2686
|
+
const found = byKey.get(id);
|
|
2687
|
+
if (found) {
|
|
2688
|
+
found.usages.push(usage);
|
|
2689
|
+
return;
|
|
2690
|
+
}
|
|
2691
|
+
byKey.set(id, {
|
|
2692
|
+
key: node.template,
|
|
2693
|
+
channel: node.channel,
|
|
2694
|
+
usages: [usage]
|
|
2695
|
+
});
|
|
2696
|
+
});
|
|
2697
|
+
return Array.from(byKey.values()).sort((a, b) => a.key.localeCompare(b.key) || a.channel.localeCompare(b.channel));
|
|
2698
|
+
}
|
|
2699
|
+
/**
|
|
2700
|
+
* Every template the studio can show: each registered one — referenced or
|
|
2701
|
+
* not yet, so a template can be previewed before a flow uses it — plus each
|
|
2702
|
+
* one the IR references without registering it (shown as missing). The IR
|
|
2703
|
+
* only adds the use sites.
|
|
2704
|
+
*/
|
|
2705
|
+
function collectTemplates(irs, registries) {
|
|
2706
|
+
const byKey = new Map(collectTemplateRefs(irs).map((ref) => [`${ref.channel}:${ref.key}`, ref]));
|
|
2707
|
+
for (const [channel, registry] of [
|
|
2708
|
+
["email", registries.emails],
|
|
2709
|
+
["push", registries.pushes],
|
|
2710
|
+
["discord", registries.discords],
|
|
2711
|
+
["slack", registries.slacks]
|
|
2712
|
+
]) for (const key of Object.keys(registry ?? {})) if (!byKey.has(`${channel}:${key}`)) byKey.set(`${channel}:${key}`, {
|
|
2713
|
+
key,
|
|
2714
|
+
channel,
|
|
2715
|
+
usages: []
|
|
2716
|
+
});
|
|
2717
|
+
return Array.from(byKey.values()).sort((a, b) => a.key.localeCompare(b.key) || a.channel.localeCompare(b.channel));
|
|
2718
|
+
}
|
|
2719
|
+
//#endregion
|
|
2720
|
+
export { ALL_CHANNELS_ICON, Avatar, Button, CARD_SIZE, CHANNEL_ICON, DateRangePicker, ICON_SIZE, METRIC_CHANNELS, MetricCard, PushPreview, Sparkline, TemplatesPage, WorkflowCanvas, WorkflowList, channelIcon, collectTemplateRefs, collectTemplates, defineStats, formatDay, isoDay, lastDays, layout, parseIsoDay, superellipse };
|
|
2721
|
+
|
|
2722
|
+
//# sourceMappingURL=index.mjs.map
|