mlform 0.1.9 → 0.1.10

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 (224) hide show
  1. package/README.md +16 -14
  2. package/dist/builtins-D8rXH4ED.js +725 -0
  3. package/dist/{design-system-CIU_vH6O.js → design-6suKVQDo.js} +15 -15
  4. package/dist/mlform/builtins.mjs +2 -0
  5. package/dist/mlform/{design-system.mjs → design.mjs} +2 -2
  6. package/dist/mlform/kit.mjs +1896 -3
  7. package/dist/mlform/primitives.mjs +2 -2
  8. package/dist/mlform/runtime.mjs +3 -4
  9. package/dist/mlform/schema.mjs +2 -102
  10. package/dist/mlform/transport.mjs +2 -2
  11. package/dist/{primitives-Di95y_ur.js → primitives-k9HTnd72.js} +2303 -3384
  12. package/dist/{runtime-C5iTM3uu.js → runtime-CI7vlp9i.js} +655 -791
  13. package/dist/schema-DSAZ6bts.js +88 -0
  14. package/dist/{transport-B6ePTLFK.js → transport-CO6udZ6z.js} +605 -575
  15. package/dist/types/{builtins-ml/definitions/index.d.ts → builtins/definitions/collections.d.ts} +0 -14
  16. package/dist/types/{shared/object.d.ts → builtins/definitions/fields/value-helpers.d.ts} +1 -0
  17. package/dist/types/builtins/definitions/index.d.ts +14 -0
  18. package/dist/types/{builtins-ml → builtins}/definitions/shared.d.ts +2 -9
  19. package/dist/types/builtins/index.d.ts +5 -0
  20. package/dist/types/builtins/mapped-category-behavior.d.ts +2 -0
  21. package/dist/types/builtins/registry-pack.d.ts +10 -0
  22. package/dist/types/{design-system/recipes/index.d.ts → design/recipes/collections.d.ts} +0 -1
  23. package/dist/types/design/recipes/index.d.ts +2 -0
  24. package/dist/types/design/resolve/index.d.ts +4 -0
  25. package/dist/types/{design-system/resolve/index.d.ts → design/resolve/resolve-design.d.ts} +0 -3
  26. package/dist/types/{design-system → design}/runtime/index.d.ts +3 -3
  27. package/dist/types/{design-system/themes/index.d.ts → design/themes/collections.d.ts} +0 -2
  28. package/dist/types/design/themes/index.d.ts +3 -0
  29. package/dist/types/{design-system → design}/types.d.ts +1 -1
  30. package/dist/types/kit/constants.d.ts +2 -10
  31. package/dist/types/kit/defaults.d.ts +1 -1
  32. package/dist/types/kit/disclosure-root-styles.d.ts +1 -0
  33. package/dist/types/kit/error-navigation.d.ts +2 -1
  34. package/dist/types/kit/index.d.ts +3 -5
  35. package/dist/types/{presentation → kit/kinds}/define-field-kind.d.ts +11 -3
  36. package/dist/types/kit/kinds/define-report-kind.d.ts +40 -0
  37. package/dist/types/kit/kinds/index.d.ts +3 -0
  38. package/dist/types/kit/kinds/register-kind.d.ts +5 -0
  39. package/dist/types/kit/layout-helpers.d.ts +7 -11
  40. package/dist/types/kit/layout-node-render.d.ts +4 -4
  41. package/dist/types/kit/layout-node-resolver.d.ts +1 -1
  42. package/dist/types/kit/{accordion-root.d.ts → layout-root.d.ts} +3 -4
  43. package/dist/types/kit/layout-types.d.ts +8 -36
  44. package/dist/types/kit/layout-utils.d.ts +0 -1
  45. package/dist/types/kit/layout.d.ts +2 -2
  46. package/dist/types/kit/mount-types.d.ts +8 -7
  47. package/dist/types/kit/panel-nav.d.ts +1 -1
  48. package/dist/types/kit/tabs-root.d.ts +1 -2
  49. package/dist/types/kit/types.d.ts +2 -3
  50. package/dist/types/kit/view-core-types.d.ts +110 -0
  51. package/dist/types/kit/view-layout-state.d.ts +10 -3
  52. package/dist/types/kit/view-navigation.d.ts +3 -3
  53. package/dist/types/kit/view-snapshot-cache.d.ts +3 -3
  54. package/dist/types/kit/view-snapshot.d.ts +4 -4
  55. package/dist/types/kit/view-types.d.ts +1 -172
  56. package/dist/types/kit/view.d.ts +2 -8
  57. package/dist/types/kit/wizard-root.d.ts +1 -2
  58. package/dist/types/primitives/base-async-report-element.d.ts +1 -1
  59. package/dist/types/primitives/base-field-element.d.ts +3 -3
  60. package/dist/types/primitives/base-report-element.d.ts +3 -3
  61. package/dist/types/primitives/components/descriptor-content.d.ts +4 -0
  62. package/dist/types/primitives/components/error-focus.d.ts +3 -2
  63. package/dist/types/primitives/components/field-frame-feedback.d.ts +3 -3
  64. package/dist/types/primitives/components/field-frame.d.ts +3 -3
  65. package/dist/types/primitives/components/form-errors.d.ts +2 -2
  66. package/dist/types/primitives/components/form-root-presenters.d.ts +6 -11
  67. package/dist/types/primitives/components/form-root-state.d.ts +4 -6
  68. package/dist/types/primitives/components/form-root-templates.d.ts +4 -8
  69. package/dist/types/primitives/components/form-root.d.ts +4 -4
  70. package/dist/types/primitives/components/report-frame.d.ts +4 -4
  71. package/dist/types/primitives/components/submit-button.d.ts +2 -2
  72. package/dist/types/primitives/constants.d.ts +6 -9
  73. package/dist/types/primitives/controller-types.d.ts +96 -0
  74. package/dist/types/primitives/descriptor-resolution.d.ts +6 -0
  75. package/dist/types/primitives/descriptors/content.d.ts +61 -0
  76. package/dist/types/primitives/descriptors/field.d.ts +32 -0
  77. package/dist/types/primitives/descriptors/index.d.ts +5 -0
  78. package/dist/types/primitives/descriptors/registry.d.ts +11 -0
  79. package/dist/types/primitives/descriptors/report.d.ts +20 -0
  80. package/dist/types/primitives/index.d.ts +8 -3
  81. package/dist/types/primitives/mount-form.d.ts +2 -2
  82. package/dist/types/primitives/request-runner.d.ts +13 -0
  83. package/dist/types/primitives/types.d.ts +16 -53
  84. package/dist/types/runtime/errors.d.ts +1 -2
  85. package/dist/types/runtime/index.d.ts +2 -4
  86. package/dist/types/runtime/reports/controller.d.ts +3 -2
  87. package/dist/types/runtime/runtime-controller.d.ts +1 -5
  88. package/dist/types/runtime/state/engine.d.ts +1 -2
  89. package/dist/types/runtime/submission/create-submitter.d.ts +1 -1
  90. package/dist/types/runtime/submission/index.d.ts +1 -1
  91. package/dist/types/runtime/submission/lifecycle.d.ts +1 -2
  92. package/dist/types/runtime/submission/pipeline.d.ts +1 -1
  93. package/dist/types/runtime/submission/report-fetches.d.ts +2 -0
  94. package/dist/types/runtime/submission/types.d.ts +1 -2
  95. package/dist/types/runtime/types/form.d.ts +9 -13
  96. package/dist/types/runtime/types/index.d.ts +0 -1
  97. package/dist/types/runtime/types/pipeline.d.ts +10 -10
  98. package/dist/types/runtime/types/registry.d.ts +2 -3
  99. package/dist/types/runtime/types/report.d.ts +4 -1
  100. package/dist/types/runtime/types/transport.d.ts +3 -4
  101. package/dist/types/runtime/utils.d.ts +1 -3
  102. package/dist/types/runtime/validation/form.d.ts +1 -1
  103. package/dist/types/schema/ids.d.ts +1 -0
  104. package/dist/types/schema/index.d.ts +3 -1
  105. package/dist/types/schema/registry.d.ts +2 -4
  106. package/dist/types/schema/report-fetch-request.d.ts +6 -0
  107. package/dist/types/schema/types/form.d.ts +0 -3
  108. package/dist/types/schema/types/registry.d.ts +0 -5
  109. package/dist/types/schema/types/report.d.ts +25 -3
  110. package/dist/types/schema/types/submit.d.ts +11 -0
  111. package/dist/types/transport/errors.d.ts +1 -2
  112. package/dist/types/transport/index.d.ts +2 -0
  113. package/dist/types/transport/request-runner.d.ts +16 -0
  114. package/package.json +9 -22
  115. package/dist/builtins-ml-pjab8_gu.js +0 -3878
  116. package/dist/errors-CTNw8fwS.js +0 -8
  117. package/dist/kit-QY6zff-h.js +0 -1888
  118. package/dist/mlform/behaviors.mjs +0 -32
  119. package/dist/mlform/builtins-ml.mjs +0 -2
  120. package/dist/mlform/presentation.mjs +0 -2
  121. package/dist/mlform.mjs +0 -8
  122. package/dist/presentation-BrlVO4oV.js +0 -200
  123. package/dist/strings-CWwrrYzz.js +0 -4
  124. package/dist/types/behaviors/index.d.ts +0 -3
  125. package/dist/types/builtins-ml/index.d.ts +0 -5
  126. package/dist/types/index.d.ts +0 -13
  127. package/dist/types/kit/accordion-root-styles.d.ts +0 -1
  128. package/dist/types/kit/accordion.d.ts +0 -2
  129. package/dist/types/kit/tabs.d.ts +0 -2
  130. package/dist/types/kit/wizard.d.ts +0 -2
  131. package/dist/types/packs/default.d.ts +0 -2
  132. package/dist/types/packs/index.d.ts +0 -3
  133. package/dist/types/packs/ml.d.ts +0 -2
  134. package/dist/types/packs/shared.d.ts +0 -24
  135. package/dist/types/presentation/define-explanation-kind.d.ts +0 -11
  136. package/dist/types/presentation/define-report-kind.d.ts +0 -15
  137. package/dist/types/presentation/index.d.ts +0 -10
  138. package/dist/types/presentation/register-kind.d.ts +0 -6
  139. package/dist/types/presentation/registry.d.ts +0 -15
  140. package/dist/types/presentation/types/explanation.d.ts +0 -32
  141. package/dist/types/presentation/types/field.d.ts +0 -36
  142. package/dist/types/presentation/types/presentation.d.ts +0 -61
  143. package/dist/types/presentation/types/report.d.ts +0 -41
  144. package/dist/types/primitives/base-explanation-element.d.ts +0 -22
  145. package/dist/types/primitives/components/declarative-explanation.d.ts +0 -5
  146. package/dist/types/primitives/components/explanation-panel.d.ts +0 -24
  147. package/dist/types/primitives/components/presentation.d.ts +0 -4
  148. package/dist/types/primitives/presentation.d.ts +0 -8
  149. package/dist/types/runtime/explanations/controller.d.ts +0 -13
  150. package/dist/types/runtime/explanations/index.d.ts +0 -1
  151. package/dist/types/runtime/schema/index.d.ts +0 -7
  152. package/dist/types/runtime/submission/explanations.d.ts +0 -2
  153. package/dist/types/runtime/types/explanation.d.ts +0 -15
  154. package/dist/types/schema/types/explanation.d.ts +0 -43
  155. package/dist/types/shared/errors.d.ts +0 -3
  156. package/dist/types/shared/index.d.ts +0 -3
  157. package/dist/types/shared/strings.d.ts +0 -1
  158. package/dist/utils-J5o8lkea.js +0 -29
  159. /package/dist/types/{runtime → builtins}/constants.d.ts +0 -0
  160. /package/dist/types/{builtins-ml → builtins}/definitions/fields/boolean.d.ts +0 -0
  161. /package/dist/types/{builtins-ml → builtins}/definitions/fields/category.d.ts +0 -0
  162. /package/dist/types/{builtins-ml → builtins}/definitions/fields/date.d.ts +0 -0
  163. /package/dist/types/{builtins-ml → builtins}/definitions/fields/long-text.d.ts +0 -0
  164. /package/dist/types/{builtins-ml → builtins}/definitions/fields/mapped-category.d.ts +0 -0
  165. /package/dist/types/{builtins-ml → builtins}/definitions/fields/multi-choice.d.ts +0 -0
  166. /package/dist/types/{builtins-ml → builtins}/definitions/fields/number.d.ts +0 -0
  167. /package/dist/types/{builtins-ml → builtins}/definitions/fields/rating.d.ts +0 -0
  168. /package/dist/types/{builtins-ml → builtins}/definitions/fields/series-helpers.d.ts +0 -0
  169. /package/dist/types/{builtins-ml → builtins}/definitions/fields/series.d.ts +0 -0
  170. /package/dist/types/{builtins-ml → builtins}/definitions/fields/single-choice.d.ts +0 -0
  171. /package/dist/types/{builtins-ml → builtins}/definitions/fields/text.d.ts +0 -0
  172. /package/dist/types/{builtins-ml → builtins}/definitions/reports/classifier.d.ts +0 -0
  173. /package/dist/types/{builtins-ml → builtins}/definitions/reports/regressor.d.ts +0 -0
  174. /package/dist/types/{design-system → design}/constants.d.ts +0 -0
  175. /package/dist/types/{design-system → design}/contract/component-keys.d.ts +0 -0
  176. /package/dist/types/{design-system → design}/contract/component-tokens.d.ts +0 -0
  177. /package/dist/types/{design-system → design}/contract/global-tokens.d.ts +0 -0
  178. /package/dist/types/{design-system → design}/contract/index.d.ts +0 -0
  179. /package/dist/types/{design-system → design}/contract/token-keys.d.ts +0 -0
  180. /package/dist/types/{design-system → design}/index.d.ts +0 -0
  181. /package/dist/types/{design-system → design}/recipes/contrast.d.ts +0 -0
  182. /package/dist/types/{design-system → design}/recipes/default.d.ts +0 -0
  183. /package/dist/types/{design-system → design}/recipes/minimal.d.ts +0 -0
  184. /package/dist/types/{design-system → design}/recipes/soft.d.ts +0 -0
  185. /package/dist/types/{design-system → design}/registry/builtins.d.ts +0 -0
  186. /package/dist/types/{design-system → design}/registry/create-registry.d.ts +0 -0
  187. /package/dist/types/{design-system → design}/registry/deep-freeze.d.ts +0 -0
  188. /package/dist/types/{design-system → design}/registry/define-recipe.d.ts +0 -0
  189. /package/dist/types/{design-system → design}/registry/define-theme.d.ts +0 -0
  190. /package/dist/types/{design-system → design}/registry/define-token-maps.d.ts +0 -0
  191. /package/dist/types/{design-system → design}/registry/index.d.ts +0 -0
  192. /package/dist/types/{design-system → design}/resolve/diagnostics.d.ts +0 -0
  193. /package/dist/types/{design-system → design}/resolve/merge-config.d.ts +0 -0
  194. /package/dist/types/{design-system → design}/resolve/migrate-tokens.d.ts +0 -0
  195. /package/dist/types/{design-system → design}/resolve/resolve-mode.d.ts +0 -0
  196. /package/dist/types/{design-system → design}/resolve/resolve-recipe.d.ts +0 -0
  197. /package/dist/types/{design-system → design}/resolve/resolve-theme.d.ts +0 -0
  198. /package/dist/types/{design-system → design}/resolve/resolve-tokens.d.ts +0 -0
  199. /package/dist/types/{design-system → design}/runtime/apply-tokens.d.ts +0 -0
  200. /package/dist/types/{design-system/runtime/attach-design-system.d.ts → design/runtime/attach-design.d.ts} +0 -0
  201. /package/dist/types/{design-system → design}/runtime/controller-helpers.d.ts +0 -0
  202. /package/dist/types/{design-system → design}/runtime/create-stylesheet.d.ts +0 -0
  203. /package/dist/types/{design-system → design}/runtime/declarations.d.ts +0 -0
  204. /package/dist/types/{design-system/runtime/design-system-controller.d.ts → design/runtime/design-controller.d.ts} +0 -0
  205. /package/dist/types/{design-system → design}/runtime/fingerprint.d.ts +0 -0
  206. /package/dist/types/{design-system → design}/runtime/host-observer.d.ts +0 -0
  207. /package/dist/types/{design-system → design}/runtime/host-state.d.ts +0 -0
  208. /package/dist/types/{design-system/runtime/hydrate-design-system.d.ts → design/runtime/hydrate-design.d.ts} +0 -0
  209. /package/dist/types/{design-system → design}/runtime/hydration-state.d.ts +0 -0
  210. /package/dist/types/{design-system → design}/runtime/inherited-scheme.d.ts +0 -0
  211. /package/dist/types/{design-system → design}/runtime/media.d.ts +0 -0
  212. /package/dist/types/{design-system → design}/themes/airbnb.d.ts +0 -0
  213. /package/dist/types/{design-system → design}/themes/clickhouse.d.ts +0 -0
  214. /package/dist/types/{design-system → design}/themes/cobalt.d.ts +0 -0
  215. /package/dist/types/{design-system → design}/themes/graphite.d.ts +0 -0
  216. /package/dist/types/{design-system → design}/themes/neutral.d.ts +0 -0
  217. /package/dist/types/{design-system → design}/themes/sage.d.ts +0 -0
  218. /package/dist/types/{design-system → design}/themes/sunset.d.ts +0 -0
  219. /package/dist/types/{design-system → design}/tokens/base.d.ts +0 -0
  220. /package/dist/types/{design-system → design}/tokens/contrast.d.ts +0 -0
  221. /package/dist/types/{design-system → design}/tokens/density.d.ts +0 -0
  222. /package/dist/types/{design-system → design}/tokens/forced-colors.d.ts +0 -0
  223. /package/dist/types/{design-system → design}/tokens/index.d.ts +0 -0
  224. /package/dist/types/{design-system → design}/tokens/motion.d.ts +0 -0
