@palmyit/elements 0.0.0-stage → 0.1.7

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 (60) hide show
  1. package/README.md +12 -2
  2. package/dist/definitions.d.ts +51 -0
  3. package/dist/definitions.js +1737 -0
  4. package/dist/manifest.json +7 -0
  5. package/dist/plmt-elements.css +2 -0
  6. package/dist/plmt-elements.js +0 -0
  7. package/dist/registry.d.ts +9 -0
  8. package/dist/render/renderHtml.d.ts +5 -0
  9. package/dist/render/styleToVars.d.ts +2 -0
  10. package/dist/render/tags.d.ts +42 -0
  11. package/dist/render/toDom.d.ts +3 -0
  12. package/dist/render/types.d.ts +14 -0
  13. package/dist/schema/Fields/BackgroundField/backgroundValue.d.ts +15 -0
  14. package/dist/schema/Fields/ColorField/color-value.d.ts +6 -0
  15. package/dist/schema/Fields/ColorField/index.d.ts +1 -0
  16. package/dist/schema/Fields/FontStyleField.d.ts +2 -0
  17. package/dist/schema/Fields/IconPicker/iconCatalog.d.ts +3 -0
  18. package/dist/schema/PButton/pButton.definition.d.ts +38 -0
  19. package/dist/schema/PCheckbox/pCheckbox.definition.d.ts +10 -0
  20. package/dist/schema/PContainer/pContainer.definition.d.ts +39 -0
  21. package/dist/schema/PDivider/pDivider.definition.d.ts +10 -0
  22. package/dist/schema/PIcon/pIcon.definition.d.ts +18 -0
  23. package/dist/schema/PImage/pImage.definition.d.ts +33 -0
  24. package/dist/schema/PList/pList.definition.d.ts +11 -0
  25. package/dist/schema/PPage/pPage.definition.d.ts +22 -0
  26. package/dist/schema/PRadio/pRadio.definition.d.ts +13 -0
  27. package/dist/schema/PRichText/pRichText.definition.d.ts +8 -0
  28. package/dist/schema/PRichText/richTextMarks.d.ts +4 -0
  29. package/dist/schema/PRichText/richTextOptions.d.ts +2 -0
  30. package/dist/schema/PSection/pSection.definition.d.ts +39 -0
  31. package/dist/schema/PSelect/pSelect.definition.d.ts +13 -0
  32. package/dist/schema/PTable/pTable.definition.d.ts +20 -0
  33. package/dist/schema/PText/pText.definition.d.ts +46 -0
  34. package/dist/schema/PTextArea/pTextArea.definition.d.ts +10 -0
  35. package/dist/schema/PTextField/pTextField.definition.d.ts +10 -0
  36. package/dist/schema/PVideo/pVideo.definition.d.ts +10 -0
  37. package/dist/schema/addressSchema.d.ts +3 -0
  38. package/dist/schema/backgroundStyleDefinitions.d.ts +15 -0
  39. package/dist/schema/device/deviceStyle.d.ts +13 -0
  40. package/dist/schema/device/devices.d.ts +21 -0
  41. package/dist/schema/deviceSettings.d.ts +13 -0
  42. package/dist/schema/deviceVisibility.d.ts +19 -0
  43. package/dist/schema/elementConfiguration.d.ts +38 -0
  44. package/dist/schema/elementRegistry.d.ts +40 -0
  45. package/dist/schema/elementStyleDefinitions.d.ts +24 -0
  46. package/dist/schema/elementTemplates.d.ts +26 -0
  47. package/dist/schema/layoutChildren.d.ts +2 -0
  48. package/dist/schema/layoutElementConfiguration.d.ts +17 -0
  49. package/dist/schema/linkSettings.d.ts +26 -0
  50. package/dist/schema/style/backgroundStyle.d.ts +5 -0
  51. package/dist/schema/style/elementStyle.d.ts +62 -0
  52. package/dist/schema/style/page-styles.d.ts +3 -0
  53. package/dist/schema/styleItems.d.ts +53 -0
  54. package/dist/schema/textItems.d.ts +10 -0
  55. package/dist/tags.json +19 -0
  56. package/dist/templates/elementSpec.d.ts +15 -0
  57. package/dist/templates/helpers.d.ts +9 -0
  58. package/dist/templates.d.ts +11 -0
  59. package/dist/templates.js +269 -0
  60. package/package.json +67 -4
