@drfed/web 0.0.0-stage → 0.1.0-dev.561

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 (126) hide show
  1. package/.output/nitro.json +17 -0
  2. package/.output/public/.vite/manifest.json +483 -0
  3. package/.output/public/_build/assets/ActorDetailQuery.graphql-D96mwq1k.js +60 -0
  4. package/.output/public/_build/assets/ActorDetailQuery.graphql-DrxSNh1X.js +60 -0
  5. package/.output/public/_build/assets/CompleteLoginChallenge.graphql-C5Zq3wNh.js +10 -0
  6. package/.output/public/_build/assets/CopyButton-B2l484wE.js +1 -0
  7. package/.output/public/_build/assets/CopyButton-Bi-ZR8x9.css +1 -0
  8. package/.output/public/_build/assets/CreateInstanceMutation.graphql-B4CRy6cl.js +19 -0
  9. package/.output/public/_build/assets/CreateObjectMutation.graphql-B4A01dgV.js +23 -0
  10. package/.output/public/_build/assets/GenerateActorsMutation.graphql-mlHJNIbe.js +23 -0
  11. package/.output/public/_build/assets/GetHostQuery.graphql-CuzDdOdW.js +17 -0
  12. package/.output/public/_build/assets/GetHostQuery.graphql-o9K0Qkg0.js +17 -0
  13. package/.output/public/_build/assets/HomeViewerQuery.graphql-B903WWKs.js +8 -0
  14. package/.output/public/_build/assets/HttpStatusCode-bgaVzuLy.js +1 -0
  15. package/.output/public/_build/assets/InstanceActorListQuery.graphql-DmNwiEhM.js +24 -0
  16. package/.output/public/_build/assets/InstanceActorListQuery.graphql-paa7teUO.js +24 -0
  17. package/.output/public/_build/assets/InstanceDetailQuery.graphql-B52nR132.js +66 -0
  18. package/.output/public/_build/assets/InstanceDetailQuery.graphql-DSA2BcAV.js +66 -0
  19. package/.output/public/_build/assets/JNCCF6MP-CNMywyiC.js +1 -0
  20. package/.output/public/_build/assets/LP6E37CW-Cwv6G3n1.js +1 -0
  21. package/.output/public/_build/assets/SignInMutation.graphql-BalZYNFu.js +9 -0
  22. package/.output/public/_build/assets/TSB6MOZK-CpiH97G1.js +1 -0
  23. package/.output/public/_build/assets/Toast-3-eXCAKc.css +1 -0
  24. package/.output/public/_build/assets/Toast-C1zr9crB.js +1 -0
  25. package/.output/public/_build/assets/WorkspaceQuery.graphql-UoI7QDs4.js +23 -0
  26. package/.output/public/_build/assets/_...404_-WZ8kAljY.js +1 -0
  27. package/.output/public/_build/assets/_challengeId_-Dk-0l7zl.js +1 -0
  28. package/.output/public/_build/assets/_id_-YcZZShAv.css +1 -0
  29. package/.output/public/_build/assets/_id_-bpxdclBj.js +1 -0
  30. package/.output/public/_build/assets/_slug_-CyTA2aW7.css +1 -0
  31. package/.output/public/_build/assets/_slug_-DXfRknzJ.js +200 -0
  32. package/.output/public/_build/assets/about-DIrbzRsi.js +1 -0
  33. package/.output/public/_build/assets/actors-HfZh_afh.js +24 -0
  34. package/.output/public/_build/assets/client-CGFoRcqH.js +3 -0
  35. package/.output/public/_build/assets/components-5MVu7IcD.js +1 -0
  36. package/.output/public/_build/assets/dist-BrJ_B8nU.js +1 -0
  37. package/.output/public/_build/assets/dist-DVo0HS5G.js +1 -0
  38. package/.output/public/_build/assets/dist-WrlGlK67.js +1 -0
  39. package/.output/public/_build/assets/entry-client-BurSTYr9.css +1 -0
  40. package/.output/public/_build/assets/entry-client-Do7ocrsL.js +8 -0
  41. package/.output/public/_build/assets/form-BxigYd7J.css +1 -0
  42. package/.output/public/_build/assets/form.module-BecmEfV_.js +1 -0
  43. package/.output/public/_build/assets/index-BHn6sAgH.js +23 -0
  44. package/.output/public/_build/assets/index-BSLqnqN7.js +8 -0
  45. package/.output/public/_build/assets/index-B_xLBDOo.css +1 -0
  46. package/.output/public/_build/assets/instance-tpMrvJNZ.js +35 -0
  47. package/.output/public/_build/assets/label-Mv8GZ4jc.js +1 -0
  48. package/.output/public/_build/assets/objects-DPb8DI8A.css +1 -0
  49. package/.output/public/_build/assets/objects-DR9TfL-V.js +25 -0
  50. package/.output/public/_build/assets/relay-runtime-BX3uubtA.js +7 -0
  51. package/.output/public/_build/assets/routing-DMN2NHu6.js +1 -0
  52. package/.output/public/_build/assets/sign-in-B67sv7z8.js +10 -0
  53. package/.output/public/_build/assets/web-DB_Nkq2D.js +1 -0
  54. package/.output/public/apple-touch-icon.png +0 -0
  55. package/.output/public/favicon.ico +0 -0
  56. package/.output/public/icon-192.png +0 -0
  57. package/.output/public/icon-512.png +0 -0
  58. package/.output/public/icon-mask.png +0 -0
  59. package/.output/public/icon.svg +395 -0
  60. package/.output/public/manifest.webmanifest +13 -0
  61. package/.output/server/_...404_-DDEH5apf.mjs +16 -0
  62. package/.output/server/_challengeId_-C_n_Bww9.mjs +100 -0
  63. package/.output/server/_chunks/ssr-renderer.mjs +26 -0
  64. package/.output/server/_id_-DqytvZEf.mjs +505 -0
  65. package/.output/server/_libs/@shikijs/core+[...].mjs +7173 -0
  66. package/.output/server/_libs/@shikijs/engine-javascript+[...].mjs +3110 -0
  67. package/.output/server/_libs/babel__runtime.mjs +243 -0
  68. package/.output/server/_libs/dequal.mjs +25 -0
  69. package/.output/server/_libs/faker-js__faker.mjs +13150 -0
  70. package/.output/server/_libs/fbjs.mjs +115 -0
  71. package/.output/server/_libs/h3+rou3+srvx.mjs +650 -0
  72. package/.output/server/_libs/hookable.mjs +41 -0
  73. package/.output/server/_libs/invariant.mjs +36 -0
  74. package/.output/server/_libs/relay-runtime.mjs +9704 -0
  75. package/.output/server/_libs/seroval-plugins.mjs +563 -0
  76. package/.output/server/_libs/seroval.mjs +2956 -0
  77. package/.output/server/_libs/shikijs__langs.mjs +3 -0
  78. package/.output/server/_libs/shikijs__themes.mjs +7 -0
  79. package/.output/server/_libs/solid-js.mjs +1248 -0
  80. package/.output/server/_libs/solid-relay+tiny-invariant.mjs +1029 -0
  81. package/.output/server/_libs/ufo.mjs +64 -0
  82. package/.output/server/_libs/valibot.mjs +711 -0
  83. package/.output/server/_runtime.mjs +33 -0
  84. package/.output/server/_slug_-CBOaSqoF.mjs +978 -0
  85. package/.output/server/_ssr/ActorDetailQuery.graphql-C1mWRP1B.mjs +283 -0
  86. package/.output/server/_ssr/CompleteLoginChallenge.graphql-CM7o_Md1.mjs +78 -0
  87. package/.output/server/_ssr/CopyButton-CQNR5D1y.mjs +43 -0
  88. package/.output/server/_ssr/CreateInstanceMutation.graphql-C-h2lGxz.mjs +116 -0
  89. package/.output/server/_ssr/CreateObjectMutation.graphql-C393Hp7q.mjs +166 -0
  90. package/.output/server/_ssr/GenerateActorsMutation.graphql-D2ADtn1j.mjs +163 -0
  91. package/.output/server/_ssr/GetHostQuery.graphql-C45XQo1i.mjs +127 -0
  92. package/.output/server/_ssr/HomeViewerQuery.graphql-Dote4Pkz.mjs +81 -0
  93. package/.output/server/_ssr/InstanceActorListQuery.graphql-DgItgN5t.mjs +167 -0
  94. package/.output/server/_ssr/InstanceDetailQuery.graphql-DP5wWWjX.mjs +367 -0
  95. package/.output/server/_ssr/JNCCF6MP-BAZlBnvx.mjs +419 -0
  96. package/.output/server/_ssr/LP6E37CW-D2Ih_b_K.mjs +163 -0
  97. package/.output/server/_ssr/SignInMutation.graphql-BBXmiay6.mjs +72 -0
  98. package/.output/server/_ssr/TSB6MOZK-D06WZb6o.mjs +166 -0
  99. package/.output/server/_ssr/Toast-Bb1gcxED.mjs +947 -0
  100. package/.output/server/_ssr/WorkspaceQuery.graphql-DnCO8t-4.mjs +153 -0
  101. package/.output/server/_ssr/about-CD3QIgf_.mjs +14 -0
  102. package/.output/server/_ssr/actors-CMWf-xQU.mjs +1160 -0
  103. package/.output/server/_ssr/dist-D6rgyh-L.mjs +81 -0
  104. package/.output/server/_ssr/dist-I7KRMRbA.mjs +432 -0
  105. package/.output/server/_ssr/form.module-CTvIl1lm.mjs +192 -0
  106. package/.output/server/_ssr/index-C4crD6q-.mjs +347 -0
  107. package/.output/server/_ssr/index-yuhuc6-X.mjs +111 -0
  108. package/.output/server/_ssr/instance-ZYWGeWd3.mjs +280 -0
  109. package/.output/server/_ssr/label-DAXzanI9.mjs +9 -0
  110. package/.output/server/_ssr/objects-D5MVukzB.mjs +4316 -0
  111. package/.output/server/_ssr/routing-DKTLkkbY.mjs +620 -0
  112. package/.output/server/_ssr/sign-in-CNHZb_zL.mjs +264 -0
  113. package/.output/server/_ssr/ssr.mjs +6121 -0
  114. package/.output/server/index.mjs +684 -0
  115. package/LICENSE +661 -0
  116. package/README.md +143 -2
  117. package/dist/bridge.d.mts +39 -0
  118. package/dist/bridge.mjs +104 -0
  119. package/dist/bridge.mjs.map +1 -0
  120. package/dist/request-policy.d.mts +8 -0
  121. package/dist/request-policy.mjs +94 -0
  122. package/dist/request-policy.mjs.map +1 -0
  123. package/dist/runtime.d.mts +14 -0
  124. package/dist/runtime.mjs +44 -0
  125. package/dist/runtime.mjs.map +1 -0
  126. package/package.json +123 -3