@@ -1,3 +1,1896 @@
1
- import { A as e, C as t, D as n, E as r, F as i, M as a, N as o, O as s, P as c, R as l, S as u, T as d, _ as f, a as p, b as m, c as h, d as g, f as _, g as v, h as y, i as b, j as x, k as S, l as C, m as w, n as T, o as E, p as D, r as O, s as k, t as A, u as j, v as M, w as N, x as P, y as F, z as I } from "../transport-B6ePTLFK.js";
2
- import { a as L, c as R, d as z, i as B, l as V, n as H, o as U, r as W, s as G, t as K, u as q } from "../kit-QY6zff-h.js";
3
- export { l as assertPayloadWithinLimits, I as assertTransportCapabilities, G as collectLayoutReferences, p as createFallbackTransport, k as createFanoutTransport, U as createFormView, c as createGraphqlTransport, n as createGrpcSessionTransport, s as createGrpcStreamTransport, S as createGrpcTransport, e as createGrpcUnaryTransport, T as createHedgedTransport, i as createJsonTransport, h as createLoadBalancedTransport, f as createMemoryCircuitBreakerState, y as createMemorySharedRateLimiter, _ as createMemoryTransportCacheStore, A as createMemoryTransportHealthState, b as createPipelineTransport, E as createQuorumFanoutTransport, O as createRacingTransport, C as createRoutingTransport, a as createSessionTransport, o as createSseTransport, x as createWebSocketSessionTransport, j as createWeightedRoutingTransport, q as defaultKitDesignSystem, z as defaultKitLabels, R as flattenLayoutNodes, L as mountAccordionForm, W as mountForm, H as mountTabsForm, K as mountWizardForm, r as pipe, B as unmountForm, V as walkLayoutNodes, M as withAuth, g as withCache, v as withCircuitBreaker, D as withDedup, P as withLogging, F as withMetrics, w as withRateLimit, u as withRequestTransform, t as withResponseTransform, d as withRetry, N as withTimeout, m as withTracing };
1
+ import { t as e } from "../runtime-CI7vlp9i.js";
2
+ import { i as t, s as n } from "../schema-DSAZ6bts.js";
3
+ import { n as r } from "../builtins-D8rXH4ED.js";
4
+ import { _ as i, a, h as o, l as s, m as c, p as l, r as u, t as d } from "../primitives-k9HTnd72.js";
5
+ import { d as f, h as p, r as m } from "../design-6suKVQDo.js";
6
+ import { LitElement as h, css as g, html as _, nothing as v } from "lit";
7
+ import { customElement as y, property as b, state as x } from "lit/decorators.js";
8
+ import { repeat as S } from "lit/directives/repeat.js";
9
+ //#region src/kit/defaults.ts
10
+ var C = { ...c }, w = {
11
+ mode: "auto",
12
+ theme: "neutral",
13
+ recipe: "default"
14
+ }, ee = (e) => {
15
+ let n = t();
16
+ for (let t of e.listFields()) n.registerField(t);
17
+ for (let t of e.listReports()) n.registerReport(t);
18
+ return n;
19
+ }, te = (e) => e?.clone() ?? u(), ne = (e) => e?.clone() ?? p.clone(), re = (e = {}) => ({
20
+ ...C,
21
+ ...e
22
+ }), ie = (e = {}) => f(w, e), T = (e, t) => {
23
+ if (t(e), "children" in e) for (let n of e.children) T(n, t);
24
+ }, E = (e, t) => {
25
+ switch (e.kind) {
26
+ case "stacked":
27
+ case "split":
28
+ for (let n of e.children) T(n, t);
29
+ return;
30
+ case "wizard":
31
+ for (let n of e.steps) for (let e of n.children) T(e, t);
32
+ return;
33
+ case "tabs":
34
+ for (let n of e.tabs) for (let e of n.children) T(e, t);
35
+ return;
36
+ }
37
+ }, D = (e) => {
38
+ let t = [];
39
+ return E(e, (e) => {
40
+ t.push(e);
41
+ }), t;
42
+ }, O = (e) => {
43
+ let t = {
44
+ fields: [],
45
+ reports: []
46
+ };
47
+ for (let n of D(e)) switch (n.kind) {
48
+ case "field":
49
+ t.fields.push(n.field);
50
+ break;
51
+ case "report":
52
+ t.reports.push(n.report);
53
+ break;
54
+ default: break;
55
+ }
56
+ return t;
57
+ }, k = {
58
+ invalidDesignSystemSnapshot: "replaceDesignSystem requires an explicit mode, theme, and recipe.",
59
+ fieldDuplicateInLayout: (e) => `Field "${e}" appears multiple times in layout.`,
60
+ fieldMissingInLayout: (e) => `Field "${e}" is missing from layout.`,
61
+ reportDuplicateInLayout: (e) => `Report "${e}" appears multiple times in layout.`,
62
+ unknownFieldReference: (e) => `Layout references unknown field "${e}".`,
63
+ unknownReportReference: (e) => `Layout references unknown report "${e}".`,
64
+ wizardRequiresSteps: "Wizard layout must define at least one step.",
65
+ wizardStepEmpty: (e) => `Wizard step "${e}" must contain at least one layout node.`,
66
+ tabsRequiresTabs: "Tabs layout must define at least one tab.",
67
+ tabEmpty: (e) => `Tab "${e}" must contain at least one layout node.`,
68
+ nonWizardNextStep: "nextStep() is only available for wizard layouts.",
69
+ nonWizardGoToStep: "goToStep() is only available for wizard layouts.",
70
+ nonTabsSetActiveTab: "setActiveTab() is only available for tabs layouts.",
71
+ unknownTab: (e) => `Unknown tab "${e}".`,
72
+ unknownWizardStep: (e) => `Unknown wizard step "${e}".`,
73
+ unknownDisclosureSection: (e) => `Unknown disclosure section "${e}".`
74
+ }, A = {
75
+ wizard: "mlf-kit-wizard",
76
+ tabs: "mlf-kit-tabs",
77
+ disclosure: "mlf-kit-disclosure",
78
+ stepIndicator: "mlf-kit-step-indicator"
79
+ }, ae = async (e) => {
80
+ await Promise.resolve(), "updateComplete" in e && await e.updateComplete, await Promise.resolve();
81
+ }, oe = (e) => {
82
+ let t = e.getSnapshot().fields.filter((e) => e.state.visible && e.state.errors.length > 0), n = new Map(e.getLayoutReferences().fields.map((e, t) => [e, t]));
83
+ return t.sort((e, t) => (n.get(e.id) ?? 0) - (n.get(t.id) ?? 0)), t[0] ?? null;
84
+ }, j = async (e, t, n) => {
85
+ let r = oe(t);
86
+ if (!r) return !1;
87
+ let i = t.getSnapshot().layout.kind;
88
+ return i === "wizard" && r.stepId && await t.goToStep(r.stepId), i === "tabs" && r.tabId && t.setActiveTab(r.tabId), r.sectionId && t.openSection(r.sectionId), await ae(e), n(e, r.id);
89
+ }, M = ({ node: e, view: t, snapshot: n, registry: r, primitiveText: i = o, sectionClass: a, sectionCopyClass: s, sectionTitleClass: c, sectionDescriptionClass: l, childrenClass: u, groupBaseClass: d }) => {
90
+ switch (e.kind) {
91
+ case "section": {
92
+ let o = n.disclosure?.openSectionIds.includes(e.id) ?? !0;
93
+ return _`
94
+ <section class=${a} data-section-id=${e.id}>
95
+ ${e.title || e.description ? _`
96
+ <button
97
+ type="button"
98
+ class=${s}
99
+ aria-expanded=${String(o)}
100
+ @click=${() => t?.toggleSection(e.id)}
101
+ >
102
+ <span class="section-label">
103
+ ${e.title ? _`<span class=${c}>${e.title}</span>` : v}
104
+ ${e.description ? _`<span class=${l}>${e.description}</span>` : v}
105
+ </span>
106
+ <span class="section-toggle-icon" aria-hidden="true">${o ? "−" : "+"}</span>
107
+ </button>
108
+ ` : v}
109
+ ${o ? _`
110
+ <div class=${u}>
111
+ ${S(e.children, (t, n) => `${e.id}-${n}`, (e) => M({
112
+ node: e,
113
+ view: t,
114
+ snapshot: n,
115
+ registry: r,
116
+ primitiveText: i,
117
+ sectionClass: a,
118
+ sectionCopyClass: s,
119
+ sectionTitleClass: c,
120
+ sectionDescriptionClass: l,
121
+ childrenClass: u,
122
+ groupBaseClass: d
123
+ }))}
124
+ </div>
125
+ ` : v}
126
+ </section>
127
+ `;
128
+ }
129
+ case "group": return _`
130
+ <div
131
+ class=${`${d}${e.columns ? ` columns-${e.columns}` : ""}`}
132
+ data-group-id=${e.id}
133
+ >
134
+ ${S(e.children, (t, n) => `${e.id}-${n}`, (e) => M({
135
+ node: e,
136
+ view: t,
137
+ snapshot: n,
138
+ registry: r,
139
+ primitiveText: i,
140
+ sectionClass: a,
141
+ sectionCopyClass: s,
142
+ sectionTitleClass: c,
143
+ sectionDescriptionClass: l,
144
+ childrenClass: u,
145
+ groupBaseClass: d
146
+ }))}
147
+ </div>
148
+ `;
149
+ case "field": {
150
+ let t = n.fields.find((t) => t.id === e.field);
151
+ return t ? _`
152
+ <mlf-field-frame
153
+ data-field-id=${t.id}
154
+ .controller=${t.controller}
155
+ .descriptor=${t.descriptor}
156
+ .registry=${r}
157
+ .text=${i}
158
+ ></mlf-field-frame>
159
+ ` : v;
160
+ }
161
+ case "report": {
162
+ let t = n.reports.find((t) => t.id === e.report);
163
+ return t ? _`
164
+ <mlf-report-frame
165
+ .controller=${t.controller}
166
+ .descriptor=${t.descriptor}
167
+ .registry=${r}
168
+ .text=${i}
169
+ .lastResult=${n.form.lastResult}
170
+ ></mlf-report-frame>
171
+ ` : v;
172
+ }
173
+ }
174
+ }, se = g`
175
+ :host {
176
+ display: block;
177
+ inline-size: 100%;
178
+ block-size: 100%;
179
+ color: var(--mlf-shell-color, var(--mlf-color-text, #0f172a));
180
+ background: var(--mlf-shell-bg, var(--mlf-color-bg, #f5f7fa));
181
+ font-family: var(--mlf-font-family-body);
182
+ }
183
+ *,
184
+ *::before,
185
+ *::after {
186
+ box-sizing: border-box;
187
+ }
188
+ .root {
189
+ display: grid;
190
+ grid-template-rows: auto 1fr auto;
191
+ min-height: 100%;
192
+ border-radius: var(--mlf-panel-radius, 12px);
193
+ border: var(--mlf-border-width, 1px) solid
194
+ var(--mlf-shell-panel-border, var(--mlf-color-border, #e2e8f0));
195
+ background: var(--mlf-shell-panel-bg, var(--mlf-color-surface, #ffffff));
196
+ box-shadow:
197
+ 0 2px 4px var(--mlf-shell-panel-shadow-soft, rgba(0, 0, 0, 0.04)),
198
+ 0 8px 16px var(--mlf-shell-panel-shadow, rgba(0, 0, 0, 0.04));
199
+ overflow: hidden;
200
+ }
201
+ .header,
202
+ .footer {
203
+ display: flex;
204
+ align-items: center;
205
+ justify-content: space-between;
206
+ gap: 0.75rem;
207
+ padding: 0.85rem 1rem;
208
+ background: var(
209
+ --mlf-shell-header-bg,
210
+ color-mix(in srgb, var(--mlf-color-surface, #ffffff) 76%, transparent)
211
+ );
212
+ border-bottom: var(--mlf-border-width, 1px) solid
213
+ var(--mlf-shell-panel-border, var(--mlf-color-border, #e2e8f0));
214
+ }
215
+ .footer {
216
+ border-bottom: none;
217
+ border-top: var(--mlf-border-width, 1px) solid
218
+ var(--mlf-shell-panel-border, var(--mlf-color-border, #e2e8f0));
219
+ background: var(--mlf-shell-action-bg, var(--mlf-color-surface-muted, #f5f7fa));
220
+ }
221
+ .title {
222
+ margin: 0;
223
+ font-size: 1rem;
224
+ font-weight: 700;
225
+ }
226
+ .actions {
227
+ display: inline-flex;
228
+ gap: 0.5rem;
229
+ flex-wrap: wrap;
230
+ }
231
+ .body {
232
+ display: grid;
233
+ gap: 0;
234
+ overflow-y: auto;
235
+ overflow-x: hidden;
236
+ }
237
+ .section + .section {
238
+ margin-block-start: var(--mlf-section-gap, 1rem);
239
+ }
240
+ .section-toggle {
241
+ inline-size: 100%;
242
+ display: flex;
243
+ align-items: center;
244
+ justify-content: space-between;
245
+ gap: 0.75rem;
246
+ min-height: 2rem;
247
+ padding: 0;
248
+ border: none;
249
+ background: transparent;
250
+ color: var(--mlf-section-title-color, var(--mlf-color-text, currentColor));
251
+ font: inherit;
252
+ text-align: left;
253
+ cursor: pointer;
254
+ }
255
+ .section-copy,
256
+ .nested-copy {
257
+ display: grid;
258
+ gap: 0.35rem;
259
+ }
260
+ .section-label {
261
+ display: grid;
262
+ gap: 0.25rem;
263
+ min-inline-size: 0;
264
+ }
265
+ .section-title {
266
+ margin: 0;
267
+ font-size: 0.96rem;
268
+ font-weight: 700;
269
+ line-height: 1.35;
270
+ color: var(--mlf-section-title-color, var(--mlf-color-text, currentColor));
271
+ }
272
+ .section-description,
273
+ .nested-description {
274
+ margin: 0;
275
+ font-size: var(--mlf-font-size-sm, 0.84rem);
276
+ color: var(--mlf-color-text-muted, #475569);
277
+ line-height: 1.5;
278
+ }
279
+ .section-toggle-icon {
280
+ flex: 0 0 auto;
281
+ display: inline-grid;
282
+ place-items: center;
283
+ inline-size: 1.5rem;
284
+ block-size: 1.5rem;
285
+ border-radius: var(--mlf-control-radius, var(--mlf-input-radius, 8px));
286
+ color: var(--mlf-section-toggle-color, var(--mlf-color-text-muted, currentColor));
287
+ font-size: 1rem;
288
+ font-weight: 700;
289
+ line-height: 1;
290
+ }
291
+ .section-toggle:focus-visible .section-toggle-icon {
292
+ outline: var(--mlf-focus-ring-width, 2px) solid
293
+ var(--mlf-focus-ring-color, var(--mlf-color-accent, #1e40af));
294
+ outline-offset: 2px;
295
+ }
296
+ .section-panel {
297
+ display: grid;
298
+ gap: 1rem;
299
+ padding-block-start: 0.75rem;
300
+ }
301
+ .collection,
302
+ .section-children,
303
+ .nested-section,
304
+ .group {
305
+ display: grid;
306
+ gap: var(--mlf-section-gap, 1rem);
307
+ }
308
+ .nested-copy {
309
+ padding: 0 0.5rem;
310
+ }
311
+ .nested-title {
312
+ margin: 0;
313
+ font-size: 0.95rem;
314
+ font-weight: 700;
315
+ }
316
+ .group.columns-2 {
317
+ grid-template-columns: repeat(2, minmax(0, 1fr));
318
+ }
319
+ .group.columns-3 {
320
+ grid-template-columns: repeat(3, minmax(0, 1fr));
321
+ }
322
+ .btn {
323
+ display: inline-flex;
324
+ align-items: center;
325
+ justify-content: center;
326
+ min-height: 2.5rem;
327
+ padding: 0.5rem 1rem;
328
+ border-radius: var(--mlf-input-radius, 12px);
329
+ border: var(--mlf-border-width, 1px) solid var(--mlf-input-border, #e2e8f0);
330
+ background: var(--mlf-input-bg, var(--mlf-color-surface-elevated, #ffffff));
331
+ color: var(--mlf-color-text, #0f172a);
332
+ font: inherit;
333
+ font-size: 0.92rem;
334
+ font-weight: 600;
335
+ cursor: pointer;
336
+ }
337
+ .btn-submit {
338
+ border-color: var(--mlf-submit-bg, var(--mlf-color-accent, #1e40af));
339
+ background: var(--mlf-submit-bg, var(--mlf-color-accent, #1e40af));
340
+ color: var(--mlf-submit-color, #ffffff);
341
+ }
342
+ .btn:disabled {
343
+ cursor: not-allowed;
344
+ opacity: 0.55;
345
+ }
346
+ @media (max-width: 900px) {
347
+ .group.columns-2,
348
+ .group.columns-3 {
349
+ grid-template-columns: minmax(0, 1fr);
350
+ }
351
+ .header,
352
+ .footer {
353
+ flex-direction: column;
354
+ align-items: stretch;
355
+ }
356
+ }
357
+ `, N = class extends h {
358
+ static styles = se;
359
+ #e;
360
+ get view() {
361
+ return this.#e;
362
+ }
363
+ set view(e) {
364
+ this.#e = e;
365
+ }
366
+ #t;
367
+ get registry() {
368
+ return this.#t;
369
+ }
370
+ set registry(e) {
371
+ this.#t = e;
372
+ }
373
+ #n = o;
374
+ get primitiveText() {
375
+ return this.#n;
376
+ }
377
+ set primitiveText(e) {
378
+ this.#n = e;
379
+ }
380
+ #r = "Submit";
381
+ get submitLabel() {
382
+ return this.#r;
383
+ }
384
+ set submitLabel(e) {
385
+ this.#r = e;
386
+ }
387
+ #i = "Validating...";
388
+ get validatingLabel() {
389
+ return this.#i;
390
+ }
391
+ set validatingLabel(e) {
392
+ this.#i = e;
393
+ }
394
+ #a = "Submitting...";
395
+ get submittingLabel() {
396
+ return this.#a;
397
+ }
398
+ set submittingLabel(e) {
399
+ this.#a = e;
400
+ }
401
+ #o = null;
402
+ get snapshot() {
403
+ return this.#o;
404
+ }
405
+ set snapshot(e) {
406
+ this.#o = e;
407
+ }
408
+ #s = null;
409
+ willUpdate(e) {
410
+ e.has("view") && (this.#s?.(), this.#s = null, this.snapshot = this.view?.getSnapshot() ?? null, this.view && (this.#s = this.view.subscribe((e) => {
411
+ this.snapshot = e;
412
+ })));
413
+ }
414
+ disconnectedCallback() {
415
+ this.#s?.(), this.#s = null, super.disconnectedCallback();
416
+ }
417
+ render() {
418
+ let e = this.snapshot;
419
+ if (!e || e.layout.kind !== "stacked" && e.layout.kind !== "split") return _``;
420
+ let t = e.form.status, n = t === "validating" ? this.validatingLabel : t === "submitting" ? this.submittingLabel : this.submitLabel;
421
+ return _`
422
+ <section class="root" part="layout-panel">
423
+ <div class="body">
424
+ <div class="collection">
425
+ ${S(e.layout.children, (e, t) => `root-${t}`, (t) => M({
426
+ node: t,
427
+ view: this.view,
428
+ snapshot: e,
429
+ registry: this.registry,
430
+ primitiveText: this.primitiveText,
431
+ sectionClass: "section",
432
+ sectionCopyClass: "section-toggle",
433
+ sectionTitleClass: "section-title",
434
+ sectionDescriptionClass: "section-description",
435
+ childrenClass: "section-panel",
436
+ groupBaseClass: "group"
437
+ }))}
438
+ </div>
439
+ </div>
440
+
441
+ <footer class="footer" part="actions">
442
+ <span>${e.disclosure?.openSectionIds.length ?? 0} sections open</span>
443
+ <button
444
+ type="button"
445
+ class="btn btn-submit"
446
+ ?disabled=${t === "validating" || t === "submitting"}
447
+ @click=${this.#c}
448
+ >
449
+ ${n}
450
+ </button>
451
+ </footer>
452
+ </section>
453
+ `;
454
+ }
455
+ #c = async () => {
456
+ if (this.view) try {
457
+ await this.view.submit();
458
+ } catch (e) {
459
+ if (!await j(this, this.view, s)) throw e;
460
+ }
461
+ };
462
+ };
463
+ l([b({ attribute: !1 })], N.prototype, "view", null), l([b({ attribute: !1 })], N.prototype, "registry", null), l([b({ attribute: !1 })], N.prototype, "primitiveText", null), l([b({ type: String })], N.prototype, "submitLabel", null), l([b({ type: String })], N.prototype, "validatingLabel", null), l([b({ type: String })], N.prototype, "submittingLabel", null), l([x()], N.prototype, "snapshot", null), N = l([y(A.disclosure)], N);
464
+ //#endregion
465
+ //#region src/kit/tabs-root-styles.ts
466
+ var ce = g`
467
+ :host {
468
+ display: block;
469
+ flex: 1 1 auto;
470
+ align-self: stretch;
471
+ inline-size: 100%;
472
+ block-size: 100%;
473
+ color: var(--mlf-shell-color, var(--mlf-color-text, #0f172a));
474
+ background: var(--mlf-shell-bg, var(--mlf-color-bg, #f5f7fa));
475
+ font-family: var(--mlf-font-family-body);
476
+ min-width: 0;
477
+ min-height: 0;
478
+ }
479
+ *,
480
+ *::before,
481
+ *::after {
482
+ box-sizing: border-box;
483
+ }
484
+ .root {
485
+ display: grid;
486
+ grid-template-rows: auto 1fr auto;
487
+ inline-size: 100%;
488
+ block-size: 100%;
489
+ min-width: 0;
490
+ min-height: 0;
491
+ overflow: hidden;
492
+ border-radius: var(--mlf-panel-radius, 12px);
493
+ border: var(--mlf-border-width, 1px) solid
494
+ var(--mlf-shell-panel-border, var(--mlf-color-border, #e2e8f0));
495
+ background: var(--mlf-shell-panel-bg, var(--mlf-color-surface, #ffffff));
496
+ box-shadow:
497
+ 0 2px 4px var(--mlf-shell-panel-shadow-soft, rgba(0, 0, 0, 0.04)),
498
+ 0 8px 16px var(--mlf-shell-panel-shadow, rgba(0, 0, 0, 0.04));
499
+ }
500
+ .tablist {
501
+ display: flex;
502
+ gap: 0.35rem;
503
+ overflow-x: auto;
504
+ padding: 0.85rem 1rem 0;
505
+ border-bottom: var(--mlf-border-width, 1px) solid
506
+ var(--mlf-shell-panel-border, var(--mlf-color-border, #e2e8f0));
507
+ background: var(
508
+ --mlf-shell-header-bg,
509
+ color-mix(in srgb, var(--mlf-color-surface, #ffffff) 76%, transparent)
510
+ );
511
+ scrollbar-width: thin;
512
+ }
513
+ .tab {
514
+ position: relative;
515
+ border: none;
516
+ border-radius: 12px 12px 0 0;
517
+ background: transparent;
518
+ color: var(--mlf-color-text-muted, #475569);
519
+ font: inherit;
520
+ font-size: 0.94rem;
521
+ font-weight: 600;
522
+ padding: 0.85rem 1rem 0.75rem;
523
+ cursor: pointer;
524
+ white-space: nowrap;
525
+ }
526
+ .tab[aria-selected="true"] {
527
+ color: var(--mlf-color-text, #0f172a);
528
+ background: color-mix(in srgb, var(--mlf-color-surface, #ffffff) 94%, transparent);
529
+ }
530
+ .tab[aria-selected="true"]::after {
531
+ content: "";
532
+ position: absolute;
533
+ inset-inline: 0.8rem;
534
+ inset-block-end: 0;
535
+ block-size: 3px;
536
+ border-radius: 999px;
537
+ background: var(--mlf-color-accent, #1e40af);
538
+ }
539
+ .tab-panel {
540
+ display: grid;
541
+ grid-template-rows: auto 1fr;
542
+ min-width: 0;
543
+ min-height: 0;
544
+ overflow: hidden;
545
+ }
546
+ .tab-header {
547
+ display: grid;
548
+ gap: 0.35rem;
549
+ padding: 1rem 1.25rem 0.5rem;
550
+ }
551
+ .tab-title {
552
+ margin: 0;
553
+ font-size: 1.08rem;
554
+ font-weight: 700;
555
+ color: var(--mlf-color-text, #0f172a);
556
+ line-height: 1.3;
557
+ }
558
+ .tab-description {
559
+ margin: 0;
560
+ font-size: var(--mlf-font-size-sm, 0.84rem);
561
+ color: var(--mlf-color-text-muted, #475569);
562
+ line-height: 1.5;
563
+ }
564
+ .body {
565
+ display: grid;
566
+ align-content: start;
567
+ gap: 1rem;
568
+ padding: 0.5rem 1rem 1.25rem;
569
+ overflow-y: auto;
570
+ overflow-x: hidden;
571
+ }
572
+ .collection,
573
+ .section-children,
574
+ .group {
575
+ display: grid;
576
+ gap: var(--mlf-section-gap, 1rem);
577
+ }
578
+ .section {
579
+ display: grid;
580
+ gap: 0.75rem;
581
+ }
582
+ .section-copy {
583
+ inline-size: 100%;
584
+ display: flex;
585
+ align-items: center;
586
+ justify-content: space-between;
587
+ gap: 0.75rem;
588
+ min-height: 2rem;
589
+ padding: 0;
590
+ border: none;
591
+ background: transparent;
592
+ color: var(--mlf-section-title-color, var(--mlf-color-text, currentColor));
593
+ font: inherit;
594
+ text-align: left;
595
+ cursor: pointer;
596
+ }
597
+ .section-label {
598
+ display: grid;
599
+ gap: 0.25rem;
600
+ min-inline-size: 0;
601
+ }
602
+ .section-title {
603
+ margin: 0;
604
+ font-size: 0.95rem;
605
+ font-weight: 700;
606
+ line-height: 1.35;
607
+ color: var(--mlf-section-title-color, var(--mlf-color-text, currentColor));
608
+ }
609
+ .section-description {
610
+ margin: 0;
611
+ font-size: var(--mlf-font-size-sm, 0.84rem);
612
+ color: var(--mlf-color-text-muted, #475569);
613
+ line-height: 1.5;
614
+ }
615
+ .section-toggle-icon {
616
+ flex: 0 0 auto;
617
+ display: inline-grid;
618
+ place-items: center;
619
+ inline-size: 1.5rem;
620
+ block-size: 1.5rem;
621
+ border-radius: var(--mlf-control-radius, var(--mlf-input-radius, 8px));
622
+ color: var(--mlf-section-toggle-color, var(--mlf-color-text-muted, currentColor));
623
+ font-size: 1rem;
624
+ font-weight: 700;
625
+ line-height: 1;
626
+ }
627
+ .section-copy:focus-visible .section-toggle-icon {
628
+ outline: var(--mlf-focus-ring-width, 2px) solid
629
+ var(--mlf-focus-ring-color, var(--mlf-color-accent, #1e40af));
630
+ outline-offset: 2px;
631
+ }
632
+ .group.columns-2 {
633
+ grid-template-columns: repeat(2, minmax(0, 1fr));
634
+ }
635
+ .group.columns-3 {
636
+ grid-template-columns: repeat(3, minmax(0, 1fr));
637
+ }
638
+ .footer {
639
+ display: flex;
640
+ align-items: center;
641
+ justify-content: space-between;
642
+ gap: 0.75rem;
643
+ padding: 0.85rem 1rem 1rem;
644
+ border-top: var(--mlf-border-width, 1px) solid
645
+ var(--mlf-shell-panel-border, var(--mlf-color-border, #e2e8f0));
646
+ background: var(--mlf-shell-action-bg, var(--mlf-color-surface-muted, #f5f7fa));
647
+ }
648
+ .nav {
649
+ display: inline-flex;
650
+ gap: 0.5rem;
651
+ }
652
+ .btn {
653
+ display: inline-flex;
654
+ align-items: center;
655
+ justify-content: center;
656
+ min-height: 2.5rem;
657
+ padding: 0.5rem 1rem;
658
+ border-radius: var(--mlf-input-radius, 12px);
659
+ border: var(--mlf-border-width, 1px) solid var(--mlf-input-border, #e2e8f0);
660
+ background: var(--mlf-input-bg, var(--mlf-color-surface-elevated, #ffffff));
661
+ color: var(--mlf-color-text, #0f172a);
662
+ font: inherit;
663
+ font-size: 0.92rem;
664
+ font-weight: 600;
665
+ cursor: pointer;
666
+ }
667
+ .btn:disabled {
668
+ cursor: not-allowed;
669
+ opacity: 0.55;
670
+ }
671
+ .btn-submit {
672
+ border-color: var(--mlf-submit-bg, var(--mlf-color-accent, #1e40af));
673
+ background: var(--mlf-submit-bg, var(--mlf-color-accent, #1e40af));
674
+ color: var(--mlf-submit-color, #ffffff);
675
+ }
676
+ @media (max-width: 900px) {
677
+ .group.columns-2,
678
+ .group.columns-3 {
679
+ grid-template-columns: minmax(0, 1fr);
680
+ }
681
+ .footer {
682
+ flex-direction: column;
683
+ align-items: stretch;
684
+ }
685
+ .nav {
686
+ justify-content: space-between;
687
+ }
688
+ }
689
+ `, P = class extends h {
690
+ static styles = ce;
691
+ #e;
692
+ get view() {
693
+ return this.#e;
694
+ }
695
+ set view(e) {
696
+ this.#e = e;
697
+ }
698
+ #t;
699
+ get registry() {
700
+ return this.#t;
701
+ }
702
+ set registry(e) {
703
+ this.#t = e;
704
+ }
705
+ #n = o;
706
+ get primitiveText() {
707
+ return this.#n;
708
+ }
709
+ set primitiveText(e) {
710
+ this.#n = e;
711
+ }
712
+ #r = "Submit";
713
+ get submitLabel() {
714
+ return this.#r;
715
+ }
716
+ set submitLabel(e) {
717
+ this.#r = e;
718
+ }
719
+ #i = "Validating...";
720
+ get validatingLabel() {
721
+ return this.#i;
722
+ }
723
+ set validatingLabel(e) {
724
+ this.#i = e;
725
+ }
726
+ #a = "Submitting...";
727
+ get submittingLabel() {
728
+ return this.#a;
729
+ }
730
+ set submittingLabel(e) {
731
+ this.#a = e;
732
+ }
733
+ #o = null;
734
+ get snapshot() {
735
+ return this.#o;
736
+ }
737
+ set snapshot(e) {
738
+ this.#o = e;
739
+ }
740
+ #s = null;
741
+ willUpdate(e) {
742
+ e.has("view") && (this.#s?.(), this.#s = null, this.snapshot = this.view?.getSnapshot() ?? null, this.view && (this.#s = this.view.subscribe((e) => {
743
+ this.snapshot = e;
744
+ })));
745
+ }
746
+ disconnectedCallback() {
747
+ this.#s?.(), this.#s = null, super.disconnectedCallback();
748
+ }
749
+ render() {
750
+ let e = this.snapshot, t = e?.tabs;
751
+ if (!e || !t || e.layout.kind !== "tabs") return _``;
752
+ let n = e.layout.tabs[t.activeTabIndex];
753
+ if (!n) return _``;
754
+ let r = e.form.status, i = r === "validating" ? this.validatingLabel : r === "submitting" ? this.submittingLabel : this.submitLabel;
755
+ return _`
756
+ <section class="root" part="tabs-panel">
757
+ <div class="tablist" role="tablist" aria-label="Form sections">
758
+ ${S(e.layout.tabs, (e) => e.id, (e, n) => _`
759
+ <button
760
+ type="button"
761
+ class="tab"
762
+ role="tab"
763
+ aria-selected=${String(n === t.activeTabIndex)}
764
+ aria-controls=${`panel-${e.id}`}
765
+ id=${`tab-${e.id}`}
766
+ @click=${() => this.view?.setActiveTab(e.id)}
767
+ >
768
+ ${e.title}
769
+ </button>
770
+ `)}
771
+ </div>
772
+
773
+ <div
774
+ class="tab-panel"
775
+ role="tabpanel"
776
+ id=${`panel-${n.id}`}
777
+ aria-labelledby=${`tab-${n.id}`}
778
+ >
779
+ ${n.title || n.description ? _`
780
+ <header class="tab-header">
781
+ <h1 class="tab-title">${n.title}</h1>
782
+ ${n.description ? _`<p class="tab-description">${n.description}</p>` : v}
783
+ </header>
784
+ ` : v}
785
+
786
+ <div class="body">
787
+ <div class="collection">
788
+ ${S(n.children, (e, t) => `${n.id}-${t}`, (t) => M({
789
+ node: t,
790
+ view: this.view,
791
+ snapshot: e,
792
+ registry: this.registry,
793
+ primitiveText: this.primitiveText,
794
+ sectionClass: "section",
795
+ sectionCopyClass: "section-copy",
796
+ sectionTitleClass: "section-title",
797
+ sectionDescriptionClass: "section-description",
798
+ childrenClass: "section-children",
799
+ groupBaseClass: "group"
800
+ }))}
801
+ </div>
802
+ </div>
803
+ </div>
804
+
805
+ <footer class="footer" part="actions">
806
+ <div class="nav">
807
+ <button
808
+ type="button"
809
+ class="btn"
810
+ ?disabled=${!t.canGoPrev}
811
+ @click=${() => this.view?.prevTab()}
812
+ >
813
+ Previous
814
+ </button>
815
+ <button
816
+ type="button"
817
+ class="btn"
818
+ ?disabled=${!t.canGoNext}
819
+ @click=${() => this.view?.nextTab()}
820
+ >
821
+ Next
822
+ </button>
823
+ </div>
824
+ <button
825
+ type="button"
826
+ class="btn btn-submit"
827
+ ?disabled=${r === "validating" || r === "submitting"}
828
+ @click=${this.#c}
829
+ >
830
+ ${i}
831
+ </button>
832
+ </footer>
833
+ </section>
834
+ `;
835
+ }
836
+ #c = async () => {
837
+ if (this.view) try {
838
+ await this.view.submit();
839
+ } catch (e) {
840
+ if (!await j(this, this.view, s)) throw e;
841
+ }
842
+ };
843
+ };
844
+ l([b({ attribute: !1 })], P.prototype, "view", null), l([b({ attribute: !1 })], P.prototype, "registry", null), l([b({ attribute: !1 })], P.prototype, "primitiveText", null), l([b({ type: String })], P.prototype, "submitLabel", null), l([b({ type: String })], P.prototype, "validatingLabel", null), l([b({ type: String })], P.prototype, "submittingLabel", null), l([x()], P.prototype, "snapshot", null), P = l([y(A.tabs)], P);
845
+ //#endregion
846
+ //#region src/kit/step-indicator.ts
847
+ var F = class extends h {
848
+ static styles = g`
849
+ :host {
850
+ display: block;
851
+ min-width: 0;
852
+ }
853
+
854
+ *,
855
+ *::before,
856
+ *::after {
857
+ box-sizing: border-box;
858
+ }
859
+
860
+ .indicator {
861
+ display: grid;
862
+ gap: 0.5rem;
863
+ }
864
+
865
+ .header {
866
+ display: flex;
867
+ align-items: center;
868
+ justify-content: space-between;
869
+ gap: 1rem;
870
+ }
871
+
872
+ .step-label {
873
+ font-size: var(--mlf-font-size-sm, 0.84rem);
874
+ font-weight: 600;
875
+ letter-spacing: 0.05em;
876
+ text-transform: uppercase;
877
+ color: var(--mlf-color-text-muted, #475569);
878
+ }
879
+
880
+ .step-fraction {
881
+ font-size: var(--mlf-font-size-sm, 0.84rem);
882
+ font-weight: 700;
883
+ color: var(--mlf-color-accent, #1e40af);
884
+ }
885
+
886
+ .track {
887
+ height: 4px;
888
+ border-radius: 999px;
889
+ background: var(--mlf-color-border, #e2e8f0);
890
+ overflow: hidden;
891
+ }
892
+
893
+ .fill {
894
+ height: 100%;
895
+ border-radius: 999px;
896
+ background: var(--mlf-color-accent, #1e40af);
897
+ transition: width 0.3s ease;
898
+ }
899
+
900
+ .dots {
901
+ display: flex;
902
+ gap: 0.4rem;
903
+ flex-wrap: wrap;
904
+ }
905
+
906
+ .dot {
907
+ width: 8px;
908
+ height: 8px;
909
+ border-radius: 50%;
910
+ background: var(--mlf-color-border, #e2e8f0);
911
+ transition:
912
+ background-color 0.2s ease,
913
+ transform 0.2s ease;
914
+ }
915
+
916
+ .dot.active {
917
+ background: var(--mlf-color-accent, #1e40af);
918
+ transform: scale(1.25);
919
+ }
920
+
921
+ .dot.done {
922
+ background: color-mix(in srgb, var(--mlf-color-accent, #1e40af) 50%, transparent);
923
+ }
924
+ `;
925
+ #e = 1;
926
+ get current() {
927
+ return this.#e;
928
+ }
929
+ set current(e) {
930
+ this.#e = e;
931
+ }
932
+ #t = 1;
933
+ get total() {
934
+ return this.#t;
935
+ }
936
+ set total(e) {
937
+ this.#t = e;
938
+ }
939
+ #n = "Step";
940
+ get label() {
941
+ return this.#n;
942
+ }
943
+ set label(e) {
944
+ this.#n = e;
945
+ }
946
+ render() {
947
+ let e = this.total > 0 ? Math.round(this.current / this.total * 100) : 0;
948
+ return _`
949
+ <div
950
+ class="indicator"
951
+ role="status"
952
+ aria-label=${`${this.label} ${this.current} of ${this.total}`}
953
+ >
954
+ <div class="header">
955
+ <span class="step-label">${this.label}</span>
956
+ <span class="step-fraction">${this.current} / ${this.total}</span>
957
+ </div>
958
+ <div class="track" aria-hidden="true">
959
+ <div class="fill" style="width: ${e}%"></div>
960
+ </div>
961
+ <div class="dots" aria-hidden="true">
962
+ ${Array.from({ length: this.total }, (e, t) => _`<div class=${t + 1 < this.current ? "dot done" : t + 1 === this.current ? "dot active" : "dot"}></div>`)}
963
+ </div>
964
+ </div>
965
+ `;
966
+ }
967
+ };
968
+ l([b({ type: Number })], F.prototype, "current", null), l([b({ type: Number })], F.prototype, "total", null), l([b({ type: String })], F.prototype, "label", null), F = l([y(A.stepIndicator)], F);
969
+ //#endregion
970
+ //#region src/kit/wizard-constants.ts
971
+ var I = {
972
+ prev: "Previous",
973
+ next: "Next",
974
+ submit: "Submit",
975
+ validating: "Validating...",
976
+ submitting: "Submitting..."
977
+ }, L = Object.freeze({
978
+ stepLabel: (e, t) => `Step ${e} of ${t}`,
979
+ prevLabel: "Previous",
980
+ nextLabel: "Next",
981
+ submitLabel: "Submit",
982
+ validatingLabel: "Validating...",
983
+ submittingLabel: "Submitting..."
984
+ }), R = (e) => e ? Object.freeze({
985
+ ...L,
986
+ ...e
987
+ }) : L, le = g`
988
+ :host {
989
+ display: block;
990
+ flex: 1 1 auto;
991
+ align-self: stretch;
992
+ inline-size: 100%;
993
+ block-size: 100%;
994
+ color: var(--mlf-shell-color, var(--mlf-color-text, #0f172a));
995
+ background: var(--mlf-shell-bg, var(--mlf-color-bg, #f5f7fa));
996
+ font-family: var(--mlf-font-family-body);
997
+ min-width: 0;
998
+ min-height: 0;
999
+ }
1000
+ *,
1001
+ *::before,
1002
+ *::after {
1003
+ box-sizing: border-box;
1004
+ }
1005
+ .root {
1006
+ display: grid;
1007
+ grid-template-rows: 1fr;
1008
+ gap: var(--mlf-shell-gap, 1rem);
1009
+ inline-size: 100%;
1010
+ block-size: 100%;
1011
+ min-width: 0;
1012
+ min-height: 0;
1013
+ }
1014
+ .panel {
1015
+ display: flex;
1016
+ flex-direction: column;
1017
+ min-width: 0;
1018
+ min-height: 0;
1019
+ overflow: hidden;
1020
+ border-radius: var(--mlf-panel-radius, 12px);
1021
+ border: var(--mlf-border-width, 1px) solid
1022
+ var(--mlf-shell-panel-border, var(--mlf-color-border, #e2e8f0));
1023
+ background: var(--mlf-shell-panel-bg, var(--mlf-color-surface, #ffffff));
1024
+ box-shadow:
1025
+ 0 2px 4px var(--mlf-shell-panel-shadow-soft, rgba(0, 0, 0, 0.04)),
1026
+ 0 8px 16px var(--mlf-shell-panel-shadow, rgba(0, 0, 0, 0.04));
1027
+ }
1028
+ .pane-header {
1029
+ flex: 0 0 auto;
1030
+ display: grid;
1031
+ gap: 0.85rem;
1032
+ padding: 1rem 1.5rem;
1033
+ border-bottom: var(--mlf-border-width, 1px) solid
1034
+ var(--mlf-shell-panel-border, var(--mlf-color-border, #e2e8f0));
1035
+ background: var(
1036
+ --mlf-shell-header-bg,
1037
+ color-mix(in srgb, var(--mlf-color-surface, #ffffff) 76%, transparent)
1038
+ );
1039
+ backdrop-filter: blur(var(--mlf-shell-header-blur, 3px));
1040
+ -webkit-backdrop-filter: blur(var(--mlf-shell-header-blur, 3px));
1041
+ }
1042
+ .step-title {
1043
+ margin: 0;
1044
+ font-size: 1.1rem;
1045
+ font-weight: 700;
1046
+ color: var(--mlf-pane-title-color, var(--mlf-color-text, #0f172a));
1047
+ line-height: 1.3;
1048
+ }
1049
+ .step-description {
1050
+ margin: 0;
1051
+ font-size: var(--mlf-font-size-sm, 0.84rem);
1052
+ color: var(--mlf-color-text-muted, #475569);
1053
+ line-height: 1.5;
1054
+ }
1055
+ .pane-body {
1056
+ flex: 1 1 auto;
1057
+ display: grid;
1058
+ align-content: start;
1059
+ gap: 1rem;
1060
+ padding: 1rem 1rem 1.25rem;
1061
+ overflow-y: auto;
1062
+ overflow-x: hidden;
1063
+ }
1064
+ .collection,
1065
+ .section-children,
1066
+ .section,
1067
+ .group {
1068
+ display: grid;
1069
+ gap: var(--mlf-section-gap, 1rem);
1070
+ }
1071
+ .section-copy {
1072
+ inline-size: 100%;
1073
+ display: flex;
1074
+ align-items: center;
1075
+ justify-content: space-between;
1076
+ gap: 0.75rem;
1077
+ min-height: 2rem;
1078
+ padding: 0;
1079
+ border: none;
1080
+ background: transparent;
1081
+ color: var(--mlf-section-title-color, var(--mlf-color-text, currentColor));
1082
+ font: inherit;
1083
+ text-align: left;
1084
+ cursor: pointer;
1085
+ }
1086
+ .section-label {
1087
+ display: grid;
1088
+ gap: 0.25rem;
1089
+ min-inline-size: 0;
1090
+ }
1091
+ .section-title {
1092
+ margin: 0;
1093
+ font-size: 0.95rem;
1094
+ font-weight: 700;
1095
+ line-height: 1.35;
1096
+ color: var(--mlf-section-title-color, var(--mlf-color-text, currentColor));
1097
+ }
1098
+ .section-description {
1099
+ margin: 0;
1100
+ font-size: var(--mlf-font-size-sm, 0.84rem);
1101
+ color: var(--mlf-color-text-muted, #475569);
1102
+ line-height: 1.5;
1103
+ }
1104
+ .section-toggle-icon {
1105
+ flex: 0 0 auto;
1106
+ display: inline-grid;
1107
+ place-items: center;
1108
+ inline-size: 1.5rem;
1109
+ block-size: 1.5rem;
1110
+ border-radius: var(--mlf-control-radius, var(--mlf-input-radius, 8px));
1111
+ color: var(--mlf-section-toggle-color, var(--mlf-color-text-muted, currentColor));
1112
+ font-size: 1rem;
1113
+ font-weight: 700;
1114
+ line-height: 1;
1115
+ }
1116
+ .section-copy:focus-visible .section-toggle-icon {
1117
+ outline: var(--mlf-focus-ring-width, 2px) solid
1118
+ var(--mlf-focus-ring-color, var(--mlf-color-accent, #1e40af));
1119
+ outline-offset: 2px;
1120
+ }
1121
+ .group.columns-2 {
1122
+ grid-template-columns: repeat(2, minmax(0, 1fr));
1123
+ }
1124
+ .group.columns-3 {
1125
+ grid-template-columns: repeat(3, minmax(0, 1fr));
1126
+ }
1127
+ .actions {
1128
+ flex: 0 0 auto;
1129
+ display: flex;
1130
+ align-items: center;
1131
+ justify-content: space-between;
1132
+ gap: 1rem;
1133
+ padding: 0.75rem 1.5rem;
1134
+ border-top: var(--mlf-border-width, 1px) solid
1135
+ var(--mlf-shell-panel-border, var(--mlf-color-border, #e2e8f0));
1136
+ background: var(--mlf-shell-action-bg, var(--mlf-color-surface-muted, #f5f7fa));
1137
+ }
1138
+ .btn {
1139
+ display: inline-flex;
1140
+ align-items: center;
1141
+ justify-content: center;
1142
+ gap: 0.5rem;
1143
+ min-height: 2.5rem;
1144
+ padding: 0.5rem 1.25rem;
1145
+ border: var(--mlf-border-width, 1px) solid transparent;
1146
+ border-radius: var(--mlf-input-radius, 12px);
1147
+ font: inherit;
1148
+ font-size: 0.95rem;
1149
+ font-weight: 600;
1150
+ cursor: pointer;
1151
+ transition:
1152
+ background-color 0.2s ease,
1153
+ border-color 0.2s ease,
1154
+ opacity 0.2s ease;
1155
+ }
1156
+ .btn:disabled {
1157
+ cursor: not-allowed;
1158
+ opacity: 0.55;
1159
+ }
1160
+ .btn-prev {
1161
+ background: transparent;
1162
+ border-color: var(--mlf-input-border, var(--mlf-color-border, #e2e8f0));
1163
+ color: var(--mlf-color-text-muted, #475569);
1164
+ }
1165
+ .btn-next,
1166
+ .btn-submit {
1167
+ background: var(--mlf-submit-bg, var(--mlf-color-accent, #1e40af));
1168
+ border-color: var(--mlf-submit-bg, var(--mlf-color-accent, #1e40af));
1169
+ color: var(--mlf-submit-color, #ffffff);
1170
+ }
1171
+ .spacer {
1172
+ flex: 1 1 auto;
1173
+ }
1174
+ @media (max-width: 900px) {
1175
+ .group.columns-2,
1176
+ .group.columns-3 {
1177
+ grid-template-columns: minmax(0, 1fr);
1178
+ }
1179
+ }
1180
+ `, z = class extends h {
1181
+ static styles = le;
1182
+ #e;
1183
+ get view() {
1184
+ return this.#e;
1185
+ }
1186
+ set view(e) {
1187
+ this.#e = e;
1188
+ }
1189
+ #t;
1190
+ get registry() {
1191
+ return this.#t;
1192
+ }
1193
+ set registry(e) {
1194
+ this.#t = e;
1195
+ }
1196
+ #n = o;
1197
+ get primitiveText() {
1198
+ return this.#n;
1199
+ }
1200
+ set primitiveText(e) {
1201
+ this.#n = e;
1202
+ }
1203
+ #r = I;
1204
+ get labels() {
1205
+ return this.#r;
1206
+ }
1207
+ set labels(e) {
1208
+ this.#r = e;
1209
+ }
1210
+ #i = R();
1211
+ get text() {
1212
+ return this.#i;
1213
+ }
1214
+ set text(e) {
1215
+ this.#i = e;
1216
+ }
1217
+ #a = null;
1218
+ get snapshot() {
1219
+ return this.#a;
1220
+ }
1221
+ set snapshot(e) {
1222
+ this.#a = e;
1223
+ }
1224
+ #o = null;
1225
+ willUpdate(e) {
1226
+ e.has("view") && (this.#o?.(), this.#o = null, this.snapshot = this.view?.getSnapshot() ?? null, this.view && (this.#o = this.view.subscribe((e) => {
1227
+ this.snapshot = e;
1228
+ })));
1229
+ }
1230
+ disconnectedCallback() {
1231
+ this.#o?.(), this.#o = null, super.disconnectedCallback();
1232
+ }
1233
+ render() {
1234
+ let e = this.snapshot, t = e?.wizard;
1235
+ if (!e || !t || e.layout.kind !== "wizard") return _``;
1236
+ let n = e.layout.steps[t.stepIndex];
1237
+ if (!n) return _``;
1238
+ let r = e.form.status, i = r === "validating" || r === "submitting", a = t.isLastStep ? r === "validating" ? this.labels.validating : r === "submitting" ? this.labels.submitting : this.labels.submit : this.labels.next;
1239
+ return _`
1240
+ <div class="root">
1241
+ <section class="panel" part="wizard-panel">
1242
+ <header class="pane-header">
1243
+ <mlf-kit-step-indicator
1244
+ .current=${t.stepIndex + 1}
1245
+ .total=${t.stepCount}
1246
+ .label=${this.text.stepLabel(t.stepIndex + 1, t.stepCount).split(" ")[0] ?? "Step"}
1247
+ ></mlf-kit-step-indicator>
1248
+ <h1 class="step-title">${n.title}</h1>
1249
+ ${n.description ? _`<p class="step-description">${n.description}</p>` : v}
1250
+ </header>
1251
+
1252
+ <div class="pane-body">
1253
+ <div class="collection">
1254
+ ${S(n.children, (e, t) => `${n.id}-${t}`, (t) => M({
1255
+ node: t,
1256
+ view: this.view,
1257
+ snapshot: e,
1258
+ registry: this.registry,
1259
+ primitiveText: this.primitiveText,
1260
+ sectionClass: "section",
1261
+ sectionCopyClass: "section-copy",
1262
+ sectionTitleClass: "section-title",
1263
+ sectionDescriptionClass: "section-description",
1264
+ childrenClass: "section-children",
1265
+ groupBaseClass: "group"
1266
+ }))}
1267
+ </div>
1268
+ </div>
1269
+
1270
+ <div class="actions" part="actions">
1271
+ <button
1272
+ type="button"
1273
+ class="btn btn-prev"
1274
+ ?disabled=${!t.canPrev || i}
1275
+ @click=${this.#s}
1276
+ >
1277
+ ${this.labels.prev}
1278
+ </button>
1279
+ <span class="spacer"></span>
1280
+ <button
1281
+ type="button"
1282
+ class=${t.isLastStep ? "btn btn-submit" : "btn btn-next"}
1283
+ ?disabled=${i}
1284
+ @click=${t.isLastStep ? this.#l : this.#c}
1285
+ >
1286
+ ${a}
1287
+ </button>
1288
+ </div>
1289
+ </section>
1290
+ </div>
1291
+ `;
1292
+ }
1293
+ #s = () => {
1294
+ this.view?.prevStep();
1295
+ };
1296
+ #c = async () => {
1297
+ await this.view?.nextStep() === !1 && this.view && await j(this, this.view, s);
1298
+ };
1299
+ #l = async () => {
1300
+ if (this.view) {
1301
+ if (!await this.view.nextStep()) {
1302
+ await j(this, this.view, s);
1303
+ return;
1304
+ }
1305
+ try {
1306
+ await this.view.submit();
1307
+ } catch (e) {
1308
+ if (!await j(this, this.view, s)) throw e;
1309
+ }
1310
+ }
1311
+ };
1312
+ };
1313
+ l([b({ attribute: !1 })], z.prototype, "view", null), l([b({ attribute: !1 })], z.prototype, "registry", null), l([b({ attribute: !1 })], z.prototype, "primitiveText", null), l([b({ attribute: !1 })], z.prototype, "labels", null), l([b({ attribute: !1 })], z.prototype, "text", null), l([x()], z.prototype, "snapshot", null), z = l([y(A.wizard)], z);
1314
+ //#endregion
1315
+ //#region src/kit/layout-helpers.ts
1316
+ var ue = (e, t) => ({
1317
+ fieldIds: new Set(e.map((e) => e.id)),
1318
+ reportIds: new Set(t.map((e) => e.id))
1319
+ }), de = () => ({
1320
+ fieldStepIds: /* @__PURE__ */ new Map(),
1321
+ reportStepIds: /* @__PURE__ */ new Map(),
1322
+ fieldTabIds: /* @__PURE__ */ new Map(),
1323
+ reportTabIds: /* @__PURE__ */ new Map(),
1324
+ fieldSectionIds: /* @__PURE__ */ new Map(),
1325
+ reportSectionIds: /* @__PURE__ */ new Map(),
1326
+ fieldIdsInLayout: /* @__PURE__ */ new Set(),
1327
+ reportIdsInLayout: /* @__PURE__ */ new Set()
1328
+ }), B = (e, t, r) => {
1329
+ let i = n(t ?? e) || e, a = r.get(i) ?? 0;
1330
+ return r.set(i, a + 1), a === 0 ? i : `${i}-${a + 1}`;
1331
+ }, fe = (e, t) => {
1332
+ if (!t.fieldIds.has(e)) throw TypeError(k.unknownFieldReference(e));
1333
+ }, pe = (e, t) => {
1334
+ if (!t.reportIds.has(e)) throw TypeError(k.unknownReportReference(e));
1335
+ }, me = (e, t, n, r, i) => {
1336
+ if (t.fieldIdsInLayout.has(e)) throw TypeError(k.fieldDuplicateInLayout(e));
1337
+ t.fieldIdsInLayout.add(e), n && t.fieldStepIds.set(e, n), r && t.fieldTabIds.set(e, r), i && t.fieldSectionIds.set(e, i);
1338
+ }, he = (e, t, n, r, i) => {
1339
+ if (t.reportIdsInLayout.has(e)) throw TypeError(k.reportDuplicateInLayout(e));
1340
+ t.reportIdsInLayout.add(e), n && t.reportStepIds.set(e, n), r && t.reportTabIds.set(e, r), i && t.reportSectionIds.set(e, i);
1341
+ }, ge = (e, t) => [...e.map((e) => ({
1342
+ kind: "field",
1343
+ field: e.id
1344
+ })), ...t.map((e) => ({
1345
+ kind: "report",
1346
+ report: e.id
1347
+ }))], V = (e, t) => {
1348
+ for (let n of e) if (!t.fieldIdsInLayout.has(n.id)) throw TypeError(k.fieldMissingInLayout(n.id));
1349
+ }, H = (e, t, n, r, i, a, o) => e.map((e) => {
1350
+ switch (e.kind) {
1351
+ case "section": {
1352
+ let o = B("section", e.id ?? e.title, r);
1353
+ return {
1354
+ kind: "section",
1355
+ id: o,
1356
+ title: e.title,
1357
+ description: e.description,
1358
+ defaultOpen: e.defaultOpen ?? !0,
1359
+ children: H(e.children, t, n, r, i, a, o)
1360
+ };
1361
+ }
1362
+ case "group": return {
1363
+ kind: "group",
1364
+ id: B("group", e.id, r),
1365
+ columns: e.columns,
1366
+ children: H(e.children, t, n, r, i, a, o)
1367
+ };
1368
+ case "field": return fe(e.field, t), me(e.field, n, i, a, o), {
1369
+ kind: "field",
1370
+ field: e.field
1371
+ };
1372
+ case "report": return pe(e.report, t), he(e.report, n, i, a, o), {
1373
+ kind: "report",
1374
+ report: e.report
1375
+ };
1376
+ }
1377
+ }), _e = (e, t, n) => {
1378
+ let r = ue(t, n), i = de(), a = /* @__PURE__ */ new Map();
1379
+ if (!e || e.kind === void 0 || e.kind === "stacked" || e.kind === "split") {
1380
+ let o = H(e?.children ?? ge(t, n), r, i, a, null, null, null);
1381
+ return V(t, i), {
1382
+ layout: {
1383
+ kind: e?.kind ?? "stacked",
1384
+ children: o
1385
+ },
1386
+ maps: i
1387
+ };
1388
+ }
1389
+ if (e.kind === "tabs") {
1390
+ if (e.tabs.length === 0) throw TypeError(k.tabsRequiresTabs);
1391
+ let n = /* @__PURE__ */ new Map(), o = e.tabs.map((e, t) => {
1392
+ let o = B("tab", e.id ?? e.title ?? `tab-${t + 1}`, n), s = H(e.children, r, i, a, null, o, null);
1393
+ if (s.length === 0) throw TypeError(k.tabEmpty(o));
1394
+ return {
1395
+ id: o,
1396
+ title: e.title,
1397
+ description: e.description,
1398
+ children: s
1399
+ };
1400
+ });
1401
+ return V(t, i), {
1402
+ layout: {
1403
+ kind: "tabs",
1404
+ tabs: o
1405
+ },
1406
+ maps: i
1407
+ };
1408
+ }
1409
+ let o = e;
1410
+ if (o.steps.length === 0) throw TypeError(k.wizardRequiresSteps);
1411
+ let s = /* @__PURE__ */ new Map(), c = o.steps.map((e, t) => {
1412
+ let n = B("step", e.id ?? e.title ?? `step-${t + 1}`, s), o = H(e.children, r, i, a, n, null, null);
1413
+ if (o.length === 0) throw TypeError(k.wizardStepEmpty(n));
1414
+ return {
1415
+ id: n,
1416
+ title: e.title,
1417
+ description: e.description,
1418
+ children: o
1419
+ };
1420
+ });
1421
+ return V(t, i), {
1422
+ layout: {
1423
+ kind: "wizard",
1424
+ steps: c
1425
+ },
1426
+ maps: i
1427
+ };
1428
+ }, U = (e, t, n) => {
1429
+ if (n.length === 0) return null;
1430
+ let r = Math.min(Math.max(t, 0), n.length - 1);
1431
+ return {
1432
+ kind: e,
1433
+ index: r,
1434
+ count: n.length,
1435
+ currentId: n[r] ?? n[0],
1436
+ canGoNext: r < n.length - 1,
1437
+ canGoPrev: r > 0
1438
+ };
1439
+ }, W = ({ layout: e, stepIndex: t, formState: n }) => {
1440
+ let r = U("wizard-step", t, (e.kind === "wizard" ? e.steps : []).map((e) => e.id));
1441
+ return r ? {
1442
+ stepIndex: r.index,
1443
+ stepCount: r.count,
1444
+ currentStepId: r.currentId,
1445
+ canNext: n.status !== "validating" && n.status !== "submitting",
1446
+ canPrev: r.canGoPrev,
1447
+ isLastStep: r.index === r.count - 1
1448
+ } : null;
1449
+ }, G = ({ layout: e, activeTabIndex: t }) => {
1450
+ let n = U("tab", t, (e.kind === "tabs" ? e.tabs : []).map((e) => e.id));
1451
+ return n ? {
1452
+ activeTabIndex: n.index,
1453
+ tabCount: n.count,
1454
+ currentTabId: n.currentId,
1455
+ canGoNext: n.canGoNext,
1456
+ canGoPrev: n.canGoPrev
1457
+ } : null;
1458
+ }, K = (e, t = []) => {
1459
+ for (let n of e) n.kind === "section" ? (t.push({
1460
+ id: n.id,
1461
+ defaultOpen: n.defaultOpen
1462
+ }), K(n.children, t)) : n.kind === "group" && K(n.children, t);
1463
+ return t;
1464
+ }, q = ({ layout: e, openSectionIds: t }) => {
1465
+ let n = e.kind === "wizard" ? e.steps.flatMap((e) => K(e.children)) : e.kind === "tabs" ? e.tabs.flatMap((e) => K(e.children)) : K(e.children);
1466
+ return n.length === 0 ? null : {
1467
+ openSectionIds: n.map((e) => e.id).filter((e) => t.has(e)),
1468
+ sectionCount: n.length
1469
+ };
1470
+ }, ve = (e) => ({
1471
+ form: e.formState,
1472
+ wizard: W(e),
1473
+ tabs: G(e),
1474
+ disclosure: q(e)
1475
+ }), J = (e, t, n, r, i, a, o) => e.kind === "wizard" ? i === (e.steps[t]?.id ?? null) && (!o || r.has(o)) : e.kind === "tabs" ? a === (e.tabs[n]?.id ?? null) && (!o || r.has(o)) : !o || r.has(o), ye = (e) => ({
1476
+ component: "unsupported-field",
1477
+ props: { label: e.config.label ?? e.id }
1478
+ }), be = (e, t, n, r, i, a) => {
1479
+ let o = n.maps.fieldStepIds.get(e.id) ?? null, s = n.maps.fieldTabIds.get(e.id) ?? null, c = n.maps.fieldSectionIds.get(e.id) ?? null, l = t.getField(e.kind);
1480
+ return {
1481
+ id: e.id,
1482
+ kind: e.kind,
1483
+ config: e.config,
1484
+ controller: e,
1485
+ state: e.state,
1486
+ descriptor: l?.describe(e.config, {
1487
+ fieldId: e.id,
1488
+ state: e.state,
1489
+ value: e.state.value
1490
+ }) ?? ye(e),
1491
+ stepId: o,
1492
+ tabId: s,
1493
+ sectionId: c,
1494
+ visibleInLayout: J(n.layout, r, i, a, o, s, c)
1495
+ };
1496
+ }, xe = (e, t, n, r, i, a, o) => {
1497
+ let s = r.maps.reportStepIds.get(e.id) ?? null, c = r.maps.reportTabIds.get(e.id) ?? null, l = r.maps.reportSectionIds.get(e.id) ?? null, u = n.getReport(e.kind);
1498
+ return {
1499
+ id: e.id,
1500
+ kind: e.kind,
1501
+ config: e.config,
1502
+ controller: e,
1503
+ state: e.state,
1504
+ descriptor: u ? u.describe(e.config, {
1505
+ reportId: e.id,
1506
+ state: e.state,
1507
+ payload: e.state.payload,
1508
+ result: t.state.lastResult
1509
+ }) : null,
1510
+ stepId: s,
1511
+ tabId: c,
1512
+ sectionId: l,
1513
+ visibleInLayout: J(r.layout, i, a, o, s, c, l)
1514
+ };
1515
+ }, Se = ({ form: e, descriptorRegistry: t, resolvedLayout: n, stepIndex: r, activeTabIndex: i, openSectionIds: a }) => ({
1516
+ form: e.state,
1517
+ layout: n.layout,
1518
+ fields: e.fields.map((e) => be(e, t, n, r, i, a)),
1519
+ reports: e.reports.map((o) => xe(o, e, t, n, r, i, a)),
1520
+ wizard: W({
1521
+ layout: n.layout,
1522
+ stepIndex: r,
1523
+ activeTabIndex: i,
1524
+ openSectionIds: a,
1525
+ formState: e.state
1526
+ }),
1527
+ tabs: G({
1528
+ layout: n.layout,
1529
+ stepIndex: r,
1530
+ activeTabIndex: i,
1531
+ openSectionIds: a,
1532
+ formState: e.state
1533
+ }),
1534
+ disclosure: q({
1535
+ layout: n.layout,
1536
+ stepIndex: r,
1537
+ activeTabIndex: i,
1538
+ openSectionIds: a,
1539
+ formState: e.state
1540
+ })
1541
+ }), Ce = (e, t, n, r, i) => ve({
1542
+ formState: e.state,
1543
+ layout: t,
1544
+ stepIndex: n,
1545
+ activeTabIndex: r,
1546
+ openSectionIds: i
1547
+ }), we = ({ form: e, descriptorRegistry: t, resolvedLayout: n, getStepIndex: r, getActiveTabIndex: i, getOpenSectionIds: a }) => {
1548
+ let o = e.state, s = -1, c = -1, l = "", u = null;
1549
+ return () => {
1550
+ let d = r(), f = i(), p = a(), m = e.state, h = Array.from(p).sort().join("|");
1551
+ return u && o === m && s === d && c === f && l === h ? u : (o = m, s = d, c = f, l = h, u = Se({
1552
+ form: e,
1553
+ descriptorRegistry: t,
1554
+ resolvedLayout: n,
1555
+ stepIndex: d,
1556
+ activeTabIndex: f,
1557
+ openSectionIds: p
1558
+ }), u);
1559
+ };
1560
+ }, Y = (e, t) => e.flatMap((e) => e.kind === "section" ? t.has(e.id) ? [e] : [] : [e]), Te = async (e, t, n) => {
1561
+ if (t.layout.kind !== "wizard") return !1;
1562
+ let r = t.layout.steps[n]?.id;
1563
+ if (!r) return !1;
1564
+ let i = e.fields.filter((e) => t.maps.fieldStepIds.get(e.id) === r && e.state.visible);
1565
+ return (await Promise.all(i.map((e) => e.validate()))).every((e) => e.errors.length === 0);
1566
+ }, Ee = (e, t, n, r) => {
1567
+ switch (e.layout.kind) {
1568
+ case "stacked":
1569
+ case "split": return Y(e.layout.children, r);
1570
+ case "wizard": return Y(e.layout.steps[t]?.children ?? [], r);
1571
+ case "tabs": return Y(e.layout.tabs[n]?.children ?? [], r);
1572
+ }
1573
+ }, X = (e, t) => {
1574
+ if (!e.some((e) => e.id === t)) throw TypeError(k.unknownDisclosureSection(t));
1575
+ }, Z = (t) => {
1576
+ let n = !t.registry || !t.descriptorRegistry || !t.behaviors ? r() : null, i = t.registry ? ee(t.registry) : n.registry, a = t.descriptorRegistry?.clone() ?? n.descriptorRegistry, o = e({
1577
+ schema: t.schema,
1578
+ registry: i,
1579
+ behaviors: t.behaviors ?? n?.behaviors,
1580
+ transport: t.transport,
1581
+ initialValues: t.initialValues,
1582
+ validators: t.validators,
1583
+ hooks: t.hooks,
1584
+ hookFailurePolicy: t.hookFailurePolicy,
1585
+ inactiveFieldPolicy: t.inactiveFieldPolicy,
1586
+ listenerErrorPolicy: t.listenerErrorPolicy,
1587
+ onListenerError: t.onListenerError
1588
+ }), s = _e(t.layout, o.fields, o.reports), c = 0, l = 0, u = s.layout.kind === "wizard" ? s.layout.steps.flatMap((e) => K(e.children)) : s.layout.kind === "tabs" ? s.layout.tabs.flatMap((e) => K(e.children)) : K(s.layout.children), d = new Set(u.filter((e) => e.defaultOpen).map((e) => e.id)), f = /* @__PURE__ */ new Set(), p = s.layout.kind === "wizard" ? s.layout.steps : [], m = s.layout.kind === "tabs" ? s.layout.tabs : [], h = O(s.layout), g = /* @__PURE__ */ new Map();
1589
+ for (let e of D(s.layout)) "id" in e && g.set(e.id, e);
1590
+ let _ = () => Ce(o, s.layout, c, l, d), v = we({
1591
+ form: o,
1592
+ descriptorRegistry: a,
1593
+ resolvedLayout: s,
1594
+ getStepIndex: () => c,
1595
+ getActiveTabIndex: () => l,
1596
+ getOpenSectionIds: () => d
1597
+ }), y = () => {
1598
+ let e = v();
1599
+ for (let t of f) t(e);
1600
+ };
1601
+ return o.subscribe(() => {
1602
+ y();
1603
+ }), Object.freeze({
1604
+ form: o,
1605
+ engineRegistry: i,
1606
+ descriptorRegistry: a,
1607
+ get state() {
1608
+ return _();
1609
+ },
1610
+ getSnapshot: v,
1611
+ getNodeById(e) {
1612
+ return g.get(e);
1613
+ },
1614
+ getField(e) {
1615
+ return v().fields.find((t) => t.id === e);
1616
+ },
1617
+ getReport(e) {
1618
+ return v().reports.find((t) => t.id === e);
1619
+ },
1620
+ getVisibleFields() {
1621
+ return v().fields.filter((e) => e.visibleInLayout && e.state.visible);
1622
+ },
1623
+ getVisibleReports() {
1624
+ return v().reports.filter((e) => e.visibleInLayout);
1625
+ },
1626
+ getActiveLayoutNodes() {
1627
+ return Ee(s, c, l, d);
1628
+ },
1629
+ getLayoutReferences() {
1630
+ return h;
1631
+ },
1632
+ validate() {
1633
+ return o.validate();
1634
+ },
1635
+ submit(e) {
1636
+ return o.submit(e);
1637
+ },
1638
+ reset() {
1639
+ o.reset();
1640
+ },
1641
+ subscribe(e) {
1642
+ return f.add(e), () => {
1643
+ f.delete(e);
1644
+ };
1645
+ },
1646
+ async nextStep() {
1647
+ return s.layout.kind !== "wizard" || !await Te(o, s, c) ? !1 : (c < p.length - 1 && (c += 1, y()), !0);
1648
+ },
1649
+ prevStep() {
1650
+ s.layout.kind === "wizard" && c > 0 && (--c, y());
1651
+ },
1652
+ async goToStep(e) {
1653
+ if (s.layout.kind !== "wizard") throw TypeError(k.nonWizardGoToStep);
1654
+ let t = p.findIndex((t) => t.id === e);
1655
+ if (t < 0) throw TypeError(k.unknownWizardStep(e));
1656
+ if (t <= c) return c = t, y(), !0;
1657
+ for (; c < t;) if (!await this.nextStep()) return !1;
1658
+ return !0;
1659
+ },
1660
+ setActiveTab(e) {
1661
+ if (s.layout.kind !== "tabs") throw TypeError(k.nonTabsSetActiveTab);
1662
+ let t = m.findIndex((t) => t.id === e);
1663
+ if (t < 0) throw TypeError(k.unknownTab(e));
1664
+ t !== l && (l = t, y());
1665
+ },
1666
+ nextTab() {
1667
+ return s.layout.kind !== "tabs" || l >= m.length - 1 ? !1 : (l += 1, y(), !0);
1668
+ },
1669
+ prevTab() {
1670
+ return s.layout.kind !== "tabs" || l <= 0 ? !1 : (--l, y(), !0);
1671
+ },
1672
+ toggleSection(e) {
1673
+ X(u, e), d.has(e) ? d.delete(e) : d.add(e), y();
1674
+ },
1675
+ openSection(e) {
1676
+ X(u, e), d.has(e) || (d.add(e), y());
1677
+ },
1678
+ closeSection(e) {
1679
+ X(u, e), d.delete(e) && y();
1680
+ },
1681
+ openAllSections() {
1682
+ d = new Set(u.map((e) => e.id)), y();
1683
+ },
1684
+ closeAllSections() {
1685
+ d = /* @__PURE__ */ new Set(), y();
1686
+ }
1687
+ });
1688
+ }, Q = Symbol("mlform.kit.mounted"), De = (e) => {
1689
+ if (!e.mode || !e.theme || !e.recipe) throw TypeError(k.invalidDesignSystemSnapshot);
1690
+ }, Oe = (e) => {
1691
+ let t = e.layout;
1692
+ return !!(t && "children" in t && t.children && t.children.length > 0);
1693
+ }, ke = (e) => Z({
1694
+ schema: e.schema,
1695
+ transport: e.transport,
1696
+ registry: e.registry,
1697
+ descriptorRegistry: e.descriptorRegistry,
1698
+ behaviors: e.behaviors,
1699
+ initialValues: e.initialValues,
1700
+ validators: e.validators,
1701
+ hooks: e.hooks,
1702
+ hookFailurePolicy: e.hookFailurePolicy,
1703
+ inactiveFieldPolicy: e.inactiveFieldPolicy,
1704
+ listenerErrorPolicy: e.listenerErrorPolicy,
1705
+ onListenerError: e.onListenerError,
1706
+ layout: e.layout
1707
+ }), Ae = (e, t) => {
1708
+ let n = e;
1709
+ n[Q]?.unmount();
1710
+ let r = te(t.primitiveRegistry), i = ne(t.designSystemRegistry), a = re(t.labels), o = ie(t.designSystem), s = !t.layout || (t.layout.kind === void 0 || t.layout.kind === "stacked" || t.layout.kind === "split") && !Oe(t), c = ke(t), l = () => {}, u = s ? (() => {
1711
+ let n = d(e, c.form, {
1712
+ registry: r,
1713
+ descriptorRegistry: c.descriptorRegistry,
1714
+ layout: t.layout?.kind === "split" ? "split" : "stacked",
1715
+ containerStrategy: t.containerStrategy,
1716
+ formLabel: a.form,
1717
+ reportsLabel: a.reports,
1718
+ submitLabel: a.submit,
1719
+ validatingLabel: a.validating,
1720
+ submittingLabel: a.submitting,
1721
+ reportPane: t.reportPane,
1722
+ text: t.primitiveText,
1723
+ reportTransport: t.reportTransport
1724
+ });
1725
+ return l = () => n.unmount(), n.host;
1726
+ })() : (() => {
1727
+ let n = je(e, t, r, a, c);
1728
+ return l = () => n.remove(), n;
1729
+ })(), f = m(u, {
1730
+ config: o,
1731
+ registry: i,
1732
+ onChange: t.onDesignSystemChange
1733
+ }), p = !1, h = Object.freeze({
1734
+ form: c.form,
1735
+ host: u,
1736
+ engineRegistry: c.engineRegistry,
1737
+ descriptorRegistry: c.descriptorRegistry,
1738
+ primitiveRegistry: r,
1739
+ designSystemRegistry: i,
1740
+ designSystem: f,
1741
+ updateDesignSystem(e) {
1742
+ f.update(e);
1743
+ },
1744
+ replaceDesignSystem(e) {
1745
+ De(e), f.replace(e);
1746
+ },
1747
+ resetDesignSystem() {
1748
+ f.reset();
1749
+ },
1750
+ unmount() {
1751
+ p || (p = !0, n[Q] === h && delete n[Q], c.form.abortSubmit("unmount"), f.disconnect(), l());
1752
+ }
1753
+ });
1754
+ return n[Q] = h, h;
1755
+ }, $ = (e) => {
1756
+ e.unmount();
1757
+ }, je = (e, t, n, r, a) => {
1758
+ let o = a.getSnapshot(), s = o.layout.kind === "wizard" ? A.wizard : o.layout.kind === "tabs" ? A.tabs : A.disclosure, c = document.createElement(s);
1759
+ if (c.view = a, c.registry = n, c.primitiveText = i(t.primitiveText), o.layout.kind === "wizard") {
1760
+ let e = {
1761
+ ...I,
1762
+ ...t.labels
1763
+ };
1764
+ c.labels = e, c.text = R({
1765
+ prevLabel: e.prev,
1766
+ nextLabel: e.next,
1767
+ submitLabel: e.submit,
1768
+ validatingLabel: e.validating,
1769
+ submittingLabel: e.submitting
1770
+ });
1771
+ } else c.submitLabel = r.submit, c.validatingLabel = r.validating, c.submittingLabel = r.submitting;
1772
+ return e.replaceChildren(c), c;
1773
+ }, Me = (e, t) => e ? typeof e == "function" ? e(t) ?? {} : e : {}, Ne = (e) => {
1774
+ let t = e.validate, n = {
1775
+ kind: e.kind,
1776
+ schema: e.schema,
1777
+ getDefaultValue: e.value?.default,
1778
+ normalizeValue: e.value?.normalize,
1779
+ cloneValue: e.value?.clone,
1780
+ isEqual: e.value?.isEqual,
1781
+ serializeValue: e.value?.serialize,
1782
+ validate: t ? (e, n, r) => t({
1783
+ ...r,
1784
+ config: n,
1785
+ value: e
1786
+ }) : void 0
1787
+ }, r = {
1788
+ kind: e.kind,
1789
+ describe(t, n) {
1790
+ let r = Me(e.render.hints, {
1791
+ config: t,
1792
+ fieldId: t.id,
1793
+ state: n.state,
1794
+ value: n.value
1795
+ });
1796
+ return {
1797
+ component: "declarative-field",
1798
+ props: {
1799
+ id: t.id,
1800
+ kind: t.kind,
1801
+ label: t.label,
1802
+ description: t.description ?? "",
1803
+ showDescriptionInline: !!t.showDescriptionInline,
1804
+ required: !!t.required,
1805
+ disabled: !!t.disabled,
1806
+ widget: e.render.widget,
1807
+ value: n.value,
1808
+ state: n.state.status,
1809
+ errors: n.state.errors,
1810
+ ...r,
1811
+ ...t.ui
1812
+ },
1813
+ meta: {
1814
+ declarative: !0,
1815
+ widget: e.render.widget
1816
+ }
1817
+ };
1818
+ }
1819
+ }, i = r.describe.bind(r);
1820
+ return Object.assign(n, { describe: i }), {
1821
+ kind: e.kind,
1822
+ schema: e.schema,
1823
+ getDefaultValue: e.value?.default,
1824
+ normalizeValue: e.value?.normalize,
1825
+ cloneValue: e.value?.clone,
1826
+ isEqual: e.value?.isEqual,
1827
+ serializeValue: e.value?.serialize,
1828
+ validate: n.validate,
1829
+ describe: i,
1830
+ definition: n,
1831
+ presenter: r
1832
+ };
1833
+ }, Pe = (e) => {
1834
+ let t = {
1835
+ kind: e.kind,
1836
+ schema: e.schema,
1837
+ payloadSchema: e.payloadSchema,
1838
+ payloadValidationPolicy: e.payloadValidationPolicy,
1839
+ partialUpdatePolicy: e.partialUpdatePolicy,
1840
+ clonePayload: e.clonePayload,
1841
+ fetch: e.fetch,
1842
+ resolvePayload: (t, n) => e.resolve({
1843
+ config: n.report,
1844
+ report: n.report,
1845
+ result: n.result
1846
+ })
1847
+ }, n = {
1848
+ kind: e.kind,
1849
+ describe(t, n) {
1850
+ if (n.payload === void 0 && n.state.error === null && n.result === null) return null;
1851
+ let r = {
1852
+ config: t,
1853
+ report: t,
1854
+ reportId: t.id,
1855
+ state: n.state,
1856
+ payload: n.payload,
1857
+ result: n.result
1858
+ };
1859
+ return {
1860
+ component: "declarative-report",
1861
+ props: {
1862
+ id: t.id,
1863
+ kind: t.kind,
1864
+ label: t.label ?? t.id,
1865
+ description: t.description ?? "",
1866
+ payload: n.payload,
1867
+ error: n.state.error,
1868
+ state: n.state.status,
1869
+ summary: e.render.summary?.(r) ?? null,
1870
+ content: n.payload === void 0 ? [] : a(e.render.content(r)),
1871
+ ...t.ui
1872
+ },
1873
+ meta: { declarative: !0 }
1874
+ };
1875
+ }
1876
+ }, r = n.describe.bind(n);
1877
+ return Object.assign(t, { describe: r }), {
1878
+ kind: e.kind,
1879
+ schema: e.schema,
1880
+ payloadSchema: e.payloadSchema,
1881
+ payloadValidationPolicy: e.payloadValidationPolicy,
1882
+ partialUpdatePolicy: e.partialUpdatePolicy,
1883
+ clonePayload: t.clonePayload,
1884
+ fetch: t.fetch,
1885
+ resolvePayload: t.resolvePayload,
1886
+ describe: r,
1887
+ definition: t,
1888
+ presenter: n
1889
+ };
1890
+ }, Fe = (e, t, n) => {
1891
+ e.registerField(n.definition), t.registerField(n.presenter);
1892
+ }, Ie = (e, t, n) => {
1893
+ e.registerReport(n.definition), t.registerReport(n.presenter);
1894
+ };
1895
+ //#endregion
1896
+ export { O as collectLayoutReferences, Z as createFormView, w as defaultKitDesignSystem, C as defaultKitLabels, Ne as defineFieldKind, Pe as defineReportKind, D as flattenLayoutNodes, Ae as mountForm, Fe as registerDefinedFieldKind, Ie as registerDefinedReportKind, $ as unmountForm, E as walkLayoutNodes };