@selfhelp/shared 1.21.3 → 1.21.6

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 (53) hide show
  1. package/CHANGELOG.md +106 -0
  2. package/README.md +2 -1
  3. package/dist/index.d.mts +519 -24
  4. package/dist/index.d.ts +519 -24
  5. package/dist/index.js +723 -18
  6. package/dist/index.mjs +674 -18
  7. package/dist/plugin-sdk/index.d.mts +1 -1
  8. package/dist/plugin-sdk/index.d.ts +1 -1
  9. package/dist/plugin-sdk/index.js +2 -1
  10. package/dist/plugin-sdk/index.mjs +2 -1
  11. package/dist/registry/index.d.mts +2 -2
  12. package/dist/registry/index.d.ts +2 -2
  13. package/dist/registry/index.js +2 -1
  14. package/dist/registry/index.mjs +2 -1
  15. package/dist/{styles.registry-DEDEZ8l3.d.ts → styles.registry-DX79oirw.d.ts} +93 -16
  16. package/dist/{styles.registry-DHM4M77N.d.mts → styles.registry-ffw0MH3r.d.mts} +93 -16
  17. package/package.json +1 -1
  18. package/src/api/__tests__/endpoints.test.ts +37 -12
  19. package/src/api/endpoints.ts +5 -5
  20. package/src/api/index.ts +1 -0
  21. package/src/api/pagesResolve.ts +78 -0
  22. package/src/content/__tests__/fieldsMapLabels.test.ts +55 -0
  23. package/src/content/__tests__/formRecordPrefill.test.ts +104 -0
  24. package/src/content/__tests__/optionLabels.test.ts +100 -0
  25. package/src/content/fieldsMapLabels.ts +103 -0
  26. package/src/content/formRecordPrefill.ts +191 -0
  27. package/src/content/index.ts +3 -0
  28. package/src/content/optionLabels.ts +200 -0
  29. package/src/navigation/__tests__/navigation.test.ts +296 -6
  30. package/src/navigation/activeTrail.ts +99 -0
  31. package/src/navigation/branchNav.ts +155 -6
  32. package/src/navigation/footerPreset.ts +109 -0
  33. package/src/navigation/headerLayers.ts +56 -0
  34. package/src/navigation/headerPreset.ts +9 -2
  35. package/src/navigation/index.ts +4 -0
  36. package/src/navigation/menuDepth.ts +73 -37
  37. package/src/navigation/mobileRoute.ts +25 -0
  38. package/src/navigation/navLinks.ts +0 -4
  39. package/src/navigation/navigationBundle.ts +81 -0
  40. package/src/navigation/navigationPayload.ts +96 -17
  41. package/src/registry/__tests__/platform.test.ts +11 -10
  42. package/src/registry/styles.registry.ts +2 -1
  43. package/src/types/__tests__/preview-bridge.test.ts +7 -0
  44. package/src/types/auth.ts +4 -0
  45. package/src/types/cms-app.ts +74 -0
  46. package/src/types/index.ts +1 -0
  47. package/src/types/mobile-adapters.ts +1 -0
  48. package/src/types/pages.ts +6 -0
  49. package/src/types/preview-bridge.ts +22 -2
  50. package/src/types/styles/composite.ts +21 -0
  51. package/src/types/styles/forms.ts +57 -10
  52. package/src/types/styles/interactive.ts +1 -1
  53. package/src/types/styles/unknown.ts +2 -2
