@palmyit/elements 0.1.3 → 0.1.8

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