@@ -0,0 +1,81 @@
1
+ import { F as createContext, H as createUniqueId, J as onCleanup, N as createComponent, R as createRenderEffect, h as ssr, nt as useContext, u as escape, x as useAssets } from "../_libs/solid-js.mjs";
2
+ //#region node_modules/.nitro/vite/services/ssr/_build/assets/dist-D6rgyh-L.js
3
+ var MetaContext = createContext();
4
+ var cascadingTags = ["title", "meta"];
5
+ var titleTagProperties = [];
6
+ var metaTagProperties = [
7
+ "name",
8
+ "http-equiv",
9
+ "content",
10
+ "charset",
11
+ "media"
12
+ ].concat(["property"]);
13
+ var getTagKey = (tag, properties) => {
14
+ const tagProps = Object.fromEntries(Object.entries(tag.props).filter(([k]) => properties.includes(k)).sort());
15
+ if (Object.hasOwn(tagProps, "name") || Object.hasOwn(tagProps, "property")) {
16
+ tagProps.name = tagProps.name || tagProps.property;
17
+ delete tagProps.property;
18
+ }
19
+ return tag.tag + JSON.stringify(tagProps);
20
+ };
21
+ function initServerProvider() {
22
+ const tags = [];
23
+ useAssets(() => ssr(renderTags(tags)));
24
+ return {
25
+ addTag(tagDesc) {
26
+ if (cascadingTags.indexOf(tagDesc.tag) !== -1) {
27
+ const properties = tagDesc.tag === "title" ? titleTagProperties : metaTagProperties;
28
+ const tagDescKey = getTagKey(tagDesc, properties);
29
+ const index = tags.findIndex((prev) => prev.tag === tagDesc.tag && getTagKey(prev, properties) === tagDescKey);
30
+ if (index !== -1) tags.splice(index, 1);
31
+ }
32
+ tags.push(tagDesc);
33
+ return tags.length;
34
+ },
35
+ removeTag(tag, index) {}
36
+ };
37
+ }
38
+ var MetaProvider = (props) => {
39
+ const actions = initServerProvider();
40
+ return createComponent(MetaContext.Provider, {
41
+ value: actions,
42
+ get children() {
43
+ return props.children;
44
+ }
45
+ });
46
+ };
47
+ var MetaTag = (tag, props, setting) => {
48
+ useHead({
49
+ tag,
50
+ props,
51
+ setting,
52
+ id: createUniqueId(),
53
+ get name() {
54
+ return props.name || props.property;
55
+ }
56
+ });
57
+ return null;
58
+ };
59
+ function useHead(tagDesc) {
60
+ const c = useContext(MetaContext);
61
+ if (!c) throw new Error("<MetaProvider /> should be in the tree");
62
+ createRenderEffect(() => {
63
+ const index = c.addTag(tagDesc);
64
+ onCleanup(() => c.removeTag(tagDesc, index));
65
+ });
66
+ }
67
+ function renderTags(tags) {
68
+ return tags.map((tag) => {
69
+ const props = Object.keys(tag.props).map((k) => k === "children" ? "" : ` ${k}="${escape(tag.props[k], true)}"`).join("");
70
+ let children = tag.props.children;
71
+ if (Array.isArray(children)) children = children.join("");
72
+ if (tag.setting?.close) return `<${tag.tag} data-sm="${tag.id}"${props}>${tag.setting?.escape ? escape(children) : children || ""}</${tag.tag}>`;
73
+ return `<${tag.tag} data-sm="${tag.id}"${props}/>`;
74
+ }).join("");
75
+ }
76
+ var Title = (props) => MetaTag("title", props, {
77
+ escape: true,
78
+ close: true
79
+ });
80
+ //#endregion
81
+ export { Title as n, MetaProvider as t };
@@ -0,0 +1,432 @@
1
+ import { $ as splitProps, A as batch, H as createUniqueId, J as onCleanup, K as mergeProps, L as createMemo, V as createSignal, _ as ssrElement, tt as untrack } from "../_libs/solid-js.mjs";
2
+ import { i as getDefault, v as safeParseAsync } from "../_libs/valibot.mjs";
3
+ //#region node_modules/.nitro/vite/services/ssr/_build/assets/dist-I7KRMRbA.js
4
+ var framework = "solid";
5
+ // @__NO_SIDE_EFFECTS__
6
+ function createSignal$1(initialValue) {
7
+ const [getSignal, setSignal] = createSignal(initialValue);
8
+ return {
9
+ get value() {
10
+ return getSignal();
11
+ },
12
+ set value(nextValue) {
13
+ setSignal(() => nextValue);
14
+ }
15
+ };
16
+ }
17
+ function initializeFieldStore(internalFormStore, internalFieldStore, schema, initialInput, path, nullish = false) {
18
+ if (framework === "qwik" && schema.type === "lazy" || schema.type === "object_with_rest" || schema.type === "record" || schema.type === "tuple_with_rest" || schema.type === "promise") throw new Error(`"${schema.type}" schema is not supported`);
19
+ else if (schema.type === "lazy") initializeFieldStore(internalFormStore, internalFieldStore, schema.getter(void 0), initialInput, path, nullish);
20
+ else if (schema.type === "exact_optional" || schema.type === "nullable" || schema.type === "nullish" || schema.type === "optional" || schema.type === "undefinedable") initializeFieldStore(internalFormStore, internalFieldStore, schema.wrapped, initialInput === void 0 ? getDefault(schema) : initialInput, path, true);
21
+ else if (schema.type === "non_nullable" || schema.type === "non_nullish" || schema.type === "non_optional") initializeFieldStore(internalFormStore, internalFieldStore, schema.wrapped, initialInput, path, nullish);
22
+ else if (schema.type === "intersect" || schema.type === "union" || schema.type === "variant") for (const schemaOption of schema.options) initializeFieldStore(internalFormStore, internalFieldStore, schemaOption, initialInput, path, nullish);
23
+ else {
24
+ internalFieldStore.schema = schema;
25
+ internalFieldStore.name = JSON.stringify(path);
26
+ internalFieldStore.path = path;
27
+ internalFieldStore.isNullish = nullish;
28
+ const initialElements = [];
29
+ internalFieldStore.initialElements = initialElements;
30
+ internalFieldStore.elements = initialElements;
31
+ internalFieldStore.errors = /* @__PURE__ */ createSignal$1(null);
32
+ internalFieldStore.isTouched = /* @__PURE__ */ createSignal$1(false);
33
+ internalFieldStore.isEdited = /* @__PURE__ */ createSignal$1(false);
34
+ internalFieldStore.isDirty = /* @__PURE__ */ createSignal$1(false);
35
+ if (schema.type === "array" || schema.type === "loose_tuple" || schema.type === "strict_tuple" || schema.type === "tuple") {
36
+ if (internalFieldStore.kind && internalFieldStore.kind !== "array") throw new Error(`Store initialized as "${internalFieldStore.kind}" cannot be reinitialized as "array"`);
37
+ internalFieldStore.kind = "array";
38
+ if (internalFieldStore.kind === "array") {
39
+ internalFieldStore.children ??= [];
40
+ if (schema.type === "array") {
41
+ if (initialInput) for (let index = 0; index < initialInput.length; index++) {
42
+ internalFieldStore.children[index] = {};
43
+ initializeFieldStore(internalFormStore, internalFieldStore.children[index], schema.item, initialInput[index], [...path, index]);
44
+ }
45
+ } else for (let index = 0; index < schema.items.length; index++) {
46
+ internalFieldStore.children[index] = {};
47
+ initializeFieldStore(internalFormStore, internalFieldStore.children[index], schema.items[index], initialInput?.[index], [...path, index]);
48
+ }
49
+ const arrayInput = nullish && initialInput == null ? initialInput : true;
50
+ internalFieldStore.initialInput = /* @__PURE__ */ createSignal$1(arrayInput);
51
+ internalFieldStore.startInput = /* @__PURE__ */ createSignal$1(arrayInput);
52
+ internalFieldStore.input = /* @__PURE__ */ createSignal$1(arrayInput);
53
+ const initialItems = internalFieldStore.children.map(createUniqueId);
54
+ internalFieldStore.initialItems = /* @__PURE__ */ createSignal$1(initialItems);
55
+ internalFieldStore.startItems = /* @__PURE__ */ createSignal$1(initialItems);
56
+ internalFieldStore.items = /* @__PURE__ */ createSignal$1(initialItems);
57
+ }
58
+ } else if (schema.type === "loose_object" || schema.type === "object" || schema.type === "strict_object") {
59
+ if (internalFieldStore.kind && internalFieldStore.kind !== "object") throw new Error(`Store initialized as "${internalFieldStore.kind}" cannot be reinitialized as "object"`);
60
+ internalFieldStore.kind = "object";
61
+ if (internalFieldStore.kind === "object") {
62
+ internalFieldStore.children ??= {};
63
+ for (const key in schema.entries) {
64
+ internalFieldStore.children[key] ??= {};
65
+ initializeFieldStore(internalFormStore, internalFieldStore.children[key], schema.entries[key], initialInput?.[key], [...path, key]);
66
+ }
67
+ const objectInput = nullish && initialInput == null ? initialInput : true;
68
+ internalFieldStore.initialInput = /* @__PURE__ */ createSignal$1(objectInput);
69
+ internalFieldStore.startInput = /* @__PURE__ */ createSignal$1(objectInput);
70
+ internalFieldStore.input = /* @__PURE__ */ createSignal$1(objectInput);
71
+ }
72
+ } else {
73
+ if (internalFieldStore.kind && internalFieldStore.kind !== "value") throw new Error(`Store initialized as "${internalFieldStore.kind}" cannot be reinitialized as "value"`);
74
+ internalFieldStore.kind = "value";
75
+ if (internalFieldStore.kind === "value") {
76
+ const valueInput = initialInput === void 0 && !nullish ? internalFormStore.emptyInput[schema.type] : initialInput;
77
+ internalFieldStore.initialInput = /* @__PURE__ */ createSignal$1(valueInput);
78
+ internalFieldStore.startInput = /* @__PURE__ */ createSignal$1(valueInput);
79
+ internalFieldStore.input = /* @__PURE__ */ createSignal$1(valueInput);
80
+ }
81
+ }
82
+ }
83
+ }
84
+ function resetItemState(internalFormStore, internalFieldStore, input, keepStart = false) {
85
+ batch(() => {
86
+ const elements = [];
87
+ if (internalFieldStore.elements === internalFieldStore.initialElements) internalFieldStore.initialElements = elements;
88
+ internalFieldStore.elements = elements;
89
+ internalFieldStore.errors.value = null;
90
+ internalFieldStore.isTouched.value = false;
91
+ internalFieldStore.isEdited.value = false;
92
+ internalFieldStore.isDirty.value = false;
93
+ if (internalFieldStore.kind === "array" || internalFieldStore.kind === "object") {
94
+ const objectInput = internalFieldStore.isNullish && input == null ? input : true;
95
+ if (!keepStart) internalFieldStore.startInput.value = objectInput;
96
+ internalFieldStore.input.value = objectInput;
97
+ if (internalFieldStore.kind === "array") {
98
+ const isTuple = internalFieldStore.schema.type !== "array";
99
+ if (input || isTuple) {
100
+ const length = isTuple ? internalFieldStore.children.length : input.length;
101
+ const newItems = Array.from({ length }, createUniqueId);
102
+ if (!keepStart) internalFieldStore.startItems.value = newItems;
103
+ internalFieldStore.items.value = newItems;
104
+ for (let index = 0; index < length; index++) {
105
+ const itemInput = input?.[index];
106
+ if (internalFieldStore.children[index]) resetItemState(internalFormStore, internalFieldStore.children[index], itemInput, keepStart);
107
+ else {
108
+ internalFieldStore.children[index] = {};
109
+ initializeFieldStore(internalFormStore, internalFieldStore.children[index], internalFieldStore.schema.item, itemInput, [...internalFieldStore.path, index]);
110
+ }
111
+ }
112
+ } else {
113
+ if (!keepStart) internalFieldStore.startItems.value = [];
114
+ internalFieldStore.items.value = [];
115
+ }
116
+ } else for (const key in internalFieldStore.children) resetItemState(internalFormStore, internalFieldStore.children[key], input?.[key], keepStart);
117
+ } else {
118
+ const valueInput = input === void 0 && !internalFieldStore.isNullish ? internalFormStore.emptyInput[internalFieldStore.schema.type] : input;
119
+ if (!keepStart) internalFieldStore.startInput.value = valueInput;
120
+ internalFieldStore.input.value = valueInput;
121
+ }
122
+ });
123
+ }
124
+ function focusFieldElement(internalFieldStore) {
125
+ for (const element of internalFieldStore.elements) {
126
+ element.focus();
127
+ if (element.getRootNode().activeElement === element) return true;
128
+ }
129
+ return false;
130
+ }
131
+ function walkFieldStore(internalFieldStore, callback) {
132
+ if (callback(internalFieldStore)) return true;
133
+ if (internalFieldStore.kind === "array") {
134
+ for (let index = 0; index < internalFieldStore.items.value.length; index++) if (walkFieldStore(internalFieldStore.children[index], callback)) return true;
135
+ } else if (internalFieldStore.kind === "object") {
136
+ for (const key in internalFieldStore.children) if (walkFieldStore(internalFieldStore.children[key], callback)) return true;
137
+ }
138
+ return false;
139
+ }
140
+ // @__NO_SIDE_EFFECTS__
141
+ function getFieldBool(internalFieldStore, type) {
142
+ return walkFieldStore(internalFieldStore, (internalFieldStore$1) => Boolean(internalFieldStore$1[type].value));
143
+ }
144
+ // @__NO_SIDE_EFFECTS__
145
+ function getFieldInput(internalFieldStore) {
146
+ if (internalFieldStore.kind === "array") {
147
+ if (internalFieldStore.input.value) {
148
+ const value = [];
149
+ for (let index = 0; index < internalFieldStore.items.value.length; index++) value[index] = /* @__PURE__ */ getFieldInput(internalFieldStore.children[index]);
150
+ return value;
151
+ }
152
+ return internalFieldStore.input.value;
153
+ }
154
+ if (internalFieldStore.kind === "object") {
155
+ if (internalFieldStore.input.value) {
156
+ const value = {};
157
+ for (const key in internalFieldStore.children) value[key] = /* @__PURE__ */ getFieldInput(internalFieldStore.children[key]);
158
+ return value;
159
+ }
160
+ return internalFieldStore.input.value;
161
+ }
162
+ return internalFieldStore.input.value;
163
+ }
164
+ // @__NO_SIDE_EFFECTS__
165
+ function getElementInput(element, internalFieldStore) {
166
+ if (element.options && internalFieldStore.kind === "array") return [...element.options].filter((option) => option.selected && !option.disabled).map((option) => option.value);
167
+ if (element.type === "checkbox") {
168
+ if (internalFieldStore.kind === "array") return Array.from(document.getElementsByName(element.name)).filter((option) => option.checked && !option.disabled && option.form === element.form).map((option) => option.value);
169
+ return element.checked;
170
+ }
171
+ if (element.type === "radio") {
172
+ if (element.checked) return element.value;
173
+ return untrack(() => /* @__PURE__ */ getFieldInput(internalFieldStore));
174
+ }
175
+ if (element.type === "file") {
176
+ if (internalFieldStore.kind === "array") return [...element.files];
177
+ return element.files[0];
178
+ }
179
+ return element.value;
180
+ }
181
+ // @__NO_SIDE_EFFECTS__
182
+ function getFieldStore(internalFormStore, path) {
183
+ let internalFieldStore = internalFormStore;
184
+ for (const key of path) {
185
+ if (internalFieldStore.kind === "array" && untrack(() => internalFieldStore.items.value)[key] === void 0) return;
186
+ internalFieldStore = internalFieldStore.children[key];
187
+ }
188
+ return internalFieldStore;
189
+ }
190
+ function setFieldBool(internalFieldStore, type, bool) {
191
+ batch(() => {
192
+ untrack(() => {
193
+ walkFieldStore(internalFieldStore, (internalFieldStore$1) => {
194
+ internalFieldStore$1[type].value = bool;
195
+ });
196
+ });
197
+ });
198
+ }
199
+ function setNestedInput(internalFormStore, internalFieldStore, input) {
200
+ internalFieldStore.isTouched.value = true;
201
+ internalFieldStore.isEdited.value = true;
202
+ if (internalFieldStore.kind === "array") {
203
+ const arrayInput = input ?? [];
204
+ const items = internalFieldStore.items.value;
205
+ const length = internalFieldStore.schema.type === "array" ? arrayInput.length : internalFieldStore.children.length;
206
+ if (length < items.length) internalFieldStore.items.value = items.slice(0, length);
207
+ else if (length > items.length) {
208
+ for (let index = items.length; index < length; index++) if (internalFieldStore.children[index]) resetItemState(internalFormStore, internalFieldStore.children[index], arrayInput[index], true);
209
+ else {
210
+ internalFieldStore.children[index] = {};
211
+ initializeFieldStore(internalFormStore, internalFieldStore.children[index], internalFieldStore.schema.item, arrayInput[index], [...internalFieldStore.path, index]);
212
+ }
213
+ internalFieldStore.items.value = [...items, ...Array.from({ length: length - items.length }, createUniqueId)];
214
+ }
215
+ for (let index = 0; index < length; index++) setNestedInput(internalFormStore, internalFieldStore.children[index], arrayInput[index]);
216
+ internalFieldStore.input.value = input == null ? input : true;
217
+ internalFieldStore.isDirty.value = internalFieldStore.startInput.value !== internalFieldStore.input.value || internalFieldStore.startItems.value.length !== internalFieldStore.items.value.length;
218
+ } else if (internalFieldStore.kind === "object") {
219
+ for (const key in internalFieldStore.children) setNestedInput(internalFormStore, internalFieldStore.children[key], input?.[key]);
220
+ internalFieldStore.input.value = input == null ? input : true;
221
+ internalFieldStore.isDirty.value = internalFieldStore.startInput.value !== internalFieldStore.input.value;
222
+ } else {
223
+ internalFieldStore.input.value = input;
224
+ const startInput = internalFieldStore.startInput.value;
225
+ internalFieldStore.isDirty.value = startInput !== input && (startInput != null || input !== "" && !Number.isNaN(input));
226
+ }
227
+ }
228
+ function setFieldInput(internalFormStore, path, input) {
229
+ batch(() => {
230
+ untrack(() => {
231
+ let internalFieldStore = internalFormStore;
232
+ for (let index = 0; index < path.length; index++) {
233
+ internalFieldStore = internalFieldStore.children[path[index]];
234
+ if (index < path.length - 1) {
235
+ internalFieldStore.input.value = true;
236
+ internalFieldStore.isDirty.value = internalFieldStore.startInput.value !== internalFieldStore.input.value || internalFieldStore.kind === "array" && internalFieldStore.startItems.value.join() !== internalFieldStore.items.value.join();
237
+ }
238
+ }
239
+ setNestedInput(internalFormStore, internalFieldStore, input);
240
+ });
241
+ });
242
+ }
243
+ var DEFAULT_EMPTY_INPUT = { string: "" };
244
+ // @__NO_SIDE_EFFECTS__
245
+ function createFormStore(config, parse) {
246
+ const store = {};
247
+ store.emptyInput = {
248
+ ...DEFAULT_EMPTY_INPUT,
249
+ ...config.emptyInput
250
+ };
251
+ store.validationId = 0;
252
+ store.validate = config.validate ?? "submit";
253
+ store.revalidate = config.revalidate ?? "input";
254
+ store.parse = parse;
255
+ store.isSubmitting = /* @__PURE__ */ createSignal$1(false);
256
+ store.isSubmitted = /* @__PURE__ */ createSignal$1(false);
257
+ store.isValidating = /* @__PURE__ */ createSignal$1(false);
258
+ initializeFieldStore(store, store, config.schema, config.initialInput, []);
259
+ return store;
260
+ }
261
+ async function validateFormInput(internalFormStore, config) {
262
+ const validationId = ++internalFormStore.validationId;
263
+ internalFormStore.isValidating.value = true;
264
+ try {
265
+ const result = await internalFormStore.parse(untrack(() => /* @__PURE__ */ getFieldInput(internalFormStore)));
266
+ if (internalFormStore.validationId !== validationId) return result;
267
+ let rootErrors;
268
+ let nestedErrors;
269
+ if (result.issues) {
270
+ nestedErrors = {};
271
+ for (const issue of result.issues) if (issue.path) {
272
+ const path = [];
273
+ for (const pathItem of issue.path) {
274
+ const key = pathItem.key;
275
+ const keyType = typeof key;
276
+ const itemType = pathItem.type;
277
+ if (keyType !== "string" && keyType !== "number" || itemType === "map" || itemType === "set") break;
278
+ path.push(key);
279
+ }
280
+ const name = JSON.stringify(path);
281
+ const fieldErrors = nestedErrors[name];
282
+ if (fieldErrors) fieldErrors.push(issue.message);
283
+ else nestedErrors[name] = [issue.message];
284
+ } else if (rootErrors) rootErrors.push(issue.message);
285
+ else rootErrors = [issue.message];
286
+ }
287
+ let shouldFocus = config?.shouldFocus ?? false;
288
+ batch(() => {
289
+ untrack(() => {
290
+ walkFieldStore(internalFormStore, (internalFieldStore) => {
291
+ if (internalFieldStore.path.length === 0) internalFieldStore.errors.value = rootErrors ?? null;
292
+ else {
293
+ const fieldErrors = nestedErrors?.[internalFieldStore.name] ?? null;
294
+ internalFieldStore.errors.value = fieldErrors;
295
+ if (shouldFocus && fieldErrors && focusFieldElement(internalFieldStore)) shouldFocus = false;
296
+ }
297
+ });
298
+ });
299
+ if (internalFormStore.validationId === validationId) internalFormStore.isValidating.value = false;
300
+ });
301
+ return result;
302
+ } catch (error) {
303
+ if (internalFormStore.validationId === validationId) internalFormStore.isValidating.value = false;
304
+ throw error;
305
+ }
306
+ }
307
+ function validateIfRequired(internalFormStore, internalFieldStore, validationMode) {
308
+ if (validationMode === (internalFormStore.validate === "initial" || (internalFormStore.validate === "submit" ? untrack(() => internalFormStore.isSubmitted.value) : untrack(() => /* @__PURE__ */ getFieldBool(internalFieldStore, "errors"))) ? internalFormStore.revalidate : internalFormStore.validate)) validateFormInput(internalFormStore);
309
+ }
310
+ var INTERNAL = "~internal";
311
+ // @__NO_SIDE_EFFECTS__
312
+ function createForm(config) {
313
+ const internalFormStore = /* @__PURE__ */ createFormStore(config, (input) => safeParseAsync(config.schema, input));
314
+ const getIsTouched = createMemo(() => /* @__PURE__ */ getFieldBool(internalFormStore, "isTouched"));
315
+ const getIsEdited = createMemo(() => /* @__PURE__ */ getFieldBool(internalFormStore, "isEdited"));
316
+ const getIsDirty = createMemo(() => /* @__PURE__ */ getFieldBool(internalFormStore, "isDirty"));
317
+ const getIsValid = createMemo(() => !/* @__PURE__ */ getFieldBool(internalFormStore, "errors"));
318
+ const form = {
319
+ [INTERNAL]: internalFormStore,
320
+ get isSubmitting() {
321
+ return internalFormStore.isSubmitting.value;
322
+ },
323
+ get isSubmitted() {
324
+ return internalFormStore.isSubmitted.value;
325
+ },
326
+ get isValidating() {
327
+ return internalFormStore.isValidating.value;
328
+ },
329
+ get isTouched() {
330
+ return getIsTouched();
331
+ },
332
+ get isEdited() {
333
+ return getIsEdited();
334
+ },
335
+ get isDirty() {
336
+ return getIsDirty();
337
+ },
338
+ get isValid() {
339
+ return getIsValid();
340
+ },
341
+ get errors() {
342
+ return internalFormStore.errors.value;
343
+ }
344
+ };
345
+ if (config.validate === "initial") validateFormInput(form[INTERNAL]);
346
+ return form;
347
+ }
348
+ function unwrap(value) {
349
+ if (typeof value === "function") return value();
350
+ return value;
351
+ }
352
+ // @__NO_SIDE_EFFECTS__
353
+ function useField(form, config) {
354
+ const getPath = createMemo(() => unwrap(config).path);
355
+ const getInternalFormStore = createMemo(() => unwrap(form)[INTERNAL]);
356
+ const getInternalFieldStore = createMemo(() => /* @__PURE__ */ getFieldStore(getInternalFormStore(), getPath()));
357
+ const getInput2 = createMemo(() => /* @__PURE__ */ getFieldInput(getInternalFieldStore()));
358
+ const getIsTouched = createMemo(() => /* @__PURE__ */ getFieldBool(getInternalFieldStore(), "isTouched"));
359
+ const getIsEdited = createMemo(() => /* @__PURE__ */ getFieldBool(getInternalFieldStore(), "isEdited"));
360
+ const getIsDirty = createMemo(() => /* @__PURE__ */ getFieldBool(getInternalFieldStore(), "isDirty"));
361
+ const getIsValid = createMemo(() => !/* @__PURE__ */ getFieldBool(getInternalFieldStore(), "errors"));
362
+ return {
363
+ get path() {
364
+ return getPath();
365
+ },
366
+ get input() {
367
+ return getInput2();
368
+ },
369
+ get errors() {
370
+ return getInternalFieldStore().errors.value;
371
+ },
372
+ get isTouched() {
373
+ return getIsTouched();
374
+ },
375
+ get isEdited() {
376
+ return getIsEdited();
377
+ },
378
+ get isDirty() {
379
+ return getIsDirty();
380
+ },
381
+ get isValid() {
382
+ return getIsValid();
383
+ },
384
+ onInput(value) {
385
+ setFieldInput(getInternalFormStore(), getPath(), value);
386
+ validateIfRequired(getInternalFormStore(), getInternalFieldStore(), "input");
387
+ },
388
+ props: {
389
+ get name() {
390
+ return getInternalFieldStore().name;
391
+ },
392
+ autofocus: !!getInternalFieldStore().errors.value,
393
+ ref: (element) => {
394
+ const internalFieldStore = getInternalFieldStore();
395
+ if (!internalFieldStore.elements.includes(element)) internalFieldStore.elements.push(element);
396
+ onCleanup(() => {
397
+ const elements = internalFieldStore.elements.filter((el) => el !== element);
398
+ if (internalFieldStore.elements === internalFieldStore.initialElements) internalFieldStore.initialElements = elements;
399
+ else internalFieldStore.initialElements = internalFieldStore.initialElements.filter((el) => el !== element);
400
+ internalFieldStore.elements = elements;
401
+ });
402
+ },
403
+ onFocus() {
404
+ setFieldBool(getInternalFieldStore(), "isTouched", true);
405
+ validateIfRequired(getInternalFormStore(), getInternalFieldStore(), "touch");
406
+ },
407
+ onInput(event) {
408
+ const internalFieldStore = getInternalFieldStore();
409
+ setFieldInput(getInternalFormStore(), getPath(), /* @__PURE__ */ getElementInput(event.currentTarget, internalFieldStore));
410
+ validateIfRequired(getInternalFormStore(), internalFieldStore, "input");
411
+ },
412
+ onChange() {
413
+ validateIfRequired(getInternalFormStore(), getInternalFieldStore(), "change");
414
+ },
415
+ onBlur() {
416
+ validateIfRequired(getInternalFormStore(), getInternalFieldStore(), "blur");
417
+ }
418
+ }
419
+ };
420
+ }
421
+ // @__NO_SIDE_EFFECTS__
422
+ function Field(props) {
423
+ const field = /* @__PURE__ */ useField(() => props.of, () => ({ path: props.path }));
424
+ return props.children(field);
425
+ }
426
+ // @__NO_SIDE_EFFECTS__
427
+ function Form(props) {
428
+ const [, other] = splitProps(props, ["of", "onSubmit"]);
429
+ return ssrElement("form", mergeProps(other, { novalidate: true }), void 0, true);
430
+ }
431
+ //#endregion
432
+ export { Form as n, createForm as r, Field as t };