package/dist/index.mjs CHANGED
@@ -9,6 +9,10 @@ var PERMISSIONS = {
9
9
  ADMIN_PAGE_VERSION_PUBLISH: "admin.page.version.publish",
10
10
  ADMIN_PAGE_VERSION_READ: "admin.page.version.read",
11
11
  ADMIN_PAGE_VERSION_COMPARE: "admin.page.version.compare",
12
+ ADMIN_CMS_APP_READ: "admin.cms_app.read",
13
+ ADMIN_CMS_APP_CREATE: "admin.cms_app.create",
14
+ ADMIN_CMS_APP_UPDATE: "admin.cms_app.update",
15
+ ADMIN_CMS_APP_DELETE: "admin.cms_app.delete",
12
16
  ADMIN_USER_READ: "admin.user.read",
13
17
  ADMIN_USER_CREATE: "admin.user.create",
14
18
  ADMIN_USER_UPDATE: "admin.user.update",
@@ -50,6 +54,23 @@ var PERMISSIONS = {
50
54
  ADMIN_AUDIT_VIEW: "admin.audit.view"
51
55
  };
52
56
 
57
+ // src/types/cms-app.ts
58
+ var CMS_APP_ROLES = [
59
+ "form",
60
+ "cms_list",
61
+ "cms_detail",
62
+ "public_list",
63
+ "public_detail",
64
+ "other"
65
+ ];
66
+ var CMS_APP_PRIMARY_ROLES = [
67
+ "form",
68
+ "cms_list",
69
+ "cms_detail",
70
+ "public_list",
71
+ "public_detail"
72
+ ];
73
+
53
74
  // src/types/api/system.ts
54
75
  var SYSTEM_PREFIX = "/cms-api/v1/admin/system";
55
76
  var SYSTEM_ENDPOINTS = {
@@ -120,9 +141,9 @@ function isPreviewBridgeMessage(value) {
120
141
  case PREVIEW_BRIDGE_MESSAGE.READY:
121
142
  return record.source === "web" || record.source === "mobile";
122
143
  case PREVIEW_BRIDGE_MESSAGE.NAVIGATED:
123
- return (record.source === "web" || record.source === "mobile") && (typeof record.keyword === "string" || record.keyword === null) && typeof record.href === "string";
144
+ return (record.source === "web" || record.source === "mobile") && (typeof record.keyword === "string" || record.keyword === null) && typeof record.href === "string" && (record.path === void 0 || record.path === null || typeof record.path === "string");
124
145
  case PREVIEW_BRIDGE_MESSAGE.NAVIGATE:
125
- return typeof record.keyword === "string" || record.keyword === null;
146
+ return (typeof record.keyword === "string" || record.keyword === null) && (record.path === void 0 || record.path === null || typeof record.path === "string");
126
147
  case PREVIEW_BRIDGE_MESSAGE.SET_PREFERENCES:
127
148
  return isPreviewPreferences(record.preferences);
128
149
  case PREVIEW_BRIDGE_MESSAGE.PREFERENCES_CHANGED:
@@ -208,6 +229,7 @@ var BASE_STYLE_REGISTRY = {
208
229
  // ===== forms =====
209
230
  "form-log": { description: "Append-only form (one row per submit)", category: "forms", canHaveChildren: true },
210
231
  "form-record": { description: "Per-user record form", category: "forms", canHaveChildren: true },
232
+ "entry-record-form": { description: "Route-aware create/edit form", category: "forms", canHaveChildren: true },
211
233
  input: { description: "Plain HTML input", category: "forms", canHaveChildren: false },
212
234
  "text-input": { description: "Mantine TextInput", category: "forms", canHaveChildren: false },
213
235
  textarea: { description: "Mantine Textarea", category: "forms", canHaveChildren: false },
@@ -249,7 +271,7 @@ var BASE_STYLE_REGISTRY = {
249
271
  version: { description: "Build/version diagnostic surface", category: "auth", canHaveChildren: false },
250
272
  "ref-container": { description: "Renders content referenced from another section", category: "layout", canHaveChildren: true },
251
273
  "data-container": { description: "Data-scoped container (renders subtree against a data scope)", category: "layout", canHaveChildren: true },
252
- "show-user-input": { description: "Displays previously submitted user input as a list/card view", category: "forms", canHaveChildren: false }
274
+ "entry-table": { description: "Built-in admin CRUD grid over a form's records (search/sort/paginate/CSV, add / edit / delete actions)", category: "forms", canHaveChildren: false }
253
275
  };
254
276
  var STYLE_REGISTRY = BASE_STYLE_REGISTRY;
255
277
  var PLUGIN_STYLE_REGISTRY = {};
@@ -393,11 +415,12 @@ var ENDPOINTS = {
393
415
  BY_KEYWORD: (keyword) => `${API_VERSION_PREFIX}/pages/by-keyword/${encodeURIComponent(keyword)}`,
394
416
  BY_ID: (pageId) => `${API_VERSION_PREFIX}/pages/${pageId}`,
395
417
  /**
396
- * DB-driven public path resolution (issue #30): maps a full public URL
397
- * path (e.g. `/reset/42/abc`, `/team/7`) to a page payload + route
398
- * params. `path` is sent URL-encoded as a query parameter.
418
+ * Static resolve route (no query). Always pair with
419
+ * {@link buildPagesResolveUrl} / {@link buildPagesResolvePath} so
420
+ * `path`, `language_id`, and `preview` are encoded identically across
421
+ * SSR, browser, and mobile.
399
422
  */
400
- RESOLVE: (path) => `${API_VERSION_PREFIX}/pages/resolve?path=${encodeURIComponent(path)}`
423
+ RESOLVE_ROUTE: `${API_VERSION_PREFIX}/pages/resolve`
401
424
  },
402
425
  NAVIGATION: {
403
426
  GET: `${API_VERSION_PREFIX}/navigation`,
@@ -419,6 +442,37 @@ var CLIENT_TYPE_WEB = "web";
419
442
  var CLIENT_TYPE_MOBILE = "mobile";
420
443
  var CLIENT_TYPE_MOBILE_AND_WEB = "mobile_and_web";
421
444
 
445
+ // src/api/pagesResolve.ts
446
+ function normalizePagesResolvePath(rawPath) {
447
+ const withoutOrigin = rawPath.includes("://") ? (() => {
448
+ try {
449
+ return new URL(rawPath).pathname;
450
+ } catch {
451
+ return rawPath;
452
+ }
453
+ })() : rawPath;
454
+ const pathOnly = withoutOrigin.split("#")[0].split("?")[0];
455
+ const withSlash = pathOnly.startsWith("/") ? pathOnly : `/${pathOnly}`;
456
+ return withSlash.replace(/\/+$/, "") || "/";
457
+ }
458
+ function buildPagesResolveQuery(params) {
459
+ const search = new URLSearchParams();
460
+ search.set("path", normalizePagesResolvePath(params.path));
461
+ if (params.languageId != null && Number.isFinite(params.languageId) && params.languageId > 0) {
462
+ search.set("language_id", String(params.languageId));
463
+ }
464
+ if (params.preview) {
465
+ search.set("preview", "true");
466
+ }
467
+ return search.toString();
468
+ }
469
+ function buildPagesResolvePath(params) {
470
+ return `/pages/resolve?${buildPagesResolveQuery(params)}`;
471
+ }
472
+ function buildPagesResolveUrl(params) {
473
+ return `${API_VERSION_PREFIX}${buildPagesResolvePath(params)}`;
474
+ }
475
+
422
476
  // src/theme/tokens.ts
423
477
  var FONT_SIZE_PX = {
424
478
  xs: 12,
@@ -1405,6 +1459,295 @@ function stripHtmlToText(value) {
1405
1459
  return out.replace(/\s+/g, " ").trim();
1406
1460
  }
1407
1461
 
1462
+ // src/content/optionLabels.ts
1463
+ var OPTION_STYLE_CONFIGS = {
1464
+ select: {
1465
+ catalogField: "options",
1466
+ multipleField: "is_multiple"
1467
+ },
1468
+ radio: {
1469
+ catalogField: "radio_options"
1470
+ },
1471
+ combobox: {
1472
+ catalogField: "combobox_options",
1473
+ multipleField: "web_combobox_multi_select"
1474
+ },
1475
+ "segmented-control": {
1476
+ catalogField: "segmented_control_data"
1477
+ }
1478
+ };
1479
+ function parseJson(raw) {
1480
+ if (typeof raw !== "string" || raw.trim() === "") {
1481
+ return raw;
1482
+ }
1483
+ try {
1484
+ return JSON.parse(raw);
1485
+ } catch {
1486
+ return raw;
1487
+ }
1488
+ }
1489
+ function toString(value) {
1490
+ if (typeof value !== "string") return null;
1491
+ const trimmed = value.trim();
1492
+ return trimmed === "" ? null : trimmed;
1493
+ }
1494
+ function parseOptionCatalog(raw) {
1495
+ const parsed = parseJson(raw);
1496
+ if (!Array.isArray(parsed)) return [];
1497
+ const entries = [];
1498
+ for (const item of parsed) {
1499
+ if (item == null || typeof item !== "object") continue;
1500
+ const record = item;
1501
+ const value = toString(record.value);
1502
+ if (!value) continue;
1503
+ const explicitMeta = record.meta && typeof record.meta === "object" && !Array.isArray(record.meta) ? record.meta : {};
1504
+ const legacyDescription = toString(record.description);
1505
+ const meta = legacyDescription && explicitMeta.description === void 0 ? { ...explicitMeta, description: legacyDescription } : explicitMeta;
1506
+ entries.push({
1507
+ value,
1508
+ ...typeof record.sort === "number" ? { sort: record.sort } : {},
1509
+ ...typeof record.disabled === "boolean" ? { disabled: record.disabled } : {},
1510
+ ...Object.keys(meta).length > 0 ? { meta } : {},
1511
+ ...toString(record.label) ?? toString(record.text) ? { legacyLabel: toString(record.label) ?? toString(record.text) ?? void 0 } : {}
1512
+ });
1513
+ }
1514
+ return entries;
1515
+ }
1516
+ function parseOptionLabels(raw) {
1517
+ const parsed = parseJson(raw);
1518
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
1519
+ return {};
1520
+ }
1521
+ const labels = {};
1522
+ for (const [key, value] of Object.entries(parsed)) {
1523
+ if (!key || typeof value !== "string") continue;
1524
+ const trimmed = value.trim();
1525
+ if (trimmed !== "") {
1526
+ labels[key] = trimmed;
1527
+ }
1528
+ }
1529
+ return labels;
1530
+ }
1531
+ function resolveOptionLabel(code, labels, fallbackLabels = {}, legacyLabel) {
1532
+ if (!code) return "";
1533
+ return labels[code] ?? fallbackLabels[code] ?? legacyLabel ?? code;
1534
+ }
1535
+ function resolveOptions(catalogRaw, labelsRaw, fallbackLabelsRaw) {
1536
+ const catalog = parseOptionCatalog(catalogRaw);
1537
+ const labels = parseOptionLabels(labelsRaw);
1538
+ const fallbackLabels = parseOptionLabels(fallbackLabelsRaw);
1539
+ return catalog.map((entry) => ({
1540
+ value: entry.value,
1541
+ label: resolveOptionLabel(entry.value, labels, fallbackLabels, entry.legacyLabel),
1542
+ ...entry.sort !== void 0 ? { sort: entry.sort } : {},
1543
+ ...entry.disabled !== void 0 ? { disabled: entry.disabled } : {},
1544
+ ...entry.meta ? { meta: entry.meta } : {}
1545
+ }));
1546
+ }
1547
+ function resolveOptionCodesLabels(codes, labels, fallbackLabels = {}) {
1548
+ return codes.map((code) => resolveOptionLabel(code, labels, fallbackLabels)).filter((label) => label !== "");
1549
+ }
1550
+ function parseOptionCodes(value) {
1551
+ const rawCodes = Array.isArray(value) ? value : typeof value === "string" ? value.split(",") : [];
1552
+ return rawCodes.filter((code) => typeof code === "string").map((code) => code.trim()).filter((code) => code !== "");
1553
+ }
1554
+ function resolveOptionValueLabels(value, labelsRaw, fallbackLabelsRaw) {
1555
+ return resolveOptionCodesLabels(
1556
+ parseOptionCodes(value),
1557
+ parseOptionLabels(labelsRaw),
1558
+ parseOptionLabels(fallbackLabelsRaw)
1559
+ );
1560
+ }
1561
+
1562
+ // src/content/fieldsMapLabels.ts
1563
+ var FIELDS_MAP_STYLE_CONFIG = {
1564
+ catalogField: "fields_map",
1565
+ labelsField: "fields_map_labels"
1566
+ };
1567
+ function parseJson2(raw) {
1568
+ if (typeof raw !== "string" || raw.trim() === "") {
1569
+ return raw;
1570
+ }
1571
+ try {
1572
+ return JSON.parse(raw);
1573
+ } catch {
1574
+ return raw;
1575
+ }
1576
+ }
1577
+ function parseFieldsMapCatalog(raw) {
1578
+ const parsed = parseJson2(raw);
1579
+ if (!Array.isArray(parsed)) {
1580
+ return [];
1581
+ }
1582
+ const keys = [];
1583
+ for (const item of parsed) {
1584
+ if (typeof item === "string" && item.trim() !== "") {
1585
+ keys.push(item.trim());
1586
+ continue;
1587
+ }
1588
+ if (item && typeof item === "object" && !Array.isArray(item)) {
1589
+ const record = item;
1590
+ const legacy = typeof record.field_name === "string" ? record.field_name.trim() : "";
1591
+ if (legacy !== "") {
1592
+ keys.push(legacy);
1593
+ }
1594
+ }
1595
+ }
1596
+ return keys;
1597
+ }
1598
+ function parseFieldsMapLabels(raw) {
1599
+ const parsed = parseJson2(raw);
1600
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
1601
+ return {};
1602
+ }
1603
+ const labels = {};
1604
+ for (const [key, value] of Object.entries(parsed)) {
1605
+ if (!key || typeof value !== "string") {
1606
+ continue;
1607
+ }
1608
+ const trimmed = value.trim();
1609
+ if (trimmed !== "") {
1610
+ labels[key] = trimmed;
1611
+ }
1612
+ }
1613
+ return labels;
1614
+ }
1615
+ function resolveFieldsMapLabel(fieldKey, labels, fallbackLabels = {}) {
1616
+ return labels[fieldKey] ?? fallbackLabels[fieldKey] ?? fieldKey;
1617
+ }
1618
+ function serializeFieldsMapCatalog(fieldKeys) {
1619
+ const keys = fieldKeys.map((key) => key.trim()).filter((key) => key !== "");
1620
+ if (keys.length === 0) {
1621
+ return "";
1622
+ }
1623
+ return JSON.stringify(keys);
1624
+ }
1625
+ function serializeFieldsMapLabels(labels) {
1626
+ const clean = {};
1627
+ for (const [key, value] of Object.entries(labels)) {
1628
+ const trimmed = value.trim();
1629
+ if (key && trimmed !== "") {
1630
+ clean[key] = trimmed;
1631
+ }
1632
+ }
1633
+ if (Object.keys(clean).length === 0) {
1634
+ return "";
1635
+ }
1636
+ return JSON.stringify(clean);
1637
+ }
1638
+
1639
+ // src/content/formRecordPrefill.ts
1640
+ var FORM_RECORD_PREFILL_SKIP_FIELDS = /* @__PURE__ */ new Set([
1641
+ "record_id",
1642
+ "entry_date",
1643
+ "id_users",
1644
+ "user_name",
1645
+ "user_code",
1646
+ "id_actionTriggerTypes",
1647
+ "triggerType",
1648
+ "id_languages",
1649
+ "language_locale",
1650
+ "language_name"
1651
+ ]);
1652
+ function isTranslatableChild(children, fieldName) {
1653
+ if (!Array.isArray(children)) {
1654
+ return false;
1655
+ }
1656
+ const child = children.find((item) => item?.name?.content === fieldName);
1657
+ return child?.translatable?.content === "1";
1658
+ }
1659
+ function asScalarString(value) {
1660
+ if (value === null || value === void 0) {
1661
+ return null;
1662
+ }
1663
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
1664
+ return String(value);
1665
+ }
1666
+ return null;
1667
+ }
1668
+ function parseFormRecordPrefill(section) {
1669
+ const sectionDataArray = section?.section_data;
1670
+ if (!Array.isArray(sectionDataArray) || sectionDataArray.length === 0) {
1671
+ return { recordId: null, values: {} };
1672
+ }
1673
+ const recordGroups = {};
1674
+ for (const row of sectionDataArray) {
1675
+ if (!row || typeof row !== "object" || Array.isArray(row)) {
1676
+ continue;
1677
+ }
1678
+ const record = row;
1679
+ const rawRecordId = record.record_id;
1680
+ const recordId = typeof rawRecordId === "number" ? rawRecordId : typeof rawRecordId === "string" && rawRecordId.trim() !== "" && Number.isFinite(Number(rawRecordId)) ? Number(rawRecordId) : null;
1681
+ if (recordId === null) {
1682
+ continue;
1683
+ }
1684
+ if (!recordGroups[recordId]) {
1685
+ recordGroups[recordId] = {};
1686
+ }
1687
+ const languageId = typeof record.id_languages === "number" ? record.id_languages : typeof record.id_languages === "string" && Number.isFinite(Number(record.id_languages)) ? Number(record.id_languages) : void 0;
1688
+ for (const [fieldName, fieldValue] of Object.entries(record)) {
1689
+ if (FORM_RECORD_PREFILL_SKIP_FIELDS.has(fieldName)) {
1690
+ continue;
1691
+ }
1692
+ const value = asScalarString(fieldValue);
1693
+ if (value === null) {
1694
+ continue;
1695
+ }
1696
+ const translatable = isTranslatableChild(section.children, fieldName);
1697
+ if (translatable) {
1698
+ if (languageId === 1) {
1699
+ if (!recordGroups[recordId][fieldName]) {
1700
+ recordGroups[recordId][fieldName] = value;
1701
+ }
1702
+ } else if (typeof languageId === "number") {
1703
+ const current = recordGroups[recordId][fieldName];
1704
+ if (typeof current === "string" || !current) {
1705
+ recordGroups[recordId][fieldName] = [{ language_id: languageId, value }];
1706
+ } else {
1707
+ const langValues = current;
1708
+ const existingIndex = langValues.findIndex((v) => v.language_id === languageId);
1709
+ if (existingIndex >= 0) {
1710
+ langValues[existingIndex] = { language_id: languageId, value };
1711
+ } else {
1712
+ langValues.push({ language_id: languageId, value });
1713
+ }
1714
+ }
1715
+ }
1716
+ } else if (languageId === 1 || !recordGroups[recordId][fieldName]) {
1717
+ recordGroups[recordId][fieldName] = value;
1718
+ }
1719
+ }
1720
+ }
1721
+ const firstRecordId = Object.keys(recordGroups)[0];
1722
+ if (!firstRecordId) {
1723
+ return { recordId: null, values: {} };
1724
+ }
1725
+ const id = Number(firstRecordId);
1726
+ return { recordId: id, values: recordGroups[id] ?? {} };
1727
+ }
1728
+ function flattenFormRecordPrefillValues(values, languageId) {
1729
+ const out = {};
1730
+ for (const [key, value] of Object.entries(values)) {
1731
+ if (typeof value === "string") {
1732
+ out[key] = value;
1733
+ continue;
1734
+ }
1735
+ if (!Array.isArray(value) || value.length === 0) {
1736
+ continue;
1737
+ }
1738
+ if (languageId != null) {
1739
+ const match = value.find((entry) => entry.language_id === languageId);
1740
+ if (match) {
1741
+ out[key] = match.value;
1742
+ continue;
1743
+ }
1744
+ }
1745
+ const nonIndependent = value.find((entry) => entry.language_id !== 1);
1746
+ out[key] = (nonIndependent ?? value[0]).value;
1747
+ }
1748
+ return out;
1749
+ }
1750
+
1408
1751
  // src/navigation/headerPreset.ts
1409
1752
  var WEB_HEADER_PRESET_VALUES = [
1410
1753
  "simple",
@@ -1420,16 +1763,134 @@ var WEB_HEADER_PRESET_OPTIONS = [
1420
1763
  { value: "dropdown", label: "Dropdown", description: "Default \u2014 nested dropdown menus." },
1421
1764
  { value: "mega-menu", label: "Mega menu", description: "Rich sections with descriptions and icons." },
1422
1765
  { value: "tabs", label: "Tabs", description: "Top-level sections as tabs." },
1423
- { value: "double-dropdown", label: "Double header (dropdown)", description: "Utility row plus main dropdown nav." },
1424
- { value: "double-mega-menu", label: "Double header (mega menu)", description: "Utility row plus mega menu." }
1766
+ { value: "double-dropdown", label: "Double header (dropdown)", description: "Top row with flat links and utilities above the main dropdown nav." },
1767
+ { value: "double-mega-menu", label: "Double header (mega menu)", description: "Top row with flat links and utilities above the mega menu." }
1425
1768
  ];
1769
+ var DOUBLE_WEB_HEADER_PRESETS = ["double-dropdown", "double-mega-menu"];
1426
1770
  function isWebHeaderPreset(value) {
1427
1771
  return typeof value === "string" && WEB_HEADER_PRESET_VALUES.includes(value);
1428
1772
  }
1773
+ function isDoubleWebHeaderPreset(value) {
1774
+ return isWebHeaderPreset(value) && DOUBLE_WEB_HEADER_PRESETS.includes(value);
1775
+ }
1429
1776
  function resolveWebHeaderPreset(value, fallback = DEFAULT_WEB_HEADER_PRESET) {
1430
1777
  return isWebHeaderPreset(value) ? value : fallback;
1431
1778
  }
1432
1779
 
1780
+ // src/navigation/footerPreset.ts
1781
+ var WEB_FOOTER_PRESET_VALUES = [
1782
+ "columns",
1783
+ "inline"
1784
+ ];
1785
+ var DEFAULT_WEB_FOOTER_PRESET = "columns";
1786
+ var WEB_FOOTER_PRESET_OPTIONS = [
1787
+ {
1788
+ value: "columns",
1789
+ label: "Columns (grouped)",
1790
+ description: "Group headings become footer columns with their links below."
1791
+ },
1792
+ {
1793
+ value: "inline",
1794
+ label: "Inline links",
1795
+ description: "One flat centered link row; group links are shown inline, headings hidden. Groups are kept and restored when switching back."
1796
+ }
1797
+ ];
1798
+ function isWebFooterPreset(value) {
1799
+ return typeof value === "string" && WEB_FOOTER_PRESET_VALUES.includes(value);
1800
+ }
1801
+ function resolveWebFooterPreset(value, fallback = DEFAULT_WEB_FOOTER_PRESET) {
1802
+ return isWebFooterPreset(value) ? value : fallback;
1803
+ }
1804
+ function isRenderableFooterLeaf(item) {
1805
+ if (!item.is_active) {
1806
+ return false;
1807
+ }
1808
+ if (item.item_type === "external_url") {
1809
+ return item.external_url != null && item.external_url !== "";
1810
+ }
1811
+ return item.item_type === "page" && item.page != null;
1812
+ }
1813
+ function flattenFooterItems(items) {
1814
+ const out = [];
1815
+ for (const item of items) {
1816
+ if (!item.is_active) {
1817
+ continue;
1818
+ }
1819
+ if (item.item_type === "group") {
1820
+ out.push(...flattenFooterItems(item.children));
1821
+ continue;
1822
+ }
1823
+ if (isRenderableFooterLeaf(item)) {
1824
+ out.push(item);
1825
+ out.push(...flattenFooterItems(item.children));
1826
+ }
1827
+ }
1828
+ return out;
1829
+ }
1830
+ function footerColumnItems(items) {
1831
+ return items.filter(
1832
+ (item) => item.is_active && item.item_type === "group" && item.children.some(isRenderableFooterLeaf)
1833
+ );
1834
+ }
1835
+ function footerStandaloneItems(items) {
1836
+ return items.filter((item) => item.item_type !== "group" && isRenderableFooterLeaf(item));
1837
+ }
1838
+ function footerGroupLinks(group) {
1839
+ return group.children.filter(isRenderableFooterLeaf);
1840
+ }
1841
+
1842
+ // src/navigation/headerLayers.ts
1843
+ var NAVIGATION_HEADER_LAYER_TOP = "top";
1844
+ function byPosition(a, b) {
1845
+ return a.position - b.position || a.id - b.id;
1846
+ }
1847
+ function splitHeaderLayers(items) {
1848
+ const top = [];
1849
+ const main = [];
1850
+ for (const item of items) {
1851
+ if (item.layer === NAVIGATION_HEADER_LAYER_TOP) {
1852
+ top.push(item);
1853
+ } else {
1854
+ main.push(item);
1855
+ }
1856
+ }
1857
+ top.sort(byPosition);
1858
+ main.sort(byPosition);
1859
+ return { top, main };
1860
+ }
1861
+ function mergeHeaderLayers(items) {
1862
+ const { top, main } = splitHeaderLayers(items);
1863
+ return [...main, ...top];
1864
+ }
1865
+
1866
+ // src/navigation/navigationPayload.ts
1867
+ var NAVIGATION_BRANDING_LOGO_HEIGHTS = {
1868
+ sm: 24,
1869
+ md: 32,
1870
+ lg: 44,
1871
+ xl: 56
1872
+ };
1873
+ function resolveBrandingPresentation(branding) {
1874
+ const size = branding?.logo_size ?? "md";
1875
+ const requestedVariant = branding?.logo_variant ?? "logo-and-name";
1876
+ const hasLogo = Boolean(branding?.logo_url);
1877
+ const variant = hasLogo ? requestedVariant : "name-only";
1878
+ return {
1879
+ size,
1880
+ variant,
1881
+ logoHeight: NAVIGATION_BRANDING_LOGO_HEIGHTS[size],
1882
+ showLogo: variant !== "name-only",
1883
+ showName: variant !== "logo-only"
1884
+ };
1885
+ }
1886
+
1887
+ // src/navigation/navigationBundle.ts
1888
+ var NAVIGATION_BUNDLE_FORMAT = "selfhelp/navigation-bundle";
1889
+ var NAVIGATION_BUNDLE_VERSION = "2.0";
1890
+ function isNavigationBundleVersionSupported(version) {
1891
+ return version === NAVIGATION_BUNDLE_VERSION;
1892
+ }
1893
+
1433
1894
  // src/navigation/menuMembership.ts
1434
1895
  function flattenItems(items) {
1435
1896
  const out = [];
@@ -1494,6 +1955,22 @@ function findPageRefInNavigationPayload(payload, pageId) {
1494
1955
  }
1495
1956
 
1496
1957
  // src/navigation/mobileRoute.ts
1958
+ function buildPublicPathFromRoute(urlTemplate, routeParams) {
1959
+ if (!urlTemplate || !urlTemplate.includes("{")) {
1960
+ return null;
1961
+ }
1962
+ let path = urlTemplate;
1963
+ for (const [key, value] of Object.entries(routeParams)) {
1964
+ if (value === void 0 || value === "") {
1965
+ continue;
1966
+ }
1967
+ path = path.replaceAll(`{${key}}`, value);
1968
+ }
1969
+ if (path.includes("{")) {
1970
+ return null;
1971
+ }
1972
+ return path.replace(/\/+$/, "") || "/";
1973
+ }
1497
1974
  function pageUrlToMobileRoute(url, keyword) {
1498
1975
  const normalizedKeyword = keyword.trim().toLowerCase();
1499
1976
  if (normalizedKeyword === "profile") {
@@ -1518,8 +1995,8 @@ function toSegment(item) {
1518
1995
  keyword: item.page.keyword,
1519
1996
  url: item.page.url,
1520
1997
  label: itemLabel(item),
1521
- icon: item.icon ?? item.page.icon,
1522
- mobile_icon: item.page.mobile_icon
1998
+ icon: item.icon ?? null,
1999
+ mobile_icon: item.mobile_icon ?? null
1523
2000
  };
1524
2001
  }
1525
2002
  function findParentItem(items, pageId, parent = null) {
@@ -1572,9 +2049,7 @@ function resolveBranchNavGroup(payload, currentPageId, menuKeys) {
1572
2049
  }
1573
2050
  const located = findParentItem([root], currentPageId);
1574
2051
  if (located) {
1575
- const directChildren = menuVisibleChildItems(
1576
- located.parent ?? { id: 0, item_type: "group", label: "", position: 0, children: located.siblings }
1577
- );
2052
+ const directChildren = located.parent ? menuVisibleChildItems(located.parent) : located.siblings.filter((sibling) => sibling.page != null && sibling.is_active !== false);
1578
2053
  if (located.parent && located.parent.page?.id === currentPageId && directChildren.length > 0) {
1579
2054
  const segments = directChildren.map(toSegment).filter((s) => s != null);
1580
2055
  return segments.length > 0 ? segments : null;
@@ -1615,6 +2090,80 @@ function resolveMobileSegmentGroup(payload, currentPageId) {
1615
2090
  function resolveWebBranchNavGroup(payload, currentPageId) {
1616
2091
  return resolveBranchNavGroup(payload, currentPageId, ["web_header", "web_footer"]);
1617
2092
  }
2093
+ function findMenuItemPath(items, pageId, trail = []) {
2094
+ for (const item of items) {
2095
+ const nextTrail = [...trail, item];
2096
+ if (item.page?.id === pageId) {
2097
+ return nextTrail;
2098
+ }
2099
+ if (item.children?.length) {
2100
+ const found = findMenuItemPath(item.children, pageId, nextTrail);
2101
+ if (found) {
2102
+ return found;
2103
+ }
2104
+ }
2105
+ }
2106
+ return null;
2107
+ }
2108
+ function toBreadcrumb(item) {
2109
+ return {
2110
+ label: itemLabel(item),
2111
+ pageId: item.page?.id ?? null,
2112
+ keyword: item.page?.keyword ?? null,
2113
+ url: item.page?.url ?? null
2114
+ };
2115
+ }
2116
+ function resolveModeForBranch(branchParent, menu) {
2117
+ return branchParent?.children_nav ?? menu.children_nav ?? "sidebar";
2118
+ }
2119
+ function resolvePagerForBranch(branchParent, menu) {
2120
+ return branchParent?.show_pager ?? menu.show_pager ?? true;
2121
+ }
2122
+ function resolveWebBranchNavContext(payload, currentPageId) {
2123
+ for (const key of ["web_header", "web_footer"]) {
2124
+ const menu = payload.menus[key];
2125
+ if (!menu?.items?.length) {
2126
+ continue;
2127
+ }
2128
+ const path = findMenuItemPath(menu.items, currentPageId);
2129
+ if (!path) {
2130
+ continue;
2131
+ }
2132
+ const currentItem = path[path.length - 1];
2133
+ const ownChildren = menuVisibleChildItems(currentItem);
2134
+ let branchParent = null;
2135
+ let group;
2136
+ if (ownChildren.length > 0) {
2137
+ branchParent = currentItem;
2138
+ group = ownChildren;
2139
+ } else if (path.length >= 2) {
2140
+ branchParent = path[path.length - 2];
2141
+ group = menuVisibleChildItems(branchParent);
2142
+ } else {
2143
+ return null;
2144
+ }
2145
+ const segments = group.map(toSegment).filter((segment) => segment != null);
2146
+ if (segments.length === 0) {
2147
+ return null;
2148
+ }
2149
+ const currentIndex = segments.findIndex((segment) => segment.pageId === currentPageId);
2150
+ const pager = {
2151
+ prev: currentIndex > 0 ? segments[currentIndex - 1] : null,
2152
+ next: currentIndex >= 0 && currentIndex < segments.length - 1 ? segments[currentIndex + 1] : null
2153
+ };
2154
+ return {
2155
+ mode: resolveModeForBranch(branchParent, menu),
2156
+ showBreadcrumbs: menu.show_breadcrumbs ?? false,
2157
+ showPager: resolvePagerForBranch(branchParent, menu),
2158
+ heading: branchParent ? itemLabel(branchParent) : null,
2159
+ parent: branchParent ? toSegment(branchParent) : null,
2160
+ segments,
2161
+ breadcrumbs: path.map(toBreadcrumb),
2162
+ pager
2163
+ };
2164
+ }
2165
+ return null;
2166
+ }
1618
2167
  function resolveMobilePagePresentation(payload, pageId) {
1619
2168
  return isOnAnyMobileMenuFromPayload(payload, pageId) ? "route" : "modal";
1620
2169
  }
@@ -1678,10 +2227,6 @@ function getNavigationItemLabel(item) {
1678
2227
  return item.label || item.page?.title || item.page?.keyword || "";
1679
2228
  }
1680
2229
  function getNavigationItemAriaLabel(item) {
1681
- const aria = item.aria_label?.trim();
1682
- if (aria) {
1683
- return aria;
1684
- }
1685
2230
  const label = getNavigationItemLabel(item);
1686
2231
  return label || void 0;
1687
2232
  }
@@ -1905,6 +2450,68 @@ function clampMenuItemsAtDepth(items, maxDepth, depth = 0) {
1905
2450
  });
1906
2451
  }
1907
2452
 
2453
+ // src/navigation/activeTrail.ts
2454
+ function getNavigationItemMobileHref(item) {
2455
+ if (item.item_type === "external_url" && item.external_url) {
2456
+ return item.external_url;
2457
+ }
2458
+ if (!item.page) {
2459
+ return "/index";
2460
+ }
2461
+ return pageUrlToMobileRoute(item.page.url, item.page.keyword);
2462
+ }
2463
+ function matchesWebPath(href, pathname) {
2464
+ if (href === "" || href === "#") {
2465
+ return false;
2466
+ }
2467
+ if (pathname === href) {
2468
+ return true;
2469
+ }
2470
+ return href !== "/" && pathname.startsWith(`${href}/`);
2471
+ }
2472
+ function matchesMobilePath(href, pathname) {
2473
+ if (pathname === href) {
2474
+ return true;
2475
+ }
2476
+ if (href === "/index" && (pathname === "" || pathname === "/" || pathname === "/index")) {
2477
+ return true;
2478
+ }
2479
+ return href !== "/" && pathname.startsWith(`${href}/`);
2480
+ }
2481
+ function isActive(item, pathname, getHref, matches) {
2482
+ if (matches(getHref(item), pathname)) {
2483
+ return true;
2484
+ }
2485
+ return item.children.some((child) => isActive(child, pathname, getHref, matches));
2486
+ }
2487
+ function isMenuItemActiveOnWeb(item, pathname) {
2488
+ return isActive(item, pathname, getNavigationItemHref, matchesWebPath);
2489
+ }
2490
+ function isMenuItemActiveOnMobile(item, pathname) {
2491
+ return isActive(item, pathname, getNavigationItemMobileHref, matchesMobilePath);
2492
+ }
2493
+ function expandedIdsForActiveTrail(items, pathname, platform) {
2494
+ const getHref = platform === "mobile" ? getNavigationItemMobileHref : getNavigationItemHref;
2495
+ const matches = platform === "mobile" ? matchesMobilePath : matchesWebPath;
2496
+ const expanded = /* @__PURE__ */ new Set();
2497
+ const visit = (item) => {
2498
+ let childActive = false;
2499
+ for (const child of item.children) {
2500
+ if (visit(child)) {
2501
+ childActive = true;
2502
+ }
2503
+ }
2504
+ if (childActive) {
2505
+ expanded.add(item.id);
2506
+ }
2507
+ return childActive || matches(getHref(item), pathname);
2508
+ };
2509
+ for (const item of items) {
2510
+ visit(item);
2511
+ }
2512
+ return expanded;
2513
+ }
2514
+
1908
2515
  // src/utils/spacing.ts
1909
2516
  var ALLOWED_KEYS = ["mt", "mb", "ms", "me", "pt", "pb", "ps", "pe"];
1910
2517
  function parseSpacing(raw) {
@@ -1980,14 +2587,19 @@ export {
1980
2587
  CLIENT_TYPE_MOBILE,
1981
2588
  CLIENT_TYPE_MOBILE_AND_WEB,
1982
2589
  CLIENT_TYPE_WEB,
2590
+ CMS_APP_PRIMARY_ROLES,
2591
+ CMS_APP_ROLES,
1983
2592
  COLOR_NAMES,
1984
2593
  COLOR_PALETTE,
1985
2594
  COLOR_SCALES,
1986
2595
  CONTAINER_SIZE_PX,
1987
2596
  DEFAULT_MOBILE_ICON,
2597
+ DEFAULT_WEB_FOOTER_PRESET,
1988
2598
  DEFAULT_WEB_HEADER_PRESET,
1989
2599
  ENDPOINTS,
2600
+ FIELDS_MAP_STYLE_CONFIG,
1990
2601
  FONT_SIZE_PX,
2602
+ FORM_RECORD_PREFILL_SKIP_FIELDS,
1991
2603
  FULL_RADIUS_PX,
1992
2604
  HEADER_CLIENT_TYPE,
1993
2605
  LINE_HEIGHT,
@@ -1995,6 +2607,11 @@ export {
1995
2607
  MOBILE_ICON_NAMES,
1996
2608
  MOBILE_ICON_SET,
1997
2609
  MOBILE_PREVIEW_ENDPOINTS,
2610
+ NAVIGATION_BRANDING_LOGO_HEIGHTS,
2611
+ NAVIGATION_BUNDLE_FORMAT,
2612
+ NAVIGATION_BUNDLE_VERSION,
2613
+ NAVIGATION_HEADER_LAYER_TOP,
2614
+ OPTION_STYLE_CONFIGS,
1998
2615
  PERMISSIONS,
1999
2616
  PREVIEW_BRIDGE_MESSAGE,
2000
2617
  PREVIEW_PARENT_ORIGIN_PARAM,
@@ -2007,29 +2624,42 @@ export {
2007
2624
  SPACING_VALUES,
2008
2625
  STYLE_REGISTRY,
2009
2626
  SYSTEM_ENDPOINTS,
2627
+ WEB_FOOTER_PRESET_OPTIONS,
2628
+ WEB_FOOTER_PRESET_VALUES,
2010
2629
  WEB_HEADER_PRESET_OPTIONS,
2011
2630
  WEB_HEADER_PRESET_VALUES,
2012
2631
  _resetPluginStyleRegistry,
2013
2632
  arePreviewPreferencesEqual,
2014
2633
  buildConditionContext,
2634
+ buildPagesResolvePath,
2635
+ buildPagesResolveQuery,
2636
+ buildPagesResolveUrl,
2637
+ buildPublicPathFromRoute,
2015
2638
  clampMenuItemsAtDepth,
2016
2639
  classifyClass,
2017
2640
  classifyClassString,
2018
2641
  collectPageIdsFromMenuItems,
2019
2642
  colorToHex,
2020
2643
  evaluateCondition,
2644
+ expandedIdsForActiveTrail,
2021
2645
  extendStyleRegistry,
2022
2646
  findMenuItemByPageId,
2023
2647
  findNearestBottomTabMenuItemForPage,
2024
2648
  findPageRefInNavigationPayload,
2025
2649
  findRemap,
2650
+ flattenFooterItems,
2651
+ flattenFormRecordPrefillValues,
2026
2652
  flattenMenuItems,
2027
2653
  flattenNavigationMenuItems,
2654
+ footerColumnItems,
2655
+ footerGroupLinks,
2656
+ footerStandaloneItems,
2028
2657
  getMergedStyleRegistry,
2029
2658
  getNavigationItemAriaLabel,
2030
2659
  getNavigationItemHref,
2031
2660
  getNavigationItemKeyword,
2032
2661
  getNavigationItemLabel,
2662
+ getNavigationItemMobileHref,
2033
2663
  getPluginStyleRegistry,
2034
2664
  getRegistryEntry,
2035
2665
  getRegistryEntryAny,
@@ -2039,8 +2669,12 @@ export {
2039
2669
  gridSpanToReactNativeColumn,
2040
2670
  hasInlineFormatting,
2041
2671
  isBottomTabMenuItemActive,
2672
+ isDoubleWebHeaderPreset,
2042
2673
  isKnownStyleName,
2674
+ isMenuItemActiveOnMobile,
2675
+ isMenuItemActiveOnWeb,
2043
2676
  isMobileIconName,
2677
+ isNavigationBundleVersionSupported,
2044
2678
  isOnAnyMobileMenu,
2045
2679
  isOnAnyMobileMenuFromPayload,
2046
2680
  isPageInMenuTree,
@@ -2053,6 +2687,7 @@ export {
2053
2687
  isStyleAllowedOnPage,
2054
2688
  isStylePlacementAllowed,
2055
2689
  isStyleSupportedOnPlatform,
2690
+ isWebFooterPreset,
2056
2691
  isWebHeaderPreset,
2057
2692
  mapAccordionVariantToHeroUiVariant,
2058
2693
  mapChipVariantToHeroUiVariant,
@@ -2065,10 +2700,20 @@ export {
2065
2700
  mapSizeToHeroUi,
2066
2701
  mapSizeToMantine,
2067
2702
  mapSpacingToPx,
2703
+ matchesMobilePath,
2704
+ matchesWebPath,
2705
+ mergeHeaderLayers,
2706
+ normalizePagesResolvePath,
2068
2707
  pageUrlToMobileRoute,
2069
2708
  parseDimensionToReactNative,
2070
2709
  parseDimensionToWeb,
2710
+ parseFieldsMapCatalog,
2711
+ parseFieldsMapLabels,
2712
+ parseFormRecordPrefill,
2071
2713
  parseInlineRich,
2714
+ parseOptionCatalog,
2715
+ parseOptionCodes,
2716
+ parseOptionLabels,
2072
2717
  parseSpacing,
2073
2718
  previewKeywordFromPath,
2074
2719
  radiusToPx,
@@ -2076,6 +2721,8 @@ export {
2076
2721
  resolveAssetSources,
2077
2722
  resolveAssetUrl,
2078
2723
  resolveBranchNavGroup,
2724
+ resolveBrandingPresentation,
2725
+ resolveFieldsMapLabel,
2079
2726
  resolveHolderRedirectPath,
2080
2727
  resolveMantineVariant,
2081
2728
  resolveMenuMaxDepth,
@@ -2084,20 +2731,29 @@ export {
2084
2731
  resolveMobileSegmentGroup,
2085
2732
  resolveMobileStartupKeyword,
2086
2733
  resolveMobileStartupRoute,
2734
+ resolveOptionCodesLabels,
2735
+ resolveOptionLabel,
2736
+ resolveOptionValueLabels,
2737
+ resolveOptions,
2087
2738
  resolveSharedStyle,
2088
2739
  resolveSharedStyleForMobile,
2089
2740
  resolveSharedStyleForWeb,
2090
2741
  resolveSharedStyleProps,
2742
+ resolveWebBranchNavContext,
2091
2743
  resolveWebBranchNavGroup,
2744
+ resolveWebFooterPreset,
2092
2745
  resolveWebHeaderPreset,
2093
2746
  resolveWebStartupPath,
2094
2747
  searchMenuPagesInPayload,
2748
+ serializeFieldsMapCatalog,
2749
+ serializeFieldsMapLabels,
2095
2750
  setToStylePlatform,
2096
2751
  sharedTailwindExtend,
2097
2752
  sharedTailwindPreset,
2098
2753
  sizeToFontPx,
2099
2754
  spacingToClasses,
2100
2755
  spacingToPx,
2756
+ splitHeaderLayers,
2101
2757
  stripHtmlToText,
2102
2758
  stylePlatformToSet,
2103
2759
  toHeroUiSemanticProps,