@getrheo/contracts 1.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.
Files changed (81) hide show
  1. package/dist/animations.d.ts +226 -0
  2. package/dist/animations.js +1160 -0
  3. package/dist/animations.js.map +1 -0
  4. package/dist/appIntegrations.d.ts +175 -0
  5. package/dist/appIntegrations.js +60 -0
  6. package/dist/appIntegrations.js.map +1 -0
  7. package/dist/billingPeriod.d.ts +26 -0
  8. package/dist/billingPeriod.js +39 -0
  9. package/dist/billingPeriod.js.map +1 -0
  10. package/dist/canvasEditorGates.d.ts +81 -0
  11. package/dist/canvasEditorGates.js +1460 -0
  12. package/dist/canvasEditorGates.js.map +1 -0
  13. package/dist/constants/index.d.ts +30 -0
  14. package/dist/constants/index.js +67 -0
  15. package/dist/constants/index.js.map +1 -0
  16. package/dist/dashboard.d.ts +181856 -0
  17. package/dist/dashboard.js +3348 -0
  18. package/dist/dashboard.js.map +1 -0
  19. package/dist/decisions.d.ts +575 -0
  20. package/dist/decisions.js +1209 -0
  21. package/dist/decisions.js.map +1 -0
  22. package/dist/events.d.ts +231 -0
  23. package/dist/events.js +63 -0
  24. package/dist/events.js.map +1 -0
  25. package/dist/experiments-DN8pQa_D.d.ts +530 -0
  26. package/dist/externalSurfaceIntegrations.d.ts +20 -0
  27. package/dist/externalSurfaceIntegrations.js +49 -0
  28. package/dist/externalSurfaceIntegrations.js.map +1 -0
  29. package/dist/externalSurfaces.d.ts +177 -0
  30. package/dist/externalSurfaces.js +1190 -0
  31. package/dist/externalSurfaces.js.map +1 -0
  32. package/dist/fields.d.ts +8 -0
  33. package/dist/fields.js +15 -0
  34. package/dist/fields.js.map +1 -0
  35. package/dist/flowManifestSchema-CtqygXCK.d.ts +50857 -0
  36. package/dist/flowTemplateComments.d.ts +23 -0
  37. package/dist/flowTemplateComments.js +14 -0
  38. package/dist/flowTemplateComments.js.map +1 -0
  39. package/dist/flowTemplates.d.ts +22 -0
  40. package/dist/flowTemplates.js +73 -0
  41. package/dist/flowTemplates.js.map +1 -0
  42. package/dist/identity.d.ts +35 -0
  43. package/dist/identity.js +18 -0
  44. package/dist/identity.js.map +1 -0
  45. package/dist/imageContentType.d.ts +11 -0
  46. package/dist/imageContentType.js +54 -0
  47. package/dist/imageContentType.js.map +1 -0
  48. package/dist/index.d.ts +224 -0
  49. package/dist/index.js +4557 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/layerUnion-BzXoAJLY.d.ts +34 -0
  52. package/dist/layers.d.ts +89844 -0
  53. package/dist/layers.js +1507 -0
  54. package/dist/layers.js.map +1 -0
  55. package/dist/layout-D0LpaKG-.d.ts +12896 -0
  56. package/dist/localized.d.ts +17 -0
  57. package/dist/localized.js +18 -0
  58. package/dist/localized.js.map +1 -0
  59. package/dist/manifest.d.ts +22192 -0
  60. package/dist/manifest.js +2163 -0
  61. package/dist/manifest.js.map +1 -0
  62. package/dist/media.d.ts +53 -0
  63. package/dist/media.js +55 -0
  64. package/dist/media.js.map +1 -0
  65. package/dist/planEntitlements.d.ts +65 -0
  66. package/dist/planEntitlements.js +117 -0
  67. package/dist/planEntitlements.js.map +1 -0
  68. package/dist/publish-exports.json +102 -0
  69. package/dist/screens.d.ts +33586 -0
  70. package/dist/screens.js +1439 -0
  71. package/dist/screens.js.map +1 -0
  72. package/dist/sdk.d.ts +145942 -0
  73. package/dist/sdk.js +3424 -0
  74. package/dist/sdk.js.map +1 -0
  75. package/dist/sdkAttributes.d.ts +11 -0
  76. package/dist/sdkAttributes.js +17 -0
  77. package/dist/sdkAttributes.js.map +1 -0
  78. package/dist/workspaceCapabilities.d.ts +15 -0
  79. package/dist/workspaceCapabilities.js +116 -0
  80. package/dist/workspaceCapabilities.js.map +1 -0
  81. package/package.json +162 -0