@@ -0,0 +1,1737 @@
1
+ import { z as e } from "zod";
2
+ // src/schema/elementConfiguration.ts
3
+ var t = e.string().trim().min(1);
4
+ function n(e) {
5
+ return e;
6
+ }
7
+ var r = /^[#0-9a-z%.,\s()-]+$/i, i = /url|var|image|expression|attr/i;
8
+ function a(e) {
9
+ let t = e.trim();
10
+ return t !== "" && t.length <= 200 && r.test(t) && !i.test(t);
11
+ }
12
+ function o(e) {
13
+ if (a(e.value)) return `${e.kind}-gradient(${e.value.trim()})`;
14
+ }
15
+ // src/schema/backgroundStyleDefinitions.ts
16
+ var s = e.strictObject({
17
+ hex: e.string().regex(/^#[0-9A-Fa-f]{6}$/, "Expected a #RRGGBB color"),
18
+ opacity: e.number().int().min(0).max(100)
19
+ }), c = e.strictObject({
20
+ kind: e.enum(["linear", "radial"]),
21
+ value: e.string().refine(a, "Expected gradient arguments such as 135deg, #2563EB, #7C3AED")
22
+ });
23
+ function l(t, { defaults: n, typeAttribute: r } = {}) {
24
+ return [
25
+ {
26
+ key: "backgroundType",
27
+ ...r ? { attribute: r } : {},
28
+ value: e.enum(["color", "gradient"]),
29
+ defaultValue: n?.backgroundType,
30
+ label: "Background type"
31
+ },
32
+ {
33
+ key: "backgroundColor",
34
+ variable: `${t}-background-color`,
35
+ value: s,
36
+ defaultValue: n?.backgroundColor,
37
+ label: "Background color"
38
+ },
39
+ {
40
+ key: "backgroundGradient",
41
+ variable: `${t}-background-image`,
42
+ value: c,
43
+ defaultValue: n?.backgroundGradient,
44
+ label: "Background gradient"
45
+ }
46
+ ];
47
+ }
48
+ // src/schema/device/devices.ts
49
+ var u = [
50
+ {
51
+ name: "Desktop",
52
+ icon: "Monitor",
53
+ portrait: {
54
+ width: 1280,
55
+ height: "auto"
56
+ }
57
+ },
58
+ {
59
+ name: "Tablet",
60
+ icon: "Tablet",
61
+ portrait: {
62
+ width: 768,
63
+ height: "auto"
64
+ },
65
+ landscape: {
66
+ width: 1024,
67
+ height: 768
68
+ }
69
+ },
70
+ {
71
+ name: "Mobile",
72
+ icon: "Smartphone",
73
+ portrait: {
74
+ width: 360,
75
+ height: "auto"
76
+ },
77
+ landscape: {
78
+ width: 640,
79
+ height: 360
80
+ }
81
+ }
82
+ ], ee = u.map(({ portrait: e, icon: t, name: n }) => ({
83
+ ...e,
84
+ icon: t,
85
+ label: n
86
+ }));
87
+ function te(e) {
88
+ return u.find((t) => t.portrait.width === e || t.landscape?.width === e) ?? u[0];
89
+ }
90
+ function ne(e) {
91
+ return te(e).landscape?.width === e ? "landscape" : "portrait";
92
+ }
93
+ // src/schema/deviceVisibility.ts
94
+ var d = {
95
+ Desktop: "showOnDesktop",
96
+ Tablet: "showOnTablet",
97
+ Mobile: "showOnMobile"
98
+ }, f = {
99
+ Tablet: "showOnTabletLandscape",
100
+ Mobile: "showOnMobileLandscape"
101
+ }, re = [...Object.values(d), ...Object.values(f)], p = u.flatMap(({ name: e, landscape: t }) => t ? [{
102
+ device: e,
103
+ orientation: "portrait"
104
+ }, {
105
+ device: e,
106
+ orientation: "landscape"
107
+ }] : [{
108
+ device: e,
109
+ orientation: "portrait"
110
+ }]);
111
+ function m(e, t) {
112
+ return (t === "landscape" ? f[e] : void 0) ?? d[e];
113
+ }
114
+ function h(e, t, n = "portrait") {
115
+ let r = e[m(t, n)];
116
+ return r === void 0 ? e[d[t]] !== !1 : r;
117
+ }
118
+ function ie(e) {
119
+ return p.filter(({ device: t, orientation: n }) => h(e, t, n)).length;
120
+ }
121
+ // src/schema/styleItems.ts
122
+ var ae = e.strictObject({
123
+ key: e.string(),
124
+ variable: e.string().optional(),
125
+ variables: e.record(e.string(), e.string()).optional(),
126
+ attribute: e.string().optional(),
127
+ value: e.unknown()
128
+ }), oe = [
129
+ "variable",
130
+ "variables",
131
+ "attribute"
132
+ ];
133
+ function se(e) {
134
+ let t = {};
135
+ for (let n of e) n.defaultValue !== void 0 && (t[n.key] = n.defaultValue);
136
+ return t;
137
+ }
138
+ function ce(e, t) {
139
+ return oe.find((n) => JSON.stringify(e[n]) !== JSON.stringify(t[n]));
140
+ }
141
+ function le(e, t, n) {
142
+ if (!t) return {
143
+ field: "key",
144
+ message: `Unknown style key "${e.key}"`
145
+ };
146
+ if (n.has(e.key)) return {
147
+ field: "key",
148
+ message: `Style key "${e.key}" appears twice`
149
+ };
150
+ let r = ce(e, t);
151
+ if (r) return {
152
+ field: r,
153
+ message: `Style "${e.key}" ${r} does not match the element configuration`
154
+ };
155
+ }
156
+ function g(e) {
157
+ return de(e, () => se(e));
158
+ }
159
+ function ue(e) {
160
+ return de(e, () => ({}));
161
+ }
162
+ function de(t, n) {
163
+ let r = new Map(t.map((e) => [e.key, e]));
164
+ return e.array(ae).default([]).transform((e, t) => {
165
+ let i = n(), a = /* @__PURE__ */ new Set();
166
+ return e.forEach((e, n) => {
167
+ let o = r.get(e.key), s = le(e, o, a);
168
+ if (s || !o) {
169
+ t.addIssue({
170
+ code: "custom",
171
+ path: [n, s?.field ?? "key"],
172
+ message: s?.message ?? ""
173
+ });
174
+ return;
175
+ }
176
+ a.add(e.key);
177
+ let c = o.value.safeParse(e.value);
178
+ if (c.success) i[e.key] = c.data;
179
+ else {
180
+ let e = c.error.issues[0]?.message ?? "Invalid value";
181
+ t.addIssue({
182
+ code: "custom",
183
+ path: [n, "value"],
184
+ message: e
185
+ });
186
+ }
187
+ }), i;
188
+ });
189
+ }
190
+ function fe(e, t) {
191
+ let n = Object.fromEntries(oe.filter((t) => e[t] !== void 0).map((t) => [t, e[t]]));
192
+ return {
193
+ key: e.key,
194
+ ...n,
195
+ value: t
196
+ };
197
+ }
198
+ function _(e, t = "") {
199
+ return Object.fromEntries(e.flatMap(({ key: e, label: n }) => n === void 0 ? [] : [[`${t}${e}`, n]]));
200
+ }
201
+ function v(e, t) {
202
+ return me({
203
+ ...se(t),
204
+ ...e
205
+ }, t);
206
+ }
207
+ function pe(e, t) {
208
+ return me(e ?? {}, t);
209
+ }
210
+ function me(e, t) {
211
+ return t.filter((t) => e[t.key] !== void 0).map((t) => fe(t, e[t.key]));
212
+ }
213
+ // src/schema/deviceSettings.ts
214
+ var y = [
215
+ {
216
+ prop: "tabletStyle",
217
+ device: "Tablet"
218
+ },
219
+ {
220
+ prop: "mobileStyle",
221
+ device: "Mobile"
222
+ },
223
+ {
224
+ prop: "tabletLandscapeStyle",
225
+ device: "Landscape tablet"
226
+ },
227
+ {
228
+ prop: "mobileLandscapeStyle",
229
+ device: "Landscape mobile"
230
+ }
231
+ ], he = {
232
+ showOnDesktop: "Show on desktop",
233
+ showOnTablet: "Show on portrait tablet",
234
+ showOnTabletLandscape: "Show on landscape tablet",
235
+ showOnMobile: "Show on portrait mobile",
236
+ showOnMobileLandscape: "Show on landscape mobile"
237
+ }, ge = Object.fromEntries(re.map((t) => [t, e.boolean().optional()]));
238
+ function _e(t) {
239
+ let n = t ? Object.fromEntries(y.map(({ prop: e }) => [e, ue(t).optional()])) : {};
240
+ return e.strictObject({
241
+ ...ge,
242
+ ...n
243
+ }).refine((e) => ie(e) > 0, {
244
+ path: ["showOnDesktop"],
245
+ message: "Show the element on at least one device"
246
+ });
247
+ }
248
+ function ve(e, t, n) {
249
+ return Object.fromEntries(Object.entries(e).filter(([e]) => t.has(e) === n));
250
+ }
251
+ function ye(t, n) {
252
+ let r = new Set(Object.keys(n.shape));
253
+ return e.record(e.string(), e.unknown()).transform((i, a) => {
254
+ let o = t.safeParse(ve(i, r, !1)), s = n.safeParse(ve(i, r, !0));
255
+ for (let e of [...o.error?.issues ?? [], ...s.error?.issues ?? []]) a.addIssue({
256
+ code: "custom",
257
+ path: e.path,
258
+ message: e.message
259
+ });
260
+ return !o.success || !s.success ? e.NEVER : {
261
+ ...o.data,
262
+ ...be(s.data)
263
+ };
264
+ });
265
+ }
266
+ function be(e) {
267
+ return Object.fromEntries(Object.entries(e).filter(([, e]) => !xe(e)));
268
+ }
269
+ function xe(e) {
270
+ return e === void 0 || typeof e == "object" && !!e && Object.keys(e).length === 0;
271
+ }
272
+ function Se(e) {
273
+ return Object.fromEntries(p.flatMap(({ device: t, orientation: n }) => {
274
+ let r = h(e, t, n);
275
+ return (n === "portrait" ? !r : r !== h(e, t, "portrait")) ? [[m(t, n), r]] : [];
276
+ }));
277
+ }
278
+ function Ce(e, t) {
279
+ return Object.fromEntries(y.flatMap(({ prop: n }) => {
280
+ let r = pe(e[n], t);
281
+ return r.length > 0 ? [[n, r]] : [];
282
+ }));
283
+ }
284
+ function we(e) {
285
+ return `${e.charAt(0).toLowerCase()}${e.slice(1)}`;
286
+ }
287
+ function Te(e) {
288
+ return Object.fromEntries(y.flatMap(({ prop: t, device: n }) => Object.entries(_(e, `${t}.`)).map(([e, t]) => [e, `${n} ${we(t)}`])));
289
+ }
290
+ function b(e, t) {
291
+ return {
292
+ ...e,
293
+ attributes: ye(e.attributes, _e(t)),
294
+ toDocumentAttributes: (n) => ({
295
+ ...e.toDocumentAttributes(n),
296
+ ...Se(n),
297
+ ...t ? Ce(n, t) : {}
298
+ }),
299
+ history: {
300
+ summary: e.history.summary,
301
+ attributes: {
302
+ ...e.history.attributes,
303
+ ...he,
304
+ ...t ? Te(t) : {}
305
+ }
306
+ }
307
+ };
308
+ }
309
+ // src/schema/addressSchema.ts
310
+ var Ee = "Enter an https:// address or a path that starts with /";
311
+ function De(e) {
312
+ if (e.startsWith("/")) return !e.startsWith("//") && !e.startsWith("/\\");
313
+ try {
314
+ let { protocol: t } = new URL(e);
315
+ return t === "https:" || t === "http:";
316
+ } catch {
317
+ return !1;
318
+ }
319
+ }
320
+ var x = e.string().trim().min(1, Ee).refine(De, Ee), Oe = ["_self", "_blank"], S = {
321
+ href: "",
322
+ target: "_self",
323
+ description: ""
324
+ }, C = {
325
+ href: e.string().trim().pipe(e.union([e.literal(""), x])).default(S.href),
326
+ target: e.enum(Oe).default(S.target),
327
+ description: e.string().trim().default(S.description)
328
+ }, w = {
329
+ href: "Link address",
330
+ target: "Link target",
331
+ description: "Link description"
332
+ };
333
+ function T({ href: e, target: t, description: n }) {
334
+ return e === "" ? {} : {
335
+ href: e,
336
+ ...t === S.target ? {} : { target: t },
337
+ ...n === "" ? {} : { description: n }
338
+ };
339
+ }
340
+ // src/schema/PRichText/richTextMarks.ts
341
+ var ke = /^[A-Za-z0-9][A-Za-z0-9 ]*$/;
342
+ function E(e) {
343
+ return typeof e == "string" && ke.test(e);
344
+ }
345
+ // src/schema/style/page-styles.ts
346
+ var Ae = /^#[0-9A-Fa-f]{6}$/;
347
+ function je(e) {
348
+ return Ae.test(e) ? [
349
+ Number.parseInt(e.slice(1, 3), 16),
350
+ Number.parseInt(e.slice(3, 5), 16),
351
+ Number.parseInt(e.slice(5, 7), 16)
352
+ ] : null;
353
+ }
354
+ function D(e) {
355
+ let t = je(e.hex);
356
+ if (!t || !Number.isFinite(e.opacity)) return;
357
+ if (e.opacity === 100) return e.hex.toUpperCase();
358
+ let n = Math.min(100, Math.max(0, e.opacity)) / 100, [r, i, a] = t;
359
+ return `rgba(${r}, ${i}, ${a}, ${n})`;
360
+ }
361
+ function Me(e) {
362
+ if (!(!Number.isFinite(e) || e <= 0)) return `${e}px`;
363
+ }
364
+ // src/schema/style/backgroundStyle.ts
365
+ function Ne(e) {
366
+ if (e.backgroundType === "gradient") return "transparent";
367
+ if (e.backgroundColor) return D(e.backgroundColor);
368
+ }
369
+ function Pe(e) {
370
+ if (e.backgroundType !== "gradient") return "none";
371
+ if (e.backgroundGradient) return o(e.backgroundGradient);
372
+ }
373
+ function Fe(e, t) {
374
+ return e.backgroundType ? {
375
+ [`${t}-background-color`]: Ne(e),
376
+ [`${t}-background-image`]: Pe(e)
377
+ } : {};
378
+ }
379
+ // src/schema/style/elementStyle.ts
380
+ var O = [
381
+ "none",
382
+ "solid",
383
+ "dashed",
384
+ "dotted",
385
+ "double"
386
+ ], Ie = [
387
+ "row",
388
+ "column",
389
+ "row-reverse",
390
+ "column-reverse"
391
+ ], Le = [
392
+ "nowrap",
393
+ "wrap",
394
+ "wrap-reverse"
395
+ ], k = [
396
+ "flex-start",
397
+ "center",
398
+ "flex-end",
399
+ "space-between",
400
+ "space-around",
401
+ "space-evenly"
402
+ ], Re = [
403
+ "stretch",
404
+ "flex-start",
405
+ "center",
406
+ "flex-end",
407
+ "baseline"
408
+ ], ze = ["stretch", ...k], A = {
409
+ layout: "block",
410
+ flexDirection: "row",
411
+ flexWrap: "nowrap",
412
+ justifyContent: "flex-start",
413
+ alignItems: "stretch",
414
+ alignContent: "stretch",
415
+ rowGap: "0",
416
+ columnGap: "0",
417
+ backgroundType: "color",
418
+ backgroundColor: {
419
+ hex: "#FFFFFF",
420
+ opacity: 0
421
+ },
422
+ backgroundGradient: {
423
+ kind: "linear",
424
+ value: "135deg, #2563EB, #7C3AED"
425
+ },
426
+ overflow: "show",
427
+ overflowVertical: !0,
428
+ overflowHorizontal: !0,
429
+ width: "auto",
430
+ height: "auto",
431
+ minWidth: "auto",
432
+ minHeight: "auto",
433
+ maxWidth: "auto",
434
+ maxHeight: "auto",
435
+ paddingTop: "auto",
436
+ paddingBottom: "auto",
437
+ paddingLeft: "auto",
438
+ paddingRight: "auto",
439
+ marginTop: "0",
440
+ marginBottom: "0",
441
+ marginLeft: "0",
442
+ marginRight: "0",
443
+ borderRadiusTopLeft: "0",
444
+ borderRadiusTopRight: "0",
445
+ borderRadiusBottomRight: "0",
446
+ borderRadiusBottomLeft: "0",
447
+ borderWidth: "0",
448
+ borderStyle: "solid",
449
+ borderColor: {
450
+ hex: "#000000",
451
+ opacity: 100
452
+ }
453
+ }, Be = /^(auto|0|-?\d+(\.\d+)?(px|rem|em|%))$/i, Ve = /^(0|\d+(\.\d+)?(px|rem|em))$/i;
454
+ function j(e) {
455
+ let t = e.trim();
456
+ if (Be.test(t)) return t;
457
+ }
458
+ function M(e) {
459
+ let t = j(e);
460
+ if (t != null) return t.toLowerCase() === "auto" ? "0" : t;
461
+ }
462
+ function N(e) {
463
+ let t = j(e);
464
+ return t?.toLowerCase() === "auto" ? "none" : t;
465
+ }
466
+ function He(e) {
467
+ let t = e.trim();
468
+ return Ve.test(t) ? t : void 0;
469
+ }
470
+ function Ue(e, t) {
471
+ return e === "hide" ? "hidden" : t ? "auto" : "hidden";
472
+ }
473
+ var We = [
474
+ "marginTop",
475
+ "marginBottom",
476
+ "marginLeft",
477
+ "marginRight"
478
+ ];
479
+ function Ge(e) {
480
+ return e.trim().toLowerCase() === "auto";
481
+ }
482
+ function P(e, t) {
483
+ return We.every((t) => Ge(e[t])) ? "0" : j(e[t]);
484
+ }
485
+ function Ke(e) {
486
+ return e.layout !== "grid" || e.gridColumns == null ? "none" : `repeat(${e.gridColumns}, minmax(0, 1fr))`;
487
+ }
488
+ function qe(e, t) {
489
+ let n = {
490
+ ...A,
491
+ ...e
492
+ }, r = `--palmyit-${t}`;
493
+ return {
494
+ [`${r}-display`]: n.layout,
495
+ [`${r}-grid-template-columns`]: Ke(n),
496
+ [`${r}-flex-direction`]: n.flexDirection,
497
+ [`${r}-flex-wrap`]: n.flexWrap,
498
+ [`${r}-justify-content`]: n.justifyContent,
499
+ [`${r}-align-items`]: n.alignItems,
500
+ [`${r}-align-content`]: n.alignContent,
501
+ [`${r}-row-gap`]: M(n.rowGap),
502
+ [`${r}-column-gap`]: M(n.columnGap),
503
+ [`${r}-overflow-x`]: Ue(n.overflow, n.overflowHorizontal),
504
+ [`${r}-overflow-y`]: Ue(n.overflow, n.overflowVertical),
505
+ [`${r}-width`]: j(n.width),
506
+ [`${r}-height`]: j(n.height),
507
+ [`${r}-min-width`]: j(n.minWidth),
508
+ [`${r}-min-height`]: j(n.minHeight),
509
+ [`${r}-max-width`]: N(n.maxWidth),
510
+ [`${r}-max-height`]: N(n.maxHeight),
511
+ [`${r}-padding-top`]: M(n.paddingTop),
512
+ [`${r}-padding-bottom`]: M(n.paddingBottom),
513
+ [`${r}-padding-left`]: M(n.paddingLeft),
514
+ [`${r}-padding-right`]: M(n.paddingRight),
515
+ [`${r}-margin-top`]: P(n, "marginTop"),
516
+ [`${r}-margin-bottom`]: P(n, "marginBottom"),
517
+ [`${r}-margin-left`]: P(n, "marginLeft"),
518
+ [`${r}-margin-right`]: P(n, "marginRight"),
519
+ [`${r}-border-top-left-radius`]: M(n.borderRadiusTopLeft),
520
+ [`${r}-border-top-right-radius`]: M(n.borderRadiusTopRight),
521
+ [`${r}-border-bottom-right-radius`]: M(n.borderRadiusBottomRight),
522
+ [`${r}-border-bottom-left-radius`]: M(n.borderRadiusBottomLeft),
523
+ [`${r}-border-width`]: He(n.borderWidth),
524
+ [`${r}-border-style`]: n.borderStyle,
525
+ [`${r}-border-color`]: D(n.borderColor),
526
+ ...Fe(n, r)
527
+ };
528
+ }
529
+ // src/schema/elementStyleDefinitions.ts
530
+ var F = e.string().trim().regex(Be, "Expected auto, 0, or a px, rem, em, or % length"), I = [
531
+ [
532
+ "width",
533
+ "width",
534
+ "Width"
535
+ ],
536
+ [
537
+ "height",
538
+ "height",
539
+ "Height"
540
+ ],
541
+ [
542
+ "minWidth",
543
+ "min-width",
544
+ "Min width"
545
+ ],
546
+ [
547
+ "minHeight",
548
+ "min-height",
549
+ "Min height"
550
+ ],
551
+ [
552
+ "maxWidth",
553
+ "max-width",
554
+ "Max width"
555
+ ],
556
+ [
557
+ "maxHeight",
558
+ "max-height",
559
+ "Max height"
560
+ ],
561
+ [
562
+ "paddingTop",
563
+ "padding-top",
564
+ "Padding top"
565
+ ],
566
+ [
567
+ "paddingBottom",
568
+ "padding-bottom",
569
+ "Padding bottom"
570
+ ],
571
+ [
572
+ "paddingLeft",
573
+ "padding-left",
574
+ "Padding left"
575
+ ],
576
+ [
577
+ "paddingRight",
578
+ "padding-right",
579
+ "Padding right"
580
+ ],
581
+ [
582
+ "marginTop",
583
+ "margin-top",
584
+ "Margin top"
585
+ ],
586
+ [
587
+ "marginBottom",
588
+ "margin-bottom",
589
+ "Margin bottom"
590
+ ],
591
+ [
592
+ "marginLeft",
593
+ "margin-left",
594
+ "Margin left"
595
+ ],
596
+ [
597
+ "marginRight",
598
+ "margin-right",
599
+ "Margin right"
600
+ ],
601
+ [
602
+ "borderRadiusTopLeft",
603
+ "border-top-left-radius",
604
+ "Radius top left"
605
+ ],
606
+ [
607
+ "borderRadiusTopRight",
608
+ "border-top-right-radius",
609
+ "Radius top right"
610
+ ],
611
+ [
612
+ "borderRadiusBottomRight",
613
+ "border-bottom-right-radius",
614
+ "Radius bottom right"
615
+ ],
616
+ [
617
+ "borderRadiusBottomLeft",
618
+ "border-bottom-left-radius",
619
+ "Radius bottom left"
620
+ ]
621
+ ];
622
+ function Je(t) {
623
+ let n = `--palmyit-${t}`, r = {
624
+ key: "gridColumns",
625
+ variable: `${n}-grid-template-columns`,
626
+ value: e.union([
627
+ e.literal(2),
628
+ e.literal(3),
629
+ e.literal(4)
630
+ ]),
631
+ label: "Grid columns"
632
+ };
633
+ return [
634
+ {
635
+ key: "layout",
636
+ variable: `${n}-display`,
637
+ attribute: "data-layout",
638
+ value: e.enum([
639
+ "block",
640
+ "flex",
641
+ "grid"
642
+ ]),
643
+ defaultValue: "block",
644
+ label: "Layout"
645
+ },
646
+ r,
647
+ ...Ye(t)
648
+ ];
649
+ }
650
+ function Ye(t) {
651
+ let n = `--palmyit-${t}`;
652
+ return [
653
+ {
654
+ key: "flexDirection",
655
+ variable: `${n}-flex-direction`,
656
+ value: e.enum(Ie),
657
+ defaultValue: A.flexDirection,
658
+ label: "Direction"
659
+ },
660
+ {
661
+ key: "flexWrap",
662
+ variable: `${n}-flex-wrap`,
663
+ value: e.enum(Le),
664
+ defaultValue: A.flexWrap,
665
+ label: "Wrap"
666
+ },
667
+ {
668
+ key: "justifyContent",
669
+ variable: `${n}-justify-content`,
670
+ value: e.enum(k),
671
+ defaultValue: A.justifyContent,
672
+ label: "Justify"
673
+ },
674
+ {
675
+ key: "alignItems",
676
+ variable: `${n}-align-items`,
677
+ value: e.enum(Re),
678
+ defaultValue: A.alignItems,
679
+ label: "Align items"
680
+ },
681
+ {
682
+ key: "alignContent",
683
+ variable: `${n}-align-content`,
684
+ value: e.enum(ze),
685
+ defaultValue: A.alignContent,
686
+ label: "Align content"
687
+ },
688
+ {
689
+ key: "rowGap",
690
+ variable: `${n}-row-gap`,
691
+ value: F,
692
+ defaultValue: A.rowGap,
693
+ label: "Row gap"
694
+ },
695
+ {
696
+ key: "columnGap",
697
+ variable: `${n}-column-gap`,
698
+ value: F,
699
+ defaultValue: A.columnGap,
700
+ label: "Column gap"
701
+ }
702
+ ];
703
+ }
704
+ function Xe(t, n) {
705
+ let r = `--palmyit-${t}`;
706
+ return [
707
+ {
708
+ key: "overflow",
709
+ variables: {
710
+ x: `${r}-overflow-x`,
711
+ y: `${r}-overflow-y`
712
+ },
713
+ value: e.enum(["show", "hide"]),
714
+ defaultValue: n.overflow,
715
+ label: "Overflowing contents"
716
+ },
717
+ {
718
+ key: "overflowHorizontal",
719
+ variable: `${r}-overflow-x`,
720
+ value: e.boolean(),
721
+ defaultValue: n.overflowHorizontal,
722
+ label: "Horizontal overflow"
723
+ },
724
+ {
725
+ key: "overflowVertical",
726
+ variable: `${r}-overflow-y`,
727
+ value: e.boolean(),
728
+ defaultValue: n.overflowVertical,
729
+ label: "Vertical overflow"
730
+ }
731
+ ];
732
+ }
733
+ function Ze(e, t) {
734
+ return I.map(([n, r, i]) => ({
735
+ key: n,
736
+ variable: `--palmyit-${e}-${r}`,
737
+ value: F,
738
+ defaultValue: t[n],
739
+ label: i
740
+ }));
741
+ }
742
+ function Qe(t, n) {
743
+ let r = `--palmyit-${t}`;
744
+ return [
745
+ {
746
+ key: "borderWidth",
747
+ variable: `${r}-border-width`,
748
+ value: F,
749
+ defaultValue: n.borderWidth,
750
+ label: "Border width"
751
+ },
752
+ {
753
+ key: "borderStyle",
754
+ variable: `${r}-border-style`,
755
+ value: e.enum(O),
756
+ defaultValue: n.borderStyle,
757
+ label: "Border style"
758
+ },
759
+ {
760
+ key: "borderColor",
761
+ variable: `${r}-border-color`,
762
+ value: s,
763
+ defaultValue: n.borderColor,
764
+ label: "Border color"
765
+ }
766
+ ];
767
+ }
768
+ function $e(e, t) {
769
+ return [
770
+ ...Je(e),
771
+ ...Xe(e, t),
772
+ ...Ze(e, t),
773
+ ...Qe(e, t),
774
+ ...l(`--palmyit-${e}`, { defaults: t })
775
+ ];
776
+ }
777
+ function et(e, t) {
778
+ return g(e).transform((e) => ({
779
+ ...t,
780
+ ...e
781
+ })).superRefine((e, t) => {
782
+ e.layout === "grid" && e.gridColumns == null && t.addIssue({
783
+ code: "custom",
784
+ path: ["gridColumns"],
785
+ message: "A grid layout needs 2, 3, or 4 columns"
786
+ });
787
+ });
788
+ }
789
+ // src/schema/Fields/IconPicker/iconCatalog.ts
790
+ var tt = /^MdOutline[A-Z0-9]/, nt = "";
791
+ function L(e) {
792
+ return tt.test(e);
793
+ }
794
+ function rt(e) {
795
+ return e.replace(/^MdOutline/, "").replace(/([a-z0-9])([A-Z])/g, "$1 $2");
796
+ }
797
+ // src/schema/PButton/pButton.definition.ts
798
+ var it = {
799
+ name: "Button",
800
+ startIcon: "",
801
+ endIcon: "",
802
+ ...S,
803
+ style: {}
804
+ }, at = e.string().refine((e) => e === "" || L(e), "Expected an outlined Material icon name such as MdOutlineHome").default("");
805
+ function ot(e, t) {
806
+ return t === "" ? {} : { [e]: t };
807
+ }
808
+ var R = "--palmyit-button", z = [
809
+ ...l(R, { typeAttribute: "data-background" }),
810
+ {
811
+ key: "borderWidth",
812
+ variable: `${R}-border-width`,
813
+ value: F,
814
+ label: "Border width"
815
+ },
816
+ {
817
+ key: "borderStyle",
818
+ variable: `${R}-border-style`,
819
+ value: e.enum(O),
820
+ label: "Border style"
821
+ },
822
+ {
823
+ key: "borderColor",
824
+ variable: `${R}-border-color`,
825
+ value: s,
826
+ label: "Border color"
827
+ },
828
+ ...I.map(([e, t, n]) => ({
829
+ key: e,
830
+ variable: `${R}-${t}`,
831
+ value: F,
832
+ label: n
833
+ })),
834
+ {
835
+ key: "textColor",
836
+ variable: `${R}-text-color`,
837
+ value: s,
838
+ label: "Text color"
839
+ },
840
+ {
841
+ key: "textFont",
842
+ variable: `${R}-font-family`,
843
+ value: e.string().refine(E, "Expected a Google Fonts family name"),
844
+ label: "Font"
845
+ },
846
+ {
847
+ key: "textSize",
848
+ variable: `${R}-font-size`,
849
+ value: F,
850
+ label: "Text size"
851
+ },
852
+ {
853
+ key: "iconGap",
854
+ variable: `${R}-gap`,
855
+ value: F,
856
+ label: "Icon gap"
857
+ }
858
+ ], st = b(n({
859
+ type: "PButton",
860
+ label: "Button",
861
+ allowedChildren: [],
862
+ templates: [],
863
+ attributes: e.strictObject({
864
+ id: t,
865
+ name: e.string().trim().min(1, "Enter a button label").default(it.name),
866
+ startIcon: at,
867
+ endIcon: at,
868
+ ...C,
869
+ style: g(z).transform((e) => e)
870
+ }),
871
+ toDocumentAttributes: ({ id: e, name: t, startIcon: n, endIcon: r, href: i, target: a, description: o, style: s }) => ({
872
+ id: e,
873
+ name: t,
874
+ ...ot("startIcon", n),
875
+ ...ot("endIcon", r),
876
+ ...T({
877
+ href: i,
878
+ target: a,
879
+ description: o
880
+ }),
881
+ style: v(s, z)
882
+ }),
883
+ history: {
884
+ summary: ({ name: e }) => e,
885
+ attributes: {
886
+ name: "Label",
887
+ startIcon: "Start icon",
888
+ endIcon: "End icon",
889
+ ...w,
890
+ ..._(z, "style.")
891
+ }
892
+ }
893
+ }), z), B = {
894
+ label: "Checkbox",
895
+ checked: !1
896
+ }, ct = b(n({
897
+ type: "PCheckbox",
898
+ label: "Checkbox input",
899
+ allowedChildren: [],
900
+ templates: [],
901
+ attributes: e.strictObject({
902
+ id: t,
903
+ label: e.string().trim().min(1, "Enter a label").default(B.label),
904
+ checked: e.boolean().default(B.checked)
905
+ }),
906
+ toDocumentAttributes: ({ id: e, label: t, checked: n }) => ({
907
+ id: e,
908
+ label: t,
909
+ checked: n
910
+ }),
911
+ history: {
912
+ summary: ({ label: e }) => e,
913
+ attributes: {
914
+ label: "Label",
915
+ checked: "Checked"
916
+ }
917
+ }
918
+ }));
919
+ // src/schema/layoutElementConfiguration.ts
920
+ function V({ type: r, label: i, kind: a, defaultStyle: o, allowedChildren: s, templates: c }) {
921
+ let l = $e(a, o);
922
+ return b(n({
923
+ type: r,
924
+ label: i,
925
+ allowedChildren: s,
926
+ templates: c,
927
+ attributes: e.strictObject({
928
+ id: t,
929
+ style: et(l, o)
930
+ }),
931
+ toDocumentAttributes: ({ id: e, style: t }) => ({
932
+ id: e,
933
+ style: v(t, l)
934
+ }),
935
+ history: {
936
+ summary: () => i,
937
+ attributes: _(l, "style.")
938
+ }
939
+ }), l);
940
+ }
941
+ // src/schema/layoutChildren.ts
942
+ var H = [
943
+ "PContainer",
944
+ "PButton",
945
+ "PText",
946
+ "PRichText",
947
+ "PImage",
948
+ "PVideo",
949
+ "PList",
950
+ "PIcon",
951
+ "PDivider",
952
+ "PTable",
953
+ "PTextField",
954
+ "PTextArea",
955
+ "PCheckbox",
956
+ "PRadio",
957
+ "PSelect"
958
+ ], lt = { ...A }, ut = V({
959
+ type: "PContainer",
960
+ label: "Container",
961
+ kind: "container",
962
+ defaultStyle: lt,
963
+ allowedChildren: H,
964
+ templates: []
965
+ }), dt = [
966
+ "1",
967
+ "2",
968
+ "3",
969
+ "4"
970
+ ], ft = { size: "4" }, pt = b(n({
971
+ type: "PDivider",
972
+ label: "Divider",
973
+ allowedChildren: [],
974
+ templates: [],
975
+ attributes: e.strictObject({
976
+ id: t,
977
+ size: e.enum(dt).default(ft.size)
978
+ }),
979
+ toDocumentAttributes: ({ id: e, size: t }) => ({
980
+ id: e,
981
+ size: t
982
+ }),
983
+ history: {
984
+ summary: () => "",
985
+ attributes: { size: "Width" }
986
+ }
987
+ })), U = {
988
+ icon: "MdOutlineStarBorder",
989
+ label: "Icon",
990
+ ...S
991
+ }, mt = b(n({
992
+ type: "PIcon",
993
+ label: "Icon",
994
+ allowedChildren: [],
995
+ templates: [],
996
+ attributes: e.strictObject({
997
+ id: t,
998
+ icon: e.string().refine(L, "Choose an outlined Material icon such as MdOutlineHome").default(U.icon),
999
+ label: e.string().trim().default(U.label),
1000
+ ...C
1001
+ }).refine(({ href: e, label: t }) => e === "" || t !== "", {
1002
+ path: ["label"],
1003
+ message: "Describe a linked icon so the link has a name"
1004
+ }),
1005
+ toDocumentAttributes: ({ id: e, icon: t, label: n, href: r, target: i, description: a }) => ({
1006
+ id: e,
1007
+ icon: t,
1008
+ label: n,
1009
+ ...T({
1010
+ href: r,
1011
+ target: i,
1012
+ description: a
1013
+ })
1014
+ }),
1015
+ history: {
1016
+ summary: ({ icon: e, label: t }) => t || rt(e),
1017
+ attributes: {
1018
+ icon: "Icon",
1019
+ label: "Description",
1020
+ ...w
1021
+ }
1022
+ }
1023
+ })), ht = [
1024
+ "width",
1025
+ "height",
1026
+ "minWidth",
1027
+ "minHeight",
1028
+ "maxWidth",
1029
+ "maxHeight"
1030
+ ], gt = [
1031
+ "borderRadiusTopLeft",
1032
+ "borderRadiusTopRight",
1033
+ "borderRadiusBottomRight",
1034
+ "borderRadiusBottomLeft"
1035
+ ], _t = [...ht, ...gt], W = {
1036
+ src: "/image-placeholder.svg",
1037
+ alt: "Image",
1038
+ style: {},
1039
+ ...S
1040
+ }, G = "--palmyit-image";
1041
+ function vt(e) {
1042
+ return I.filter(([t]) => e.includes(t)).map(([e, t, n]) => ({
1043
+ key: e,
1044
+ variable: `${G}-${t}`,
1045
+ value: F,
1046
+ label: n
1047
+ }));
1048
+ }
1049
+ var K = [
1050
+ ...vt(ht),
1051
+ ...l(G, { typeAttribute: "data-background" }),
1052
+ {
1053
+ key: "borderWidth",
1054
+ variable: `${G}-border-width`,
1055
+ value: F,
1056
+ label: "Border width"
1057
+ },
1058
+ {
1059
+ key: "borderStyle",
1060
+ variable: `${G}-border-style`,
1061
+ value: e.enum(O),
1062
+ label: "Border style"
1063
+ },
1064
+ {
1065
+ key: "borderColor",
1066
+ variable: `${G}-border-color`,
1067
+ value: s,
1068
+ label: "Border color"
1069
+ },
1070
+ ...vt(gt)
1071
+ ], yt = b(n({
1072
+ type: "PImage",
1073
+ label: "Image",
1074
+ allowedChildren: [],
1075
+ templates: [],
1076
+ attributes: e.strictObject({
1077
+ id: t,
1078
+ src: x.default(W.src),
1079
+ alt: e.string().trim().default(W.alt),
1080
+ style: g(K).transform((e) => e),
1081
+ ...C
1082
+ }).refine(({ href: e, alt: t }) => e === "" || t !== "", {
1083
+ path: ["alt"],
1084
+ message: "Describe a linked image so the link has a name"
1085
+ }),
1086
+ toDocumentAttributes: ({ id: e, src: t, alt: n, style: r, href: i, target: a, description: o }) => ({
1087
+ id: e,
1088
+ src: t,
1089
+ alt: n,
1090
+ style: v(r, K),
1091
+ ...T({
1092
+ href: i,
1093
+ target: a,
1094
+ description: o
1095
+ })
1096
+ }),
1097
+ history: {
1098
+ summary: ({ alt: e }) => e,
1099
+ attributes: {
1100
+ src: "Image address",
1101
+ alt: "Description",
1102
+ ...w,
1103
+ ..._(K, "style.")
1104
+ }
1105
+ }
1106
+ }), K);
1107
+ // src/schema/textItems.ts
1108
+ function q(t, n) {
1109
+ return e.array(e.strictObject({ text: e.string().trim().min(1, n) })).min(1, t);
1110
+ }
1111
+ function J(e) {
1112
+ return e.map(({ text: e }) => ({ text: e }));
1113
+ }
1114
+ // src/schema/PList/pList.definition.ts
1115
+ var bt = { items: [
1116
+ { text: "First item" },
1117
+ { text: "Second item" },
1118
+ { text: "Third item" }
1119
+ ] }, xt = b(n({
1120
+ type: "PList",
1121
+ label: "List",
1122
+ allowedChildren: [],
1123
+ templates: [],
1124
+ attributes: e.strictObject({
1125
+ id: t,
1126
+ items: q("Add a list item", "Enter item text").default(bt.items)
1127
+ }),
1128
+ toDocumentAttributes: ({ id: e, items: t }) => ({
1129
+ id: e,
1130
+ items: J(t)
1131
+ }),
1132
+ history: {
1133
+ summary: ({ items: e }) => e[0]?.text ?? "",
1134
+ attributes: { items: "Items" }
1135
+ }
1136
+ })), St = /^\/([a-z0-9]+(-[a-z0-9]+)*)?$/, Ct = e.strictObject({
1137
+ hex: e.string().regex(/^#[0-9A-Fa-f]{6}$/, "Expected a #RRGGBB color"),
1138
+ opacity: e.number().int().min(0).max(100)
1139
+ }), Y = {
1140
+ backgroundColor: {
1141
+ hex: "#FFFFFF",
1142
+ opacity: 100
1143
+ },
1144
+ textColor: {
1145
+ hex: "#0F172A",
1146
+ opacity: 100
1147
+ },
1148
+ textSize: 14
1149
+ }, X = [
1150
+ {
1151
+ key: "backgroundColor",
1152
+ variable: "--palmyit-page-background-color",
1153
+ value: Ct,
1154
+ defaultValue: Y.backgroundColor,
1155
+ label: "Background color"
1156
+ },
1157
+ {
1158
+ key: "textColor",
1159
+ variable: "--palmyit-page-text-color",
1160
+ value: Ct,
1161
+ defaultValue: Y.textColor,
1162
+ label: "Text color"
1163
+ },
1164
+ {
1165
+ key: "textSize",
1166
+ variable: "--palmyit-page-font-size",
1167
+ value: e.number().min(1).max(200),
1168
+ defaultValue: Y.textSize,
1169
+ label: "Text size"
1170
+ }
1171
+ ], wt = X.map(({ key: e }) => e), Tt = n({
1172
+ type: "PPage",
1173
+ label: "Page",
1174
+ allowedChildren: ["PSection"],
1175
+ templates: [],
1176
+ attributes: e.strictObject({
1177
+ id: t,
1178
+ url: e.string().regex(St, "Expected / or a lowercase path such as /about-us"),
1179
+ title: e.string().default(""),
1180
+ style: g(X)
1181
+ }).transform(({ id: e, url: t, title: n, style: r }) => ({
1182
+ pageId: e,
1183
+ url: t,
1184
+ title: n,
1185
+ ...r
1186
+ })),
1187
+ toDocumentAttributes: ({ pageId: e, url: t, title: n, ...r }) => ({
1188
+ id: e,
1189
+ url: t,
1190
+ title: n,
1191
+ style: v(r, X)
1192
+ }),
1193
+ history: {
1194
+ summary: ({ title: e, url: t }) => e || t,
1195
+ attributes: {
1196
+ title: "Title",
1197
+ url: "URL",
1198
+ ..._(X)
1199
+ }
1200
+ }
1201
+ }), Et = {
1202
+ legend: "Choose one",
1203
+ options: [{ text: "Option 1" }, { text: "Option 2" }]
1204
+ }, Dt = b(n({
1205
+ type: "PRadio",
1206
+ label: "Radio input",
1207
+ allowedChildren: [],
1208
+ templates: [],
1209
+ attributes: e.strictObject({
1210
+ id: t,
1211
+ legend: e.string().trim().min(1, "Enter a question").default(Et.legend),
1212
+ options: q("Add an option", "Enter option text").default(Et.options)
1213
+ }),
1214
+ toDocumentAttributes: ({ id: e, legend: t, options: n }) => ({
1215
+ id: e,
1216
+ legend: t,
1217
+ options: J(n)
1218
+ }),
1219
+ history: {
1220
+ summary: ({ legend: e }) => e,
1221
+ attributes: {
1222
+ legend: "Question",
1223
+ options: "Options"
1224
+ }
1225
+ }
1226
+ })), Ot = { ...A }, kt = V({
1227
+ type: "PSection",
1228
+ label: "Section",
1229
+ kind: "section",
1230
+ defaultStyle: Ot,
1231
+ allowedChildren: H,
1232
+ templates: []
1233
+ }), At = {
1234
+ label: "Select",
1235
+ options: [{ text: "Option 1" }, { text: "Option 2" }]
1236
+ }, jt = b(n({
1237
+ type: "PSelect",
1238
+ label: "Select",
1239
+ allowedChildren: [],
1240
+ templates: [],
1241
+ attributes: e.strictObject({
1242
+ id: t,
1243
+ label: e.string().trim().min(1, "Enter a label").default(At.label),
1244
+ options: q("Add an option", "Enter option text").default(At.options)
1245
+ }),
1246
+ toDocumentAttributes: ({ id: e, label: t, options: n }) => ({
1247
+ id: e,
1248
+ label: t,
1249
+ options: J(n)
1250
+ }),
1251
+ history: {
1252
+ summary: ({ label: e }) => e,
1253
+ attributes: {
1254
+ label: "Label",
1255
+ options: "Options"
1256
+ }
1257
+ }
1258
+ })), Mt = {
1259
+ headers: [
1260
+ { text: "Column 1" },
1261
+ { text: "Column 2" },
1262
+ { text: "Column 3" }
1263
+ ],
1264
+ rows: [{ cells: [
1265
+ "Cell 1",
1266
+ "Cell 2",
1267
+ "Cell 3"
1268
+ ] }, { cells: [
1269
+ "Cell 4",
1270
+ "Cell 5",
1271
+ "Cell 6"
1272
+ ] }]
1273
+ };
1274
+ function Nt(e, t) {
1275
+ return t.map(({ cells: t }) => ({ cells: Array.from({ length: e }, (e, n) => t[n] ?? "") }));
1276
+ }
1277
+ var Pt = e.strictObject({ cells: e.array(e.string()) }), Ft = b(n({
1278
+ type: "PTable",
1279
+ label: "Table",
1280
+ allowedChildren: [],
1281
+ templates: [],
1282
+ attributes: e.strictObject({
1283
+ id: t,
1284
+ headers: q("Add a column", "Enter a column heading").default(Mt.headers),
1285
+ rows: e.array(Pt).default(Mt.rows)
1286
+ }).superRefine(({ headers: e, rows: t }, n) => {
1287
+ t.forEach(({ cells: t }, r) => {
1288
+ t.length !== e.length && n.addIssue({
1289
+ code: "custom",
1290
+ path: [
1291
+ "rows",
1292
+ r,
1293
+ "cells"
1294
+ ],
1295
+ message: "Give each row one cell per column"
1296
+ });
1297
+ });
1298
+ }),
1299
+ toDocumentAttributes: ({ id: e, headers: t, rows: n }) => ({
1300
+ id: e,
1301
+ headers: J(t),
1302
+ rows: n.map(({ cells: e }) => ({ cells: [...e] }))
1303
+ }),
1304
+ history: {
1305
+ summary: ({ headers: e }) => e[0]?.text ?? "",
1306
+ attributes: {
1307
+ headers: "Column headings",
1308
+ rows: "Rows"
1309
+ }
1310
+ }
1311
+ })), It = /<[^>]*>/g;
1312
+ function Lt(e) {
1313
+ let t = e.trim();
1314
+ return t.includes("<") ? t : `<p>${t}</p>`;
1315
+ }
1316
+ function Rt(e) {
1317
+ return e.replace(It, " ").replace(/&nbsp;/g, " ").replace(/&amp;/g, "&").replace(/\s+/g, " ").trim();
1318
+ }
1319
+ // src/schema/PRichText/pRichText.definition.ts
1320
+ var zt = { text: "<p>Add your main text here. Double-click to edit and customize your content to make it selectable.</p>" }, Bt = b(n({
1321
+ type: "PRichText",
1322
+ label: "Rich text",
1323
+ allowedChildren: [],
1324
+ templates: [],
1325
+ attributes: e.strictObject({
1326
+ id: t,
1327
+ text: e.string().transform(Lt).refine((e) => Rt(e).trim().length > 0, "Enter text").default(zt.text)
1328
+ }),
1329
+ toDocumentAttributes: ({ id: e, text: t }) => ({
1330
+ id: e,
1331
+ text: Lt(t)
1332
+ }),
1333
+ history: {
1334
+ summary: ({ text: e }) => Rt(e),
1335
+ attributes: { text: "Text" }
1336
+ }
1337
+ })), Vt = [
1338
+ "normal",
1339
+ "italic",
1340
+ "oblique"
1341
+ ], Ht = [
1342
+ "none",
1343
+ "underline",
1344
+ "overline",
1345
+ "line-through"
1346
+ ], Ut = [
1347
+ "left",
1348
+ "center",
1349
+ "right",
1350
+ "justify"
1351
+ ], Wt = [
1352
+ "none",
1353
+ "capitalize",
1354
+ "uppercase",
1355
+ "lowercase"
1356
+ ], Gt = [
1357
+ "100",
1358
+ "200",
1359
+ "300",
1360
+ "400",
1361
+ "500",
1362
+ "600",
1363
+ "700",
1364
+ "800",
1365
+ "900"
1366
+ ], Kt = {
1367
+ text: "Text",
1368
+ ...S,
1369
+ style: {}
1370
+ }, qt = "--palmyit-text";
1371
+ function Jt(t) {
1372
+ return [
1373
+ {
1374
+ key: "textFont",
1375
+ variable: `${t}-font-family`,
1376
+ value: e.string().refine(E, "Expected a Google Fonts family name"),
1377
+ label: "Font family"
1378
+ },
1379
+ {
1380
+ key: "fontStyle",
1381
+ variable: `${t}-font-style`,
1382
+ value: e.enum(Vt),
1383
+ label: "Text style"
1384
+ },
1385
+ {
1386
+ key: "textSize",
1387
+ variable: `${t}-font-size`,
1388
+ value: F,
1389
+ label: "Text size"
1390
+ },
1391
+ {
1392
+ key: "textColor",
1393
+ variable: `${t}-color`,
1394
+ value: s,
1395
+ label: "Text color"
1396
+ },
1397
+ {
1398
+ key: "lineHeight",
1399
+ variable: `${t}-line-height`,
1400
+ value: F,
1401
+ label: "Height"
1402
+ },
1403
+ {
1404
+ key: "letterSpacing",
1405
+ variable: `${t}-letter-spacing`,
1406
+ value: F,
1407
+ label: "Letter spacing"
1408
+ },
1409
+ {
1410
+ key: "wordSpacing",
1411
+ variable: `${t}-word-spacing`,
1412
+ value: F,
1413
+ label: "Word spacing"
1414
+ },
1415
+ {
1416
+ key: "textDecoration",
1417
+ variable: `${t}-text-decoration`,
1418
+ value: e.enum(Ht),
1419
+ label: "Text decoration"
1420
+ },
1421
+ {
1422
+ key: "textAlign",
1423
+ variable: `${t}-text-align`,
1424
+ value: e.enum(Ut),
1425
+ label: "Text align"
1426
+ },
1427
+ {
1428
+ key: "textTransform",
1429
+ variable: `${t}-text-transform`,
1430
+ value: e.enum(Wt),
1431
+ label: "Text transform"
1432
+ },
1433
+ {
1434
+ key: "fontWeight",
1435
+ variable: `${t}-font-weight`,
1436
+ value: e.enum(Gt),
1437
+ label: "Text weight"
1438
+ }
1439
+ ];
1440
+ }
1441
+ var Z = Jt(qt), Yt = b(n({
1442
+ type: "PText",
1443
+ label: "Text",
1444
+ allowedChildren: [],
1445
+ templates: [],
1446
+ attributes: e.strictObject({
1447
+ id: t,
1448
+ text: e.string().trim().min(1, "Enter text").default(Kt.text),
1449
+ ...C,
1450
+ style: g(Z).transform((e) => e)
1451
+ }),
1452
+ toDocumentAttributes: ({ id: e, text: t, href: n, target: r, description: i, style: a }) => ({
1453
+ id: e,
1454
+ text: t,
1455
+ ...T({
1456
+ href: n,
1457
+ target: r,
1458
+ description: i
1459
+ }),
1460
+ style: v(a, Z)
1461
+ }),
1462
+ history: {
1463
+ summary: ({ text: e }) => e,
1464
+ attributes: {
1465
+ text: "Text",
1466
+ ...w,
1467
+ ..._(Z, "style.")
1468
+ }
1469
+ }
1470
+ }), Z), Xt = {
1471
+ label: "Text area",
1472
+ placeholder: ""
1473
+ }, Zt = b(n({
1474
+ type: "PTextArea",
1475
+ label: "Text area",
1476
+ allowedChildren: [],
1477
+ templates: [],
1478
+ attributes: e.strictObject({
1479
+ id: t,
1480
+ label: e.string().trim().min(1, "Enter a label").default(Xt.label),
1481
+ placeholder: e.string().default(Xt.placeholder)
1482
+ }),
1483
+ toDocumentAttributes: ({ id: e, label: t, placeholder: n }) => ({
1484
+ id: e,
1485
+ label: t,
1486
+ placeholder: n
1487
+ }),
1488
+ history: {
1489
+ summary: ({ label: e }) => e,
1490
+ attributes: {
1491
+ label: "Label",
1492
+ placeholder: "Placeholder"
1493
+ }
1494
+ }
1495
+ })), Qt = {
1496
+ label: "Text field",
1497
+ placeholder: ""
1498
+ }, $t = b(n({
1499
+ type: "PTextField",
1500
+ label: "Text field",
1501
+ allowedChildren: [],
1502
+ templates: [],
1503
+ attributes: e.strictObject({
1504
+ id: t,
1505
+ label: e.string().trim().min(1, "Enter a label").default(Qt.label),
1506
+ placeholder: e.string().default(Qt.placeholder)
1507
+ }),
1508
+ toDocumentAttributes: ({ id: e, label: t, placeholder: n }) => ({
1509
+ id: e,
1510
+ label: t,
1511
+ placeholder: n
1512
+ }),
1513
+ history: {
1514
+ summary: ({ label: e }) => e,
1515
+ attributes: {
1516
+ label: "Label",
1517
+ placeholder: "Placeholder"
1518
+ }
1519
+ }
1520
+ })), en = {
1521
+ src: "",
1522
+ title: "Video"
1523
+ }, tn = b(n({
1524
+ type: "PVideo",
1525
+ label: "Video",
1526
+ allowedChildren: [],
1527
+ templates: [],
1528
+ attributes: e.strictObject({
1529
+ id: t,
1530
+ src: e.union([e.literal(""), x]).default(en.src),
1531
+ title: e.string().trim().min(1, "Enter a video title").default(en.title)
1532
+ }),
1533
+ toDocumentAttributes: ({ id: e, src: t, title: n }) => ({
1534
+ id: e,
1535
+ src: t,
1536
+ title: n
1537
+ }),
1538
+ history: {
1539
+ summary: ({ title: e }) => e,
1540
+ attributes: {
1541
+ src: "Video address",
1542
+ title: "Title"
1543
+ }
1544
+ }
1545
+ })), Q = {
1546
+ PPage: Tt,
1547
+ PSection: kt,
1548
+ PContainer: ut,
1549
+ PButton: st,
1550
+ PText: Yt,
1551
+ PRichText: Bt,
1552
+ PImage: yt,
1553
+ PVideo: tn,
1554
+ PList: xt,
1555
+ PIcon: mt,
1556
+ PDivider: pt,
1557
+ PTextField: $t,
1558
+ PTextArea: Zt,
1559
+ PCheckbox: ct,
1560
+ PRadio: Dt,
1561
+ PSelect: jt,
1562
+ PTable: Ft
1563
+ };
1564
+ function nn(e) {
1565
+ return typeof e == "string" && Object.hasOwn(Q, e);
1566
+ }
1567
+ // src/schema/elementTemplates.ts
1568
+ function rn(e) {
1569
+ return typeof e == "object" && !!e && !Array.isArray(e);
1570
+ }
1571
+ function an(e) {
1572
+ try {
1573
+ let t = JSON.parse(e);
1574
+ return rn(t) ? t : void 0;
1575
+ } catch {
1576
+ return;
1577
+ }
1578
+ }
1579
+ function on(e) {
1580
+ return Array.isArray(e) ? e : [];
1581
+ }
1582
+ function sn(e, t) {
1583
+ let n = new Map(on(e).map((e) => [e.key, e]));
1584
+ for (let e of on(t)) n.set(e.key, {
1585
+ ...n.get(e.key),
1586
+ ...e
1587
+ });
1588
+ return [...n.values()];
1589
+ }
1590
+ function cn(e, t) {
1591
+ let n = {
1592
+ ...e,
1593
+ ...t,
1594
+ id: e.id
1595
+ };
1596
+ return "style" in t && (n.style = sn(e.style, t.style)), n;
1597
+ }
1598
+ function ln(e, t) {
1599
+ if (!Array.isArray(t)) return {
1600
+ ok: !1,
1601
+ message: "Expected a list of children"
1602
+ };
1603
+ let n = [];
1604
+ for (let r of t) {
1605
+ let t = un(e, r);
1606
+ if (!t.ok) return t;
1607
+ n.push(t.item);
1608
+ }
1609
+ return {
1610
+ ok: !0,
1611
+ content: n
1612
+ };
1613
+ }
1614
+ function un(e, t) {
1615
+ if (!rn(t)) return {
1616
+ ok: !1,
1617
+ message: "Expected an element object"
1618
+ };
1619
+ let n = t.type;
1620
+ if (!nn(n)) return {
1621
+ ok: !1,
1622
+ message: `Unknown element type "${String(n)}"`
1623
+ };
1624
+ if (!Q[e].allowedChildren.includes(n)) return {
1625
+ ok: !1,
1626
+ message: `${n} is not allowed inside ${e}`
1627
+ };
1628
+ let { children: r, type: i, ...a } = t, o = Q[n];
1629
+ if (r !== void 0 && o.allowedChildren.length === 0) return {
1630
+ ok: !1,
1631
+ message: `${n} cannot have children`
1632
+ };
1633
+ let s = o.attributes.safeParse(a);
1634
+ if (!s.success) return {
1635
+ ok: !1,
1636
+ message: s.error.issues[0]?.message ?? "Invalid template"
1637
+ };
1638
+ let c = { ...s.data };
1639
+ if (o.allowedChildren.length === 0) return {
1640
+ ok: !0,
1641
+ item: {
1642
+ type: n,
1643
+ props: c
1644
+ }
1645
+ };
1646
+ let l = r === void 0 ? {
1647
+ ok: !0,
1648
+ content: []
1649
+ } : ln(n, r);
1650
+ return l.ok ? {
1651
+ ok: !0,
1652
+ item: {
1653
+ type: n,
1654
+ props: {
1655
+ ...c,
1656
+ content: l.content
1657
+ }
1658
+ }
1659
+ } : l;
1660
+ }
1661
+ function dn(e, t, n) {
1662
+ let r = (e) => ({
1663
+ ok: !1,
1664
+ message: `Template "${n.name}": ${e}`
1665
+ }), i = an(n.shortcode);
1666
+ if (!i) return r("Expected a JSON object");
1667
+ let { children: a, type: o, ...s } = i, c = e.toDocumentAttributes(t), l = e.attributes.safeParse(cn(c, s));
1668
+ if (!l.success) return r(l.error.issues[0]?.message ?? "Invalid template");
1669
+ if (a === void 0) return {
1670
+ ok: !0,
1671
+ props: l.data
1672
+ };
1673
+ let u = ln(e.type, a);
1674
+ return u.ok ? {
1675
+ ok: !0,
1676
+ props: l.data,
1677
+ content: u.content
1678
+ } : r(u.message);
1679
+ }
1680
+ // src/schema/Fields/ColorField/color-value.ts
1681
+ var fn = /^#[0-9A-Fa-f]{6}$/, pn = /^#[0-9A-Fa-f]{8}$/;
1682
+ function mn(e) {
1683
+ return Math.min(100, Math.max(0, Math.round(e)));
1684
+ }
1685
+ function hn(e) {
1686
+ let t = e.hex.toUpperCase();
1687
+ if (!fn.test(t)) return "#000000FF";
1688
+ let n = mn(e.opacity);
1689
+ return `${t}${Math.round(n / 100 * 255).toString(16).padStart(2, "0").toUpperCase()}`;
1690
+ }
1691
+ function gn(e) {
1692
+ let t = e.trim().toUpperCase();
1693
+ return fn.test(t) ? {
1694
+ hex: t,
1695
+ opacity: 100
1696
+ } : pn.test(t) ? {
1697
+ hex: t.slice(0, 7),
1698
+ opacity: mn(Number.parseInt(t.slice(7, 9), 16) / 255 * 100)
1699
+ } : null;
1700
+ }
1701
+ // src/schema/device/deviceStyle.ts
1702
+ var _n = {
1703
+ Desktop: {
1704
+ portrait: "style",
1705
+ landscape: "style"
1706
+ },
1707
+ Tablet: {
1708
+ portrait: "tabletStyle",
1709
+ landscape: "tabletLandscapeStyle"
1710
+ },
1711
+ Mobile: {
1712
+ portrait: "mobileStyle",
1713
+ landscape: "mobileLandscapeStyle"
1714
+ }
1715
+ };
1716
+ function vn(e, t = "portrait") {
1717
+ return _n[e][t];
1718
+ }
1719
+ function $(e, t, n = "portrait") {
1720
+ let r = vn(t, n);
1721
+ return r === "style" ? {} : e[r] ?? {};
1722
+ }
1723
+ function yn(e, t) {
1724
+ return JSON.stringify(e) === JSON.stringify(t);
1725
+ }
1726
+ function bn(e, t) {
1727
+ return Object.fromEntries(Object.entries(t).filter(([t, n]) => n !== void 0 && !yn(n, e[t])));
1728
+ }
1729
+ function xn(e, t, n = "portrait") {
1730
+ let r = n === "landscape" ? $(e, t, "landscape") : {};
1731
+ return {
1732
+ ...e.style,
1733
+ ...$(e, t, "portrait"),
1734
+ ...r
1735
+ };
1736
+ }
1737
+ export { O as BORDER_LINE_STYLES, p as DEVICE_CHOICES, ze as FLEX_ALIGN_CONTENTS, Re as FLEX_ALIGN_ITEMS, Ie as FLEX_DIRECTIONS, k as FLEX_JUSTIFY_CONTENTS, Le as FLEX_WRAPS, Vt as FONT_STYLES, Gt as FONT_WEIGHTS, _t as IMAGE_LENGTH_KEYS, G as IMAGE_PREFIX, f as LANDSCAPE_VISIBILITY_PROP_BY_DEVICE, Be as LENGTH_PATTERN, nt as NO_ICON, Ut as TEXT_ALIGNS, Ht as TEXT_DECORATIONS, qt as TEXT_PREFIX, Wt as TEXT_TRANSFORMS, re as VISIBILITY_PROPS, d as VISIBILITY_PROP_BY_DEVICE, x as addressSchema, dn as applyElementTemplate, l as backgroundStyleDefinitions, Fe as backgroundStyleToCssVariables, u as builderDevices, ee as builderViewports, bn as changedStyle, s as colorValue, D as colorValueToCss, it as defaultButtonProps, B as defaultCheckboxProps, lt as defaultContainerStyle, ft as defaultDividerProps, A as defaultElementStyle, U as defaultIconProps, W as defaultImageProps, S as defaultLinkSettings, bt as defaultListProps, Y as defaultPageStyle, Et as defaultRadioProps, zt as defaultRichTextProps, Ot as defaultSectionStyle, At as defaultSelectProps, Mt as defaultTableProps, Xt as defaultTextAreaProps, Qt as defaultTextFieldProps, Kt as defaultTextProps, en as defaultVideoProps, n as defineElement, V as defineLayoutElement, te as deviceForWidth, $ as deviceOverride, vn as deviceStyleProp, t as elementIdSchema, Q as elementRegistry, $e as elementStyleDefinitions, et as elementStyleSchema, qe as elementStyleToCssVariables, Nt as fitRowsToHeaders, gn as fromHexAlpha, o as gradientToCss, nn as isElementType, E as isFontFamily, L as isOutlineIconName, a as isSafeGradientArgs, h as isShownOn, rt as labelForIcon, H as layoutChildren, I as lengthKeys, F as lengthValue, w as linkHistoryLabels, C as linkSettingsShape, Lt as normalizeRichText, ne as orientationForWidth, st as pButtonDefinition, ct as pCheckboxDefinition, ut as pContainerDefinition, pt as pDividerDefinition, mt as pIconDefinition, yt as pImageDefinition, xt as pListDefinition, Tt as pPageDefinition, Dt as pRadioDefinition, Bt as pRichTextDefinition, kt as pSectionDefinition, jt as pSelectDefinition, Ft as pTableDefinition, Zt as pTextAreaDefinition, Yt as pTextDefinition, $t as pTextFieldDefinition, tn as pVideoDefinition, wt as pageStyleKeys, xn as resolveDeviceStyle, Rt as richTextToPlainText, M as sanitizeAutoAsZero, He as sanitizeBorderWidth, j as sanitizeLength, N as sanitizeMaxLength, ie as shownDeviceCount, g as styleItemsSchema, _ as styleLabels, ue as styleOverrideItemsSchema, q as textItemsSchema, Me as textSizeToCss, Jt as textStyleDefinitions, hn as toHexAlpha, T as toLinkAttributes, v as toStyleItems, pe as toStyleOverrideItems, J as toTextItems, m as visibilityProp, b as withDeviceSettings };