@aleph-alpha/settings-kit 0.1.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/README.md +465 -15
  2. package/dist/SkLayout.vue_vue_type_script_setup_true_lang-ZjV2AMdR.js +51 -0
  3. package/dist/SkLayoutPage-DGbCpQFm.js +2545 -0
  4. package/dist/UseFileConvertor-DN6cCXNi.js +50 -0
  5. package/dist/components/SkField/SkField.vue.d.ts +28 -0
  6. package/dist/components/SkField/SkField.vue.d.ts.map +1 -0
  7. package/dist/components/SkField/index.d.ts +2 -0
  8. package/dist/components/SkField/index.d.ts.map +1 -0
  9. package/dist/components/SkGroup/SkGroup.vue.d.ts +29 -0
  10. package/dist/components/SkGroup/SkGroup.vue.d.ts.map +1 -0
  11. package/dist/components/SkGroup/index.d.ts +2 -0
  12. package/dist/components/SkGroup/index.d.ts.map +1 -0
  13. package/dist/components/SkItem/SkItem.vue.d.ts +22 -0
  14. package/dist/components/SkItem/SkItem.vue.d.ts.map +1 -0
  15. package/dist/components/SkItem/index.d.ts +2 -0
  16. package/dist/components/SkItem/index.d.ts.map +1 -0
  17. package/dist/components/SkLayout/SkLayout.vue.d.ts +53 -0
  18. package/dist/components/SkLayout/SkLayout.vue.d.ts.map +1 -0
  19. package/dist/components/SkLayout/SkLayoutPage.d.ts +23 -0
  20. package/dist/components/SkLayout/SkLayoutPage.d.ts.map +1 -0
  21. package/dist/components/SkLayout/context.d.ts +61 -0
  22. package/dist/components/SkLayout/context.d.ts.map +1 -0
  23. package/dist/components/SkLayout/index.d.ts +5 -0
  24. package/dist/components/SkLayout/index.d.ts.map +1 -0
  25. package/dist/components/SkPage/SkPage.vue.d.ts +35 -0
  26. package/dist/components/SkPage/SkPage.vue.d.ts.map +1 -0
  27. package/dist/components/SkPage/index.d.ts +2 -0
  28. package/dist/components/SkPage/index.d.ts.map +1 -0
  29. package/dist/components/SkSection/SkSection.vue.d.ts +29 -0
  30. package/dist/components/SkSection/SkSection.vue.d.ts.map +1 -0
  31. package/dist/components/SkSection/index.d.ts +2 -0
  32. package/dist/components/SkSection/index.d.ts.map +1 -0
  33. package/dist/components/controls/SkActionsControl/SkActionsControl.vue.d.ts +37 -0
  34. package/dist/components/controls/SkActionsControl/SkActionsControl.vue.d.ts.map +1 -0
  35. package/dist/components/controls/SkActionsControl/index.d.ts +2 -0
  36. package/dist/components/controls/SkActionsControl/index.d.ts.map +1 -0
  37. package/dist/components/controls/SkCheckboxControl/SkCheckboxControl.vue.d.ts +35 -0
  38. package/dist/components/controls/SkCheckboxControl/SkCheckboxControl.vue.d.ts.map +1 -0
  39. package/dist/components/controls/SkCheckboxControl/index.d.ts +2 -0
  40. package/dist/components/controls/SkCheckboxControl/index.d.ts.map +1 -0
  41. package/dist/components/controls/SkColorControl/SkColorControl.vue.d.ts +35 -0
  42. package/dist/components/controls/SkColorControl/SkColorControl.vue.d.ts.map +1 -0
  43. package/dist/components/controls/SkColorControl/index.d.ts +2 -0
  44. package/dist/components/controls/SkColorControl/index.d.ts.map +1 -0
  45. package/dist/components/controls/SkFileUpload/SkFilePlaceholder.vue.d.ts +11 -0
  46. package/dist/components/controls/SkFileUpload/SkFilePlaceholder.vue.d.ts.map +1 -0
  47. package/dist/components/controls/SkFileUpload/SkFileUpload.vue.d.ts +46 -0
  48. package/dist/components/controls/SkFileUpload/SkFileUpload.vue.d.ts.map +1 -0
  49. package/dist/components/controls/SkFileUpload/index.d.ts +2 -0
  50. package/dist/components/controls/SkFileUpload/index.d.ts.map +1 -0
  51. package/dist/components/controls/SkPeriodControl/SkPeriodControl.vue.d.ts +35 -0
  52. package/dist/components/controls/SkPeriodControl/SkPeriodControl.vue.d.ts.map +1 -0
  53. package/dist/components/controls/SkPeriodControl/index.d.ts +2 -0
  54. package/dist/components/controls/SkPeriodControl/index.d.ts.map +1 -0
  55. package/dist/components/controls/SkSelectControl/SkSelectControl.vue.d.ts +40 -0
  56. package/dist/components/controls/SkSelectControl/SkSelectControl.vue.d.ts.map +1 -0
  57. package/dist/components/controls/SkSelectControl/index.d.ts +2 -0
  58. package/dist/components/controls/SkSelectControl/index.d.ts.map +1 -0
  59. package/dist/components/controls/SkTelControl/SKTelPrefixControl.vue.d.ts +16 -0
  60. package/dist/components/controls/SkTelControl/SKTelPrefixControl.vue.d.ts.map +1 -0
  61. package/dist/components/controls/SkTelControl/SkTelControl.vue.d.ts +35 -0
  62. package/dist/components/controls/SkTelControl/SkTelControl.vue.d.ts.map +1 -0
  63. package/dist/components/controls/SkTelControl/index.d.ts +4 -0
  64. package/dist/components/controls/SkTelControl/index.d.ts.map +1 -0
  65. package/dist/components/controls/SkTelControl/prefixes.d.ts +26 -0
  66. package/dist/components/controls/SkTelControl/prefixes.d.ts.map +1 -0
  67. package/dist/components/controls/SkTextControl/SkTextControl.vue.d.ts +45 -0
  68. package/dist/components/controls/SkTextControl/SkTextControl.vue.d.ts.map +1 -0
  69. package/dist/components/controls/SkTextControl/index.d.ts +2 -0
  70. package/dist/components/controls/SkTextControl/index.d.ts.map +1 -0
  71. package/dist/components/controls/SkUnsupportedControl/SkUnsupportedControl.vue.d.ts +8 -0
  72. package/dist/components/controls/SkUnsupportedControl/SkUnsupportedControl.vue.d.ts.map +1 -0
  73. package/dist/components/controls/storyEventLog.d.ts +33 -0
  74. package/dist/components/controls/storyEventLog.d.ts.map +1 -0
  75. package/dist/components/index.d.ts +7 -2
  76. package/dist/components/index.d.ts.map +1 -1
  77. package/dist/components/index.js +12 -2
  78. package/dist/composables/UseFileConvertor/UseFileConvertor.d.ts +7 -0
  79. package/dist/composables/UseFileConvertor/UseFileConvertor.d.ts.map +1 -0
  80. package/dist/composables/index.d.ts +14 -0
  81. package/dist/composables/index.d.ts.map +1 -0
  82. package/dist/composables/useFieldInheritance/useFieldInheritance.d.ts +24 -0
  83. package/dist/composables/useFieldInheritance/useFieldInheritance.d.ts.map +1 -0
  84. package/dist/composables/useFieldValidator/useFieldValidator.d.ts +50 -0
  85. package/dist/composables/useFieldValidator/useFieldValidator.d.ts.map +1 -0
  86. package/dist/composables/useSettingField/useSettingField.d.ts +24 -0
  87. package/dist/composables/useSettingField/useSettingField.d.ts.map +1 -0
  88. package/dist/composables/useSettingsForm/useSettingsForm.d.ts +12 -0
  89. package/dist/composables/useSettingsForm/useSettingsForm.d.ts.map +1 -0
  90. package/dist/composables/useSettingsLayout/useSettingsLayout.d.ts +71 -0
  91. package/dist/composables/useSettingsLayout/useSettingsLayout.d.ts.map +1 -0
  92. package/dist/composables/useSettingsLocale/useSettingsLocale.d.ts +38 -0
  93. package/dist/composables/useSettingsLocale/useSettingsLocale.d.ts.map +1 -0
  94. package/dist/composables/useStateManager/useStateManager.d.ts +10 -0
  95. package/dist/composables/useStateManager/useStateManager.d.ts.map +1 -0
  96. package/dist/core/controls/controlDefinitions.d.ts +33 -0
  97. package/dist/core/controls/controlDefinitions.d.ts.map +1 -0
  98. package/dist/core/controls/index.d.ts +26 -0
  99. package/dist/core/controls/index.d.ts.map +1 -0
  100. package/dist/core/index.d.ts +18 -0
  101. package/dist/core/index.d.ts.map +1 -0
  102. package/dist/core/layout/index.d.ts +8 -0
  103. package/dist/core/layout/index.d.ts.map +1 -0
  104. package/dist/core/layout/navigation.d.ts +33 -0
  105. package/dist/core/layout/navigation.d.ts.map +1 -0
  106. package/dist/core/layout/resolve.d.ts +41 -0
  107. package/dist/core/layout/resolve.d.ts.map +1 -0
  108. package/dist/core/layout/types.d.ts +160 -0
  109. package/dist/core/layout/types.d.ts.map +1 -0
  110. package/dist/core/layout/validate.d.ts +26 -0
  111. package/dist/core/layout/validate.d.ts.map +1 -0
  112. package/dist/core/types.d.ts +541 -0
  113. package/dist/core/types.d.ts.map +1 -0
  114. package/dist/core/useControlModel.d.ts +13 -0
  115. package/dist/core/useControlModel.d.ts.map +1 -0
  116. package/dist/core/utils/a11y.d.ts +25 -0
  117. package/dist/core/utils/a11y.d.ts.map +1 -0
  118. package/dist/core/utils/cast.d.ts +8 -0
  119. package/dist/core/utils/cast.d.ts.map +1 -0
  120. package/dist/core/utils/consts.d.ts +978 -0
  121. package/dist/core/utils/consts.d.ts.map +1 -0
  122. package/dist/core/utils/kitMessages.d.ts +165 -0
  123. package/dist/core/utils/kitMessages.d.ts.map +1 -0
  124. package/dist/core/utils/localizedText.d.ts +10 -0
  125. package/dist/core/utils/localizedText.d.ts.map +1 -0
  126. package/dist/core/utils/useName.d.ts +7 -0
  127. package/dist/core/utils/useName.d.ts.map +1 -0
  128. package/dist/core/validate/constraints.d.ts +20 -0
  129. package/dist/core/validate/constraints.d.ts.map +1 -0
  130. package/dist/core/validate/rules.d.ts +29 -0
  131. package/dist/core/validate/rules.d.ts.map +1 -0
  132. package/dist/index-BQ6z6MK4.js +214 -0
  133. package/dist/index-BXs-0JdT.js +168 -0
  134. package/dist/index-BynIH0EE.js +92 -0
  135. package/dist/index-C-WLhRod.js +100 -0
  136. package/dist/index-CFMv8jSO.js +4 -0
  137. package/dist/index-CGYERet5.js +373 -0
  138. package/dist/index-KAbhkO1J.js +81 -0
  139. package/dist/index.d.ts +8 -2
  140. package/dist/index.d.ts.map +1 -1
  141. package/dist/index.js +48 -3
  142. package/dist/service/index.d.ts +2 -0
  143. package/dist/service/index.d.ts.map +1 -0
  144. package/dist/shell/SkShell.vue.d.ts +80 -0
  145. package/dist/shell/SkShell.vue.d.ts.map +1 -0
  146. package/dist/shell/SkShellFrame.vue.d.ts +46 -0
  147. package/dist/shell/SkShellFrame.vue.d.ts.map +1 -0
  148. package/dist/shell/SkShellNav.vue.d.ts +19 -0
  149. package/dist/shell/SkShellNav.vue.d.ts.map +1 -0
  150. package/dist/shell/history.d.ts +9 -0
  151. package/dist/shell/history.d.ts.map +1 -0
  152. package/dist/shell/index.d.ts +12 -0
  153. package/dist/shell/index.d.ts.map +1 -0
  154. package/dist/shell/index.js +848 -0
  155. package/dist/shell/labels.d.ts +25 -0
  156. package/dist/shell/labels.d.ts.map +1 -0
  157. package/dist/shell/location.d.ts +18 -0
  158. package/dist/shell/location.d.ts.map +1 -0
  159. package/dist/shell/routes.d.ts +19 -0
  160. package/dist/shell/routes.d.ts.map +1 -0
  161. package/dist/shell/useMediaQuery.d.ts +4 -0
  162. package/dist/shell/useMediaQuery.d.ts.map +1 -0
  163. package/dist/shell/useShellLocation.d.ts +37 -0
  164. package/dist/shell/useShellLocation.d.ts.map +1 -0
  165. package/package.json +42 -23
  166. package/dist/SettingToggleUnit.vue_vue_type_script_setup_true_lang-BM7-6aXj.js +0 -61
  167. package/dist/components/SettingToggleUnit/SettingToggleUnit.vue.d.ts +0 -16
  168. package/dist/components/SettingToggleUnit/SettingToggleUnit.vue.d.ts.map +0 -1
  169. package/dist/components/SettingToggleUnit/index.d.ts +0 -3
  170. package/dist/components/SettingToggleUnit/index.d.ts.map +0 -1
  171. package/dist/components/SettingToggleUnit/types.d.ts +0 -11
  172. package/dist/components/SettingToggleUnit/types.d.ts.map +0 -1
