@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,1460 @@
1
+ import { z } from 'zod';
2
+
3
+ // src/canvasEditorGates.ts
4
+
5
+ // src/layers/layerSchemaRef.ts
6
+ var layerSchemaStore = {};
7
+ var LocaleCode = z.string().regex(/^[a-z]{2}(-[A-Z]{2})?$/, 'locale must be like "en" or "en-US"');
8
+ var LocalizedTextSchema = z.object({
9
+ default: z.string().min(1, "default copy is required"),
10
+ translations: z.record(LocaleCode, z.string()).optional()
11
+ });
12
+
13
+ // src/hyperlinkHref.ts
14
+ var parseHyperlinkHref = (raw) => {
15
+ const t = raw.trim();
16
+ if (!t) return { ok: false };
17
+ let u;
18
+ try {
19
+ u = new URL(t);
20
+ } catch {
21
+ return { ok: false };
22
+ }
23
+ const scheme = u.protocol.replace(/:$/, "").toLowerCase();
24
+ if (scheme === "https") {
25
+ if (!u.hostname) return { ok: false };
26
+ return { ok: true, scheme: "https", host: u.hostname };
27
+ }
28
+ if (scheme === "mailto") {
29
+ return { ok: true, scheme: "mailto" };
30
+ }
31
+ return { ok: false };
32
+ };
33
+
34
+ // src/constants/index.ts
35
+ var FIELD_CLASSIFICATIONS = ["safe", "sensitive"];
36
+ var MEDIA_TYPES = ["image", "font", "lottie", "video"];
37
+
38
+ // src/media.ts
39
+ var MediaTypeSchema = z.enum(MEDIA_TYPES);
40
+ var MediaReferenceSchema = z.object({
41
+ mediaAssetId: z.string().uuid()
42
+ });
43
+ z.object({
44
+ id: z.string().uuid(),
45
+ orgId: z.string().uuid(),
46
+ type: MediaTypeSchema,
47
+ url: z.string().url(),
48
+ name: z.string().nullable().optional(),
49
+ contentType: z.string(),
50
+ sizeBytes: z.number().int().nonnegative(),
51
+ archivedAt: z.string().datetime().nullable().optional(),
52
+ createdAt: z.string().datetime()
53
+ });
54
+ var LayerIdSchema = z.string().min(1).max(64).regex(/^lyr_[a-z0-9_]+$/i, "layer id must look like lyr_<id>");
55
+ var ScreenIdSchema = z.string().min(1).max(64).regex(/^scr_[a-z0-9_]+$/i, "screen id must look like scr_<id>");
56
+ var RESTING_MOTION_PRESETS = ["translate", "bounce", "scale", "pulse", "rotate"];
57
+ var RestingMotionPresetSchema = z.enum(RESTING_MOTION_PRESETS);
58
+ var RESTING_MOTION_SCALE_DIRECTIONS = ["up", "down"];
59
+ var RestingMotionScaleDirectionSchema = z.enum(RESTING_MOTION_SCALE_DIRECTIONS);
60
+ var RESTING_MOTION_ROTATE_DIRECTIONS = ["clockwise", "counterclockwise"];
61
+ var RestingMotionRotateDirectionSchema = z.enum(RESTING_MOTION_ROTATE_DIRECTIONS);
62
+ var RestingMotionSchema = z.object({
63
+ preset: RestingMotionPresetSchema,
64
+ /**
65
+ * Timeline segment length (ms): motion is active from start until
66
+ * start + durationMs. When {@link loop} is true, the preset pattern repeats
67
+ * every {@link cycleDurationMs} (or preset default) within this window.
68
+ */
69
+ durationMs: z.number().int().min(200).max(2e4).optional(),
70
+ /** When true, repeat the motion pattern within the timeline segment; default is one shot. */
71
+ loop: z.boolean().optional(),
72
+ /**
73
+ * Duration (ms) of one full pattern cycle when looping. Defaults per {@link RESTING_MOTION_DEFAULT_DURATION_MS}.
74
+ */
75
+ cycleDurationMs: z.number().int().min(200).max(2e4).optional(),
76
+ intensity: z.number().min(0).max(2).optional(),
77
+ /** Bounce preset only: vertical lift in px. When omitted, uses `14 * intensity` (default intensity 1 → 14). */
78
+ bounceAmplitudePx: z.number().min(1).max(80).optional(),
79
+ /** Scale preset: grow (+) or shrink (−) toward a peak, then return to 100%. */
80
+ scaleDirection: RestingMotionScaleDirectionSchema.optional(),
81
+ /**
82
+ * Scale preset: when true (default), each cycle goes rest → peak scale → rest.
83
+ * When false, ramps rest → peak and holds; with loop, the next cycle restarts from rest.
84
+ */
85
+ scaleSpringBack: z.boolean().optional(),
86
+ /**
87
+ * Scale preset: magnitude in % — growth above 100% (up to +400% = 5× at peak) or shrink toward
88
+ * 100%− (up to 90% so peak can be 10% size). See authoring caps in the layer editor.
89
+ */
90
+ scalePercent: z.number().min(0).max(400).optional(),
91
+ /**
92
+ * Scale preset: ms for one full out-and-back (rest → peak → rest). Timeline bar still sets
93
+ * {@link durationMs} (when the layer may animate); this controls how fast each cycle runs.
94
+ */
95
+ scalePatternDurationMs: z.number().int().min(200).max(2e4).optional(),
96
+ /** @deprecated Use {@link scalePercent} + {@link scaleDirection}. Kept for legacy manifests. */
97
+ scaleUpPercent: z.number().min(0).max(400).optional(),
98
+ /** @deprecated Use {@link scalePercent} + {@link scaleDirection}. Kept for legacy manifests. */
99
+ scaleDownPercent: z.number().min(0).max(90).optional(),
100
+ /**
101
+ * @deprecated Legacy vertical-only float (px). Prefer {@link translatePeakXPercent} / {@link translatePeakYPercent}.
102
+ */
103
+ translateRangePx: z.number().min(0).max(40).optional(),
104
+ /** @deprecated Legacy peak offsets in px. Prefer {@link translatePeakXPercent} / {@link translatePeakYPercent}. */
105
+ translatePeakXPx: z.number().min(-200).max(200).optional(),
106
+ /** @deprecated Legacy peak offsets in px. Prefer {@link translatePeakXPercent} / {@link translatePeakYPercent}. */
107
+ translatePeakYPx: z.number().min(-200).max(200).optional(),
108
+ /** Translate preset: peak X offset as % of the layer box (−200–200). Scaled by intensity. */
109
+ translatePeakXPercent: z.number().min(-200).max(200).optional(),
110
+ /** Translate preset: peak Y offset as % of the layer box (−200–200). Scaled by intensity. */
111
+ translatePeakYPercent: z.number().min(-200).max(200).optional(),
112
+ /**
113
+ * Translate preset: when true (default), each cycle goes rest → peak offset → rest. When false, ramp to
114
+ * peak and hold; with loop, the next cycle restarts from the origin.
115
+ */
116
+ translateSpringBack: z.boolean().optional(),
117
+ /** Rotate preset: target rotation in degrees (0–360), scaled by intensity. */
118
+ rotateMaxDeg: z.number().min(0).max(360).optional(),
119
+ /** Rotate preset: spin direction; omitted or `clockwise` → positive angles (default). */
120
+ rotateDirection: RestingMotionRotateDirectionSchema.optional(),
121
+ /**
122
+ * Rotate preset: when true (default), each cycle oscillates 0° → peak → 0°.
123
+ * When false, each cycle ramps 0° → peak and holds; with loop, the next cycle snaps to 0° and ramps again.
124
+ */
125
+ rotateSpringBack: z.boolean().optional(),
126
+ /** Pulse preset: minimum opacity at the dip (0–1). Omitted → `1 - 0.38 * intensity`. */
127
+ pulseMinOpacity: z.number().min(0).max(1).optional(),
128
+ /** Ms after the last mount/stagger clip ends before motion applies (authoring + scrub). */
129
+ delayMsAfterMountEnd: z.number().int().min(0).max(6e4).optional(),
130
+ /**
131
+ * Absolute start time (ms from screen mount). When set, overrides
132
+ * {@link delayMsAfterMountEnd} + mount-clip end so motion can sit between
133
+ * clips (e.g. after first entry, before exit) when multiple mounts exist.
134
+ */
135
+ timelineStartMs: z.number().int().min(0).max(36e5).optional()
136
+ }).strict();
137
+ var RestingMotionEntrySchema = RestingMotionSchema.extend({
138
+ id: z.string().min(1)
139
+ });
140
+
141
+ // src/layers/base.ts
142
+ var baseLayerShape = {
143
+ id: LayerIdSchema,
144
+ name: z.string().max(80).optional(),
145
+ restingMotion: RestingMotionSchema.optional(),
146
+ restingMotions: z.array(RestingMotionEntrySchema).optional()
147
+ };
148
+ var ThemedColorModesSchema = z.object({
149
+ light: z.string().min(1).optional(),
150
+ dark: z.string().min(1).optional()
151
+ }).strict().refine((o) => o.light !== void 0 || o.dark !== void 0, {
152
+ message: "at least one of light or dark is required"
153
+ });
154
+ var ThemedColorSchema = z.union([z.string().min(1), ThemedColorModesSchema]);
155
+ var WIDTH_PRESETS = ["auto", "full", "1/2", "1/3", "2/3", "1/4", "3/4"];
156
+ var WidthValueSchema = z.union([z.enum(WIDTH_PRESETS), z.number().int().min(0).max(2e3)]);
157
+ var HEIGHT_PRESETS = ["auto", "full", "fill"];
158
+ var CommonLayoutHeightSchema = z.union([
159
+ z.enum(HEIGHT_PRESETS),
160
+ z.number().int().min(0).max(2e3)
161
+ ]);
162
+
163
+ // src/layers/styleCommon.ts
164
+ var NonNegativePxSchema = z.number().int().min(0);
165
+ var PaddingSchema = z.object({
166
+ t: NonNegativePxSchema.optional(),
167
+ r: NonNegativePxSchema.optional(),
168
+ b: NonNegativePxSchema.optional(),
169
+ l: NonNegativePxSchema.optional()
170
+ }).partial();
171
+ var BorderSchema = z.object({
172
+ width: z.number().int().min(0).max(20).optional(),
173
+ color: ThemedColorSchema.optional()
174
+ }).partial();
175
+ var DropShadowSchema = z.object({
176
+ offsetX: z.number().int().min(-100).max(100).optional(),
177
+ offsetY: z.number().int().min(-100).max(100).optional(),
178
+ blur: z.number().int().min(0).max(100).optional(),
179
+ spread: z.number().int().min(-50).max(50).optional(),
180
+ color: ThemedColorSchema.optional(),
181
+ opacity: z.number().min(0).max(1).optional()
182
+ }).partial();
183
+ var CommonStyleSchema = z.object({
184
+ padding: PaddingSchema.optional(),
185
+ margin: PaddingSchema.optional(),
186
+ radius: z.number().int().min(0).max(96).optional(),
187
+ background: ThemedColorSchema.optional(),
188
+ border: BorderSchema.optional(),
189
+ shadow: DropShadowSchema.optional(),
190
+ opacity: z.number().min(0).max(1).optional(),
191
+ width: WidthValueSchema.optional(),
192
+ /** Omit for normal flow; `'absolute'` removes the layer from flex flow (non-root only). */
193
+ position: z.literal("absolute").optional(),
194
+ /** Pixel insets when `position === 'absolute'` (same shape as padding). */
195
+ inset: PaddingSchema.optional(),
196
+ zIndex: z.number().int().min(-999).max(999).optional(),
197
+ /** Static rotation in degrees (CSS `rotate`); not timeline animation. */
198
+ rotate: z.number().min(-360).max(360).optional(),
199
+ /** Cross-axis size: `auto` (hug), `full`/`fill` (parent height), or fixed px. No fractions. */
200
+ height: CommonLayoutHeightSchema.optional(),
201
+ /** Stroke thickness in px for layers that render a stroke primitive (e.g. loader ring). */
202
+ strokeWidth: z.number().int().min(0).max(64).optional()
203
+ }).partial();
204
+ var TextStyleSchema = CommonStyleSchema.extend({
205
+ /**
206
+ * Logical font family: manifest `theme.fontFamily` when omitted, {@link TEXT_FONT_FAMILY_SYSTEM_UI}
207
+ * for the platform stack, or a custom name (matches `Branding.fontFamilies[].name` for uploaded fonts).
208
+ */
209
+ fontFamily: z.string().min(1).max(128).optional(),
210
+ fontSize: z.number().int().min(8).max(96).optional(),
211
+ fontWeight: z.number().int().min(100).max(900).optional(),
212
+ color: ThemedColorSchema.optional(),
213
+ align: z.enum(["left", "center", "right"]).optional(),
214
+ lineHeight: z.number().min(0.8).max(3).optional(),
215
+ /** Multiplier (0–1) applied to the resolved background color alpha only; text stays fully opaque unless `opacity` is set. */
216
+ backgroundOpacity: z.number().min(0).max(1).optional()
217
+ });
218
+ var ImageStyleSchema = CommonStyleSchema.extend({
219
+ fit: z.enum(["cover", "contain", "fill"]).optional(),
220
+ aspectRatio: z.number().positive().max(10).optional()
221
+ });
222
+ var IconStyleSchema = CommonStyleSchema.extend({
223
+ color: ThemedColorSchema.optional()
224
+ });
225
+ var ICON_FAMILIES = ["ionicons"];
226
+ var ButtonStyleSchema = CommonStyleSchema.extend({
227
+ fontSize: z.number().int().min(8).max(96).optional(),
228
+ fontWeight: z.number().int().min(100).max(900).optional(),
229
+ color: ThemedColorSchema.optional(),
230
+ align: z.enum(["left", "center", "right"]).optional()
231
+ });
232
+ var BUTTON_LAYER_VARIANTS = ["primary", "secondary", "ghost", "destructive"];
233
+ var ButtonLayerVariantSchema = z.enum(BUTTON_LAYER_VARIANTS);
234
+ var CommonStyleBreakpointsSchema = z.object({
235
+ sm: CommonStyleSchema.partial().optional(),
236
+ md: CommonStyleSchema.partial().optional(),
237
+ lg: CommonStyleSchema.partial().optional(),
238
+ xl: CommonStyleSchema.partial().optional(),
239
+ "2xl": CommonStyleSchema.partial().optional()
240
+ }).partial().optional();
241
+ var TextStyleBreakpointsSchema = z.object({
242
+ sm: TextStyleSchema.partial().optional(),
243
+ md: TextStyleSchema.partial().optional(),
244
+ lg: TextStyleSchema.partial().optional(),
245
+ xl: TextStyleSchema.partial().optional(),
246
+ "2xl": TextStyleSchema.partial().optional()
247
+ }).partial().optional();
248
+ var ImageStyleBreakpointsSchema = z.object({
249
+ sm: ImageStyleSchema.partial().optional(),
250
+ md: ImageStyleSchema.partial().optional(),
251
+ lg: ImageStyleSchema.partial().optional(),
252
+ xl: ImageStyleSchema.partial().optional(),
253
+ "2xl": ImageStyleSchema.partial().optional()
254
+ }).partial().optional();
255
+ var IconStyleBreakpointsSchema = z.object({
256
+ sm: IconStyleSchema.partial().optional(),
257
+ md: IconStyleSchema.partial().optional(),
258
+ lg: IconStyleSchema.partial().optional(),
259
+ xl: IconStyleSchema.partial().optional(),
260
+ "2xl": IconStyleSchema.partial().optional()
261
+ }).partial().optional();
262
+ var ButtonStyleBreakpointsSchema = z.object({
263
+ sm: ButtonStyleSchema.partial().optional(),
264
+ md: ButtonStyleSchema.partial().optional(),
265
+ lg: ButtonStyleSchema.partial().optional(),
266
+ xl: ButtonStyleSchema.partial().optional(),
267
+ "2xl": ButtonStyleSchema.partial().optional()
268
+ }).partial().optional();
269
+ var StackLayoutBreakpointPatchSchema = z.object({
270
+ gap: NonNegativePxSchema.optional(),
271
+ direction: z.enum(["vertical", "horizontal"]).optional()
272
+ }).partial();
273
+ var StackLayoutBreakpointsSchema = z.object({
274
+ sm: StackLayoutBreakpointPatchSchema.optional(),
275
+ md: StackLayoutBreakpointPatchSchema.optional(),
276
+ lg: StackLayoutBreakpointPatchSchema.optional(),
277
+ xl: StackLayoutBreakpointPatchSchema.optional(),
278
+ "2xl": StackLayoutBreakpointPatchSchema.optional()
279
+ }).partial().optional();
280
+ var ButtonLayoutBreakpointPatchSchema = z.object({
281
+ gap: NonNegativePxSchema.optional(),
282
+ direction: z.enum(["vertical", "horizontal"]).optional()
283
+ }).partial();
284
+ var ButtonLayoutBreakpointsSchema = z.object({
285
+ sm: ButtonLayoutBreakpointPatchSchema.optional(),
286
+ md: ButtonLayoutBreakpointPatchSchema.optional(),
287
+ lg: ButtonLayoutBreakpointPatchSchema.optional(),
288
+ xl: ButtonLayoutBreakpointPatchSchema.optional(),
289
+ "2xl": ButtonLayoutBreakpointPatchSchema.optional()
290
+ }).partial().optional();
291
+ var OS_PERMISSION_KEYS = [
292
+ "notifications",
293
+ "camera",
294
+ "microphone",
295
+ "photo_library",
296
+ "contacts",
297
+ "calendar",
298
+ "reminders",
299
+ "location_when_in_use",
300
+ "location_always",
301
+ "motion",
302
+ "bluetooth",
303
+ "app_tracking_transparency",
304
+ "speech_recognition",
305
+ "face_id",
306
+ "health_kit",
307
+ "media_library",
308
+ "local_network",
309
+ "nearby_interactions",
310
+ "nfc",
311
+ "full_screen_intent_android",
312
+ "sms_android",
313
+ "phone_android"
314
+ ];
315
+ var OsPermissionKeySchema = z.enum(OS_PERMISSION_KEYS);
316
+ var PERMISSION_OUTCOME_VALUES = ["granted", "denied", "blocked"];
317
+ z.enum(PERMISSION_OUTCOME_VALUES);
318
+ var OS_PERMISSION_OUTCOME_CONTINUE = "continue";
319
+ var OS_PERMISSION_OUTCOME_END = "end";
320
+ var OsPermissionOutcomeBranchTargetSchema = z.union([
321
+ ScreenIdSchema,
322
+ z.literal(OS_PERMISSION_OUTCOME_CONTINUE),
323
+ z.literal(OS_PERMISSION_OUTCOME_END)
324
+ ]);
325
+ var OsPermissionOutcomesSchema = z.object({
326
+ granted: OsPermissionOutcomeBranchTargetSchema,
327
+ denied: OsPermissionOutcomeBranchTargetSchema,
328
+ blocked: OsPermissionOutcomeBranchTargetSchema
329
+ }).strict();
330
+ var APP_REVIEW_OUTCOMES = ["not_shown", "dismissed"];
331
+ z.enum(APP_REVIEW_OUTCOMES);
332
+ var ButtonActionSchema = z.discriminatedUnion("kind", [
333
+ z.object({ kind: z.literal("none") }),
334
+ z.object({ kind: z.literal("continue") }),
335
+ z.object({ kind: z.literal("skip") }),
336
+ z.object({ kind: z.literal("end_flow") }),
337
+ z.object({
338
+ kind: z.literal("go_back_one_screen"),
339
+ fallbackScreenId: ScreenIdSchema.optional()
340
+ }),
341
+ z.object({ kind: z.literal("go_to_step"), screenId: ScreenIdSchema }),
342
+ z.object({
343
+ kind: z.literal("request_os_permission"),
344
+ permissionKey: OsPermissionKeySchema,
345
+ outcomes: OsPermissionOutcomesSchema
346
+ }),
347
+ z.object({
348
+ kind: z.literal("play_media"),
349
+ targetLayerIds: z.array(z.string().min(1)).min(1)
350
+ }),
351
+ z.object({ kind: z.literal("request_app_review") })
352
+ ]);
353
+ var TEXT_INPUT_TYPES = ["plain", "email", "phone", "url", "multiline"];
354
+ var TextInputTypeSchema = z.enum(TEXT_INPUT_TYPES);
355
+ var COUNTER_DISPLAY_KINDS = ["number", "time"];
356
+ var COUNTER_TIME_FORMATS = ["mm_ss", "hh_mm_ss", "dd_hh_mm_ss"];
357
+ var CheckboxGlyphStyleSchema = z.object({
358
+ /** Square edge length in px. */
359
+ size: z.number().int().min(8).max(128).optional(),
360
+ radius: z.number().int().min(0).max(96).optional(),
361
+ background: ThemedColorSchema.optional(),
362
+ border: BorderSchema.optional(),
363
+ shadow: DropShadowSchema.optional(),
364
+ opacity: z.number().min(0).max(1).optional(),
365
+ /** Fill color for the check mark when checked. */
366
+ checkColor: ThemedColorSchema.optional()
367
+ }).partial();
368
+ var OAUTH_LOGIN_PRESETS = ["github", "google", "apple"];
369
+ var OAuthPresetButtonChromeSchema = CommonStyleSchema.pick({
370
+ width: true,
371
+ padding: true,
372
+ margin: true,
373
+ radius: true
374
+ }).partial();
375
+ var OAuthPresetButtonChromeBreakpointsSchema = z.object({
376
+ sm: OAuthPresetButtonChromeSchema.partial().optional(),
377
+ md: OAuthPresetButtonChromeSchema.partial().optional(),
378
+ lg: OAuthPresetButtonChromeSchema.partial().optional(),
379
+ xl: OAuthPresetButtonChromeSchema.partial().optional(),
380
+ "2xl": OAuthPresetButtonChromeSchema.partial().optional()
381
+ }).partial().optional();
382
+ var EMAIL_PASSWORD_AUTH_MODES = ["sign_in", "sign_up"];
383
+ var EMAIL_PASSWORD_SLOTS = ["email", "password", "confirm"];
384
+
385
+ // src/layers/kinds/chrome.ts
386
+ var lazyLayer = () => layerSchemaStore.schema;
387
+ var ButtonLayerSchema = z.object({
388
+ ...baseLayerShape,
389
+ kind: z.literal("button"),
390
+ children: z.lazy(() => z.array(lazyLayer())),
391
+ action: ButtonActionSchema,
392
+ variant: ButtonLayerVariantSchema,
393
+ direction: z.enum(["vertical", "horizontal"]).optional(),
394
+ gap: z.number().int().min(0).optional(),
395
+ align: z.enum(["start", "center", "end", "stretch"]).optional(),
396
+ distribution: z.enum(["start", "center", "end", "between", "around"]).optional(),
397
+ style: ButtonStyleSchema.optional(),
398
+ styleBreakpoints: ButtonStyleBreakpointsSchema,
399
+ buttonLayoutBreakpoints: ButtonLayoutBreakpointsSchema
400
+ });
401
+ var BackButtonLayerSchema = z.object({
402
+ ...baseLayerShape,
403
+ kind: z.literal("back_button"),
404
+ children: z.lazy(() => z.array(lazyLayer())),
405
+ variant: ButtonLayerVariantSchema,
406
+ direction: z.enum(["vertical", "horizontal"]).optional(),
407
+ gap: z.number().int().min(0).optional(),
408
+ align: z.enum(["start", "center", "end", "stretch"]).optional(),
409
+ distribution: z.enum(["start", "center", "end", "between", "around"]).optional(),
410
+ style: ButtonStyleSchema.optional(),
411
+ styleBreakpoints: ButtonStyleBreakpointsSchema,
412
+ buttonLayoutBreakpoints: ButtonLayoutBreakpointsSchema,
413
+ fallbackScreenId: ScreenIdSchema.optional()
414
+ });
415
+ var ProgressLayerSchema = z.object({
416
+ ...baseLayerShape,
417
+ kind: z.literal("progress"),
418
+ trackColor: ThemedColorSchema.optional(),
419
+ fillColor: ThemedColorSchema.optional(),
420
+ style: CommonStyleSchema.optional()
421
+ });
422
+ var LoaderOnCompleteSchema = z.discriminatedUnion("mode", [
423
+ z.object({ mode: z.literal("none") }),
424
+ z.object({ mode: z.literal("next") }),
425
+ z.object({ mode: z.literal("screen"), screenId: ScreenIdSchema })
426
+ ]);
427
+ var LoaderLayerSchema = z.object({
428
+ ...baseLayerShape,
429
+ kind: z.literal("loader"),
430
+ variant: z.enum(["linear", "circular"]).optional(),
431
+ targetPercent: z.number().int().min(0).max(100).optional(),
432
+ fillDelayMs: z.number().int().min(0).max(1e4).optional(),
433
+ durationMs: z.number().int().min(0).max(36e5).optional(),
434
+ onComplete: LoaderOnCompleteSchema.optional(),
435
+ trackColor: ThemedColorSchema.optional(),
436
+ trackOpacity: z.number().min(0).max(1).optional(),
437
+ fillColor: ThemedColorSchema.optional(),
438
+ /** Horizontal alignment of the bar or ring within the layer box (default start). */
439
+ align: z.enum(["start", "center", "end"]).optional(),
440
+ style: CommonStyleSchema.optional()
441
+ }).superRefine((data, ctx) => {
442
+ if (data.variant !== "circular") return;
443
+ const w = data.style?.width;
444
+ const h = data.style?.height;
445
+ if (typeof w === "number" && typeof h === "number" && w !== h) {
446
+ ctx.addIssue({
447
+ code: z.ZodIssueCode.custom,
448
+ message: "circular loader requires style.width === style.height",
449
+ path: ["style", "height"]
450
+ });
451
+ }
452
+ });
453
+ var CounterLayerSchema = z.object({
454
+ ...baseLayerShape,
455
+ kind: z.literal("counter"),
456
+ startValue: z.number().finite(),
457
+ endValue: z.number().finite(),
458
+ durationMs: z.number().int().min(0).max(36e5).optional(),
459
+ delayMs: z.number().int().min(0).max(36e5).optional(),
460
+ decimalPlaces: z.number().int().min(0).max(10).optional(),
461
+ displayKind: z.enum(COUNTER_DISPLAY_KINDS).optional(),
462
+ timeFormat: z.enum(COUNTER_TIME_FORMATS).optional(),
463
+ style: TextStyleSchema.optional(),
464
+ styleBreakpoints: TextStyleBreakpointsSchema
465
+ });
466
+ var CheckboxLayerSchema = z.object({
467
+ ...baseLayerShape,
468
+ kind: z.literal("checkbox"),
469
+ fieldKey: z.string().min(1),
470
+ blocking: z.boolean().optional(),
471
+ uncheckedStyle: CheckboxGlyphStyleSchema.optional(),
472
+ checkedStyle: CheckboxGlyphStyleSchema.optional(),
473
+ style: CommonStyleSchema.optional(),
474
+ styleBreakpoints: CommonStyleBreakpointsSchema
475
+ });
476
+
477
+ // src/layers/kinds/layout.ts
478
+ var lazyLayer2 = () => layerSchemaStore.schema;
479
+ var StackLayerSchema = z.object({
480
+ ...baseLayerShape,
481
+ kind: z.literal("stack"),
482
+ style: CommonStyleSchema.optional(),
483
+ styleBreakpoints: CommonStyleBreakpointsSchema,
484
+ stackLayoutBreakpoints: StackLayoutBreakpointsSchema,
485
+ selectedStyle: CommonStyleSchema.optional(),
486
+ direction: z.enum(["vertical", "horizontal"]),
487
+ gap: z.number().int().min(0).optional(),
488
+ align: z.enum(["start", "center", "end", "stretch"]).optional(),
489
+ justify: z.enum(["start", "center", "end"]).optional(),
490
+ distribution: z.enum(["start", "center", "end", "between", "around"]).optional(),
491
+ wrap: z.boolean().optional(),
492
+ children: z.lazy(() => z.array(lazyLayer2()))
493
+ });
494
+ var TextLayerSchema = z.object({
495
+ ...baseLayerShape,
496
+ kind: z.literal("text"),
497
+ text: LocalizedTextSchema,
498
+ style: TextStyleSchema.optional(),
499
+ styleBreakpoints: TextStyleBreakpointsSchema
500
+ });
501
+ var migrateLegacyHyperlinkForParse = (raw) => {
502
+ if (!raw || typeof raw !== "object") return raw;
503
+ const o = raw;
504
+ if (o.kind !== "hyperlink") return raw;
505
+ const existing = o.children;
506
+ if (Array.isArray(existing) && existing.length > 0) return raw;
507
+ const idSrc = typeof o.id === "string" ? o.id.replace(/[^a-zA-Z0-9_]/g, "_") : "lyr_hyperlink";
508
+ const textChildId = `${idSrc}_lnktxt`.slice(0, 64);
509
+ const children = [
510
+ {
511
+ id: textChildId,
512
+ kind: "text",
513
+ text: o.text ?? { default: "Link" },
514
+ ...typeof o.style === "object" && o.style !== null ? { style: o.style } : {},
515
+ ...typeof o.styleBreakpoints === "object" && o.styleBreakpoints !== null ? { styleBreakpoints: o.styleBreakpoints } : {}
516
+ }
517
+ ];
518
+ const next = {
519
+ ...o,
520
+ children
521
+ };
522
+ delete next.text;
523
+ delete next.style;
524
+ delete next.styleBreakpoints;
525
+ return next;
526
+ };
527
+ var HyperlinkLayerSchemaInner = z.object({
528
+ ...baseLayerShape,
529
+ kind: z.literal("hyperlink"),
530
+ href: z.string().min(1).max(2048),
531
+ children: z.lazy(() => z.array(lazyLayer2()).min(1)),
532
+ direction: z.enum(["vertical", "horizontal"]).optional(),
533
+ gap: z.number().int().min(0).optional(),
534
+ align: z.enum(["start", "center", "end", "stretch"]).optional(),
535
+ distribution: z.enum(["start", "center", "end", "between", "around"]).optional(),
536
+ wrap: z.boolean().optional(),
537
+ style: CommonStyleSchema.optional(),
538
+ styleBreakpoints: CommonStyleBreakpointsSchema
539
+ }).superRefine((data, ctx) => {
540
+ const p = parseHyperlinkHref(data.href.trim());
541
+ if (!p.ok) {
542
+ ctx.addIssue({
543
+ code: z.ZodIssueCode.custom,
544
+ message: "hyperlink href must be a valid https: or mailto: URL",
545
+ path: ["href"]
546
+ });
547
+ }
548
+ });
549
+ var HyperlinkLayerSchema = z.preprocess(
550
+ migrateLegacyHyperlinkForParse,
551
+ HyperlinkLayerSchemaInner
552
+ );
553
+ var ImageLayerSchema = z.object({
554
+ ...baseLayerShape,
555
+ kind: z.literal("image"),
556
+ media: MediaReferenceSchema.optional(),
557
+ alt: z.string().max(280).optional(),
558
+ style: ImageStyleSchema.optional(),
559
+ styleBreakpoints: ImageStyleBreakpointsSchema
560
+ });
561
+ var LottieLayerSchema = z.object({
562
+ ...baseLayerShape,
563
+ kind: z.literal("lottie"),
564
+ media: MediaReferenceSchema.optional(),
565
+ loop: z.boolean().optional(),
566
+ autoPlay: z.boolean().optional(),
567
+ triggerLayerId: z.string().min(1).optional(),
568
+ onComplete: LoaderOnCompleteSchema.optional(),
569
+ style: ImageStyleSchema.optional(),
570
+ styleBreakpoints: ImageStyleBreakpointsSchema
571
+ });
572
+ var VideoLayerSchema = z.object({
573
+ ...baseLayerShape,
574
+ kind: z.literal("video"),
575
+ media: MediaReferenceSchema.optional(),
576
+ loop: z.boolean().optional(),
577
+ autoPlay: z.boolean().optional(),
578
+ triggerLayerId: z.string().min(1).optional(),
579
+ onComplete: LoaderOnCompleteSchema.optional(),
580
+ audioEnabled: z.boolean().optional(),
581
+ style: ImageStyleSchema.optional(),
582
+ styleBreakpoints: ImageStyleBreakpointsSchema
583
+ });
584
+ var IconLayerSchema = z.object({
585
+ ...baseLayerShape,
586
+ kind: z.literal("icon"),
587
+ family: z.enum(ICON_FAMILIES),
588
+ iconName: z.string().min(1).max(128),
589
+ style: IconStyleSchema.optional(),
590
+ styleBreakpoints: IconStyleBreakpointsSchema
591
+ });
592
+ var lazyLayer3 = () => layerSchemaStore.schema;
593
+ var OAuthProviderPresetLayerSchema = z.object({
594
+ ...baseLayerShape,
595
+ kind: z.literal("oauth_provider"),
596
+ variant: z.literal("preset"),
597
+ provider: z.enum(OAUTH_LOGIN_PRESETS),
598
+ label: LocalizedTextSchema.optional(),
599
+ style: OAuthPresetButtonChromeSchema.optional(),
600
+ styleBreakpoints: OAuthPresetButtonChromeBreakpointsSchema.optional()
601
+ });
602
+ var migrateOAuthProviderCustomIncoming = (raw) => {
603
+ if (!raw || typeof raw !== "object") return raw;
604
+ const o = raw;
605
+ if (o.kind !== "oauth_provider" || o.variant !== "custom") return raw;
606
+ const ch = o.children;
607
+ if (Array.isArray(ch) && ch.length > 0) {
608
+ const next2 = { ...o };
609
+ if (next2.buttonVariant === void 0) next2.buttonVariant = "secondary";
610
+ return next2;
611
+ }
612
+ const pid = typeof o.id === "string" ? o.id : "lyr_oauth_custom";
613
+ const slug = pid.replace(/[^a-z0-9_]/gi, "_").slice(0, 40) || "oauth";
614
+ const label = o.label ?? { default: "Custom" };
615
+ let family = o.family ?? "ionicons";
616
+ let iconName = o.iconName ?? "shield-outline";
617
+ if (family === "sf_symbol") {
618
+ family = "ionicons";
619
+ iconName = "star-outline";
620
+ }
621
+ const cid = slug;
622
+ const iconId = `lyr_${cid}_ico`.slice(0, 64);
623
+ const textId = `lyr_${cid}_txt`.slice(0, 64);
624
+ const next = { ...o };
625
+ delete next.label;
626
+ delete next.family;
627
+ delete next.iconName;
628
+ return {
629
+ ...next,
630
+ buttonVariant: o.buttonVariant ?? "secondary",
631
+ children: [
632
+ { id: iconId, kind: "icon", family, iconName },
633
+ { id: textId, kind: "text", text: label }
634
+ ]
635
+ };
636
+ };
637
+ var OAuthProviderCustomLayerSchemaValidated = z.object({
638
+ ...baseLayerShape,
639
+ kind: z.literal("oauth_provider"),
640
+ variant: z.literal("custom"),
641
+ rowId: z.string().uuid(),
642
+ buttonVariant: ButtonLayerVariantSchema,
643
+ direction: z.enum(["vertical", "horizontal"]).optional(),
644
+ gap: z.number().int().min(0).optional(),
645
+ align: z.enum(["start", "center", "end", "stretch"]).optional(),
646
+ distribution: z.enum(["start", "center", "end", "between", "around"]).optional(),
647
+ children: z.lazy(() => z.array(lazyLayer3()).min(1)),
648
+ style: ButtonStyleSchema.optional(),
649
+ styleBreakpoints: ButtonStyleBreakpointsSchema,
650
+ buttonLayoutBreakpoints: ButtonLayoutBreakpointsSchema
651
+ });
652
+ var OAuthProviderCustomLayerSchema = z.preprocess(
653
+ migrateOAuthProviderCustomIncoming,
654
+ OAuthProviderCustomLayerSchemaValidated
655
+ );
656
+ var OAuthProviderLayerSchema = z.union([
657
+ OAuthProviderPresetLayerSchema,
658
+ OAuthProviderCustomLayerSchema
659
+ ]);
660
+ var OAuthLoginPresetProviderSchema = z.object({
661
+ type: z.literal("preset"),
662
+ provider: z.enum(OAUTH_LOGIN_PRESETS)
663
+ });
664
+ var OAuthLoginCustomProviderSchema = z.object({
665
+ type: z.literal("custom"),
666
+ rowId: z.string().uuid(),
667
+ label: LocalizedTextSchema,
668
+ family: z.enum(ICON_FAMILIES),
669
+ iconName: z.string().min(1).max(128)
670
+ });
671
+ var OAuthLoginProviderSchema = z.discriminatedUnion("type", [
672
+ OAuthLoginPresetProviderSchema,
673
+ OAuthLoginCustomProviderSchema
674
+ ]);
675
+ var oauthLoginChildrenUniquePresets = (children, ctx) => {
676
+ const seen = /* @__PURE__ */ new Set();
677
+ for (let i = 0; i < children.length; i++) {
678
+ const c = children[i];
679
+ if (!c || c.kind !== "oauth_provider" || c.variant !== "preset") continue;
680
+ const preset = c.provider;
681
+ if (seen.has(preset)) {
682
+ ctx.addIssue({
683
+ code: z.ZodIssueCode.custom,
684
+ message: `duplicate OAuth preset "${preset}"`,
685
+ path: ["children", i, "provider"]
686
+ });
687
+ return;
688
+ }
689
+ seen.add(preset);
690
+ }
691
+ };
692
+ var migrateOAuthLoginIncoming = (raw) => {
693
+ if (!raw || typeof raw !== "object") return raw;
694
+ const o = raw;
695
+ if (o.kind !== "oauth_login") return raw;
696
+ if (Array.isArray(o.children) && o.children.length > 0) return raw;
697
+ const provs = o.providers;
698
+ if (!Array.isArray(provs) || provs.length === 0) return raw;
699
+ const pid = typeof o.id === "string" ? o.id : "lyr_oauth_legacy";
700
+ const slug = pid.replace(/^lyr_/i, "").replace(/[^a-z0-9_]/gi, "_").replace(/^_+/, "").slice(0, 48) || "oauth";
701
+ const children = provs.map((p, idx) => {
702
+ const prov = p ?? {};
703
+ const cid = `lyr_${slug}_opr_${idx}`.slice(0, 64);
704
+ if (prov.type === "preset") {
705
+ return {
706
+ id: cid,
707
+ kind: "oauth_provider",
708
+ variant: "preset",
709
+ provider: prov.provider
710
+ };
711
+ }
712
+ return {
713
+ id: cid,
714
+ kind: "oauth_provider",
715
+ variant: "custom",
716
+ rowId: String(prov.rowId),
717
+ buttonVariant: "secondary",
718
+ children: [
719
+ {
720
+ id: `${cid}_ico`.slice(0, 64),
721
+ kind: "icon",
722
+ family: prov.family ?? "ionicons",
723
+ iconName: String(prov.iconName ?? "shield")
724
+ },
725
+ {
726
+ id: `${cid}_txt`.slice(0, 64),
727
+ kind: "text",
728
+ text: prov.label ?? { default: "Custom" }
729
+ }
730
+ ]
731
+ };
732
+ });
733
+ const { providers: _omit, ...rest } = o;
734
+ return { ...rest, children };
735
+ };
736
+ var OAuthLoginLayerSchemaValidated = z.object({
737
+ ...baseLayerShape,
738
+ kind: z.literal("oauth_login"),
739
+ children: z.lazy(
740
+ () => z.array(OAuthProviderLayerSchema).min(1).superRefine(oauthLoginChildrenUniquePresets)
741
+ ),
742
+ gap: z.number().int().min(0).optional(),
743
+ align: z.enum(["start", "center", "end", "stretch"]).optional(),
744
+ style: CommonStyleSchema.optional(),
745
+ styleBreakpoints: CommonStyleBreakpointsSchema
746
+ });
747
+ var OAuthLoginLayerSchema = z.preprocess(
748
+ migrateOAuthLoginIncoming,
749
+ OAuthLoginLayerSchemaValidated
750
+ );
751
+ z.array(OAuthLoginProviderSchema).min(1).superRefine((providers, ctx) => {
752
+ const seen = /* @__PURE__ */ new Set();
753
+ for (let i = 0; i < providers.length; i++) {
754
+ const p = providers[i];
755
+ if (!p || p.type !== "preset") continue;
756
+ const preset = p.provider;
757
+ if (seen.has(preset)) {
758
+ ctx.addIssue({
759
+ code: z.ZodIssueCode.custom,
760
+ message: `duplicate OAuth preset "${preset}"`,
761
+ path: [i, "provider"]
762
+ });
763
+ return;
764
+ }
765
+ seen.add(preset);
766
+ }
767
+ });
768
+ var FIELD_KEY_RE = /^[a-z][a-z0-9_]*$/;
769
+ var FieldKeySchema = z.string().min(1).max(64).regex(FIELD_KEY_RE, "field key must be snake_case");
770
+ var FieldClassificationSchema = z.enum(FIELD_CLASSIFICATIONS);
771
+
772
+ // src/layers/kinds/auth/emailPasswordAuth.ts
773
+ var lazyLayer4 = () => layerSchemaStore.schema;
774
+ var EmailPasswordAuthModeSchema = z.enum(EMAIL_PASSWORD_AUTH_MODES);
775
+ var migrateEmailPasswordAuthIncoming = (raw) => {
776
+ if (!raw || typeof raw !== "object") return raw;
777
+ const o = raw;
778
+ if (o.kind !== "email_password_auth") return raw;
779
+ if (Array.isArray(o.children) && o.children.length > 0) return raw;
780
+ const idBase = typeof o.id === "string" ? o.id : "lyr_email_password_auth";
781
+ const slugRaw = idBase.replace(/^lyr_/i, "").replace(/[^a-z0-9_]/gi, "_");
782
+ const slug = slugRaw.length > 0 ? slugRaw.slice(0, 40) : "ep_auth";
783
+ const mode = o.mode === "sign_up" ? "sign_up" : "sign_in";
784
+ const pickLt = (v, fallback) => v && typeof v === "object" && v !== null && "default" in v ? v : { default: fallback };
785
+ const mkField = (suf, slot, labelSource, fallbackPlaceholder) => ({
786
+ id: `lyr_${slug}_fld_${suf}`.slice(0, 64),
787
+ kind: "email_password_field",
788
+ slot,
789
+ ...labelSource ? { placeholder: pickLt(labelSource, fallbackPlaceholder) } : { placeholder: { default: fallbackPlaceholder } },
790
+ children: []
791
+ });
792
+ const children = [];
793
+ children.push(mkField("email", "email", o.emailLabel, "Email"));
794
+ children.push(mkField("pw", "password", o.passwordLabel, "Password"));
795
+ if (mode === "sign_up") {
796
+ children.push(mkField("cf", "confirm", o.confirmPasswordLabel, "Confirm password"));
797
+ }
798
+ const submitLbl = o.submitLabel ?? { default: mode === "sign_in" ? "Sign in" : "Create account" };
799
+ children.push({
800
+ id: `lyr_${slug}_submit`.slice(0, 64),
801
+ kind: "email_password_submit",
802
+ buttonVariant: "primary",
803
+ direction: "horizontal",
804
+ align: "center",
805
+ distribution: "center",
806
+ gap: 8,
807
+ children: [
808
+ {
809
+ id: `lyr_${slug}_submit_txt`.slice(0, 64),
810
+ kind: "text",
811
+ text: submitLbl
812
+ }
813
+ ]
814
+ });
815
+ const {
816
+ emailLabel: _e,
817
+ passwordLabel: _p,
818
+ confirmPasswordLabel: _c,
819
+ submitLabel: _s,
820
+ ...rest
821
+ } = o;
822
+ return { ...rest, mode, children };
823
+ };
824
+ var refineEmailPasswordAuthChildren = (data, ctx) => {
825
+ const fields = data.children.filter((c) => c.kind === "email_password_field");
826
+ const submits = data.children.filter((c) => c.kind === "email_password_submit");
827
+ const slotSeen = /* @__PURE__ */ new Set();
828
+ for (const f of fields) {
829
+ if (slotSeen.has(f.slot)) {
830
+ ctx.addIssue({
831
+ code: z.ZodIssueCode.custom,
832
+ message: `duplicate email_password_field slot "${f.slot}"`,
833
+ path: ["children"]
834
+ });
835
+ }
836
+ slotSeen.add(f.slot);
837
+ }
838
+ const slotHas = new Set(fields.map((f) => f.slot));
839
+ const requiredSlots = data.mode === "sign_up" ? ["email", "password", "confirm"] : ["email", "password"];
840
+ for (const s of requiredSlots) {
841
+ if (!slotHas.has(s)) {
842
+ ctx.addIssue({
843
+ code: z.ZodIssueCode.custom,
844
+ 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}"`,
845
+ path: ["children"]
846
+ });
847
+ }
848
+ }
849
+ if (data.mode === "sign_in" && slotHas.has("confirm")) {
850
+ ctx.addIssue({
851
+ code: z.ZodIssueCode.custom,
852
+ message: 'sign_in must not include email_password_field with slot "confirm"',
853
+ path: ["children"]
854
+ });
855
+ }
856
+ if (submits.length !== 1) {
857
+ ctx.addIssue({
858
+ code: z.ZodIssueCode.custom,
859
+ message: `email_password_auth must have exactly one email_password_submit (found ${submits.length})`,
860
+ path: ["children"]
861
+ });
862
+ }
863
+ };
864
+ var EmailPasswordFieldLayerSchema = z.object({
865
+ ...baseLayerShape,
866
+ kind: z.literal("email_password_field"),
867
+ slot: z.enum(EMAIL_PASSWORD_SLOTS),
868
+ placeholder: LocalizedTextSchema.optional(),
869
+ children: z.lazy(() => z.array(lazyLayer4())).optional(),
870
+ style: CommonStyleSchema.optional(),
871
+ styleBreakpoints: CommonStyleBreakpointsSchema
872
+ });
873
+ var EmailPasswordSubmitLayerSchema = z.object({
874
+ ...baseLayerShape,
875
+ kind: z.literal("email_password_submit"),
876
+ buttonVariant: ButtonLayerVariantSchema,
877
+ direction: z.enum(["vertical", "horizontal"]).optional(),
878
+ gap: z.number().int().min(0).optional(),
879
+ align: z.enum(["start", "center", "end", "stretch"]).optional(),
880
+ distribution: z.enum(["start", "center", "end", "between", "around"]).optional(),
881
+ children: z.lazy(() => z.array(lazyLayer4()).min(1)),
882
+ style: ButtonStyleSchema.optional(),
883
+ styleBreakpoints: ButtonStyleBreakpointsSchema,
884
+ buttonLayoutBreakpoints: ButtonLayoutBreakpointsSchema
885
+ });
886
+ var EmailPasswordAuthLayerSchemaValidated = z.object({
887
+ ...baseLayerShape,
888
+ kind: z.literal("email_password_auth"),
889
+ mode: EmailPasswordAuthModeSchema,
890
+ fieldKey: FieldKeySchema,
891
+ minPasswordLength: z.number().int().min(4).max(128).optional(),
892
+ children: z.lazy(
893
+ () => z.array(z.union([EmailPasswordFieldLayerSchema, EmailPasswordSubmitLayerSchema])).min(1)
894
+ ),
895
+ gap: z.number().int().min(0).optional(),
896
+ align: z.enum(["start", "center", "end", "stretch"]).optional(),
897
+ style: CommonStyleSchema.optional(),
898
+ styleBreakpoints: CommonStyleBreakpointsSchema
899
+ }).superRefine(refineEmailPasswordAuthChildren);
900
+ var EmailPasswordAuthLayerSchema = z.preprocess(
901
+ migrateEmailPasswordAuthIncoming,
902
+ EmailPasswordAuthLayerSchemaValidated
903
+ );
904
+ var ChoiceOptionBindingSchema = z.object({
905
+ optionId: z.string().min(1).max(64),
906
+ rootLayerId: LayerIdSchema
907
+ });
908
+ var BranchConditionSchema = z.object({
909
+ choiceId: z.string().min(1),
910
+ goTo: ScreenIdSchema
911
+ });
912
+ var ChoiceBranchingSchema = z.object({
913
+ enabled: z.boolean(),
914
+ conditions: z.array(BranchConditionSchema)
915
+ });
916
+
917
+ // src/layers/kinds/input.ts
918
+ var lazyLayer5 = () => layerSchemaStore.schema;
919
+ var SingleChoiceLayerSchema = z.object({
920
+ ...baseLayerShape,
921
+ kind: z.literal("single_choice"),
922
+ fieldKey: FieldKeySchema,
923
+ children: z.lazy(
924
+ () => z.array(StackLayerSchema).min(2)
925
+ ),
926
+ optionBindings: z.array(ChoiceOptionBindingSchema).min(2),
927
+ branching: ChoiceBranchingSchema,
928
+ direction: z.enum(["vertical", "horizontal", "grid"]).optional(),
929
+ gap: z.number().int().min(0).optional(),
930
+ columns: z.number().int().min(1).max(12).optional(),
931
+ style: CommonStyleSchema.optional(),
932
+ styleBreakpoints: CommonStyleBreakpointsSchema
933
+ });
934
+ var MultipleChoiceLayerSchema = z.object({
935
+ ...baseLayerShape,
936
+ kind: z.literal("multiple_choice"),
937
+ fieldKey: FieldKeySchema,
938
+ children: z.lazy(
939
+ () => z.array(StackLayerSchema).min(2)
940
+ ),
941
+ optionBindings: z.array(ChoiceOptionBindingSchema).min(2),
942
+ minSelections: z.number().int().nonnegative().optional(),
943
+ maxSelections: z.number().int().positive().optional(),
944
+ branching: ChoiceBranchingSchema,
945
+ direction: z.enum(["vertical", "horizontal", "grid"]).optional(),
946
+ gap: z.number().int().min(0).optional(),
947
+ columns: z.number().int().min(1).max(12).optional(),
948
+ style: CommonStyleSchema.optional(),
949
+ styleBreakpoints: CommonStyleBreakpointsSchema
950
+ });
951
+ var TextInputLayerSchema = z.object({
952
+ ...baseLayerShape,
953
+ kind: z.literal("text_input"),
954
+ fieldKey: FieldKeySchema,
955
+ placeholder: LocalizedTextSchema.optional(),
956
+ inputType: TextInputTypeSchema.optional(),
957
+ required: z.boolean().optional(),
958
+ minLength: z.number().int().min(0).max(2e3).optional(),
959
+ maxLength: z.number().int().positive().max(2e3).optional(),
960
+ classification: FieldClassificationSchema,
961
+ children: z.lazy(() => z.array(lazyLayer5())).optional(),
962
+ style: CommonStyleSchema.optional()
963
+ });
964
+ var ScaleInputLabelStyleSchema = z.object({
965
+ fontFamily: z.string().min(1).max(128).optional(),
966
+ fontSize: z.number().int().min(8).max(96).optional(),
967
+ fontWeight: z.number().int().min(100).max(900).optional(),
968
+ color: ThemedColorSchema.optional(),
969
+ align: z.enum(["left", "center", "right"]).optional(),
970
+ lineHeight: z.number().min(0.8).max(3).optional(),
971
+ opacity: z.number().min(0).max(1).optional()
972
+ }).partial();
973
+ var ScaleInputLayerSchema = z.object({
974
+ ...baseLayerShape,
975
+ kind: z.literal("scale_input"),
976
+ fieldKey: FieldKeySchema,
977
+ min: z.number(),
978
+ max: z.number(),
979
+ step: z.number().positive().optional(),
980
+ defaultValue: z.number().optional(),
981
+ minLabel: LocalizedTextSchema.optional(),
982
+ maxLabel: LocalizedTextSchema.optional(),
983
+ labelStyle: ScaleInputLabelStyleSchema.optional(),
984
+ valueStyle: ScaleInputLabelStyleSchema.optional(),
985
+ showLabels: z.boolean().optional(),
986
+ showValue: z.boolean().optional(),
987
+ trackHeight: z.number().int().min(2).max(32).optional(),
988
+ trackColor: ThemedColorSchema.optional(),
989
+ fillColor: ThemedColorSchema.optional(),
990
+ thumbSize: z.number().int().min(8).max(48).optional(),
991
+ thumbColor: ThemedColorSchema.optional(),
992
+ children: z.lazy(() => z.array(lazyLayer5())).optional(),
993
+ style: CommonStyleSchema.optional()
994
+ });
995
+ var CarouselIndicatorsStyleSchema = z.object({
996
+ width: z.number().int().min(1).max(64).optional(),
997
+ height: z.number().int().min(1).max(64).optional(),
998
+ defaultColor: ThemedColorSchema.optional(),
999
+ defaultOpacity: z.number().min(0).max(1).optional(),
1000
+ activeColor: ThemedColorSchema.optional(),
1001
+ activeOpacity: z.number().min(0).max(1).optional(),
1002
+ activeWidth: z.number().int().min(1).max(64).optional(),
1003
+ activeHeight: z.number().int().min(1).max(64).optional(),
1004
+ border: BorderSchema.optional(),
1005
+ activeBorder: BorderSchema.optional()
1006
+ }).partial();
1007
+ var CarouselPageControlSchema = z.object({
1008
+ position: z.enum(["top", "bottom"]),
1009
+ spacing: z.number().int().min(0).optional(),
1010
+ padding: PaddingSchema.optional(),
1011
+ margin: PaddingSchema.optional(),
1012
+ indicators: CarouselIndicatorsStyleSchema.optional(),
1013
+ border: BorderSchema.optional(),
1014
+ shadow: DropShadowSchema.optional()
1015
+ });
1016
+ var CarouselLayerSchema = z.object({
1017
+ ...baseLayerShape,
1018
+ kind: z.literal("carousel"),
1019
+ slides: z.lazy(() => z.array(StackLayerSchema).min(1)),
1020
+ pageAlignment: z.enum(["top", "center", "bottom"]).optional(),
1021
+ pageSpacing: z.number().int().min(0).optional(),
1022
+ pagePeek: z.number().int().min(0).max(400).optional(),
1023
+ openOn: z.number().int().min(0).optional(),
1024
+ loop: z.boolean().optional(),
1025
+ autoAdvance: z.boolean().optional(),
1026
+ autoAdvanceMs: z.number().int().min(500).max(6e4).optional(),
1027
+ pageControl: CarouselPageControlSchema.optional(),
1028
+ style: CommonStyleSchema.optional(),
1029
+ styleBreakpoints: CommonStyleBreakpointsSchema
1030
+ });
1031
+
1032
+ // src/layers/initLayerSchema.ts
1033
+ layerSchemaStore.schema = z.lazy(
1034
+ () => z.union([
1035
+ StackLayerSchema,
1036
+ TextLayerSchema,
1037
+ HyperlinkLayerSchema,
1038
+ ImageLayerSchema,
1039
+ LottieLayerSchema,
1040
+ VideoLayerSchema,
1041
+ IconLayerSchema,
1042
+ ButtonLayerSchema,
1043
+ BackButtonLayerSchema,
1044
+ ProgressLayerSchema,
1045
+ LoaderLayerSchema,
1046
+ CounterLayerSchema,
1047
+ CheckboxLayerSchema,
1048
+ SingleChoiceLayerSchema,
1049
+ MultipleChoiceLayerSchema,
1050
+ TextInputLayerSchema,
1051
+ ScaleInputLayerSchema,
1052
+ OAuthLoginLayerSchema,
1053
+ OAuthProviderPresetLayerSchema,
1054
+ OAuthProviderCustomLayerSchema,
1055
+ EmailPasswordAuthLayerSchema,
1056
+ EmailPasswordFieldLayerSchema,
1057
+ EmailPasswordSubmitLayerSchema,
1058
+ CarouselLayerSchema
1059
+ ])
1060
+ );
1061
+ var ScreenBackgroundFitSchema = z.enum(["cover", "contain", "fill"]);
1062
+ var ScreenBackgroundScrimSchema = z.object({
1063
+ color: ThemedColorSchema.optional(),
1064
+ opacity: z.number().min(0).max(1).optional()
1065
+ }).partial();
1066
+ var screenBackgroundMediaShape = {
1067
+ media: MediaReferenceSchema.optional(),
1068
+ fit: ScreenBackgroundFitSchema.optional(),
1069
+ opacity: z.number().min(0).max(1).optional(),
1070
+ scrim: ScreenBackgroundScrimSchema.optional()
1071
+ };
1072
+ var ScreenBackgroundColorFillSchema = z.object({
1073
+ kind: z.literal("color"),
1074
+ color: ThemedColorSchema.optional(),
1075
+ opacity: z.number().min(0).max(1).optional()
1076
+ });
1077
+ var ScreenBackgroundImageFillSchema = z.object({
1078
+ kind: z.literal("image"),
1079
+ ...screenBackgroundMediaShape
1080
+ });
1081
+ var ScreenBackgroundVideoFillSchema = z.object({
1082
+ kind: z.literal("video"),
1083
+ ...screenBackgroundMediaShape,
1084
+ loop: z.boolean().optional(),
1085
+ autoPlay: z.boolean().optional(),
1086
+ triggerLayerId: z.string().min(1).optional(),
1087
+ onComplete: LoaderOnCompleteSchema.optional(),
1088
+ audioEnabled: z.boolean().optional()
1089
+ });
1090
+ var ScreenBackgroundFillSchema = z.discriminatedUnion("kind", [
1091
+ ScreenBackgroundColorFillSchema,
1092
+ ScreenBackgroundImageFillSchema,
1093
+ ScreenBackgroundVideoFillSchema
1094
+ ]);
1095
+ var ScreenBackgroundFillPatchSchema = z.object({
1096
+ color: ThemedColorSchema.optional(),
1097
+ fit: ScreenBackgroundFitSchema.optional(),
1098
+ opacity: z.number().min(0).max(1).optional(),
1099
+ scrim: ScreenBackgroundScrimSchema.optional(),
1100
+ loop: z.boolean().optional(),
1101
+ autoPlay: z.boolean().optional(),
1102
+ triggerLayerId: z.string().min(1).optional(),
1103
+ onComplete: LoaderOnCompleteSchema.optional(),
1104
+ audioEnabled: z.boolean().optional()
1105
+ }).partial();
1106
+ var ScreenContainerBreakpointPatchSchema = z.object({
1107
+ padding: PaddingSchema.optional(),
1108
+ margin: PaddingSchema.optional(),
1109
+ insetSafeArea: z.boolean().optional(),
1110
+ backgroundFillPatch: ScreenBackgroundFillPatchSchema.optional()
1111
+ }).partial();
1112
+ var ScreenContainerStyleBreakpointsSchema = z.object({
1113
+ sm: ScreenContainerBreakpointPatchSchema.optional(),
1114
+ md: ScreenContainerBreakpointPatchSchema.optional(),
1115
+ lg: ScreenContainerBreakpointPatchSchema.optional(),
1116
+ xl: ScreenContainerBreakpointPatchSchema.optional(),
1117
+ "2xl": ScreenContainerBreakpointPatchSchema.optional()
1118
+ }).partial().optional();
1119
+ var DecisionNodeIdSchema = z.string().min(1).max(64).regex(/^dec_[a-z0-9_]+$/i, "decision node id must look like dec_<id>");
1120
+ var ExternalSurfaceJumpIdSchema = z.string().min(1).max(64).regex(/^surf_[a-z0-9_]+$/i, "external surface node id must look like surf_<id>");
1121
+ var EXTERNAL_SURFACE_NO_NEXT = "__onb_surface_no_next__";
1122
+ var ExternalSurfaceTerminalTargetSchema = z.literal(EXTERNAL_SURFACE_NO_NEXT);
1123
+ var FlowJumpTargetSchema = ScreenIdSchema.or(DecisionNodeIdSchema).or(ExternalSurfaceJumpIdSchema).or(ExternalSurfaceTerminalTargetSchema).nullable();
1124
+ var DecisionBuiltinNameSchema = z.enum(["locale", "platform"]);
1125
+ var DecisionVariableRefSchema = z.discriminatedUnion("kind", [
1126
+ z.object({ kind: z.literal("builtin"), name: DecisionBuiltinNameSchema }),
1127
+ z.object({ kind: z.literal("sdk"), key: z.string().min(1).max(128) }),
1128
+ z.object({ kind: z.literal("field"), fieldKey: z.string().min(1).max(128) })
1129
+ ]);
1130
+ var DecisionStringPredicateSchema = z.discriminatedUnion("op", [
1131
+ z.object({ op: z.literal("eq"), value: z.string() }),
1132
+ z.object({ op: z.literal("neq"), value: z.string() }),
1133
+ z.object({ op: z.literal("contains"), value: z.string() })
1134
+ ]);
1135
+ var DecisionNumberPredicateSchema = z.discriminatedUnion("op", [
1136
+ z.object({ op: z.literal("eq"), value: z.number() }),
1137
+ z.object({ op: z.literal("neq"), value: z.number() }),
1138
+ z.object({ op: z.literal("lt"), value: z.number() }),
1139
+ z.object({ op: z.literal("lte"), value: z.number() }),
1140
+ z.object({ op: z.literal("gt"), value: z.number() }),
1141
+ z.object({ op: z.literal("gte"), value: z.number() })
1142
+ ]);
1143
+ var DecisionChoicePredicateSchema = z.discriminatedUnion("op", [
1144
+ z.object({ op: z.literal("eq"), optionId: z.string().min(1) }),
1145
+ z.object({ op: z.literal("one_of"), optionIds: z.array(z.string().min(1)).min(1) })
1146
+ ]);
1147
+ var DecisionMultiPredicateSchema = z.discriminatedUnion("op", [
1148
+ z.object({
1149
+ op: z.literal("intersects"),
1150
+ optionIds: z.array(z.string().min(1)).min(1)
1151
+ }),
1152
+ z.object({
1153
+ op: z.literal("contains_all"),
1154
+ optionIds: z.array(z.string().min(1)).min(1)
1155
+ }),
1156
+ z.object({
1157
+ op: z.literal("subset_of"),
1158
+ optionIds: z.array(z.string().min(1)).min(1)
1159
+ })
1160
+ ]);
1161
+ var DecisionBooleanPredicateSchema = z.discriminatedUnion("op", [
1162
+ z.object({ op: z.literal("eq"), value: z.boolean() }),
1163
+ z.object({ op: z.literal("neq"), value: z.boolean() })
1164
+ ]);
1165
+ var DecisionPredicatePayloadSchema = z.discriminatedUnion("type", [
1166
+ z.object({ type: z.literal("string"), pred: DecisionStringPredicateSchema }),
1167
+ z.object({ type: z.literal("number"), pred: DecisionNumberPredicateSchema }),
1168
+ z.object({ type: z.literal("boolean"), pred: DecisionBooleanPredicateSchema }),
1169
+ z.object({ type: z.literal("choice"), pred: DecisionChoicePredicateSchema }),
1170
+ z.object({ type: z.literal("multi"), pred: DecisionMultiPredicateSchema })
1171
+ ]);
1172
+ var DecisionExprSchema = z.lazy(
1173
+ () => z.discriminatedUnion("kind", [
1174
+ z.object({ kind: z.literal("empty") }),
1175
+ z.object({
1176
+ kind: z.literal("group"),
1177
+ op: z.enum(["and", "or"]),
1178
+ children: z.array(DecisionExprSchema).min(1)
1179
+ }),
1180
+ z.object({
1181
+ kind: z.literal("predicate"),
1182
+ variable: DecisionVariableRefSchema,
1183
+ predicate: DecisionPredicatePayloadSchema
1184
+ })
1185
+ ])
1186
+ );
1187
+ var DecisionCaseSchema = z.object({
1188
+ id: z.string().min(1).max(80),
1189
+ /** Display label in the editor (e.g. “Engaged users”). */
1190
+ name: z.string().min(1).max(80).optional(),
1191
+ expression: DecisionExprSchema,
1192
+ next: FlowJumpTargetSchema
1193
+ });
1194
+ z.object({
1195
+ id: DecisionNodeIdSchema,
1196
+ name: z.string().min(1).max(80).optional(),
1197
+ cases: z.array(DecisionCaseSchema).min(1).max(16),
1198
+ elseNext: FlowJumpTargetSchema
1199
+ });
1200
+ var ANIMATABLE_PROPERTIES = [
1201
+ "opacity",
1202
+ "translateX",
1203
+ "translateY",
1204
+ "scale"
1205
+ ];
1206
+ var AnimatablePropertySchema = z.enum(ANIMATABLE_PROPERTIES);
1207
+ var EASING_TOKENS = [
1208
+ "linear",
1209
+ "ease-in",
1210
+ "ease-out",
1211
+ "ease-in-out",
1212
+ "standard",
1213
+ "emphasized"
1214
+ ];
1215
+ var EasingTokenSchema = z.enum(EASING_TOKENS);
1216
+ var KeyframeSchema = z.object({
1217
+ t: z.number().min(0).max(1),
1218
+ value: z.number(),
1219
+ /** Easing applied from this keyframe to the next; defaults to linear. */
1220
+ easing: EasingTokenSchema.optional()
1221
+ }).strict();
1222
+ var KeyframeTrackSchema = z.object({
1223
+ property: AnimatablePropertySchema,
1224
+ keyframes: z.array(KeyframeSchema).min(2)
1225
+ }).strict().superRefine((track, ctx) => {
1226
+ let last = -Infinity;
1227
+ for (const k of track.keyframes) {
1228
+ if (k.t < last) {
1229
+ ctx.addIssue({
1230
+ code: z.ZodIssueCode.custom,
1231
+ message: `keyframe times must be monotonically non-decreasing on track "${track.property}"`
1232
+ });
1233
+ return;
1234
+ }
1235
+ last = k.t;
1236
+ }
1237
+ if (track.keyframes[0].t !== 0) {
1238
+ ctx.addIssue({
1239
+ code: z.ZodIssueCode.custom,
1240
+ message: `track "${track.property}" first keyframe must start at t=0`
1241
+ });
1242
+ }
1243
+ if (track.keyframes[track.keyframes.length - 1].t !== 1) {
1244
+ ctx.addIssue({
1245
+ code: z.ZodIssueCode.custom,
1246
+ message: `track "${track.property}" last keyframe must end at t=1`
1247
+ });
1248
+ }
1249
+ });
1250
+ var ANIMATION_TRIGGERS = ["mount", "stagger", "unmount"];
1251
+ var AnimationTriggerSchema = z.enum(ANIMATION_TRIGGERS);
1252
+ var AnimationClipSchema = z.object({
1253
+ id: z.string().min(1).max(64),
1254
+ targetLayerId: LayerIdSchema,
1255
+ trigger: AnimationTriggerSchema,
1256
+ /** Position in the screen's stagger order. Required when trigger is `stagger`. */
1257
+ staggerIndex: z.number().int().min(0).max(64).optional(),
1258
+ /** Total clip duration in milliseconds (renderer scales 0..1 keyframes by this). */
1259
+ durationMs: z.number().int().min(0).max(36e5),
1260
+ /** Pre-roll delay before the clip begins, in ms. Stagger adds on top of this. */
1261
+ delayMs: z.number().int().min(0).max(36e5).optional(),
1262
+ tracks: z.array(KeyframeTrackSchema).min(1)
1263
+ }).strict().superRefine((clip, ctx) => {
1264
+ if (clip.trigger === "unmount" && clip.staggerIndex !== void 0) {
1265
+ ctx.addIssue({
1266
+ code: z.ZodIssueCode.custom,
1267
+ message: `clip "${clip.id}" with trigger "unmount" must not set staggerIndex`,
1268
+ path: ["staggerIndex"]
1269
+ });
1270
+ }
1271
+ if (clip.trigger === "stagger" && clip.staggerIndex === void 0) {
1272
+ ctx.addIssue({
1273
+ code: z.ZodIssueCode.custom,
1274
+ message: `clip "${clip.id}" with trigger "stagger" must define staggerIndex`,
1275
+ path: ["staggerIndex"]
1276
+ });
1277
+ }
1278
+ const seenProps = /* @__PURE__ */ new Set();
1279
+ for (const track of clip.tracks) {
1280
+ if (seenProps.has(track.property)) {
1281
+ ctx.addIssue({
1282
+ code: z.ZodIssueCode.custom,
1283
+ message: `clip "${clip.id}" has duplicate track for property "${track.property}"`
1284
+ });
1285
+ }
1286
+ seenProps.add(track.property);
1287
+ }
1288
+ });
1289
+ var ScreenStaggerSchema = z.object({
1290
+ /** Per-index delay multiplier in ms. */
1291
+ stepMs: z.number().int().min(0).max(2e3)
1292
+ }).strict();
1293
+
1294
+ // src/screens.ts
1295
+ var ScreenNextSchema = z.object({
1296
+ default: FlowJumpTargetSchema
1297
+ });
1298
+ var ScreenRegionsSchema = z.object({
1299
+ header: StackLayerSchema.optional(),
1300
+ body: StackLayerSchema,
1301
+ footer: StackLayerSchema.optional()
1302
+ });
1303
+ var ScreenContainerStyleSchema = z.object({
1304
+ padding: PaddingSchema.optional(),
1305
+ margin: PaddingSchema.optional(),
1306
+ /** When true, runtimes add device safe-area insets to shell padding (in addition to manual padding). */
1307
+ insetSafeArea: z.boolean().optional(),
1308
+ backgroundFill: ScreenBackgroundFillSchema.optional()
1309
+ }).partial();
1310
+ z.object({
1311
+ id: ScreenIdSchema,
1312
+ name: z.string().min(1).max(80),
1313
+ regions: ScreenRegionsSchema,
1314
+ next: ScreenNextSchema,
1315
+ /** Ordered animation clips bound to layers on this screen. */
1316
+ animations: z.array(AnimationClipSchema).optional(),
1317
+ /** Defaults for clips with `trigger: stagger`. */
1318
+ stagger: ScreenStaggerSchema.optional(),
1319
+ /** Chrome on the outer screen container (wraps all regions). */
1320
+ containerStyle: ScreenContainerStyleSchema.optional(),
1321
+ containerStyleBreakpoints: ScreenContainerStyleBreakpointsSchema
1322
+ });
1323
+ var walkScreenLayers = (screen, fn) => {
1324
+ const visit = (l) => {
1325
+ fn(l);
1326
+ if (l.kind === "stack") l.children.forEach(visit);
1327
+ else if (l.kind === "carousel") l.slides.forEach(visit);
1328
+ else if (l.kind === "button") l.children.forEach(visit);
1329
+ else if (l.kind === "back_button") l.children.forEach(visit);
1330
+ else if (l.kind === "hyperlink") l.children.forEach(visit);
1331
+ else if (l.kind === "single_choice" || l.kind === "multiple_choice") {
1332
+ l.children.forEach(visit);
1333
+ } else if (l.kind === "text_input" || l.kind === "scale_input") {
1334
+ l.children?.forEach(visit);
1335
+ } else if (l.kind === "oauth_login") {
1336
+ l.children.forEach(visit);
1337
+ } else if (l.kind === "oauth_provider" && l.variant === "custom") {
1338
+ l.children.forEach(visit);
1339
+ } else if (l.kind === "email_password_auth") {
1340
+ l.children.forEach(visit);
1341
+ } else if (l.kind === "email_password_field") {
1342
+ l.children?.forEach(visit);
1343
+ } else if (l.kind === "email_password_submit") {
1344
+ l.children.forEach(visit);
1345
+ }
1346
+ };
1347
+ if (screen.regions.header) visit(screen.regions.header);
1348
+ visit(screen.regions.body);
1349
+ if (screen.regions.footer) visit(screen.regions.footer);
1350
+ };
1351
+
1352
+ // src/canvasEditorGates.ts
1353
+ var CANVAS_EDITOR_GATE_KEYS = [
1354
+ "lottie",
1355
+ "oauthLogin",
1356
+ "oauthProviderPreset",
1357
+ "oauthProviderCustom",
1358
+ "emailPasswordAuth",
1359
+ "emailPasswordField",
1360
+ "emailPasswordSubmit",
1361
+ "requestOsPermission"
1362
+ ];
1363
+ var CanvasEditorGatesResolvedSchema = z.object({
1364
+ lottie: z.boolean(),
1365
+ oauthLogin: z.boolean(),
1366
+ oauthProviderPreset: z.boolean(),
1367
+ oauthProviderCustom: z.boolean(),
1368
+ emailPasswordAuth: z.boolean(),
1369
+ emailPasswordField: z.boolean(),
1370
+ emailPasswordSubmit: z.boolean(),
1371
+ requestOsPermission: z.boolean()
1372
+ });
1373
+ var ALL_TRUE = {
1374
+ lottie: true,
1375
+ oauthLogin: true,
1376
+ oauthProviderPreset: true,
1377
+ oauthProviderCustom: true,
1378
+ emailPasswordAuth: true,
1379
+ emailPasswordField: true,
1380
+ emailPasswordSubmit: true,
1381
+ requestOsPermission: true
1382
+ };
1383
+ var CanvasEditorGatesPatchSchema = z.object({
1384
+ lottie: z.boolean().optional(),
1385
+ oauthLogin: z.boolean().optional(),
1386
+ oauthProviderPreset: z.boolean().optional(),
1387
+ oauthProviderCustom: z.boolean().optional(),
1388
+ emailPasswordAuth: z.boolean().optional(),
1389
+ emailPasswordField: z.boolean().optional(),
1390
+ emailPasswordSubmit: z.boolean().optional(),
1391
+ requestOsPermission: z.boolean().optional()
1392
+ }).strict();
1393
+ var parseCanvasEditorGates = (raw) => {
1394
+ if (raw == null) return { ...ALL_TRUE };
1395
+ const parsed = CanvasEditorGatesPatchSchema.safeParse(raw);
1396
+ if (!parsed.success) return { ...ALL_TRUE };
1397
+ return { ...ALL_TRUE, ...parsed.data };
1398
+ };
1399
+ var layerViolationMessage = (screenId, layerId, label) => `Screen "${screenId}": ${label} (layer "${layerId}") is disabled for this app in canvas editor settings.`;
1400
+ var buttonOsPermissionMessage = (screenId, layerId) => `Screen "${screenId}": request OS permission button actions are disabled for this app (layer "${layerId}").`;
1401
+ var collectCanvasGateViolations = (manifest, gates) => {
1402
+ const issues = [];
1403
+ for (const screen of manifest.screens) {
1404
+ walkScreenLayers(screen, (l) => {
1405
+ if ((l.kind === "lottie" || l.kind === "video") && !gates.lottie) {
1406
+ issues.push(
1407
+ layerViolationMessage(
1408
+ screen.id,
1409
+ l.id,
1410
+ l.kind === "video" ? "Video layers" : "Lottie layers"
1411
+ )
1412
+ );
1413
+ }
1414
+ if (l.kind === "oauth_login" && !gates.oauthLogin) {
1415
+ issues.push(layerViolationMessage(screen.id, l.id, "OAuth login layers"));
1416
+ }
1417
+ if (l.kind === "oauth_provider") {
1418
+ if (l.variant === "preset" && !gates.oauthProviderPreset) {
1419
+ issues.push(layerViolationMessage(screen.id, l.id, "OAuth provider (preset) layers"));
1420
+ }
1421
+ if (l.variant === "custom" && !gates.oauthProviderCustom) {
1422
+ issues.push(layerViolationMessage(screen.id, l.id, "OAuth provider (custom) layers"));
1423
+ }
1424
+ }
1425
+ if (l.kind === "email_password_auth" && !gates.emailPasswordAuth) {
1426
+ issues.push(layerViolationMessage(screen.id, l.id, "Email/password auth layers"));
1427
+ }
1428
+ if (l.kind === "email_password_field" && !gates.emailPasswordField) {
1429
+ issues.push(layerViolationMessage(screen.id, l.id, "Email/password field layers"));
1430
+ }
1431
+ if (l.kind === "email_password_submit" && !gates.emailPasswordSubmit) {
1432
+ issues.push(layerViolationMessage(screen.id, l.id, "Email/password submit layers"));
1433
+ }
1434
+ if (l.kind === "button" && l.action.kind === "request_os_permission" && !gates.requestOsPermission) {
1435
+ issues.push(buttonOsPermissionMessage(screen.id, l.id));
1436
+ }
1437
+ });
1438
+ }
1439
+ return issues;
1440
+ };
1441
+ var manifestPassesCanvasGates = (manifest, gates) => collectCanvasGateViolations(manifest, gates).length === 0;
1442
+ var describeCanvasGatesForAi = (gates) => {
1443
+ const disabled = [];
1444
+ if (!gates.lottie) disabled.push("do not use lottie or video layers");
1445
+ if (!gates.oauthLogin) disabled.push("do not use oauth_login layers");
1446
+ if (!gates.oauthProviderPreset) disabled.push("do not use oauth_provider with variant preset");
1447
+ if (!gates.oauthProviderCustom) disabled.push("do not use oauth_provider with variant custom");
1448
+ if (!gates.emailPasswordAuth) disabled.push("do not use email_password_auth layers");
1449
+ if (!gates.emailPasswordField) disabled.push("do not use email_password_field layers");
1450
+ if (!gates.emailPasswordSubmit) disabled.push("do not use email_password_submit layers");
1451
+ if (!gates.requestOsPermission) disabled.push("do not use button actions with kind request_os_permission");
1452
+ if (disabled.length === 0) {
1453
+ return "Canvas editor: all advanced layer types and OS permission button actions are allowed.";
1454
+ }
1455
+ return `Canvas editor restrictions for this app \u2014 ${disabled.join("; ")}.`;
1456
+ };
1457
+
1458
+ export { CANVAS_EDITOR_GATE_KEYS, CanvasEditorGatesPatchSchema, CanvasEditorGatesResolvedSchema, collectCanvasGateViolations, describeCanvasGatesForAi, manifestPassesCanvasGates, parseCanvasEditorGates };
1459
+ //# sourceMappingURL=canvasEditorGates.js.map
1460
+ //# sourceMappingURL=canvasEditorGates.js.map