@@ -0,0 +1,3348 @@
1
+ import { z } from 'zod';
2
+
3
+ // src/dashboard/appBranding.ts
4
+
5
+ // src/constants/index.ts
6
+ var ENVIRONMENTS = ["test", "live"];
7
+ var ROLES = ["owner", "editor"];
8
+ var FIELD_CLASSIFICATIONS = ["safe", "sensitive"];
9
+ var MEDIA_TYPES = ["image", "font", "lottie", "video"];
10
+ var MAX_IMAGE_BYTES = 5 * 1024 * 1024;
11
+
12
+ // src/layers/layerSchemaRef.ts
13
+ var layerSchemaStore = {};
14
+ var LocaleCode = z.string().regex(/^[a-z]{2}(-[A-Z]{2})?$/, 'locale must be like "en" or "en-US"');
15
+ var LocalizedTextSchema = z.object({
16
+ default: z.string().min(1, "default copy is required"),
17
+ translations: z.record(LocaleCode, z.string()).optional()
18
+ });
19
+
20
+ // src/hyperlinkHref.ts
21
+ var parseHyperlinkHref = (raw) => {
22
+ const t = raw.trim();
23
+ if (!t) return { ok: false };
24
+ let u;
25
+ try {
26
+ u = new URL(t);
27
+ } catch {
28
+ return { ok: false };
29
+ }
30
+ const scheme = u.protocol.replace(/:$/, "").toLowerCase();
31
+ if (scheme === "https") {
32
+ if (!u.hostname) return { ok: false };
33
+ return { ok: true, scheme: "https", host: u.hostname };
34
+ }
35
+ if (scheme === "mailto") {
36
+ return { ok: true, scheme: "mailto" };
37
+ }
38
+ return { ok: false };
39
+ };
40
+ var MediaTypeSchema = z.enum(MEDIA_TYPES);
41
+ var MediaReferenceSchema = z.object({
42
+ mediaAssetId: z.string().uuid()
43
+ });
44
+ var MediaAssetSchema = z.object({
45
+ id: z.string().uuid(),
46
+ orgId: z.string().uuid(),
47
+ type: MediaTypeSchema,
48
+ url: z.string().url(),
49
+ name: z.string().nullable().optional(),
50
+ contentType: z.string(),
51
+ sizeBytes: z.number().int().nonnegative(),
52
+ archivedAt: z.string().datetime().nullable().optional(),
53
+ createdAt: z.string().datetime()
54
+ });
55
+ var LayerIdSchema = z.string().min(1).max(64).regex(/^lyr_[a-z0-9_]+$/i, "layer id must look like lyr_<id>");
56
+ var ScreenIdSchema = z.string().min(1).max(64).regex(/^scr_[a-z0-9_]+$/i, "screen id must look like scr_<id>");
57
+ var RESTING_MOTION_PRESETS = ["translate", "bounce", "scale", "pulse", "rotate"];
58
+ var RestingMotionPresetSchema = z.enum(RESTING_MOTION_PRESETS);
59
+ var RESTING_MOTION_SCALE_DIRECTIONS = ["up", "down"];
60
+ var RestingMotionScaleDirectionSchema = z.enum(RESTING_MOTION_SCALE_DIRECTIONS);
61
+ var RESTING_MOTION_ROTATE_DIRECTIONS = ["clockwise", "counterclockwise"];
62
+ var RestingMotionRotateDirectionSchema = z.enum(RESTING_MOTION_ROTATE_DIRECTIONS);
63
+ var RestingMotionSchema = z.object({
64
+ preset: RestingMotionPresetSchema,
65
+ /**
66
+ * Timeline segment length (ms): motion is active from start until
67
+ * start + durationMs. When {@link loop} is true, the preset pattern repeats
68
+ * every {@link cycleDurationMs} (or preset default) within this window.
69
+ */
70
+ durationMs: z.number().int().min(200).max(2e4).optional(),
71
+ /** When true, repeat the motion pattern within the timeline segment; default is one shot. */
72
+ loop: z.boolean().optional(),
73
+ /**
74
+ * Duration (ms) of one full pattern cycle when looping. Defaults per {@link RESTING_MOTION_DEFAULT_DURATION_MS}.
75
+ */
76
+ cycleDurationMs: z.number().int().min(200).max(2e4).optional(),
77
+ intensity: z.number().min(0).max(2).optional(),
78
+ /** Bounce preset only: vertical lift in px. When omitted, uses `14 * intensity` (default intensity 1 → 14). */
79
+ bounceAmplitudePx: z.number().min(1).max(80).optional(),
80
+ /** Scale preset: grow (+) or shrink (−) toward a peak, then return to 100%. */
81
+ scaleDirection: RestingMotionScaleDirectionSchema.optional(),
82
+ /**
83
+ * Scale preset: when true (default), each cycle goes rest → peak scale → rest.
84
+ * When false, ramps rest → peak and holds; with loop, the next cycle restarts from rest.
85
+ */
86
+ scaleSpringBack: z.boolean().optional(),
87
+ /**
88
+ * Scale preset: magnitude in % — growth above 100% (up to +400% = 5× at peak) or shrink toward
89
+ * 100%− (up to 90% so peak can be 10% size). See authoring caps in the layer editor.
90
+ */
91
+ scalePercent: z.number().min(0).max(400).optional(),
92
+ /**
93
+ * Scale preset: ms for one full out-and-back (rest → peak → rest). Timeline bar still sets
94
+ * {@link durationMs} (when the layer may animate); this controls how fast each cycle runs.
95
+ */
96
+ scalePatternDurationMs: z.number().int().min(200).max(2e4).optional(),
97
+ /** @deprecated Use {@link scalePercent} + {@link scaleDirection}. Kept for legacy manifests. */
98
+ scaleUpPercent: z.number().min(0).max(400).optional(),
99
+ /** @deprecated Use {@link scalePercent} + {@link scaleDirection}. Kept for legacy manifests. */
100
+ scaleDownPercent: z.number().min(0).max(90).optional(),
101
+ /**
102
+ * @deprecated Legacy vertical-only float (px). Prefer {@link translatePeakXPercent} / {@link translatePeakYPercent}.
103
+ */
104
+ translateRangePx: z.number().min(0).max(40).optional(),
105
+ /** @deprecated Legacy peak offsets in px. Prefer {@link translatePeakXPercent} / {@link translatePeakYPercent}. */
106
+ translatePeakXPx: z.number().min(-200).max(200).optional(),
107
+ /** @deprecated Legacy peak offsets in px. Prefer {@link translatePeakXPercent} / {@link translatePeakYPercent}. */
108
+ translatePeakYPx: z.number().min(-200).max(200).optional(),
109
+ /** Translate preset: peak X offset as % of the layer box (−200–200). Scaled by intensity. */
110
+ translatePeakXPercent: z.number().min(-200).max(200).optional(),
111
+ /** Translate preset: peak Y offset as % of the layer box (−200–200). Scaled by intensity. */
112
+ translatePeakYPercent: z.number().min(-200).max(200).optional(),
113
+ /**
114
+ * Translate preset: when true (default), each cycle goes rest → peak offset → rest. When false, ramp to
115
+ * peak and hold; with loop, the next cycle restarts from the origin.
116
+ */
117
+ translateSpringBack: z.boolean().optional(),
118
+ /** Rotate preset: target rotation in degrees (0–360), scaled by intensity. */
119
+ rotateMaxDeg: z.number().min(0).max(360).optional(),
120
+ /** Rotate preset: spin direction; omitted or `clockwise` → positive angles (default). */
121
+ rotateDirection: RestingMotionRotateDirectionSchema.optional(),
122
+ /**
123
+ * Rotate preset: when true (default), each cycle oscillates 0° → peak → 0°.
124
+ * When false, each cycle ramps 0° → peak and holds; with loop, the next cycle snaps to 0° and ramps again.
125
+ */
126
+ rotateSpringBack: z.boolean().optional(),
127
+ /** Pulse preset: minimum opacity at the dip (0–1). Omitted → `1 - 0.38 * intensity`. */
128
+ pulseMinOpacity: z.number().min(0).max(1).optional(),
129
+ /** Ms after the last mount/stagger clip ends before motion applies (authoring + scrub). */
130
+ delayMsAfterMountEnd: z.number().int().min(0).max(6e4).optional(),
131
+ /**
132
+ * Absolute start time (ms from screen mount). When set, overrides
133
+ * {@link delayMsAfterMountEnd} + mount-clip end so motion can sit between
134
+ * clips (e.g. after first entry, before exit) when multiple mounts exist.
135
+ */
136
+ timelineStartMs: z.number().int().min(0).max(36e5).optional()
137
+ }).strict();
138
+ var RestingMotionEntrySchema = RestingMotionSchema.extend({
139
+ id: z.string().min(1)
140
+ });
141
+
142
+ // src/layers/base.ts
143
+ var baseLayerShape = {
144
+ id: LayerIdSchema,
145
+ name: z.string().max(80).optional(),
146
+ restingMotion: RestingMotionSchema.optional(),
147
+ restingMotions: z.array(RestingMotionEntrySchema).optional()
148
+ };
149
+ var ThemedColorModesSchema = z.object({
150
+ light: z.string().min(1).optional(),
151
+ dark: z.string().min(1).optional()
152
+ }).strict().refine((o) => o.light !== void 0 || o.dark !== void 0, {
153
+ message: "at least one of light or dark is required"
154
+ });
155
+ var ThemedColorSchema = z.union([z.string().min(1), ThemedColorModesSchema]);
156
+ var WIDTH_PRESETS = ["auto", "full", "1/2", "1/3", "2/3", "1/4", "3/4"];
157
+ var WidthValueSchema = z.union([z.enum(WIDTH_PRESETS), z.number().int().min(0).max(2e3)]);
158
+ var HEIGHT_PRESETS = ["auto", "full", "fill"];
159
+ var CommonLayoutHeightSchema = z.union([
160
+ z.enum(HEIGHT_PRESETS),
161
+ z.number().int().min(0).max(2e3)
162
+ ]);
163
+
164
+ // src/layers/styleCommon.ts
165
+ var NonNegativePxSchema = z.number().int().min(0);
166
+ var PaddingSchema = z.object({
167
+ t: NonNegativePxSchema.optional(),
168
+ r: NonNegativePxSchema.optional(),
169
+ b: NonNegativePxSchema.optional(),
170
+ l: NonNegativePxSchema.optional()
171
+ }).partial();
172
+ var BorderSchema = z.object({
173
+ width: z.number().int().min(0).max(20).optional(),
174
+ color: ThemedColorSchema.optional()
175
+ }).partial();
176
+ var DropShadowSchema = z.object({
177
+ offsetX: z.number().int().min(-100).max(100).optional(),
178
+ offsetY: z.number().int().min(-100).max(100).optional(),
179
+ blur: z.number().int().min(0).max(100).optional(),
180
+ spread: z.number().int().min(-50).max(50).optional(),
181
+ color: ThemedColorSchema.optional(),
182
+ opacity: z.number().min(0).max(1).optional()
183
+ }).partial();
184
+ var CommonStyleSchema = z.object({
185
+ padding: PaddingSchema.optional(),
186
+ margin: PaddingSchema.optional(),
187
+ radius: z.number().int().min(0).max(96).optional(),
188
+ background: ThemedColorSchema.optional(),
189
+ border: BorderSchema.optional(),
190
+ shadow: DropShadowSchema.optional(),
191
+ opacity: z.number().min(0).max(1).optional(),
192
+ width: WidthValueSchema.optional(),
193
+ /** Omit for normal flow; `'absolute'` removes the layer from flex flow (non-root only). */
194
+ position: z.literal("absolute").optional(),
195
+ /** Pixel insets when `position === 'absolute'` (same shape as padding). */
196
+ inset: PaddingSchema.optional(),
197
+ zIndex: z.number().int().min(-999).max(999).optional(),
198
+ /** Static rotation in degrees (CSS `rotate`); not timeline animation. */
199
+ rotate: z.number().min(-360).max(360).optional(),
200
+ /** Cross-axis size: `auto` (hug), `full`/`fill` (parent height), or fixed px. No fractions. */
201
+ height: CommonLayoutHeightSchema.optional(),
202
+ /** Stroke thickness in px for layers that render a stroke primitive (e.g. loader ring). */
203
+ strokeWidth: z.number().int().min(0).max(64).optional()
204
+ }).partial();
205
+ var TextStyleSchema = CommonStyleSchema.extend({
206
+ /**
207
+ * Logical font family: manifest `theme.fontFamily` when omitted, {@link TEXT_FONT_FAMILY_SYSTEM_UI}
208
+ * for the platform stack, or a custom name (matches `Branding.fontFamilies[].name` for uploaded fonts).
209
+ */
210
+ fontFamily: z.string().min(1).max(128).optional(),
211
+ fontSize: z.number().int().min(8).max(96).optional(),
212
+ fontWeight: z.number().int().min(100).max(900).optional(),
213
+ color: ThemedColorSchema.optional(),
214
+ align: z.enum(["left", "center", "right"]).optional(),
215
+ lineHeight: z.number().min(0.8).max(3).optional(),
216
+ /** Multiplier (0–1) applied to the resolved background color alpha only; text stays fully opaque unless `opacity` is set. */
217
+ backgroundOpacity: z.number().min(0).max(1).optional()
218
+ });
219
+ var ImageStyleSchema = CommonStyleSchema.extend({
220
+ fit: z.enum(["cover", "contain", "fill"]).optional(),
221
+ aspectRatio: z.number().positive().max(10).optional()
222
+ });
223
+ var IconStyleSchema = CommonStyleSchema.extend({
224
+ color: ThemedColorSchema.optional()
225
+ });
226
+ var ICON_FAMILIES = ["ionicons"];
227
+ var ButtonStyleSchema = CommonStyleSchema.extend({
228
+ fontSize: z.number().int().min(8).max(96).optional(),
229
+ fontWeight: z.number().int().min(100).max(900).optional(),
230
+ color: ThemedColorSchema.optional(),
231
+ align: z.enum(["left", "center", "right"]).optional()
232
+ });
233
+ var BUTTON_LAYER_VARIANTS = ["primary", "secondary", "ghost", "destructive"];
234
+ var ButtonLayerVariantSchema = z.enum(BUTTON_LAYER_VARIANTS);
235
+ var CommonStyleBreakpointsSchema = z.object({
236
+ sm: CommonStyleSchema.partial().optional(),
237
+ md: CommonStyleSchema.partial().optional(),
238
+ lg: CommonStyleSchema.partial().optional(),
239
+ xl: CommonStyleSchema.partial().optional(),
240
+ "2xl": CommonStyleSchema.partial().optional()
241
+ }).partial().optional();
242
+ var TextStyleBreakpointsSchema = z.object({
243
+ sm: TextStyleSchema.partial().optional(),
244
+ md: TextStyleSchema.partial().optional(),
245
+ lg: TextStyleSchema.partial().optional(),
246
+ xl: TextStyleSchema.partial().optional(),
247
+ "2xl": TextStyleSchema.partial().optional()
248
+ }).partial().optional();
249
+ var ImageStyleBreakpointsSchema = z.object({
250
+ sm: ImageStyleSchema.partial().optional(),
251
+ md: ImageStyleSchema.partial().optional(),
252
+ lg: ImageStyleSchema.partial().optional(),
253
+ xl: ImageStyleSchema.partial().optional(),
254
+ "2xl": ImageStyleSchema.partial().optional()
255
+ }).partial().optional();
256
+ var IconStyleBreakpointsSchema = z.object({
257
+ sm: IconStyleSchema.partial().optional(),
258
+ md: IconStyleSchema.partial().optional(),
259
+ lg: IconStyleSchema.partial().optional(),
260
+ xl: IconStyleSchema.partial().optional(),
261
+ "2xl": IconStyleSchema.partial().optional()
262
+ }).partial().optional();
263
+ var ButtonStyleBreakpointsSchema = z.object({
264
+ sm: ButtonStyleSchema.partial().optional(),
265
+ md: ButtonStyleSchema.partial().optional(),
266
+ lg: ButtonStyleSchema.partial().optional(),
267
+ xl: ButtonStyleSchema.partial().optional(),
268
+ "2xl": ButtonStyleSchema.partial().optional()
269
+ }).partial().optional();
270
+ var StackLayoutBreakpointPatchSchema = z.object({
271
+ gap: NonNegativePxSchema.optional(),
272
+ direction: z.enum(["vertical", "horizontal"]).optional()
273
+ }).partial();
274
+ var StackLayoutBreakpointsSchema = z.object({
275
+ sm: StackLayoutBreakpointPatchSchema.optional(),
276
+ md: StackLayoutBreakpointPatchSchema.optional(),
277
+ lg: StackLayoutBreakpointPatchSchema.optional(),
278
+ xl: StackLayoutBreakpointPatchSchema.optional(),
279
+ "2xl": StackLayoutBreakpointPatchSchema.optional()
280
+ }).partial().optional();
281
+ var ButtonLayoutBreakpointPatchSchema = z.object({
282
+ gap: NonNegativePxSchema.optional(),
283
+ direction: z.enum(["vertical", "horizontal"]).optional()
284
+ }).partial();
285
+ var ButtonLayoutBreakpointsSchema = z.object({
286
+ sm: ButtonLayoutBreakpointPatchSchema.optional(),
287
+ md: ButtonLayoutBreakpointPatchSchema.optional(),
288
+ lg: ButtonLayoutBreakpointPatchSchema.optional(),
289
+ xl: ButtonLayoutBreakpointPatchSchema.optional(),
290
+ "2xl": ButtonLayoutBreakpointPatchSchema.optional()
291
+ }).partial().optional();
292
+ var OS_PERMISSION_KEYS = [
293
+ "notifications",
294
+ "camera",
295
+ "microphone",
296
+ "photo_library",
297
+ "contacts",
298
+ "calendar",
299
+ "reminders",
300
+ "location_when_in_use",
301
+ "location_always",
302
+ "motion",
303
+ "bluetooth",
304
+ "app_tracking_transparency",
305
+ "speech_recognition",
306
+ "face_id",
307
+ "health_kit",
308
+ "media_library",
309
+ "local_network",
310
+ "nearby_interactions",
311
+ "nfc",
312
+ "full_screen_intent_android",
313
+ "sms_android",
314
+ "phone_android"
315
+ ];
316
+ var OsPermissionKeySchema = z.enum(OS_PERMISSION_KEYS);
317
+ var PERMISSION_CAPTURE_FIELD_KEY_PREFIX = "permission:";
318
+ var permissionCaptureFieldKey = (key) => `${PERMISSION_CAPTURE_FIELD_KEY_PREFIX}${key}`;
319
+ var PERMISSION_OUTCOME_VALUES = ["granted", "denied", "blocked"];
320
+ z.enum(PERMISSION_OUTCOME_VALUES);
321
+ var OS_PERMISSION_OUTCOME_CONTINUE = "continue";
322
+ var OS_PERMISSION_OUTCOME_END = "end";
323
+ var OsPermissionOutcomeBranchTargetSchema = z.union([
324
+ ScreenIdSchema,
325
+ z.literal(OS_PERMISSION_OUTCOME_CONTINUE),
326
+ z.literal(OS_PERMISSION_OUTCOME_END)
327
+ ]);
328
+ var OsPermissionOutcomesSchema = z.object({
329
+ granted: OsPermissionOutcomeBranchTargetSchema,
330
+ denied: OsPermissionOutcomeBranchTargetSchema,
331
+ blocked: OsPermissionOutcomeBranchTargetSchema
332
+ }).strict();
333
+ var APP_REVIEW_OUTCOMES = ["not_shown", "dismissed"];
334
+ z.enum(APP_REVIEW_OUTCOMES);
335
+ var ButtonActionSchema = z.discriminatedUnion("kind", [
336
+ z.object({ kind: z.literal("none") }),
337
+ z.object({ kind: z.literal("continue") }),
338
+ z.object({ kind: z.literal("skip") }),
339
+ z.object({ kind: z.literal("end_flow") }),
340
+ z.object({
341
+ kind: z.literal("go_back_one_screen"),
342
+ fallbackScreenId: ScreenIdSchema.optional()
343
+ }),
344
+ z.object({ kind: z.literal("go_to_step"), screenId: ScreenIdSchema }),
345
+ z.object({
346
+ kind: z.literal("request_os_permission"),
347
+ permissionKey: OsPermissionKeySchema,
348
+ outcomes: OsPermissionOutcomesSchema
349
+ }),
350
+ z.object({
351
+ kind: z.literal("play_media"),
352
+ targetLayerIds: z.array(z.string().min(1)).min(1)
353
+ }),
354
+ z.object({ kind: z.literal("request_app_review") })
355
+ ]);
356
+ var TEXT_INPUT_TYPES = ["plain", "email", "phone", "url", "multiline"];
357
+ var TextInputTypeSchema = z.enum(TEXT_INPUT_TYPES);
358
+ var COUNTER_DISPLAY_KINDS = ["number", "time"];
359
+ var COUNTER_TIME_FORMATS = ["mm_ss", "hh_mm_ss", "dd_hh_mm_ss"];
360
+ var CheckboxGlyphStyleSchema = z.object({
361
+ /** Square edge length in px. */
362
+ size: z.number().int().min(8).max(128).optional(),
363
+ radius: z.number().int().min(0).max(96).optional(),
364
+ background: ThemedColorSchema.optional(),
365
+ border: BorderSchema.optional(),
366
+ shadow: DropShadowSchema.optional(),
367
+ opacity: z.number().min(0).max(1).optional(),
368
+ /** Fill color for the check mark when checked. */
369
+ checkColor: ThemedColorSchema.optional()
370
+ }).partial();
371
+ var OAUTH_LOGIN_PRESETS = ["github", "google", "apple"];
372
+ var OAuthPresetButtonChromeSchema = CommonStyleSchema.pick({
373
+ width: true,
374
+ padding: true,
375
+ margin: true,
376
+ radius: true
377
+ }).partial();
378
+ var OAuthPresetButtonChromeBreakpointsSchema = z.object({
379
+ sm: OAuthPresetButtonChromeSchema.partial().optional(),
380
+ md: OAuthPresetButtonChromeSchema.partial().optional(),
381
+ lg: OAuthPresetButtonChromeSchema.partial().optional(),
382
+ xl: OAuthPresetButtonChromeSchema.partial().optional(),
383
+ "2xl": OAuthPresetButtonChromeSchema.partial().optional()
384
+ }).partial().optional();
385
+ var EMAIL_PASSWORD_AUTH_MODES = ["sign_in", "sign_up"];
386
+ var EMAIL_PASSWORD_SLOTS = ["email", "password", "confirm"];
387
+
388
+ // src/layers/kinds/chrome.ts
389
+ var lazyLayer = () => layerSchemaStore.schema;
390
+ var ButtonLayerSchema = z.object({
391
+ ...baseLayerShape,
392
+ kind: z.literal("button"),
393
+ children: z.lazy(() => z.array(lazyLayer())),
394
+ action: ButtonActionSchema,
395
+ variant: ButtonLayerVariantSchema,
396
+ direction: z.enum(["vertical", "horizontal"]).optional(),
397
+ gap: z.number().int().min(0).optional(),
398
+ align: z.enum(["start", "center", "end", "stretch"]).optional(),
399
+ distribution: z.enum(["start", "center", "end", "between", "around"]).optional(),
400
+ style: ButtonStyleSchema.optional(),
401
+ styleBreakpoints: ButtonStyleBreakpointsSchema,
402
+ buttonLayoutBreakpoints: ButtonLayoutBreakpointsSchema
403
+ });
404
+ var BackButtonLayerSchema = z.object({
405
+ ...baseLayerShape,
406
+ kind: z.literal("back_button"),
407
+ children: z.lazy(() => z.array(lazyLayer())),
408
+ variant: ButtonLayerVariantSchema,
409
+ direction: z.enum(["vertical", "horizontal"]).optional(),
410
+ gap: z.number().int().min(0).optional(),
411
+ align: z.enum(["start", "center", "end", "stretch"]).optional(),
412
+ distribution: z.enum(["start", "center", "end", "between", "around"]).optional(),
413
+ style: ButtonStyleSchema.optional(),
414
+ styleBreakpoints: ButtonStyleBreakpointsSchema,
415
+ buttonLayoutBreakpoints: ButtonLayoutBreakpointsSchema,
416
+ fallbackScreenId: ScreenIdSchema.optional()
417
+ });
418
+ var ProgressLayerSchema = z.object({
419
+ ...baseLayerShape,
420
+ kind: z.literal("progress"),
421
+ trackColor: ThemedColorSchema.optional(),
422
+ fillColor: ThemedColorSchema.optional(),
423
+ style: CommonStyleSchema.optional()
424
+ });
425
+ var LoaderOnCompleteSchema = z.discriminatedUnion("mode", [
426
+ z.object({ mode: z.literal("none") }),
427
+ z.object({ mode: z.literal("next") }),
428
+ z.object({ mode: z.literal("screen"), screenId: ScreenIdSchema })
429
+ ]);
430
+ var LoaderLayerSchema = z.object({
431
+ ...baseLayerShape,
432
+ kind: z.literal("loader"),
433
+ variant: z.enum(["linear", "circular"]).optional(),
434
+ targetPercent: z.number().int().min(0).max(100).optional(),
435
+ fillDelayMs: z.number().int().min(0).max(1e4).optional(),
436
+ durationMs: z.number().int().min(0).max(36e5).optional(),
437
+ onComplete: LoaderOnCompleteSchema.optional(),
438
+ trackColor: ThemedColorSchema.optional(),
439
+ trackOpacity: z.number().min(0).max(1).optional(),
440
+ fillColor: ThemedColorSchema.optional(),
441
+ /** Horizontal alignment of the bar or ring within the layer box (default start). */
442
+ align: z.enum(["start", "center", "end"]).optional(),
443
+ style: CommonStyleSchema.optional()
444
+ }).superRefine((data, ctx) => {
445
+ if (data.variant !== "circular") return;
446
+ const w = data.style?.width;
447
+ const h = data.style?.height;
448
+ if (typeof w === "number" && typeof h === "number" && w !== h) {
449
+ ctx.addIssue({
450
+ code: z.ZodIssueCode.custom,
451
+ message: "circular loader requires style.width === style.height",
452
+ path: ["style", "height"]
453
+ });
454
+ }
455
+ });
456
+ var CounterLayerSchema = z.object({
457
+ ...baseLayerShape,
458
+ kind: z.literal("counter"),
459
+ startValue: z.number().finite(),
460
+ endValue: z.number().finite(),
461
+ durationMs: z.number().int().min(0).max(36e5).optional(),
462
+ delayMs: z.number().int().min(0).max(36e5).optional(),
463
+ decimalPlaces: z.number().int().min(0).max(10).optional(),
464
+ displayKind: z.enum(COUNTER_DISPLAY_KINDS).optional(),
465
+ timeFormat: z.enum(COUNTER_TIME_FORMATS).optional(),
466
+ style: TextStyleSchema.optional(),
467
+ styleBreakpoints: TextStyleBreakpointsSchema
468
+ });
469
+ var CheckboxLayerSchema = z.object({
470
+ ...baseLayerShape,
471
+ kind: z.literal("checkbox"),
472
+ fieldKey: z.string().min(1),
473
+ blocking: z.boolean().optional(),
474
+ uncheckedStyle: CheckboxGlyphStyleSchema.optional(),
475
+ checkedStyle: CheckboxGlyphStyleSchema.optional(),
476
+ style: CommonStyleSchema.optional(),
477
+ styleBreakpoints: CommonStyleBreakpointsSchema
478
+ });
479
+
480
+ // src/layers/kinds/layout.ts
481
+ var lazyLayer2 = () => layerSchemaStore.schema;
482
+ var StackLayerSchema = z.object({
483
+ ...baseLayerShape,
484
+ kind: z.literal("stack"),
485
+ style: CommonStyleSchema.optional(),
486
+ styleBreakpoints: CommonStyleBreakpointsSchema,
487
+ stackLayoutBreakpoints: StackLayoutBreakpointsSchema,
488
+ selectedStyle: CommonStyleSchema.optional(),
489
+ direction: z.enum(["vertical", "horizontal"]),
490
+ gap: z.number().int().min(0).optional(),
491
+ align: z.enum(["start", "center", "end", "stretch"]).optional(),
492
+ justify: z.enum(["start", "center", "end"]).optional(),
493
+ distribution: z.enum(["start", "center", "end", "between", "around"]).optional(),
494
+ wrap: z.boolean().optional(),
495
+ children: z.lazy(() => z.array(lazyLayer2()))
496
+ });
497
+ var TextLayerSchema = z.object({
498
+ ...baseLayerShape,
499
+ kind: z.literal("text"),
500
+ text: LocalizedTextSchema,
501
+ style: TextStyleSchema.optional(),
502
+ styleBreakpoints: TextStyleBreakpointsSchema
503
+ });
504
+ var migrateLegacyHyperlinkForParse = (raw) => {
505
+ if (!raw || typeof raw !== "object") return raw;
506
+ const o = raw;
507
+ if (o.kind !== "hyperlink") return raw;
508
+ const existing = o.children;
509
+ if (Array.isArray(existing) && existing.length > 0) return raw;
510
+ const idSrc = typeof o.id === "string" ? o.id.replace(/[^a-zA-Z0-9_]/g, "_") : "lyr_hyperlink";
511
+ const textChildId = `${idSrc}_lnktxt`.slice(0, 64);
512
+ const children = [
513
+ {
514
+ id: textChildId,
515
+ kind: "text",
516
+ text: o.text ?? { default: "Link" },
517
+ ...typeof o.style === "object" && o.style !== null ? { style: o.style } : {},
518
+ ...typeof o.styleBreakpoints === "object" && o.styleBreakpoints !== null ? { styleBreakpoints: o.styleBreakpoints } : {}
519
+ }
520
+ ];
521
+ const next = {
522
+ ...o,
523
+ children
524
+ };
525
+ delete next.text;
526
+ delete next.style;
527
+ delete next.styleBreakpoints;
528
+ return next;
529
+ };
530
+ var HyperlinkLayerSchemaInner = z.object({
531
+ ...baseLayerShape,
532
+ kind: z.literal("hyperlink"),
533
+ href: z.string().min(1).max(2048),
534
+ children: z.lazy(() => z.array(lazyLayer2()).min(1)),
535
+ direction: z.enum(["vertical", "horizontal"]).optional(),
536
+ gap: z.number().int().min(0).optional(),
537
+ align: z.enum(["start", "center", "end", "stretch"]).optional(),
538
+ distribution: z.enum(["start", "center", "end", "between", "around"]).optional(),
539
+ wrap: z.boolean().optional(),
540
+ style: CommonStyleSchema.optional(),
541
+ styleBreakpoints: CommonStyleBreakpointsSchema
542
+ }).superRefine((data, ctx) => {
543
+ const p = parseHyperlinkHref(data.href.trim());
544
+ if (!p.ok) {
545
+ ctx.addIssue({
546
+ code: z.ZodIssueCode.custom,
547
+ message: "hyperlink href must be a valid https: or mailto: URL",
548
+ path: ["href"]
549
+ });
550
+ }
551
+ });
552
+ var HyperlinkLayerSchema = z.preprocess(
553
+ migrateLegacyHyperlinkForParse,
554
+ HyperlinkLayerSchemaInner
555
+ );
556
+ var ImageLayerSchema = z.object({
557
+ ...baseLayerShape,
558
+ kind: z.literal("image"),
559
+ media: MediaReferenceSchema.optional(),
560
+ alt: z.string().max(280).optional(),
561
+ style: ImageStyleSchema.optional(),
562
+ styleBreakpoints: ImageStyleBreakpointsSchema
563
+ });
564
+ var LottieLayerSchema = z.object({
565
+ ...baseLayerShape,
566
+ kind: z.literal("lottie"),
567
+ media: MediaReferenceSchema.optional(),
568
+ loop: z.boolean().optional(),
569
+ autoPlay: z.boolean().optional(),
570
+ triggerLayerId: z.string().min(1).optional(),
571
+ onComplete: LoaderOnCompleteSchema.optional(),
572
+ style: ImageStyleSchema.optional(),
573
+ styleBreakpoints: ImageStyleBreakpointsSchema
574
+ });
575
+ var VideoLayerSchema = z.object({
576
+ ...baseLayerShape,
577
+ kind: z.literal("video"),
578
+ media: MediaReferenceSchema.optional(),
579
+ loop: z.boolean().optional(),
580
+ autoPlay: z.boolean().optional(),
581
+ triggerLayerId: z.string().min(1).optional(),
582
+ onComplete: LoaderOnCompleteSchema.optional(),
583
+ audioEnabled: z.boolean().optional(),
584
+ style: ImageStyleSchema.optional(),
585
+ styleBreakpoints: ImageStyleBreakpointsSchema
586
+ });
587
+ var IconLayerSchema = z.object({
588
+ ...baseLayerShape,
589
+ kind: z.literal("icon"),
590
+ family: z.enum(ICON_FAMILIES),
591
+ iconName: z.string().min(1).max(128),
592
+ style: IconStyleSchema.optional(),
593
+ styleBreakpoints: IconStyleBreakpointsSchema
594
+ });
595
+ var lazyLayer3 = () => layerSchemaStore.schema;
596
+ var OAuthProviderPresetLayerSchema = z.object({
597
+ ...baseLayerShape,
598
+ kind: z.literal("oauth_provider"),
599
+ variant: z.literal("preset"),
600
+ provider: z.enum(OAUTH_LOGIN_PRESETS),
601
+ label: LocalizedTextSchema.optional(),
602
+ style: OAuthPresetButtonChromeSchema.optional(),
603
+ styleBreakpoints: OAuthPresetButtonChromeBreakpointsSchema.optional()
604
+ });
605
+ var migrateOAuthProviderCustomIncoming = (raw) => {
606
+ if (!raw || typeof raw !== "object") return raw;
607
+ const o = raw;
608
+ if (o.kind !== "oauth_provider" || o.variant !== "custom") return raw;
609
+ const ch = o.children;
610
+ if (Array.isArray(ch) && ch.length > 0) {
611
+ const next2 = { ...o };
612
+ if (next2.buttonVariant === void 0) next2.buttonVariant = "secondary";
613
+ return next2;
614
+ }
615
+ const pid = typeof o.id === "string" ? o.id : "lyr_oauth_custom";
616
+ const slug = pid.replace(/[^a-z0-9_]/gi, "_").slice(0, 40) || "oauth";
617
+ const label = o.label ?? { default: "Custom" };
618
+ let family = o.family ?? "ionicons";
619
+ let iconName = o.iconName ?? "shield-outline";
620
+ if (family === "sf_symbol") {
621
+ family = "ionicons";
622
+ iconName = "star-outline";
623
+ }
624
+ const cid = slug;
625
+ const iconId = `lyr_${cid}_ico`.slice(0, 64);
626
+ const textId = `lyr_${cid}_txt`.slice(0, 64);
627
+ const next = { ...o };
628
+ delete next.label;
629
+ delete next.family;
630
+ delete next.iconName;
631
+ return {
632
+ ...next,
633
+ buttonVariant: o.buttonVariant ?? "secondary",
634
+ children: [
635
+ { id: iconId, kind: "icon", family, iconName },
636
+ { id: textId, kind: "text", text: label }
637
+ ]
638
+ };
639
+ };
640
+ var OAuthProviderCustomLayerSchemaValidated = z.object({
641
+ ...baseLayerShape,
642
+ kind: z.literal("oauth_provider"),
643
+ variant: z.literal("custom"),
644
+ rowId: z.string().uuid(),
645
+ buttonVariant: ButtonLayerVariantSchema,
646
+ direction: z.enum(["vertical", "horizontal"]).optional(),
647
+ gap: z.number().int().min(0).optional(),
648
+ align: z.enum(["start", "center", "end", "stretch"]).optional(),
649
+ distribution: z.enum(["start", "center", "end", "between", "around"]).optional(),
650
+ children: z.lazy(() => z.array(lazyLayer3()).min(1)),
651
+ style: ButtonStyleSchema.optional(),
652
+ styleBreakpoints: ButtonStyleBreakpointsSchema,
653
+ buttonLayoutBreakpoints: ButtonLayoutBreakpointsSchema
654
+ });
655
+ var OAuthProviderCustomLayerSchema = z.preprocess(
656
+ migrateOAuthProviderCustomIncoming,
657
+ OAuthProviderCustomLayerSchemaValidated
658
+ );
659
+ var OAuthProviderLayerSchema = z.union([
660
+ OAuthProviderPresetLayerSchema,
661
+ OAuthProviderCustomLayerSchema
662
+ ]);
663
+ var OAuthLoginPresetProviderSchema = z.object({
664
+ type: z.literal("preset"),
665
+ provider: z.enum(OAUTH_LOGIN_PRESETS)
666
+ });
667
+ var OAuthLoginCustomProviderSchema = z.object({
668
+ type: z.literal("custom"),
669
+ rowId: z.string().uuid(),
670
+ label: LocalizedTextSchema,
671
+ family: z.enum(ICON_FAMILIES),
672
+ iconName: z.string().min(1).max(128)
673
+ });
674
+ var OAuthLoginProviderSchema = z.discriminatedUnion("type", [
675
+ OAuthLoginPresetProviderSchema,
676
+ OAuthLoginCustomProviderSchema
677
+ ]);
678
+ var oauthLoginChildrenUniquePresets = (children, ctx) => {
679
+ const seen = /* @__PURE__ */ new Set();
680
+ for (let i = 0; i < children.length; i++) {
681
+ const c = children[i];
682
+ if (!c || c.kind !== "oauth_provider" || c.variant !== "preset") continue;
683
+ const preset = c.provider;
684
+ if (seen.has(preset)) {
685
+ ctx.addIssue({
686
+ code: z.ZodIssueCode.custom,
687
+ message: `duplicate OAuth preset "${preset}"`,
688
+ path: ["children", i, "provider"]
689
+ });
690
+ return;
691
+ }
692
+ seen.add(preset);
693
+ }
694
+ };
695
+ var migrateOAuthLoginIncoming = (raw) => {
696
+ if (!raw || typeof raw !== "object") return raw;
697
+ const o = raw;
698
+ if (o.kind !== "oauth_login") return raw;
699
+ if (Array.isArray(o.children) && o.children.length > 0) return raw;
700
+ const provs = o.providers;
701
+ if (!Array.isArray(provs) || provs.length === 0) return raw;
702
+ const pid = typeof o.id === "string" ? o.id : "lyr_oauth_legacy";
703
+ const slug = pid.replace(/^lyr_/i, "").replace(/[^a-z0-9_]/gi, "_").replace(/^_+/, "").slice(0, 48) || "oauth";
704
+ const children = provs.map((p, idx) => {
705
+ const prov = p ?? {};
706
+ const cid = `lyr_${slug}_opr_${idx}`.slice(0, 64);
707
+ if (prov.type === "preset") {
708
+ return {
709
+ id: cid,
710
+ kind: "oauth_provider",
711
+ variant: "preset",
712
+ provider: prov.provider
713
+ };
714
+ }
715
+ return {
716
+ id: cid,
717
+ kind: "oauth_provider",
718
+ variant: "custom",
719
+ rowId: String(prov.rowId),
720
+ buttonVariant: "secondary",
721
+ children: [
722
+ {
723
+ id: `${cid}_ico`.slice(0, 64),
724
+ kind: "icon",
725
+ family: prov.family ?? "ionicons",
726
+ iconName: String(prov.iconName ?? "shield")
727
+ },
728
+ {
729
+ id: `${cid}_txt`.slice(0, 64),
730
+ kind: "text",
731
+ text: prov.label ?? { default: "Custom" }
732
+ }
733
+ ]
734
+ };
735
+ });
736
+ const { providers: _omit, ...rest } = o;
737
+ return { ...rest, children };
738
+ };
739
+ var OAuthLoginLayerSchemaValidated = z.object({
740
+ ...baseLayerShape,
741
+ kind: z.literal("oauth_login"),
742
+ children: z.lazy(
743
+ () => z.array(OAuthProviderLayerSchema).min(1).superRefine(oauthLoginChildrenUniquePresets)
744
+ ),
745
+ gap: z.number().int().min(0).optional(),
746
+ align: z.enum(["start", "center", "end", "stretch"]).optional(),
747
+ style: CommonStyleSchema.optional(),
748
+ styleBreakpoints: CommonStyleBreakpointsSchema
749
+ });
750
+ var OAuthLoginLayerSchema = z.preprocess(
751
+ migrateOAuthLoginIncoming,
752
+ OAuthLoginLayerSchemaValidated
753
+ );
754
+ z.array(OAuthLoginProviderSchema).min(1).superRefine((providers, ctx) => {
755
+ const seen = /* @__PURE__ */ new Set();
756
+ for (let i = 0; i < providers.length; i++) {
757
+ const p = providers[i];
758
+ if (!p || p.type !== "preset") continue;
759
+ const preset = p.provider;
760
+ if (seen.has(preset)) {
761
+ ctx.addIssue({
762
+ code: z.ZodIssueCode.custom,
763
+ message: `duplicate OAuth preset "${preset}"`,
764
+ path: [i, "provider"]
765
+ });
766
+ return;
767
+ }
768
+ seen.add(preset);
769
+ }
770
+ });
771
+ var FIELD_KEY_RE = /^[a-z][a-z0-9_]*$/;
772
+ var FieldKeySchema = z.string().min(1).max(64).regex(FIELD_KEY_RE, "field key must be snake_case");
773
+ var FieldClassificationSchema = z.enum(FIELD_CLASSIFICATIONS);
774
+
775
+ // src/layers/kinds/auth/emailPasswordAuth.ts
776
+ var lazyLayer4 = () => layerSchemaStore.schema;
777
+ var EmailPasswordAuthModeSchema = z.enum(EMAIL_PASSWORD_AUTH_MODES);
778
+ var migrateEmailPasswordAuthIncoming = (raw) => {
779
+ if (!raw || typeof raw !== "object") return raw;
780
+ const o = raw;
781
+ if (o.kind !== "email_password_auth") return raw;
782
+ if (Array.isArray(o.children) && o.children.length > 0) return raw;
783
+ const idBase = typeof o.id === "string" ? o.id : "lyr_email_password_auth";
784
+ const slugRaw = idBase.replace(/^lyr_/i, "").replace(/[^a-z0-9_]/gi, "_");
785
+ const slug = slugRaw.length > 0 ? slugRaw.slice(0, 40) : "ep_auth";
786
+ const mode = o.mode === "sign_up" ? "sign_up" : "sign_in";
787
+ const pickLt = (v, fallback) => v && typeof v === "object" && v !== null && "default" in v ? v : { default: fallback };
788
+ const mkField = (suf, slot, labelSource, fallbackPlaceholder) => ({
789
+ id: `lyr_${slug}_fld_${suf}`.slice(0, 64),
790
+ kind: "email_password_field",
791
+ slot,
792
+ ...labelSource ? { placeholder: pickLt(labelSource, fallbackPlaceholder) } : { placeholder: { default: fallbackPlaceholder } },
793
+ children: []
794
+ });
795
+ const children = [];
796
+ children.push(mkField("email", "email", o.emailLabel, "Email"));
797
+ children.push(mkField("pw", "password", o.passwordLabel, "Password"));
798
+ if (mode === "sign_up") {
799
+ children.push(mkField("cf", "confirm", o.confirmPasswordLabel, "Confirm password"));
800
+ }
801
+ const submitLbl = o.submitLabel ?? { default: mode === "sign_in" ? "Sign in" : "Create account" };
802
+ children.push({
803
+ id: `lyr_${slug}_submit`.slice(0, 64),
804
+ kind: "email_password_submit",
805
+ buttonVariant: "primary",
806
+ direction: "horizontal",
807
+ align: "center",
808
+ distribution: "center",
809
+ gap: 8,
810
+ children: [
811
+ {
812
+ id: `lyr_${slug}_submit_txt`.slice(0, 64),
813
+ kind: "text",
814
+ text: submitLbl
815
+ }
816
+ ]
817
+ });
818
+ const {
819
+ emailLabel: _e,
820
+ passwordLabel: _p,
821
+ confirmPasswordLabel: _c,
822
+ submitLabel: _s,
823
+ ...rest
824
+ } = o;
825
+ return { ...rest, mode, children };
826
+ };
827
+ var refineEmailPasswordAuthChildren = (data, ctx) => {
828
+ const fields = data.children.filter((c) => c.kind === "email_password_field");
829
+ const submits = data.children.filter((c) => c.kind === "email_password_submit");
830
+ const slotSeen = /* @__PURE__ */ new Set();
831
+ for (const f of fields) {
832
+ if (slotSeen.has(f.slot)) {
833
+ ctx.addIssue({
834
+ code: z.ZodIssueCode.custom,
835
+ message: `duplicate email_password_field slot "${f.slot}"`,
836
+ path: ["children"]
837
+ });
838
+ }
839
+ slotSeen.add(f.slot);
840
+ }
841
+ const slotHas = new Set(fields.map((f) => f.slot));
842
+ const requiredSlots = data.mode === "sign_up" ? ["email", "password", "confirm"] : ["email", "password"];
843
+ for (const s of requiredSlots) {
844
+ if (!slotHas.has(s)) {
845
+ ctx.addIssue({
846
+ code: z.ZodIssueCode.custom,
847
+ message: data.mode === "sign_up" ? `sign_up requires an email_password_field with slot "${s}"` : `sign_in requires an email_password_field with slot "${s}"`,
848
+ path: ["children"]
849
+ });
850
+ }
851
+ }
852
+ if (data.mode === "sign_in" && slotHas.has("confirm")) {
853
+ ctx.addIssue({
854
+ code: z.ZodIssueCode.custom,
855
+ message: 'sign_in must not include email_password_field with slot "confirm"',
856
+ path: ["children"]
857
+ });
858
+ }
859
+ if (submits.length !== 1) {
860
+ ctx.addIssue({
861
+ code: z.ZodIssueCode.custom,
862
+ message: `email_password_auth must have exactly one email_password_submit (found ${submits.length})`,
863
+ path: ["children"]
864
+ });
865
+ }
866
+ };
867
+ var EmailPasswordFieldLayerSchema = z.object({
868
+ ...baseLayerShape,
869
+ kind: z.literal("email_password_field"),
870
+ slot: z.enum(EMAIL_PASSWORD_SLOTS),
871
+ placeholder: LocalizedTextSchema.optional(),
872
+ children: z.lazy(() => z.array(lazyLayer4())).optional(),
873
+ style: CommonStyleSchema.optional(),
874
+ styleBreakpoints: CommonStyleBreakpointsSchema
875
+ });
876
+ var EmailPasswordSubmitLayerSchema = z.object({
877
+ ...baseLayerShape,
878
+ kind: z.literal("email_password_submit"),
879
+ buttonVariant: ButtonLayerVariantSchema,
880
+ direction: z.enum(["vertical", "horizontal"]).optional(),
881
+ gap: z.number().int().min(0).optional(),
882
+ align: z.enum(["start", "center", "end", "stretch"]).optional(),
883
+ distribution: z.enum(["start", "center", "end", "between", "around"]).optional(),
884
+ children: z.lazy(() => z.array(lazyLayer4()).min(1)),
885
+ style: ButtonStyleSchema.optional(),
886
+ styleBreakpoints: ButtonStyleBreakpointsSchema,
887
+ buttonLayoutBreakpoints: ButtonLayoutBreakpointsSchema
888
+ });
889
+ var EmailPasswordAuthLayerSchemaValidated = z.object({
890
+ ...baseLayerShape,
891
+ kind: z.literal("email_password_auth"),
892
+ mode: EmailPasswordAuthModeSchema,
893
+ fieldKey: FieldKeySchema,
894
+ minPasswordLength: z.number().int().min(4).max(128).optional(),
895
+ children: z.lazy(
896
+ () => z.array(z.union([EmailPasswordFieldLayerSchema, EmailPasswordSubmitLayerSchema])).min(1)
897
+ ),
898
+ gap: z.number().int().min(0).optional(),
899
+ align: z.enum(["start", "center", "end", "stretch"]).optional(),
900
+ style: CommonStyleSchema.optional(),
901
+ styleBreakpoints: CommonStyleBreakpointsSchema
902
+ }).superRefine(refineEmailPasswordAuthChildren);
903
+ var EmailPasswordAuthLayerSchema = z.preprocess(
904
+ migrateEmailPasswordAuthIncoming,
905
+ EmailPasswordAuthLayerSchemaValidated
906
+ );
907
+ var ChoiceOptionBindingSchema = z.object({
908
+ optionId: z.string().min(1).max(64),
909
+ rootLayerId: LayerIdSchema
910
+ });
911
+ var BranchConditionSchema = z.object({
912
+ choiceId: z.string().min(1),
913
+ goTo: ScreenIdSchema
914
+ });
915
+ var ChoiceBranchingSchema = z.object({
916
+ enabled: z.boolean(),
917
+ conditions: z.array(BranchConditionSchema)
918
+ });
919
+
920
+ // src/layers/kinds/input.ts
921
+ var lazyLayer5 = () => layerSchemaStore.schema;
922
+ var ChoiceChildrenAndBindingsRefinement = (data, ctx) => {
923
+ const childIds = /* @__PURE__ */ new Set();
924
+ for (const c of data.children) {
925
+ if (childIds.has(c.id)) {
926
+ ctx.addIssue({
927
+ code: z.ZodIssueCode.custom,
928
+ message: `duplicate option child id "${c.id}"`,
929
+ path: ["children"]
930
+ });
931
+ }
932
+ childIds.add(c.id);
933
+ }
934
+ const seenOptionIds = /* @__PURE__ */ new Set();
935
+ const seenRootIds = /* @__PURE__ */ new Set();
936
+ for (const b of data.optionBindings) {
937
+ if (seenOptionIds.has(b.optionId)) {
938
+ ctx.addIssue({
939
+ code: z.ZodIssueCode.custom,
940
+ message: `duplicate optionId "${b.optionId}" in optionBindings`,
941
+ path: ["optionBindings"]
942
+ });
943
+ }
944
+ seenOptionIds.add(b.optionId);
945
+ if (seenRootIds.has(b.rootLayerId)) {
946
+ ctx.addIssue({
947
+ code: z.ZodIssueCode.custom,
948
+ message: `duplicate rootLayerId "${b.rootLayerId}" in optionBindings`,
949
+ path: ["optionBindings"]
950
+ });
951
+ }
952
+ seenRootIds.add(b.rootLayerId);
953
+ if (!childIds.has(b.rootLayerId)) {
954
+ ctx.addIssue({
955
+ code: z.ZodIssueCode.custom,
956
+ message: `optionBindings rootLayerId "${b.rootLayerId}" does not match any direct child stack`,
957
+ path: ["optionBindings"]
958
+ });
959
+ }
960
+ }
961
+ if (data.optionBindings.length !== data.children.length) {
962
+ ctx.addIssue({
963
+ code: z.ZodIssueCode.custom,
964
+ message: "optionBindings length must equal children length",
965
+ path: ["optionBindings"]
966
+ });
967
+ }
968
+ };
969
+ var SingleChoiceLayerSchema = z.object({
970
+ ...baseLayerShape,
971
+ kind: z.literal("single_choice"),
972
+ fieldKey: FieldKeySchema,
973
+ children: z.lazy(
974
+ () => z.array(StackLayerSchema).min(2)
975
+ ),
976
+ optionBindings: z.array(ChoiceOptionBindingSchema).min(2),
977
+ branching: ChoiceBranchingSchema,
978
+ direction: z.enum(["vertical", "horizontal", "grid"]).optional(),
979
+ gap: z.number().int().min(0).optional(),
980
+ columns: z.number().int().min(1).max(12).optional(),
981
+ style: CommonStyleSchema.optional(),
982
+ styleBreakpoints: CommonStyleBreakpointsSchema
983
+ });
984
+ var MultipleChoiceLayerSchema = z.object({
985
+ ...baseLayerShape,
986
+ kind: z.literal("multiple_choice"),
987
+ fieldKey: FieldKeySchema,
988
+ children: z.lazy(
989
+ () => z.array(StackLayerSchema).min(2)
990
+ ),
991
+ optionBindings: z.array(ChoiceOptionBindingSchema).min(2),
992
+ minSelections: z.number().int().nonnegative().optional(),
993
+ maxSelections: z.number().int().positive().optional(),
994
+ branching: ChoiceBranchingSchema,
995
+ direction: z.enum(["vertical", "horizontal", "grid"]).optional(),
996
+ gap: z.number().int().min(0).optional(),
997
+ columns: z.number().int().min(1).max(12).optional(),
998
+ style: CommonStyleSchema.optional(),
999
+ styleBreakpoints: CommonStyleBreakpointsSchema
1000
+ });
1001
+ var validateChoiceChildrenAndBindings = ChoiceChildrenAndBindingsRefinement;
1002
+ var TextInputLayerSchema = z.object({
1003
+ ...baseLayerShape,
1004
+ kind: z.literal("text_input"),
1005
+ fieldKey: FieldKeySchema,
1006
+ placeholder: LocalizedTextSchema.optional(),
1007
+ inputType: TextInputTypeSchema.optional(),
1008
+ required: z.boolean().optional(),
1009
+ minLength: z.number().int().min(0).max(2e3).optional(),
1010
+ maxLength: z.number().int().positive().max(2e3).optional(),
1011
+ classification: FieldClassificationSchema,
1012
+ children: z.lazy(() => z.array(lazyLayer5())).optional(),
1013
+ style: CommonStyleSchema.optional()
1014
+ });
1015
+ var ScaleInputLabelStyleSchema = z.object({
1016
+ fontFamily: z.string().min(1).max(128).optional(),
1017
+ fontSize: z.number().int().min(8).max(96).optional(),
1018
+ fontWeight: z.number().int().min(100).max(900).optional(),
1019
+ color: ThemedColorSchema.optional(),
1020
+ align: z.enum(["left", "center", "right"]).optional(),
1021
+ lineHeight: z.number().min(0.8).max(3).optional(),
1022
+ opacity: z.number().min(0).max(1).optional()
1023
+ }).partial();
1024
+ var ScaleInputLayerSchema = z.object({
1025
+ ...baseLayerShape,
1026
+ kind: z.literal("scale_input"),
1027
+ fieldKey: FieldKeySchema,
1028
+ min: z.number(),
1029
+ max: z.number(),
1030
+ step: z.number().positive().optional(),
1031
+ defaultValue: z.number().optional(),
1032
+ minLabel: LocalizedTextSchema.optional(),
1033
+ maxLabel: LocalizedTextSchema.optional(),
1034
+ labelStyle: ScaleInputLabelStyleSchema.optional(),
1035
+ valueStyle: ScaleInputLabelStyleSchema.optional(),
1036
+ showLabels: z.boolean().optional(),
1037
+ showValue: z.boolean().optional(),
1038
+ trackHeight: z.number().int().min(2).max(32).optional(),
1039
+ trackColor: ThemedColorSchema.optional(),
1040
+ fillColor: ThemedColorSchema.optional(),
1041
+ thumbSize: z.number().int().min(8).max(48).optional(),
1042
+ thumbColor: ThemedColorSchema.optional(),
1043
+ children: z.lazy(() => z.array(lazyLayer5())).optional(),
1044
+ style: CommonStyleSchema.optional()
1045
+ });
1046
+ var CarouselIndicatorsStyleSchema = z.object({
1047
+ width: z.number().int().min(1).max(64).optional(),
1048
+ height: z.number().int().min(1).max(64).optional(),
1049
+ defaultColor: ThemedColorSchema.optional(),
1050
+ defaultOpacity: z.number().min(0).max(1).optional(),
1051
+ activeColor: ThemedColorSchema.optional(),
1052
+ activeOpacity: z.number().min(0).max(1).optional(),
1053
+ activeWidth: z.number().int().min(1).max(64).optional(),
1054
+ activeHeight: z.number().int().min(1).max(64).optional(),
1055
+ border: BorderSchema.optional(),
1056
+ activeBorder: BorderSchema.optional()
1057
+ }).partial();
1058
+ var CarouselPageControlSchema = z.object({
1059
+ position: z.enum(["top", "bottom"]),
1060
+ spacing: z.number().int().min(0).optional(),
1061
+ padding: PaddingSchema.optional(),
1062
+ margin: PaddingSchema.optional(),
1063
+ indicators: CarouselIndicatorsStyleSchema.optional(),
1064
+ border: BorderSchema.optional(),
1065
+ shadow: DropShadowSchema.optional()
1066
+ });
1067
+ var CarouselLayerSchema = z.object({
1068
+ ...baseLayerShape,
1069
+ kind: z.literal("carousel"),
1070
+ slides: z.lazy(() => z.array(StackLayerSchema).min(1)),
1071
+ pageAlignment: z.enum(["top", "center", "bottom"]).optional(),
1072
+ pageSpacing: z.number().int().min(0).optional(),
1073
+ pagePeek: z.number().int().min(0).max(400).optional(),
1074
+ openOn: z.number().int().min(0).optional(),
1075
+ loop: z.boolean().optional(),
1076
+ autoAdvance: z.boolean().optional(),
1077
+ autoAdvanceMs: z.number().int().min(500).max(6e4).optional(),
1078
+ pageControl: CarouselPageControlSchema.optional(),
1079
+ style: CommonStyleSchema.optional(),
1080
+ styleBreakpoints: CommonStyleBreakpointsSchema
1081
+ });
1082
+
1083
+ // src/layers/initLayerSchema.ts
1084
+ layerSchemaStore.schema = z.lazy(
1085
+ () => z.union([
1086
+ StackLayerSchema,
1087
+ TextLayerSchema,
1088
+ HyperlinkLayerSchema,
1089
+ ImageLayerSchema,
1090
+ LottieLayerSchema,
1091
+ VideoLayerSchema,
1092
+ IconLayerSchema,
1093
+ ButtonLayerSchema,
1094
+ BackButtonLayerSchema,
1095
+ ProgressLayerSchema,
1096
+ LoaderLayerSchema,
1097
+ CounterLayerSchema,
1098
+ CheckboxLayerSchema,
1099
+ SingleChoiceLayerSchema,
1100
+ MultipleChoiceLayerSchema,
1101
+ TextInputLayerSchema,
1102
+ ScaleInputLayerSchema,
1103
+ OAuthLoginLayerSchema,
1104
+ OAuthProviderPresetLayerSchema,
1105
+ OAuthProviderCustomLayerSchema,
1106
+ EmailPasswordAuthLayerSchema,
1107
+ EmailPasswordFieldLayerSchema,
1108
+ EmailPasswordSubmitLayerSchema,
1109
+ CarouselLayerSchema
1110
+ ])
1111
+ );
1112
+
1113
+ // src/layers/tree.ts
1114
+ var STYLE_BREAKPOINT_KEYS = ["sm", "md", "lg", "xl", "2xl"];
1115
+ var commonStyleHasAbsolutePosition = (style, breakpoints) => {
1116
+ if (style?.position === "absolute") return true;
1117
+ if (!breakpoints) return false;
1118
+ for (const k of STYLE_BREAKPOINT_KEYS) {
1119
+ if (breakpoints[k]?.position === "absolute") return true;
1120
+ }
1121
+ return false;
1122
+ };
1123
+ var layerHasAbsolutePositionAuthored = (layer) => {
1124
+ switch (layer.kind) {
1125
+ case "stack":
1126
+ return commonStyleHasAbsolutePosition(layer.style, layer.styleBreakpoints) || layer.selectedStyle?.position === "absolute";
1127
+ case "text":
1128
+ case "counter":
1129
+ return commonStyleHasAbsolutePosition(layer.style, layer.styleBreakpoints);
1130
+ case "image":
1131
+ case "lottie":
1132
+ case "video":
1133
+ return commonStyleHasAbsolutePosition(layer.style, layer.styleBreakpoints);
1134
+ case "icon":
1135
+ return commonStyleHasAbsolutePosition(layer.style, layer.styleBreakpoints);
1136
+ case "button":
1137
+ case "back_button":
1138
+ case "hyperlink":
1139
+ return commonStyleHasAbsolutePosition(layer.style, layer.styleBreakpoints);
1140
+ case "progress":
1141
+ case "loader":
1142
+ return commonStyleHasAbsolutePosition(layer.style, void 0);
1143
+ case "text_input":
1144
+ case "scale_input":
1145
+ return commonStyleHasAbsolutePosition(layer.style, void 0);
1146
+ case "oauth_provider":
1147
+ if (layer.variant === "preset") {
1148
+ return commonStyleHasAbsolutePosition(layer.style, layer.styleBreakpoints);
1149
+ }
1150
+ return commonStyleHasAbsolutePosition(layer.style, layer.styleBreakpoints);
1151
+ case "oauth_login":
1152
+ return commonStyleHasAbsolutePosition(layer.style, layer.styleBreakpoints);
1153
+ case "email_password_auth":
1154
+ return commonStyleHasAbsolutePosition(layer.style, layer.styleBreakpoints);
1155
+ case "email_password_field":
1156
+ return commonStyleHasAbsolutePosition(layer.style, layer.styleBreakpoints);
1157
+ case "email_password_submit":
1158
+ return commonStyleHasAbsolutePosition(layer.style, layer.styleBreakpoints);
1159
+ case "carousel":
1160
+ return commonStyleHasAbsolutePosition(layer.style, void 0);
1161
+ case "checkbox":
1162
+ case "single_choice":
1163
+ case "multiple_choice":
1164
+ return commonStyleHasAbsolutePosition(layer.style, layer.styleBreakpoints);
1165
+ default:
1166
+ return false;
1167
+ }
1168
+ };
1169
+
1170
+ // src/layers/layerUnion.ts
1171
+ var isInputLayer = (l) => l.kind === "single_choice" || l.kind === "multiple_choice" || l.kind === "text_input" || l.kind === "scale_input";
1172
+ var ScreenBackgroundFitSchema = z.enum(["cover", "contain", "fill"]);
1173
+ var ScreenBackgroundScrimSchema = z.object({
1174
+ color: ThemedColorSchema.optional(),
1175
+ opacity: z.number().min(0).max(1).optional()
1176
+ }).partial();
1177
+ var screenBackgroundMediaShape = {
1178
+ media: MediaReferenceSchema.optional(),
1179
+ fit: ScreenBackgroundFitSchema.optional(),
1180
+ opacity: z.number().min(0).max(1).optional(),
1181
+ scrim: ScreenBackgroundScrimSchema.optional()
1182
+ };
1183
+ var ScreenBackgroundColorFillSchema = z.object({
1184
+ kind: z.literal("color"),
1185
+ color: ThemedColorSchema.optional(),
1186
+ opacity: z.number().min(0).max(1).optional()
1187
+ });
1188
+ var ScreenBackgroundImageFillSchema = z.object({
1189
+ kind: z.literal("image"),
1190
+ ...screenBackgroundMediaShape
1191
+ });
1192
+ var ScreenBackgroundVideoFillSchema = z.object({
1193
+ kind: z.literal("video"),
1194
+ ...screenBackgroundMediaShape,
1195
+ loop: z.boolean().optional(),
1196
+ autoPlay: z.boolean().optional(),
1197
+ triggerLayerId: z.string().min(1).optional(),
1198
+ onComplete: LoaderOnCompleteSchema.optional(),
1199
+ audioEnabled: z.boolean().optional()
1200
+ });
1201
+ var ScreenBackgroundFillSchema = z.discriminatedUnion("kind", [
1202
+ ScreenBackgroundColorFillSchema,
1203
+ ScreenBackgroundImageFillSchema,
1204
+ ScreenBackgroundVideoFillSchema
1205
+ ]);
1206
+ var ScreenBackgroundFillPatchSchema = z.object({
1207
+ color: ThemedColorSchema.optional(),
1208
+ fit: ScreenBackgroundFitSchema.optional(),
1209
+ opacity: z.number().min(0).max(1).optional(),
1210
+ scrim: ScreenBackgroundScrimSchema.optional(),
1211
+ loop: z.boolean().optional(),
1212
+ autoPlay: z.boolean().optional(),
1213
+ triggerLayerId: z.string().min(1).optional(),
1214
+ onComplete: LoaderOnCompleteSchema.optional(),
1215
+ audioEnabled: z.boolean().optional()
1216
+ }).partial();
1217
+ var ScreenContainerBreakpointPatchSchema = z.object({
1218
+ padding: PaddingSchema.optional(),
1219
+ margin: PaddingSchema.optional(),
1220
+ insetSafeArea: z.boolean().optional(),
1221
+ backgroundFillPatch: ScreenBackgroundFillPatchSchema.optional()
1222
+ }).partial();
1223
+ var ScreenContainerStyleBreakpointsSchema = z.object({
1224
+ sm: ScreenContainerBreakpointPatchSchema.optional(),
1225
+ md: ScreenContainerBreakpointPatchSchema.optional(),
1226
+ lg: ScreenContainerBreakpointPatchSchema.optional(),
1227
+ xl: ScreenContainerBreakpointPatchSchema.optional(),
1228
+ "2xl": ScreenContainerBreakpointPatchSchema.optional()
1229
+ }).partial().optional();
1230
+ var DecisionNodeIdSchema = z.string().min(1).max(64).regex(/^dec_[a-z0-9_]+$/i, "decision node id must look like dec_<id>");
1231
+ var ExternalSurfaceJumpIdSchema = z.string().min(1).max(64).regex(/^surf_[a-z0-9_]+$/i, "external surface node id must look like surf_<id>");
1232
+ var EXTERNAL_SURFACE_NO_NEXT = "__onb_surface_no_next__";
1233
+ var ExternalSurfaceTerminalTargetSchema = z.literal(EXTERNAL_SURFACE_NO_NEXT);
1234
+ var FlowJumpTargetSchema = ScreenIdSchema.or(DecisionNodeIdSchema).or(ExternalSurfaceJumpIdSchema).or(ExternalSurfaceTerminalTargetSchema).nullable();
1235
+ var DecisionBuiltinNameSchema = z.enum(["locale", "platform"]);
1236
+ var DecisionVariableRefSchema = z.discriminatedUnion("kind", [
1237
+ z.object({ kind: z.literal("builtin"), name: DecisionBuiltinNameSchema }),
1238
+ z.object({ kind: z.literal("sdk"), key: z.string().min(1).max(128) }),
1239
+ z.object({ kind: z.literal("field"), fieldKey: z.string().min(1).max(128) })
1240
+ ]);
1241
+ var DecisionStringPredicateSchema = z.discriminatedUnion("op", [
1242
+ z.object({ op: z.literal("eq"), value: z.string() }),
1243
+ z.object({ op: z.literal("neq"), value: z.string() }),
1244
+ z.object({ op: z.literal("contains"), value: z.string() })
1245
+ ]);
1246
+ var DecisionNumberPredicateSchema = z.discriminatedUnion("op", [
1247
+ z.object({ op: z.literal("eq"), value: z.number() }),
1248
+ z.object({ op: z.literal("neq"), value: z.number() }),
1249
+ z.object({ op: z.literal("lt"), value: z.number() }),
1250
+ z.object({ op: z.literal("lte"), value: z.number() }),
1251
+ z.object({ op: z.literal("gt"), value: z.number() }),
1252
+ z.object({ op: z.literal("gte"), value: z.number() })
1253
+ ]);
1254
+ var DecisionChoicePredicateSchema = z.discriminatedUnion("op", [
1255
+ z.object({ op: z.literal("eq"), optionId: z.string().min(1) }),
1256
+ z.object({ op: z.literal("one_of"), optionIds: z.array(z.string().min(1)).min(1) })
1257
+ ]);
1258
+ var DecisionMultiPredicateSchema = z.discriminatedUnion("op", [
1259
+ z.object({
1260
+ op: z.literal("intersects"),
1261
+ optionIds: z.array(z.string().min(1)).min(1)
1262
+ }),
1263
+ z.object({
1264
+ op: z.literal("contains_all"),
1265
+ optionIds: z.array(z.string().min(1)).min(1)
1266
+ }),
1267
+ z.object({
1268
+ op: z.literal("subset_of"),
1269
+ optionIds: z.array(z.string().min(1)).min(1)
1270
+ })
1271
+ ]);
1272
+ var DecisionBooleanPredicateSchema = z.discriminatedUnion("op", [
1273
+ z.object({ op: z.literal("eq"), value: z.boolean() }),
1274
+ z.object({ op: z.literal("neq"), value: z.boolean() })
1275
+ ]);
1276
+ var DecisionPredicatePayloadSchema = z.discriminatedUnion("type", [
1277
+ z.object({ type: z.literal("string"), pred: DecisionStringPredicateSchema }),
1278
+ z.object({ type: z.literal("number"), pred: DecisionNumberPredicateSchema }),
1279
+ z.object({ type: z.literal("boolean"), pred: DecisionBooleanPredicateSchema }),
1280
+ z.object({ type: z.literal("choice"), pred: DecisionChoicePredicateSchema }),
1281
+ z.object({ type: z.literal("multi"), pred: DecisionMultiPredicateSchema })
1282
+ ]);
1283
+ var DecisionExprSchema = z.lazy(
1284
+ () => z.discriminatedUnion("kind", [
1285
+ z.object({ kind: z.literal("empty") }),
1286
+ z.object({
1287
+ kind: z.literal("group"),
1288
+ op: z.enum(["and", "or"]),
1289
+ children: z.array(DecisionExprSchema).min(1)
1290
+ }),
1291
+ z.object({
1292
+ kind: z.literal("predicate"),
1293
+ variable: DecisionVariableRefSchema,
1294
+ predicate: DecisionPredicatePayloadSchema
1295
+ })
1296
+ ])
1297
+ );
1298
+ var DecisionCaseSchema = z.object({
1299
+ id: z.string().min(1).max(80),
1300
+ /** Display label in the editor (e.g. “Engaged users”). */
1301
+ name: z.string().min(1).max(80).optional(),
1302
+ expression: DecisionExprSchema,
1303
+ next: FlowJumpTargetSchema
1304
+ });
1305
+ var DecisionNodeSchema = z.object({
1306
+ id: DecisionNodeIdSchema,
1307
+ name: z.string().min(1).max(80).optional(),
1308
+ cases: z.array(DecisionCaseSchema).min(1).max(16),
1309
+ elseNext: FlowJumpTargetSchema
1310
+ });
1311
+ var collectDecisionSdkKeys = (expr) => {
1312
+ const out = [];
1313
+ const walk = (e) => {
1314
+ if (e.kind === "empty") return;
1315
+ if (e.kind === "predicate") {
1316
+ if (e.variable.kind === "sdk") out.push(e.variable.key);
1317
+ return;
1318
+ }
1319
+ for (const c of e.children) walk(c);
1320
+ };
1321
+ walk(expr);
1322
+ return out;
1323
+ };
1324
+ var collectDecisionFieldKeys = (expr) => {
1325
+ const out = [];
1326
+ const walk = (e) => {
1327
+ if (e.kind === "empty") return;
1328
+ if (e.kind === "predicate") {
1329
+ if (e.variable.kind === "field") out.push(e.variable.fieldKey);
1330
+ return;
1331
+ }
1332
+ for (const c of e.children) walk(c);
1333
+ };
1334
+ walk(expr);
1335
+ return out;
1336
+ };
1337
+ var collectDecisionFieldKeysFromNode = (node) => {
1338
+ const seen = /* @__PURE__ */ new Set();
1339
+ for (const c of node.cases) {
1340
+ for (const k of collectDecisionFieldKeys(c.expression)) seen.add(k);
1341
+ }
1342
+ return [...seen];
1343
+ };
1344
+ var ANIMATABLE_PROPERTIES = [
1345
+ "opacity",
1346
+ "translateX",
1347
+ "translateY",
1348
+ "scale"
1349
+ ];
1350
+ var AnimatablePropertySchema = z.enum(ANIMATABLE_PROPERTIES);
1351
+ var EASING_TOKENS = [
1352
+ "linear",
1353
+ "ease-in",
1354
+ "ease-out",
1355
+ "ease-in-out",
1356
+ "standard",
1357
+ "emphasized"
1358
+ ];
1359
+ var EasingTokenSchema = z.enum(EASING_TOKENS);
1360
+ var KeyframeSchema = z.object({
1361
+ t: z.number().min(0).max(1),
1362
+ value: z.number(),
1363
+ /** Easing applied from this keyframe to the next; defaults to linear. */
1364
+ easing: EasingTokenSchema.optional()
1365
+ }).strict();
1366
+ var KeyframeTrackSchema = z.object({
1367
+ property: AnimatablePropertySchema,
1368
+ keyframes: z.array(KeyframeSchema).min(2)
1369
+ }).strict().superRefine((track, ctx) => {
1370
+ let last = -Infinity;
1371
+ for (const k of track.keyframes) {
1372
+ if (k.t < last) {
1373
+ ctx.addIssue({
1374
+ code: z.ZodIssueCode.custom,
1375
+ message: `keyframe times must be monotonically non-decreasing on track "${track.property}"`
1376
+ });
1377
+ return;
1378
+ }
1379
+ last = k.t;
1380
+ }
1381
+ if (track.keyframes[0].t !== 0) {
1382
+ ctx.addIssue({
1383
+ code: z.ZodIssueCode.custom,
1384
+ message: `track "${track.property}" first keyframe must start at t=0`
1385
+ });
1386
+ }
1387
+ if (track.keyframes[track.keyframes.length - 1].t !== 1) {
1388
+ ctx.addIssue({
1389
+ code: z.ZodIssueCode.custom,
1390
+ message: `track "${track.property}" last keyframe must end at t=1`
1391
+ });
1392
+ }
1393
+ });
1394
+ var ANIMATION_TRIGGERS = ["mount", "stagger", "unmount"];
1395
+ var AnimationTriggerSchema = z.enum(ANIMATION_TRIGGERS);
1396
+ var AnimationClipSchema = z.object({
1397
+ id: z.string().min(1).max(64),
1398
+ targetLayerId: LayerIdSchema,
1399
+ trigger: AnimationTriggerSchema,
1400
+ /** Position in the screen's stagger order. Required when trigger is `stagger`. */
1401
+ staggerIndex: z.number().int().min(0).max(64).optional(),
1402
+ /** Total clip duration in milliseconds (renderer scales 0..1 keyframes by this). */
1403
+ durationMs: z.number().int().min(0).max(36e5),
1404
+ /** Pre-roll delay before the clip begins, in ms. Stagger adds on top of this. */
1405
+ delayMs: z.number().int().min(0).max(36e5).optional(),
1406
+ tracks: z.array(KeyframeTrackSchema).min(1)
1407
+ }).strict().superRefine((clip, ctx) => {
1408
+ if (clip.trigger === "unmount" && clip.staggerIndex !== void 0) {
1409
+ ctx.addIssue({
1410
+ code: z.ZodIssueCode.custom,
1411
+ message: `clip "${clip.id}" with trigger "unmount" must not set staggerIndex`,
1412
+ path: ["staggerIndex"]
1413
+ });
1414
+ }
1415
+ if (clip.trigger === "stagger" && clip.staggerIndex === void 0) {
1416
+ ctx.addIssue({
1417
+ code: z.ZodIssueCode.custom,
1418
+ message: `clip "${clip.id}" with trigger "stagger" must define staggerIndex`,
1419
+ path: ["staggerIndex"]
1420
+ });
1421
+ }
1422
+ const seenProps = /* @__PURE__ */ new Set();
1423
+ for (const track of clip.tracks) {
1424
+ if (seenProps.has(track.property)) {
1425
+ ctx.addIssue({
1426
+ code: z.ZodIssueCode.custom,
1427
+ message: `clip "${clip.id}" has duplicate track for property "${track.property}"`
1428
+ });
1429
+ }
1430
+ seenProps.add(track.property);
1431
+ }
1432
+ });
1433
+ var ScreenStaggerSchema = z.object({
1434
+ /** Per-index delay multiplier in ms. */
1435
+ stepMs: z.number().int().min(0).max(2e3)
1436
+ }).strict();
1437
+
1438
+ // src/screens.ts
1439
+ var ScreenNextSchema = z.object({
1440
+ default: FlowJumpTargetSchema
1441
+ });
1442
+ var ScreenRegionsSchema = z.object({
1443
+ header: StackLayerSchema.optional(),
1444
+ body: StackLayerSchema,
1445
+ footer: StackLayerSchema.optional()
1446
+ });
1447
+ var ScreenContainerStyleSchema = z.object({
1448
+ padding: PaddingSchema.optional(),
1449
+ margin: PaddingSchema.optional(),
1450
+ /** When true, runtimes add device safe-area insets to shell padding (in addition to manual padding). */
1451
+ insetSafeArea: z.boolean().optional(),
1452
+ backgroundFill: ScreenBackgroundFillSchema.optional()
1453
+ }).partial();
1454
+ var ScreenSchema = z.object({
1455
+ id: ScreenIdSchema,
1456
+ name: z.string().min(1).max(80),
1457
+ regions: ScreenRegionsSchema,
1458
+ next: ScreenNextSchema,
1459
+ /** Ordered animation clips bound to layers on this screen. */
1460
+ animations: z.array(AnimationClipSchema).optional(),
1461
+ /** Defaults for clips with `trigger: stagger`. */
1462
+ stagger: ScreenStaggerSchema.optional(),
1463
+ /** Chrome on the outer screen container (wraps all regions). */
1464
+ containerStyle: ScreenContainerStyleSchema.optional(),
1465
+ containerStyleBreakpoints: ScreenContainerStyleBreakpointsSchema
1466
+ });
1467
+ var walkScreenLayersWithLayoutContext = (screen, fn) => {
1468
+ const visit = (l, ctx) => {
1469
+ fn(l, ctx);
1470
+ const childCtx = (opts = {}) => ({
1471
+ region: ctx.region,
1472
+ isRegionRoot: false,
1473
+ insideChoiceOption: opts.insideChoiceOption ?? ctx.insideChoiceOption,
1474
+ parentKind: l.kind
1475
+ });
1476
+ if (l.kind === "stack") {
1477
+ for (const c of l.children) visit(c, childCtx());
1478
+ } else if (l.kind === "carousel") {
1479
+ for (const s of l.slides) visit(s, childCtx());
1480
+ } else if (l.kind === "button" || l.kind === "back_button") {
1481
+ for (const c of l.children) visit(c, childCtx());
1482
+ } else if (l.kind === "hyperlink") {
1483
+ for (const c of l.children) visit(c, childCtx());
1484
+ } else if (l.kind === "single_choice" || l.kind === "multiple_choice") {
1485
+ for (const c of l.children) {
1486
+ visit(c, childCtx({ insideChoiceOption: true }));
1487
+ }
1488
+ } else if (l.kind === "text_input" || l.kind === "scale_input") {
1489
+ for (const c of l.children ?? []) visit(c, childCtx());
1490
+ } else if (l.kind === "oauth_login") {
1491
+ for (const c of l.children) visit(c, childCtx());
1492
+ } else if (l.kind === "oauth_provider" && l.variant === "custom") {
1493
+ for (const c of l.children) visit(c, childCtx());
1494
+ } else if (l.kind === "email_password_auth") {
1495
+ for (const c of l.children) visit(c, childCtx());
1496
+ } else if (l.kind === "email_password_field") {
1497
+ for (const c of l.children ?? []) visit(c, childCtx());
1498
+ } else if (l.kind === "email_password_submit") {
1499
+ for (const c of l.children) visit(c, childCtx());
1500
+ }
1501
+ };
1502
+ const regionCtx = (region) => ({
1503
+ region,
1504
+ isRegionRoot: true,
1505
+ insideChoiceOption: false,
1506
+ parentKind: null
1507
+ });
1508
+ if (screen.regions.header) visit(screen.regions.header, regionCtx("header"));
1509
+ visit(screen.regions.body, regionCtx("body"));
1510
+ if (screen.regions.footer) visit(screen.regions.footer, regionCtx("footer"));
1511
+ };
1512
+ var walkScreenLayers = (screen, fn) => {
1513
+ const visit = (l) => {
1514
+ fn(l);
1515
+ if (l.kind === "stack") l.children.forEach(visit);
1516
+ else if (l.kind === "carousel") l.slides.forEach(visit);
1517
+ else if (l.kind === "button") l.children.forEach(visit);
1518
+ else if (l.kind === "back_button") l.children.forEach(visit);
1519
+ else if (l.kind === "hyperlink") l.children.forEach(visit);
1520
+ else if (l.kind === "single_choice" || l.kind === "multiple_choice") {
1521
+ l.children.forEach(visit);
1522
+ } else if (l.kind === "text_input" || l.kind === "scale_input") {
1523
+ l.children?.forEach(visit);
1524
+ } else if (l.kind === "oauth_login") {
1525
+ l.children.forEach(visit);
1526
+ } else if (l.kind === "oauth_provider" && l.variant === "custom") {
1527
+ l.children.forEach(visit);
1528
+ } else if (l.kind === "email_password_auth") {
1529
+ l.children.forEach(visit);
1530
+ } else if (l.kind === "email_password_field") {
1531
+ l.children?.forEach(visit);
1532
+ } else if (l.kind === "email_password_submit") {
1533
+ l.children.forEach(visit);
1534
+ }
1535
+ };
1536
+ if (screen.regions.header) visit(screen.regions.header);
1537
+ visit(screen.regions.body);
1538
+ if (screen.regions.footer) visit(screen.regions.footer);
1539
+ };
1540
+
1541
+ // src/canvasEditorGates.ts
1542
+ var CanvasEditorGatesResolvedSchema = z.object({
1543
+ lottie: z.boolean(),
1544
+ oauthLogin: z.boolean(),
1545
+ oauthProviderPreset: z.boolean(),
1546
+ oauthProviderCustom: z.boolean(),
1547
+ emailPasswordAuth: z.boolean(),
1548
+ emailPasswordField: z.boolean(),
1549
+ emailPasswordSubmit: z.boolean(),
1550
+ requestOsPermission: z.boolean()
1551
+ });
1552
+ z.object({
1553
+ lottie: z.boolean().optional(),
1554
+ oauthLogin: z.boolean().optional(),
1555
+ oauthProviderPreset: z.boolean().optional(),
1556
+ oauthProviderCustom: z.boolean().optional(),
1557
+ emailPasswordAuth: z.boolean().optional(),
1558
+ emailPasswordField: z.boolean().optional(),
1559
+ emailPasswordSubmit: z.boolean().optional(),
1560
+ requestOsPermission: z.boolean().optional()
1561
+ }).strict();
1562
+ var RevenueCatIntegrationSchema = z.object({
1563
+ enabled: z.boolean(),
1564
+ defaultOfferingId: z.string(),
1565
+ defaultPlacementId: z.string()
1566
+ });
1567
+ var AppsFlyerIntegrationSchema = z.object({
1568
+ enabled: z.boolean()
1569
+ });
1570
+ var ResolvedAppIntegrationsSchema = z.object({
1571
+ revenuecat: RevenueCatIntegrationSchema,
1572
+ appsflyer: AppsFlyerIntegrationSchema
1573
+ });
1574
+ var AppIntegrationsSchema = z.object({
1575
+ revenuecat: RevenueCatIntegrationSchema.partial().optional(),
1576
+ appsflyer: AppsFlyerIntegrationSchema.partial().optional()
1577
+ }).passthrough();
1578
+ var DASHBOARD_ATTRIBUTION_INTEGRATION_PROVIDER_IDS = ["appsflyer"];
1579
+ var DashboardAttributionIntegrationProviderIdSchema = z.enum(
1580
+ DASHBOARD_ATTRIBUTION_INTEGRATION_PROVIDER_IDS
1581
+ );
1582
+ z.object({
1583
+ provider: DashboardAttributionIntegrationProviderIdSchema
1584
+ });
1585
+ z.object({
1586
+ provider: z.string(),
1587
+ signalDetected: z.boolean(),
1588
+ /** `false` when ClickHouse was unavailable or the query failed — treat as inconclusive. */
1589
+ checked: z.boolean(),
1590
+ matchCount: z.number().int().nonnegative(),
1591
+ /** ISO-8601 from ClickHouse `max(timestamp)`, or null when there are no matches. */
1592
+ lastSeenAt: z.string().nullable()
1593
+ });
1594
+
1595
+ // src/dashboard/appBranding.ts
1596
+ var HEX = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;
1597
+ var BrandColorSchema = z.object({
1598
+ id: z.string().uuid(),
1599
+ name: z.string().min(1).max(50),
1600
+ /** Hex color, e.g. `#0F172A`. Alpha (8 chars) supported. */
1601
+ value: z.string().regex(HEX, "must be a hex color (#RRGGBB or #RRGGBBAA)")
1602
+ });
1603
+ var BrandGradientStopSchema = z.object({
1604
+ /** 0..1 position along the gradient. */
1605
+ offset: z.number().min(0).max(1),
1606
+ color: z.string().regex(HEX)
1607
+ });
1608
+ var BrandGradientSchema = z.object({
1609
+ id: z.string().uuid(),
1610
+ name: z.string().min(1).max(50),
1611
+ type: z.enum(["linear", "radial"]),
1612
+ /** Degrees, used when type === 'linear'. 0 = top → bottom (CSS convention). */
1613
+ angle: z.number().min(0).max(360).optional(),
1614
+ stops: z.array(BrandGradientStopSchema).min(2)
1615
+ });
1616
+ var FontStyleSchema = z.object({
1617
+ id: z.string().uuid(),
1618
+ /** Numeric CSS font-weight, e.g. 100..900. */
1619
+ weight: z.number().int().min(100).max(900),
1620
+ italic: z.boolean(),
1621
+ /** Optional human label (e.g. "Bold Italic"). */
1622
+ label: z.string().max(40).optional(),
1623
+ /** MediaAsset id of the uploaded font file. */
1624
+ mediaAssetId: z.string().uuid().optional(),
1625
+ /** Public URL of the uploaded font file (denormalized for SDK consumption). */
1626
+ url: z.string().url().optional(),
1627
+ /** Original filename — useful for display. */
1628
+ filename: z.string().max(200).optional()
1629
+ });
1630
+ var FontFamilySchema = z.object({
1631
+ id: z.string().uuid(),
1632
+ name: z.string().min(1).max(60),
1633
+ styles: z.array(FontStyleSchema)
1634
+ });
1635
+ var AppIconSchema = z.object({
1636
+ url: z.string().url(),
1637
+ source: z.enum(["app_store", "play_store", "upload"])
1638
+ });
1639
+ var BrandingSchema = z.object({
1640
+ /** Optional store / marketing icon for this app (shown in dashboard). */
1641
+ appIcon: AppIconSchema.optional(),
1642
+ colorPresets: z.array(BrandColorSchema),
1643
+ gradientPresets: z.array(BrandGradientSchema),
1644
+ fontFamilies: z.array(FontFamilySchema)
1645
+ });
1646
+ var EMPTY_BRANDING = {
1647
+ colorPresets: [],
1648
+ gradientPresets: [],
1649
+ fontFamilies: []
1650
+ };
1651
+ var StoreListingInputSchema = z.object({
1652
+ platform: z.enum(["ios", "android"]),
1653
+ applicationId: z.string().trim().min(1).max(200)
1654
+ });
1655
+ var StoreListingLookupResponseSchema = z.object({
1656
+ found: z.boolean(),
1657
+ platform: z.enum(["ios", "android"]),
1658
+ applicationId: z.string(),
1659
+ name: z.string().optional(),
1660
+ iconUrl: z.string().url().optional()
1661
+ });
1662
+ var AppSchema = z.object({
1663
+ id: z.string().uuid(),
1664
+ orgId: z.string().uuid(),
1665
+ name: z.string().min(1).max(100),
1666
+ branding: BrandingSchema.optional(),
1667
+ /** Resolved flags; all true when unset in storage. */
1668
+ canvasEditorGates: CanvasEditorGatesResolvedSchema,
1669
+ /** Resolved per-provider integration toggles + settings. */
1670
+ integrations: ResolvedAppIntegrationsSchema,
1671
+ archivedAt: z.string().datetime().nullable().optional(),
1672
+ createdAt: z.string().datetime()
1673
+ });
1674
+ var CreateAppRequestSchema = z.object({
1675
+ name: z.string().min(1).max(100),
1676
+ /** When set, the server resolves artwork from the store after the app row exists. */
1677
+ storeListing: StoreListingInputSchema.optional()
1678
+ });
1679
+ var UpdateAppRequestSchema = z.object({
1680
+ name: z.string().min(1).max(100).optional(),
1681
+ /** Full replace for the JSON column when set; omit to leave unchanged. */
1682
+ canvasEditorGates: CanvasEditorGatesResolvedSchema.optional(),
1683
+ /** Per-provider integration toggles + settings. Full replace semantics when set. */
1684
+ integrations: AppIntegrationsSchema.optional()
1685
+ });
1686
+ var UpdateAppBrandingRequestSchema = z.object({
1687
+ branding: BrandingSchema
1688
+ });
1689
+ var DeleteAppRequestSchema = z.object({
1690
+ /** User must type the app's exact name to confirm destructive deletion. */
1691
+ confirmName: z.string().min(1)
1692
+ });
1693
+ var DeleteAppResponseSchema = z.object({
1694
+ mode: z.enum(["hard", "soft"]),
1695
+ reason: z.enum(["has_events", "clickhouse_unavailable"]).optional()
1696
+ });
1697
+ var PublishableKeySchema = z.object({
1698
+ id: z.string().uuid(),
1699
+ environment: z.enum(ENVIRONMENTS),
1700
+ /**
1701
+ * Full publishable key. Always returned to dashboard users since publishable
1702
+ * keys are non-secret and meant to ship in mobile clients.
1703
+ */
1704
+ plaintext: z.string(),
1705
+ prefix: z.string(),
1706
+ lastFour: z.string(),
1707
+ revokedAt: z.string().datetime().nullable().optional(),
1708
+ createdAt: z.string().datetime()
1709
+ });
1710
+ var CreateAppResponseSchema = z.object({
1711
+ app: AppSchema,
1712
+ keys: z.array(PublishableKeySchema)
1713
+ });
1714
+ var DASHBOARD_MAX_TAGS = 20;
1715
+ var DASHBOARD_MAX_TAG_LEN = 64;
1716
+ var normalizeDashboardTags = (raw) => {
1717
+ const out = [];
1718
+ const seen = /* @__PURE__ */ new Set();
1719
+ for (const s of raw) {
1720
+ const t = s.trim().toLowerCase();
1721
+ if (t.length === 0 || t.length > DASHBOARD_MAX_TAG_LEN) continue;
1722
+ if (seen.has(t)) continue;
1723
+ seen.add(t);
1724
+ out.push(t);
1725
+ if (out.length >= DASHBOARD_MAX_TAGS) break;
1726
+ }
1727
+ return out;
1728
+ };
1729
+ var TagsSchema = z.array(z.string()).max(DASHBOARD_MAX_TAGS).superRefine((arr, ctx) => {
1730
+ arr.forEach((s, i) => {
1731
+ const t = s.trim().toLowerCase();
1732
+ if (t.length > DASHBOARD_MAX_TAG_LEN) {
1733
+ ctx.addIssue({
1734
+ code: z.ZodIssueCode.custom,
1735
+ message: `Tag exceeds ${DASHBOARD_MAX_TAG_LEN} characters`,
1736
+ path: [i]
1737
+ });
1738
+ }
1739
+ });
1740
+ }).transform((arr) => normalizeDashboardTags(arr));
1741
+ var TagsSchemaOptional = TagsSchema.optional();
1742
+
1743
+ // src/manifest/version.ts
1744
+ var MANIFEST_SCHEMA_VERSION = 7;
1745
+ var ThemeSchema = z.object({
1746
+ primary: z.string().optional(),
1747
+ primaryForeground: z.string().optional(),
1748
+ background: z.string().optional(),
1749
+ foreground: z.string().optional(),
1750
+ accent: z.string().optional(),
1751
+ borderRadius: z.number().optional(),
1752
+ fontFamily: z.string().optional()
1753
+ });
1754
+ var BuilderMetaSchema = z.object({
1755
+ layout: z.object({
1756
+ nodes: z.array(
1757
+ z.object({
1758
+ id: z.string(),
1759
+ kind: z.enum(["screen", "decision"]).optional(),
1760
+ x: z.number(),
1761
+ y: z.number()
1762
+ })
1763
+ ).optional(),
1764
+ canvas: z.object({
1765
+ zoom: z.number().optional(),
1766
+ x: z.number().optional(),
1767
+ y: z.number().optional()
1768
+ }).optional()
1769
+ }).optional()
1770
+ }).passthrough().optional();
1771
+ var ExternalSurfaceNodeIdSchema = z.string().min(1).max(64).regex(/^surf_[a-z0-9_]+$/i, "external surface node id must look like surf_<id>");
1772
+ var NORMALIZED_SURFACE_OUTCOMES = [
1773
+ "purchase_completed",
1774
+ "purchase_cancelled",
1775
+ "dismissed",
1776
+ "failed",
1777
+ "restore_completed"
1778
+ ];
1779
+ z.enum(NORMALIZED_SURFACE_OUTCOMES);
1780
+ z.enum(["unspecified", "revenuecat"]);
1781
+ var UnspecifiedExternalSurfaceConfigSchema = z.object({
1782
+ provider: z.literal("unspecified")
1783
+ });
1784
+ var RevenueCatSurfacePresentationSchema = z.enum(["paywall", "paywall_if_needed"]);
1785
+ var RevenueCatSurfaceConfigSchema = z.object({
1786
+ provider: z.literal("revenuecat"),
1787
+ offeringId: z.string().min(1).max(128).optional(),
1788
+ placementId: z.string().min(1).max(128).optional(),
1789
+ presentation: RevenueCatSurfacePresentationSchema.optional()
1790
+ });
1791
+ var ExternalSurfaceConfigSchema = z.discriminatedUnion("provider", [
1792
+ UnspecifiedExternalSurfaceConfigSchema,
1793
+ RevenueCatSurfaceConfigSchema
1794
+ ]);
1795
+ var ExternalSurfaceOutcomesMapSchema = z.object({
1796
+ purchase_completed: FlowJumpTargetSchema.optional(),
1797
+ purchase_cancelled: FlowJumpTargetSchema.optional(),
1798
+ dismissed: FlowJumpTargetSchema.optional(),
1799
+ failed: FlowJumpTargetSchema.optional(),
1800
+ restore_completed: FlowJumpTargetSchema.optional()
1801
+ }).strict();
1802
+ var ExternalSurfaceNodeSchema = z.object({
1803
+ id: ExternalSurfaceNodeIdSchema,
1804
+ name: z.string().min(1).max(80).optional(),
1805
+ config: ExternalSurfaceConfigSchema,
1806
+ /** Per-outcome jump targets. Outcomes not listed here fall through to `fallback`. */
1807
+ outcomes: ExternalSurfaceOutcomesMapSchema,
1808
+ /** Required: used for any outcome not in `outcomes` (e.g. provider quirks, unmapped events). */
1809
+ fallback: FlowJumpTargetSchema
1810
+ });
1811
+
1812
+ // src/manifest/flowManifestObjectBaseSchema.ts
1813
+ var FlowManifestObjectBaseSchema = z.object({
1814
+ flowId: z.string().uuid(),
1815
+ /** Manifest schema version — see {@link MANIFEST_SCHEMA_VERSION}. */
1816
+ schemaVersion: z.literal(MANIFEST_SCHEMA_VERSION).optional(),
1817
+ version: z.number().int().positive(),
1818
+ defaultLocale: LocaleCode,
1819
+ locales: z.array(LocaleCode),
1820
+ /** When null, the draft has no wired entry target (builder connects the canvas entry node). */
1821
+ entryScreenId: z.union([z.string().min(1), z.null()]),
1822
+ screens: z.array(ScreenSchema),
1823
+ decisionNodes: z.union([z.array(DecisionNodeSchema), z.undefined()]).transform((x) => x ?? []),
1824
+ externalSurfaceNodes: z.union([z.array(ExternalSurfaceNodeSchema), z.undefined()]).transform((x) => x ?? []),
1825
+ sdkAttributeKeys: z.union([z.array(z.string().min(1).max(128)), z.undefined()]).transform((x) => x ?? []),
1826
+ theme: ThemeSchema.optional(),
1827
+ builderMeta: BuilderMetaSchema
1828
+ });
1829
+
1830
+ // src/sdkAttributes.ts
1831
+ var RESERVED_RC_SDK_KEYS = [
1832
+ /** Last RC event observed by the SDK (e.g. `purchase_completed`, `purchase_cancelled`). */
1833
+ "onb_rc_last_event",
1834
+ /** Product identifier from the most recent successful purchase. */
1835
+ "onb_rc_last_product_id",
1836
+ /** Period type (`normal`, `intro`, `trial`) from the most recent purchase. */
1837
+ "onb_rc_last_period_type",
1838
+ /** RevenueCat offering id surfaced by the most recent paywall presentation. */
1839
+ "onb_rc_last_offering_id"
1840
+ ];
1841
+ var RESERVED_SDK_KEYS_SET = new Set(RESERVED_RC_SDK_KEYS);
1842
+ var isReservedSdkKey = (key) => RESERVED_SDK_KEYS_SET.has(key);
1843
+
1844
+ // src/manifest/refineManifestGraph.ts
1845
+ var buildManifestJumpTargets = (manifest) => {
1846
+ const screenIds = new Set(manifest.screens.map((s) => s.id));
1847
+ const decisionIds = new Set(manifest.decisionNodes.map((d) => d.id));
1848
+ const surfaceIds = new Set(manifest.externalSurfaceNodes.map((s) => s.id));
1849
+ return /* @__PURE__ */ new Set([
1850
+ ...screenIds,
1851
+ ...decisionIds,
1852
+ ...surfaceIds,
1853
+ EXTERNAL_SURFACE_NO_NEXT
1854
+ ]);
1855
+ };
1856
+ var refineManifestGraph = (manifest, ctx, jumpTargets) => {
1857
+ const screenIds = /* @__PURE__ */ new Set();
1858
+ for (const s of manifest.screens) {
1859
+ if (screenIds.has(s.id)) {
1860
+ ctx.addIssue({
1861
+ code: z.ZodIssueCode.custom,
1862
+ message: `duplicate screen id "${s.id}"`,
1863
+ path: ["screens"]
1864
+ });
1865
+ }
1866
+ screenIds.add(s.id);
1867
+ }
1868
+ const decisionIds = new Set(manifest.decisionNodes.map((d) => d.id));
1869
+ const surfaceIds = new Set(manifest.externalSurfaceNodes.map((s) => s.id));
1870
+ if (manifest.entryScreenId != null && !jumpTargets.has(manifest.entryScreenId)) {
1871
+ ctx.addIssue({
1872
+ code: z.ZodIssueCode.custom,
1873
+ message: `entryScreenId "${manifest.entryScreenId}" not found in screens, decisionNodes, or externalSurfaceNodes`,
1874
+ path: ["entryScreenId"]
1875
+ });
1876
+ }
1877
+ const seenDecisionId = /* @__PURE__ */ new Set();
1878
+ const sdkAllow = new Set(manifest.sdkAttributeKeys);
1879
+ manifest.decisionNodes.forEach((dn, di) => {
1880
+ if (seenDecisionId.has(dn.id)) {
1881
+ ctx.addIssue({
1882
+ code: z.ZodIssueCode.custom,
1883
+ message: `duplicate decision node id "${dn.id}"`,
1884
+ path: ["decisionNodes", di]
1885
+ });
1886
+ }
1887
+ seenDecisionId.add(dn.id);
1888
+ if (screenIds.has(dn.id)) {
1889
+ ctx.addIssue({
1890
+ code: z.ZodIssueCode.custom,
1891
+ message: `decision node id "${dn.id}" collides with a screen id`,
1892
+ path: ["decisionNodes", di]
1893
+ });
1894
+ }
1895
+ if (surfaceIds.has(dn.id)) {
1896
+ ctx.addIssue({
1897
+ code: z.ZodIssueCode.custom,
1898
+ message: `decision node id "${dn.id}" collides with an external surface id`,
1899
+ path: ["decisionNodes", di]
1900
+ });
1901
+ }
1902
+ dn.cases.forEach((c, ci) => {
1903
+ if (c.next != null && !jumpTargets.has(c.next)) {
1904
+ ctx.addIssue({
1905
+ code: z.ZodIssueCode.custom,
1906
+ message: `decision "${dn.id}" case "${c.id}" next "${c.next}" not found`,
1907
+ path: ["decisionNodes", di, "cases", ci, "next"]
1908
+ });
1909
+ }
1910
+ for (const sk of collectDecisionSdkKeys(c.expression)) {
1911
+ if (isReservedSdkKey(sk)) continue;
1912
+ if (!sdkAllow.has(sk)) {
1913
+ ctx.addIssue({
1914
+ code: z.ZodIssueCode.custom,
1915
+ message: `decision "${dn.id}" case "${c.id}" references sdk key "${sk}" not in sdkAttributeKeys`,
1916
+ path: ["decisionNodes", di, "cases", ci, "expression"]
1917
+ });
1918
+ }
1919
+ }
1920
+ });
1921
+ if (dn.elseNext != null && !jumpTargets.has(dn.elseNext)) {
1922
+ ctx.addIssue({
1923
+ code: z.ZodIssueCode.custom,
1924
+ message: `decision "${dn.id}" elseNext "${dn.elseNext}" not found`,
1925
+ path: ["decisionNodes", di, "elseNext"]
1926
+ });
1927
+ }
1928
+ });
1929
+ const seenSurfaceId = /* @__PURE__ */ new Set();
1930
+ manifest.externalSurfaceNodes.forEach((sn, si) => {
1931
+ if (seenSurfaceId.has(sn.id)) {
1932
+ ctx.addIssue({
1933
+ code: z.ZodIssueCode.custom,
1934
+ message: `duplicate external surface id "${sn.id}"`,
1935
+ path: ["externalSurfaceNodes", si]
1936
+ });
1937
+ }
1938
+ seenSurfaceId.add(sn.id);
1939
+ if (screenIds.has(sn.id)) {
1940
+ ctx.addIssue({
1941
+ code: z.ZodIssueCode.custom,
1942
+ message: `external surface id "${sn.id}" collides with a screen id`,
1943
+ path: ["externalSurfaceNodes", si]
1944
+ });
1945
+ }
1946
+ if (decisionIds.has(sn.id)) {
1947
+ ctx.addIssue({
1948
+ code: z.ZodIssueCode.custom,
1949
+ message: `external surface id "${sn.id}" collides with a decision node id`,
1950
+ path: ["externalSurfaceNodes", si]
1951
+ });
1952
+ }
1953
+ for (const [outcome, target] of Object.entries(sn.outcomes)) {
1954
+ if (target != null && !jumpTargets.has(target)) {
1955
+ ctx.addIssue({
1956
+ code: z.ZodIssueCode.custom,
1957
+ message: `external surface "${sn.id}" outcome "${outcome}" target "${target}" not found`,
1958
+ path: ["externalSurfaceNodes", si, "outcomes", outcome]
1959
+ });
1960
+ }
1961
+ }
1962
+ if (sn.fallback != null && !jumpTargets.has(sn.fallback)) {
1963
+ ctx.addIssue({
1964
+ code: z.ZodIssueCode.custom,
1965
+ message: `external surface "${sn.id}" fallback "${sn.fallback}" not found`,
1966
+ path: ["externalSurfaceNodes", si, "fallback"]
1967
+ });
1968
+ }
1969
+ });
1970
+ return { screenIds, decisionIds, surfaceIds };
1971
+ };
1972
+ var refineManifestScreens = (manifest, ctx, jumpTargets, screenIds, allFieldKeys) => {
1973
+ const layerIds = /* @__PURE__ */ new Set();
1974
+ manifest.screens.forEach((screen, screenIdx) => {
1975
+ let inputCount = 0;
1976
+ const layerIdsForScreen = /* @__PURE__ */ new Set();
1977
+ walkScreenLayers(screen, (l) => {
1978
+ layerIdsForScreen.add(l.id);
1979
+ });
1980
+ walkScreenLayers(screen, (l) => {
1981
+ if (layerIds.has(l.id)) {
1982
+ ctx.addIssue({
1983
+ code: z.ZodIssueCode.custom,
1984
+ message: `duplicate layer id "${l.id}"`,
1985
+ path: ["screens", screenIdx, "regions"]
1986
+ });
1987
+ }
1988
+ layerIds.add(l.id);
1989
+ if (isInputLayer(l)) {
1990
+ inputCount += 1;
1991
+ if (allFieldKeys.has(l.fieldKey)) {
1992
+ ctx.addIssue({
1993
+ code: z.ZodIssueCode.custom,
1994
+ message: `duplicate fieldKey "${l.fieldKey}" across screens or on the same screen`,
1995
+ path: ["screens", screenIdx]
1996
+ });
1997
+ }
1998
+ allFieldKeys.set(l.fieldKey, screen.id);
1999
+ }
2000
+ if (l.kind === "checkbox") {
2001
+ if (allFieldKeys.has(l.fieldKey)) {
2002
+ ctx.addIssue({
2003
+ code: z.ZodIssueCode.custom,
2004
+ message: `duplicate fieldKey "${l.fieldKey}" across screens or on the same screen`,
2005
+ path: ["screens", screenIdx]
2006
+ });
2007
+ }
2008
+ allFieldKeys.set(l.fieldKey, screen.id);
2009
+ }
2010
+ if (l.kind === "button" && l.action.kind === "request_os_permission") {
2011
+ const fk = permissionCaptureFieldKey(l.action.permissionKey);
2012
+ if (!allFieldKeys.has(fk)) allFieldKeys.set(fk, screen.id);
2013
+ }
2014
+ });
2015
+ if (inputCount > 1) {
2016
+ ctx.addIssue({
2017
+ code: z.ZodIssueCode.custom,
2018
+ message: `screen "${screen.id}" has ${inputCount} input layers (max 1 allowed)`,
2019
+ path: ["screens", screenIdx, "regions"]
2020
+ });
2021
+ }
2022
+ walkScreenLayersWithLayoutContext(screen, (l, layoutCtx) => {
2023
+ if (!layerHasAbsolutePositionAuthored(l)) return;
2024
+ if (layoutCtx.isRegionRoot) {
2025
+ ctx.addIssue({
2026
+ code: z.ZodIssueCode.custom,
2027
+ message: `layer "${l.id}" cannot use absolute positioning on a screen region root`,
2028
+ path: ["screens", screenIdx, "regions"]
2029
+ });
2030
+ }
2031
+ if (layoutCtx.insideChoiceOption) {
2032
+ ctx.addIssue({
2033
+ code: z.ZodIssueCode.custom,
2034
+ message: `layer "${l.id}" cannot use absolute positioning inside a choice option`,
2035
+ path: ["screens", screenIdx, "regions"]
2036
+ });
2037
+ }
2038
+ });
2039
+ walkScreenLayersWithLayoutContext(screen, (l, layoutCtx) => {
2040
+ if (l.kind === "oauth_provider" && layoutCtx.parentKind !== "oauth_login") {
2041
+ ctx.addIssue({
2042
+ code: z.ZodIssueCode.custom,
2043
+ message: `OAuth button "${l.id}" must be nested under an OAuth login layer`,
2044
+ path: ["screens", screenIdx, "regions"]
2045
+ });
2046
+ }
2047
+ if ((l.kind === "email_password_field" || l.kind === "email_password_submit") && layoutCtx.parentKind !== "email_password_auth") {
2048
+ ctx.addIssue({
2049
+ code: z.ZodIssueCode.custom,
2050
+ message: `Layer "${l.id}" (${l.kind}) must be nested under an Email / password login layer`,
2051
+ path: ["screens", screenIdx, "regions"]
2052
+ });
2053
+ }
2054
+ });
2055
+ const nextDefault = screen.next.default;
2056
+ if (nextDefault && !jumpTargets.has(nextDefault)) {
2057
+ ctx.addIssue({
2058
+ code: z.ZodIssueCode.custom,
2059
+ message: `screen "${screen.id}" next.default "${nextDefault}" not found`,
2060
+ path: ["screens", screenIdx, "next", "default"]
2061
+ });
2062
+ }
2063
+ walkScreenLayers(screen, (l) => {
2064
+ if (l.kind === "single_choice" || l.kind === "multiple_choice") {
2065
+ validateChoiceChildrenAndBindings(
2066
+ { children: l.children, optionBindings: l.optionBindings },
2067
+ ctx
2068
+ );
2069
+ const knownOptionIds = new Set(l.optionBindings.map((b) => b.optionId));
2070
+ for (const cond of l.branching.conditions) {
2071
+ if (!screenIds.has(cond.goTo)) {
2072
+ ctx.addIssue({
2073
+ code: z.ZodIssueCode.custom,
2074
+ message: `screen "${screen.id}" branch condition "${cond.choiceId}" -> "${cond.goTo}" not found`,
2075
+ path: ["screens", screenIdx]
2076
+ });
2077
+ }
2078
+ if (!knownOptionIds.has(cond.choiceId)) {
2079
+ ctx.addIssue({
2080
+ code: z.ZodIssueCode.custom,
2081
+ message: `screen "${screen.id}" branch condition references unknown choice "${cond.choiceId}"`,
2082
+ path: ["screens", screenIdx]
2083
+ });
2084
+ }
2085
+ }
2086
+ }
2087
+ if (l.kind === "button" && l.action.kind === "go_to_step") {
2088
+ if (!screenIds.has(l.action.screenId)) {
2089
+ ctx.addIssue({
2090
+ code: z.ZodIssueCode.custom,
2091
+ message: `screen "${screen.id}" button action go_to_step "${l.action.screenId}" not found`,
2092
+ path: ["screens", screenIdx]
2093
+ });
2094
+ }
2095
+ }
2096
+ if (l.kind === "button" && l.action.kind === "go_back_one_screen" && manifest.entryScreenId != null && screen.id === manifest.entryScreenId) {
2097
+ ctx.addIssue({
2098
+ code: z.ZodIssueCode.custom,
2099
+ message: `screen "${screen.id}" is the flow entry screen; buttons cannot use go_back_one_screen`,
2100
+ path: ["screens", screenIdx]
2101
+ });
2102
+ }
2103
+ if (l.kind === "button" && l.action.kind === "request_os_permission") {
2104
+ for (const [label, sid] of [
2105
+ ["granted", l.action.outcomes.granted],
2106
+ ["denied", l.action.outcomes.denied],
2107
+ ["blocked", l.action.outcomes.blocked]
2108
+ ]) {
2109
+ if (sid === OS_PERMISSION_OUTCOME_END) ; else if (sid === OS_PERMISSION_OUTCOME_CONTINUE) {
2110
+ const def = screen.next.default;
2111
+ if (def != null && !jumpTargets.has(def)) {
2112
+ ctx.addIssue({
2113
+ code: z.ZodIssueCode.custom,
2114
+ message: `screen "${screen.id}" request_os_permission outcomes.${label} uses default next (continue) but screen.next.default "${def}" is not a valid target`,
2115
+ path: ["screens", screenIdx]
2116
+ });
2117
+ }
2118
+ } else if (!jumpTargets.has(sid)) {
2119
+ ctx.addIssue({
2120
+ code: z.ZodIssueCode.custom,
2121
+ message: `screen "${screen.id}" request_os_permission outcomes.${label} "${sid}" not found`,
2122
+ path: ["screens", screenIdx]
2123
+ });
2124
+ }
2125
+ }
2126
+ }
2127
+ if (l.kind === "back_button" && l.fallbackScreenId && !screenIds.has(l.fallbackScreenId)) {
2128
+ ctx.addIssue({
2129
+ code: z.ZodIssueCode.custom,
2130
+ message: `screen "${screen.id}" back_button fallback "${l.fallbackScreenId}" not found`,
2131
+ path: ["screens", screenIdx]
2132
+ });
2133
+ }
2134
+ if (l.kind === "button" && l.action.kind === "go_back_one_screen" && l.action.fallbackScreenId && !screenIds.has(l.action.fallbackScreenId)) {
2135
+ ctx.addIssue({
2136
+ code: z.ZodIssueCode.custom,
2137
+ message: `screen "${screen.id}" button go_back_one_screen fallback "${l.action.fallbackScreenId}" not found`,
2138
+ path: ["screens", screenIdx]
2139
+ });
2140
+ }
2141
+ if (l.kind === "text_input") {
2142
+ const minL = l.minLength;
2143
+ const maxL = l.maxLength;
2144
+ if (minL !== void 0 && maxL !== void 0 && minL > maxL) {
2145
+ ctx.addIssue({
2146
+ code: z.ZodIssueCode.custom,
2147
+ message: `text_input "${l.id}" minLength cannot exceed maxLength`,
2148
+ path: ["screens", screenIdx]
2149
+ });
2150
+ }
2151
+ }
2152
+ if (l.kind === "scale_input") {
2153
+ if (l.min >= l.max) {
2154
+ ctx.addIssue({
2155
+ code: z.ZodIssueCode.custom,
2156
+ message: `scale_input "${l.id}" max must be greater than min`,
2157
+ path: ["screens", screenIdx]
2158
+ });
2159
+ }
2160
+ const step = l.step ?? 1;
2161
+ if (l.defaultValue !== void 0) {
2162
+ if (l.defaultValue < l.min || l.defaultValue > l.max) {
2163
+ ctx.addIssue({
2164
+ code: z.ZodIssueCode.custom,
2165
+ message: `scale_input "${l.id}" defaultValue must be between min and max`,
2166
+ path: ["screens", screenIdx]
2167
+ });
2168
+ } else {
2169
+ const rem = (l.defaultValue - l.min) / step;
2170
+ if (Math.abs(rem - Math.round(rem)) > 1e-6) {
2171
+ ctx.addIssue({
2172
+ code: z.ZodIssueCode.custom,
2173
+ message: `scale_input "${l.id}" defaultValue must align with min and step`,
2174
+ path: ["screens", screenIdx]
2175
+ });
2176
+ }
2177
+ }
2178
+ }
2179
+ }
2180
+ });
2181
+ if (screen.animations) {
2182
+ const clipIds = /* @__PURE__ */ new Set();
2183
+ for (const clip of screen.animations) {
2184
+ if (clipIds.has(clip.id)) {
2185
+ ctx.addIssue({
2186
+ code: z.ZodIssueCode.custom,
2187
+ message: `screen "${screen.id}" has duplicate clip id "${clip.id}"`,
2188
+ path: ["screens", screenIdx, "animations"]
2189
+ });
2190
+ }
2191
+ clipIds.add(clip.id);
2192
+ if (!layerIdsForScreen.has(clip.targetLayerId)) {
2193
+ ctx.addIssue({
2194
+ code: z.ZodIssueCode.custom,
2195
+ message: `clip "${clip.id}" targets layer "${clip.targetLayerId}" not on screen "${screen.id}"`,
2196
+ path: ["screens", screenIdx, "animations"]
2197
+ });
2198
+ }
2199
+ }
2200
+ }
2201
+ });
2202
+ };
2203
+
2204
+ // src/manifest/refineFlowManifest.ts
2205
+ var refineFlowManifest = (manifest, ctx) => {
2206
+ const jumpTargets = buildManifestJumpTargets(manifest);
2207
+ const { screenIds } = refineManifestGraph(manifest, ctx, jumpTargets);
2208
+ const allFieldKeys = /* @__PURE__ */ new Map();
2209
+ refineManifestScreens(manifest, ctx, jumpTargets, screenIds, allFieldKeys);
2210
+ manifest.decisionNodes.forEach((dn, di) => {
2211
+ for (const fk of collectDecisionFieldKeysFromNode(dn)) {
2212
+ if (!allFieldKeys.has(fk)) {
2213
+ ctx.addIssue({
2214
+ code: z.ZodIssueCode.custom,
2215
+ message: `decision "${dn.id}" references unknown fieldKey "${fk}"`,
2216
+ path: ["decisionNodes", di, "cases"]
2217
+ });
2218
+ }
2219
+ }
2220
+ });
2221
+ if (manifest.locales.length > 0 && !manifest.locales.includes(manifest.defaultLocale)) {
2222
+ ctx.addIssue({
2223
+ code: z.ZodIssueCode.custom,
2224
+ message: `defaultLocale "${manifest.defaultLocale}" must be in locales`,
2225
+ path: ["defaultLocale"]
2226
+ });
2227
+ }
2228
+ };
2229
+
2230
+ // src/manifest/flowManifestSchema.ts
2231
+ var FlowManifestObjectSchema = FlowManifestObjectBaseSchema.superRefine(refineFlowManifest);
2232
+ var FlowManifestSchema = FlowManifestObjectSchema;
2233
+ var FLOW_TEMPLATE_IDS = [
2234
+ "stories",
2235
+ "language_learning",
2236
+ "fitness",
2237
+ "win_back",
2238
+ "feedback",
2239
+ "word_learning",
2240
+ "journal_onboarding"
2241
+ ];
2242
+ var FlowTemplateIdSchema = z.enum(FLOW_TEMPLATE_IDS);
2243
+
2244
+ // src/dashboard/flows.ts
2245
+ var FlowStatusSchema = z.enum(["draft", "published_test", "published_live"]);
2246
+ var FlowPreviewSchema = z.object({
2247
+ nodes: z.array(
2248
+ z.object({
2249
+ id: z.string(),
2250
+ x: z.number(),
2251
+ y: z.number(),
2252
+ isEntry: z.boolean().optional()
2253
+ })
2254
+ ),
2255
+ edges: z.array(
2256
+ z.object({
2257
+ source: z.string(),
2258
+ target: z.string(),
2259
+ branching: z.boolean().optional()
2260
+ })
2261
+ )
2262
+ });
2263
+ var FlowSummarySchema = z.object({
2264
+ id: z.string().uuid(),
2265
+ appId: z.string().uuid(),
2266
+ name: z.string().min(1),
2267
+ status: FlowStatusSchema,
2268
+ archivedAt: z.string().datetime().nullable().optional(),
2269
+ updatedAt: z.string().datetime(),
2270
+ createdAt: z.string().datetime(),
2271
+ /** Dashboard user who created the flow (null for legacy rows). */
2272
+ createdByUserId: z.string().uuid().nullable().optional(),
2273
+ /** Number of published immutable versions (each publish appends one). */
2274
+ versionCount: z.number().int().nonnegative(),
2275
+ screenCount: z.number().int().nonnegative().optional(),
2276
+ preview: FlowPreviewSchema.optional(),
2277
+ tags: z.array(z.string())
2278
+ });
2279
+ var CREATE_FLOW_AI_PROMPT_MAX = 8e3;
2280
+ var AiFlowPromptSchema = z.string().trim().min(1).max(CREATE_FLOW_AI_PROMPT_MAX);
2281
+ var CreateFlowRequestSchema = z.object({
2282
+ name: z.string().min(1).max(100),
2283
+ tags: TagsSchemaOptional,
2284
+ /** When set, seeds the draft with a multi-screen onboarding manifest. Omit for a blank flow. */
2285
+ flowTemplateId: FlowTemplateIdSchema.optional(),
2286
+ /** When set, starts multi-step AI expansion after seeding a blank manifest. Mutually exclusive with `flowTemplateId`. */
2287
+ aiPrompt: AiFlowPromptSchema.optional(),
2288
+ /** Imported manifest JSON from the rheo skill flow-import workflow. Mutually exclusive with template and AI generation. */
2289
+ importManifest: z.unknown().optional()
2290
+ }).superRefine((data, ctx) => {
2291
+ const selected = [data.flowTemplateId, data.aiPrompt, data.importManifest].filter(
2292
+ (v) => v !== void 0
2293
+ );
2294
+ if (selected.length > 1) {
2295
+ ctx.addIssue({
2296
+ code: z.ZodIssueCode.custom,
2297
+ message: "Pick only one start mode: catalog template, Generate with AI, or Import manifest.",
2298
+ path: ["importManifest"]
2299
+ });
2300
+ }
2301
+ });
2302
+ var FlowAiGenerationRunStatusSchema = z.enum([
2303
+ "queued",
2304
+ "running",
2305
+ "completed",
2306
+ "failed"
2307
+ ]);
2308
+ var FlowAiGenerationRunStatusResponseSchema = z.object({
2309
+ id: z.string().uuid(),
2310
+ flowId: z.string().uuid(),
2311
+ status: FlowAiGenerationRunStatusSchema,
2312
+ stepIndex: z.number().int().nonnegative(),
2313
+ lastError: z.string().nullable().optional()
2314
+ });
2315
+ var StartAiFlowGenerationRequestSchema = z.object({
2316
+ aiPrompt: AiFlowPromptSchema
2317
+ });
2318
+ var RHEO_AGENT_IMAGE_MIME_TYPES = ["image/png", "image/jpeg", "image/webp"];
2319
+ var RHEO_AGENT_MAX_IMAGE_ATTACHMENTS = 4;
2320
+ var estimateBase64DecodedBytes = (dataBase64) => {
2321
+ const len = dataBase64.length;
2322
+ const padding = dataBase64.endsWith("==") ? 2 : dataBase64.endsWith("=") ? 1 : 0;
2323
+ return Math.max(0, Math.floor(len * 3 / 4) - padding);
2324
+ };
2325
+ var RheoAgentImageAttachmentSchema = z.object({
2326
+ mimeType: z.enum(RHEO_AGENT_IMAGE_MIME_TYPES),
2327
+ dataBase64: z.string().min(1)
2328
+ }).superRefine((attachment, ctx) => {
2329
+ const bytes = estimateBase64DecodedBytes(attachment.dataBase64);
2330
+ if (bytes > MAX_IMAGE_BYTES) {
2331
+ ctx.addIssue({
2332
+ code: z.ZodIssueCode.custom,
2333
+ message: "Image exceeds 5 MB limit"
2334
+ });
2335
+ }
2336
+ });
2337
+ var RheoAgentMessageSchema = z.object({
2338
+ role: z.enum(["user", "assistant"]),
2339
+ content: z.string(),
2340
+ attachments: z.array(RheoAgentImageAttachmentSchema).max(RHEO_AGENT_MAX_IMAGE_ATTACHMENTS).optional()
2341
+ }).superRefine((message, ctx) => {
2342
+ if (message.role === "assistant" && message.attachments?.length) {
2343
+ ctx.addIssue({
2344
+ code: z.ZodIssueCode.custom,
2345
+ message: "Assistant messages cannot include attachments"
2346
+ });
2347
+ }
2348
+ if (message.role === "user" && !message.content.trim() && !(message.attachments && message.attachments.length > 0)) {
2349
+ ctx.addIssue({
2350
+ code: z.ZodIssueCode.custom,
2351
+ message: "User message must include text or at least one image"
2352
+ });
2353
+ }
2354
+ });
2355
+ var RheoAgentSelectionSchema = z.object({
2356
+ screenId: z.string().optional(),
2357
+ screenIds: z.array(z.string()).min(1).optional(),
2358
+ layerId: z.string().optional(),
2359
+ decisionId: z.string().optional(),
2360
+ decisionIds: z.array(z.string()).min(1).optional(),
2361
+ externalSurfaceId: z.string().optional()
2362
+ }).optional();
2363
+ var RheoAgentChatRequestSchema = z.object({
2364
+ messages: z.array(RheoAgentMessageSchema).min(1),
2365
+ selection: RheoAgentSelectionSchema
2366
+ });
2367
+ var RheoAgentTextDeltaEventSchema = z.object({
2368
+ type: z.literal("text-delta"),
2369
+ delta: z.string()
2370
+ });
2371
+ var RheoAgentApplyingManifestEventSchema = z.object({
2372
+ type: z.literal("applying-manifest")
2373
+ });
2374
+ var RheoAgentManifestEventSchema = z.object({
2375
+ type: z.literal("manifest"),
2376
+ manifest: FlowManifestSchema
2377
+ });
2378
+ var RheoAgentErrorEventSchema = z.object({
2379
+ type: z.literal("error"),
2380
+ message: z.string()
2381
+ });
2382
+ var RheoAgentDoneEventSchema = z.object({
2383
+ type: z.literal("done"),
2384
+ ok: z.boolean()
2385
+ });
2386
+ var RheoAgentAttemptEventSchema = z.object({
2387
+ type: z.literal("attempt"),
2388
+ /** 1-based attempt index shown in the builder debug UI. */
2389
+ attempt: z.number().int().min(1),
2390
+ maxAttempts: z.number().int().min(1),
2391
+ phase: z.enum(["stream", "repair"])
2392
+ });
2393
+ var RheoAgentStreamEventSchema = z.discriminatedUnion("type", [
2394
+ RheoAgentTextDeltaEventSchema,
2395
+ RheoAgentApplyingManifestEventSchema,
2396
+ RheoAgentManifestEventSchema,
2397
+ RheoAgentErrorEventSchema,
2398
+ RheoAgentDoneEventSchema,
2399
+ RheoAgentAttemptEventSchema
2400
+ ]);
2401
+ var CreateFlowResponseSchema = z.object({
2402
+ flow: FlowSummarySchema,
2403
+ /** Present when `CreateFlowRequest` included `aiPrompt`. */
2404
+ generationRunId: z.string().uuid().optional()
2405
+ });
2406
+ var UpdateFlowRequestSchema = z.object({
2407
+ name: z.string().min(1).max(100).optional(),
2408
+ tags: TagsSchema.optional()
2409
+ }).refine((o) => o.name !== void 0 || o.tags !== void 0, {
2410
+ message: "Provide at least one of name or tags"
2411
+ });
2412
+ var DuplicateFlowRequestSchema = z.object({
2413
+ name: z.string().min(1).max(100).optional(),
2414
+ targetAppId: z.string().uuid().optional()
2415
+ });
2416
+ var FlowDraftSchema = z.object({
2417
+ flowId: z.string().uuid(),
2418
+ name: z.string().min(1),
2419
+ tags: z.array(z.string()),
2420
+ manifest: FlowManifestSchema,
2421
+ autosaveVersion: z.number().int().nonnegative(),
2422
+ updatedAt: z.string().datetime()
2423
+ });
2424
+ var AutosaveDraftRequestSchema = z.object({
2425
+ manifest: FlowManifestSchema,
2426
+ autosaveVersion: z.number().int().nonnegative()
2427
+ });
2428
+ var AutosaveDraftResponseSchema = z.object({
2429
+ flowId: z.string().uuid(),
2430
+ autosaveVersion: z.number().int().nonnegative(),
2431
+ updatedAt: z.string().datetime()
2432
+ });
2433
+ var PublishRequestSchema = z.object({
2434
+ label: z.string().trim().max(120).optional()
2435
+ });
2436
+ var PublishValidationErrorSchema = z.object({
2437
+ stepId: z.string().nullable().optional(),
2438
+ path: z.array(z.union([z.string(), z.number()])).optional(),
2439
+ message: z.string(),
2440
+ code: z.string()
2441
+ });
2442
+ var FlowVersionSchema = z.object({
2443
+ id: z.string().uuid(),
2444
+ flowId: z.string().uuid(),
2445
+ versionNumber: z.number().int().positive(),
2446
+ label: z.string().nullable().optional(),
2447
+ createdAt: z.string().datetime(),
2448
+ publishedByUserId: z.string().uuid().nullable().optional()
2449
+ });
2450
+ var FlowVersionWithManifestSchema = FlowVersionSchema.extend({
2451
+ manifest: FlowManifestSchema
2452
+ });
2453
+ var PublishResponseSchema = z.object({
2454
+ version: FlowVersionSchema
2455
+ });
2456
+ var ListVersionsResponseSchema = z.object({
2457
+ items: z.array(FlowVersionSchema)
2458
+ });
2459
+ var ChannelAssignmentKindSchema = z.enum(["direct", "experiment"]);
2460
+ var ChannelDirectAssignmentSchema = z.object({
2461
+ kind: z.literal("direct"),
2462
+ flowId: z.string().uuid(),
2463
+ versionId: z.string().uuid()
2464
+ });
2465
+ var ChannelExperimentAssignmentSchema = z.object({
2466
+ kind: z.literal("experiment"),
2467
+ experimentId: z.string().uuid()
2468
+ });
2469
+ var ChannelAssignmentRequestSchema = z.discriminatedUnion("kind", [
2470
+ ChannelDirectAssignmentSchema,
2471
+ ChannelExperimentAssignmentSchema
2472
+ ]);
2473
+ var ChannelSchema = z.object({
2474
+ id: z.string().uuid(),
2475
+ publicId: z.string(),
2476
+ appId: z.string().uuid(),
2477
+ environment: z.enum(ENVIRONMENTS),
2478
+ name: z.string(),
2479
+ archivedAt: z.string().datetime().nullable(),
2480
+ createdAt: z.string().datetime(),
2481
+ assignmentKind: ChannelAssignmentKindSchema.nullable(),
2482
+ assignmentVersion: z.number().int().nonnegative(),
2483
+ assignmentUpdatedAt: z.string().datetime().nullable(),
2484
+ pinned: z.object({
2485
+ flowId: z.string().uuid(),
2486
+ flowName: z.string(),
2487
+ versionId: z.string().uuid(),
2488
+ versionNumber: z.number().int().positive(),
2489
+ versionLabel: z.string().nullable().optional()
2490
+ }).nullable(),
2491
+ experimentId: z.string().uuid().nullable()
2492
+ });
2493
+ var ListChannelsResponseSchema = z.object({
2494
+ items: z.array(ChannelSchema)
2495
+ });
2496
+ var CreateChannelRequestSchema = z.object({
2497
+ name: z.string().min(1).max(64),
2498
+ environment: z.enum(ENVIRONMENTS)
2499
+ });
2500
+ var RenameChannelRequestSchema = z.object({
2501
+ name: z.string().min(1).max(64)
2502
+ });
2503
+ var ArchiveChannelRequestSchema = z.object({
2504
+ confirmName: z.string().min(1)
2505
+ });
2506
+ var UnarchiveChannelResponseSchema = z.object({
2507
+ channel: ChannelSchema,
2508
+ restored: z.boolean(),
2509
+ restoreWarning: z.string().nullable()
2510
+ });
2511
+ var ChannelEventTypeSchema = z.enum([
2512
+ "channel_created",
2513
+ "channel_renamed",
2514
+ "channel_archived",
2515
+ "channel_unarchived",
2516
+ "direct_pinned",
2517
+ "experiment_assigned",
2518
+ "assignment_cleared",
2519
+ "experiment_stopped_repinned",
2520
+ "experiment_winner_promoted",
2521
+ "rollout_requested",
2522
+ "rollout_rejected",
2523
+ "rollout_cancelled"
2524
+ ]);
2525
+ var ChannelHistoryFlowVersionSnapshotSchema = z.object({
2526
+ flowId: z.string().uuid(),
2527
+ flowName: z.string(),
2528
+ versionId: z.string().uuid(),
2529
+ versionNumber: z.number().int().positive(),
2530
+ versionLabel: z.string().nullable().optional()
2531
+ });
2532
+ var ChannelHistoryExperimentSnapshotSchema = z.object({
2533
+ experimentId: z.string().uuid(),
2534
+ experimentName: z.string(),
2535
+ variantCount: z.number().int().nonnegative().optional()
2536
+ });
2537
+ var ChannelHistoryPreviousAssignmentSchema = z.object({
2538
+ kind: z.enum(["direct", "experiment"]).nullable(),
2539
+ pinned: ChannelHistoryFlowVersionSnapshotSchema.nullable().optional(),
2540
+ experiment: ChannelHistoryExperimentSnapshotSchema.nullable().optional()
2541
+ });
2542
+ var ChannelCreatedPayloadSchema = z.object({
2543
+ type: z.literal("channel_created"),
2544
+ environment: z.enum(ENVIRONMENTS),
2545
+ name: z.string()
2546
+ });
2547
+ var ChannelRenamedPayloadSchema = z.object({
2548
+ type: z.literal("channel_renamed"),
2549
+ previousName: z.string(),
2550
+ newName: z.string()
2551
+ });
2552
+ var ChannelArchivedPayloadSchema = z.object({
2553
+ type: z.literal("channel_archived"),
2554
+ name: z.string()
2555
+ });
2556
+ var ChannelUnarchivedPayloadSchema = z.object({
2557
+ type: z.literal("channel_unarchived"),
2558
+ assignmentRestored: z.boolean(),
2559
+ restoreWarning: z.string().nullable(),
2560
+ assignmentCleared: z.boolean().optional()
2561
+ });
2562
+ var DirectPinnedPayloadSchema = z.object({
2563
+ type: z.literal("direct_pinned"),
2564
+ flowId: z.string().uuid(),
2565
+ flowName: z.string(),
2566
+ versionId: z.string().uuid(),
2567
+ versionNumber: z.number().int().positive(),
2568
+ versionLabel: z.string().nullable().optional(),
2569
+ source: z.enum(["direct", "rollout"]),
2570
+ rolloutRequestId: z.string().uuid().optional(),
2571
+ previous: ChannelHistoryPreviousAssignmentSchema.optional()
2572
+ });
2573
+ var ExperimentAssignedPayloadSchema = z.object({
2574
+ type: z.literal("experiment_assigned"),
2575
+ experimentId: z.string().uuid(),
2576
+ experimentName: z.string(),
2577
+ variantCount: z.number().int().nonnegative(),
2578
+ previous: ChannelHistoryPreviousAssignmentSchema.optional()
2579
+ });
2580
+ var AssignmentClearedPayloadSchema = z.object({
2581
+ type: z.literal("assignment_cleared"),
2582
+ previous: ChannelHistoryPreviousAssignmentSchema,
2583
+ reason: z.enum(["manual", "unarchive_restore_failed"]).optional()
2584
+ });
2585
+ var ExperimentStoppedRepinnedPayloadSchema = z.object({
2586
+ type: z.literal("experiment_stopped_repinned"),
2587
+ experimentId: z.string().uuid(),
2588
+ experimentName: z.string(),
2589
+ pinned: ChannelHistoryFlowVersionSnapshotSchema
2590
+ });
2591
+ var ExperimentWinnerPromotedPayloadSchema = z.object({
2592
+ type: z.literal("experiment_winner_promoted"),
2593
+ experimentId: z.string().uuid(),
2594
+ experimentName: z.string(),
2595
+ pinned: ChannelHistoryFlowVersionSnapshotSchema,
2596
+ wasPendingDecision: z.boolean()
2597
+ });
2598
+ var RolloutFlowPayloadSchema = z.object({
2599
+ type: z.enum(["rollout_requested", "rollout_rejected", "rollout_cancelled"]),
2600
+ rolloutRequestId: z.string().uuid(),
2601
+ flow: ChannelHistoryFlowVersionSnapshotSchema
2602
+ });
2603
+ var ChannelEventPayloadSchema = z.discriminatedUnion("type", [
2604
+ ChannelCreatedPayloadSchema,
2605
+ ChannelRenamedPayloadSchema,
2606
+ ChannelArchivedPayloadSchema,
2607
+ ChannelUnarchivedPayloadSchema,
2608
+ DirectPinnedPayloadSchema,
2609
+ ExperimentAssignedPayloadSchema,
2610
+ AssignmentClearedPayloadSchema,
2611
+ ExperimentStoppedRepinnedPayloadSchema,
2612
+ ExperimentWinnerPromotedPayloadSchema,
2613
+ RolloutFlowPayloadSchema
2614
+ ]);
2615
+ var ChannelEventSchema = z.object({
2616
+ id: z.string().uuid(),
2617
+ type: ChannelEventTypeSchema,
2618
+ actorUserId: z.string().uuid().nullable(),
2619
+ actorLabel: z.string().nullable(),
2620
+ occurredAt: z.string().datetime(),
2621
+ payload: z.record(z.unknown())
2622
+ });
2623
+ var ListChannelHistoryResponseSchema = z.object({
2624
+ items: z.array(ChannelEventSchema),
2625
+ total: z.number().int().nonnegative()
2626
+ });
2627
+ var RolloutRequestStatusSchema = z.enum([
2628
+ "pending",
2629
+ "approved",
2630
+ "rejected",
2631
+ "cancelled"
2632
+ ]);
2633
+ var RolloutCommentKindSchema = z.enum(["comment", "system"]);
2634
+ var CreateRolloutRequestsBodySchema = z.object({
2635
+ appId: z.string().uuid(),
2636
+ versionId: z.string().uuid(),
2637
+ channelIds: z.array(z.string().uuid()).min(1),
2638
+ /** PR-style summary: what changed, why, risk notes (first activity comment). */
2639
+ description: z.string().trim().min(1).max(8e3)
2640
+ });
2641
+ var RolloutPolicyResponseSchema = z.object({
2642
+ enabled: z.boolean(),
2643
+ environments: z.array(z.enum(ENVIRONMENTS)),
2644
+ approverUserIds: z.array(z.string().uuid())
2645
+ });
2646
+ var PatchRolloutPolicySchema = z.object({
2647
+ enabled: z.boolean(),
2648
+ environments: z.array(z.enum(ENVIRONMENTS)),
2649
+ approverUserIds: z.array(z.string().uuid())
2650
+ });
2651
+ var RolloutCommentMentionUserSchema = z.object({
2652
+ userId: z.string().uuid(),
2653
+ label: z.string()
2654
+ });
2655
+ var RolloutRequestCommentSchema = z.object({
2656
+ id: z.string().uuid(),
2657
+ authorUserId: z.string().uuid(),
2658
+ body: z.string(),
2659
+ kind: RolloutCommentKindSchema,
2660
+ createdAt: z.string().datetime(),
2661
+ mentions: z.array(RolloutCommentMentionUserSchema)
2662
+ });
2663
+ var RolloutRequestSummarySchema = z.object({
2664
+ id: z.string().uuid(),
2665
+ orgId: z.string().uuid(),
2666
+ channelId: z.string().uuid(),
2667
+ channelName: z.string(),
2668
+ channelPublicId: z.string(),
2669
+ channelEnvironment: z.enum(ENVIRONMENTS),
2670
+ appId: z.string().uuid(),
2671
+ appName: z.string(),
2672
+ flowId: z.string().uuid(),
2673
+ flowName: z.string(),
2674
+ flowVersionId: z.string().uuid(),
2675
+ versionNumber: z.number().int().positive(),
2676
+ versionLabel: z.string().nullable().optional(),
2677
+ requestedByUserId: z.string().uuid(),
2678
+ requestedByEmail: z.string(),
2679
+ /** Display: full name, else username, else email. */
2680
+ requestedByLabel: z.string(),
2681
+ status: RolloutRequestStatusSchema,
2682
+ decidedByUserId: z.string().uuid().nullable().optional(),
2683
+ decidedAt: z.string().datetime().nullable().optional(),
2684
+ createdAt: z.string().datetime()
2685
+ });
2686
+ var RolloutRequestDetailSchema = RolloutRequestSummarySchema.extend({
2687
+ comments: z.array(RolloutRequestCommentSchema)
2688
+ });
2689
+ var CreateRolloutRequestsResponseSchema = z.object({
2690
+ items: z.array(
2691
+ z.object({
2692
+ id: z.string().uuid(),
2693
+ channelId: z.string().uuid()
2694
+ })
2695
+ )
2696
+ });
2697
+ var ListRolloutRequestsResponseSchema = z.object({
2698
+ items: z.array(RolloutRequestSummarySchema),
2699
+ total: z.number().int().nonnegative()
2700
+ });
2701
+ var RejectRolloutRequestSchema = z.object({
2702
+ message: z.string().trim().max(4e3).optional()
2703
+ });
2704
+ var ApproveRolloutRequestSchema = z.object({
2705
+ message: z.string().trim().max(4e3).optional()
2706
+ });
2707
+ var AddRolloutCommentSchema = z.object({
2708
+ body: z.string().trim().min(1).max(8e3),
2709
+ mentionedUserIds: z.array(z.string().uuid()).max(20).optional().default([])
2710
+ });
2711
+ var AddRolloutCommentResponseSchema = z.object({
2712
+ comment: RolloutRequestCommentSchema
2713
+ });
2714
+ z.object({
2715
+ positionX: z.number().finite(),
2716
+ positionY: z.number().finite(),
2717
+ body: z.string().trim().min(1).max(8e3)
2718
+ });
2719
+ var FlowCommentThreadSourceSchema = z.enum(["user", "template"]);
2720
+
2721
+ // src/dashboard/flowComments.ts
2722
+ var FlowCommentFilterSchema = z.enum(["active", "archived", "all"]);
2723
+ var CreateFlowCommentThreadRequestSchema = z.object({
2724
+ positionX: z.number().finite(),
2725
+ positionY: z.number().finite(),
2726
+ body: z.string().trim().min(1).max(8e3),
2727
+ mentionedUserIds: z.array(z.string().uuid()).max(20).optional().default([]),
2728
+ anchorScreenId: ScreenIdSchema.optional(),
2729
+ anchorLayerId: LayerIdSchema.optional(),
2730
+ anchorDecisionNodeId: DecisionNodeIdSchema.optional(),
2731
+ anchorExternalSurfaceNodeId: ExternalSurfaceNodeIdSchema.optional()
2732
+ }).refine((d) => !d.anchorLayerId || !!d.anchorScreenId, {
2733
+ message: "anchorLayerId requires anchorScreenId",
2734
+ path: ["anchorLayerId"]
2735
+ }).refine(
2736
+ (d) => {
2737
+ const n = (d.anchorScreenId ? 1 : 0) + (d.anchorDecisionNodeId ? 1 : 0) + (d.anchorExternalSurfaceNodeId ? 1 : 0);
2738
+ return n <= 1;
2739
+ },
2740
+ {
2741
+ message: "only one of anchorScreenId, anchorDecisionNodeId, or anchorExternalSurfaceNodeId",
2742
+ path: ["anchorScreenId"]
2743
+ }
2744
+ );
2745
+ var AddFlowCommentMessageRequestSchema = z.object({
2746
+ body: z.string().trim().min(1).max(8e3),
2747
+ parentMessageId: z.string().uuid().nullable().optional(),
2748
+ mentionedUserIds: z.array(z.string().uuid()).max(20).optional().default([])
2749
+ });
2750
+ var FlowCommentMessageSchema = z.object({
2751
+ id: z.string().uuid(),
2752
+ threadId: z.string().uuid(),
2753
+ authorUserId: z.string().uuid(),
2754
+ body: z.string(),
2755
+ parentMessageId: z.string().uuid().nullable(),
2756
+ createdAt: z.string().datetime(),
2757
+ mentions: z.array(RolloutCommentMentionUserSchema)
2758
+ });
2759
+ var FlowCommentThreadSummarySchema = z.object({
2760
+ id: z.string().uuid(),
2761
+ flowId: z.string().uuid(),
2762
+ positionX: z.number(),
2763
+ positionY: z.number(),
2764
+ anchorScreenId: z.string().nullable(),
2765
+ anchorLayerId: z.string().nullable(),
2766
+ anchorDecisionNodeId: z.string().nullable(),
2767
+ anchorExternalSurfaceNodeId: z.string().nullable(),
2768
+ archivedAt: z.string().datetime().nullable(),
2769
+ createdAt: z.string().datetime(),
2770
+ createdByUserId: z.string().uuid(),
2771
+ source: FlowCommentThreadSourceSchema.optional().default("user"),
2772
+ messageCount: z.number().int().nonnegative(),
2773
+ previewSnippet: z.string(),
2774
+ rootMessageAuthorLabel: z.string(),
2775
+ rootMessageCreatedAt: z.string().datetime(),
2776
+ rootMessageBody: z.string()
2777
+ });
2778
+ var ListFlowCommentThreadsResponseSchema = z.object({
2779
+ items: z.array(FlowCommentThreadSummarySchema)
2780
+ });
2781
+ var GetFlowCommentThreadResponseSchema = z.object({
2782
+ thread: FlowCommentThreadSummarySchema,
2783
+ messages: z.array(FlowCommentMessageSchema)
2784
+ });
2785
+ var CreateFlowCommentThreadResponseSchema = z.object({
2786
+ thread: FlowCommentThreadSummarySchema,
2787
+ message: FlowCommentMessageSchema
2788
+ });
2789
+ var AddFlowCommentMessageResponseSchema = z.object({
2790
+ message: FlowCommentMessageSchema
2791
+ });
2792
+ var ArchiveFlowCommentThreadResponseSchema = z.object({
2793
+ thread: FlowCommentThreadSummarySchema
2794
+ });
2795
+ var PublicationSchema = z.object({
2796
+ id: z.string().uuid(),
2797
+ flowId: z.string().uuid(),
2798
+ environment: z.enum(ENVIRONMENTS),
2799
+ revision: z.number().int().positive(),
2800
+ manifest: FlowManifestSchema,
2801
+ publishedAt: z.string().datetime(),
2802
+ supersededAt: z.string().datetime().nullable().optional()
2803
+ });
2804
+ var SignUploadRequestSchema = z.object({
2805
+ type: MediaTypeSchema,
2806
+ contentType: z.string(),
2807
+ sizeBytes: z.number().int().positive(),
2808
+ filename: z.string().min(1).max(200).optional()
2809
+ });
2810
+ var SignUploadResponseSchema = z.object({
2811
+ assetId: z.string().uuid(),
2812
+ uploadUrl: z.string().url(),
2813
+ objectKey: z.string(),
2814
+ publicUrl: z.string().url(),
2815
+ headers: z.record(z.string(), z.string()).optional()
2816
+ });
2817
+ var ConfirmUploadRequestSchema = z.object({
2818
+ assetId: z.string().uuid(),
2819
+ name: z.string().max(200).optional()
2820
+ });
2821
+ var ListMediaResponseSchema = z.object({
2822
+ items: z.array(MediaAssetSchema)
2823
+ });
2824
+ var MediaAssetUsageReferenceSchema = z.object({
2825
+ flowId: z.string().uuid(),
2826
+ flowName: z.string(),
2827
+ appId: z.string().uuid(),
2828
+ appName: z.string(),
2829
+ inDraft: z.boolean(),
2830
+ publishedVersionNumbers: z.array(z.number().int().positive())
2831
+ });
2832
+ var MediaAssetUsageResponseSchema = z.object({
2833
+ references: z.array(MediaAssetUsageReferenceSchema)
2834
+ });
2835
+ var DeleteMediaAssetResponseSchema = z.object({
2836
+ asset: MediaAssetSchema
2837
+ });
2838
+ var UpdateMediaAssetRequestSchema = z.object({
2839
+ nameStem: z.string().trim().min(1).max(200)
2840
+ });
2841
+ var UpdateMediaAssetResponseSchema = z.object({
2842
+ asset: MediaAssetSchema
2843
+ });
2844
+ var ExperimentStatusSchema = z.enum([
2845
+ "draft",
2846
+ "running",
2847
+ "pending_decision",
2848
+ "stopped"
2849
+ ]);
2850
+ var VariantSchema = z.object({
2851
+ id: z.string().uuid(),
2852
+ experimentId: z.string().uuid(),
2853
+ name: z.string().min(1),
2854
+ weight: z.number().int().positive(),
2855
+ flowId: z.string().uuid().nullable(),
2856
+ versionId: z.string().uuid().nullable(),
2857
+ /** Convenience read fields populated by list/get endpoints. */
2858
+ flowName: z.string().nullable().optional(),
2859
+ versionNumber: z.number().int().positive().nullable().optional(),
2860
+ versionLabel: z.string().nullable().optional()
2861
+ });
2862
+ var ExperimentEndedReasonSchema = z.enum([
2863
+ "manual",
2864
+ "scheduled_resolved"
2865
+ ]);
2866
+ var ExperimentSchema = z.object({
2867
+ id: z.string().uuid(),
2868
+ appId: z.string().uuid(),
2869
+ /** Internal channel uuid. */
2870
+ channelId: z.string().uuid(),
2871
+ /** Display name of the channel (denormalized for list views). */
2872
+ channelName: z.string(),
2873
+ /** Test/live env of the channel — kept for badges and analytics filters. */
2874
+ channelEnvironment: z.enum(ENVIRONMENTS),
2875
+ name: z.string(),
2876
+ status: ExperimentStatusSchema,
2877
+ variants: z.array(VariantSchema),
2878
+ startedAt: z.string().datetime().nullable().optional(),
2879
+ stoppedAt: z.string().datetime().nullable().optional(),
2880
+ endsAt: z.string().datetime().nullable().optional(),
2881
+ endedReason: ExperimentEndedReasonSchema.nullable().optional(),
2882
+ archivedAt: z.string().datetime().nullable().optional(),
2883
+ createdAt: z.string().datetime(),
2884
+ /** Dashboard user who created the experiment (null for legacy rows). */
2885
+ createdByUserId: z.string().uuid().nullable().optional(),
2886
+ /** Display: full name, else @username, else email; null when unknown. */
2887
+ createdByLabel: z.string().nullable().optional(),
2888
+ tags: z.array(z.string()),
2889
+ /** Power-analysis inputs; nulls → dashboard defaults for sample accumulation. */
2890
+ statsDesignBaselineCvr: z.number().nullable().optional(),
2891
+ statsDesignMdePp: z.number().nullable().optional(),
2892
+ statsDesignAlpha: z.number().nullable().optional(),
2893
+ statsDesignPower: z.number().nullable().optional()
2894
+ });
2895
+ var EXPERIMENT_STATS_DESIGN_DEFAULTS = {
2896
+ statsDesignBaselineCvr: 0.342,
2897
+ statsDesignMdePp: 3,
2898
+ statsDesignAlpha: 0.05,
2899
+ statsDesignPower: 0.8
2900
+ };
2901
+ var ExperimentStatsDesignInputSchema = z.object({
2902
+ statsDesignBaselineCvr: z.number().min(1e-6).max(0.999999),
2903
+ statsDesignMdePp: z.number().min(0.01).max(50),
2904
+ statsDesignAlpha: z.number().min(1e-3).max(0.5),
2905
+ statsDesignPower: z.number().min(0.5).max(0.999)
2906
+ });
2907
+ var CreateExperimentRequestSchema = z.object({
2908
+ channelId: z.string().uuid(),
2909
+ name: z.string().min(1),
2910
+ /** Required auto-stop. Hour granularity is enforced server-side. */
2911
+ endsAt: z.string().datetime(),
2912
+ tags: TagsSchemaOptional,
2913
+ statsDesignBaselineCvr: z.number().min(1e-6).max(0.999999).optional(),
2914
+ statsDesignMdePp: z.number().min(0.01).max(50).optional(),
2915
+ statsDesignAlpha: z.number().min(1e-3).max(0.5).optional(),
2916
+ statsDesignPower: z.number().min(0.5).max(0.999).optional()
2917
+ });
2918
+ var UpdateExperimentRequestSchema = z.object({
2919
+ name: z.string().min(1).optional(),
2920
+ channelId: z.string().uuid().optional(),
2921
+ endsAt: z.string().datetime().optional(),
2922
+ tags: TagsSchema.optional(),
2923
+ statsDesignBaselineCvr: z.number().min(1e-6).max(0.999999).optional(),
2924
+ statsDesignMdePp: z.number().min(0.01).max(50).optional(),
2925
+ statsDesignAlpha: z.number().min(1e-3).max(0.5).optional(),
2926
+ statsDesignPower: z.number().min(0.5).max(0.999).optional()
2927
+ });
2928
+ var ExtendExperimentRequestSchema = z.object({
2929
+ endsAt: z.string().datetime()
2930
+ });
2931
+ var StopExperimentRequestSchema = z.discriminatedUnion("kind", [
2932
+ z.object({ kind: z.literal("variant"), variantId: z.string().uuid() }),
2933
+ z.object({
2934
+ kind: z.literal("version"),
2935
+ flowId: z.string().uuid(),
2936
+ versionId: z.string().uuid()
2937
+ })
2938
+ ]);
2939
+ var CreateVariantRequestSchema = z.object({
2940
+ weight: z.number().int().positive(),
2941
+ flowId: z.string().uuid().optional(),
2942
+ versionId: z.string().uuid().optional()
2943
+ });
2944
+ var ReorderExperimentVariantsRequestSchema = z.object({
2945
+ variantIds: z.array(z.string().uuid()).min(1)
2946
+ });
2947
+ var UpdateExperimentStatusRequestSchema = z.object({
2948
+ status: ExperimentStatusSchema
2949
+ });
2950
+ var ListExperimentsResponseSchema = z.object({
2951
+ items: z.array(ExperimentSchema)
2952
+ });
2953
+ var ExperimentArmStatsSchema = z.object({
2954
+ variantId: z.string().uuid(),
2955
+ name: z.string(),
2956
+ weight: z.number().int().nonnegative(),
2957
+ trafficShare: z.number(),
2958
+ /** Distinct users with ≥1 `flow_started` in the window. */
2959
+ starts: z.number().int().nonnegative(),
2960
+ /** Distinct users with ≥1 `flow_completed` in the window. */
2961
+ completes: z.number().int().nonnegative(),
2962
+ /** Distinct users with ≥1 `flow_abandoned` in the window. */
2963
+ abandoningUsers: z.number().int().nonnegative(),
2964
+ /** abandoningUsers / starts when starts > 0, else 0. */
2965
+ abandonRate: z.number(),
2966
+ /** Raw event counts (sessions), for debugging / power users. */
2967
+ rawStarts: z.number().int().nonnegative(),
2968
+ rawCompletes: z.number().int().nonnegative(),
2969
+ /** Distinct-user completion rate (`completes / starts`). JSON field name is historical. */
2970
+ conversionRate: z.number(),
2971
+ /** Wilson 95% CI bounds. */
2972
+ ciLow: z.number(),
2973
+ ciHigh: z.number(),
2974
+ lift: z.number().nullable(),
2975
+ pValue: z.number().nullable(),
2976
+ significant: z.boolean().nullable(),
2977
+ /** (completion rate − control) in percentage points; null on control. */
2978
+ liftAbsolutePp: z.number().nullable(),
2979
+ /** 95% CI for absolute completion-rate difference (treatment − control). */
2980
+ liftDiffCiLow: z.number().nullable(),
2981
+ liftDiffCiHigh: z.number().nullable()
2982
+ });
2983
+ var ExperimentFunnelStepSchema = z.object({
2984
+ stepId: z.string(),
2985
+ stepName: z.string().nullable().optional(),
2986
+ views: z.number().int().nonnegative(),
2987
+ completes: z.number().int().nonnegative(),
2988
+ skips: z.number().int().nonnegative(),
2989
+ dropoffs: z.number().int().nonnegative()
2990
+ });
2991
+ var ExperimentAbandonStepRowSchema = z.object({
2992
+ variantId: z.string().uuid(),
2993
+ stepId: z.string(),
2994
+ stepName: z.string().nullable().optional(),
2995
+ users: z.number().int().nonnegative()
2996
+ });
2997
+ var ExperimentSrmSchema = z.object({
2998
+ chiSquareStatistic: z.number(),
2999
+ pValue: z.number().nullable(),
3000
+ /** True when p < 0.01 (observed split unlikely vs configured weights). */
3001
+ flagged: z.boolean()
3002
+ });
3003
+ var ExperimentVariantFunnelSchema = z.object({
3004
+ variantId: z.string().uuid(),
3005
+ steps: z.array(ExperimentFunnelStepSchema)
3006
+ });
3007
+ var ExperimentCohortRuleSchema = z.discriminatedUnion("dimension", [
3008
+ z.object({ dimension: z.literal("platform"), key: z.string().min(1) }),
3009
+ z.object({ dimension: z.literal("locale"), key: z.string().min(1) }),
3010
+ z.object({ dimension: z.literal("app_version"), key: z.string().min(1) }),
3011
+ z.object({ dimension: z.literal("experiment_variant"), key: z.string().min(1) }),
3012
+ z.object({
3013
+ dimension: z.literal("custom_property"),
3014
+ customKey: z.string().regex(/^[A-Za-z0-9._-]{1,64}$/),
3015
+ key: z.string().min(1)
3016
+ })
3017
+ ]);
3018
+ var ExperimentSampleAccumulationSchema = z.object({
3019
+ requiredPerArm: z.number(),
3020
+ /** ISO range used for accumulation starters (same analytics window as results; cohort filters apply). */
3021
+ accumulationRangeStart: z.string().datetime(),
3022
+ accumulationRangeEnd: z.string().datetime(),
3023
+ comparisons: z.number().int(),
3024
+ alphaPerComparison: z.number(),
3025
+ familyAlpha: z.number(),
3026
+ baselineCvr: z.number(),
3027
+ mdePp: z.number(),
3028
+ power: z.number(),
3029
+ /** Distinct starters in the accumulation window (matches Results table when cohorts match). */
3030
+ arms: z.array(
3031
+ z.object({
3032
+ variantId: z.string().uuid(),
3033
+ name: z.string(),
3034
+ observedStarters: z.number().int(),
3035
+ pctOfRequired: z.number()
3036
+ })
3037
+ ),
3038
+ allArmsAboveThreshold: z.boolean()
3039
+ });
3040
+ var ExperimentResultsOverviewSchema = z.object({
3041
+ winningVariant: z.object({ variantId: z.string().uuid(), name: z.string() }).nullable(),
3042
+ /** Sum of distinct starters per arm in the selected stats window. */
3043
+ totalSessions: z.number().int().nonnegative(),
3044
+ experimentTimelineLabel: z.string().nullable(),
3045
+ bestLift: z.object({
3046
+ variantId: z.string().uuid(),
3047
+ name: z.string(),
3048
+ absolutePp: z.number(),
3049
+ relativePct: z.number()
3050
+ }).nullable(),
3051
+ assignmentBalance: z.object({
3052
+ pass: z.boolean(),
3053
+ pValue: z.number().nullable(),
3054
+ chiSquareStatistic: z.number(),
3055
+ threshold: z.number()
3056
+ }),
3057
+ significanceEta: z.object({
3058
+ daysElapsedInclusive: z.number().int().nullable(),
3059
+ daysPlannedInclusive: z.number().int().nullable(),
3060
+ projectedTotalDays: z.number().nullable(),
3061
+ /** Positive = fewer days than planned window to reach projected end. */
3062
+ aheadOfPlanDays: z.number().nullable()
3063
+ }).nullable()
3064
+ });
3065
+ var ExperimentStatsResponseSchema = z.object({
3066
+ rangeStart: z.string().datetime(),
3067
+ rangeEnd: z.string().datetime(),
3068
+ /** Active composite cohort (AND). Null when unsegmented. */
3069
+ cohort: z.array(ExperimentCohortRuleSchema).nullable(),
3070
+ srm: ExperimentSrmSchema,
3071
+ resultsOverview: ExperimentResultsOverviewSchema,
3072
+ arms: z.array(ExperimentArmStatsSchema),
3073
+ abandonByStep: z.array(ExperimentAbandonStepRowSchema),
3074
+ funnel: z.array(ExperimentVariantFunnelSchema),
3075
+ sampleAccumulation: ExperimentSampleAccumulationSchema.optional()
3076
+ });
3077
+ var ExperimentCvrTimeseriesResponseSchema = z.object({
3078
+ keys: z.array(z.string()),
3079
+ points: z.array(
3080
+ z.object({
3081
+ date: z.string(),
3082
+ conversionRates: z.array(z.union([z.number(), z.null()]))
3083
+ })
3084
+ )
3085
+ });
3086
+ var ExperimentEndedPayloadSchema = z.object({
3087
+ appId: z.string().uuid(),
3088
+ experimentId: z.string().uuid(),
3089
+ experimentName: z.string(),
3090
+ channelId: z.string().uuid(),
3091
+ channelName: z.string(),
3092
+ channelEnvironment: z.enum(ENVIRONMENTS)
3093
+ });
3094
+ var NotificationKindSchema = z.enum([
3095
+ "experiment_ended_pick_winner",
3096
+ "rollout_comment_mention",
3097
+ "flow_comment_new",
3098
+ "flow_comment_mention",
3099
+ "flow_comment_reply"
3100
+ ]);
3101
+ var RolloutCommentMentionPayloadSchema = z.object({
3102
+ appId: z.string().uuid(),
3103
+ channelId: z.string().uuid(),
3104
+ requestId: z.string().uuid(),
3105
+ commentId: z.string().uuid(),
3106
+ authorUserId: z.string().uuid(),
3107
+ authorLabel: z.string(),
3108
+ channelName: z.string(),
3109
+ flowName: z.string(),
3110
+ snippet: z.string()
3111
+ });
3112
+ var FlowCommentNotificationBasePayloadSchema = z.object({
3113
+ appId: z.string().uuid(),
3114
+ flowId: z.string().uuid(),
3115
+ flowName: z.string(),
3116
+ threadId: z.string().uuid(),
3117
+ messageId: z.string().uuid(),
3118
+ authorUserId: z.string().uuid(),
3119
+ authorLabel: z.string(),
3120
+ snippet: z.string()
3121
+ });
3122
+ var FlowCommentNewPayloadSchema = FlowCommentNotificationBasePayloadSchema;
3123
+ var FlowCommentMentionPayloadSchema = FlowCommentNotificationBasePayloadSchema;
3124
+ var FlowCommentReplyPayloadSchema = FlowCommentNotificationBasePayloadSchema.extend({
3125
+ parentMessageId: z.string().uuid()
3126
+ });
3127
+ var NotificationBaseSchema = z.object({
3128
+ id: z.string().uuid(),
3129
+ readAt: z.string().datetime().nullable(),
3130
+ createdAt: z.string().datetime()
3131
+ });
3132
+ var NotificationSchema = z.discriminatedUnion("kind", [
3133
+ NotificationBaseSchema.extend({
3134
+ kind: z.literal("experiment_ended_pick_winner"),
3135
+ payload: ExperimentEndedPayloadSchema
3136
+ }),
3137
+ NotificationBaseSchema.extend({
3138
+ kind: z.literal("rollout_comment_mention"),
3139
+ payload: RolloutCommentMentionPayloadSchema
3140
+ }),
3141
+ NotificationBaseSchema.extend({
3142
+ kind: z.literal("flow_comment_new"),
3143
+ payload: FlowCommentNewPayloadSchema
3144
+ }),
3145
+ NotificationBaseSchema.extend({
3146
+ kind: z.literal("flow_comment_mention"),
3147
+ payload: FlowCommentMentionPayloadSchema
3148
+ }),
3149
+ NotificationBaseSchema.extend({
3150
+ kind: z.literal("flow_comment_reply"),
3151
+ payload: FlowCommentReplyPayloadSchema
3152
+ })
3153
+ ]);
3154
+
3155
+ // src/workspaceCapabilities.ts
3156
+ var WORKSPACE_ROLES = ["owner", "admin", "editor", "viewer"];
3157
+ var WORKSPACE_CAPABILITIES = [
3158
+ "org:read",
3159
+ "billing:manage",
3160
+ "workspace:delete",
3161
+ "workspace:settings",
3162
+ "app:settings",
3163
+ "app:manage",
3164
+ "member:invite",
3165
+ "member:remove",
3166
+ "member:role",
3167
+ "ownership:transfer",
3168
+ "flow:read",
3169
+ "flow:edit",
3170
+ "flow:publish",
3171
+ "channel:read",
3172
+ "channel:manage",
3173
+ "experiment:read",
3174
+ "experiment:manage",
3175
+ "media:manage",
3176
+ "ai:brand_extract",
3177
+ "ai:translate",
3178
+ "store:manage",
3179
+ "analytics:read",
3180
+ "customers:read",
3181
+ "notifications:read",
3182
+ "notifications:write",
3183
+ "apiKey:manage",
3184
+ /** Granted at runtime via workspace-access when the member may approve rollouts. */
3185
+ "rollout:approve"
3186
+ ];
3187
+ new Set(
3188
+ WORKSPACE_CAPABILITIES.filter((c) => c !== "rollout:approve")
3189
+ );
3190
+ var caps = (...c) => new Set(c);
3191
+ ({
3192
+ admin: caps(
3193
+ "org:read",
3194
+ "workspace:settings",
3195
+ "app:settings",
3196
+ "app:manage",
3197
+ "member:invite",
3198
+ "member:remove",
3199
+ "member:role",
3200
+ "flow:read",
3201
+ "flow:edit",
3202
+ "flow:publish",
3203
+ "channel:read",
3204
+ "channel:manage",
3205
+ "experiment:read",
3206
+ "experiment:manage",
3207
+ "media:manage",
3208
+ "ai:brand_extract",
3209
+ "ai:translate",
3210
+ "store:manage",
3211
+ "analytics:read",
3212
+ "customers:read",
3213
+ "notifications:read",
3214
+ "notifications:write"
3215
+ ),
3216
+ editor: caps(
3217
+ "org:read",
3218
+ "flow:read",
3219
+ "flow:edit",
3220
+ "flow:publish",
3221
+ "channel:read",
3222
+ "channel:manage",
3223
+ "experiment:read",
3224
+ "experiment:manage",
3225
+ "media:manage",
3226
+ "ai:brand_extract",
3227
+ "ai:translate",
3228
+ "store:manage",
3229
+ "analytics:read",
3230
+ "customers:read",
3231
+ "notifications:read",
3232
+ "notifications:write"
3233
+ ),
3234
+ viewer: caps(
3235
+ "org:read",
3236
+ "flow:read",
3237
+ "channel:read",
3238
+ "experiment:read",
3239
+ "analytics:read",
3240
+ "customers:read",
3241
+ "notifications:read",
3242
+ "notifications:write"
3243
+ )
3244
+ });
3245
+
3246
+ // src/dashboard/workspace.ts
3247
+ var WorkspaceMemberRowSchema = z.object({
3248
+ userId: z.string().uuid(),
3249
+ email: z.string(),
3250
+ /** Same display rule as rollout requester labels. */
3251
+ label: z.string(),
3252
+ workspaceRole: z.enum(WORKSPACE_ROLES),
3253
+ createdAt: z.string()
3254
+ });
3255
+ var ListWorkspaceMembersResponseSchema = z.object({
3256
+ items: z.array(WorkspaceMemberRowSchema)
3257
+ });
3258
+ var ListNotificationsResponseSchema = z.object({
3259
+ items: z.array(NotificationSchema),
3260
+ unreadCount: z.number().int().nonnegative()
3261
+ });
3262
+ var AnalyticsRangeSchema = z.object({
3263
+ flowId: z.string().uuid(),
3264
+ environment: z.enum(ENVIRONMENTS),
3265
+ startDate: z.string().datetime(),
3266
+ endDate: z.string().datetime(),
3267
+ filters: z.object({
3268
+ platform: z.array(z.string()).optional(),
3269
+ locale: z.array(z.string()).optional(),
3270
+ variantId: z.array(z.string()).optional(),
3271
+ customProperties: z.record(z.string(), z.string()).optional()
3272
+ }).optional()
3273
+ });
3274
+ var FunnelResponseSchema = z.object({
3275
+ steps: z.array(
3276
+ z.object({
3277
+ stepId: z.string(),
3278
+ views: z.number().int().nonnegative(),
3279
+ completes: z.number().int().nonnegative(),
3280
+ skips: z.number().int().nonnegative(),
3281
+ dropoffs: z.number().int().nonnegative()
3282
+ })
3283
+ ),
3284
+ totalStarts: z.number().int().nonnegative(),
3285
+ totalCompletes: z.number().int().nonnegative()
3286
+ });
3287
+ var ResponseBreakdownSchema = z.object({
3288
+ fields: z.array(
3289
+ z.object({
3290
+ stepId: z.string(),
3291
+ fieldKey: z.string(),
3292
+ values: z.array(
3293
+ z.object({
3294
+ value: z.string(),
3295
+ count: z.number().int().nonnegative()
3296
+ })
3297
+ )
3298
+ })
3299
+ )
3300
+ });
3301
+ var RoleSchema = z.enum(ROLES);
3302
+ var MembershipSchema = z.object({
3303
+ userId: z.string().uuid(),
3304
+ orgId: z.string().uuid(),
3305
+ role: RoleSchema
3306
+ });
3307
+ var ONBOARDING_TASK_IDS = ["sdk_events"];
3308
+ var OnboardingTaskIdSchema = z.enum(ONBOARDING_TASK_IDS);
3309
+ var OnboardingTaskStatusSchema = z.enum(["pending", "done", "unknown"]);
3310
+ var OnboardingTaskCompletionSourceSchema = z.enum(["auto", "manual"]).nullable();
3311
+ var OnboardingTaskActionSchema = z.object({
3312
+ docsHref: z.string().url().optional(),
3313
+ keysHref: z.string().optional(),
3314
+ verifyable: z.boolean().optional()
3315
+ });
3316
+ var OnboardingTaskSchema = z.object({
3317
+ id: OnboardingTaskIdSchema,
3318
+ title: z.string(),
3319
+ description: z.string(),
3320
+ status: OnboardingTaskStatusSchema,
3321
+ completionSource: OnboardingTaskCompletionSourceSchema,
3322
+ action: OnboardingTaskActionSchema.optional()
3323
+ });
3324
+ var OnboardingChecklistFocusAppSchema = z.object({
3325
+ id: z.string().uuid(),
3326
+ name: z.string()
3327
+ });
3328
+ var OnboardingChecklistResponseSchema = z.object({
3329
+ tasks: z.array(OnboardingTaskSchema),
3330
+ completedCount: z.number().int().nonnegative(),
3331
+ totalCount: z.number().int().nonnegative(),
3332
+ focusApp: OnboardingChecklistFocusAppSchema.nullable(),
3333
+ dismissed: z.boolean(),
3334
+ eligible: z.boolean()
3335
+ });
3336
+ var OnboardingTaskVerifyResponseSchema = z.object({
3337
+ task: OnboardingTaskSchema
3338
+ });
3339
+ var OnboardingTaskCompleteResponseSchema = z.object({
3340
+ task: OnboardingTaskSchema
3341
+ });
3342
+ var OnboardingChecklistDismissResponseSchema = z.object({
3343
+ ok: z.literal(true)
3344
+ });
3345
+
3346
+ export { AddFlowCommentMessageRequestSchema, AddFlowCommentMessageResponseSchema, AddRolloutCommentResponseSchema, AddRolloutCommentSchema, AiFlowPromptSchema, AnalyticsRangeSchema, AppIconSchema, AppSchema, ApproveRolloutRequestSchema, ArchiveChannelRequestSchema, ArchiveFlowCommentThreadResponseSchema, AssignmentClearedPayloadSchema, AutosaveDraftRequestSchema, AutosaveDraftResponseSchema, BrandColorSchema, BrandGradientSchema, BrandGradientStopSchema, BrandingSchema, CREATE_FLOW_AI_PROMPT_MAX, ChannelArchivedPayloadSchema, ChannelAssignmentKindSchema, ChannelAssignmentRequestSchema, ChannelCreatedPayloadSchema, ChannelDirectAssignmentSchema, ChannelEventPayloadSchema, ChannelEventSchema, ChannelEventTypeSchema, ChannelExperimentAssignmentSchema, ChannelHistoryExperimentSnapshotSchema, ChannelHistoryFlowVersionSnapshotSchema, ChannelHistoryPreviousAssignmentSchema, ChannelRenamedPayloadSchema, ChannelSchema, ChannelUnarchivedPayloadSchema, ConfirmUploadRequestSchema, CreateAppRequestSchema, CreateAppResponseSchema, CreateChannelRequestSchema, CreateExperimentRequestSchema, CreateFlowCommentThreadRequestSchema, CreateFlowCommentThreadResponseSchema, CreateFlowRequestSchema, CreateFlowResponseSchema, CreateRolloutRequestsBodySchema, CreateRolloutRequestsResponseSchema, CreateVariantRequestSchema, DASHBOARD_MAX_TAGS, DASHBOARD_MAX_TAG_LEN, DeleteAppRequestSchema, DeleteAppResponseSchema, DeleteMediaAssetResponseSchema, DirectPinnedPayloadSchema, DuplicateFlowRequestSchema, EMPTY_BRANDING, EXPERIMENT_STATS_DESIGN_DEFAULTS, ExperimentAbandonStepRowSchema, ExperimentArmStatsSchema, ExperimentAssignedPayloadSchema, ExperimentCohortRuleSchema, ExperimentCvrTimeseriesResponseSchema, ExperimentEndedPayloadSchema, ExperimentEndedReasonSchema, ExperimentFunnelStepSchema, ExperimentResultsOverviewSchema, ExperimentSampleAccumulationSchema, ExperimentSchema, ExperimentSrmSchema, ExperimentStatsDesignInputSchema, ExperimentStatsResponseSchema, ExperimentStatusSchema, ExperimentStoppedRepinnedPayloadSchema, ExperimentVariantFunnelSchema, ExperimentWinnerPromotedPayloadSchema, ExtendExperimentRequestSchema, FlowAiGenerationRunStatusResponseSchema, FlowAiGenerationRunStatusSchema, FlowCommentFilterSchema, FlowCommentMentionPayloadSchema, FlowCommentMessageSchema, FlowCommentNewPayloadSchema, FlowCommentNotificationBasePayloadSchema, FlowCommentReplyPayloadSchema, FlowCommentThreadSummarySchema, FlowDraftSchema, FlowPreviewSchema, FlowStatusSchema, FlowSummarySchema, FlowVersionSchema, FlowVersionWithManifestSchema, FontFamilySchema, FontStyleSchema, FunnelResponseSchema, GetFlowCommentThreadResponseSchema, ListChannelHistoryResponseSchema, ListChannelsResponseSchema, ListExperimentsResponseSchema, ListFlowCommentThreadsResponseSchema, ListMediaResponseSchema, ListNotificationsResponseSchema, ListRolloutRequestsResponseSchema, ListVersionsResponseSchema, ListWorkspaceMembersResponseSchema, MediaAssetUsageReferenceSchema, MediaAssetUsageResponseSchema, MembershipSchema, NotificationKindSchema, NotificationSchema, ONBOARDING_TASK_IDS, OnboardingChecklistDismissResponseSchema, OnboardingChecklistFocusAppSchema, OnboardingChecklistResponseSchema, OnboardingTaskActionSchema, OnboardingTaskCompleteResponseSchema, OnboardingTaskCompletionSourceSchema, OnboardingTaskIdSchema, OnboardingTaskSchema, OnboardingTaskStatusSchema, OnboardingTaskVerifyResponseSchema, PatchRolloutPolicySchema, PublicationSchema, PublishRequestSchema, PublishResponseSchema, PublishValidationErrorSchema, PublishableKeySchema, RHEO_AGENT_IMAGE_MIME_TYPES, RHEO_AGENT_MAX_IMAGE_ATTACHMENTS, RejectRolloutRequestSchema, RenameChannelRequestSchema, ReorderExperimentVariantsRequestSchema, ResponseBreakdownSchema, RheoAgentApplyingManifestEventSchema, RheoAgentAttemptEventSchema, RheoAgentChatRequestSchema, RheoAgentDoneEventSchema, RheoAgentErrorEventSchema, RheoAgentImageAttachmentSchema, RheoAgentManifestEventSchema, RheoAgentMessageSchema, RheoAgentSelectionSchema, RheoAgentStreamEventSchema, RheoAgentTextDeltaEventSchema, RoleSchema, RolloutCommentKindSchema, RolloutCommentMentionPayloadSchema, RolloutCommentMentionUserSchema, RolloutFlowPayloadSchema, RolloutPolicyResponseSchema, RolloutRequestCommentSchema, RolloutRequestDetailSchema, RolloutRequestStatusSchema, RolloutRequestSummarySchema, SignUploadRequestSchema, SignUploadResponseSchema, StartAiFlowGenerationRequestSchema, StopExperimentRequestSchema, StoreListingInputSchema, StoreListingLookupResponseSchema, TagsSchema, TagsSchemaOptional, UnarchiveChannelResponseSchema, UpdateAppBrandingRequestSchema, UpdateAppRequestSchema, UpdateExperimentRequestSchema, UpdateExperimentStatusRequestSchema, UpdateFlowRequestSchema, UpdateMediaAssetRequestSchema, UpdateMediaAssetResponseSchema, VariantSchema, WorkspaceMemberRowSchema, normalizeDashboardTags };
3347
+ //# sourceMappingURL=dashboard.js.map
3348
+ //# sourceMappingURL=dashboard.js.map