@@ -0,0 +1,2545 @@
1
+ import { useAttrs, computed, hasInjectionContext, inject, toValue, provide, defineComponent, openBlock, createElementBlock, Fragment, renderSlot, createVNode, unref, withCtx, mergeProps, isRef, toDisplayString, createCommentVNode, mergeDefaults, defineAsyncComponent, h, reactive, shallowReactive, ref, watch, watchEffect, createElementVNode, useModel, createBlock, resolveDynamicComponent, toHandlers, createSlots, createTextVNode, mergeModels, normalizeStyle, normalizeClass, withModifiers } from "vue";
2
+ import { UiInputGroup, UiInputGroupInput, UiCheckbox, UiField, UiFieldError, UiFieldLabel } from "@aleph-alpha/ui-library";
3
+ const skBaseControlDefaults = {
4
+ modelValue: void 0,
5
+ id: void 0,
6
+ name: void 0,
7
+ placeholder: void 0,
8
+ disabled: false,
9
+ inheriting: false,
10
+ required: false,
11
+ label: void 0,
12
+ tooltip: void 0,
13
+ errors: void 0
14
+ };
15
+ const skPeriodUnits = [
16
+ { value: "d", label: "Days" },
17
+ { value: "w", label: "Weeks" },
18
+ { value: "m", label: "Months" },
19
+ { value: "y", label: "Years" }
20
+ ];
21
+ const skCountries = {
22
+ AD: { number: "+376", flag: "FlagsAd" },
23
+ AE: { number: "+971", flag: "FlagsAe" },
24
+ AF: { number: "+93", flag: "FlagsAf" },
25
+ AG: { number: "+1268", flag: "FlagsAg" },
26
+ AI: { number: "+1264", flag: "FlagsAi" },
27
+ AL: { number: "+355", flag: "FlagsAl" },
28
+ AM: { number: "+374", flag: "FlagsAm" },
29
+ AO: { number: "+244", flag: "FlagsAo" },
30
+ AR: { number: "+54", flag: "FlagsAr" },
31
+ AS: { number: "+1684", flag: "FlagsAs" },
32
+ AT: { number: "+43", flag: "FlagsAt" },
33
+ AU: { number: "+61", flag: "FlagsAu" },
34
+ AW: { number: "+297", flag: "FlagsAw" },
35
+ AX: { number: "+358", flag: "FlagsAx" },
36
+ AZ: { number: "+994", flag: "FlagsAz" },
37
+ BA: { number: "+387", flag: "FlagsBa" },
38
+ BB: { number: "+1246", flag: "FlagsBb" },
39
+ BD: { number: "+880", flag: "FlagsBd" },
40
+ BE: { number: "+32", flag: "FlagsBe" },
41
+ BF: { number: "+226", flag: "FlagsBf" },
42
+ BG: { number: "+359", flag: "FlagsBg" },
43
+ BH: { number: "+973", flag: "FlagsBh" },
44
+ BI: { number: "+257", flag: "FlagsBi" },
45
+ BJ: { number: "+229", flag: "FlagsBj" },
46
+ BL: { number: "+590", flag: "FlagsBl" },
47
+ BM: { number: "+1441", flag: "FlagsBm" },
48
+ BN: { number: "+673", flag: "FlagsBn" },
49
+ BO: { number: "+591", flag: "FlagsBo" },
50
+ BQ: { number: "+599", flag: "FlagsBq" },
51
+ BR: { number: "+55", flag: "FlagsBr" },
52
+ BS: { number: "+1242", flag: "FlagsBs" },
53
+ BT: { number: "+975", flag: "FlagsBt" },
54
+ BW: { number: "+267", flag: "FlagsBw" },
55
+ BY: { number: "+375", flag: "FlagsBy" },
56
+ BZ: { number: "+501", flag: "FlagsBz" },
57
+ CA: { number: "+1", flag: "FlagsCa" },
58
+ CC: { number: "+61", flag: "FlagsCc" },
59
+ CD: { number: "+243", flag: "FlagsCd" },
60
+ CF: { number: "+236", flag: "FlagsCf" },
61
+ CG: { number: "+242", flag: "FlagsCg" },
62
+ CH: { number: "+41", flag: "FlagsCh" },
63
+ CI: { number: "+225", flag: "FlagsCi" },
64
+ CK: { number: "+682", flag: "FlagsCk" },
65
+ CL: { number: "+56", flag: "FlagsCl" },
66
+ CM: { number: "+237", flag: "FlagsCm" },
67
+ CN: { number: "+86", flag: "FlagsCn" },
68
+ CO: { number: "+57", flag: "FlagsCo" },
69
+ CR: { number: "+506", flag: "FlagsCr" },
70
+ CU: { number: "+53", flag: "FlagsCu" },
71
+ CV: { number: "+238", flag: "FlagsCv" },
72
+ CW: { number: "+599", flag: "FlagsCw" },
73
+ CY: { number: "+357", flag: "FlagsCy" },
74
+ CZ: { number: "+420", flag: "FlagsCz" },
75
+ DE: { number: "+49", flag: "FlagsDe" },
76
+ DJ: { number: "+253", flag: "FlagsDj" },
77
+ DK: { number: "+45", flag: "FlagsDk" },
78
+ DM: { number: "+1767", flag: "FlagsDm" },
79
+ DO: { number: "+1809", flag: "FlagsDo" },
80
+ DZ: { number: "+213", flag: "FlagsDz" },
81
+ EC: { number: "+593", flag: "FlagsEc" },
82
+ EE: { number: "+372", flag: "FlagsEe" },
83
+ EG: { number: "+20", flag: "FlagsEg" },
84
+ EH: { number: "+212", flag: "FlagsEh" },
85
+ ER: { number: "+291", flag: "FlagsEr" },
86
+ ES: { number: "+34", flag: "FlagsEs" },
87
+ ET: { number: "+251", flag: "FlagsEt" },
88
+ FI: { number: "+358", flag: "FlagsFi" },
89
+ FJ: { number: "+679", flag: "FlagsFj" },
90
+ FK: { number: "+500", flag: "FlagsFk" },
91
+ FM: { number: "+691", flag: "FlagsFm" },
92
+ FO: { number: "+298", flag: "FlagsFo" },
93
+ FR: { number: "+33", flag: "FlagsFr" },
94
+ GA: { number: "+241", flag: "FlagsGa" },
95
+ GB: { number: "+44", flag: "FlagsGb" },
96
+ GD: { number: "+1473", flag: "FlagsGd" },
97
+ GE: { number: "+995", flag: "FlagsGe" },
98
+ GG: { number: "+44", flag: "FlagsGg" },
99
+ GH: { number: "+233", flag: "FlagsGh" },
100
+ GI: { number: "+350", flag: "FlagsGi" },
101
+ GL: { number: "+299", flag: "FlagsGl" },
102
+ GM: { number: "+220", flag: "FlagsGm" },
103
+ GN: { number: "+224", flag: "FlagsGn" },
104
+ GQ: { number: "+240", flag: "FlagsGq" },
105
+ GR: { number: "+30", flag: "FlagsGr" },
106
+ GT: { number: "+502", flag: "FlagsGt" },
107
+ GU: { number: "+1671", flag: "FlagsGu" },
108
+ GW: { number: "+245", flag: "FlagsGw" },
109
+ GY: { number: "+592", flag: "FlagsGy" },
110
+ HK: { number: "+852", flag: "FlagsHk" },
111
+ HN: { number: "+504", flag: "FlagsHn" },
112
+ HR: { number: "+385", flag: "FlagsHr" },
113
+ HT: { number: "+509", flag: "FlagsHt" },
114
+ HU: { number: "+36", flag: "FlagsHu" },
115
+ ID: { number: "+62", flag: "FlagsId" },
116
+ IE: { number: "+353", flag: "FlagsIe" },
117
+ IL: { number: "+972", flag: "FlagsIl" },
118
+ IM: { number: "+44", flag: "FlagsIm" },
119
+ IN: { number: "+91", flag: "FlagsIn" },
120
+ IO: { number: "+246", flag: "FlagsIo" },
121
+ IQ: { number: "+964", flag: "FlagsIq" },
122
+ IR: { number: "+98", flag: "FlagsIr" },
123
+ IS: { number: "+354", flag: "FlagsIs" },
124
+ IT: { number: "+39", flag: "FlagsIt" },
125
+ JE: { number: "+44", flag: "FlagsJe" },
126
+ JM: { number: "+1876", flag: "FlagsJm" },
127
+ JO: { number: "+962", flag: "FlagsJo" },
128
+ JP: { number: "+81", flag: "FlagsJp" },
129
+ KE: { number: "+254", flag: "FlagsKe" },
130
+ KG: { number: "+996", flag: "FlagsKg" },
131
+ KH: { number: "+855", flag: "FlagsKh" },
132
+ KI: { number: "+686", flag: "FlagsKi" },
133
+ KM: { number: "+269", flag: "FlagsKm" },
134
+ KP: { number: "+850", flag: "FlagsKp" },
135
+ KR: { number: "+82", flag: "FlagsKr" },
136
+ KW: { number: "+965", flag: "FlagsKw" },
137
+ KY: { number: "+1345", flag: "FlagsKy" },
138
+ KZ: { number: "+7", flag: "FlagsKz" },
139
+ LA: { number: "+856", flag: "FlagsLa" },
140
+ LB: { number: "+961", flag: "FlagsLb" },
141
+ LC: { number: "+1758", flag: "FlagsLc" },
142
+ LI: { number: "+423", flag: "FlagsLi" },
143
+ LK: { number: "+94", flag: "FlagsLk" },
144
+ LR: { number: "+231", flag: "FlagsLr" },
145
+ LS: { number: "+266", flag: "FlagsLs" },
146
+ LT: { number: "+370", flag: "FlagsLt" },
147
+ LU: { number: "+352", flag: "FlagsLu" },
148
+ LV: { number: "+371", flag: "FlagsLv" },
149
+ LY: { number: "+218", flag: "FlagsLy" },
150
+ MA: { number: "+212", flag: "FlagsMa" },
151
+ MC: { number: "+377", flag: "FlagsMc" },
152
+ MD: { number: "+373", flag: "FlagsMd" },
153
+ ME: { number: "+382", flag: "FlagsMe" },
154
+ MG: { number: "+261", flag: "FlagsMg" },
155
+ MH: { number: "+692", flag: "FlagsMh" },
156
+ MK: { number: "+389", flag: "FlagsMk" },
157
+ ML: { number: "+223", flag: "FlagsMl" },
158
+ MM: { number: "+95", flag: "FlagsMm" },
159
+ MN: { number: "+976", flag: "FlagsMn" },
160
+ MO: { number: "+853", flag: "FlagsMo" },
161
+ MP: { number: "+1670", flag: "FlagsMp" },
162
+ MQ: { number: "+596", flag: "FlagsMq" },
163
+ MR: { number: "+222", flag: "FlagsMr" },
164
+ MS: { number: "+1664", flag: "FlagsMs" },
165
+ MT: { number: "+356", flag: "FlagsMt" },
166
+ MU: { number: "+230", flag: "FlagsMu" },
167
+ MV: { number: "+960", flag: "FlagsMv" },
168
+ MW: { number: "+265", flag: "FlagsMw" },
169
+ MX: { number: "+52", flag: "FlagsMx" },
170
+ MY: { number: "+60", flag: "FlagsMy" },
171
+ MZ: { number: "+258", flag: "FlagsMz" },
172
+ NA: { number: "+264", flag: "FlagsNa" },
173
+ NE: { number: "+227", flag: "FlagsNe" },
174
+ NF: { number: "+672", flag: "FlagsNf" },
175
+ NG: { number: "+234", flag: "FlagsNg" },
176
+ NI: { number: "+505", flag: "FlagsNi" },
177
+ NL: { number: "+31", flag: "FlagsNl" },
178
+ NO: { number: "+47", flag: "FlagsNo" },
179
+ NP: { number: "+977", flag: "FlagsNp" },
180
+ NR: { number: "+674", flag: "FlagsNr" },
181
+ NU: { number: "+683", flag: "FlagsNu" },
182
+ NZ: { number: "+64", flag: "FlagsNz" },
183
+ OM: { number: "+968", flag: "FlagsOm" },
184
+ PA: { number: "+507", flag: "FlagsPa" },
185
+ PE: { number: "+51", flag: "FlagsPe" },
186
+ PF: { number: "+689", flag: "FlagsPf" },
187
+ PG: { number: "+675", flag: "FlagsPg" },
188
+ PH: { number: "+63", flag: "FlagsPh" },
189
+ PK: { number: "+92", flag: "FlagsPk" },
190
+ PL: { number: "+48", flag: "FlagsPl" },
191
+ PN: { number: "+64", flag: "FlagsPn" },
192
+ PR: { number: "+1787", flag: "FlagsPr" },
193
+ PS: { number: "+970", flag: "FlagsPs" },
194
+ PT: { number: "+351", flag: "FlagsPt" },
195
+ PW: { number: "+680", flag: "FlagsPw" },
196
+ PY: { number: "+595", flag: "FlagsPy" },
197
+ QA: { number: "+974", flag: "FlagsQa" },
198
+ RO: { number: "+40", flag: "FlagsRo" },
199
+ RS: { number: "+381", flag: "FlagsRs" },
200
+ RU: { number: "+7", flag: "FlagsRu" },
201
+ RW: { number: "+250", flag: "FlagsRw" },
202
+ SA: { number: "+966", flag: "FlagsSa" },
203
+ SB: { number: "+677", flag: "FlagsSb" },
204
+ SC: { number: "+248", flag: "FlagsSc" },
205
+ SD: { number: "+249", flag: "FlagsSd" },
206
+ SE: { number: "+46", flag: "FlagsSe" },
207
+ SG: { number: "+65", flag: "FlagsSg" },
208
+ SI: { number: "+386", flag: "FlagsSi" },
209
+ SK: { number: "+421", flag: "FlagsSk" },
210
+ SL: { number: "+232", flag: "FlagsSl" },
211
+ SM: { number: "+378", flag: "FlagsSm" },
212
+ SN: { number: "+221", flag: "FlagsSn" },
213
+ SO: { number: "+252", flag: "FlagsSo" },
214
+ SR: { number: "+597", flag: "FlagsSr" },
215
+ SS: { number: "+211", flag: "FlagsSs" },
216
+ ST: { number: "+239", flag: "FlagsSt" },
217
+ SV: { number: "+503", flag: "FlagsSv" },
218
+ SX: { number: "+1721", flag: "FlagsSx" },
219
+ SY: { number: "+963", flag: "FlagsSy" },
220
+ SZ: { number: "+268", flag: "FlagsSz" },
221
+ TC: { number: "+1649", flag: "FlagsTc" },
222
+ TD: { number: "+235", flag: "FlagsTd" },
223
+ TG: { number: "+228", flag: "FlagsTg" },
224
+ TH: { number: "+66", flag: "FlagsTh" },
225
+ TJ: { number: "+992", flag: "FlagsTj" },
226
+ TK: { number: "+690", flag: "FlagsTk" },
227
+ TL: { number: "+670", flag: "FlagsTl" },
228
+ TM: { number: "+993", flag: "FlagsTm" },
229
+ TN: { number: "+216", flag: "FlagsTn" },
230
+ TO: { number: "+676", flag: "FlagsTo" },
231
+ TR: { number: "+90", flag: "FlagsTr" },
232
+ TT: { number: "+1868", flag: "FlagsTt" },
233
+ TV: { number: "+688", flag: "FlagsTv" },
234
+ TW: { number: "+886", flag: "FlagsTw" },
235
+ TZ: { number: "+255", flag: "FlagsTz" },
236
+ UA: { number: "+380", flag: "FlagsUa" },
237
+ UG: { number: "+256", flag: "FlagsUg" },
238
+ US: { number: "+1", flag: "FlagsUs" },
239
+ UY: { number: "+598", flag: "FlagsUy" },
240
+ UZ: { number: "+998", flag: "FlagsUz" },
241
+ VA: { number: "+379", flag: "FlagsVa" },
242
+ VC: { number: "+1784", flag: "FlagsVc" },
243
+ VE: { number: "+58", flag: "FlagsVe" },
244
+ VG: { number: "+1284", flag: "FlagsVg" },
245
+ VI: { number: "+1340", flag: "FlagsVi" },
246
+ VN: { number: "+84", flag: "FlagsVn" },
247
+ VU: { number: "+678", flag: "FlagsVu" },
248
+ WS: { number: "+685", flag: "FlagsWs" },
249
+ XK: { number: "+383", flag: "FlagsXk" },
250
+ YE: { number: "+967", flag: "FlagsYe" },
251
+ ZA: { number: "+27", flag: "FlagsZa" },
252
+ ZM: { number: "+260", flag: "FlagsZm" },
253
+ ZW: { number: "+263", flag: "FlagsZw" }
254
+ };
255
+ function skErrorId(id) {
256
+ return `${id}-error`;
257
+ }
258
+ function skDescriptionId(id) {
259
+ return `${id}-description`;
260
+ }
261
+ function skA11yAttrs(options) {
262
+ return {
263
+ "aria-invalid": options.invalid || void 0,
264
+ "aria-errormessage": options.invalid ? skErrorId(options.id) : void 0,
265
+ "aria-required": options.required || void 0
266
+ };
267
+ }
268
+ function useA11yAttrs(required) {
269
+ const attrs = useAttrs();
270
+ return computed(() => {
271
+ const a11y = {};
272
+ for (const name of required) {
273
+ if (attrs[name] !== void 0) {
274
+ a11y[name] = attrs[name];
275
+ }
276
+ }
277
+ return a11y;
278
+ });
279
+ }
280
+ function useName(name) {
281
+ const fallback = typeof globalThis.crypto?.randomUUID === "function" ? globalThis.crypto.randomUUID() : String(Date.now());
282
+ return computed(() => name ?? fallback);
283
+ }
284
+ function skCastModelValue(value, modifiers) {
285
+ if (value === void 0 || value === null) return value;
286
+ if (modifiers.number) {
287
+ if (typeof value === "number") return value;
288
+ const parsed = Number.parseFloat(String(value));
289
+ return Number.isNaN(parsed) ? value : parsed;
290
+ }
291
+ if (modifiers.boolean) {
292
+ if (typeof value === "boolean") return value;
293
+ if (value === "true") return true;
294
+ if (value === "false") return false;
295
+ return value;
296
+ }
297
+ return value;
298
+ }
299
+ const DEFAULT_LOCALE = "en";
300
+ function resolveLocalizedText(text, locale = DEFAULT_LOCALE, fallbackLocale) {
301
+ for (const code of [locale, fallbackLocale, DEFAULT_LOCALE]) {
302
+ const value = code ? text[code] : void 0;
303
+ if (typeof value === "string" && value) return value;
304
+ }
305
+ return Object.values(text).find(Boolean) ?? "";
306
+ }
307
+ const kitMessages = {
308
+ "constraint.required": {
309
+ en: "A value is required.",
310
+ de: "Ein Wert ist erforderlich."
311
+ },
312
+ "constraint.maxLength": {
313
+ en: "Use at most {max} characters.",
314
+ de: "Verwenden Sie höchstens {max} Zeichen."
315
+ },
316
+ "constraint.pattern": {
317
+ en: "The value does not match the expected format.",
318
+ de: "Der Wert entspricht nicht dem erwarteten Format."
319
+ },
320
+ "constraint.enum": {
321
+ en: "Choose one of the allowed values.",
322
+ de: "Wählen Sie einen der zulässigen Werte."
323
+ },
324
+ "constraint.format.hex": {
325
+ en: "Enter a valid hex color, for example #1A2B3C.",
326
+ de: "Geben Sie eine gültige Hex-Farbe ein, zum Beispiel #1A2B3C."
327
+ },
328
+ "constraint.format.email": {
329
+ en: "Enter a valid email address.",
330
+ de: "Geben Sie eine gültige E-Mail-Adresse ein."
331
+ },
332
+ "constraint.format.phone": {
333
+ en: "Enter a valid phone number.",
334
+ de: "Geben Sie eine gültige Telefonnummer ein."
335
+ },
336
+ "constraint.mimeTypes": {
337
+ en: "This file type is not allowed.",
338
+ de: "Dieser Dateityp ist nicht zulässig."
339
+ },
340
+ "constraint.invalid": { en: "Invalid value.", de: "Ungültiger Wert." },
341
+ "field.inheritLabel": { en: "Same as {name}", de: "Wie {name}" },
342
+ "field.inheritLabelDefault": {
343
+ en: "Use inherited value",
344
+ de: "Geerbten Wert verwenden"
345
+ },
346
+ "text.charCount": {
347
+ en: "{count}/{max} characters",
348
+ de: "{count}/{max} Zeichen"
349
+ },
350
+ "control.unsupported": {
351
+ en: "Unsupported control.",
352
+ de: "Nicht unterstütztes Eingabefeld."
353
+ },
354
+ "control.unsupportedNamed": {
355
+ en: 'Unsupported control "{control}".',
356
+ de: "Nicht unterstütztes Eingabefeld „{control}“."
357
+ },
358
+ "file.upload": { en: "Upload", de: "Hochladen" },
359
+ "file.preview": { en: "{label} preview", de: "Vorschau von {label}" },
360
+ "file.previewDefault": { en: "Preview", de: "Vorschau" },
361
+ "file.readError": {
362
+ en: "The file could not be read.",
363
+ de: "Die Datei konnte nicht gelesen werden."
364
+ },
365
+ "color.hexValue": { en: "{label} hex value", de: "Hex-Wert für {label}" },
366
+ "color.hexValueDefault": { en: "Hex value", de: "Hex-Wert" },
367
+ "tel.countryCode": {
368
+ en: "Country code: {country} ({dialCode})",
369
+ de: "Ländervorwahl: {country} ({dialCode})"
370
+ },
371
+ "tel.search": { en: "Search", de: "Suchen" },
372
+ "tel.searchCountry": { en: "Search country", de: "Land suchen" },
373
+ "tel.countryCodes": { en: "Country codes", de: "Ländervorwahlen" },
374
+ "period.unitAria": { en: "Period unit: {unit}", de: "Zeiteinheit: {unit}" },
375
+ "period.unit.d": { en: "Days", de: "Tage" },
376
+ "period.unit.w": { en: "Weeks", de: "Wochen" },
377
+ "period.unit.m": { en: "Months", de: "Monate" },
378
+ "period.unit.y": { en: "Years", de: "Jahre" },
379
+ "shell.title": {
380
+ en: "Organization settings",
381
+ de: "Organisationseinstellungen"
382
+ },
383
+ "shell.back": { en: "Back", de: "Zurück" },
384
+ "shell.toggleSidebar": {
385
+ en: "Toggle sidebar",
386
+ de: "Seitenleiste umschalten"
387
+ },
388
+ "shell.navigation": { en: "Settings", de: "Einstellungen" },
389
+ "shell.layout": { en: "Layout", de: "Layout" },
390
+ "shell.focusLayout": { en: "Focus layout", de: "Fokuslayout" },
391
+ "shell.sidebarLayout": { en: "Sidebar", de: "Seitenleiste" },
392
+ "shell.pageHasErrors": { en: "has errors", de: "enthält Fehler" }
393
+ };
394
+ function mergeLocalizedText(base, override) {
395
+ const merged = { ...base };
396
+ for (const [code, value] of Object.entries(override ?? {})) {
397
+ if (value) merged[code] = value;
398
+ }
399
+ return merged;
400
+ }
401
+ function formatMessage(template, params = {}) {
402
+ return template.replace(
403
+ /\{(\w+)\}/g,
404
+ (match, name) => Object.hasOwn(params, name) ? String(params[name]) : match
405
+ );
406
+ }
407
+ function resolveKitMessage(key, locale, fallbackLocale, overrides, params) {
408
+ const text = mergeLocalizedText(kitMessages[key], overrides?.[key]);
409
+ return formatMessage(
410
+ resolveLocalizedText(text, locale, fallbackLocale),
411
+ params
412
+ );
413
+ }
414
+ function useControlModel(props, emit, emptyValue) {
415
+ return computed({
416
+ get: () => props.modelValue ?? emptyValue,
417
+ set: (value) => emit("update:modelValue", value)
418
+ });
419
+ }
420
+ function isEmptyValue$1(value) {
421
+ if (value === void 0 || value === null || value === "") return true;
422
+ return Array.isArray(value) && value.length === 0;
423
+ }
424
+ function compareNumbers(value, bound, holds) {
425
+ if (value === null || value === void 0 || typeof value === "string" && value.trim() === "") {
426
+ return false;
427
+ }
428
+ const numeric = typeof value === "number" ? value : Number(value);
429
+ return !Number.isNaN(numeric) && holds(numeric, bound);
430
+ }
431
+ const leafOperators = {
432
+ equals: (value, operand) => value === operand,
433
+ notEquals: (value, operand) => value !== operand,
434
+ in: (value, operand) => operand.includes(value),
435
+ notIn: (value, operand) => !operand.includes(value),
436
+ gt: (value, operand) => compareNumbers(value, operand, (v, b) => v > b),
437
+ gte: (value, operand) => compareNumbers(value, operand, (v, b) => v >= b),
438
+ lt: (value, operand) => compareNumbers(value, operand, (v, b) => v < b),
439
+ lte: (value, operand) => compareNumbers(value, operand, (v, b) => v <= b),
440
+ isEmpty: (value, operand) => isEmptyValue$1(value) === operand,
441
+ notEmpty: (value, operand) => isEmptyValue$1(value) !== operand
442
+ };
443
+ function evaluateLeaf(leaf, values) {
444
+ const value = values[leaf.key];
445
+ return Object.keys(leafOperators).every((operator) => {
446
+ const operand = leaf[operator];
447
+ return operand === void 0 || leafOperators[operator](value, operand);
448
+ });
449
+ }
450
+ function evaluateCondition(condition, values) {
451
+ if ("allOf" in condition) {
452
+ return condition.allOf.every((child) => evaluateCondition(child, values));
453
+ }
454
+ if ("anyOf" in condition) {
455
+ return condition.anyOf.some((child) => evaluateCondition(child, values));
456
+ }
457
+ if ("not" in condition) {
458
+ return !evaluateCondition(condition.not, values);
459
+ }
460
+ return evaluateLeaf(condition, values);
461
+ }
462
+ function evaluateFieldRules(field, values) {
463
+ const state = { visible: true, enabled: true };
464
+ for (const rule of field.rules ?? []) {
465
+ const holds = evaluateCondition(rule.when, values);
466
+ if (rule.effect === "HIDE" && holds) state.visible = false;
467
+ if (rule.effect === "SHOW" && !holds) state.visible = false;
468
+ if (rule.effect === "DISABLE" && holds) state.enabled = false;
469
+ if (rule.effect === "ENABLE" && !holds) state.enabled = false;
470
+ }
471
+ return state;
472
+ }
473
+ function evaluateRuleStates(fields, values) {
474
+ const states = {};
475
+ for (const field of fields) {
476
+ states[field.key] = evaluateFieldRules(field, values);
477
+ }
478
+ return states;
479
+ }
480
+ function conditionKeys(condition) {
481
+ if ("allOf" in condition) return condition.allOf.flatMap(conditionKeys);
482
+ if ("anyOf" in condition) return condition.anyOf.flatMap(conditionKeys);
483
+ if ("not" in condition) return conditionKeys(condition.not);
484
+ return [condition.key];
485
+ }
486
+ function validateFieldRules(fields) {
487
+ const known = new Set(fields.map((field) => field.key));
488
+ for (const field of fields) {
489
+ if (field.fallback?.key === field.key) {
490
+ throw new Error(`Setting "${field.key}" falls back to itself.`);
491
+ }
492
+ }
493
+ const dependencies = /* @__PURE__ */ new Map();
494
+ for (const field of fields) {
495
+ const keys = (field.rules ?? []).flatMap(
496
+ (rule) => conditionKeys(rule.when)
497
+ );
498
+ for (const key of keys) {
499
+ if (!known.has(key)) {
500
+ throw new Error(
501
+ `Setting "${field.key}" has a rule referencing unknown setting "${key}".`
502
+ );
503
+ }
504
+ }
505
+ const fallback = field.fallback?.key;
506
+ dependencies.set(field.key, [
507
+ ...keys.filter((key) => key !== field.key),
508
+ ...fallback !== void 0 && known.has(fallback) ? [fallback] : []
509
+ ]);
510
+ }
511
+ const done = /* @__PURE__ */ new Set();
512
+ const inProgress = /* @__PURE__ */ new Set();
513
+ function visit(key, path) {
514
+ if (done.has(key)) return;
515
+ if (inProgress.has(key)) {
516
+ throw new Error(
517
+ `Setting rules form a cycle: ${[...path, key].join(" -> ")}.`
518
+ );
519
+ }
520
+ inProgress.add(key);
521
+ for (const dependency of dependencies.get(key) ?? []) {
522
+ visit(dependency, [...path, key]);
523
+ }
524
+ inProgress.delete(key);
525
+ done.add(key);
526
+ }
527
+ for (const key of dependencies.keys()) {
528
+ visit(key, []);
529
+ }
530
+ }
531
+ function isEmptyValue(value) {
532
+ if (value === void 0 || value === null || value === "") return true;
533
+ return Array.isArray(value) && value.length === 0;
534
+ }
535
+ const formatCheckers = {
536
+ hex: (value) => /^#[0-9a-f]{6}$/i.test(value),
537
+ email: (value) => {
538
+ const at = value.indexOf("@");
539
+ return at > 0 && value.indexOf(".", at) > at + 1 && !/\s/.test(value);
540
+ },
541
+ phone: (value) => /^\+?[\d\s\-()]{5,}$/.test(value)
542
+ };
543
+ const compiledPatterns = /* @__PURE__ */ new WeakMap();
544
+ function fieldPattern(field) {
545
+ const source = field.constraints?.pattern;
546
+ if (!source) return void 0;
547
+ const cached = compiledPatterns.get(field);
548
+ if (cached?.source === source) return cached.expression;
549
+ let expression;
550
+ try {
551
+ expression = new RegExp(source);
552
+ } catch {
553
+ expression = null;
554
+ }
555
+ compiledPatterns.set(field, { source, expression });
556
+ return expression;
557
+ }
558
+ function dataUrlMediaType(value) {
559
+ const headerEnd = [value.indexOf(";"), value.indexOf(",")].filter((index) => index >= 0).reduce((earliest, index) => Math.min(earliest, index), value.length);
560
+ return value.slice("data:".length, headerEnd);
561
+ }
562
+ const stringChecks = {
563
+ maxLength: (value, field) => {
564
+ const maxLength = field.constraints?.maxLength;
565
+ return maxLength !== void 0 && value.length > maxLength;
566
+ },
567
+ pattern: (value, field) => {
568
+ const expression = fieldPattern(field);
569
+ if (expression === void 0) return false;
570
+ return expression === null || !expression.test(value);
571
+ },
572
+ enum: (value, field) => {
573
+ const allowed = field.constraints?.enum;
574
+ return !!allowed && !allowed.includes(value);
575
+ },
576
+ format: (value, field) => {
577
+ const format = field.constraints?.format;
578
+ const check = format ? formatCheckers[format] : void 0;
579
+ return !!check && !check(value);
580
+ },
581
+ mimeTypes: (value, field) => {
582
+ const mimeTypes = field.constraints?.mimeTypes;
583
+ return !!mimeTypes && value.startsWith("data:") && !mimeTypes.includes(dataUrlMediaType(value));
584
+ }
585
+ };
586
+ function checkFieldConstraints(field, value) {
587
+ const constraints = field.constraints;
588
+ if (!constraints) return [];
589
+ if (isEmptyValue(value) || value === false) {
590
+ return constraints.required ? ["required"] : [];
591
+ }
592
+ if (typeof value !== "string") return [];
593
+ return Object.entries(stringChecks).filter(([, isViolated]) => isViolated(value, field)).map(([name]) => name);
594
+ }
595
+ function genericKey(field, constraint) {
596
+ const key = constraint === "format" ? `constraint.format.${field.constraints?.format}` : `constraint.${constraint}`;
597
+ return key in kitMessages ? key : "constraint.invalid";
598
+ }
599
+ function resolveConstraintMessage(field, constraint, locale, options = {}) {
600
+ const { fallbackLocale, messages } = options;
601
+ const owned = constraint ? field?.errors?.[constraint] : void 0;
602
+ if (owned) return resolveLocalizedText(owned, locale, fallbackLocale);
603
+ const key = constraint && field ? genericKey(field, constraint) : "constraint.invalid";
604
+ return resolveKitMessage(key, locale, fallbackLocale, messages, {
605
+ max: field?.constraints?.maxLength ?? ""
606
+ });
607
+ }
608
+ function byOrder(entries, missing = Number.POSITIVE_INFINITY) {
609
+ const rank = (entry) => Number.isFinite(entry.order) ? entry.order : missing;
610
+ return entries.map((entry, index) => ({ entry, index })).sort((a, b) => rank(a.entry) - rank(b.entry) || a.index - b.index).map(({ entry }) => entry);
611
+ }
612
+ function layoutIdSegment(uid) {
613
+ return encodeURIComponent(uid);
614
+ }
615
+ function layoutPageId(categoryUid, pageUid) {
616
+ return `${layoutIdSegment(categoryUid)}/${layoutIdSegment(pageUid)}`;
617
+ }
618
+ function columnsOf(layout) {
619
+ const columns = Math.floor(layout?.columns ?? 1);
620
+ return Number.isFinite(columns) && columns > 0 ? columns : 1;
621
+ }
622
+ function uniqueBy(entries) {
623
+ const seen = /* @__PURE__ */ new Set();
624
+ return entries.filter((entry) => {
625
+ if (seen.has(entry.uid)) return false;
626
+ seen.add(entry.uid);
627
+ return true;
628
+ });
629
+ }
630
+ function resolveLayout(layout, source, options = {}) {
631
+ const locale = options.locale ?? "en";
632
+ const text = (value) => value ? resolveLocalizedText(value, locale, options.fallbackLocale) : void 0;
633
+ const values = new Proxy({}, {
634
+ get: (_target, key) => typeof key === "string" ? source.valueOf(key) : void 0
635
+ });
636
+ const placed = /* @__PURE__ */ new Set();
637
+ const placedKeys = [];
638
+ const pageOfKey = /* @__PURE__ */ new Map();
639
+ let actions = [];
640
+ let pageId = "";
641
+ function item(entry, parentId, columns) {
642
+ const field = source.fieldByKey(entry.key);
643
+ if (!field || placed.has(entry.key)) return void 0;
644
+ placed.add(entry.key);
645
+ placedKeys.push(entry.key);
646
+ pageOfKey.set(entry.key, pageId);
647
+ const rule = evaluateFieldRules(field, values);
648
+ if (!rule.visible) return void 0;
649
+ const column = Number.isInteger(entry.column) && entry.column >= 1 && entry.column <= columns ? entry.column : void 0;
650
+ const node = {
651
+ kind: "item",
652
+ id: `${parentId}/${layoutIdSegment(entry.key)}`,
653
+ uid: entry.key,
654
+ key: entry.key,
655
+ field,
656
+ column,
657
+ rule
658
+ };
659
+ if (field.type === "actions") {
660
+ actions.push(node);
661
+ return void 0;
662
+ }
663
+ return node;
664
+ }
665
+ function items(entries, parentId, columns) {
666
+ return entries.flatMap((entry) => item(entry, parentId, columns) ?? []);
667
+ }
668
+ function group(entry, parentId) {
669
+ const id = `${parentId}/${layoutIdSegment(entry.uid)}`;
670
+ const columns = columnsOf(entry.layout);
671
+ const children = items(
672
+ byOrder(entry.items, Number.NEGATIVE_INFINITY),
673
+ id,
674
+ columns
675
+ );
676
+ if (!children.length) return void 0;
677
+ return {
678
+ kind: "group",
679
+ id,
680
+ uid: entry.uid,
681
+ label: text(entry.label),
682
+ description: text(entry.description),
683
+ showHeader: entry.presentation?.showHeader !== false,
684
+ columns,
685
+ children
686
+ };
687
+ }
688
+ function section(entry, parentId) {
689
+ const id = `${parentId}/${layoutIdSegment(entry.uid)}`;
690
+ const columns = columnsOf(entry.layout);
691
+ const ordered = byOrder(
692
+ [
693
+ ...(entry.items ?? []).map((value) => ({
694
+ kind: "item",
695
+ order: value.order,
696
+ entry: value
697
+ })),
698
+ ...uniqueBy(entry.groups ?? []).map((value) => ({
699
+ kind: "group",
700
+ order: value.order,
701
+ entry: value
702
+ }))
703
+ ],
704
+ Number.NEGATIVE_INFINITY
705
+ );
706
+ const children = ordered.flatMap(
707
+ (child) => child.kind === "item" ? item(child.entry, id, columns) ?? [] : group(child.entry, id) ?? []
708
+ );
709
+ if (!children.length) return void 0;
710
+ return {
711
+ kind: "section",
712
+ id,
713
+ uid: entry.uid,
714
+ label: text(entry.label),
715
+ description: text(entry.description),
716
+ showHeader: entry.presentation?.showHeader !== false,
717
+ columns,
718
+ children
719
+ };
720
+ }
721
+ function page(entry, category) {
722
+ pageId = layoutPageId(category.uid, entry.uid);
723
+ actions = [];
724
+ const children = byOrder(uniqueBy(entry.sections)).flatMap(
725
+ (value) => section(value, pageId) ?? []
726
+ );
727
+ return {
728
+ kind: "page",
729
+ id: pageId,
730
+ uid: entry.uid,
731
+ categoryId: category.uid,
732
+ path: `/${pageId}`,
733
+ label: text(entry.label) || entry.uid,
734
+ description: text(entry.description),
735
+ showHeader: entry.presentation?.showHeader !== false,
736
+ sidebar: entry.presentation?.sidebar === true,
737
+ sidebarMode: entry.presentation?.sidebarMode ?? "default",
738
+ children,
739
+ actions
740
+ };
741
+ }
742
+ const categories = byOrder(
743
+ uniqueBy(layout.categories)
744
+ ).map((category) => ({
745
+ kind: "category",
746
+ id: layoutIdSegment(category.uid),
747
+ uid: category.uid,
748
+ label: text(category.label) || category.uid,
749
+ children: byOrder(uniqueBy(category.pages)).map(
750
+ (entry) => page(entry, category)
751
+ )
752
+ }));
753
+ const pages = categories.flatMap((category) => category.children);
754
+ return {
755
+ categories,
756
+ pages,
757
+ pageById: new Map(pages.map((entry) => [entry.id, entry])),
758
+ pageOfKey,
759
+ placedKeys
760
+ };
761
+ }
762
+ function toNavigation(layout, options = {}) {
763
+ const isInvalid = options.isInvalid ?? (() => false);
764
+ const label = (text, fallback) => text && resolveLocalizedText(text, options.locale, options.fallbackLocale) || fallback;
765
+ function node(entry, text, children, invalid) {
766
+ const { id, kind, path } = entry;
767
+ return path === void 0 ? { id, kind, label: text, invalid, children } : { id, kind, label: text, path, invalid, children };
768
+ }
769
+ function item(entry) {
770
+ return node(
771
+ entry,
772
+ label(entry.field.label, entry.key),
773
+ [],
774
+ isInvalid(entry.key)
775
+ );
776
+ }
777
+ function nested(entry) {
778
+ const children = entry.children.flatMap(
779
+ (child) => child.kind === "item" ? [item(child)] : nested(child)
780
+ );
781
+ if (!entry.label) return children;
782
+ return [
783
+ node(
784
+ entry,
785
+ entry.label,
786
+ children,
787
+ children.some((child) => child.invalid)
788
+ )
789
+ ];
790
+ }
791
+ function page(entry) {
792
+ const invalid = keysOf(entry).some(isInvalid);
793
+ const children = options.depth === "item" ? entry.children.flatMap(nested) : [];
794
+ return node(
795
+ { id: entry.id, kind: "page", path: entry.path },
796
+ entry.label,
797
+ children,
798
+ invalid
799
+ );
800
+ }
801
+ return layout.categories.map((category) => {
802
+ const children = category.children.map(page);
803
+ return node(
804
+ category,
805
+ category.label,
806
+ children,
807
+ children.some((child) => child.invalid)
808
+ );
809
+ });
810
+ }
811
+ function keysOf(page) {
812
+ const keys = [];
813
+ const walk = (entry) => {
814
+ for (const child of entry.children) {
815
+ if (child.kind === "item") keys.push(child.key);
816
+ else walk(child);
817
+ }
818
+ };
819
+ page.children.forEach(walk);
820
+ return [...keys, ...page.actions.map((entry) => entry.key)];
821
+ }
822
+ function isColumnIn(column, columns) {
823
+ return Number.isInteger(column) && column >= 1 && column <= columns;
824
+ }
825
+ function checkSiblings(check, entries, parent, level) {
826
+ const seen = /* @__PURE__ */ new Set();
827
+ const kept = entries.filter((entry) => {
828
+ const path = join(parent, entry.uid);
829
+ if (!entry.uid) {
830
+ check.report(
831
+ "empty-uid",
832
+ path,
833
+ `A ${level} under "${parent}" has no uid.`
834
+ );
835
+ }
836
+ if (seen.has(entry.uid)) {
837
+ check.report(
838
+ "duplicate-uid",
839
+ path,
840
+ `${level} uid "${entry.uid}" repeats under "${parent || "layout"}"; only the first renders.`
841
+ );
842
+ return false;
843
+ }
844
+ seen.add(entry.uid);
845
+ return true;
846
+ });
847
+ return byOrder(kept);
848
+ }
849
+ function checkItems(check, entries, parent, columns = 1) {
850
+ for (const entry of byOrder(entries, Number.NEGATIVE_INFINITY)) {
851
+ const path = join(parent, entry.key);
852
+ if (check.known && !check.known.has(entry.key)) {
853
+ check.report("unknown-key", path, `No field has key "${entry.key}".`);
854
+ continue;
855
+ }
856
+ const first = check.placed.get(entry.key);
857
+ if (first !== void 0) {
858
+ check.report(
859
+ "duplicate-key",
860
+ path,
861
+ `"${entry.key}" is already placed at "${first}"; only the first renders.`
862
+ );
863
+ continue;
864
+ }
865
+ check.placed.set(entry.key, path);
866
+ if (entry.column !== void 0 && !isColumnIn(entry.column, columns)) {
867
+ check.report(
868
+ "invalid-column",
869
+ path,
870
+ `Column ${entry.column} is outside 1..${columns}; the pin is ignored.`,
871
+ "warning"
872
+ );
873
+ }
874
+ }
875
+ }
876
+ function checkRoute(check, category, page) {
877
+ const route = `/${layoutIdSegment(category.uid)}/${layoutIdSegment(page.uid)}`;
878
+ const folded = route.toLowerCase();
879
+ const clash = check.routes.get(folded);
880
+ if (clash === void 0) {
881
+ check.routes.set(folded, route);
882
+ return;
883
+ }
884
+ check.report(
885
+ "path-collision",
886
+ join(category.uid, page.uid),
887
+ `Route ${route} differs from ${clash} only by letter case; a case-insensitive URL cannot tell them apart.`,
888
+ "warning"
889
+ );
890
+ }
891
+ function checkPage(check, page, pagePath) {
892
+ for (const section of checkSiblings(
893
+ check,
894
+ page.sections,
895
+ pagePath,
896
+ "section"
897
+ )) {
898
+ const sectionPath = join(pagePath, section.uid);
899
+ checkItems(
900
+ check,
901
+ section.items ?? [],
902
+ sectionPath,
903
+ section.layout?.columns
904
+ );
905
+ for (const group of checkSiblings(
906
+ check,
907
+ section.groups ?? [],
908
+ sectionPath,
909
+ "group"
910
+ )) {
911
+ checkItems(
912
+ check,
913
+ group.items,
914
+ join(sectionPath, group.uid),
915
+ group.layout?.columns
916
+ );
917
+ }
918
+ }
919
+ }
920
+ function validateLayout(layout, fields) {
921
+ const issues = [];
922
+ const check = {
923
+ report: (code, path, message, severity = "error") => issues.push({ code, severity, path, message }),
924
+ known: fields && new Set(fields.map((field) => field.key)),
925
+ placed: /* @__PURE__ */ new Map(),
926
+ routes: /* @__PURE__ */ new Map()
927
+ };
928
+ for (const category of checkSiblings(
929
+ check,
930
+ layout.categories,
931
+ "",
932
+ "category"
933
+ )) {
934
+ for (const page of checkSiblings(
935
+ check,
936
+ category.pages,
937
+ category.uid,
938
+ "page"
939
+ )) {
940
+ checkRoute(check, category, page);
941
+ checkPage(check, page, join(category.uid, page.uid));
942
+ }
943
+ }
944
+ for (const field of fields ?? []) {
945
+ if (!check.placed.has(field.key)) {
946
+ check.report(
947
+ "unplaced-field",
948
+ field.key,
949
+ `Field "${field.key}" is not placed in the layout and never renders.`,
950
+ "warning"
951
+ );
952
+ }
953
+ }
954
+ return issues;
955
+ }
956
+ function join(parent, uid) {
957
+ return parent ? `${parent}/${uid}` : uid;
958
+ }
959
+ const settingsLocaleKey = /* @__PURE__ */ Symbol("settings-locale");
960
+ function createSettingsLocale(options) {
961
+ const locale = computed(() => toValue(options.locale) ?? DEFAULT_LOCALE);
962
+ const fallbackLocale = computed(() => toValue(options.fallbackLocale));
963
+ const messages = computed(() => toValue(options.messages));
964
+ return {
965
+ locale,
966
+ fallbackLocale,
967
+ messages,
968
+ resolveText: (text) => resolveLocalizedText(text, locale.value, fallbackLocale.value),
969
+ message: (key, params) => resolveKitMessage(
970
+ key,
971
+ locale.value,
972
+ fallbackLocale.value,
973
+ messages.value,
974
+ params
975
+ )
976
+ };
977
+ }
978
+ function provideSettingsLocale(options = {}) {
979
+ const parent = useSettingsLocale();
980
+ const context = createSettingsLocale({
981
+ locale: () => toValue(options.locale) ?? parent.locale.value,
982
+ fallbackLocale: () => toValue(options.fallbackLocale) ?? parent.fallbackLocale.value,
983
+ messages: () => {
984
+ const own = toValue(options.messages);
985
+ if (!own) return parent.messages.value;
986
+ const merged = { ...parent.messages.value };
987
+ for (const key of Object.keys(own)) {
988
+ merged[key] = mergeLocalizedText(merged[key], own[key]);
989
+ }
990
+ return merged;
991
+ }
992
+ });
993
+ provide(settingsLocaleKey, context);
994
+ return context;
995
+ }
996
+ function useSettingsLocale() {
997
+ const provided = hasInjectionContext() ? inject(settingsLocaleKey, void 0) : void 0;
998
+ return provided ?? createSettingsLocale({});
999
+ }
1000
+ const _hoisted_1$6 = {
1001
+ key: 0,
1002
+ class: "text-left label-xs-regular text-content-on-surface-muted"
1003
+ };
1004
+ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
1005
+ ...{
1006
+ name: "SkTextControl",
1007
+ inheritAttrs: false
1008
+ },
1009
+ __name: "SkTextControl",
1010
+ props: /* @__PURE__ */ mergeDefaults({
1011
+ type: {},
1012
+ maxLength: {},
1013
+ charCounter: { type: Boolean },
1014
+ modelValue: {},
1015
+ id: {},
1016
+ name: {},
1017
+ placeholder: {},
1018
+ disabled: { type: Boolean },
1019
+ inheriting: { type: Boolean },
1020
+ required: { type: Boolean },
1021
+ label: {},
1022
+ tooltip: {},
1023
+ errors: {}
1024
+ }, {
1025
+ ...skBaseControlDefaults,
1026
+ type: "text",
1027
+ maxLength: void 0,
1028
+ charCounter: false
1029
+ }),
1030
+ emits: ["update:modelValue", "change"],
1031
+ setup(__props, { emit: __emit }) {
1032
+ const props = __props;
1033
+ const emit = __emit;
1034
+ const model = useControlModel(props, emit, "");
1035
+ const controlName = useName(props?.name ?? props?.id);
1036
+ const a11yAttrs = useA11yAttrs([
1037
+ "aria-label",
1038
+ "aria-labelledby",
1039
+ "aria-describedby",
1040
+ "aria-invalid",
1041
+ "aria-required",
1042
+ "aria-errormessage"
1043
+ ]);
1044
+ const { message } = useSettingsLocale();
1045
+ const counter = computed(
1046
+ () => props.charCounter && props.maxLength ? message("text.charCount", {
1047
+ count: String(model.value ?? "").length,
1048
+ max: props.maxLength
1049
+ }) : void 0
1050
+ );
1051
+ function onChange(event) {
1052
+ const { value } = event.target;
1053
+ emit(
1054
+ "change",
1055
+ skCastModelValue(value, { number: props.type === "number" })
1056
+ );
1057
+ }
1058
+ return (_ctx, _cache) => {
1059
+ return openBlock(), createElementBlock(Fragment, null, [
1060
+ renderSlot(_ctx.$slots, "label"),
1061
+ createVNode(unref(UiInputGroup), null, {
1062
+ default: withCtx(() => [
1063
+ createVNode(unref(UiInputGroupInput), mergeProps({
1064
+ id: __props.id,
1065
+ modelValue: unref(model),
1066
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(model) ? model.value = $event : null)
1067
+ }, unref(a11yAttrs), {
1068
+ type: __props.type,
1069
+ name: unref(controlName),
1070
+ placeholder: __props.placeholder,
1071
+ disabled: __props.disabled,
1072
+ required: __props.required,
1073
+ maxlength: __props.maxLength,
1074
+ onChange
1075
+ }), null, 16, ["id", "modelValue", "type", "name", "placeholder", "disabled", "required", "maxlength"])
1076
+ ]),
1077
+ _: 1
1078
+ }),
1079
+ counter.value ? (openBlock(), createElementBlock("p", _hoisted_1$6, toDisplayString(counter.value), 1)) : createCommentVNode("", true),
1080
+ renderSlot(_ctx.$slots, "error")
1081
+ ], 64);
1082
+ };
1083
+ }
1084
+ });
1085
+ const _hoisted_1$5 = {
1086
+ role: "alert",
1087
+ class: "body-s-regular text-border-input-error"
1088
+ };
1089
+ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
1090
+ ...{
1091
+ name: "SkUnsupportedControl",
1092
+ inheritAttrs: false
1093
+ },
1094
+ __name: "SkUnsupportedControl",
1095
+ props: {
1096
+ control: {}
1097
+ },
1098
+ setup(__props) {
1099
+ const { message } = useSettingsLocale();
1100
+ return (_ctx, _cache) => {
1101
+ return openBlock(), createElementBlock("p", _hoisted_1$5, toDisplayString(__props.control ? unref(message)("control.unsupportedNamed", { control: __props.control }) : unref(message)("control.unsupported")), 1);
1102
+ };
1103
+ }
1104
+ });
1105
+ const reservedPresentationKeys = /* @__PURE__ */ new Set([
1106
+ "control",
1107
+ "inheritLabel",
1108
+ "inheritHint"
1109
+ ]);
1110
+ function presentationProps(field) {
1111
+ return Object.fromEntries(
1112
+ Object.entries(field.presentation ?? {}).filter(
1113
+ ([key]) => !reservedPresentationKeys.has(key)
1114
+ )
1115
+ );
1116
+ }
1117
+ const ControlLoading = () => h("div", {
1118
+ "aria-busy": "true",
1119
+ class: "h-10 w-full animate-pulse rounded-md bg-background-surface-muted"
1120
+ });
1121
+ function asyncControl(loader) {
1122
+ return defineAsyncComponent({
1123
+ loader,
1124
+ loadingComponent: ControlLoading,
1125
+ delay: 0
1126
+ });
1127
+ }
1128
+ const controlDefinitions = {
1129
+ text: {
1130
+ kind: "input",
1131
+ component: _sfc_main$7,
1132
+ // `charCounter`/`placeholder` arrive via presentation; the value type
1133
+ // and length limit map onto the input's own attributes.
1134
+ props: (field) => ({
1135
+ ...presentationProps(field),
1136
+ type: field.type === "number" ? "number" : "text",
1137
+ maxLength: field.constraints?.maxLength
1138
+ })
1139
+ },
1140
+ select: {
1141
+ kind: "input",
1142
+ component: asyncControl(
1143
+ () => import("./index-C-WLhRod.js").then(
1144
+ (m) => m.SkSelectControl
1145
+ )
1146
+ ),
1147
+ props: presentationProps
1148
+ },
1149
+ checkbox: {
1150
+ kind: "input",
1151
+ component: asyncControl(
1152
+ () => import("./index-CFMv8jSO.js").then(
1153
+ (m) => m.SkCheckboxControl
1154
+ )
1155
+ ),
1156
+ props: presentationProps
1157
+ },
1158
+ color: {
1159
+ kind: "input",
1160
+ component: asyncControl(
1161
+ () => import("./index-BynIH0EE.js").then(
1162
+ (m) => m.SkColorControl
1163
+ )
1164
+ ),
1165
+ props: presentationProps
1166
+ },
1167
+ phone: {
1168
+ kind: "input",
1169
+ component: asyncControl(
1170
+ () => import("./index-CGYERet5.js").then(
1171
+ (m) => m.SkTelControl
1172
+ )
1173
+ ),
1174
+ props: presentationProps
1175
+ },
1176
+ period: {
1177
+ kind: "input",
1178
+ component: asyncControl(
1179
+ () => import("./index-BXs-0JdT.js").then(
1180
+ (m) => m.SkPeriodControl
1181
+ )
1182
+ ),
1183
+ props: presentationProps
1184
+ },
1185
+ actions: {
1186
+ kind: "button",
1187
+ component: asyncControl(
1188
+ () => import("./index-KAbhkO1J.js").then(
1189
+ (m) => m.SkActionsControl
1190
+ )
1191
+ ),
1192
+ // `options` are the buttons. Each option value is the method name.
1193
+ props: presentationProps
1194
+ },
1195
+ "image-upload": {
1196
+ kind: "input",
1197
+ component: asyncControl(
1198
+ () => import("./index-BQ6z6MK4.js").then(
1199
+ (m) => m.SkFileUpload
1200
+ )
1201
+ ),
1202
+ // The upload control shows the description as visible copy, not a
1203
+ // tooltip, so it is the one control that can be `aria-describedby` it.
1204
+ props: (field, context) => ({
1205
+ ...presentationProps(field),
1206
+ description: context.tooltip,
1207
+ accept: field.constraints?.mimeTypes?.join(","),
1208
+ "aria-describedby": field.description ? skDescriptionId(field.key) : void 0
1209
+ })
1210
+ }
1211
+ };
1212
+ const fallbackDefinition = {
1213
+ // Emits nothing; `input` so no action listener is attached.
1214
+ kind: "input",
1215
+ component: _sfc_main$6,
1216
+ props: (field) => ({
1217
+ control: field.presentation?.control ?? field.type
1218
+ })
1219
+ };
1220
+ const skControlRegistryKey = /* @__PURE__ */ Symbol(
1221
+ "sk-control-registry"
1222
+ );
1223
+ function provideControls(definitions) {
1224
+ const registry = { ...useControlRegistry(), ...definitions };
1225
+ provide(skControlRegistryKey, registry);
1226
+ return registry;
1227
+ }
1228
+ function useControlRegistry() {
1229
+ const provided = hasInjectionContext() ? inject(skControlRegistryKey, void 0) : void 0;
1230
+ return provided ?? controlDefinitions;
1231
+ }
1232
+ const defaultControlByType = {
1233
+ string: "text",
1234
+ number: "text",
1235
+ boolean: "checkbox",
1236
+ asset: "image-upload",
1237
+ actions: "actions"
1238
+ };
1239
+ function resolveFieldControl(field) {
1240
+ return field.presentation?.control ?? defaultControlByType[field.type];
1241
+ }
1242
+ function resolveControlDefinition(field, registry = controlDefinitions) {
1243
+ const control = resolveFieldControl(field);
1244
+ return control && registry[control] || fallbackDefinition;
1245
+ }
1246
+ function createFieldInput(field) {
1247
+ return resolveControlDefinition(field).component;
1248
+ }
1249
+ function useFieldInheritance(props, session) {
1250
+ const handle = computed(() => session.field(props.field.key));
1251
+ const { message, resolveText } = useSettingsLocale();
1252
+ const declared = props.field.fallback;
1253
+ const targetKey = computed(
1254
+ () => props.field.fallback?.key ?? declared?.key ?? ""
1255
+ );
1256
+ const fallback = declared ? reactive({
1257
+ key: targetKey,
1258
+ id: computed(() => `${props.field.key}-fallback`),
1259
+ label: computed(() => {
1260
+ const { inheritLabel } = props.field.presentation ?? {};
1261
+ const custom = inheritLabel ? resolveText(inheritLabel) : "";
1262
+ if (custom) return custom;
1263
+ const target = session.fieldByKey(targetKey.value);
1264
+ const name = target?.label ? resolveText(target.label) : "";
1265
+ return name ? message("field.inheritLabel", { name }) : message("field.inheritLabelDefault");
1266
+ }),
1267
+ hint: computed(() => {
1268
+ const { inheritHint } = props.field.presentation ?? {};
1269
+ return inheritHint ? resolveText(inheritHint) : void 0;
1270
+ }),
1271
+ active: computed({
1272
+ get: () => handle.value.fallbackActive.value,
1273
+ set: (next) => {
1274
+ handle.value.fallbackActive.value = next;
1275
+ }
1276
+ })
1277
+ }) : void 0;
1278
+ return {
1279
+ fallback,
1280
+ inheriting: computed(() => handle.value.inheriting.value),
1281
+ inheritedFrom: computed(() => handle.value.inheritedFrom.value),
1282
+ fallbackActiveDefault: computed(
1283
+ () => handle.value.fallbackActiveDefault.value
1284
+ )
1285
+ };
1286
+ }
1287
+ function createStateManager(options = {}) {
1288
+ const work = shallowReactive(/* @__PURE__ */ new Map());
1289
+ const conflicts = shallowReactive(/* @__PURE__ */ new Map());
1290
+ const baselines = shallowReactive(/* @__PURE__ */ new Map());
1291
+ const schemaRevisions = /* @__PURE__ */ new Map();
1292
+ const registered = shallowReactive(/* @__PURE__ */ new Map());
1293
+ const savingKeys = shallowReactive(/* @__PURE__ */ new Set());
1294
+ const saving = ref(false);
1295
+ const areaStates = (options.areas ?? []).map(
1296
+ (area) => reactive({
1297
+ id: area.id,
1298
+ status: area.fields ? "ready" : "loading",
1299
+ fields: area.fields ?? [],
1300
+ keys: area.keys ?? [],
1301
+ error: void 0,
1302
+ load: area.load,
1303
+ loads: 0
1304
+ })
1305
+ );
1306
+ async function loadArea(state) {
1307
+ if (!state.load) return;
1308
+ const id = ++state.loads;
1309
+ state.status = "loading";
1310
+ state.error = void 0;
1311
+ try {
1312
+ const fields2 = await state.load();
1313
+ if (id !== state.loads) return;
1314
+ state.fields = fields2;
1315
+ state.status = "ready";
1316
+ } catch (error) {
1317
+ if (id !== state.loads) return;
1318
+ state.error = error;
1319
+ state.status = "unavailable";
1320
+ }
1321
+ }
1322
+ const areas = areaStates.map((state) => ({
1323
+ id: state.id,
1324
+ status: computed(() => state.status),
1325
+ fields: computed(() => state.status === "ready" ? state.fields : []),
1326
+ error: computed(() => state.error),
1327
+ reload: () => loadArea(state)
1328
+ }));
1329
+ for (const state of areaStates) {
1330
+ if (state.status === "loading") void loadArea(state);
1331
+ }
1332
+ function areaOf(key) {
1333
+ const index = areaStates.findIndex(
1334
+ (state) => state.keys.includes(key) || state.fields.some((field2) => field2.key === key)
1335
+ );
1336
+ return index === -1 ? void 0 : areas[index];
1337
+ }
1338
+ function available(key) {
1339
+ const area = areaOf(key);
1340
+ return !area || area.status.value === "ready";
1341
+ }
1342
+ function register(field2) {
1343
+ watchEffect(
1344
+ () => {
1345
+ const current = toValue(field2);
1346
+ registered.set(current.key, current);
1347
+ },
1348
+ { flush: "sync" }
1349
+ );
1350
+ }
1351
+ const declared = computed(() => toValue(options.fields) ?? []);
1352
+ const fieldsByKey = computed(() => {
1353
+ const map = /* @__PURE__ */ new Map();
1354
+ for (const [key, field2] of registered) map.set(key, field2);
1355
+ for (const field2 of declared.value) map.set(field2.key, field2);
1356
+ for (const state of areaStates) {
1357
+ for (const field2 of state.fields) map.set(field2.key, field2);
1358
+ }
1359
+ return map;
1360
+ });
1361
+ function fieldByKey(key) {
1362
+ return fieldsByKey.value.get(key);
1363
+ }
1364
+ function schemaRevision(key) {
1365
+ return schemaRevisions.get(key) ?? 0;
1366
+ }
1367
+ watch(
1368
+ () => new Map(
1369
+ [...fieldsByKey.value].map(([key, field2]) => [
1370
+ key,
1371
+ { field: field2, value: field2.value }
1372
+ ])
1373
+ ),
1374
+ (next, prev) => {
1375
+ for (const key of /* @__PURE__ */ new Set([...next.keys(), ...prev.keys()])) {
1376
+ const before = prev.get(key);
1377
+ const after = next.get(key);
1378
+ if (before?.field === after?.field && before?.value === after?.value)
1379
+ continue;
1380
+ schemaRevisions.set(key, schemaRevision(key) + 1);
1381
+ baselines.delete(key);
1382
+ }
1383
+ },
1384
+ { flush: "sync" }
1385
+ );
1386
+ function stored(key) {
1387
+ return baselines.has(key) ? baselines.get(key) : fieldByKey(key)?.value;
1388
+ }
1389
+ function base(key) {
1390
+ const value = stored(key);
1391
+ return value !== void 0 ? value : fieldByKey(key)?.default;
1392
+ }
1393
+ function fallbackDefault(key) {
1394
+ if (!fieldByKey(key)?.fallback) return false;
1395
+ const value = stored(key);
1396
+ return value === void 0 || value === null;
1397
+ }
1398
+ function fallbackOn(key) {
1399
+ if (!fieldByKey(key)?.fallback) return false;
1400
+ return work.get(key)?.fallback ?? fallbackDefault(key);
1401
+ }
1402
+ function own(key) {
1403
+ const current = work.get(key);
1404
+ return current && "edit" in current ? current.edit : base(key);
1405
+ }
1406
+ function sourceOf(key) {
1407
+ if (!fallbackOn(key)) return void 0;
1408
+ const source = fieldByKey(key)?.fallback?.key;
1409
+ return source !== void 0 && fieldsByKey.value.has(source) ? source : void 0;
1410
+ }
1411
+ function resolve(key, visited) {
1412
+ if (visited.has(key)) return void 0;
1413
+ visited.add(key);
1414
+ try {
1415
+ const source = sourceOf(key);
1416
+ return source === void 0 ? own(key) : resolve(source, visited);
1417
+ } finally {
1418
+ visited.delete(key);
1419
+ }
1420
+ }
1421
+ function valueOf(key) {
1422
+ return resolve(key, /* @__PURE__ */ new Set());
1423
+ }
1424
+ function isDirty(key) {
1425
+ if (fallbackOn(key)) return stored(key) != null;
1426
+ return valueOf(key) !== base(key);
1427
+ }
1428
+ function outgoing(key) {
1429
+ return fallbackOn(key) ? null : valueOf(key);
1430
+ }
1431
+ function status(key) {
1432
+ if (!available(key)) return "unavailable";
1433
+ if (savingKeys.has(key)) return "saving";
1434
+ if (conflicts.has(key)) return "conflicted";
1435
+ return isDirty(key) ? "dirty" : "clean";
1436
+ }
1437
+ function putWork(key, next) {
1438
+ if (!("edit" in next) && next.fallback === void 0) work.delete(key);
1439
+ else work.set(key, next);
1440
+ }
1441
+ function set(key, value) {
1442
+ const next = { ...work.get(key) };
1443
+ if (value === void 0) delete next.edit;
1444
+ else next.edit = value;
1445
+ putWork(key, next);
1446
+ }
1447
+ function pinned(key, fallback) {
1448
+ const next = { edit: own(key) };
1449
+ if (fallback !== void 0) next.fallback = fallback;
1450
+ return next;
1451
+ }
1452
+ function setFallbackOn(key, on) {
1453
+ putWork(key, on ? { fallback: true } : pinned(key, false));
1454
+ }
1455
+ function discardField(key) {
1456
+ work.delete(key);
1457
+ conflicts.delete(key);
1458
+ }
1459
+ function resetToDefault(key) {
1460
+ const field2 = fieldByKey(key);
1461
+ const next = {};
1462
+ if (field2?.default !== void 0) next.edit = field2.default;
1463
+ if (field2?.fallback) next.fallback = false;
1464
+ putWork(key, next);
1465
+ }
1466
+ function rebase(key) {
1467
+ const conflict = conflicts.get(key);
1468
+ conflicts.delete(key);
1469
+ if (conflict && "remote" in conflict) baselines.set(key, conflict.remote);
1470
+ }
1471
+ function keepMine(key) {
1472
+ if (!conflicts.has(key)) return;
1473
+ const declared2 = fieldByKey(key)?.fallback !== void 0;
1474
+ const on = fallbackOn(key);
1475
+ if (on) putWork(key, { fallback: true });
1476
+ else putWork(key, pinned(key, declared2 ? false : void 0));
1477
+ rebase(key);
1478
+ }
1479
+ function takeTheirs(key) {
1480
+ if (!conflicts.has(key)) return;
1481
+ rebase(key);
1482
+ work.delete(key);
1483
+ }
1484
+ const handles = /* @__PURE__ */ new Map();
1485
+ function field(key) {
1486
+ const existing = handles.get(key);
1487
+ if (existing) return existing;
1488
+ const handle = {
1489
+ key,
1490
+ field: computed(() => fieldByKey(key)),
1491
+ base: computed(() => base(key)),
1492
+ pending: computed(() => work.get(key)?.edit),
1493
+ value: computed({
1494
+ get: () => valueOf(key),
1495
+ set: (value) => set(key, value)
1496
+ }),
1497
+ remote: computed(() => conflicts.get(key)?.remote),
1498
+ fallbackActive: computed({
1499
+ get: () => fallbackOn(key),
1500
+ set: (on) => setFallbackOn(key, on)
1501
+ }),
1502
+ fallbackActiveDefault: computed(() => fallbackDefault(key)),
1503
+ inheritedFrom: computed(() => sourceOf(key)),
1504
+ inheriting: computed(() => sourceOf(key) !== void 0),
1505
+ isDirty: computed(() => isDirty(key)),
1506
+ status: computed(() => status(key)),
1507
+ set: (value) => set(key, value),
1508
+ discard: () => discardField(key),
1509
+ resetToDefault: () => resetToDefault(key),
1510
+ keepMine: () => keepMine(key),
1511
+ takeTheirs: () => takeTheirs(key)
1512
+ };
1513
+ handles.set(key, handle);
1514
+ return handle;
1515
+ }
1516
+ const keys = computed(
1517
+ () => /* @__PURE__ */ new Set([...fieldsByKey.value.keys(), ...work.keys()])
1518
+ );
1519
+ const fields = computed(
1520
+ () => [...fieldsByKey.value.values()].filter((field2) => available(field2.key))
1521
+ );
1522
+ const values = computed(() => {
1523
+ const result = {};
1524
+ for (const key of fieldsByKey.value.keys()) {
1525
+ if (available(key)) result[key] = valueOf(key);
1526
+ }
1527
+ return result;
1528
+ });
1529
+ const changes = computed(() => {
1530
+ const result = {};
1531
+ for (const key of keys.value) {
1532
+ if (fieldsByKey.value.has(key) && available(key) && isDirty(key)) {
1533
+ result[key] = outgoing(key);
1534
+ }
1535
+ }
1536
+ return result;
1537
+ });
1538
+ const sendable = computed(
1539
+ () => Object.fromEntries(
1540
+ Object.entries(changes.value).filter(([key]) => !conflicts.has(key))
1541
+ )
1542
+ );
1543
+ const canSave = computed(() => Object.keys(sendable.value).length > 0);
1544
+ const isDirtyAll = computed(() => [...keys.value].some(isDirty));
1545
+ const isSaving = computed(() => saving.value);
1546
+ const conflictKeys = computed(() => [...conflicts.keys()]);
1547
+ function reportedConflicts(result) {
1548
+ const reported = result?.conflicts;
1549
+ if (Array.isArray(reported)) {
1550
+ return new Map(reported.map((key) => [key, {}]));
1551
+ }
1552
+ return new Map(
1553
+ Object.entries(reported ?? {}).map(([key, remote]) => [key, { remote }])
1554
+ );
1555
+ }
1556
+ function settle(key, sent) {
1557
+ conflicts.delete(key);
1558
+ if (schemaRevision(key) === sent.schemaRevision) {
1559
+ baselines.set(key, sent.value);
1560
+ }
1561
+ if (work.get(key) === sent.work) work.delete(key);
1562
+ }
1563
+ async function save() {
1564
+ if (saving.value) return;
1565
+ const batch = { ...sendable.value };
1566
+ const batchKeys = Object.keys(batch);
1567
+ if (batchKeys.length === 0) return;
1568
+ const sent = new Map(
1569
+ batchKeys.map((key) => [
1570
+ key,
1571
+ {
1572
+ value: batch[key],
1573
+ work: work.get(key),
1574
+ schemaRevision: schemaRevision(key)
1575
+ }
1576
+ ])
1577
+ );
1578
+ saving.value = true;
1579
+ for (const key of batchKeys) savingKeys.add(key);
1580
+ try {
1581
+ const result = await options.onSave?.(batch);
1582
+ const reported = reportedConflicts(result);
1583
+ const rejected = new Set(result?.rejected ?? []);
1584
+ for (const [key, snapshot] of sent) {
1585
+ const conflict = reported.get(key);
1586
+ if (conflict) {
1587
+ if (snapshot.work === void 0 || work.has(key)) {
1588
+ conflicts.set(key, conflict);
1589
+ }
1590
+ } else if (!rejected.has(key)) {
1591
+ settle(key, snapshot);
1592
+ }
1593
+ }
1594
+ } finally {
1595
+ saving.value = false;
1596
+ savingKeys.clear();
1597
+ }
1598
+ }
1599
+ function discard() {
1600
+ work.clear();
1601
+ conflicts.clear();
1602
+ }
1603
+ return {
1604
+ field,
1605
+ fieldByKey,
1606
+ register,
1607
+ valueOf,
1608
+ areas,
1609
+ areaOf,
1610
+ fields,
1611
+ values,
1612
+ changes,
1613
+ canSave,
1614
+ isDirty: isDirtyAll,
1615
+ isSaving,
1616
+ conflicts: conflictKeys,
1617
+ save,
1618
+ discard,
1619
+ resetToDefault
1620
+ };
1621
+ }
1622
+ function useStateManager(options = {}) {
1623
+ return createStateManager(options);
1624
+ }
1625
+ const settingsFormSessionKey = /* @__PURE__ */ Symbol(
1626
+ "settings-form-session"
1627
+ );
1628
+ function useSettingsForm(options = {}) {
1629
+ const session = createStateManager(options);
1630
+ provide(settingsFormSessionKey, session);
1631
+ return session;
1632
+ }
1633
+ function useSettingsFormSession() {
1634
+ return hasInjectionContext() ? inject(settingsFormSessionKey, void 0) : void 0;
1635
+ }
1636
+ function useSettingField(props, options = {}) {
1637
+ const session = options.session ?? useSettingsFormSession() ?? createStateManager({ fields: options.fields });
1638
+ session.register(() => props.field);
1639
+ const handle = computed(() => session.field(props.field.key));
1640
+ const { resolveText } = useSettingsLocale();
1641
+ const label = computed(
1642
+ () => props.field.label ? resolveText(props.field.label) : ""
1643
+ );
1644
+ const description = computed(
1645
+ () => props.field.description ? resolveText(props.field.description) : void 0
1646
+ );
1647
+ const placeholder = computed(() => {
1648
+ const text = props.field.presentation?.placeholder;
1649
+ if (typeof text === "string") return text;
1650
+ return text ? resolveText(text) : void 0;
1651
+ });
1652
+ const registry = useControlRegistry();
1653
+ const definition = computed(
1654
+ () => resolveControlDefinition(props.field, registry)
1655
+ );
1656
+ const inputComponent = computed(() => definition.value.component);
1657
+ const errors = computed(() => props.errors ?? []);
1658
+ const disabled = computed(
1659
+ () => props.field.editable === false || props.disabled === true || handle.value.status.value === "unavailable"
1660
+ );
1661
+ const { fallback, inheriting, inheritedFrom } = useFieldInheritance(
1662
+ props,
1663
+ session
1664
+ );
1665
+ const controlProps = computed(() => ({
1666
+ ...definition.value.props(props.field, {
1667
+ label: label.value,
1668
+ tooltip: description.value
1669
+ }),
1670
+ // After the mapper: its props carry the raw `LocalizedText` placeholder.
1671
+ // A set `presentation.placeholder` also overrides a custom mapper's own.
1672
+ ...placeholder.value !== void 0 && { placeholder: placeholder.value },
1673
+ id: props.field.key,
1674
+ name: props.field.key,
1675
+ required: props.field.constraints?.required,
1676
+ disabled: disabled.value,
1677
+ // Each control decides how it behaves while inheriting.
1678
+ inheriting: inheriting.value,
1679
+ label: label.value,
1680
+ tooltip: description.value,
1681
+ errors: errors.value,
1682
+ ...skA11yAttrs({
1683
+ id: props.field.key,
1684
+ invalid: errors.value.length > 0,
1685
+ required: props.field.constraints?.required
1686
+ })
1687
+ }));
1688
+ const value = computed({
1689
+ get: () => handle.value.value.value,
1690
+ set: (next) => {
1691
+ handle.value.value.value = next;
1692
+ }
1693
+ });
1694
+ const pending = computed(() => handle.value.pending.value);
1695
+ const remote = computed(() => handle.value.remote.value);
1696
+ const isDirty = computed(() => handle.value.isDirty.value);
1697
+ const state = computed(() => {
1698
+ const status = handle.value.status.value;
1699
+ if (status !== "clean" && status !== "dirty") return status;
1700
+ if (errors.value.length > 0) return "invalid";
1701
+ return status;
1702
+ });
1703
+ return {
1704
+ // Live getter: always reflects the latest `field` prop.
1705
+ get field() {
1706
+ return props.field;
1707
+ },
1708
+ label,
1709
+ description,
1710
+ definition,
1711
+ inputComponent,
1712
+ controlProps,
1713
+ value,
1714
+ pending,
1715
+ remote,
1716
+ disabled,
1717
+ errors,
1718
+ isDirty,
1719
+ inheriting,
1720
+ inheritedFrom,
1721
+ fallback,
1722
+ state,
1723
+ session,
1724
+ discard: () => handle.value.discard(),
1725
+ resetToDefault: () => handle.value.resetToDefault()
1726
+ };
1727
+ }
1728
+ const _hoisted_1$4 = { class: "flex items-center gap-3" };
1729
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
1730
+ ...{
1731
+ name: "SkCheckboxControl",
1732
+ inheritAttrs: false
1733
+ },
1734
+ __name: "SkCheckboxControl",
1735
+ props: /* @__PURE__ */ mergeDefaults({
1736
+ modelValue: { type: Boolean },
1737
+ id: {},
1738
+ name: {},
1739
+ placeholder: {},
1740
+ disabled: { type: Boolean },
1741
+ inheriting: { type: Boolean },
1742
+ required: { type: Boolean },
1743
+ label: {},
1744
+ tooltip: {},
1745
+ errors: {}
1746
+ }, {
1747
+ ...skBaseControlDefaults
1748
+ }),
1749
+ emits: ["update:modelValue", "change"],
1750
+ setup(__props, { emit: __emit }) {
1751
+ const props = __props;
1752
+ const emit = __emit;
1753
+ const model = useControlModel(props, emit, false);
1754
+ const controlName = useName(props?.name ?? props?.id);
1755
+ const a11yAttrs = useA11yAttrs([
1756
+ "aria-label",
1757
+ "aria-labelledby",
1758
+ "aria-describedby",
1759
+ "aria-invalid",
1760
+ "aria-required",
1761
+ "aria-errormessage"
1762
+ ]);
1763
+ const checked = computed({
1764
+ get: () => model.value === true,
1765
+ set: (next) => {
1766
+ const value = next === true;
1767
+ model.value = value;
1768
+ emit("change", value);
1769
+ }
1770
+ });
1771
+ return (_ctx, _cache) => {
1772
+ return openBlock(), createElementBlock(Fragment, null, [
1773
+ createElementVNode("div", _hoisted_1$4, [
1774
+ createVNode(unref(UiCheckbox), mergeProps({
1775
+ id: __props.id,
1776
+ modelValue: checked.value,
1777
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => checked.value = $event)
1778
+ }, unref(a11yAttrs), {
1779
+ name: unref(controlName),
1780
+ disabled: __props.disabled,
1781
+ required: __props.required
1782
+ }), null, 16, ["id", "modelValue", "name", "disabled", "required"]),
1783
+ renderSlot(_ctx.$slots, "label")
1784
+ ]),
1785
+ renderSlot(_ctx.$slots, "error")
1786
+ ], 64);
1787
+ };
1788
+ }
1789
+ });
1790
+ const _hoisted_1$3 = ["id"];
1791
+ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
1792
+ ...{
1793
+ name: "SkField"
1794
+ },
1795
+ __name: "SkField",
1796
+ props: /* @__PURE__ */ mergeModels({
1797
+ disabled: { type: Boolean, default: false },
1798
+ errors: { default: void 0 },
1799
+ field: {}
1800
+ }, {
1801
+ "modelValue": {
1802
+ default: void 0
1803
+ },
1804
+ "modelModifiers": {}
1805
+ }),
1806
+ emits: /* @__PURE__ */ mergeModels(["update", "change", "action", "update:effective"], ["update:modelValue"]),
1807
+ setup(__props, { emit: __emit }) {
1808
+ const props = __props;
1809
+ const emit = __emit;
1810
+ const [model, modifiers] = useModel(__props, "modelValue", {
1811
+ set: (next) => cast(next)
1812
+ });
1813
+ function cast(next) {
1814
+ return skCastModelValue(next, modifiers);
1815
+ }
1816
+ const {
1817
+ controlProps,
1818
+ definition,
1819
+ inputComponent,
1820
+ value,
1821
+ pending,
1822
+ label,
1823
+ description,
1824
+ errors,
1825
+ fallback
1826
+ } = useSettingField(props);
1827
+ const incoming = computed(() => cast(model.value));
1828
+ if (incoming.value === void 0 && pending.value !== void 0) {
1829
+ model.value = pending.value;
1830
+ } else if (incoming.value !== pending.value) {
1831
+ value.value = incoming.value;
1832
+ }
1833
+ watch(incoming, (next) => {
1834
+ if (next !== pending.value) value.value = next;
1835
+ });
1836
+ watch(
1837
+ pending,
1838
+ (next) => {
1839
+ if (incoming.value !== next) model.value = next;
1840
+ },
1841
+ { flush: "sync" }
1842
+ );
1843
+ watch(value, (next) => emit("update:effective", next), {
1844
+ immediate: true,
1845
+ flush: "sync"
1846
+ });
1847
+ const controlModel = computed({
1848
+ get: () => value.value,
1849
+ set: (next) => {
1850
+ value.value = cast(next);
1851
+ }
1852
+ });
1853
+ const inputListeners = {
1854
+ "update:modelValue": (next) => emit("update", cast(next)),
1855
+ change: (next) => emit("change", cast(next))
1856
+ };
1857
+ const buttonListeners = {
1858
+ action: (method) => emit("action", method)
1859
+ };
1860
+ const isButtonControl = computed(() => definition.value.kind === "button");
1861
+ const controlListeners = computed(
1862
+ () => isButtonControl.value ? buttonListeners : inputListeners
1863
+ );
1864
+ const errorId = computed(() => skErrorId(props.field.key));
1865
+ const labelId = computed(() => `${props.field.key}-label`);
1866
+ const groupLabelAttrs = computed(
1867
+ () => isButtonControl.value && label.value ? { "aria-labelledby": labelId.value } : {}
1868
+ );
1869
+ const fallbackHintId = computed(
1870
+ () => fallback?.hint && fallback.active ? skDescriptionId(fallback.id) : void 0
1871
+ );
1872
+ return (_ctx, _cache) => {
1873
+ return openBlock(), createBlock(unref(UiField), {
1874
+ "data-invalid": unref(errors).length > 0 || void 0,
1875
+ class: "gap-2"
1876
+ }, {
1877
+ default: withCtx(() => [
1878
+ (openBlock(), createBlock(resolveDynamicComponent(unref(inputComponent)), mergeProps({
1879
+ modelValue: controlModel.value,
1880
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => controlModel.value = $event)
1881
+ }, { ...unref(controlProps), ...groupLabelAttrs.value }, toHandlers(controlListeners.value)), createSlots({
1882
+ label: withCtx(() => [
1883
+ unref(label) ? (openBlock(), createBlock(unref(UiFieldLabel), {
1884
+ key: 0,
1885
+ id: isButtonControl.value ? labelId.value : void 0,
1886
+ for: isButtonControl.value ? void 0 : __props.field.key,
1887
+ tooltip: unref(description)
1888
+ }, {
1889
+ default: withCtx(() => [
1890
+ createTextVNode(toDisplayString(unref(label)), 1)
1891
+ ]),
1892
+ _: 1
1893
+ }, 8, ["id", "for", "tooltip"])) : createCommentVNode("", true)
1894
+ ]),
1895
+ error: withCtx(() => [
1896
+ unref(errors).length ? (openBlock(), createBlock(unref(UiFieldError), {
1897
+ key: 0,
1898
+ id: errorId.value,
1899
+ errors: unref(errors),
1900
+ class: "label-xs-regular"
1901
+ }, null, 8, ["id", "errors"])) : createCommentVNode("", true)
1902
+ ]),
1903
+ _: 2
1904
+ }, [
1905
+ unref(fallback) ? {
1906
+ name: "addons",
1907
+ fn: withCtx(() => [
1908
+ createVNode(unref(_sfc_main$5), {
1909
+ id: unref(fallback).id,
1910
+ modelValue: unref(fallback).active,
1911
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => unref(fallback).active = $event),
1912
+ name: unref(fallback).id,
1913
+ "aria-describedby": fallbackHintId.value
1914
+ }, {
1915
+ label: withCtx(() => [
1916
+ createVNode(unref(UiFieldLabel), {
1917
+ for: unref(fallback).id
1918
+ }, {
1919
+ default: withCtx(() => [
1920
+ createTextVNode(toDisplayString(unref(fallback).label), 1)
1921
+ ]),
1922
+ _: 1
1923
+ }, 8, ["for"])
1924
+ ]),
1925
+ _: 1
1926
+ }, 8, ["id", "modelValue", "name", "aria-describedby"]),
1927
+ unref(fallback).hint && unref(fallback).active ? (openBlock(), createElementBlock("p", {
1928
+ key: 0,
1929
+ id: fallbackHintId.value,
1930
+ class: "label-xs-regular text-content-on-surface-muted mt-1"
1931
+ }, toDisplayString(unref(fallback).hint), 9, _hoisted_1$3)) : createCommentVNode("", true)
1932
+ ]),
1933
+ key: "0"
1934
+ } : void 0
1935
+ ]), 1040, ["modelValue"]))
1936
+ ]),
1937
+ _: 1
1938
+ }, 8, ["data-invalid"]);
1939
+ };
1940
+ }
1941
+ });
1942
+ const _hoisted_1$2 = { class: "col-span-full flex flex-col gap-2.5" };
1943
+ const _hoisted_2$2 = {
1944
+ key: 1,
1945
+ class: "body-s-regular text-content-on-surface-secondary"
1946
+ };
1947
+ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1948
+ ...{
1949
+ name: "SkGroup"
1950
+ },
1951
+ __name: "SkGroup",
1952
+ props: {
1953
+ title: { default: "" },
1954
+ description: { default: "" },
1955
+ columns: { default: 1 },
1956
+ level: { default: 3 }
1957
+ },
1958
+ setup(__props) {
1959
+ const props = __props;
1960
+ const columnCount = computed(
1961
+ () => props.columns > 0 ? Math.floor(props.columns) : 1
1962
+ );
1963
+ const heading = computed(
1964
+ () => `h${Math.min(Math.max(Math.round(props.level), 1), 6)}`
1965
+ );
1966
+ return (_ctx, _cache) => {
1967
+ return openBlock(), createElementBlock("div", _hoisted_1$2, [
1968
+ __props.title ? (openBlock(), createBlock(resolveDynamicComponent(heading.value), {
1969
+ key: 0,
1970
+ class: "label-s-medium text-content-on-surface-primary"
1971
+ }, {
1972
+ default: withCtx(() => [
1973
+ createTextVNode(toDisplayString(__props.title), 1)
1974
+ ]),
1975
+ _: 1
1976
+ })) : createCommentVNode("", true),
1977
+ __props.description ? (openBlock(), createElementBlock("p", _hoisted_2$2, toDisplayString(__props.description), 1)) : createCommentVNode("", true),
1978
+ createElementVNode("div", {
1979
+ class: "grid grid-cols-1 sm:grid-cols-[repeat(var(--sk-columns),minmax(0,1fr))] items-start gap-4",
1980
+ style: normalizeStyle({ "--sk-columns": columnCount.value })
1981
+ }, [
1982
+ renderSlot(_ctx.$slots, "default")
1983
+ ], 4)
1984
+ ]);
1985
+ };
1986
+ }
1987
+ });
1988
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1989
+ ...{
1990
+ name: "SkItem"
1991
+ },
1992
+ __name: "SkItem",
1993
+ props: {
1994
+ field: {},
1995
+ column: {},
1996
+ disabled: { type: Boolean },
1997
+ errors: {}
1998
+ },
1999
+ emits: ["action"],
2000
+ setup(__props, { emit: __emit }) {
2001
+ const props = __props;
2002
+ const emit = __emit;
2003
+ const pinned = computed(
2004
+ () => props.column !== void 0 && Number.isInteger(props.column) && props.column >= 1
2005
+ );
2006
+ return (_ctx, _cache) => {
2007
+ return openBlock(), createElementBlock("div", {
2008
+ class: normalizeClass(["min-w-0 w-full", { "sm:col-start-[var(--sk-column)]": pinned.value }]),
2009
+ style: normalizeStyle(pinned.value ? { "--sk-column": __props.column } : void 0)
2010
+ }, [
2011
+ createVNode(unref(_sfc_main$4), {
2012
+ field: __props.field,
2013
+ disabled: __props.disabled,
2014
+ errors: __props.errors,
2015
+ onAction: _cache[0] || (_cache[0] = ($event) => emit("action", $event))
2016
+ }, null, 8, ["field", "disabled", "errors"])
2017
+ ], 6);
2018
+ };
2019
+ }
2020
+ });
2021
+ function isThenable(value) {
2022
+ return typeof value === "object" && value !== null && typeof value.then === "function";
2023
+ }
2024
+ function useFieldValidator(fields, values, options = {}) {
2025
+ const clientIssues = ref([]);
2026
+ const serverReports = ref([]);
2027
+ const validationPending = ref(false);
2028
+ const validationRejected = ref(false);
2029
+ const injected = useSettingsLocale();
2030
+ const locale = () => toValue(options.locale) ?? injected.locale.value;
2031
+ const fallbackLocale = () => toValue(options.fallbackLocale) ?? injected.fallbackLocale.value;
2032
+ const messages = () => toValue(options.messages) ?? injected.messages.value;
2033
+ const constraintMessage = (field, constraint) => resolveConstraintMessage(field, constraint, locale(), {
2034
+ fallbackLocale: fallbackLocale(),
2035
+ messages: messages()
2036
+ });
2037
+ let validateToken = 0;
2038
+ function constraintIssues(field, value) {
2039
+ return checkFieldConstraints(field, value).map((constraint) => ({
2040
+ key: field.key,
2041
+ constraint,
2042
+ source: "client"
2043
+ }));
2044
+ }
2045
+ async function externalIssues(field, value, external) {
2046
+ const outcome = external["~standard"].validate(value);
2047
+ const result = isThenable(outcome) ? await outcome : outcome;
2048
+ return (result.issues ?? []).map((issue) => ({
2049
+ key: field.key,
2050
+ message: issue.message,
2051
+ source: "client"
2052
+ }));
2053
+ }
2054
+ function failureIssue(field, error) {
2055
+ console.error(error);
2056
+ const message = error instanceof Error && error.message ? error.message : void 0;
2057
+ return { key: field.key, message, source: "client" };
2058
+ }
2059
+ async function issuesForField(field, value, token) {
2060
+ try {
2061
+ const external = options.validators?.[field.key];
2062
+ const fieldIssues = external ? await externalIssues(field, value, external) : constraintIssues(field, value);
2063
+ if (token !== validateToken) return [];
2064
+ return fieldIssues;
2065
+ } catch (error) {
2066
+ if (token !== validateToken) return [];
2067
+ return [failureIssue(field, error)];
2068
+ }
2069
+ }
2070
+ async function collectIssues(token) {
2071
+ const valueMap = toValue(values);
2072
+ const groups = await Promise.all(
2073
+ toValue(fields).map(
2074
+ (field) => issuesForField(field, valueMap[field.key], token)
2075
+ )
2076
+ );
2077
+ if (token !== validateToken) return [];
2078
+ return groups.flat();
2079
+ }
2080
+ async function validate() {
2081
+ const token = ++validateToken;
2082
+ validationPending.value = true;
2083
+ try {
2084
+ const next = await collectIssues(token);
2085
+ if (token !== validateToken) return;
2086
+ validationRejected.value = false;
2087
+ clientIssues.value = next;
2088
+ } catch (error) {
2089
+ if (token === validateToken) {
2090
+ validationRejected.value = true;
2091
+ console.error(error);
2092
+ }
2093
+ throw error;
2094
+ } finally {
2095
+ if (token === validateToken) validationPending.value = false;
2096
+ }
2097
+ }
2098
+ let knownValues = { ...toValue(values) };
2099
+ watch(
2100
+ () => ({
2101
+ fields: toValue(fields),
2102
+ values: { ...toValue(values) }
2103
+ }),
2104
+ ({ values: now }) => {
2105
+ validate().catch(() => {
2106
+ });
2107
+ serverReports.value = serverReports.value.filter(
2108
+ (issue) => now[issue.key] === knownValues[issue.key]
2109
+ );
2110
+ knownValues = now;
2111
+ },
2112
+ { deep: true, immediate: true }
2113
+ );
2114
+ function applyServerIssues(reported) {
2115
+ serverReports.value = reported;
2116
+ }
2117
+ function clearServerIssues() {
2118
+ serverReports.value = [];
2119
+ }
2120
+ const fieldByKey = computed(
2121
+ () => new Map(toValue(fields).map((field) => [field.key, field]))
2122
+ );
2123
+ const serverIssues = computed(
2124
+ () => serverReports.value.map((issue) => ({
2125
+ key: issue.key,
2126
+ constraint: issue.constraint,
2127
+ source: "server",
2128
+ message: issue.message ?? constraintMessage(fieldByKey.value.get(issue.key), issue.constraint)
2129
+ }))
2130
+ );
2131
+ const worded = computed(
2132
+ () => clientIssues.value.map((issue) => ({
2133
+ ...issue,
2134
+ message: issue.message ?? constraintMessage(fieldByKey.value.get(issue.key), issue.constraint)
2135
+ }))
2136
+ );
2137
+ const issues = computed(() => [...worded.value, ...serverIssues.value]);
2138
+ const errorsByKey = computed(() => {
2139
+ const map = {};
2140
+ for (const issue of issues.value) {
2141
+ const messages2 = map[issue.key] ?? [];
2142
+ messages2.push(issue.message);
2143
+ map[issue.key] = messages2;
2144
+ }
2145
+ return map;
2146
+ });
2147
+ const isValid = computed(
2148
+ () => !validationPending.value && !validationRejected.value && issues.value.length === 0
2149
+ );
2150
+ const isValidating = computed(
2151
+ () => validationPending.value && !validationRejected.value
2152
+ );
2153
+ return {
2154
+ issues,
2155
+ errorsByKey,
2156
+ isValid,
2157
+ isValidating,
2158
+ validate,
2159
+ applyServerIssues,
2160
+ clearServerIssues
2161
+ };
2162
+ }
2163
+ function useSettingsLayout(options) {
2164
+ const session = options.session ?? useSettingsFormSession() ?? createStateManager({ fields: () => toValue(options.fields) ?? [] });
2165
+ provide(settingsFormSessionKey, session);
2166
+ const settings = options.settingsLocale ?? useSettingsLocale();
2167
+ const latest = computed(
2168
+ () => new Map((toValue(options.fields) ?? []).map((f) => [f.key, f]))
2169
+ );
2170
+ const registered = /* @__PURE__ */ new Set();
2171
+ watch(
2172
+ latest,
2173
+ (byKey) => {
2174
+ for (const [key, field] of byKey) {
2175
+ if (registered.has(key) || session.fieldByKey(key)) continue;
2176
+ registered.add(key);
2177
+ let last = field;
2178
+ session.register(() => last = latest.value.get(key) ?? last);
2179
+ }
2180
+ },
2181
+ { immediate: true, flush: "sync" }
2182
+ );
2183
+ const resolved = computed(
2184
+ () => resolveLayout(toValue(options.layout), session, {
2185
+ locale: settings.locale.value,
2186
+ fallbackLocale: settings.fallbackLocale.value
2187
+ })
2188
+ );
2189
+ const pages = computed(() => resolved.value.pages);
2190
+ const fields = computed(
2191
+ () => pages.value.flatMap(
2192
+ (entry) => keysOf(entry).flatMap((key) => {
2193
+ const field = session.fieldByKey(key);
2194
+ return field && field.type !== "actions" ? [field] : [];
2195
+ })
2196
+ )
2197
+ );
2198
+ const validator = useFieldValidator(fields, session.values, {
2199
+ locale: settings.locale,
2200
+ fallbackLocale: settings.fallbackLocale,
2201
+ messages: settings.messages,
2202
+ validators: options.validators
2203
+ });
2204
+ const revealed = ref(false);
2205
+ const errorsByKey = computed(() => {
2206
+ const shown = {};
2207
+ for (const issue of validator.issues.value) {
2208
+ const visible = issue.source === "server" || revealed.value || session.field(issue.key).isDirty.value;
2209
+ if (!visible) continue;
2210
+ shown[issue.key] = [...shown[issue.key] ?? [], issue.message];
2211
+ }
2212
+ return shown;
2213
+ });
2214
+ const navigation = computed(
2215
+ () => toNavigation(resolved.value, {
2216
+ locale: settings.locale.value,
2217
+ fallbackLocale: settings.fallbackLocale.value,
2218
+ isInvalid: (key) => (errorsByKey.value[key]?.length ?? 0) > 0
2219
+ })
2220
+ );
2221
+ const issues = computed(
2222
+ () => validateLayout(toValue(options.layout), session.fields.value)
2223
+ );
2224
+ return {
2225
+ session,
2226
+ resolved,
2227
+ pages,
2228
+ navigation,
2229
+ page: (id) => id ? resolved.value.pageById.get(id) : void 0,
2230
+ issues,
2231
+ fields,
2232
+ validator,
2233
+ errorsByKey,
2234
+ revealErrors: () => {
2235
+ revealed.value = true;
2236
+ },
2237
+ resetErrors: () => {
2238
+ revealed.value = false;
2239
+ }
2240
+ };
2241
+ }
2242
+ const _hoisted_1$1 = {
2243
+ key: 0,
2244
+ class: "mb-12"
2245
+ };
2246
+ const _hoisted_2$1 = {
2247
+ key: 1,
2248
+ class: "label-m-regular text-content-on-surface-primary mt-2"
2249
+ };
2250
+ const _hoisted_3 = { class: "flex flex-col gap-8" };
2251
+ const _hoisted_4 = {
2252
+ key: 0,
2253
+ class: "flex flex-col gap-4 py-4"
2254
+ };
2255
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
2256
+ ...{
2257
+ name: "SkPage"
2258
+ },
2259
+ __name: "SkPage",
2260
+ props: {
2261
+ title: { default: "" },
2262
+ description: { default: "" },
2263
+ level: { default: 1 },
2264
+ showHeader: { type: Boolean, default: true }
2265
+ },
2266
+ emits: ["submit"],
2267
+ setup(__props, { emit: __emit }) {
2268
+ const props = __props;
2269
+ const emit = __emit;
2270
+ const heading = computed(
2271
+ () => `h${Math.min(Math.max(Math.round(props.level), 1), 6)}`
2272
+ );
2273
+ return (_ctx, _cache) => {
2274
+ return openBlock(), createElementBlock("form", {
2275
+ class: "flex flex-col h-full justify-between gap-12",
2276
+ novalidate: "",
2277
+ onSubmit: _cache[0] || (_cache[0] = withModifiers(($event) => emit("submit"), ["prevent"]))
2278
+ }, [
2279
+ createElementVNode("div", null, [
2280
+ __props.showHeader && (__props.title || __props.description) ? (openBlock(), createElementBlock("div", _hoisted_1$1, [
2281
+ __props.title ? (openBlock(), createBlock(resolveDynamicComponent(heading.value), {
2282
+ key: 0,
2283
+ class: "heading-xl font-regular text-content-on-surface-primary mt-12"
2284
+ }, {
2285
+ default: withCtx(() => [
2286
+ createTextVNode(toDisplayString(__props.title), 1)
2287
+ ]),
2288
+ _: 1
2289
+ })) : createCommentVNode("", true),
2290
+ __props.description ? (openBlock(), createElementBlock("p", _hoisted_2$1, toDisplayString(__props.description), 1)) : createCommentVNode("", true)
2291
+ ])) : createCommentVNode("", true),
2292
+ createElementVNode("div", _hoisted_3, [
2293
+ renderSlot(_ctx.$slots, "default")
2294
+ ])
2295
+ ]),
2296
+ _ctx.$slots.actions ? (openBlock(), createElementBlock("div", _hoisted_4, [
2297
+ _cache[1] || (_cache[1] = createElementVNode("hr", { class: "border-t border-input" }, null, -1)),
2298
+ renderSlot(_ctx.$slots, "actions")
2299
+ ])) : createCommentVNode("", true)
2300
+ ], 32);
2301
+ };
2302
+ }
2303
+ });
2304
+ const _hoisted_1 = { class: "flex flex-col" };
2305
+ const _hoisted_2 = {
2306
+ key: 1,
2307
+ class: "body-s-regular text-content-on-surface-secondary mt-2 mb-4"
2308
+ };
2309
+ const _sfc_main = /* @__PURE__ */ defineComponent({
2310
+ ...{
2311
+ name: "SkSection"
2312
+ },
2313
+ __name: "SkSection",
2314
+ props: {
2315
+ title: { default: "" },
2316
+ description: { default: "" },
2317
+ columns: { default: 1 },
2318
+ level: { default: 2 }
2319
+ },
2320
+ setup(__props) {
2321
+ const props = __props;
2322
+ const columnCount = computed(
2323
+ () => props.columns > 0 ? Math.floor(props.columns) : 1
2324
+ );
2325
+ const heading = computed(
2326
+ () => `h${Math.min(Math.max(Math.round(props.level), 1), 6)}`
2327
+ );
2328
+ return (_ctx, _cache) => {
2329
+ return openBlock(), createElementBlock("div", _hoisted_1, [
2330
+ __props.title ? (openBlock(), createBlock(resolveDynamicComponent(heading.value), {
2331
+ key: 0,
2332
+ class: "body-m-bold text-content-on-surface-primary"
2333
+ }, {
2334
+ default: withCtx(() => [
2335
+ createTextVNode(toDisplayString(__props.title), 1)
2336
+ ]),
2337
+ _: 1
2338
+ })) : createCommentVNode("", true),
2339
+ __props.description ? (openBlock(), createElementBlock("p", _hoisted_2, toDisplayString(__props.description), 1)) : createCommentVNode("", true),
2340
+ createElementVNode("div", {
2341
+ class: "grid grid-cols-1 sm:grid-cols-[repeat(var(--sk-columns),minmax(0,1fr))] items-start justify-between gap-x-4 gap-y-8",
2342
+ style: normalizeStyle({ "--sk-columns": columnCount.value })
2343
+ }, [
2344
+ renderSlot(_ctx.$slots, "default")
2345
+ ], 4)
2346
+ ]);
2347
+ };
2348
+ }
2349
+ });
2350
+ const defaultBlocks = {
2351
+ page: _sfc_main$1,
2352
+ section: _sfc_main,
2353
+ group: _sfc_main$3,
2354
+ item: _sfc_main$2
2355
+ };
2356
+ const skLayoutContextKey = /* @__PURE__ */ Symbol("sk-layout-context");
2357
+ function useSkLayoutContext() {
2358
+ const context = inject(skLayoutContextKey, void 0);
2359
+ if (!context) {
2360
+ throw new Error(
2361
+ "SkLayoutPage must be rendered inside SkLayout or SkShell."
2362
+ );
2363
+ }
2364
+ return context;
2365
+ }
2366
+ function createActionEvent(method, key, pageId) {
2367
+ let prevented = false;
2368
+ return {
2369
+ method,
2370
+ key,
2371
+ pageId,
2372
+ preventDefault: () => {
2373
+ prevented = true;
2374
+ },
2375
+ get defaultPrevented() {
2376
+ return prevented;
2377
+ }
2378
+ };
2379
+ }
2380
+ function provideSkLayoutContext(model, options) {
2381
+ const context = {
2382
+ model,
2383
+ blocks: computed(() => ({ ...defaultBlocks, ...options.blocks() })),
2384
+ headingLevel: computed(() => options.headingLevel() ?? 1),
2385
+ dispatch: (method, key, pageId) => {
2386
+ const event = createActionEvent(method, key, pageId);
2387
+ options.onAction(event);
2388
+ if (event.defaultPrevented) return;
2389
+ runDefaultAction(model, method).catch(options.onError);
2390
+ }
2391
+ };
2392
+ provide(skLayoutContextKey, context);
2393
+ return context;
2394
+ }
2395
+ async function runDefaultAction(model, method) {
2396
+ if (method === "discard") {
2397
+ model.session.discard();
2398
+ model.validator.clearServerIssues();
2399
+ model.resetErrors();
2400
+ return;
2401
+ }
2402
+ if (method !== "apply") return;
2403
+ await model.validator.validate();
2404
+ if (!model.validator.isValid.value) {
2405
+ model.revealErrors();
2406
+ return;
2407
+ }
2408
+ model.validator.clearServerIssues();
2409
+ await model.session.save();
2410
+ model.resetErrors();
2411
+ }
2412
+ const clampLevel = (level) => Math.min(Math.max(level, 1), 6);
2413
+ const SkLayoutPage = defineComponent({
2414
+ name: "SkLayoutPage",
2415
+ props: {
2416
+ /** The resolved page to render. */
2417
+ page: { type: Object, required: true }
2418
+ },
2419
+ setup(props) {
2420
+ const context = useSkLayoutContext();
2421
+ const { model } = context;
2422
+ function item(node) {
2423
+ return h(context.blocks.value.item, {
2424
+ key: node.id,
2425
+ field: node.field,
2426
+ column: node.column,
2427
+ disabled: !node.rule.enabled,
2428
+ errors: model.errorsByKey.value[node.key]
2429
+ });
2430
+ }
2431
+ function group(node, level) {
2432
+ return h(
2433
+ context.blocks.value.group,
2434
+ {
2435
+ key: node.id,
2436
+ title: node.showHeader ? node.label : void 0,
2437
+ description: node.showHeader ? node.description : void 0,
2438
+ columns: node.columns,
2439
+ level: clampLevel(level)
2440
+ },
2441
+ { default: () => node.children.map(item) }
2442
+ );
2443
+ }
2444
+ function section(node, level) {
2445
+ const titled = node.showHeader && !!node.label;
2446
+ return h(
2447
+ context.blocks.value.section,
2448
+ {
2449
+ key: node.id,
2450
+ title: node.showHeader ? node.label : void 0,
2451
+ description: node.showHeader ? node.description : void 0,
2452
+ columns: node.columns,
2453
+ level: clampLevel(level)
2454
+ },
2455
+ {
2456
+ default: () => {
2457
+ const groupLevel = titled ? level + 1 : level;
2458
+ return node.children.map(
2459
+ (child) => child.kind === "item" ? item(child) : group(child, groupLevel)
2460
+ );
2461
+ }
2462
+ }
2463
+ );
2464
+ }
2465
+ function action(node, page) {
2466
+ return h(_sfc_main$4, {
2467
+ key: node.id,
2468
+ field: node.field,
2469
+ disabled: !node.rule.enabled || model.session.isSaving.value,
2470
+ onAction: (method) => context.dispatch(method, node.key, page.id)
2471
+ });
2472
+ }
2473
+ return () => {
2474
+ const page = props.page;
2475
+ const level = clampLevel(context.headingLevel.value);
2476
+ return h(
2477
+ context.blocks.value.page,
2478
+ {
2479
+ key: page.id,
2480
+ title: page.label,
2481
+ description: page.description,
2482
+ showHeader: page.showHeader,
2483
+ level
2484
+ },
2485
+ {
2486
+ default: () => page.children.map((child) => section(child, level + 1)),
2487
+ ...page.actions.length ? {
2488
+ actions: () => page.actions.map((node) => action(node, page))
2489
+ } : {}
2490
+ }
2491
+ );
2492
+ };
2493
+ }
2494
+ });
2495
+ export {
2496
+ toNavigation as A,
2497
+ useControlRegistry as B,
2498
+ useFieldInheritance as C,
2499
+ useFieldValidator as D,
2500
+ useSettingField as E,
2501
+ useSettingsForm as F,
2502
+ useSettingsFormSession as G,
2503
+ useSettingsLayout as H,
2504
+ useSettingsLocale as I,
2505
+ useStateManager as J,
2506
+ validateFieldRules as K,
2507
+ validateLayout as L,
2508
+ _sfc_main$5 as M,
2509
+ useControlModel as N,
2510
+ useName as O,
2511
+ useA11yAttrs as P,
2512
+ skBaseControlDefaults as Q,
2513
+ skPeriodUnits as R,
2514
+ SkLayoutPage as S,
2515
+ skDescriptionId as T,
2516
+ skCountries as U,
2517
+ resolveKitMessage as V,
2518
+ _sfc_main$4 as _,
2519
+ _sfc_main$3 as a,
2520
+ _sfc_main$2 as b,
2521
+ _sfc_main$1 as c,
2522
+ _sfc_main as d,
2523
+ byOrder as e,
2524
+ checkFieldConstraints as f,
2525
+ createFieldInput as g,
2526
+ createStateManager as h,
2527
+ defaultBlocks as i,
2528
+ evaluateCondition as j,
2529
+ evaluateFieldRules as k,
2530
+ evaluateRuleStates as l,
2531
+ keysOf as m,
2532
+ layoutIdSegment as n,
2533
+ layoutPageId as o,
2534
+ provideControls as p,
2535
+ provideSettingsLocale as q,
2536
+ provideSkLayoutContext as r,
2537
+ resolveConstraintMessage as s,
2538
+ resolveControlDefinition as t,
2539
+ resolveFieldControl as u,
2540
+ resolveLayout as v,
2541
+ resolveLocalizedText as w,
2542
+ settingsFormSessionKey as x,
2543
+ skControlRegistryKey as y,
2544
+ skLayoutContextKey as z
2545
+ };