@lehnihon/bit-form 2.2.18 → 2.2.19

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 (136) hide show
  1. package/dist/angular/index.cjs +1 -1
  2. package/dist/angular/index.js +1 -1
  3. package/dist/angular/index.js.map +1 -1
  4. package/dist/chunk-23DHXQOC.js +2 -0
  5. package/dist/chunk-23DHXQOC.js.map +1 -0
  6. package/dist/{chunk-DD6XWUMR.cjs → chunk-27LJCW56.cjs} +2 -2
  7. package/dist/chunk-27LJCW56.cjs.map +1 -0
  8. package/dist/chunk-32RH5MSM.js +2 -0
  9. package/dist/chunk-32RH5MSM.js.map +1 -0
  10. package/dist/{chunk-P5YQ62YN.cjs → chunk-33TGLA5D.cjs} +2 -2
  11. package/dist/{chunk-P5YQ62YN.cjs.map → chunk-33TGLA5D.cjs.map} +1 -1
  12. package/dist/chunk-3CPIJF3Z.cjs +2 -0
  13. package/dist/chunk-3CPIJF3Z.cjs.map +1 -0
  14. package/dist/{chunk-SYEUXL2E.js → chunk-3WNZPBME.js} +2 -2
  15. package/dist/chunk-4WPLTOBT.cjs +2 -0
  16. package/dist/chunk-4WPLTOBT.cjs.map +1 -0
  17. package/dist/chunk-5ILGCBKG.cjs +2 -0
  18. package/dist/chunk-5ILGCBKG.cjs.map +1 -0
  19. package/dist/chunk-725CMNAV.cjs +2 -0
  20. package/dist/chunk-725CMNAV.cjs.map +1 -0
  21. package/dist/{chunk-GKNGJOB3.cjs → chunk-7IO2KLSJ.cjs} +2 -2
  22. package/dist/{chunk-GKNGJOB3.cjs.map → chunk-7IO2KLSJ.cjs.map} +1 -1
  23. package/dist/{chunk-HE6EQZTH.js → chunk-AJUX7LYB.js} +2 -2
  24. package/dist/chunk-B45EMB4Q.js +2 -0
  25. package/dist/chunk-B45EMB4Q.js.map +1 -0
  26. package/dist/chunk-CIS3YZSK.cjs +2 -0
  27. package/dist/chunk-CIS3YZSK.cjs.map +1 -0
  28. package/dist/chunk-DGEGYNQL.js +2 -0
  29. package/dist/{chunk-3NUJVIAM.js.map → chunk-DGEGYNQL.js.map} +1 -1
  30. package/dist/{chunk-AVUK52JW.cjs → chunk-EPBSLPRL.cjs} +2 -2
  31. package/dist/{chunk-AVUK52JW.cjs.map → chunk-EPBSLPRL.cjs.map} +1 -1
  32. package/dist/chunk-HTMNDK6W.js +2 -0
  33. package/dist/chunk-HTMNDK6W.js.map +1 -0
  34. package/dist/chunk-JUDBIEZK.js +2 -0
  35. package/dist/chunk-JUDBIEZK.js.map +1 -0
  36. package/dist/{chunk-77PK7U73.cjs → chunk-K2JSAJAF.cjs} +2 -2
  37. package/dist/chunk-K2JSAJAF.cjs.map +1 -0
  38. package/dist/chunk-K2KCQEER.js +2 -0
  39. package/dist/chunk-K2KCQEER.js.map +1 -0
  40. package/dist/chunk-K65TKDQ2.cjs +2 -0
  41. package/dist/chunk-K65TKDQ2.cjs.map +1 -0
  42. package/dist/chunk-S5A65JVL.cjs +2 -0
  43. package/dist/chunk-S5A65JVL.cjs.map +1 -0
  44. package/dist/chunk-SFVGMVIE.js +2 -0
  45. package/dist/chunk-SFVGMVIE.js.map +1 -0
  46. package/dist/chunk-T7TOEIOH.js +2 -0
  47. package/dist/chunk-T7TOEIOH.js.map +1 -0
  48. package/dist/chunk-TLUCO2ZN.cjs +2 -0
  49. package/dist/chunk-TLUCO2ZN.cjs.map +1 -0
  50. package/dist/chunk-WEZ5Q6YO.js +2 -0
  51. package/dist/chunk-WEZ5Q6YO.js.map +1 -0
  52. package/dist/{chunk-YO4TZ6N6.js → chunk-Y34N5TWV.js} +2 -2
  53. package/dist/cli/index.cjs +5 -5
  54. package/dist/core/bindings.cjs +1 -1
  55. package/dist/core/bindings.js +1 -1
  56. package/dist/core/store.cjs +1 -1
  57. package/dist/core/store.js +1 -1
  58. package/dist/core/utils.cjs +1 -1
  59. package/dist/core/utils.js +1 -1
  60. package/dist/core.cjs +1 -1
  61. package/dist/core.js +1 -1
  62. package/dist/devtools/bridge.cjs +1 -1
  63. package/dist/devtools/bridge.js +1 -1
  64. package/dist/devtools/index.cjs +10 -10
  65. package/dist/devtools/index.cjs.map +1 -1
  66. package/dist/devtools/index.js +10 -10
  67. package/dist/devtools/index.js.map +1 -1
  68. package/dist/index.cjs +1 -1
  69. package/dist/index.js +1 -1
  70. package/dist/mask.cjs +1 -1
  71. package/dist/mask.js +1 -1
  72. package/dist/react/index.cjs +1 -1
  73. package/dist/react/index.cjs.map +1 -1
  74. package/dist/react/index.js +1 -1
  75. package/dist/react/index.js.map +1 -1
  76. package/dist/react-native/index.cjs +1 -1
  77. package/dist/react-native/index.cjs.map +1 -1
  78. package/dist/react-native/index.js +1 -1
  79. package/dist/react-native/index.js.map +1 -1
  80. package/dist/resolvers/index.cjs +1 -1
  81. package/dist/resolvers/index.js +1 -1
  82. package/dist/resolvers/joi.cjs +1 -1
  83. package/dist/resolvers/joi.js +1 -1
  84. package/dist/resolvers/yup.cjs +1 -1
  85. package/dist/resolvers/yup.js +1 -1
  86. package/dist/resolvers/zod.cjs +1 -1
  87. package/dist/resolvers/zod.js +1 -1
  88. package/dist/utils.cjs +1 -1
  89. package/dist/utils.js +1 -1
  90. package/dist/vue/index.cjs +1 -1
  91. package/dist/vue/index.cjs.map +1 -1
  92. package/dist/vue/index.d.cts +18 -17
  93. package/dist/vue/index.d.ts +18 -17
  94. package/dist/vue/index.js +1 -1
  95. package/dist/vue/index.js.map +1 -1
  96. package/package.json +7 -6
  97. package/dist/chunk-3774TIGK.js +0 -2
  98. package/dist/chunk-3774TIGK.js.map +0 -1
  99. package/dist/chunk-3NUJVIAM.js +0 -2
  100. package/dist/chunk-77PK7U73.cjs.map +0 -1
  101. package/dist/chunk-CTURHI75.cjs +0 -2
  102. package/dist/chunk-CTURHI75.cjs.map +0 -1
  103. package/dist/chunk-DD6XWUMR.cjs.map +0 -1
  104. package/dist/chunk-FGJB4DHQ.js +0 -2
  105. package/dist/chunk-FGJB4DHQ.js.map +0 -1
  106. package/dist/chunk-FTXV2NZO.cjs +0 -2
  107. package/dist/chunk-FTXV2NZO.cjs.map +0 -1
  108. package/dist/chunk-G3EHXKOS.js +0 -2
  109. package/dist/chunk-G3EHXKOS.js.map +0 -1
  110. package/dist/chunk-GDRNKTHO.js +0 -2
  111. package/dist/chunk-GDRNKTHO.js.map +0 -1
  112. package/dist/chunk-GSZTHF7Z.js +0 -2
  113. package/dist/chunk-GSZTHF7Z.js.map +0 -1
  114. package/dist/chunk-GUU6EXFN.js +0 -2
  115. package/dist/chunk-GUU6EXFN.js.map +0 -1
  116. package/dist/chunk-L7EAZ6K6.cjs +0 -2
  117. package/dist/chunk-L7EAZ6K6.cjs.map +0 -1
  118. package/dist/chunk-LIHWJJIM.js +0 -2
  119. package/dist/chunk-LIHWJJIM.js.map +0 -1
  120. package/dist/chunk-M2XR4C7T.js +0 -2
  121. package/dist/chunk-M2XR4C7T.js.map +0 -1
  122. package/dist/chunk-PFPGASVZ.cjs +0 -2
  123. package/dist/chunk-PFPGASVZ.cjs.map +0 -1
  124. package/dist/chunk-QCKCONCU.js +0 -2
  125. package/dist/chunk-QCKCONCU.js.map +0 -1
  126. package/dist/chunk-RSH6LQVC.cjs +0 -2
  127. package/dist/chunk-RSH6LQVC.cjs.map +0 -1
  128. package/dist/chunk-U5TBWV74.cjs +0 -2
  129. package/dist/chunk-U5TBWV74.cjs.map +0 -1
  130. package/dist/chunk-UT63HKR6.cjs +0 -2
  131. package/dist/chunk-UT63HKR6.cjs.map +0 -1
  132. package/dist/chunk-WRNR6SXK.cjs +0 -2
  133. package/dist/chunk-WRNR6SXK.cjs.map +0 -1
  134. /package/dist/{chunk-SYEUXL2E.js.map → chunk-3WNZPBME.js.map} +0 -0
  135. /package/dist/{chunk-HE6EQZTH.js.map → chunk-AJUX7LYB.js.map} +0 -0
  136. /package/dist/{chunk-YO4TZ6N6.js.map → chunk-Y34N5TWV.js.map} +0 -0
@@ -1,2 +0,0 @@
1
- function l(e,n=new WeakMap){if(e===null||typeof e!="object")return e;if(typeof structuredClone=="function")try{return structuredClone(e)}catch{}if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(n.has(e))return n.get(e);if(e instanceof Map){let t=new Map;return n.set(e,t),e.forEach((o,r)=>{t.set(l(r,n),l(o,n))}),t}if(e instanceof Set){let t=new Set;return n.set(e,t),e.forEach(o=>{t.add(l(o,n))}),t}if(Array.isArray(e)){let t=[];n.set(e,t);for(let o of e)t.push(l(o,n));return t}let s=Object.getPrototypeOf(e);if(!(s===Object.prototype||s===null)){let t=Object.create(s);n.set(e,t);for(let o of Reflect.ownKeys(e)){let r=Object.getOwnPropertyDescriptor(e,o);r&&("value"in r&&(r.value=l(r.value,n)),Object.defineProperty(t,o,r))}return t}let c={};n.set(e,c);for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&(c[t]=l(e[t],n));return c}function k(e){return l(e)}function R(e,n,s=new WeakMap){if(n===void 0)return k(e);if(n===null||typeof n!="object"||n instanceof Date||n instanceof RegExp||Array.isArray(n))return k(n);let a=n;if(s.has(a))return s.get(a);let c=e&&typeof e=="object"&&!Array.isArray(e)?k(e):{};s.set(a,c);try{for(let t of Object.keys(n)){let o=n[t],r=c[t];if(o!==null&&typeof o=="object"&&!Array.isArray(o)&&!(o instanceof Date)&&!(o instanceof RegExp)){c[t]=R(r,o,s);continue}c[t]=k(o)}}finally{s.delete(a)}return c}function m(e,n){return e===n?!0:e===null||typeof e!="object"||n===null||typeof n!="object"?!1:b(e,n)}function b(e,n){return T(e,n,new WeakMap)}function T(e,n,s){if(e===n)return!0;if(e===null||typeof e!="object"||n===null||typeof n!="object")return!1;let a=s.get(e);if(a?.has(n))return!0;if(a?a.add(n):s.set(e,new WeakSet([n])),Array.isArray(e)!==Array.isArray(n))return!1;if(e instanceof Date&&n instanceof Date)return e.getTime()===n.getTime();if(e instanceof RegExp&&n instanceof RegExp)return e.toString()===n.toString();let c=Object.keys(e),t=Object.keys(n);if(c.length!==t.length)return!1;for(let o of c)if(!Object.prototype.hasOwnProperty.call(n,o)||!T(e[o],n[o],s))return!1;return!0}function O(e,n,s="",a=new Set,c=new Map){if(m(e,n))return a;if(e===null||typeof e!="object"||n===null||typeof n!="object")return s&&a.add(s),a;let t=c.get(e);if(t?.has(n))return a;t?t.add(n):c.set(e,new Set([n]));try{if(Array.isArray(e)||Array.isArray(n))return!m(e,n)&&s&&a.add(s),a;let o=new Set;for(let r of Object.keys(e||{}))o.add(r);for(let r of Object.keys(n||{}))o.add(r);for(let r of o){let i=s?`${s}.${r}`:r;O(e?.[r],n?.[r],i,a,c)}return a}finally{let o=c.get(e);o?.delete(n),o&&o.size===0&&c.delete(e)}}var d=new Map,E=new Set(["__proto__"]);function S(e,n){if(d.has(e))d.delete(e);else if(d.size>=5e3){let s=d.keys().next().value;s!==void 0&&d.delete(s)}d.set(e,n)}function p(e){let n=d.get(e);if(n)return n;let s=e.split(".");return S(e,s),s}function A(e){for(let n=0;n<e.length;n++){let s=e[n];if(E.has(s)||s==="constructor"&&e[n+1]==="prototype")return!0}return!1}function K(e,n){if(!n)return e;let s=p(n);if(A(s))return;let a=e;for(let c of s){if(a==null)return;a=a[c]}return a}function D(e,n,s){if(!n)return s;let a=p(n);if(A(a))return e;let c=Array.isArray(e)?[...e]:{...e},t=c;for(let o=0;o<a.length-1;o++){let r=a[o],i=a[o+1],f=Number(i),y=Number.isInteger(f)&&String(f)===i,u=t[r];u==null?t[r]=y?[]:{}:t[r]=Array.isArray(u)?[...u]:{...u},t=t[r]}return t[a[a.length-1]]=s,c}function N(e,n){if(n.length===0)return e;let s=n.filter(([t])=>{let o=p(t);return!A(o)});if(s.length===0)return e;let a=Array.isArray(e)?[...e]:{...e},c=new WeakSet;a&&typeof a=="object"&&c.add(a);for(let[t,o]of s){let r=p(t),i=a;for(let f=0;f<r.length-1;f++){let y=r[f],u=r[f+1],w=Number(u),x=Number.isInteger(w)&&String(w)===u,g=i[y];g==null?(i[y]=x?[]:{},c.add(i[y])):typeof g=="object"?c.has(g)||(i[y]=Array.isArray(g)?[...g]:{...g},c.add(i[y])):(i[y]=x?[]:{},c.add(i[y])),i=i[y]}i[r[r.length-1]]=o}return a}function P(e,n){if(n.length===0)return e;let s=n.filter(t=>{if(!t)return!0;let o=p(t);return!A(o)});if(s.length===0)return e;let a=Array.isArray(e)?[...e]:{...e},c=new WeakSet;a&&typeof a=="object"&&c.add(a);for(let t of s){if(!t)return Array.isArray(e)?[]:{};let o=p(t),r=a;for(let f=0;f<o.length-1;f++){let y=o[f],u=r?.[y];if(u==null){r=void 0;break}if(typeof u=="object")c.has(u)||(r[y]=Array.isArray(u)?[...u]:{...u},c.add(r[y]));else{r=void 0;break}r=r[y]}if(!r)continue;let i=o[o.length-1];if(Array.isArray(r)){let f=Number(i);Number.isInteger(f)&&f>=0&&r.splice(f,1)}else r&&typeof r=="object"&&delete r[i]}return a}function $(e,n){let s={},a=`${n}.`;for(let c in e)c!==n&&!c.startsWith(a)&&(s[c]=e[c]);return s}function j(e,n,s){let a={},c={},t={},o=`${n}.`;for(let r of Object.keys(e.errors)){let i=h(r,o,s);i&&(a[i]=e.errors[r])}for(let r of Object.keys(e.touched)){let i=h(r,o,s);i&&(c[i]=e.touched[r])}for(let r of Object.keys(e.isValidating)){let i=h(r,o,s);i&&(t[i]=e.isValidating[r])}return{errors:a,touched:c,isValidating:t}}function h(e,n,s){if(!e.startsWith(n))return e;let c=e.substring(n.length).split("."),t=Number(c[0]);if(!Number.isInteger(t)||t<0)return e;let o=s(t);if(o===null)return null;let r=c.slice(1).join(".");return r?`${n}${o}.${r}`:`${n}${o}`}function V(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let n=e.errors??e;if(typeof n!="object"||n===null||Array.isArray(n))return!1;let s=Object.entries(n);return s.length===0?!1:s.every(([a,c])=>a.length>0&&(typeof c=="string"||Array.isArray(c)&&c.every(t=>typeof t=="string")))}function M(e){return V(e)?e.errors??e:{}}export{k as a,R as b,m as c,b as d,O as e,K as f,D as g,N as h,P as i,$ as j,j as k,h as l,V as m,M as n};
2
- //# sourceMappingURL=chunk-G3EHXKOS.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/utils/clone.ts","../src/core/utils/structural.ts","../src/core/utils/path-value.ts","../src/core/utils/array-meta.ts","../src/core/utils/server-errors.ts"],"sourcesContent":["export function cloneValue<T>(\n obj: T,\n visited: WeakMap<object, unknown> = new WeakMap(),\n): T {\n if (obj === null || typeof obj !== \"object\") {\n return obj;\n }\n\n if (typeof structuredClone === \"function\") {\n try {\n return structuredClone(obj);\n } catch {\n // Alguns runtimes lançam para payloads não suportados (ex.: funções).\n // Nesses casos, seguimos para o clone recursivo para manter fail-open.\n }\n }\n\n if (obj instanceof Date) {\n return new Date(obj.getTime()) as any as T;\n }\n\n if (obj instanceof RegExp) {\n return new RegExp(obj.source, obj.flags) as any as T;\n }\n\n if (visited.has(obj as object)) {\n return visited.get(obj as object) as T;\n }\n\n if (obj instanceof Map) {\n const clone = new Map<unknown, unknown>();\n visited.set(obj as object, clone);\n\n obj.forEach((value, key) => {\n clone.set(cloneValue(key, visited), cloneValue(value, visited));\n });\n\n return clone as T;\n }\n\n if (obj instanceof Set) {\n const clone = new Set<unknown>();\n visited.set(obj as object, clone);\n\n obj.forEach((value) => {\n clone.add(cloneValue(value, visited));\n });\n\n return clone as T;\n }\n\n if (Array.isArray(obj)) {\n const clone: unknown[] = [];\n visited.set(obj as object, clone);\n\n for (const item of obj) {\n clone.push(cloneValue(item, visited));\n }\n\n return clone as T;\n }\n\n const prototype = Object.getPrototypeOf(obj);\n const isPlainObject = prototype === Object.prototype || prototype === null;\n\n if (!isPlainObject) {\n const clone = Object.create(prototype) as Record<PropertyKey, unknown>;\n visited.set(obj as object, clone);\n\n for (const key of Reflect.ownKeys(obj as object)) {\n const descriptor = Object.getOwnPropertyDescriptor(obj as object, key);\n if (!descriptor) {\n continue;\n }\n\n if (\"value\" in descriptor) {\n descriptor.value = cloneValue(descriptor.value, visited);\n }\n\n Object.defineProperty(clone, key, descriptor);\n }\n\n return clone as T;\n }\n\n const clone: any = {};\n visited.set(obj as object, clone);\n\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n clone[key] = cloneValue((obj as any)[key], visited);\n }\n }\n\n return clone as T;\n}\n","import { cloneValue } from \"./clone\";\n\nexport function deepClone<T>(obj: T): T {\n return cloneValue(obj);\n}\n\nexport function deepMerge<T>(\n target: T,\n source: any,\n activeMerges: WeakMap<object, unknown> = new WeakMap(),\n): T {\n if (source === undefined) {\n return deepClone(target);\n }\n\n if (\n source === null ||\n typeof source !== \"object\" ||\n source instanceof Date ||\n source instanceof RegExp ||\n Array.isArray(source)\n ) {\n return deepClone(source as T);\n }\n\n const sourceObject = source as object;\n if (activeMerges.has(sourceObject)) {\n return activeMerges.get(sourceObject) as T;\n }\n\n const base =\n target && typeof target === \"object\" && !Array.isArray(target)\n ? deepClone(target as any)\n : ({} as Record<string, unknown>);\n\n activeMerges.set(sourceObject, base);\n\n try {\n for (const key of Object.keys(source)) {\n const sourceValue = source[key];\n const baseValue = (base as Record<string, unknown>)[key];\n\n if (\n sourceValue !== null &&\n typeof sourceValue === \"object\" &&\n !Array.isArray(sourceValue) &&\n !(sourceValue instanceof Date) &&\n !(sourceValue instanceof RegExp)\n ) {\n (base as Record<string, unknown>)[key] = deepMerge(\n baseValue,\n sourceValue,\n activeMerges,\n );\n continue;\n }\n\n (base as Record<string, unknown>)[key] = deepClone(sourceValue);\n }\n } finally {\n activeMerges.delete(sourceObject);\n }\n\n return base as T;\n}\n\nexport function valueEqual(a: any, b: any): boolean {\n if (a === b) return true;\n if (\n a === null ||\n typeof a !== \"object\" ||\n b === null ||\n typeof b !== \"object\"\n ) {\n return false;\n }\n return deepEqual(a, b);\n}\n\nexport function deepEqual(a: any, b: any): boolean {\n return deepEqualInner(a, b, new WeakMap());\n}\n\nfunction deepEqualInner(\n a: any,\n b: any,\n visitedPairs: WeakMap<object, WeakSet<object>>,\n): boolean {\n if (a === b) return true;\n if (\n a === null ||\n typeof a !== \"object\" ||\n b === null ||\n typeof b !== \"object\"\n ) {\n return false;\n }\n\n const visitedTargets = visitedPairs.get(a);\n if (visitedTargets?.has(b)) return true;\n\n if (visitedTargets) {\n visitedTargets.add(b);\n } else {\n visitedPairs.set(a, new WeakSet([b]));\n }\n\n if (Array.isArray(a) !== Array.isArray(b)) return false;\n\n if (a instanceof Date && b instanceof Date)\n return a.getTime() === b.getTime();\n if (a instanceof RegExp && b instanceof RegExp)\n return a.toString() === b.toString();\n\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n\n if (keysA.length !== keysB.length) return false;\n\n for (const key of keysA) {\n if (\n !Object.prototype.hasOwnProperty.call(b, key) ||\n !deepEqualInner(a[key], b[key], visitedPairs)\n ) {\n return false;\n }\n }\n\n return true;\n}\n\nexport function collectDirtyPaths(\n obj: any,\n initial: any,\n prefix = \"\",\n result: Set<string> = new Set(),\n activePairs: Map<object, Set<object>> = new Map(),\n): Set<string> {\n if (valueEqual(obj, initial)) return result;\n if (\n obj === null ||\n typeof obj !== \"object\" ||\n initial === null ||\n typeof initial !== \"object\"\n ) {\n if (prefix) result.add(prefix);\n return result;\n }\n\n const activeInitials = activePairs.get(obj as object);\n if (activeInitials?.has(initial as object)) {\n return result;\n }\n\n if (activeInitials) {\n activeInitials.add(initial as object);\n } else {\n activePairs.set(obj as object, new Set([initial as object]));\n }\n\n try {\n if (Array.isArray(obj) || Array.isArray(initial)) {\n if (!valueEqual(obj, initial) && prefix) result.add(prefix);\n return result;\n }\n const allKeys = new Set<string>();\n for (const key of Object.keys(obj || {})) {\n allKeys.add(key);\n }\n for (const key of Object.keys(initial || {})) {\n allKeys.add(key);\n }\n for (const k of allKeys) {\n const p = prefix ? `${prefix}.${k}` : k;\n collectDirtyPaths(\n (obj as any)?.[k],\n (initial as any)?.[k],\n p,\n result,\n activePairs,\n );\n }\n return result;\n } finally {\n const nextActiveInitials = activePairs.get(obj as object);\n nextActiveInitials?.delete(initial as object);\n\n if (nextActiveInitials && nextActiveInitials.size === 0) {\n activePairs.delete(obj as object);\n }\n }\n}\n","const PATH_CACHE_MAX = 5000;\nconst pathCache = new Map<string, string[]>();\nconst BLOCKED_PATH_SEGMENTS = new Set([\"__proto__\"]);\n\nfunction setPathCacheEntry(path: string, keys: string[]) {\n if (pathCache.has(path)) {\n pathCache.delete(path);\n } else if (pathCache.size >= PATH_CACHE_MAX) {\n const oldestKey = pathCache.keys().next().value;\n if (oldestKey !== undefined) {\n pathCache.delete(oldestKey);\n }\n }\n\n pathCache.set(path, keys);\n}\n\nfunction getPathKeys(path: string): string[] {\n const cached = pathCache.get(path);\n if (cached) {\n return cached;\n }\n\n const keys = path.split(\".\");\n setPathCacheEntry(path, keys);\n return keys;\n}\n\nfunction hasBlockedPathSegment(keys: readonly string[]): boolean {\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n\n if (BLOCKED_PATH_SEGMENTS.has(key)) {\n return true;\n }\n\n if (key === \"constructor\" && keys[i + 1] === \"prototype\") {\n return true;\n }\n }\n\n return false;\n}\n\nexport function getDeepValue(obj: any, path: string): any {\n if (!path) return obj;\n\n const keys = getPathKeys(path);\n if (hasBlockedPathSegment(keys)) return undefined;\n\n let current = obj;\n for (const key of keys) {\n if (current === null || current === undefined) return undefined;\n current = current[key];\n }\n return current;\n}\n\nexport function setDeepValue(obj: any, path: string, value: any): any {\n if (!path) return value;\n\n const keys = getPathKeys(path);\n if (hasBlockedPathSegment(keys)) return obj;\n\n const result = Array.isArray(obj) ? [...obj] : { ...obj };\n let current = result;\n\n for (let i = 0; i < keys.length - 1; i++) {\n const key = keys[i];\n const nextKey = keys[i + 1];\n\n const nextAsNumber = Number(nextKey);\n const isNextNumeric =\n Number.isInteger(nextAsNumber) && String(nextAsNumber) === nextKey;\n const currentValue = current[key];\n\n if (currentValue === null || currentValue === undefined) {\n current[key] = isNextNumeric ? [] : {};\n } else {\n current[key] = Array.isArray(currentValue)\n ? [...currentValue]\n : { ...currentValue };\n }\n\n current = current[key];\n }\n\n current[keys[keys.length - 1]] = value;\n\n return result;\n}\n\nexport function setDeepValues(\n obj: any,\n updates: ReadonlyArray<readonly [path: string, value: any]>,\n): any {\n if (updates.length === 0) {\n return obj;\n }\n\n const safeUpdates = updates.filter(([path]) => {\n const keys = getPathKeys(path);\n return !hasBlockedPathSegment(keys);\n });\n\n if (safeUpdates.length === 0) {\n return obj;\n }\n\n const root = Array.isArray(obj) ? [...obj] : { ...obj };\n const clonedNodes = new WeakSet<object>();\n if (root && typeof root === \"object\") {\n clonedNodes.add(root);\n }\n\n for (const [path, value] of safeUpdates) {\n const keys = getPathKeys(path);\n let current: any = root;\n\n for (let i = 0; i < keys.length - 1; i++) {\n const key = keys[i];\n const nextKey = keys[i + 1];\n\n const nextAsNumber = Number(nextKey);\n const isNextNumeric =\n Number.isInteger(nextAsNumber) && String(nextAsNumber) === nextKey;\n\n const currentValue = current[key];\n\n if (currentValue === null || currentValue === undefined) {\n current[key] = isNextNumeric ? [] : {};\n clonedNodes.add(current[key]);\n } else if (typeof currentValue === \"object\") {\n if (!clonedNodes.has(currentValue)) {\n current[key] = Array.isArray(currentValue)\n ? [...currentValue]\n : { ...currentValue };\n clonedNodes.add(current[key]);\n }\n } else {\n current[key] = isNextNumeric ? [] : {};\n clonedNodes.add(current[key]);\n }\n\n current = current[key];\n }\n\n current[keys[keys.length - 1]] = value;\n }\n\n return root;\n}\n\nexport function unsetDeepValue(obj: any, path: string): any {\n if (!path) {\n return Array.isArray(obj) ? [] : {};\n }\n\n const keys = getPathKeys(path);\n if (hasBlockedPathSegment(keys)) {\n return obj;\n }\n\n const root = Array.isArray(obj) ? [...obj] : { ...obj };\n let current: any = root;\n\n for (let i = 0; i < keys.length - 1; i++) {\n const key = keys[i];\n const currentValue = current?.[key];\n\n if (currentValue === null || currentValue === undefined) {\n return root;\n }\n\n current[key] = Array.isArray(currentValue)\n ? [...currentValue]\n : { ...currentValue };\n\n current = current[key];\n }\n\n const leafKey = keys[keys.length - 1];\n\n if (Array.isArray(current)) {\n const arrayIndex = Number(leafKey);\n // Only splice if leafKey is a valid array index (integer >= 0)\n if (Number.isInteger(arrayIndex) && arrayIndex >= 0) {\n current.splice(arrayIndex, 1);\n }\n } else if (current && typeof current === \"object\") {\n delete current[leafKey];\n }\n\n return root;\n}\n\nexport function unsetDeepValues(obj: any, paths: ReadonlyArray<string>): any {\n if (paths.length === 0) {\n return obj;\n }\n\n const safePaths = paths.filter((path) => {\n if (!path) return true;\n const keys = getPathKeys(path);\n return !hasBlockedPathSegment(keys);\n });\n\n if (safePaths.length === 0) {\n return obj;\n }\n\n const root = Array.isArray(obj) ? [...obj] : { ...obj };\n const clonedNodes = new WeakSet<object>();\n if (root && typeof root === \"object\") {\n clonedNodes.add(root);\n }\n\n for (const path of safePaths) {\n if (!path) {\n return Array.isArray(obj) ? [] : {};\n }\n\n const keys = getPathKeys(path);\n\n let current: any = root;\n\n for (let i = 0; i < keys.length - 1; i++) {\n const key = keys[i];\n const currentValue = current?.[key];\n\n if (currentValue === null || currentValue === undefined) {\n current = undefined;\n break;\n }\n\n if (typeof currentValue === \"object\") {\n if (!clonedNodes.has(currentValue)) {\n current[key] = Array.isArray(currentValue)\n ? [...currentValue]\n : { ...currentValue };\n clonedNodes.add(current[key]);\n }\n } else {\n current = undefined;\n break;\n }\n\n current = current[key];\n }\n\n if (!current) {\n continue;\n }\n\n const leafKey = keys[keys.length - 1];\n\n if (Array.isArray(current)) {\n const arrayIndex = Number(leafKey);\n // Only splice if leafKey is a valid array index (integer >= 0)\n if (Number.isInteger(arrayIndex) && arrayIndex >= 0) {\n current.splice(arrayIndex, 1);\n }\n } else if (current && typeof current === \"object\") {\n delete current[leafKey];\n }\n }\n\n return root;\n}\n","export function cleanPrefixedKeys(\n obj: Record<string, any>,\n prefix: string,\n): Record<string, any> {\n const newObj: Record<string, any> = {};\n const prefixWithDot = `${prefix}.`;\n\n for (const key in obj) {\n if (key !== prefix && !key.startsWith(prefixWithDot)) {\n newObj[key] = obj[key];\n }\n }\n return newObj;\n}\n\nexport const shiftKeys = (\n obj: Record<string, any>,\n path: string,\n removedIndex: number,\n) => {\n return reindexObjectKeys(obj, path, (currentIdx) => {\n if (currentIdx === removedIndex) {\n return null;\n }\n\n return currentIdx > removedIndex ? currentIdx - 1 : currentIdx;\n });\n};\n\nexport const swapKeys = (\n obj: Record<string, any>,\n path: string,\n indexA: number,\n indexB: number,\n) => {\n return reindexObjectKeys(obj, path, (currentIdx) => {\n if (currentIdx === indexA) {\n return indexB;\n }\n\n if (currentIdx === indexB) {\n return indexA;\n }\n\n return currentIdx;\n });\n};\n\nexport const moveKeys = (\n obj: Record<string, any>,\n path: string,\n from: number,\n to: number,\n) => {\n return reindexObjectKeys(obj, path, (currentIdx) => {\n if (currentIdx === from) {\n return to;\n }\n\n if (from < to && currentIdx > from && currentIdx <= to) {\n return currentIdx - 1;\n }\n\n if (from > to && currentIdx >= to && currentIdx < from) {\n return currentIdx + 1;\n }\n\n return currentIdx;\n });\n};\n\nexport function reindexFieldArrayMeta(\n state: {\n errors: Record<string, any>;\n touched: Record<string, any>;\n isValidating: Record<string, any>;\n },\n path: string,\n remapIndex: (index: number) => number | null,\n) {\n const nextErrors: Record<string, any> = {};\n const nextTouched: Record<string, any> = {};\n const nextIsValidating: Record<string, any> = {};\n\n const prefix = `${path}.`;\n\n for (const key of Object.keys(state.errors)) {\n const nextKey = remapIndexedPath(key, prefix, remapIndex);\n if (nextKey) nextErrors[nextKey] = state.errors[key];\n }\n\n for (const key of Object.keys(state.touched)) {\n const nextKey = remapIndexedPath(key, prefix, remapIndex);\n if (nextKey) nextTouched[nextKey] = state.touched[key];\n }\n\n for (const key of Object.keys(state.isValidating)) {\n const nextKey = remapIndexedPath(key, prefix, remapIndex);\n if (nextKey) nextIsValidating[nextKey] = state.isValidating[key];\n }\n\n return {\n errors: nextErrors,\n touched: nextTouched,\n isValidating: nextIsValidating,\n };\n}\n\nexport function remapIndexedPath(\n key: string,\n prefix: string,\n remapIndex: (index: number) => number | null,\n): string | null {\n if (!key.startsWith(prefix)) {\n return key;\n }\n\n const remaining = key.substring(prefix.length);\n const parts = remaining.split(\".\");\n const currentIdx = Number(parts[0]);\n if (!Number.isInteger(currentIdx) || currentIdx < 0) {\n return key;\n }\n const nextIdx = remapIndex(currentIdx);\n\n if (nextIdx === null) {\n return null;\n }\n\n const rest = parts.slice(1).join(\".\");\n return rest ? `${prefix}${nextIdx}.${rest}` : `${prefix}${nextIdx}`;\n}\n\nfunction reindexObjectKeys(\n obj: Record<string, any>,\n path: string,\n remapIndex: (index: number) => number | null,\n) {\n const nextObject: Record<string, any> = {};\n const prefix = `${path}.`;\n\n for (const key of Object.keys(obj)) {\n if (!key.startsWith(prefix)) {\n nextObject[key] = obj[key];\n continue;\n }\n\n const remaining = key.substring(prefix.length);\n const parts = remaining.split(\".\");\n const currentIdx = Number(parts[0]);\n if (!Number.isInteger(currentIdx) || currentIdx < 0) {\n nextObject[key] = obj[key];\n continue;\n }\n const nextIdx = remapIndex(currentIdx);\n\n if (nextIdx === null) {\n continue;\n }\n\n const rest = parts.slice(1).join(\".\");\n const nextKey = rest\n ? `${prefix}${nextIdx}.${rest}`\n : `${prefix}${nextIdx}`;\n nextObject[nextKey] = obj[key];\n }\n\n return nextObject;\n}\n","export function isValidationErrorShape(\n x: unknown,\n): x is Record<string, string | string[]> {\n if (typeof x !== \"object\" || x === null || Array.isArray(x)) return false;\n\n const obj = (x as Record<string, unknown>).errors ?? x;\n if (typeof obj !== \"object\" || obj === null || Array.isArray(obj)) {\n return false;\n }\n\n const entries = Object.entries(obj as Record<string, unknown>);\n if (entries.length === 0) {\n return false;\n }\n\n return entries.every(\n ([key, v]) =>\n key.length > 0 &&\n (typeof v === \"string\" ||\n (Array.isArray(v) && v.every((i) => typeof i === \"string\"))),\n );\n}\n\nexport function extractServerErrors(\n x: unknown,\n): Record<string, string | string[]> {\n if (!isValidationErrorShape(x)) return {};\n\n const obj = (x as Record<string, unkn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J,CAAU,EACpDM,IAASH,EAAiBG,CAAO,EAAIR,EAAM,aAAaO,CAAG,EACjE,CAEA,MAAO,CACL,OAAQJ,EACR,QAASC,EACT,aAAcC,CAChB,CACF,CAEO,SAASI,EACdF,EACAD,EACAJ,EACe,CACf,GAAI,CAACK,EAAI,WAAWD,CAAM,EACxB,OAAOC,EAIT,IAAMG,EADYH,EAAI,UAAUD,EAAO,MAAM,EACrB,MAAM,GAAG,EAC3BK,EAAa,OAAOD,EAAM,CAAC,CAAC,EAClC,GAAI,CAAC,OAAO,UAAUC,CAAU,GAAKA,EAAa,EAChD,OAAOJ,EAET,IAAMK,EAAUV,EAAWS,CAAU,EAErC,GAAIC,IAAY,KACd,OAAO,KAGT,IAAMC,EAAOH,EAAM,MAAM,CAAC,EAAE,KAAK,GAAG,EACpC,OAAOG,EAAO,GAAGP,CAAM,GAAGM,CAAO,IAAIC,CAAI,GAAK,GAAGP,CAAM,GAAGM,CAAO,EACnE,CCnIO,SAASE,EACdC,EACwC,CACxC,GAAI,OAAOA,GAAM,UAAYA,IAAM,MAAQ,MAAM,QAAQA,CAAC,EAAG,MAAO,GAEpE,IAAMC,EAAOD,EAA8B,QAAUA,EACrD,GAAI,OAAOC,GAAQ,UAAYA,IAAQ,MAAQ,MAAM,QAAQA,CAAG,EAC9D,MAAO,GAGT,IAAMC,EAAU,OAAO,QAAQD,CAA8B,EAC7D,OAAIC,EAAQ,SAAW,EACd,GAGFA,EAAQ,MACb,CAAC,CAACC,EAAKC,CAAC,IACND,EAAI,OAAS,IACZ,OAAOC,GAAM,UACX,MAAM,QAAQA,CAAC,GAAKA,EAAE,MAAOC,GAAM,OAAOA,GAAM,QAAQ,EAC/D,CACF,CAEO,SAASC,EACdN,EACmC,CACnC,OAAKD,EAAuBC,CAAC,EAEhBA,EAA8B,QAAUA,EAFd,CAAC,CAI1C","names":["cloneValue","obj","visited","clone","value","key","item","prototype","descriptor","deepClone","obj","cloneValue","deepMerge","target","source","activeMerges","sourceObject","base","key","sourceValue","baseValue","valueEqual","a","b","deepEqual","deepEqualInner","visitedPairs","visitedTargets","keysA","keysB","collectDirtyPaths","initial","prefix","result","activePairs","activeInitials","allKeys","k","p","nextActiveInitials","pathCache","BLOCKED_PATH_SEGMENTS","setPathCacheEntry","path","keys","oldestKey","getPathKeys","cached","hasBlockedPathSegment","i","key","getDeepValue","obj","current","setDeepValue","value","result","nextKey","nextAsNumber","isNextNumeric","currentValue","setDeepValues","updates","safeUpdates","root","clonedNodes","unsetDeepValues","obj","paths","safePaths","path","keys","getPathKeys","hasBlockedPathSegment","root","clonedNodes","current","i","key","currentValue","leafKey","arrayIndex","cleanPrefixedKeys","obj","prefix","newObj","prefixWithDot","key","reindexFieldArrayMeta","state","path","remapIndex","nextErrors","nextTouched","nextIsValidating","prefix","key","nextKey","remapIndexedPath","parts","currentIdx","nextIdx","rest","isValidationErrorShape","x","obj","entries","key","v","i","extractServerErrors"]}
@@ -1,2 +0,0 @@
1
- import{a as i,b as s,c as l}from"./chunk-GUU6EXFN.js";import{ValidationError as c}from"yup";var u=(a,n)=>async(p,e)=>{let t={};if(e?.scopeFields&&e.scopeFields.length>0)return await Promise.all(e.scopeFields.map(async o=>{try{await a.validateAt(o,p)}catch(r){r instanceof c&&r.path&&s(t,i(r.path),r.message)}})),t;try{return await a.validate(p,{abortEarly:n?.abortEarly??!1,stripUnknown:n?.stripUnknown??!1}),{}}catch(o){if(o instanceof c){for(let r of o.inner??[])r.path&&s(t,i(r.path),r.message);return l(t,e?.scopeFields)}return{}}};export{u as a};
2
- //# sourceMappingURL=chunk-GDRNKTHO.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/resolvers/yup.ts"],"sourcesContent":["import { ValidationError, Schema } from \"yup\";\nimport { BitErrors } from \"../core\";\nimport {\n filterErrorsByScope,\n normalizeErrorPath,\n setFirstError,\n} from \"./utils\";\nimport { BitResolverScopeOptions, BitYupResolverConfig } from \"./types\";\n\nexport const yupResolver = <T extends object>(\n schema: Schema<T>,\n config?: BitYupResolverConfig,\n) => {\n return async (\n values: T,\n options?: BitResolverScopeOptions,\n ): Promise<BitErrors<T>> => {\n const errors: BitErrors<T> = {};\n\n if (options?.scopeFields && options.scopeFields.length > 0) {\n await Promise.all(\n options.scopeFields.map(async (field) => {\n try {\n await schema.validateAt(field, values);\n } catch (error: unknown) {\n if (error instanceof ValidationError && error.path) {\n setFirstError(\n errors,\n normalizeErrorPath(error.path),\n error.message,\n );\n }\n }\n }),\n );\n return errors;\n }\n\n try {\n await schema.validate(values, {\n abortEarly: config?.abortEarly ?? false,\n stripUnknown: config?.stripUnknown ?? false,\n });\n return {};\n } catch (error: unknown) {\n if (error instanceof ValidationError) {\n for (const item of error.inner ?? []) {\n if (item.path) {\n setFirstError(errors, normalizeErrorPath(item.path), item.message);\n }\n }\n\n return filterErrorsByScope(errors, options?.scopeFields);\n }\n\n return {};\n }\n };\n};\n"],"mappings":"sDAAA,OAAS,mBAAAA,MAA+B,MASjC,IAAMC,EAAc,CACzBC,EACAC,IAEO,MACLC,EACAC,IAC0B,CAC1B,IAAMC,EAAuB,CAAC,EAE9B,GAAID,GAAS,aAAeA,EAAQ,YAAY,OAAS,EACvD,aAAM,QAAQ,IACZA,EAAQ,YAAY,IAAI,MAAOE,GAAU,CACvC,GAAI,CACF,MAAML,EAAO,WAAWK,EAAOH,CAAM,CACvC,OAASI,EAAgB,CACnBA,aAAiBC,GAAmBD,EAAM,MAC5CE,EACEJ,EACAK,EAAmBH,EAAM,IAAI,EAC7BA,EAAM,OACR,CAEJ,CACF,CAAC,CACH,EACOF,EAGT,GAAI,CACF,aAAMJ,EAAO,SAASE,EAAQ,CAC5B,WAAYD,GAAQ,YAAc,GAClC,aAAcA,GAAQ,cAAgB,EACxC,CAAC,EACM,CAAC,CACV,OAASK,EAAgB,CACvB,GAAIA,aAAiBC,EAAiB,CACpC,QAAWG,KAAQJ,EAAM,OAAS,CAAC,EAC7BI,EAAK,MACPF,EAAcJ,EAAQK,EAAmBC,EAAK,IAAI,EAAGA,EAAK,OAAO,EAIrE,OAAOC,EAAoBP,EAAQD,GAAS,WAAW,CACzD,CAEA,MAAO,CAAC,CACV,CACF","names":["ValidationError","yupResolver","schema","config","values","options","errors","field","error","ValidationError","setFirstError","normalizeErrorPath","item","filterErrorsByScope"]}
@@ -1,2 +0,0 @@
1
- import{d as D}from"./chunk-LIHWJJIM.js";import{a as j,b as U,d as V,e as I,g as q,i as L,j as W,k as O}from"./chunk-SYEUXL2E.js";import{b as x}from"./chunk-UIKO6GGW.js";import{a as C}from"./chunk-HE6EQZTH.js";import{c as v,f as A}from"./chunk-G3EHXKOS.js";import{createContext as J,useContext as K}from"react";import{jsx as Q}from"react/jsx-runtime";var _=J(null),bt=({store:t,children:e})=>Q(_.Provider,{value:D(t),children:e}),m=()=>{let t=K(_);if(!t)throw new Error("BitForm hooks devem ser usados dentro de um BitFormProvider");return t};import{useCallback as d,useMemo as w,useRef as X,useState as $,useSyncExternalStore as Y}from"react";function vt(){let t=m(),[e,r]=$(null),[i,o]=$(null),s=X(null),u=d(p=>U(t,p),[t]),a=d(()=>{let p=j(t);return s.current&&s.current.isValid===p.isValid&&s.current.isDirty===p.isDirty&&s.current.isSubmitting===p.isSubmitting?s.current:(s.current=p,p)},[t]),n=Y(u,a,a),S=w(()=>L(t,{clearSubmissionState:()=>{r(null),o(null)},setSubmissionResult:p=>{o(p)},setSubmissionError:p=>{r(p)}}),[t]),{controller:c,actions:P}=S,F=d(c.submit,[c]),g=d(c.onSubmit,[c]),y=d(c.reset,[c]),l=d(c.getValues,[c]),f=d(c.getErrors,[c]),b=d(c.getTouched,[c]),h=d(c.getDirtyValues,[c]),k=w(()=>({...n,submitError:e,lastResponse:i}),[n,e,i]);return w(()=>({meta:k,getValues:l,getErrors:f,getTouched:b,getDirtyValues:h,submit:F,onSubmit:g,reset:y,...P}),[k,l,f,b,h,F,g,y,P])}import{useCallback as z,useEffect as Z,useMemo as M,useRef as N,useSyncExternalStore as tt}from"react";function wt(t){let e=m(),r=M(()=>q(e,t),[e,t]),i=N(null),o=z(()=>{let n=r.readItems();return i.current&&v(i.current,n)?i.current:(i.current=n,n)},[r]),s=z(n=>e.observe.subscribePath(t,()=>n()),[e,t]),u=tt(s,o,o),a=M(()=>r.getFields(u),[r,u]);return Z(()=>()=>{O(e,`${t}.`)},[e,t]),M(()=>({fields:a,length:u.length,append:r.append,prepend:r.prepend,insert:r.insert,remove:r.remove,move:r.move,swap:r.swap,replace:r.replace,clear:r.clear}),[a,u.length,r])}import{useCallback as R,useMemo as et,useRef as rt,useSyncExternalStore as ot}from"react";function Dt(t){let e=m(),r=rt(null),i=R(()=>{let n=e.read.getScopeStatus(t);return r.current&&x(r.current,n)?r.current:(r.current=n,n)},[e,t]),o=R(n=>e.observe.subscribeScopeStatus(t,()=>n()),[e,t]),s=ot(o,i,i),u=R(async()=>{let n=await e.feature.validate({scope:t}),S=e.read.getScopeErrors(t);return{valid:n,errors:S}},[e,t]),a=R(()=>e.read.getScopeErrors(t),[e,t]);return et(()=>({scopeName:t,status:s,errors:s.errors,validate:u,getErrors:a,isValid:!s.hasErrors,isDirty:s.isDirty}),[t,s,u,a])}import{useCallback as B,useMemo as st,useRef as nt,useState as it,useSyncExternalStore as at}from"react";function Lt(t){let e=m(),[r,i]=it(0),o=t[r]??"",s=nt(null),u=B(()=>{let l=e.read.getScopeStatus(o);return s.current&&x(s.current,l)?s.current:(s.current=l,l)},[e,o]),a=at(B(l=>e.observe.subscribeScopeStatus(o,()=>l()),[e,o]),u,u),n=B(async()=>{let l=await e.feature.validate({scope:o}),f=e.read.getScopeErrors(o);return{valid:l,errors:f}},[e,o]),S=B(()=>e.read.getScopeErrors(o),[e,o]),c=B(async()=>{let l=e.read.getScopeFields(o);if(e.feature.hasValidationsInProgress(l))return!1;let f=await e.feature.validate({scope:o});if(f)i(b=>Math.min(b+1,t.length-1));else{let b=e.read.getScopeErrors(o),h=Object.keys(b);h.length>0&&e.write.markFieldsTouched(h)}return f},[e,o,t.length]),P=B(()=>{i(l=>Math.max(l-1,0))},[]),F=B(l=>{i(Math.max(0,Math.min(l-1,t.length-1)))},[t.length]),g=r===0,y=r>=t.length-1;return st(()=>({step:r+1,stepIndex:r,scope:o,next:c,prev:P,goTo:F,isFirst:g,isLast:y,status:a,errors:a.errors,isValid:!a.hasErrors,isDirty:a.isDirty,validate:n,getErrors:S}),[r,o,c,P,F,g,y,a,n,S])}import{useCallback as G,useSyncExternalStore as ut,useRef as ct}from"react";function Ht(t){let e=m(),r=ct(null),i=G(()=>{let s=A(e.read.getState().values,t);return r.current!==null&&v(r.current,s)?r.current:(r.current=s,s)},[e,t]),o=G(s=>e.observe.subscribePath(t,()=>s()),[e,t]);return ut(o,i,i)}import{useCallback as T,useMemo as H,useSyncExternalStore as lt}from"react";function Yt(){let t=m(),e=T(a=>I(t,a),[t]),r=lt(e,()=>V(t),()=>V(t)),i=T(async()=>t.feature.restorePersisted(),[t]),o=T(async()=>{await t.feature.forceSave()},[t]),s=T(async()=>{await t.feature.clearPersisted()},[t]),u=H(()=>({isSaving:r.isSaving,isRestoring:r.isRestoring,error:r.error}),[r]);return H(()=>({restore:i,save:o,clear:s,meta:u}),[i,o,s,u])}import{useCallback as E,useEffect as mt,useRef as pt,useSyncExternalStore as St}from"react";function ne(t){let e=m(),r=pt(null);mt(()=>()=>W(e,t),[e,t]);let i=E(()=>{let n=e.read.getFieldState(t),S=C(n,r.current);return r.current=S,S},[e,t]),o=E(n=>e.observe.subscribeFieldState(t,()=>n()),[e,t]),s=St(o,i,i),u=E(n=>e.write.setField(t,n),[e,t]),a=E(()=>e.write.blurField(t),[e,t]);return{fieldState:s,setValue:u,setBlur:a,store:e}}export{bt as a,m as b,vt as c,ne as d,wt as e,Dt as f,Lt as g,Ht as h,Yt as i};
2
- //# sourceMappingURL=chunk-GSZTHF7Z.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/react/context.tsx","../src/react/use-bit-form.ts","../src/react/use-bit-array.ts","../src/react/use-bit-scope.ts","../src/react/use-bit-steps.ts","../src/react/use-bit-watch.ts","../src/react/use-bit-persist.ts","../src/react/use-bit-field-base.ts"],"sourcesContent":["import React, { createContext, useContext } from \"react\";\nimport type { BitFrameworkStoreApi, BitStoreApi } from \"../core\";\nimport { createFrameworkStoreAdapter } from \"../core\";\n\nconst BitContext = createContext<BitFrameworkStoreApi<any> | null>(null);\n\ninterface BitFormProviderProps<T extends object> {\n store: BitFrameworkStoreApi<T> | BitStoreApi<T>;\n children: React.ReactNode;\n}\n\ninterface BitFormProviderRuntimeProps {\n store: unknown;\n children: React.ReactNode;\n}\n\ntype BitFormProviderComponent = {\n <T extends object>(props: BitFormProviderProps<T>): React.ReactElement;\n (props: BitFormProviderRuntimeProps): React.ReactElement;\n};\n\nexport const BitFormProvider: BitFormProviderComponent = ({\n store,\n children,\n}: BitFormProviderRuntimeProps) => {\n return (\n <BitContext.Provider value={createFrameworkStoreAdapter(store)}>\n {children}\n </BitContext.Provider>\n );\n};\n\nexport const useBitStore = <T extends object>() => {\n const store = useContext(BitContext);\n if (!store)\n throw new Error(\n \"BitForm hooks devem ser usados dentro de um BitFormProvider\",\n );\n return store as BitFrameworkStoreApi<T>;\n};\n","import {\n useCallback,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n} from \"react\";\nimport {\n createFrameworkFormBinding,\n readFormMetaSnapshot,\n subscribeFormMetaSnapshot,\n} from \"../core\";\nimport { useBitStore } from \"./context\";\nimport type { UseBitFormResult } from \"./types\";\n\nexport function useBitForm<T extends object>(): UseBitFormResult<T> {\n const store = useBitStore<T>();\n\n const [submitError, setSubmitError] = useState<Error | null>(null);\n const [lastResponse, setLastResponse] = useState<unknown>(null);\n const lastMeta = useRef<ReturnType<typeof readFormMetaSnapshot<T>> | null>(\n null,\n );\n\n const subscribeMeta = useCallback(\n (cb: () => void) => subscribeFormMetaSnapshot(store, cb),\n [store],\n );\n const getMetaSnapshot = useCallback(() => {\n const nextMeta = readFormMetaSnapshot(store);\n\n if (\n lastMeta.current &&\n lastMeta.current.isValid === nextMeta.isValid &&\n lastMeta.current.isDirty === nextMeta.isDirty &&\n lastMeta.current.isSubmitting === nextMeta.isSubmitting\n ) {\n return lastMeta.current;\n }\n\n lastMeta.current = nextMeta;\n return nextMeta;\n }, [store]);\n\n const metaState = useSyncExternalStore(\n subscribeMeta,\n getMetaSnapshot,\n getMetaSnapshot,\n );\n\n const binding = useMemo(\n () =>\n createFrameworkFormBinding(store, {\n clearSubmissionState: () => {\n setSubmitError(null);\n setLastResponse(null);\n },\n setSubmissionResult: (result) => {\n setLastResponse(result);\n },\n setSubmissionError: (error) => {\n setSubmitError(error);\n },\n }),\n [store],\n );\n\n const { controller, actions } = binding;\n\n const submit = useCallback(controller.submit, [controller]);\n const onSubmit = useCallback(controller.onSubmit, [controller]);\n const reset = useCallback(controller.reset, [controller]);\n\n const getValues = useCallback(controller.getValues, [controller]);\n const getErrors = useCallback(controller.getErrors, [controller]);\n const getTouched = useCallback(controller.getTouched, [controller]);\n const getDirtyValues = useCallback(controller.getDirtyValues, [controller]);\n\n const meta = useMemo(\n () => ({\n ...metaState,\n submitError,\n lastResponse,\n }),\n [metaState, submitError, lastResponse],\n );\n\n return useMemo(\n () => ({\n // Metadata (grouped)\n meta,\n // Getters\n getValues,\n getErrors,\n getTouched,\n getDirtyValues,\n // Main actions (frequent use - flat)\n submit,\n onSubmit,\n reset,\n ...actions,\n }),\n [\n meta,\n getValues,\n getErrors,\n getTouched,\n getDirtyValues,\n submit,\n onSubmit,\n reset,\n actions,\n ],\n );\n}\n","import {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useSyncExternalStore,\n} from \"react\";\nimport {\n BitArrayPath,\n cleanupRegisteredPrefix,\n createArrayBinding,\n valueEqual,\n} from \"../core\";\nimport { useBitStore } from \"./context\";\n\nexport function useBitArray<\n TForm extends object = any,\n P extends BitArrayPath<TForm> = BitArrayPath<TForm>,\n>(path: P) {\n const store = useBitStore<TForm>();\n const controller = useMemo(\n () => createArrayBinding<TForm, P>(store, path),\n [store, path],\n );\n type ArraySnapshot = ReturnType<typeof controller.readItems>;\n const lastSnapshotRef = useRef<ArraySnapshot | null>(null);\n\n const getSnapshot = useCallback(() => {\n const next = controller.readItems();\n\n if (lastSnapshotRef.current && valueEqual(lastSnapshotRef.current, next)) {\n return lastSnapshotRef.current;\n }\n\n lastSnapshotRef.current = next;\n return next;\n }, [controller]);\n\n const subscribeArray = useCallback(\n (cb: () => void) => store.observe.subscribePath(path, () => cb()),\n [store, path],\n );\n\n const data = useSyncExternalStore(subscribeArray, getSnapshot, getSnapshot);\n\n const fields = useMemo(() => controller.getFields(data), [controller, data]);\n\n useEffect(() => {\n return () => {\n cleanupRegisteredPrefix(store, `${path as string}.`);\n };\n }, [store, path]);\n\n return useMemo(\n () => ({\n fields,\n length: data.length,\n append: controller.append,\n prepend: controller.prepend,\n insert: controller.insert,\n remove: controller.remove,\n move: controller.move,\n swap: controller.swap,\n replace: controller.replace,\n clear: controller.clear,\n }),\n [fields, data.length, controller],\n );\n}\n","import { useCallback, useMemo, useRef, useSyncExternalStore } from \"react\";\nimport type { ScopeStatus, ValidateScopeResult } from \"../core\";\nimport { isScopeStatusEqual } from \"../core\";\nimport { useBitStore } from \"./context\";\n\nexport type { ScopeStatus, ValidateScopeResult };\n\nexport function useBitScope(scopeName: string) {\n const store = useBitStore();\n\n const lastStatus = useRef<ScopeStatus | null>(null);\n\n const getStatusSnapshot = useCallback(() => {\n const nextStatus = store.read.getScopeStatus(scopeName);\n\n if (\n lastStatus.current &&\n isScopeStatusEqual(lastStatus.current, nextStatus)\n ) {\n return lastStatus.current;\n }\n\n lastStatus.current = nextStatus;\n return nextStatus;\n }, [store, scopeName]);\n\n // Assina apenas os slices de estado relevantes para o escopo (errors e\n // isDirty), evitando execuções desnecessárias do getStatusSnapshot em\n // mudanças não relacionadas (isSubmitting, isValidating de outros campos…)\n const subscribe = useCallback(\n (cb: () => void) =>\n store.observe.subscribeScopeStatus(scopeName, () => cb()),\n [store, scopeName],\n );\n\n const status = useSyncExternalStore(\n subscribe,\n getStatusSnapshot,\n getStatusSnapshot,\n );\n\n const validate = useCallback(async (): Promise<ValidateScopeResult> => {\n const valid = await store.feature.validate({ scope: scopeName });\n const errors = store.read.getScopeErrors(scopeName);\n return { valid, errors };\n }, [store, scopeName]);\n\n const getErrors = useCallback(() => {\n return store.read.getScopeErrors(scopeName);\n }, [store, scopeName]);\n\n return useMemo(\n () => ({\n scopeName,\n status,\n errors: status.errors,\n validate,\n getErrors,\n isValid: !status.hasErrors,\n isDirty: status.isDirty,\n }),\n [scopeName, status, validate, getErrors],\n );\n}\n","import {\n useCallback,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n} from \"react\";\nimport type { ScopeStatus, ValidateScopeResult } from \"../core\";\nimport { isScopeStatusEqual } from \"../core\";\nimport { useBitStore } from \"./context\";\nimport type { UseBitStepsResult } from \"./types\";\n\nexport function useBitSteps(scopeNames: string[]): UseBitStepsResult {\n const store = useBitStore();\n const [stepIndex, setStepIndex] = useState(0);\n\n const scope = scopeNames[stepIndex] ?? \"\";\n const lastStatus = useRef<ScopeStatus | null>(null);\n\n const getStatusSnapshot = useCallback(() => {\n const nextStatus = store.read.getScopeStatus(scope);\n\n if (\n lastStatus.current &&\n isScopeStatusEqual(lastStatus.current, nextStatus)\n ) {\n return lastStatus.current;\n }\n\n lastStatus.current = nextStatus;\n return nextStatus;\n }, [store, scope]);\n\n const status = useSyncExternalStore(\n useCallback(\n (cb: () => void) => store.observe.subscribeScopeStatus(scope, () => cb()),\n [store, scope],\n ),\n getStatusSnapshot,\n getStatusSnapshot,\n );\n\n const validate = useCallback(async (): Promise<ValidateScopeResult> => {\n const valid = await store.feature.validate({ scope });\n const errors = store.read.getScopeErrors(scope);\n return { valid, errors };\n }, [store, scope]);\n\n const getErrors = useCallback(() => {\n return store.read.getScopeErrors(scope);\n }, [store, scope]);\n\n const next = useCallback(async (): Promise<boolean> => {\n const scopeFields = store.read.getScopeFields(scope);\n\n if (store.feature.hasValidationsInProgress(scopeFields)) {\n return false;\n }\n\n const valid = await store.feature.validate({ scope });\n if (valid) {\n setStepIndex((s) => Math.min(s + 1, scopeNames.length - 1));\n } else {\n const errors = store.read.getScopeErrors(scope);\n const pathsWithErrors = Object.keys(errors);\n if (pathsWithErrors.length > 0) {\n store.write.markFieldsTouched(pathsWithErrors);\n }\n }\n return valid;\n }, [store, scope, scopeNames.length]);\n\n const prev = useCallback(() => {\n setStepIndex((s) => Math.max(s - 1, 0));\n }, []);\n\n const goTo = useCallback(\n (targetStep: number) => {\n setStepIndex(\n Math.max(0, Math.min(targetStep - 1, scopeNames.length - 1)),\n );\n },\n [scopeNames.length],\n );\n\n const isFirst = stepIndex === 0;\n const isLast = stepIndex >= scopeNames.length - 1;\n\n return useMemo(\n () => ({\n step: stepIndex + 1,\n stepIndex,\n scope,\n next,\n prev,\n goTo,\n isFirst,\n isLast,\n status,\n errors: status.errors,\n isValid: !status.hasErrors,\n isDirty: status.isDirty,\n validate,\n getErrors,\n }),\n [\n stepIndex,\n scope,\n next,\n prev,\n goTo,\n isFirst,\n isLast,\n status,\n validate,\n getErrors,\n ],\n );\n}\n","import { useCallback, useSyncExternalStore, useRef } from \"react\";\nimport { useBitStore } from \"./context\";\nimport { getDeepValue, valueEqual, BitPath, BitPathValue } from \"../core\";\n\nexport function useBitWatch<\n TForm extends object = any,\n P extends BitPath<TForm> = BitPath<TForm>,\n>(path: P): BitPathValue<TForm, P> {\n const store = useBitStore<TForm>();\n const lastValue = useRef<BitPathValue<TForm, P> | null>(null);\n\n const getSnapshot = useCallback(() => {\n const value = getDeepValue(\n store.read.getState().values,\n path as string,\n ) as BitPathValue<TForm, P>;\n\n if (lastValue.current !== null && valueEqual(lastValue.current, value)) {\n return lastValue.current;\n }\n\n lastValue.current = value;\n return value;\n }, [store, path]);\n\n // Assina apenas o path monitorado → evita executar getSnapshot em toda\n // mudança de estado do store (blur, validation, outros campos, etc.)\n const subscribe = useCallback(\n (cb: () => void) => store.observe.subscribePath(path, () => cb()),\n [store, path],\n );\n\n return useSyncExternalStore(\n subscribe,\n getSnapshot,\n getSnapshot,\n ) as BitPathValue<TForm, P>;\n}\n","import { useCallback, useMemo, useSyncExternalStore } from \"react\";\nimport { readPersistMetaSnapshot, subscribePersistMetaSnapshot } from \"../core\";\nimport { useBitStore } from \"./context\";\nimport type { UseBitPersistResult } from \"./types\";\n\nexport function useBitPersist(): UseBitPersistResult {\n const store = useBitStore<any>();\n\n const subscribePersistMeta = useCallback(\n (cb: () => void) => subscribePersistMetaSnapshot(store, cb),\n [store],\n );\n\n const persistMeta = useSyncExternalStore(\n subscribePersistMeta,\n () => readPersistMetaSnapshot(store),\n () => readPersistMetaSnapshot(store),\n );\n\n const restore = useCallback(async () => {\n return store.feature.restorePersisted();\n }, [store]);\n\n const save = useCallback(async () => {\n await store.feature.forceSave();\n }, [store]);\n\n const clear = useCallback(async () => {\n await store.feature.clearPersisted();\n }, [store]);\n\n const meta = useMemo(\n () => ({\n isSaving: persistMeta.isSaving,\n isRestoring: persistMeta.isRestoring,\n error: persistMeta.error,\n }),\n [persistMeta],\n );\n\n return useMemo(\n () => ({\n restore,\n save,\n clear,\n meta,\n }),\n [restore, save, clear, meta],\n );\n}\n","import { useCallback, useEffect, useRef, useSyncExternalStore } from \"react\";\nimport {\n BitFieldSnapshot,\n BitPath,\n BitPathValue,\n cleanupRegisteredField,\n createFieldStateSnapshot,\n} from \"../core\";\nimport { useBitStore } from \"./context\";\n\nexport function useBitFieldBase<\n _TValue = any,\n TForm extends object = any,\n P extends BitPath<TForm> = BitPath<TForm>,\n>(path: P) {\n const store = useBitStore<TForm>();\n const lastSnapshot = useRef<BitFieldSnapshot<BitPathValue<TForm, P>> | null>(\n null,\n );\n\n useEffect(() => {\n return () => cleanupRegisteredField(store, path as string);\n }, [store, path]);\n\n const getSnapshot = useCallback(() => {\n const nextState = store.read.getFieldState(path);\n const snapshot = createFieldStateSnapshot(nextState, lastSnapshot.current);\n lastSnapshot.current = snapshot;\n return snapshot;\n }, [store, path]);\n\n const subscribe = useCallback(\n (cb: () => void) => store.observe.subscribeFieldState(path, () => cb()),\n [store, path],\n );\n\n const fieldState = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n\n const setValue = useCallback(\n (val: BitPathValue<TForm, P>) => store.write.setField(path, val),\n [store, path],\n );\n\n const setBlur = useCallback(() => store.write.blurField(path), [store, path]);\n\n return { fieldState, setValue, setBlur, store };\n}\n"],"mappings":"gQAAA,OAAgB,iBAAAA,EAAe,cAAAC,MAAkB,QA0B7C,cAAAC,MAAA,oBAtBJ,IAAMC,EAAaC,EAAgD,IAAI,EAiB1DC,GAA4C,CAAC,CACxD,MAAAC,EACA,SAAAC,CACF,IAEIL,EAACC,EAAW,SAAX,CAAoB,MAAOK,EAA4BF,CAAK,EAC1D,SAAAC,EACH,EAISE,EAAc,IAAwB,CACjD,IAAMH,EAAQI,EAAWP,CAAU,EACnC,GAAI,CAACG,EACH,MAAM,IAAI,MACR,6DACF,EACF,OAAOA,CACT,ECvCA,OACE,eAAAK,EACA,WAAAC,EACA,UAAAC,EACA,YAAAC,EACA,wBAAAC,MACK,QASA,SAASC,IAAoD,CAClE,IAAMC,EAAQC,EAAe,EAEvB,CAACC,EAAaC,CAAc,EAAIC,EAAuB,IAAI,EAC3D,CAACC,EAAcC,CAAe,EAAIF,EAAkB,IAAI,EACxDG,EAAWC,EACf,IACF,EAEMC,EAAgBC,EACnBC,GAAmBC,EAA0BZ,EAAOW,CAAE,EACvD,CAACX,CAAK,CACR,EACMa,EAAkBH,EAAY,IAAM,CACxC,IAAMI,EAAWC,EAAqBf,CAAK,EAE3C,OACEO,EAAS,SACTA,EAAS,QAAQ,UAAYO,EAAS,SACtCP,EAAS,QAAQ,UAAYO,EAAS,SACtCP,EAAS,QAAQ,eAAiBO,EAAS,aAEpCP,EAAS,SAGlBA,EAAS,QAAUO,EACZA,EACT,EAAG,CAACd,CAAK,CAAC,EAEJgB,EAAYC,EAChBR,EACA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,GACA,CAACA,CAAW,CACd,EAEA,OAAOO,EACL,KAAO,CACL,QAAAJ,EACA,KAAAC,EACA,MAAAC,EACA,KAAAC,CACF,GACA,CAACH,EAASC,EAAMC,EAAOC,CAAI,CAC7B,CACF,CCjDA,OAAS,eAAAE,EAAa,aAAAC,GAAW,UAAAC,GAAQ,wBAAAC,OAA4B,QAU9D,SAASC,GAIdC,EAAS,CACT,IAAMC,EAAQC,EAAmB,EAC3BC,EAAeC,GACnB,IACF,EAEAC,GAAU,IACD,IAAMC,EAAuBL,EAAOD,CAAc,EACxD,CAACC,EAAOD,CAAI,CAAC,EAEhB,IAAMO,EAAcC,EAAY,IAAM,CACpC,IAAMC,EAAYR,EAAM,KAAK,cAAcD,CAAI,EACzCU,EAAWC,EAAyBF,EAAWN,EAAa,OAAO,EACzE,OAAAA,EAAa,QAAUO,EAChBA,CACT,EAAG,CAACT,EAAOD,CAAI,CAAC,EAEVY,EAAYJ,EACfK,GAAmBZ,EAAM,QAAQ,oBAAoBD,EAAM,IAAMa,EAAG,CAAC,EACtE,CAACZ,EAAOD,CAAI,CACd,EAEMc,EAAaC,GAAqBH,EAAWL,EAAaA,CAAW,EAErES,EAAWR,EACdS,GAAgChB,EAAM,MAAM,SAASD,EAAMiB,CAAG,EAC/D,CAAChB,EAAOD,CAAI,CACd,EAEMkB,EAAUV,EAAY,IAAMP,EAAM,MAAM,UAAUD,CAAI,EAAG,CAACC,EAAOD,CAAI,CAAC,EAE5E,MAAO,CAAE,WAAAc,EAAY,SAAAE,EAAU,QAAAE,EAAS,MAAAjB,CAAM,CAChD","names":["createContext","useContext","jsx","BitContext","createContext","BitFormProvider","store","children","createFrameworkStoreAdapter","useBitStore","useContext","useCallback","useMemo","useRef","useState","useSyncExternalStore","useBitForm","store","useBitStore","submitError","setSubmitError","useState","lastResponse","setLastResponse","lastMeta","useRef","subscribeMeta","useCallback","cb","subscribeFormMetaSnapshot","getMetaSnapshot","nextMeta","readFormMetaSnapshot","metaState","useSyncExternalStore","binding","useMemo","createFrameworkFormBinding","result","error","controller","actions","submit","onSubmit","reset","getValues","getErrors","getTouched","getDirtyValues","meta","useCallback","useEffect","useMemo","useRef","useSyncExternalStore","useBitArray","path","store","useBitStore","controller","useMemo","createArrayBinding","lastSnapshotRef","useRef","getSnapshot","useCallback","next","valueEqual","subscribeArray","cb","data","useSyncExternalStore","fields","useEffect","cleanupRegisteredPrefix","useCallback","useMemo","useRef","useSyncExternalStore","useBitScope","scopeName","store","useBitStore","lastStatus","useRef","getStatusSnapshot","useCallback","nextStatus","isScopeStatusEqual","subscribe","cb","status","useSyncExternalStore","validate","valid","errors","getErrors","useMemo","useCallback","useMemo","useRef","useState","useSyncExternalStore","useBitSteps","scopeNames","store","useBitStore","stepIndex","setStepIndex","useState","scope","lastStatus","useRef","getStatusSnapshot","useCallback","nextStatus","isScopeStatusEqual","status","useSyncExternalStore","cb","validate","valid","errors","getErrors","next","scopeFields","s","pathsWithErrors","prev","goTo","targetStep","isFirst","isLast","useMemo","useCallback","useSyncExternalStore","useRef","useBitWatch","path","store","useBitStore","lastValue","useRef","getSnapshot","useCallback","value","getDeepValue","valueEqual","subscribe","cb","useSyncExternalStore","useCallback","useMemo","useSyncExternalStore","useBitPersist","store","useBitStore","subscribePersistMeta","useCallback","cb","subscribePersistMetaSnapshot","persistMeta","useSyncExternalStore","readPersistMetaSnapshot","restore","save","clear","meta","useMemo","useCallback","useEffect","useRef","useSyncExternalStore","useBitFieldBase","path","store","useBitStore","lastSnapshot","useRef","useEffect","cleanupRegisteredField","getSnapshot","useCallback","nextState","snapshot","createFieldStateSnapshot","subscribe","cb","fieldState","useSyncExternalStore","setValue","val","setBlur"]}
@@ -1,2 +0,0 @@
1
- function s(r){return r.replace(/\[(\d+)\]/g,".$1").replace(/^\.+/,"").replace(/\.{2,}/g,".")}function a(r,t){return r===t||r.startsWith(`${t}.`)||t.startsWith(`${r}.`)}function l(r,t,i){let e=s(t);!e||!i||r[e]||(r[e]=i)}function g(r,t){if(!t||t.length===0)return r;let i=t.map(n=>s(n)).filter(n=>n.length>0);if(i.length===0)return{};let e={};for(let[n,f]of Object.entries(r)){let c=s(n);if(f&&i.some(o=>a(c,o))){let o=n;e[o]=f}}return e}export{s as a,l as b,g as c};
2
- //# sourceMappingURL=chunk-GUU6EXFN.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/resolvers/utils.ts"],"sourcesContent":["import { BitErrors } from \"../core\";\n\nexport function normalizeErrorPath(path: string): string {\n return path\n .replace(/\\[(\\d+)\\]/g, \".$1\")\n .replace(/^\\.+/, \"\")\n .replace(/\\.{2,}/g, \".\");\n}\n\nfunction matchScopePath(errorPath: string, scopePath: string): boolean {\n return (\n errorPath === scopePath ||\n errorPath.startsWith(`${scopePath}.`) ||\n scopePath.startsWith(`${errorPath}.`)\n );\n}\n\nexport function setFirstError<T extends object>(\n errors: BitErrors<T>,\n path: string,\n message: string | undefined,\n) {\n const normalizedPath = normalizeErrorPath(path);\n\n if (!normalizedPath || !message) {\n return;\n }\n\n if (!errors[normalizedPath as keyof BitErrors<T>]) {\n errors[normalizedPath as keyof BitErrors<T>] = message;\n }\n}\n\nexport function filterErrorsByScope<T extends object>(\n errors: BitErrors<T>,\n scopeFields?: string[],\n): BitErrors<T> {\n if (!scopeFields || scopeFields.length === 0) {\n return errors;\n }\n\n const normalizedScopeFields = scopeFields\n .map((scopeField) => normalizeErrorPath(scopeField))\n .filter((scopeField) => scopeField.length > 0);\n\n if (normalizedScopeFields.length === 0) {\n return {};\n }\n\n const filtered: BitErrors<T> = {};\n\n for (const [key, message] of Object.entries(errors)) {\n const normalizedKey = normalizeErrorPath(key);\n if (\n message &&\n normalizedScopeFields.some((scopeField) =>\n matchScopePath(normalizedKey, scopeField),\n )\n ) {\n const typedKey = key as keyof BitErrors<T>;\n filtered[typedKey] = message as BitErrors<T>[typeof typedKey];\n }\n }\n\n return filtered;\n}\n"],"mappings":"AAEO,SAASA,EAAmBC,EAAsB,CACvD,OAAOA,EACJ,QAAQ,aAAc,KAAK,EAC3B,QAAQ,OAAQ,EAAE,EAClB,QAAQ,UAAW,GAAG,CAC3B,CAEA,SAASC,EAAeC,EAAmBC,EAA4B,CACrE,OACED,IAAcC,GACdD,EAAU,WAAW,GAAGC,CAAS,GAAG,GACpCA,EAAU,WAAW,GAAGD,CAAS,GAAG,CAExC,CAEO,SAASE,EACdC,EACAL,EACAM,EACA,CACA,IAAMC,EAAiBR,EAAmBC,CAAI,EAE1C,CAACO,GAAkB,CAACD,GAInBD,EAAOE,CAAoC,IAC9CF,EAAOE,CAAoC,EAAID,EAEnD,CAEO,SAASE,EACdH,EACAI,EACc,CACd,GAAI,CAACA,GAAeA,EAAY,SAAW,EACzC,OAAOJ,EAGT,IAAMK,EAAwBD,EAC3B,IAAKE,GAAeZ,EAAmBY,CAAU,CAAC,EAClD,OAAQA,GAAeA,EAAW,OAAS,CAAC,EAE/C,GAAID,EAAsB,SAAW,EACnC,MAAO,CAAC,EAGV,IAAME,EAAyB,CAAC,EAEhC,OAAW,CAACC,EAAKP,CAAO,IAAK,OAAO,QAAQD,CAAM,EAAG,CACnD,IAAMS,EAAgBf,EAAmBc,CAAG,EAC5C,GACEP,GACAI,EAAsB,KAAMC,GAC1BV,EAAea,EAAeH,CAAU,CAC1C,EACA,CACA,IAAMI,EAAWF,EACjBD,EAASG,CAAQ,EAAIT,CACvB,CACF,CAEA,OAAOM,CACT","names":["normalizeErrorPath","path","matchScopePath","errorPath","scopePath","setFirstError","errors","message","normalizedPath","filterErrorsByScope","scopeFields","normalizedScopeFields","scopeField","filtered","key","normalizedKey","typedKey"]}
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13; var _class14; var _class15; var _class16; var _class17; var _class18; var _class19; var _class20; var _class21; var _class22; var _class23; var _class24;var _chunkRHMJPKNVcjs = require('./chunk-RHMJPKNV.cjs');var _chunkGKNGJOB3cjs = require('./chunk-GKNGJOB3.cjs');var _chunkFTXV2NZOcjs = require('./chunk-FTXV2NZO.cjs');var _chunkWRNR6SXKcjs = require('./chunk-WRNR6SXK.cjs');function Qe(s){let{path:e,getFieldConfig:t,masks:i}=s,r=_optionalChain([t, 'call', _2 => _2(e), 'optionalAccess', _3 => _3.mask]);if(r)return typeof r=="string"?_optionalChain([i, 'optionalAccess', _4 => _4[r]]):r}function Ze(s){let{state:e,path:t,value:i,isHidden:r,isRequired:n,isDirty:o,isValidating:a}=s,l=t;return{value:i,error:e.errors[l],touched:!!e.touched[l],isHidden:r,isRequired:n,isDirty:o,isValidating:a}}var k=Symbol.for("bit-form.framework-store-api");var R=Symbol.for("bit-form.hooks-api");var q=class{constructor(e){this.baselineValues=_chunkFTXV2NZOcjs.a.call(void 0, e)}getValues(){return this.baselineSnapshot||(this.baselineSnapshot=Object.freeze(_chunkFTXV2NZOcjs.a.call(void 0, this.baselineValues))),this.baselineSnapshot}setValues(e){this.baselineValues=_chunkFTXV2NZOcjs.a.call(void 0, e),this.baselineSnapshot=void 0}};var _= (_class =class{constructor(e,t){;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);_class.prototype.__init6.call(this);_class.prototype.__init7.call(this);this.getComputedEntries=e;this.onError=t}__init() {this.equalityCache=new Map}__init2() {this.reverseDepsCache=null}__init3() {this.childDepsIndex=null}__init4() {this.validatedEntriesSignature=null}__init5() {this.validatedEntriesRef=null}__init6() {this.orderedAllEntriesCache=null}__init7() {this.orderedIndexByPathCache=null}isCacheableScalar(e){return e===null||typeof e!="object"&&typeof e!="function"}invalidateReverseDeps(){this.reverseDepsCache=null,this.childDepsIndex=null,this.orderedAllEntriesCache=null,this.validatedEntriesSignature=null,this.validatedEntriesRef=null,this.orderedIndexByPathCache=null,this.equalityCache.clear()}apply(e,t){let i=this.getComputedEntries(e);if(i.length===0)return e;this.ensureEntriesAreValid(i);let r=this.resolveEntriesToRun(i,t);if(r.length===0)return e;let n=e,o=new Set;for(let a of r){if(a.dependsOn.some(h=>o.has(h))){o.add(a.path);continue}let l;try{l=a.compute(n)}catch(h){_optionalChain([this, 'access', _5 => _5.onError, 'optionalCall', _6 => _6(h,a.path)]),o.add(a.path);continue}let c=_chunkFTXV2NZOcjs.f.call(void 0, n,a.path),p=this.equalityCache.get(a.path),d,u=this.isCacheableScalar(c)&&this.isCacheableScalar(l);u&&p&&p.current===c&&p.next===l?d=p.equal:(d=_chunkFTXV2NZOcjs.d.call(void 0, c,l),u?this.equalityCache.set(a.path,{current:c,next:l,equal:d}):this.equalityCache.delete(a.path)),d||(n=_chunkFTXV2NZOcjs.g.call(void 0, n,a.path,l))}return n}getReverseDependencies(e){if(this.reverseDepsCache)return this.reverseDepsCache;let t=new Map;for(let r of e)for(let n of r.dependsOn){let o=t.get(n);o||(o=new Set,t.set(n,o)),o.add(r.path)}let i=new Map;for(let r of t.keys()){let n=r.split(".");for(let o=1;o<n.length;o++){let a=n.slice(0,o).join("."),l=i.get(a);l||(l=new Set,i.set(a,l)),l.add(r)}}return this.reverseDepsCache=t,this.childDepsIndex=i,t}resolveEntriesToRun(e,t){if(!t||t.length===0||t.includes("*"))return this.getOrderedAllEntries(e);let i=this.getReverseDependencies(e),r=new Set,n=[...t],o=0;for(;o<n.length;){let p=n[o++],d=this.getDependentsForPath(i,p);if(d)for(let u of d)r.has(u)||(r.add(u),n.push(u))}if(r.size===0)return[];let a=this.getOrderedAllEntries(e),l=this.getOrderedIndexByPath(e,a),c=[];return r.forEach(p=>{let d=l.get(p);if(d===void 0)return;let u=a[d];u&&c.push({index:d,entry:u})}),c.sort((p,d)=>p.index-d.index),c.map(p=>p.entry)}orderEntries(e){if(e.length<=1)return e;let t=new Map(e.map(a=>[a.path,a])),i=new Map,r=new Map;e.forEach(a=>i.set(a.path,0)),e.forEach(a=>{a.dependsOn.forEach(l=>{if(!t.has(l))return;let c=_nullishCoalesce(r.get(l), () => (new Set));c.has(a.path)||(c.add(a.path),r.set(l,c),i.set(a.path,(_nullishCoalesce(i.get(a.path), () => (0)))+1))})});let n=e.filter(a=>(_nullishCoalesce(i.get(a.path), () => (0)))===0).map(a=>a.path),o=[];for(;n.length>0;){let a=n.shift();o.push(a);let l=r.get(a);l&&l.forEach(c=>{let p=(_nullishCoalesce(i.get(c), () => (0)))-1;i.set(c,p),p===0&&n.push(c)})}if(o.length!==e.length)throw new Error("BitStore: cyclic computed dependencies detected. Check computedDependsOn definitions.");return o.map(a=>t.get(a))}getOrderedAllEntries(e){let t=this.createEntriesSignature(e);if(this.orderedAllEntriesCache&&this.orderedAllEntriesCache.signature===t)return this.orderedAllEntriesCache.ordered;let i=this.orderEntries(e);return this.orderedAllEntriesCache={signature:t,ordered:i},i}getOrderedIndexByPath(e,t){let i=this.createEntriesSignature(e);if(this.orderedIndexByPathCache&&this.orderedIndexByPathCache.signature===i)return this.orderedIndexByPathCache.indexByPath;let r=new Map;return t.forEach((n,o)=>{r.set(n.path,o)}),this.orderedIndexByPathCache={signature:i,indexByPath:r},r}ensureEntriesAreValid(e){if(this.validatedEntriesRef===e)return;let t=this.createEntriesSignature(e);if(this.validatedEntriesSignature===t){this.validatedEntriesRef=e;return}e.forEach(i=>this.assertDependencies(i)),this.invalidateReverseDeps(),this.validatedEntriesSignature=t,this.validatedEntriesRef=e}createEntriesSignature(e){return e.map(t=>`${t.path}:${t.dependsOn.join(",")}`).join("|")}getDependentsForPath(e,t){let i=new Set,r=a=>{let l=e.get(a);l&&l.forEach(c=>i.add(c))};r(t);let n=t.split(".");for(;n.length>1;)n.pop(),r(n.join("."));let o=_optionalChain([this, 'access', _7 => _7.childDepsIndex, 'optionalAccess', _8 => _8.get, 'call', _9 => _9(t)]);if(o)for(let a of o)r(a);return i}assertDependencies(e){if(e.dependsOn.length===0)throw new Error(`BitStore: computed field \`${e.path}\` requires explicit computedDependsOn in v4.`);if(e.dependsOn.includes(e.path))throw new Error(`BitStore: computed field \`${e.path}\` cannot depend on itself.`)}}, _class);var L= (_class2 =class{constructor() { _class2.prototype.__init8.call(this);_class2.prototype.__init9.call(this);_class2.prototype.__init10.call(this);_class2.prototype.__init11.call(this); }__init8() {this.dirtyPaths=new Set}__init9() {this.dirtyPathIndex=new Set}__init10() {this.dirtyPrefixRefCount=new Map}__init11() {this.childrenByPrefix=new Map}updateForPath(e,t,i){this.removeDirtyChildren(e);let r=_chunkFTXV2NZOcjs.f.call(void 0, t,e),n=_chunkFTXV2NZOcjs.f.call(void 0, i,e);return _chunkFTXV2NZOcjs.c.call(void 0, r,n)?this.removeDirtyPath(e):this.addDirtyPath(e),this.dirtyPaths.size>0}rebuild(e,t){return this.dirtyPaths=_chunkFTXV2NZOcjs.e.call(void 0, e,t),this.dirtyPrefixRefCount.clear(),this.rebuildIndex(),this.dirtyPaths.size>0}clear(){this.dirtyPaths.clear(),this.dirtyPathIndex.clear(),this.dirtyPrefixRefCount.clear(),this.childrenByPrefix.clear()}get isDirty(){return this.dirtyPaths.size>0}getDirtyPaths(){return this.dirtyPaths}isPathDirty(e){if(this.dirtyPathIndex.has(e))return!0;let t=e.lastIndexOf(".");for(;t>-1;){let i=e.slice(0,t);if((_nullishCoalesce(this.dirtyPrefixRefCount.get(i), () => (0)))>0)return!0;t=e.lastIndexOf(".",t-1)}return!1}buildDirtyValues(e){if(this.dirtyPaths.size===0)return{};let t=[],i=[...this.dirtyPaths].sort(),r=new Set,n=new Set,o=a=>{let l=a.lastIndexOf(".");for(;l>-1;){if(n.has(a.slice(0,l)))return!0;l=a.lastIndexOf(".",l-1)}return!1};for(let a of i){if(o(a))continue;let l=a.match(/^(.+)\.\d+/);if(l){let c=l[1];if(r.has(c))continue;r.add(c);let p=_chunkFTXV2NZOcjs.f.call(void 0, e,c);t.push([c,p]),n.add(c)}else{let c=_chunkFTXV2NZOcjs.f.call(void 0, e,a);t.push([a,c]),n.add(a)}}return t.length===0?{}:_chunkFTXV2NZOcjs.h.call(void 0, {},t)}rebuildIndex(){let e=new Set,t=new Map,i=new Map;for(let r of this.dirtyPaths)this.forEachPathPrefix(r,n=>{e.add(n),t.set(n,(_nullishCoalesce(t.get(n), () => (0)))+1)}),this.forEachAncestorPrefix(r,n=>{let o=i.get(n);o?o.add(r):i.set(n,new Set([r]))});this.dirtyPathIndex=e,this.dirtyPrefixRefCount=t,this.childrenByPrefix=i}removeDirtyChildren(e){let t=this.childrenByPrefix.get(e);if(!(!t||t.size===0))for(let i of[...t])this.removeDirtyPath(i)}addDirtyPath(e){this.dirtyPaths.has(e)||(this.dirtyPaths.add(e),this.forEachPathPrefix(e,t=>{this.dirtyPathIndex.add(t),this.dirtyPrefixRefCount.set(t,(_nullishCoalesce(this.dirtyPrefixRefCount.get(t), () => (0)))+1)}),this.forEachAncestorPrefix(e,t=>{let i=this.childrenByPrefix.get(t);i?i.add(e):this.childrenByPrefix.set(t,new Set([e]))}))}removeDirtyPath(e){this.dirtyPaths.has(e)&&(this.dirtyPaths.delete(e),this.forEachPathPrefix(e,t=>{let i=(_nullishCoalesce(this.dirtyPrefixRefCount.get(t), () => (0)))-1;if(i<=0){this.dirtyPrefixRefCount.delete(t),this.dirtyPathIndex.delete(t);return}this.dirtyPrefixRefCount.set(t,i)}),this.forEachAncestorPrefix(e,t=>{_optionalChain([this, 'access', _10 => _10.childrenByPrefix, 'access', _11 => _11.get, 'call', _12 => _12(t), 'optionalAccess', _13 => _13.delete, 'call', _14 => _14(e)])}))}forEachPathPrefix(e,t){let i=e.split("."),r="";for(let n of i)r=r?`${r}.${n}`:n,t(r)}forEachAncestorPrefix(e,t){let i=e.split("."),r="";for(let n=0;n<i.length-1;n++)r=r?`${r}.${i[n]}`:i[n],t(r)}}, _class2);var W= (_class3 =class{__init12() {this.masks=new Map}constructor(){;_class3.prototype.__init12.call(this);Object.entries(_chunkWRNR6SXKcjs.L).forEach(([e,t])=>{this.masks.set(e,t)})}registerMask(e,t){this.masks.set(e,t)}unregisterMask(e){this.masks.has(e)&&this.masks.delete(e)}resolveMask(e){return this.masks.get(e)}getAllMasks(){return Object.fromEntries(this.masks.entries())}clear(){this.masks.clear()}}, _class3);function fi(s){return s.replace(/\.+$/g,"")}function F(s){return fi(s.trim())}function P(s,e){let t=F(e);return t.length===0?!1:s===t||s.startsWith(`${t}.`)}function E(s,e){return F(e===void 0?s:`${s}.${e}`)}function x(s){return s.includes(".*.")||s.endsWith(".*")}function et(s){let t=s.replace(/\./g,"\\.").replace(/\*/g,"\\d+");return new RegExp(`^${t}$`)}function O(s,e){if(!x(s))return[s];let t=s.split("."),i=[""];for(let r=0;r<t.length;r++){let n=t[r],o=[];for(let a of i)if(n==="*"){let l=a.replace(/\.$/,""),c=l?_chunkFTXV2NZOcjs.f.call(void 0, e,l):e;if(Array.isArray(c)&&c.length>0)for(let p=0;p<c.length;p++)o.push(`${a}${p}.`)}else o.push(`${a}${n}.`);i=o}return i.map(r=>r.replace(/\.$/,""))}function Ie(s,e,t){if(!x(s)||!x(t))return s;let i=t.replace(/\./g,"\\.").replace(/\*/g,"(\\d+)"),r=new RegExp(`^${i}$`),n=e.match(r);if(!n)return s;let o=n.slice(1),a=0,l=s.split("*"),c=l[0];for(let p=1;p<l.length;p++){let d=a<o.length?o[a++]:"*";c+=d+l[p]}return c}var N= (_class4 =class{constructor() { _class4.prototype.__init13.call(this);_class4.prototype.__init14.call(this);_class4.prototype.__init15.call(this);_class4.prototype.__init16.call(this);_class4.prototype.__init17.call(this);_class4.prototype.__init18.call(this);_class4.prototype.__init19.call(this); }__init13() {this.fieldConfigs=new Map}__init14() {this.wildcardConfigs=new Map}__init15() {this.wildcardRegexes=new Map}__init16() {this.scopeFieldsIndex=null}__init17() {this.computedEntriesCache=null}__init18() {this.normalizerEntriesCache=null}__init19() {this.transformEntriesCache=null}get(e){let t=this.fieldConfigs.get(e);if(t)return t;for(let[i,r]of this.wildcardConfigs.entries()){let n=this.wildcardRegexes.get(i);if(n&&n.test(e))return r}}set(e,t){x(e)?(this.wildcardConfigs.set(e,t),this.wildcardRegexes.set(e,et(e))):this.fieldConfigs.set(e,t),this.registerCachedIndexes(e,t)}delete(e){let t;return x(e)?(t=this.wildcardConfigs.get(e),this.wildcardConfigs.delete(e),this.wildcardRegexes.delete(e)):(t=this.fieldConfigs.get(e),this.fieldConfigs.delete(e)),this.unregisterCachedIndexes(e,t),t}has(e){if(this.fieldConfigs.has(e)||this.wildcardConfigs.has(e))return!0;for(let t of this.wildcardRegexes.values())if(t.test(e))return!0;return!1}forEach(e){this.fieldConfigs.forEach((t,i)=>e(t,i)),this.wildcardConfigs.forEach((t,i)=>e(t,i))}entries(){return[...Array.from(this.fieldConfigs.entries()),...Array.from(this.wildcardConfigs.entries())]}getScopeFields(e,t){if(!this.scopeFieldsIndex){let n=new Map;this.forEach((o,a)=>{if(!o.scope)return;let l=_nullishCoalesce(n.get(o.scope), () => (new Set));l.add(a),n.set(o.scope,l)}),this.scopeFieldsIndex=n}let i=Array.from(_nullishCoalesce(this.scopeFieldsIndex.get(e), () => ([])));if(i.length===0)return[];let r=new Set;for(let n of i)x(n)?O(n,t).forEach(a=>r.add(a)):r.add(n);return Array.from(r)}getComputedEntries(e){if(!this.computedEntriesCache){let i=[];this.forEach((r,n)=>{r.computed&&i.push({path:n,compute:r.computed,dependsOn:r.computedDependsOn})}),this.computedEntriesCache=i}let t=[];for(let i of this.computedEntriesCache)if(x(i.path)){let r=O(i.path,e);for(let n of r)t.push({path:n,compute:o=>i.compute(o,n),dependsOn:i.dependsOn.map(o=>Ie(o,n,i.path))})}else t.push({path:i.path,compute:r=>i.compute(r,i.path),dependsOn:i.dependsOn});return t}getTransformEntries(e){if(!this.transformEntriesCache){let i=[];this.forEach((r,n)=>{r.transform&&i.push([n,r.transform])}),this.transformEntriesCache=i}let t=[];for(let[i,r]of this.transformEntriesCache)if(x(i)){let n=O(i,e);for(let o of n)t.push([o,(a,l)=>r(a,l,o)])}else t.push([i,(n,o)=>r(n,o,i)]);return t}getNormalizerEntries(e){if(!this.normalizerEntriesCache){let i=[];this.forEach((r,n)=>{r.normalize&&i.push({path:n,normalize:r.normalize,dependsOn:_optionalChain([r, 'access', _15 => _15.normalizeDependsOn, 'optionalAccess', _16 => _16.length])?r.normalizeDependsOn:[n]})}),this.normalizerEntriesCache=i}let t=[];for(let i of this.normalizerEntriesCache)if(x(i.path)){let r=O(i.path,e);for(let n of r)t.push({path:n,normalize:(o,a)=>i.normalize(o,a,n),dependsOn:i.dependsOn.map(o=>Ie(o,n,i.path))})}else t.push({path:i.path,normalize:(r,n)=>i.normalize(r,n,i.path),dependsOn:i.dependsOn});return t}invalidateIndexes(){this.scopeFieldsIndex=null,this.computedEntriesCache=null,this.normalizerEntriesCache=null,this.transformEntriesCache=null}registerCachedIndexes(e,t){if(this.scopeFieldsIndex&&t.scope){let i=_nullishCoalesce(this.scopeFieldsIndex.get(t.scope), () => (new Set));i.add(e),this.scopeFieldsIndex.set(t.scope,i)}this.computedEntriesCache&&t.computed&&this.computedEntriesCache.push({path:e,compute:t.computed,dependsOn:t.computedDependsOn}),this.normalizerEntriesCache&&t.normalize&&this.normalizerEntriesCache.push({path:e,normalize:t.normalize,dependsOn:_optionalChain([t, 'access', _17 => _17.normalizeDependsOn, 'optionalAccess', _18 => _18.length])?t.normalizeDependsOn:[e]}),this.transformEntriesCache&&t.transform&&this.transformEntriesCache.push([e,t.transform])}unregisterCachedIndexes(e,t){if(!t){this.invalidateIndexes();return}if(this.scopeFieldsIndex&&t.scope){let i=this.scopeFieldsIndex.get(t.scope);i&&(i.delete(e),i.size>0?this.scopeFieldsIndex.set(t.scope,i):this.scopeFieldsIndex.delete(t.scope))}this.computedEntriesCache&&t.computed&&(this.computedEntriesCache=this.computedEntriesCache.filter(i=>i.path!==e)),this.normalizerEntriesCache&&t.normalize&&(this.normalizerEntriesCache=this.normalizerEntriesCache.filter(i=>i.path!==e)),this.transformEntriesCache&&t.transform&&(this.transformEntriesCache=this.transformEntriesCache.filter(([i])=>i!==e))}}, _class4);var K= (_class5 =class{constructor(e,t){;_class5.prototype.__init20.call(this);_class5.prototype.__init21.call(this);_class5.prototype.__init22.call(this);_class5.prototype.__init23.call(this);_class5.prototype.__init24.call(this);_class5.prototype.__init25.call(this);_class5.prototype.__init26.call(this);this.getFieldConfig=e;this.onConditionError=t}__init20() {this.dependencies=new Map}__init21() {this.hiddenFields=new Set}__init22() {this.conditionalVisibilityPaths=new Set}__init23() {this.requiredPathsByDependency=new Map}__init24() {this.requiredConditionalPaths=new Set}__init25() {this.requiredEvaluationVersion=0}__init26() {this.requiredEvaluationCache=new Map}getHiddenFields(){return this.hiddenFields}onRegister(e,t,i){let r=!!_optionalChain([t, 'access', _19 => _19.conditional, 'optionalAccess', _20 => _20.showIf]),n=_optionalChain([t, 'access', _21 => _21.conditional, 'optionalAccess', _22 => _22.dependsOn]);if(n){if(this.wouldCreateCycle(e,n)){let o=new Error(`Circular dependency detected: "${e}" \u2192 [${n.join(", ")}]`);return _optionalChain([this, 'access', _23 => _23.onConditionError, 'optionalCall', _24 => _24({path:e,kind:"showIf",error:o})]),r&&this.hiddenFields.add(e),this.conditionalVisibilityPaths.delete(e),this.requiredConditionalPaths.delete(e),!1}n.forEach(o=>{this.dependencies.has(o)||this.dependencies.set(o,new Set),this.dependencies.get(o).add(e)})}return r&&this.conditionalVisibilityPaths.add(e),n&&_optionalChain([t, 'access', _25 => _25.conditional, 'optionalAccess', _26 => _26.requiredIf])&&(this.requiredConditionalPaths.add(e),n.forEach(o=>{this.requiredPathsByDependency.has(o)||this.requiredPathsByDependency.set(o,new Set),this.requiredPathsByDependency.get(o).add(e)})),this.requiredEvaluationVersion+=1,this.requiredEvaluationCache.clear(),this.evaluateFieldCondition(e,i),!0}onUnregister(e,t,i){this.hiddenFields.delete(e),this.conditionalVisibilityPaths.delete(e),_optionalChain([i, 'optionalAccess', _27 => _27.preserveIncomingDependents])||this.dependencies.delete(e),this.requiredEvaluationVersion+=1,this.requiredEvaluationCache.clear(),this.requiredConditionalPaths.delete(e),_optionalChain([t, 'optionalAccess', _28 => _28.conditional, 'optionalAccess', _29 => _29.dependsOn, 'optionalAccess', _30 => _30.forEach, 'call', _31 => _31(r=>{let n=this.requiredPathsByDependency.get(r);n&&(n.delete(e),n.size===0&&this.requiredPathsByDependency.delete(r))})]),this.dependencies.forEach(r=>{r.delete(e)})}isHidden(e){return this.hiddenFields.has(e)}hasDependents(e){return(_nullishCoalesce(_optionalChain([this, 'access', _32 => _32.dependencies, 'access', _33 => _33.get, 'call', _34 => _34(e), 'optionalAccess', _35 => _35.size]), () => (0)))>0}isRequired(e,t){let i=this.getFieldConfig(e);if(!i||this.isHidden(e)||!_optionalChain([i, 'access', _36 => _36.conditional, 'optionalAccess', _37 => _37.requiredIf]))return!1;let r=this.requiredEvaluationCache.get(e);if(r&&r.version===this.requiredEvaluationVersion&&r.valuesRef===t)return r.result;let n=!1;try{n=!!i.conditional.requiredIf(t)}catch(o){_optionalChain([this, 'access', _38 => _38.onConditionError, 'optionalCall', _39 => _39({path:e,kind:"requiredIf",error:o})])}return this.requiredEvaluationCache.set(e,{version:this.requiredEvaluationVersion,valuesRef:t,result:n}),n}getRequiredErrors(e){let t={};return this.requiredConditionalPaths.forEach(i=>{let r=this.getFieldConfig(i);if(r&&!this.isHidden(i)&&this.isRequired(i,e)){let n=_chunkFTXV2NZOcjs.f.call(void 0, e,i);this.isEmpty(n)&&(t[i]=_nullishCoalesce(_optionalChain([r, 'access', _40 => _40.conditional, 'optionalAccess', _41 => _41.requiredMessage]), () => ("required field")))}}),t}evaluateAll(e){this.conditionalVisibilityPaths.forEach(t=>{this.evaluateFieldCondition(t,e)})}updateDependencies(e,t,i){let r=new Set,n=new Set,o=new Set,a=[e],l=new Set;for(;a.length>0;){let c=a.shift();if(l.has(c))continue;l.add(c);let p=this.dependencies.get(c);p&&p.forEach(d=>{r.add(d);let u=this.isHidden(d),h=this.isRequired(d,t);this.evaluateFieldCondition(d,i);let f=this.isHidden(d),S=this.isRequired(d,i);u!==f&&n.add(d),h!==S&&o.add(d),a.push(d)})}return{affectedFields:Array.from(r),visibilityChanged:Array.from(n),requiredChanged:Array.from(o)}}evaluateFieldCondition(e,t){let r=_optionalChain([this, 'access', _42 => _42.getFieldConfig, 'call', _43 => _43(e), 'optionalAccess', _44 => _44.conditional, 'optionalAccess', _45 => _45.showIf]);if(r)try{r(t)?this.hiddenFields.delete(e):this.hiddenFields.add(e)}catch(n){_optionalChain([this, 'access', _46 => _46.onConditionError, 'optionalCall', _47 => _47({path:e,kind:"showIf",error:n})])}}wouldCreateCycle(e,t){for(let i of t){let r=[e],n=new Set;for(;r.length>0;){let o=r.shift();if(o===i)return!0;if(n.has(o))continue;n.add(o);let a=this.dependencies.get(o);a&&r.push(...a)}}return!1}isEmpty(e){return e==null||typeof e=="string"&&e.trim()===""||Array.isArray(e)&&e.length===0}}, _class5);var $= (_class6 =class{__init27() {this.catalog=new N}constructor(e){;_class6.prototype.__init27.call(this);this.conditions=new K(t=>this.catalog.get(t),e)}getFieldConfig(e){return this.catalog.get(e)}forEachFieldConfig(e){this.catalog.forEach((t,i)=>e(t,i))}hasFieldConfig(e){return this.catalog.has(e)}getHiddenFields(){return this.conditions.getHiddenFields()}register(e,t,i){let r=this.catalog.get(e);r&&this.conditions.onUnregister(e,r,{preserveIncomingDependents:!0}),this.catalog.set(e,t),!(this.conditions.onRegister(e,t,i)||!r)&&(this.catalog.set(e,r),this.conditions.onRegister(e,r,i))}unregister(e){let t=this.catalog.delete(e);this.conditions.onUnregister(e,t)}unregisterPrefix(e){let t=[],i=F(e);return i.length===0||(this.catalog.forEach((r,n)=>{P(n,i)&&t.push([n,r])}),t.forEach(([r,n])=>{this.catalog.delete(r),this.conditions.onUnregister(r,n)})),t}isHidden(e){return this.conditions.isHidden(e)}hasDependents(e){return this.conditions.hasDependents(e)}isRequired(e,t){return this.conditions.isRequired(e,t)}getRequiredErrors(e){return this.conditions.getRequiredErrors(e)}evaluateAll(e){this.conditions.evaluateAll(e)}updateDependencies(e,t,i){return this.conditions.updateDependencies(e,t,i)}getScopeFields(e,t){return this.catalog.getScopeFields(e,t)}getComputedEntries(e){return this.catalog.getComputedEntries(e)}getTransformEntries(e){return this.catalog.getTransformEntries(e)}getNormalizerEntries(e){return this.catalog.getNormalizerEntries(e)}invalidateIndexes(){this.catalog.invalidateIndexes()}}, _class6);function gi(){return`bit-form-${Math.random().toString(36).slice(2,9)}`}function Me(s){typeof console<"u"&&typeof console.error=="function"&&console.error(s)}function tt(s={}){let e=_nullishCoalesce(s.initialValues, () => ({})),t=s.validation,i=s.history,r=s.name?`bit-form:${s.name}:draft`:"bit-form:draft",n=_nullishCoalesce(s.onUnhandledError, () => (Me)),o=(c,p)=>{try{n(c,p)}catch(d){Me(c),Me(d)}},a=_optionalChain([s, 'access', _48 => _48.persist, 'optionalAccess', _49 => _49.onError]),l={enabled:_nullishCoalesce(_optionalChain([s, 'access', _50 => _50.persist, 'optionalAccess', _51 => _51.enabled]), () => (!1)),key:_nullishCoalesce(_optionalChain([s, 'access', _52 => _52.persist, 'optionalAccess', _53 => _53.key]), () => (r)),storage:_optionalChain([s, 'access', _54 => _54.persist, 'optionalAccess', _55 => _55.storage]),autoSave:_nullishCoalesce(_optionalChain([s, 'access', _56 => _56.persist, 'optionalAccess', _57 => _57.autoSave]), () => (!0)),debounceMs:_nullishCoalesce(_optionalChain([s, 'access', _58 => _58.persist, 'optionalAccess', _59 => _59.debounceMs]), () => (300)),mode:_nullishCoalesce(_optionalChain([s, 'access', _60 => _60.persist, 'optionalAccess', _61 => _61.mode]), () => ("values")),serialize:_nullishCoalesce(_optionalChain([s, 'access', _62 => _62.persist, 'optionalAccess', _63 => _63.serialize]), () => (JSON.stringify)),deserialize:_nullishCoalesce(_optionalChain([s, 'access', _64 => _64.persist, 'optionalAccess', _65 => _65.deserialize]), () => ((c=>JSON.parse(c)))),onError:c=>{if(a){a(c);return}o(c,"persist")}};return{name:s.name,initialValues:_chunkFTXV2NZOcjs.a.call(void 0, e),resolver:_optionalChain([t, 'optionalAccess', _66 => _66.resolver]),validationDelay:_nullishCoalesce(_optionalChain([t, 'optionalAccess', _67 => _67.delay]), () => (300)),history:{enabled:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _68 => _68.enabled]), () => (!1)),limit:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _69 => _69.limit]), () => (50)),debounceMs:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _70 => _70.debounceMs]), () => (300))},fields:s.fields,devTools:s.devTools,persist:l,idFactory:_nullishCoalesce(s.idFactory, () => (gi)),plugins:_nullishCoalesce(s.plugins, () => ([])),scheduler:s.scheduler,subscriptionCacheSize:s.subscriptionCacheSize,trackedSubscriptions:_nullishCoalesce(s.trackedSubscriptions, () => (!1)),bus:s.bus,onUnhandledError:o}}function J(s,e){if((!s||s.length===0)&&(!e||e.length===0))return;let t=new Set(_nullishCoalesce(s, () => ([])));return _optionalChain([e, 'optionalAccess', _71 => _71.forEach, 'call', _72 => _72(i=>t.add(i))]),Array.from(t)}function mi(s){let e=_nullishCoalesce(_optionalChain([s, 'optionalAccess', _73 => _73.includes, 'call', _74 => _74("*")]), () => (!1)),t=new Set(_nullishCoalesce(s, () => ([]))),i=new Set;for(let r of t){i.add(r);let n=r.lastIndexOf(".");for(;n>-1;)i.add(r.slice(0,n)),n=r.lastIndexOf(".",n-1)}return r=>{if(!s||s.length===0||e||t.has(r)||i.has(r))return!0;let n=r.lastIndexOf(".");for(;n>-1;){if(t.has(r.slice(0,n)))return!0;n=r.lastIndexOf(".",n-1)}return!1}}function yi(s,e){if(!e||e.length===0||e.includes("*"))return s;let t=mi(e);return s.filter(i=>i.dependsOn.some(r=>t(r)))}function Si(s){if(s.length<=1)return{orderedEntries:[...s],cyclePaths:[]};let e=new Map(s.map(a=>[a.path,a])),t=new Map,i=new Map,r=new Map(s.map((a,l)=>[a.path,l]));s.forEach(a=>t.set(a.path,0)),s.forEach(a=>{a.dependsOn.forEach(l=>{if(l===a.path||!e.has(l))return;let c=_nullishCoalesce(i.get(l), () => (new Set));c.has(a.path)||(c.add(a.path),i.set(l,c),t.set(a.path,(_nullishCoalesce(t.get(a.path), () => (0)))+1))})});let n=s.filter(a=>(_nullishCoalesce(t.get(a.path), () => (0)))===0).map(a=>a.path),o=[];for(;n.length>0;){n.sort((c,p)=>(_nullishCoalesce(r.get(c), () => (0)))-(_nullishCoalesce(r.get(p), () => (0))));let a=n.shift();o.push(a);let l=i.get(a);l&&l.forEach(c=>{let p=(_nullishCoalesce(t.get(c), () => (0)))-1;t.set(c,p),p===0&&n.push(c)})}if(o.length!==s.length){let a=s.filter(l=>(_nullishCoalesce(t.get(l.path), () => (0)))>0).map(l=>l.path);return{orderedEntries:o.map(l=>e.get(l)),cyclePaths:a}}return{orderedEntries:o.map(a=>e.get(a)),cyclePaths:[]}}function G(s){let{values:e,changedPaths:t,normalizerEntries:i,applyComputed:r,onError:n}=s,o=Si(yi(i,t)),{orderedEntries:a,cyclePaths:l}=o;if(l.length>0&&_optionalChain([n, 'optionalCall', _75 => _75(new Error(`BitStore: cyclic normalizer dependencies detected. Check normalizeDependsOn definitions for: ${l.join(", ")}.`),_nullishCoalesce(l[0], () => ("*")))]),a.length===0)return r(e,t);let c=[],p=e;for(let u of a){let h=_chunkFTXV2NZOcjs.f.call(void 0, p,u.path),f;try{f=u.normalize(h,p)}catch(S){_optionalChain([n, 'optionalCall', _76 => _76(S,u.path)]);continue}_chunkFTXV2NZOcjs.c.call(void 0, h,f)||(c.push([u.path,f]),p=_chunkFTXV2NZOcjs.g.call(void 0, p,u.path,f))}let d=J(t,c.map(([u])=>u));return r(p,d)}function it(s){let{values:e,sourceValues:t,transformEntries:i,onError:r}=s;if(i.length===0)return e;let n=e,o=t;for(let[a,l]of i){let c=_chunkFTXV2NZOcjs.f.call(void 0, n,a),p;try{p=l(c,o)}catch(d){_optionalChain([r, 'optionalCall', _77 => _77(d,a)]);continue}_chunkFTXV2NZOcjs.c.call(void 0, c,p)||(n=_chunkFTXV2NZOcjs.g.call(void 0, n,a,p),o=_chunkFTXV2NZOcjs.g.call(void 0, o,a,p))}return n}var Y=class{constructor(e){this.effects=e.getAll()}attachStorePort(e){this.effects.forEach(t=>_optionalChain([t, 'access', _78 => _78.attachStorePort, 'optionalCall', _79 => _79(e)]))}initialize(){this.effects.forEach(e=>_optionalChain([e, 'access', _80 => _80.initialize, 'optionalCall', _81 => _81()]))}onStateUpdated(e,t){this.effects.forEach(i=>_optionalChain([i, 'access', _82 => _82.onStateUpdated, 'optionalCall', _83 => _83(e,t)]))}async restorePersisted(){let e=!1;for(let t of this.effects)t.restorePersisted&&(e=await t.restorePersisted()||e);return e}async savePersistedNow(){for(let e of this.effects)e.savePersistedNow&&await e.savePersistedNow()}async clearPersisted(){for(let e of this.effects)e.clearPersisted&&await e.clearPersisted()}async beforeValidate(e){for(let t of this.effects)if(t.beforeValidate)try{await t.beforeValidate(e)}catch(i){this.logEffectHookError(t.name,"beforeValidate",i)}}async afterValidate(e){for(let t of this.effects)if(t.afterValidate)try{await t.afterValidate(e)}catch(i){this.logEffectHookError(t.name,"afterValidate",i)}}async beforeSubmit(e){for(let t of this.effects)if(t.beforeSubmit)try{await t.beforeSubmit(e)}catch(i){this.logEffectHookError(t.name,"beforeSubmit",i)}}async afterSubmit(e){for(let t of this.effects)if(t.afterSubmit)try{await t.afterSubmit(e)}catch(i){this.logEffectHookError(t.name,"afterSubmit",i)}}onFieldChange(e){this.effects.forEach(t=>{try{_optionalChain([t, 'access', _84 => _84.onFieldChange, 'optionalCall', _85 => _85(e)])}catch(i){this.logEffectHookError(t.name,"onFieldChange",i)}})}async reportOperationalError(e){for(let t of this.effects)if(t.reportOperationalError)try{await t.reportOperationalError(e)}catch(i){this.logEffectHookError(t.name,"reportOperationalError",i)}}logEffectHookError(e,t,i){console.error(`BitStoreEffectEngine: effect "${e}" failed in hook "${t}"`,i)}destroy(){for(let e=this.effects.length-1;e>=0;e-=1)_optionalChain([this, 'access', _86 => _86.effects, 'access', _87 => _87[e], 'access', _88 => _88.destroy, 'optionalCall', _89 => _89()])}};var X=class{constructor(e,t,i=!0,r){this.storeId=e;this.bus=t;this.enableBusDispatch=i;this.storeBusPort=r}attachStorePort(e){this.storeBusPort=e,this.enableBusDispatch&&(this.bus.stores[this.storeId]=e)}initialize(){!this.enableBusDispatch||!this.storeBusPort||(this.bus.stores[this.storeId]=this.storeBusPort)}onStateUpdated(e){this.enableBusDispatch&&this.bus.dispatch(this.storeId,e)}destroy(){this.enableBusDispatch&&delete this.bus.stores[this.storeId]}};var Q= (_class7 =class{constructor() { _class7.prototype.__init28.call(this); }__init28() {this.effects=new Map}register(e){this.effects.set(e.name,e)}getAll(){return Array.from(this.effects.values())}}, _class7);var Z=class{constructor(e){this.persistManager=e}onStateUpdated(e,t){t&&this.persistManager.queueSave()}restorePersisted(){return this.persistManager.restore()}savePersistedNow(){return this.persistManager.saveNow()}clearPersisted(){return this.persistManager.clear()}destroy(){this.persistManager.destroy()}};var ee=class{constructor(e){this.pluginManager=e}initialize(){this.pluginManager.setupAll()}beforeValidate(e){return this.pluginManager.beforeValidate(e)}afterValidate(e){return this.pluginManager.afterValidate(e)}beforeSubmit(e){return this.pluginManager.beforeSubmit(e)}afterSubmit(e){return this.pluginManager.afterSubmit(e)}onFieldChange(e){this.pluginManager.onFieldChange(e)}reportOperationalError(e){return this.pluginManager.reportError(e.source,e.error,e.payload)}destroy(){this.pluginManager.destroy()}};function bi(){if(typeof globalThis>"u")return;let s;try{s=_nullishCoalesce(globalThis.localStorage, () => (void 0))}catch (e2){return}if(s)return{getItem:e=>s.getItem(e),setItem:(e,t)=>s.setItem(e,t),removeItem:e=>s.removeItem(e)}}var te= (_class8 =class{constructor(e,t,i,r,n={}){;_class8.prototype.__init29.call(this);_class8.prototype.__init30.call(this);this.config=e;this.getValues=t;this.getDirtyValues=i;this.applyRestoredValues=r;this.callbacks=n}__init29() {this.writeQueue=Promise.resolve()}__init30() {this.activeWrites=0}getStorage(){return this.config.storage||bi()}canPersist(){return!!(this.config.enabled&&this.config.key&&this.getStorage())}handleError(e){_optionalChain([this, 'access', _90 => _90.callbacks, 'access', _91 => _91.onError, 'optionalCall', _92 => _92(e)]),_optionalChain([this, 'access', _93 => _93.config, 'access', _94 => _94.onError, 'optionalCall', _95 => _95(e)])}enqueueWriteOperation(e){this.activeWrites+=1;try{this.activeWrites===1&&_optionalChain([this, 'access', _96 => _96.callbacks, 'access', _97 => _97.onWriteStart, 'optionalCall', _98 => _98()])}catch(r){throw this.activeWrites=Math.max(0,this.activeWrites-1),r}let t=this.writeQueue.then(e,e);return this.writeQueue=t.then(()=>{},()=>{}),t.then(()=>({ok:!0,error:void 0}),r=>({ok:!1,error:r})).then(r=>{if(this.activeWrites=Math.max(0,this.activeWrites-1),r.ok){if(this.activeWrites===0)try{_optionalChain([this, 'access', _99 => _99.callbacks, 'access', _100 => _100.onWriteSuccess, 'optionalCall', _101 => _101()])}finally{_optionalChain([this, 'access', _102 => _102.callbacks, 'access', _103 => _103.onWriteSettled, 'optionalCall', _104 => _104()])}return}try{_optionalChain([this, 'access', _105 => _105.callbacks, 'access', _106 => _106.onWriteError, 'optionalCall', _107 => _107(r.error)])}finally{this.activeWrites===0&&_optionalChain([this, 'access', _108 => _108.callbacks, 'access', _109 => _109.onWriteSettled, 'optionalCall', _110 => _110()])}throw r.error})}async persistPayload(){let e=this.getStorage();if(!e)return;let t=this.config.mode==="dirtyValues"?this.getDirtyValues():this.getValues(),i=this.config.serialize(t);await e.setItem(this.config.key,i)}async saveNow(){this.canPersist()&&await this.enqueueWriteOperation(async()=>{try{await this.persistPayload()}catch(e){throw this.handleError(e),e}})}queueSave(){!this.canPersist()||!this.config.autoSave||(this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.saveNow().catch(()=>{})},this.config.debounceMs))}async restore(){if(!this.canPersist())return!1;let e=this.getStorage();if(!e)return!1;try{let t=await e.getItem(this.config.key);if(!t)return!1;let i=this.config.deserialize(t);return!i||typeof i!="object"?!1:(this.applyRestoredValues(i),!0)}catch(t){throw this.handleError(t),t}}async clear(){if(!this.canPersist())return;let e=this.getStorage();e&&await this.enqueueWriteOperation(async()=>{try{await e.removeItem(this.config.key)}catch(t){throw this.handleError(t),t}})}destroy(){this.timer&&(clearTimeout(this.timer),this.timer=void 0)}}, _class8);var ie= (_class9 =class{constructor(e,t){;_class9.prototype.__init31.call(this);_class9.prototype.__init32.call(this);_class9.prototype.__init33.call(this);_class9.prototype.__init34.call(this);this.plugins=e;this.contextFactory=t}__init31() {this.teardownFns=[]}__init32() {this.notifyingError=!1}__init33() {this.pendingErrorQueue=[]}__init34() {this.cachedContext=null}setupAll(){let e=this.getContext();this.plugins.forEach(t=>{if(t.setup)try{let i=t.setup(e);typeof i=="function"&&this.teardownFns.push(i)}catch(i){this.reportError("setup",i,void 0,t.name)}})}async beforeValidate(e){await this.emitHook("beforeValidate",e)}async afterValidate(e){await this.emitHook("afterValidate",e)}async beforeSubmit(e){await this.emitHook("beforeSubmit",e)}async afterSubmit(e){await this.emitHook("afterSubmit",e)}onFieldChange(e){let t=this.getContext();this.plugins.forEach(i=>{let r=_optionalChain([i, 'access', _111 => _111.hooks, 'optionalAccess', _112 => _112.onFieldChange]);if(r)try{let n=r(e,t);Promise.resolve(n).catch(o=>{this.reportError("onFieldChange",o,e,i.name)})}catch(n){this.reportError("onFieldChange",n,e,i.name)}})}async reportError(e,t,i,r){let o=this.getContext().getState();if(this.pendingErrorQueue.push({source:e,pluginName:r,error:t,event:i,values:o.values,state:o}),!this.notifyingError){this.notifyingError=!0;try{for(;this.pendingErrorQueue.length>0;){let a=this.pendingErrorQueue.shift();if(!a)break;for(let l of this.plugins){let c=_optionalChain([l, 'access', _113 => _113.hooks, 'optionalAccess', _114 => _114.onError]);if(c)try{await c(a,this.contextFactory())}catch (e3){}}}}finally{this.notifyingError=!1}}}destroy(){for(let e=this.teardownFns.length-1;e>=0;e-=1){let t=this.teardownFns[e];try{t()}catch(i){this.reportError("teardown",i)}}this.teardownFns=[],this.cachedContext=null}async emitHook(e,t){let i=this.getContext();for(let r of this.plugins){let n=_optionalChain([r, 'access', _115 => _115.hooks, 'optionalAccess', _116 => _116[e]]);if(n)try{await n(t,i)}catch(o){await this.reportError(e,o,t,r.name)}}}getContext(){return this.cachedContext||(this.cachedContext=this.contextFactory()),this.cachedContext}}, _class9);var De=typeof globalThis<"u"?globalThis:typeof global<"u"?global:window;De.__BIT_FORM__||(De.__BIT_FORM__={stores:{},listeners:new Set,dispatch(s,e){this.listeners.forEach(t=>{try{t(s,e)}catch (e4){}})},subscribe(s){return this.listeners.add(s),()=>{this.listeners.delete(s)}}});var ke=De.__BIT_FORM__,vi={stores:{},listeners:new Set,dispatch:()=>{},subscribe:()=>()=>{}};function Re(){return vi}function Bi(){let s=new Set;return{stores:{},listeners:s,dispatch(e,t){s.forEach(i=>{try{i(e,t)}catch (e5){}})},subscribe(e){return s.add(e),()=>s.delete(e)}}}function Ti(s){return s.bus?!0:typeof s.devTools=="boolean"?s.devTools:s.devTools&&typeof s.devTools=="object"?s.devTools.enabled!==!1:!1}function rt(s){let{storeId:e,storeBusPort:t,config:i,getState:r,getConfig:n,getValues:o,getDirtyValues:a,applyPersistedValues:l,setPersistMetadata:c}=s,p=new te(i.persist,o,a,l,{onWriteStart:()=>_optionalChain([c, 'optionalCall', _117 => _117({isSaving:!0,error:null})]),onWriteSuccess:()=>_optionalChain([c, 'optionalCall', _118 => _118({isSaving:!1,error:null})]),onWriteError:B=>_optionalChain([c, 'optionalCall', _119 => _119({error:B instanceof Error?B:new Error(String(B))})]),onWriteSettled:()=>_optionalChain([c, 'optionalCall', _120 => _120({isSaving:!1})]),onError:B=>i.onUnhandledError(B,"persist")}),d=new ie([...i.plugins],()=>({storeId:e,getState:()=>_chunkFTXV2NZOcjs.a.call(void 0, r()),getConfig:()=>_chunkFTXV2NZOcjs.a.call(void 0, n())})),u=Ti(i),h=typeof process<"u"&&typeof process.env<"u"&&process.env.VITEST==="true",f=u?_nullishCoalesce(i.bus, () => ((h?Re():ke))):Re(),S=new Q,g=new Z(p);S.register({name:"persist",onStateUpdated:(B,j)=>g.onStateUpdated(B,j),restorePersisted:()=>g.restorePersisted(),savePersistedNow:()=>g.savePersistedNow(),clearPersisted:()=>g.clearPersisted(),destroy:()=>g.destroy()});let m=new ee(d);S.register({name:"plugins",initialize:()=>m.initialize(),beforeValidate:B=>m.beforeValidate(B),afterValidate:B=>m.afterValidate(B),beforeSubmit:B=>m.beforeSubmit(B),afterSubmit:B=>m.afterSubmit(B),onFieldChange:B=>m.onFieldChange(B),reportOperationalError:B=>m.reportOperationalError(B),destroy:()=>m.destroy()});let T=new X(e,f,u,t);S.register({name:"bus",attachStorePort:B=>T.attachStorePort(B),initialize:()=>T.initialize(),onStateUpdated:B=>T.onStateUpdated(B),destroy:()=>T.destroy()});let C=new Y(S);return C.initialize(),C}function v(s,e,t){return{kind:"state.patch",partialState:s,changedPaths:e,skipComputed:_optionalChain([t, 'optionalAccess', _121 => _121.skipComputed])}}function Oe(s){return{kind:"field.touchMany",paths:s}}function re(s){return{kind:"form.persistMeta",patch:s}}function se(s,e){return{kind:"validation.commit",errors:s,isValid:e}}var st=new WeakMap,nt=new WeakMap;function Pi(s){let{dispatch:e}=s,t=st,i=nt,r=_nullishCoalesce(t.get(e), () => (0));t.set(e,r+1),r===0&&(i.set(e,null),e(re({isRestoring:!0,error:null})))}function Ei(s){let{dispatch:e,error:t}=s,i=st,r=nt,n=_nullishCoalesce(i.get(e), () => (0));if(n<=0)return;let o=n-1;if(t&&r.set(e,t),o>0){i.set(e,o);let l=_nullishCoalesce(r.get(e), () => (null));l&&e(re({error:l}));return}i.delete(e),t||r.set(e,null);let a=_nullishCoalesce(r.get(e), () => (null));r.delete(e),e(re({isRestoring:!1,error:a}))}async function ot(s){let{dispatch:e,effects:t,onUnhandledError:i}=s;Pi({dispatch:e,type:"restoring"});let r=null;try{return await t.restorePersisted()}catch(n){return r=n instanceof Error?n:new Error(String(n)),_optionalChain([i, 'optionalCall', _122 => _122(r,"persist")]),!1}finally{Ei({dispatch:e,type:"restoring",error:r})}}async function at(s){let{effects:e}=s;try{await e.savePersistedNow()}catch (e6){}}async function lt(s){let{effects:e}=s;try{await e.clearPersisted()}catch (e7){}}function dt(s){let{values:e,state:t,initialValues:i,validation:r,fieldRegistry:n,dirtyManager:o,dispatch:a,saveHistorySnapshot:l}=s,c=_chunkFTXV2NZOcjs.a.call(void 0, _chunkFTXV2NZOcjs.b.call(void 0, i,e));r.cancelAll(),n.evaluateAll(c);let p=o.rebuild(c,i);a(v({values:c,errors:{},touched:{},isValidating:{},persist:{...t.persist,error:null},isValid:!1,isDirty:p})),l(),r.validate()}function ct(s){let{state:e,path:t}=s,i=`${t}.`,r={...e.errors},n={...e.touched},o=!1;for(let a of Object.keys(r))(a===t||a.startsWith(i))&&(delete r[a],o=!0);for(let a of Object.keys(n))(a===t||a.startsWith(i))&&(delete n[a],o=!0);return o?{errors:r,touched:n}:null}function ne(s){let e=[],t=new Map,i=new Set(s.map(a=>a.path));for(let a of s)if(t.has(a.path)||t.set(a.path,new Set),a.dependsOn)for(let l of a.dependsOn)i.has(l)&&t.get(a.path).add(l);let r=new Set,n=new Set,o=(a,l)=>{r.add(a),n.add(a),l.push(a);let c=t.get(a)||new Set;for(let p of c)if(r.has(p)){if(n.has(p)){let d=l.indexOf(p),u=[...l.slice(d),p];return{cycle:u,paths:Array.from(t.keys()).filter(h=>u.includes(h)),message:`Circular dependency detected: ${u.join(" \u2192 ")}. Check your computed field definitions.`}}}else{let d=o(p,[...l]);if(d)return d}return n.delete(a),null};for(let a of t.keys())if(!r.has(a)){let l=o(a,[]);l&&!e.some(c=>c.message===l.message)&&e.push(l)}return e}function ut(s){return!!(_optionalChain([s, 'optionalAccess', _123 => _123.computed])||_optionalChain([s, 'optionalAccess', _124 => _124.normalize]))}function pt(s){let{path:e,config:t,state:i,fieldRegistry:r,subscriptions:n,validationCleanupField:o,stateReader:a,invalidateFieldIndexes:l,dispatch:c,getState:p,onUnhandledError:d}=s,u=r.getFieldConfig(e),h=_optionalChain([u, 'optionalAccess', _125 => _125.validation, 'optionalAccess', _126 => _126.asyncValidate]),f=_optionalChain([t, 'access', _127 => _127.validation, 'optionalAccess', _128 => _128.asyncValidate]),S=_nullishCoalesce(_optionalChain([u, 'optionalAccess', _129 => _129.validation, 'optionalAccess', _130 => _130.asyncValidateOn]), () => ("blur")),g=_nullishCoalesce(_optionalChain([t, 'access', _131 => _131.validation, 'optionalAccess', _132 => _132.asyncValidateOn]), () => ("blur"));u&&h&&(f!==h||g!==S)&&o(e);let T=!!(_optionalChain([u, 'optionalAccess', _133 => _133.computed])||t.computed),C=ut(u)||ut(t);if(r.register(e,t,i.values),l(),T){let j=ne(r.getComputedEntries(i.values));if(j.length>0){u?r.register(e,u,i.values):r.unregister(e),l(),n.invalidatePathExpansionCache(e),a.invalidatePath(e),d(new Error(j[0].message),"computed");return}}n.invalidatePathExpansionCache(e),a.invalidatePath(e),C&&c(v({values:i.values},["*"]));let B=p();t.scope&&n.notify(B,[_chunkRHMJPKNVcjs.d.call(void 0, t.scope)]),r.isHidden(e)&&n.notify(B,[e])}function ht(s){let{path:e,state:t,hasStaticConfig:i,fieldRegistry:r,subscriptions:n,validationCleanupField:o,invalidateFieldIndexes:a,dispatch:l}=s;if(i)return;let c=r.getFieldConfig(e);o(e),r.unregister(e),a(),n.invalidatePathExpansionCache(e),_optionalChain([c, 'optionalAccess', _134 => _134.scope])&&n.notify(t,[_chunkRHMJPKNVcjs.d.call(void 0, c.scope)]);let p=ct({state:t,path:e});p&&l(v({errors:p.errors,touched:p.touched}))}function oe(s){let{prefix:e,state:t,fieldRegistry:i,subscriptions:r,validationCleanupPrefix:n,invalidateFieldIndexes:o,dispatch:a,hasStaticConfigPath:l}=s;n(e);let c=F(e),p=_nullishCoalesce(l, () => ((()=>!1))),d=[];i.forEachFieldConfig((m,T)=>{P(T,c)&&(p(T)||d.push(T))});let u=[];d.forEach(m=>{let T=i.getFieldConfig(m);T&&(i.unregister(m),u.push([m,T]))}),o(),r.invalidatePathExpansionCache(e),new Set(u.map(([,m])=>m.scope).filter(m=>!!m)).forEach(m=>{r.notify(t,[_chunkRHMJPKNVcjs.d.call(void 0, m)])});let f={...t.errors},S={...t.touched},g=!1;for(let[m]of u)f[m]&&(delete f[m],g=!0),S[m]&&(delete S[m],g=!0);g&&a(v({errors:f,touched:S}))}var xi="subscription",ae= (_class10 =class{constructor(e,t,i=500){;_class10.prototype.__init35.call(this);_class10.prototype.__init36.call(this);_class10.prototype.__init37.call(this);_class10.prototype.__init38.call(this);_class10.prototype.__init39.call(this);_class10.prototype.__init40.call(this);_class10.prototype.__init41.call(this);_class10.prototype.__init42.call(this);_class10.prototype.__init43.call(this);this.getState=e;if(typeof t=="function"){this.onError=t,this.MAX_PATH_EXPANSION_CACHE_SIZE=i;return}this.MAX_PATH_EXPANSION_CACHE_SIZE=_nullishCoalesce(t, () => (i))}__init35() {this.listeners=new Set}__init36() {this.pathScopedSubscriptions=new Map}__init37() {this.pathSelectorIndex=new Map}__init38() {this.pathExpansionCache=new Map}__init39() {this.subscriptionSeenVersion=new Map}__init40() {this.notifyVersion=0}__init41() {this.cacheHits=0}__init42() {this.cacheMisses=0}__init43() {this.cacheEvictions=0}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}subscribeSelector(e,t,i,r){let n=e(this.getState()),o={notify:l=>{try{let c=e(l);if(r(n,c))return;n=c,t(c)}catch(c){this.reportError(c)}}},a=this.normalizeSubscriptionPaths(i.paths);if(this.pathScopedSubscriptions.set(o,a),a.forEach(l=>{this.forEachIndexPath(l,c=>{let p=_nullishCoalesce(this.pathSelectorIndex.get(c), () => (new Set));p.add(o),this.pathSelectorIndex.set(c,p)})}),i.emitImmediately)try{t(n)}catch(l){this.reportError(l)}return()=>{this.subscriptionSeenVersion.delete(o);let l=this.pathScopedSubscriptions.get(o);l&&(l.forEach(c=>{this.forEachIndexPath(c,p=>{let d=this.pathSelectorIndex.get(p);d&&(d.delete(o),d.size===0&&this.pathSelectorIndex.delete(p))})}),this.pathScopedSubscriptions.delete(o))}}notify(e,t){if(this.listeners.forEach(n=>{try{n()}catch(o){this.reportError(o)}}),this.pathScopedSubscriptions.size===0)return;let i=this.normalizeChangedPathIterable(t);if(i.length===0||i.includes("*")){this.notifyScopedSubscribers(this.pathScopedSubscriptions.keys(),e);return}if(i.length===1&&this.isSimplePath(i[0])){let n=this.collectSubscribersForSingleChangedPath(i[0]);this.notifyScopedSubscribers(n,e);return}let r=this.collectSubscribersForChangedPaths(i);this.notifyScopedSubscribers(r,e)}notifyScopedSubscribers(e,t){for(let i of e)try{i.notify(t)}catch(r){this.reportError(r)}}reportError(e){try{if(this.onError){this.onError(e,xi);return}console.error("Subscription listener error:",e)}catch (e8){}}destroy(){this.listeners.clear(),this.pathScopedSubscriptions.clear(),this.pathSelectorIndex.clear(),this.pathExpansionCache.clear(),this.subscriptionSeenVersion.clear()}getPathExpansionCacheStats(){return{cacheSize:this.pathExpansionCache.size,cacheLimit:this.MAX_PATH_EXPANSION_CACHE_SIZE,cacheHits:this.cacheHits,cacheMisses:this.cacheMisses,cacheEvictions:this.cacheEvictions}}getActiveSubscribersCount(){return this.pathScopedSubscriptions.size}invalidatePathExpansionCache(e){if(!e){this.pathExpansionCache.clear();return}let t=F(e);if(t.length===0){this.pathExpansionCache.clear();return}for(let i of this.pathExpansionCache.keys())(P(i,t)||P(t,i))&&this.pathExpansionCache.delete(i)}normalizeSubscriptionPaths(e){if(!e||e.length===0)return[];let t=new Set,i=[];for(let r of e){let n=r.trim();n.length===0||t.has(n)||(t.add(n),i.push(n))}return i}normalizeChangedPathIterable(e){if(!e)return[];let t=new Set,i=[];for(let r of e){let n=r.trim();n.length===0||t.has(n)||(t.add(n),i.push(n))}return i}collectSubscribersForChangedPaths(e){let t=[];this.notifyVersion=this.notifyVersion+1|0;let i=this.notifyVersion,r=n=>{let o=this.pathSelectorIndex.get(n);o&&o.forEach(a=>{(_nullishCoalesce(this.subscriptionSeenVersion.get(a), () => (Number.NaN)))!==i&&(this.subscriptionSeenVersion.set(a,i),t.push(a))})};return e.forEach(n=>{this.forEachLookupPath(n,r)}),t}collectSubscribersForSingleChangedPath(e){let t=[];this.notifyVersion=this.notifyVersion+1|0;let i=this.notifyVersion,r=n=>{let o=this.pathSelectorIndex.get(n);o&&o.forEach(a=>{(_nullishCoalesce(this.subscriptionSeenVersion.get(a), () => (Number.NaN)))!==i&&(this.subscriptionSeenVersion.set(a,i),t.push(a))})};return this.forEachLookupPath(e,r),t}expandChangedPathForLookup(e){return this.expandPathGeneric(e)}expandPathForIndexing(e){return this.expandPathGeneric(e)}forEachIndexPath(e,t){if(!this.isSimplePath(e)){this.expandPathForIndexing(e).forEach(t);return}let i=e.split("."),r="";for(let n=0;n<i.length;n+=1)r=r?`${r}.${i[n]}`:i[n],t(r)}forEachLookupPath(e,t){if(!this.isSimplePath(e)){this.expandChangedPathForLookup(e).forEach(t);return}t(e);let i=e.lastIndexOf(".");for(;i>-1;)t(e.slice(0,i)),i=e.lastIndexOf(".",i-1)}isSimplePath(e){return!e.includes("*")&&!e.includes("[")&&!e.includes("]")}expandPathGeneric(e){let t=this.pathExpansionCache.get(e);if(t)return this.cacheHits+=1,t;this.cacheMisses+=1;let i=e.split("."),r=[];for(let n=1;n<=i.length;n++)r.push(i.slice(0,n).join("."));return this.setBoundedCacheEntry(this.pathExpansionCache,e,r,this.MAX_PATH_EXPANSION_CACHE_SIZE),r}setBoundedCacheEntry(e,t,i,r){if(e.size>=r){let n=e.keys().next().value;n!==void 0&&(e.delete(n),this.cacheEvictions+=1)}e.set(t,i)}}, _class10);var le= (_class11 =class{constructor(e){;_class11.prototype.__init44.call(this);this.store=e}__init44() {this.pathIds=new Map}getItemIds(e,t){let i=typeof t=="number"?Math.max(0,t):this.getCurrentArrayLength(e);return[...this.ensureIds(e,i)]}pushItem(e,t){this.withPathIds(e,i=>(i.push(this.store.createArrayItemId(e,i.length)),i)),_optionalChain([this, 'access', _135 => _135.store, 'access', _136 => _136.unregisterPrefix, 'optionalCall', _137 => _137(E(e))]),this.mutateArrayWithSetField(e,i=>[...i,t],{origin:"array",operation:"push"})}prependItem(e,t){this.withPathIds(e,r=>(r.unshift(this.store.createArrayItemId(e,0)),r)),_optionalChain([this, 'access', _138 => _138.store, 'access', _139 => _139.unregisterPrefix, 'optionalCall', _140 => _140(E(e))]);let i=_nullishCoalesce(_chunkFTXV2NZOcjs.f.call(void 0, this.store.getState().values,e), () => ([]));this.commitArrayMutationWithFieldPipeline({path:e,nextArray:[t,...i],meta:{origin:"array",operation:"prepend"},reindex:r=>r+1})}insertItem(e,t,i){let r=this.getCurrentArrayLength(e),n=Math.max(0,Math.min(t,r));if(this.withPathIds(e,l=>{let c=[...l];return c.splice(n,0,this.store.createArrayItemId(e,n)),c}),this.store.unregisterPrefix)for(let l=n;l<r;l++)this.store.unregisterPrefix(E(e,l));let a=[..._nullishCoalesce(_chunkFTXV2NZOcjs.f.call(void 0, this.store.getState().values,e), () => ([]))];a.splice(n,0,i),this.commitArrayMutationWithFieldPipeline({path:e,nextArray:a,meta:{origin:"array",operation:"insert",index:n},reindex:l=>l<n?l:l+1})}removeItem(e,t){let i=this.store.getState(),r=_chunkFTXV2NZOcjs.f.call(void 0, i.values,e);if(!Array.isArray(r)||t<0||t>=r.length)return;this.withPathIds(e,o=>{let a=[...o];return a.splice(t,1),a}),this.store.unregisterPrefix&&this.store.unregisterPrefix(E(e,t));let n=r.filter((o,a)=>a!==t);this.commitArrayMutationWithFieldPipeline({path:e,nextArray:n,meta:{origin:"array",operation:"remove",index:t},reindex:o=>o===t?null:o>t?o-1:o})}swapItems(e,t,i){let r=this.store.getState(),n=_chunkFTXV2NZOcjs.f.call(void 0, r.values,e);if(!Array.isArray(n)||t<0||t>=n.length||i<0||i>=n.length)return;this.withPathIds(e,a=>{let l=[...a];return[l[t],l[i]]=[l[i],l[t]],l});let o=[...n];[o[t],o[i]]=[o[i],o[t]],this.store.unregisterPrefix&&(this.store.unregisterPrefix(E(e,t)),this.store.unregisterPrefix(E(e,i))),this.commitArrayMutationWithFieldPipeline({path:e,nextArray:o,meta:{origin:"array",operation:"swap",from:t,to:i},reindex:a=>a===t?i:a===i?t:a})}moveItem(e,t,i){let r=this.store.getState(),n=_chunkFTXV2NZOcjs.f.call(void 0, r.values,e);if(!Array.isArray(n)||t<0||t>=n.length||i<0||i>=n.length)return;this.withPathIds(e,l=>{let c=[...l],[p]=c.splice(t,1);return c.splice(i,0,p),c});let o=[...n],[a]=o.splice(t,1);if(o.splice(i,0,a),this.store.unregisterPrefix){let l=Math.min(t,i),c=Math.max(t,i);for(let p=l;p<=c;p+=1)this.store.unregisterPrefix(E(e,p))}this.commitArrayMutationWithFieldPipeline({path:e,nextArray:o,meta:{origin:"array",operation:"move",from:t,to:i},reindex:l=>l===t?i:t<i&&l>t&&l<=i?l-1:t>i&&l>=i&&l<t?l+1:l})}replaceItems(e,t){_optionalChain([this, 'access', _141 => _141.store, 'access', _142 => _142.unregisterPrefix, 'optionalCall', _143 => _143(E(e))]),t.length===0?this.pathIds.delete(e):this.pathIds.set(e,t.map((i,r)=>this.store.createArrayItemId(e,r))),this.commitArrayMutationWithFieldPipeline({path:e,nextArray:t,meta:{origin:"array",operation:"replace"},reindex:i=>i<t.length?i:null})}clearItems(e){this.pathIds.delete(e),this.store.unregisterPrefix&&this.store.unregisterPrefix(E(e)),this.commitArrayMutationWithFieldPipeline({path:e,nextArray:[],meta:{origin:"array",operation:"clear"},reindex:()=>null})}mutateArrayWithSetField(e,t,i){let r=_chunkFTXV2NZOcjs.f.call(void 0, this.store.getState().values,e)||[];this.store.setFieldWithMeta(e,t(r),i),this.store.internalSaveSnapshot()}withPathIds(e,t){let i=this.getCurrentArrayLength(e),r=this.ensureIds(e,i),n=t(r);n.length===0?this.pathIds.delete(e):this.pathIds.set(e,n)}ensureIds(e,t){let i=_nullishCoalesce(this.pathIds.get(e), () => ([]));if(i.length===t)return i;if(i.length<t){let n=[...i];for(let o=i.length;o<t;o+=1)n.push(this.store.createArrayItemId(e,o));return this.pathIds.set(e,n),n}let r=i.slice(0,t);return r.length===0?this.pathIds.delete(e):this.pathIds.set(e,r),r}getCurrentArrayLength(e){let t=_chunkFTXV2NZOcjs.f.call(void 0, this.store.getState().values,e);return Array.isArray(t)?t.length:0}commitArrayMutationWithFieldPipeline(e){let{path:t,nextArray:i,meta:r,reindex:n}=e,o=this.store.getState();this.store.setFieldWithMeta(t,i,r);let a=_chunkFTXV2NZOcjs.k.call(void 0, o,t,n);_optionalChain([this, 'access', _144 => _144.store, 'access', _145 => _145.remapValidationPaths, 'optionalCall', _146 => _146(t,n)]),this.store.dispatch(v({errors:a.errors,touched:a.touched,isValidating:a.isValidating},[t])),this.store.internalSaveSnapshot()}}, _class11);var de=class{constructor(e,t,i){this.getState=e;this.dispatch=t;this.reportError=i}reportInvalidInput(e,t){_optionalChain([this, 'access', _147 => _147.reportError, 'optionalCall', _148 => _148(new Error(t===void 0?e:`${e}: ${String(t)}`))])}setError(e,t){if(!e||typeof e!="string"){this.reportInvalidInput("setError received an invalid path",e);return}if(t!==void 0&&typeof t!="string"){this.reportInvalidInput("setError received an invalid message",t);return}let i={...this.getState().errors,[e]:t};t===void 0&&delete i[e],this.dispatch(v({errors:i}))}setErrors(e){if(!e||typeof e!="object"){this.reportInvalidInput("setErrors received an invalid payload");return}let t={};Object.entries(e).forEach(([i,r])=>{if(!i){this.reportInvalidInput("setErrors ignored an empty path");return}if(r!==void 0&&typeof r!="string"){this.reportInvalidInput("setErrors ignored a non-string message",i);return}t[i]=r}),this.dispatch(v({errors:{...this.getState().errors,...t}}))}setServerErrors(e,t){let i=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _149 => _149.arrayStrategy]), () => ("first")),r=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _150 => _150.joinSeparator]), () => ("; ")),n={};for(let[o,a]of Object.entries(e)){if(!o){this.reportInvalidInput("setServerErrors ignored an empty path");continue}if(Array.isArray(a)){let l=a.filter(c=>typeof c=="string"&&c.length>0);if(l.length===0)continue;n[o]=i==="join"?l.join(r):l[0];continue}n[o]=a}this.setErrors(n)}};var ce= (_class12 =class{constructor(e,t,i){;_class12.prototype.__init45.call(this);this.fieldMetadataProvider=e;this.getState=t;this.isPathDirty=i}__init45() {this.requiredValuesRef=null}isHidden(e){return this.fieldMetadataProvider.isHidden(e)}isRequired(e){let t=this.getState().values;return this.requiredValuesRef!==t&&(this.requiredValuesRef=t),this.fieldMetadataProvider.isRequired(e,t)}isFieldDirty(e){return this.isPathDirty(e)}isFieldValidating(e){return!!this.getState().isValidating[e]}isTouched(e){return!!this.getState().touched[e]}}, _class12);function ft(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)&&!(s instanceof Date)&&!(s instanceof RegExp)}function gt(s,e){let t=[],i=new Map,r=(n,o,a,l,c)=>{if(!(l&&c&&_chunkFTXV2NZOcjs.d.call(void 0, n,o))){if(n!==null&&typeof n=="object"&&o!==null&&typeof o=="object"){let p=i.get(n);if(_optionalChain([p, 'optionalAccess', _151 => _151.has, 'call', _152 => _152(o)]))return;p?p.add(o):i.set(n,new Set([o]))}try{if(ft(n)&&ft(o)&&l&&c){let p=new Set([...Object.keys(n),...Object.keys(o)]);for(let d of p){let u=a?`${a}.${d}`:d,h=Object.prototype.hasOwnProperty.call(n,d),f=Object.prototype.hasOwnProperty.call(o,d);r(n[d],o[d],u,h,f)}return}t.push({path:a,previousValue:_chunkFTXV2NZOcjs.a.call(void 0, n),nextValue:_chunkFTXV2NZOcjs.a.call(void 0, o),hadPreviousValue:l,hasNextValue:c})}finally{if(n!==null&&typeof n=="object"&&o!==null&&typeof o=="object"){let p=i.get(n);_optionalChain([p, 'optionalAccess', _153 => _153.delete, 'call', _154 => _154(o)]),p&&p.size===0&&i.delete(n)}}}};return r(s,e,"",!0,!0),{operations:t}}function ue(s,e,t){let i=s,r=[],n=[];for(let o of e.operations){let a=t==="undo"?o.hadPreviousValue:o.hasNextValue,l=t==="undo"?o.previousValue:o.nextValue;if(!o.path){i=a?l:{},r.length=0,n.length=0;continue}if(a){r.push([o.path,l]);continue}n.push(o.path)}return r.length>0&&(i=_chunkFTXV2NZOcjs.h.call(void 0, i,r)),n.length>0&&(i=_chunkFTXV2NZOcjs.i.call(void 0, i,n)),i}var pe= (_class13 =class{constructor(e,t){;_class13.prototype.__init46.call(this);_class13.prototype.__init47.call(this);_class13.prototype.__init48.call(this);_class13.prototype.__init49.call(this);_class13.prototype.__init50.call(this);this.enableHistory=e;this.maxHistory=t}__init46() {this.baseSnapshot=null}__init47() {this.currentSnapshot=null}__init48() {this.patches=[]}__init49() {this.historyIndex=-1}__init50() {this.historySize=0}saveSnapshot(e){if(!this.enableHistory)return;if(!this.currentSnapshot||this.baseSnapshot===null){this.reset(e);return}let t=gt(this.currentSnapshot,e);if(t.operations.length!==0)for(this.historyIndex<this.historySize-1&&(this.patches.splice(this.historyIndex),this.historySize=this.historyIndex+1),this.patches.push(t),this.currentSnapshot=e,this.historyIndex+=1,this.historySize=this.historyIndex+1;this.historySize>this.getCapacity();)this.compactOldestSnapshot()}get canUndo(){return this.enableHistory?this.historyIndex>0:!1}get canRedo(){return this.enableHistory?this.historyIndex<this.historySize-1:!1}undo(){if(!this.canUndo||!this.currentSnapshot)return null;let e=this.patches[this.historyIndex-1],t=ue(this.currentSnapshot,e,"undo");return this.currentSnapshot=t,this.historyIndex-=1,t}redo(){if(!this.canRedo||!this.currentSnapshot)return null;let e=this.patches[this.historyIndex],t=ue(this.currentSnapshot,e,"redo");return this.currentSnapshot=t,this.historyIndex+=1,t}reset(e){if(!this.enableHistory){this.baseSnapshot=null,this.currentSnapshot=null,this.patches=[],this.historyIndex=-1,this.historySize=0;return}this.baseSnapshot=_chunkFTXV2NZOcjs.a.call(void 0, e),this.currentSnapshot=this.baseSnapshot,this.patches=[],this.historyIndex=0,this.historySize=1}getMetadata(){return{enabled:this.enableHistory,canUndo:this.canUndo,canRedo:this.canRedo,historyIndex:this.historyIndex,historySize:this.historySize}}compactOldestSnapshot(){let e=this.patches.shift();!e||this.baseSnapshot===null||(this.baseSnapshot=ue(this.baseSnapshot,e,"redo"),this.historySize=Math.max(1,this.historySize-1),this.historyIndex=Math.max(0,this.historyIndex-1))}getCapacity(){return Math.max(1,this.maxHistory)}}, _class13);function je(s,e,t){if(!Object.prototype.hasOwnProperty.call(s,e))return[s,t];let r=s,n=t;return n||(r={...s},n=!0),delete r[e],[r,n]}var M=class{constructor(e){this.steps=e}async run(e){for(let t of this.steps){if(e.halted)break;await t.run(e)}}},he=class{constructor(e){this.steps=e}run(e){for(let t of this.steps){if(e.halted)break;let i=t.run(e);if(i!=null&&typeof i.then=="function")throw new Error(`BitSyncPipelineRunner: step "${t.name}" returned a Promise. Use BitPipelineRunner for async steps.`)}}};var fe=class{constructor(e){this.store=e;this.fieldUpdatePipeline=new he([{name:"field:clear-current-error",run:t=>this.clearCurrentError(t)},{name:"field:update-dependencies",run:t=>this.updateDependencies(t)},{name:"field:update-dirty",run:t=>this.updateDirtyState(t)},{name:"field:commit-state",run:t=>this.commitFieldState(t)},{name:"field:emit-change",run:t=>this.emitFieldChange(t)},{name:"field:trigger-validate",run:t=>this.triggerResolverValidation(t)},{name:"field:trigger-async-validate",run:t=>this.triggerAsyncValidation(t)}])}updateField(e,t,i={origin:"setField"}){let r=this.store.getState(),n=_chunkFTXV2NZOcjs.f.call(void 0, r.values,e),o={path:e,value:t,meta:i,previousValue:n,nextValues:_chunkFTXV2NZOcjs.g.call(void 0, r.values,e,t),nextErrors:r.errors,hasMutatedErrors:!1,dependencyDiff:{affectedFields:[],visibilityChanged:[],requiredChanged:[]},isDirty:!1};this.fieldUpdatePipeline.run(o)}clearCurrentError(e){[e.nextErrors,e.hasMutatedErrors]=je(e.nextErrors,e.path,e.hasMutatedErrors),this.store.clearFieldValidation(e.path)}updateDependencies(e){if(typeof this.store.hasDependentFields=="function"&&!this.store.hasDependentFields(e.path)){e.dependencyDiff.affectedFields.length=0,e.dependencyDiff.visibilityChanged.length=0,e.dependencyDiff.requiredChanged.length=0;return}e.dependencyDiff=this.store.updateDependencies(e.path,this.store.getState().values,e.nextValues),new Set([...e.dependencyDiff.visibilityChanged,...e.dependencyDiff.requiredChanged]).forEach(i=>{[e.nextErrors,e.hasMutatedErrors]=je(e.nextErrors,i,e.hasMutatedErrors),this.store.clearFieldValidation(i)})}updateDirtyState(e){e.isDirty=this.store.updateDirtyForPath(e.path,e.nextValues,this.store.getBaselineValues())}commitFieldState(e){let t=Array.from(new Set([e.path,...e.dependencyDiff.visibilityChanged,...e.dependencyDiff.requiredChanged]));this.store.dispatch(v({values:e.nextValues,errors:e.nextErrors,isDirty:e.isDirty},t))}emitFieldChange(e){this.store.emitFieldChange({path:e.path,previousValue:e.previousValue,nextValue:e.value,values:this.store.getState().values,state:this.store.getState(),meta:e.meta})}triggerResolverValidation(e){let t=Array.from(new Set([e.path,...e.dependencyDiff.visibilityChanged,...e.dependencyDiff.requiredChanged]));(this.store.config.resolver||e.dependencyDiff.visibilityChanged.length>0||e.dependencyDiff.requiredChanged.length>0)&&this.store.triggerValidation(t)}triggerAsyncValidation(e){this.store.isFieldHidden(e.path)||(typeof this.store.getFieldConfig=="function"?_optionalChain([this, 'access', _155 => _155.store, 'access', _156 => _156.getFieldConfig, 'call', _157 => _157(e.path), 'optionalAccess', _158 => _158.validation, 'optionalAccess', _159 => _159.asyncValidateOn]):void 0)!=="change"||this.store.handleFieldAsyncValidation(e.path,e.value)}};var ge= (_class14 =class{constructor() { _class14.prototype.__init51.call(this); }__init51() {this.executors=new Map}register(e,t){let i=_nullishCoalesce(this.executors.get(e), () => ([]));i.push(t),this.executors.set(e,i)}async execute(e){let t=this.getOrderedExecutors(e.kind);for(let i of t)await i.execute(e)}executeSync(e){let t=this.getOrderedExecutors(e.kind);for(let i of t){let r=i.execute(e);if(r&&typeof r.then=="function")throw new Error(`BitLifecycleOrchestrator: executor async em modo sync para kind "${e.kind}".`)}}getOrderedExecutors(e){return[..._nullishCoalesce(this.executors.get(e), () => ([]))].sort((i,r)=>i.phase-r.phase)}}, _class14);var me=class{constructor(e){this.store=e;this.submitPipeline=new M([{name:"submit:start",run:async t=>this.startSubmit(t)},{name:"submit:invalid",run:async t=>this.handleInvalidSubmit(t)},{name:"submit:prepare",run:t=>this.prepareSubmitValues(t)},{name:"submit:before-hooks",run:async t=>this.runBeforeSubmitHooks(t)},{name:"submit:user-handler",run:async t=>this.runSubmitHandler(t)},{name:"submit:after-hooks",run:async t=>this.runAfterSubmitHooks(t)}])}async submit(e){if(this.store.getState().isSubmitting)return{status:"blocked",reason:"isSubmitting"};if(this.store.hasValidationsInProgress())return{status:"blocked",reason:"validating"};this.store.cancelAllValidations();let i={onSuccess:e,isValid:!1,valuesToSubmit:_chunkFTXV2NZOcjs.a.call(void 0, this.store.getState().values),dirtyValues:{}};try{return await this.submitPipeline.run(i),i.invalid?{status:"invalid"}:{status:"submitted"}}catch(r){return i.error=r,await this.store.emitOperationalError({source:"submit",error:r}),await this.store.emitAfterSubmit({values:i.valuesToSubmit,dirtyValues:i.dirtyValues,state:this.store.getState(),success:!1,error:r}),this.store.config.onUnhandledError(r,"submit"),{status:"failed",error:r}}finally{this.store.dispatch(v({isSubmitting:!1}))}}async startSubmit(e){this.store.dispatch(v({isSubmitting:!0})),e.isValid=await this.store.validateNow()}async handleInvalidSubmit(e){if(e.isValid)return;let t=this.store.getState().errors,i={...this.store.getState().touched};Object.keys(t).forEach(r=>{i[r]=!0}),this.store.batchStateUpdates(()=>{this.store.dispatch(v({touched:i}))}),e.dirtyValues=this.store.buildDirtyValues(this.store.getState().values),e.invalid=!0,await this.store.emitAfterSubmit({values:this.store.getState().values,dirtyValues:e.dirtyValues,state:this.store.getState(),success:!1,invalid:!0}),e.halted=!0}prepareSubmitValues(e){let t=[],i=this.store.getHiddenFields();i.forEach(r=>{t.push([r,void 0])}),t.length>0&&(e.valuesToSubmit=_chunkFTXV2NZOcjs.h.call(void 0, e.valuesToSubmit,t)),e.valuesToSubmit=it({values:e.valuesToSubmit,sourceValues:e.valuesToSubmit,transformEntries:this.store.getTransformEntries().filter(([r])=>!i.has(r)),onError:r=>{throw r}}),e.dirtyValues=this.store.buildDirtyValues(e.valuesToSubmit)}async runBeforeSubmitHooks(e){await this.store.emitBeforeSubmit({values:e.valuesToSubmit,dirtyValues:e.dirtyValues,state:this.store.getState()})}async runSubmitHandler(e){try{await e.onSuccess(e.valuesToSubmit,e.dirtyValues)}catch(t){if(_chunkFTXV2NZOcjs.m.call(void 0, t)){this.store.setServerErrors(_chunkFTXV2NZOcjs.n.call(void 0, t)),await this.store.emitAfterSubmit({values:e.valuesToSubmit,dirtyValues:e.dirtyValues,state:this.store.getState(),success:!1,invalid:!0}),e.invalid=!0,e.halted=!0;return}throw t}}async runAfterSubmitHooks(e){await this.store.emitAfterSubmit({values:e.valuesToSubmit,dirtyValues:e.dirtyValues,state:this.store.getState(),success:!0})}};var ye=class{constructor(e){this.store=e}collectChangedUpdates(e,t="",i=[],r=new WeakSet){if(e&&typeof e=="object"){if(r.has(e))return i;r.add(e)}try{Object.entries(e).forEach(([n,o])=>{let a=t?`${t}.${n}`:n;if(o&&typeof o=="object"&&!Array.isArray(o)&&Object.keys(o).length>0){if(r.has(o))return;this.collectChangedUpdates(o,a,i,r);return}i.push([a,o])})}finally{e&&typeof e=="object"&&r.delete(e)}return i}setValues(e,t){if(_optionalChain([t, 'optionalAccess', _160 => _160.rebase])){this.rebaseValues(e);return}if(_optionalChain([t, 'optionalAccess', _161 => _161.partial])){this.hydrateValues(e);return}this.replaceValuesInternal(e,"replaceValues")}hydrateValues(e){let t=this.collectChangedUpdates(e),i=t.map(([n])=>n),r=t.length>0?_chunkFTXV2NZOcjs.h.call(void 0, this.store.getState().values,t):this.store.getState().values;this.replaceValuesInternal(r,"hydrate",i.length>0?i:["*"])}rebaseValues(e){let t=this.store.getState().values,i=_chunkFTXV2NZOcjs.a.call(void 0, e);this.store.setBaselineValues(e),this.store.cancelAllValidations(),this.store.evaluateAllDependencies(i),this.store.clearDirtyState(),this.store.dispatch(v({values:i,errors:{},touched:{},isValidating:{},isValid:!1,isDirty:!1},["*"])),this.store.resetHistory(i),this.store.validateNow().catch(r=>{_optionalChain([this, 'access', _162 => _162.store, 'access', _163 => _163.config, 'optionalAccess', _164 => _164.onUnhandledError, 'call', _165 => _165(r,"rebaseValues")])}),this.store.emitFieldChange({path:"*",previousValue:t,nextValue:i,values:this.store.getState().values,state:this.store.getState(),meta:{origin:"rebase"}})}applyHistoryState(e){this.store.cancelAllValidations();let t=this.store.rebuildDirtyState(e,this.store.getBaselineValues());this.store.dispatch(v({values:e,errors:{},isValid:!1,isDirty:t},["*"])),this.store.validateNow().catch(i=>{_optionalChain([this, 'access', _166 => _166.store, 'access', _167 => _167.config, 'optionalAccess', _168 => _168.onUnhandledError, 'call', _169 => _169(i,"applyHistoryState")])})}reset(){this.store.cancelAllValidations();let e=_chunkFTXV2NZOcjs.a.call(void 0, this.store.getBaselineValues());this.store.evaluateAllDependencies(e),this.store.clearDirtyState(),this.store.dispatch(v({values:e,errors:{},touched:{},isValidating:{},isValid:!1,isDirty:!1},["*"])),this.store.resetHistory(e)}replaceValuesInternal(e,t="replaceValues",i=["*"]){let r=this.store.getState().values,n=_chunkFTXV2NZOcjs.a.call(void 0, e);this.store.cancelAllValidations(),this.store.evaluateAllDependencies(n);let o=this.store.rebuildDirtyState(n,this.store.getBaselineValues());this.store.dispatch(v({values:n,errors:{},isValidating:{},isValid:!1,isDirty:o},i)),this.store.internalSaveSnapshot(),this.store.validateNow().catch(a=>{_optionalChain([this, 'access', _170 => _170.store, 'access', _171 => _171.config, 'optionalAccess', _172 => _172.onUnhandledError, 'call', _173 => _173(a,"replaceValuesInternal")])}),this.store.emitFieldChange({path:"*",previousValue:r,nextValue:n,values:this.store.getState().values,state:this.store.getState(),meta:{origin:t}})}};var Se= (_class15 =class{constructor(e){;_class15.prototype.__init52.call(this);this.ports=e;this.fieldUpdate=new fe(e.fieldUpdate),this.values=new ye(e.values),this.submitFlow=new me(e.submit),this.orchestrator.register("updateField",{phase:1,execute:t=>this.fieldUpdate.updateField(t.path,t.value,_nullishCoalesce(t.meta, () => ({origin:"setField"})))}),this.orchestrator.register("setValues",{phase:2,execute:t=>this.values.setValues(t.newValues,t.options)}),this.orchestrator.register("hydrateValues",{phase:2,execute:t=>this.values.hydrateValues(t.newValues)}),this.orchestrator.register("rebaseValues",{phase:2,execute:t=>this.values.rebaseValues(t.newValues)}),this.orchestrator.register("applyHistoryState",{phase:2,execute:t=>this.values.applyHistoryState(t.snapshot)}),this.orchestrator.register("submit",{phase:3,execute:async t=>{t.submitResult=await this.submitFlow.submit(t.onSuccess)}}),this.orchestrator.register("reset",{phase:4,execute:()=>this.values.reset()})}__init52() {this.orchestrator=new ge}updateField(e,t,i={origin:"setField"}){this.orchestrator.executeSync({kind:"updateField",path:e,value:t,meta:i})}setValues(e,t){this.orchestrator.executeSync({kind:"setValues",newValues:e,options:t})}hydrateValues(e){this.orchestrator.executeSync({kind:"hydrateValues",newValues:e})}rebaseValues(e){this.orchestrator.executeSync({kind:"rebaseValues",newValues:e})}applyHistoryState(e){this.orchestrator.executeSync({kind:"applyHistoryState",snapshot:e})}async submit(e){let t={kind:"submit",onSuccess:e};return await this.orchestrator.execute(t),t.submitResult}reset(){this.orchestrator.executeSync({kind:"reset"})}}, _class15);var be=class{constructor(e,t,i,r){this.getState=e;this.getInitialValues=t;this.getScopeFields=i;this.isPathDirty=r}getScopeStatus(e){let t=this.getScopeFields(e),i=this.getState(),r=t.some(a=>!!i.errors[a]),n=t.some(a=>this.isPathDirty(a)),o=this.getScopeErrors(e);return{hasErrors:r,isDirty:n,errors:o}}getScopeErrors(e){let t=this.getScopeFields(e),i=this.getState(),r={};for(let n of t){let o=i.errors[n];o&&(r[n]=o)}return r}};var mt=Symbol("bit.async.validation.timeout"),ve= (_class16 =class{constructor(e){;_class16.prototype.__init53.call(this);_class16.prototype.__init54.call(this);this.port=e}__init53() {this.abortControllers=new Map}__init54() {this.pendingJobs=new Map}handle(e,t,i,r,n){if(!i){this.cancel(e),this.port.setFieldValidating(e,!1);return}this.cancel(e),this.port.clearAsyncError(e),this.port.setFieldValidating(e,!0);let o=new AbortController;this.abortControllers.set(e,o),this.pendingJobs.set(e,{value:t,dueAt:Date.now()+r,validate:i,controller:o,timeoutMs:n}),this.schedulePendingJobs()}cancel(e){this.cancelInternal(e,!0)}cancelInternal(e,t){this.pendingJobs.has(e)&&(this.pendingJobs.delete(e),t&&this.schedulePendingJobs());let i=this.abortControllers.get(e);i&&(i.abort(),this.abortControllers.delete(e))}cleanupPrefix(e){let t=!1,i=new Set([...this.pendingJobs.keys(),...this.abortControllers.keys()]);for(let r of i)P(r,e)&&(this.cancelInternal(r,!1),t=!0,this.port.clearAsyncError(r),this.port.setFieldValidating(r,!1));t&&this.schedulePendingJobs()}remapPaths(e){let t=!1,i=new Map;for(let[n,o]of this.pendingJobs.entries()){let a=e(n);if(!a){o.controller.abort(),t=!0;continue}a!==n&&(t=!0),i.set(a,o)}let r=new Map;for(let[n,o]of this.abortControllers.entries()){let a=e(n);if(!a){o.abort();continue}r.set(a,o)}this.pendingJobs.clear(),i.forEach((n,o)=>{this.pendingJobs.set(o,n)}),this.abortControllers.clear(),r.forEach((n,o)=>{this.abortControllers.set(o,n)}),t&&this.schedulePendingJobs()}cancelAll(){if(this.cancelSchedulerTimeout)try{this.cancelSchedulerTimeout()}catch (e9){}finally{this.cancelSchedulerTimeout=void 0}this.abortControllers.forEach((e,t)=>{try{e.abort()}catch (e10){}this.port.setFieldValidating(t,!1)}),this.pendingJobs.forEach((e,t)=>{this.port.setFieldValidating(t,!1)}),this.pendingJobs.clear(),this.abortControllers.clear()}schedulePendingJobs(){this.cancelSchedulerTimeout&&(this.cancelSchedulerTimeout(),this.cancelSchedulerTimeout=void 0);let e=Number.POSITIVE_INFINITY;for(let t of this.pendingJobs.values())t.dueAt<e&&(e=t.dueAt);Number.isFinite(e)&&(this.cancelSchedulerTimeout=this.port.schedule(()=>{this.cancelSchedulerTimeout=void 0,this.flushPendingJobs().catch(t=>{this.port.onError(t)})},Math.max(0,e-Date.now())))}async flushPendingJobs(){this.cancelSchedulerTimeout=void 0;let e=Date.now(),t=[];for(let[r,n]of this.pendingJobs.entries())n.dueAt<=e&&t.push([r,n]);if(t.length===0){this.schedulePendingJobs();return}t.forEach(([r])=>{this.pendingJobs.delete(r)});let i=await Promise.allSettled(t.map(([r,n])=>this.runJob(r,n)));for(let r of i)r.status==="rejected"&&this.port.onError(r.reason);this.schedulePendingJobs()}async runJob(e,t){if(!t.controller.signal.aborted)try{let i=t.validate(t.value,this.port.getValues());if(typeof t.timeoutMs=="number"&&t.timeoutMs>0){let o;i=Promise.race([i,new Promise(a=>{o=setTimeout(()=>a(mt),t.timeoutMs)})]).finally(()=>{o&&clearTimeout(o)})}let r=await i;if(t.controller.signal.aborted)return;let n=_chunkFTXV2NZOcjs.f.call(void 0, this.port.getValues(),e);if(!_chunkFTXV2NZOcjs.c.call(void 0, n,t.value)||r===mt)return;r!=null?this.port.setAsyncError(e,r):(this.port.clearAsyncError(e),await this.port.onValidationPassed(e))}finally{let i=_nullishCoalesce(this.findControllerPath(t.controller), () => (e));t.controller.signal.aborted||this.port.setFieldValidating(i,!1),this.abortControllers.get(i)===t.controller&&this.abortControllers.delete(i)}}findControllerPath(e){for(let[t,i]of this.abortControllers.entries())if(i===e)return t}}, _class16);function D(s){for(let e in s)if(s[e]!==void 0)return!0;return!1}async function He(s){let{scopeFields:e,store:t,asyncErrors:i}=s,r=t.getState(),n=new Set(t.getHiddenFields()),o=t.config.resolver?await t.config.resolver(r.values,{scopeFields:e}):{},a=t.getState(),l=e.some(f=>_chunkFTXV2NZOcjs.f.call(void 0, r.values,f)!==_chunkFTXV2NZOcjs.f.call(void 0, a.values,f)),c=t.getHiddenFields(),p=e.some(f=>n.has(f)!==c.has(f));if(l||p)return;let d=t.getRequiredErrors(a.values),u={...o,...d};c.forEach(f=>{delete u[f]});let h={...a.errors};e.forEach(f=>{u[f]?h[f]=u[f]:i.has(f)?h[f]=i.get(f):delete h[f]}),t.dispatch(se(h,!D(h)))}var Be= (_class17 =class{constructor() { _class17.prototype.__init55.call(this);_class17.prototype.__init56.call(this); }__init55() {this.currentValidationId=0}__init56() {this.immediateAbortControllers=new Map}beginValidation(){return this.currentValidationId+=1,this.currentValidationId}getCurrentValidationId(){return this.currentValidationId}isValidationCurrent(e){return e===this.currentValidationId}setImmediateController(e,t){this.immediateAbortControllers.set(e,t)}clearImmediateController(e,t){return this.immediateAbortControllers.get(e)===t?(this.immediateAbortControllers.delete(e),!0):!1}cancelImmediate(e){let t=this.immediateAbortControllers.get(e);t&&(t.abort(),this.immediateAbortControllers.delete(e))}cancelImmediatePrefix(e,t){for(let i of this.immediateAbortControllers.keys())P(i,e)&&(this.cancelImmediate(i),t(i))}remapImmediateControllers(e){let t=new Map;for(let[i,r]of this.immediateAbortControllers.entries()){let n=e(i);if(!n){r.abort();continue}t.set(n,r)}this.immediateAbortControllers.clear(),t.forEach((i,r)=>{this.immediateAbortControllers.set(r,i)})}cancelAllImmediate(){this.immediateAbortControllers.forEach(e=>{e.abort()}),this.immediateAbortControllers.clear()}}, _class17);var Te= (_class18 =class{constructor(e){;_class18.prototype.__init57.call(this);_class18.prototype.__init58.call(this);this.port=e}__init57() {this.pendingScopeFields=null}__init58() {this.isGlobalPending=!1}trigger(e,t){this.cancelTimeout&&(this.cancelTimeout(),this.cancelTimeout=void 0);let i=_nullishCoalesce(this.port.validationDelay, () => (300)),r=_optionalChain([t, 'optionalAccess', _174 => _174.forceDebounce])?Math.max(1,i):i;if(r>0){if(!e||e.length===0)this.pendingScopeFields=null,this.isGlobalPending=!0;else if(!this.isGlobalPending)if(!this.pendingScopeFields)this.pendingScopeFields=new Set(e);else for(let n of e)this.pendingScopeFields.add(n);this.cancelTimeout=this.port.schedule(()=>{let n=this.pendingScopeFields?Array.from(this.pendingScopeFields):void 0;this.pendingScopeFields=null,this.isGlobalPending=!1,this.cancelTimeout=void 0,this.validateWithOptionalScopeFields(n)},r)}else{let n=e;if(this.isGlobalPending)n=void 0;else if(this.pendingScopeFields){if(e)for(let o of e)this.pendingScopeFields.add(o);n=Array.from(this.pendingScopeFields)}this.pendingScopeFields=null,this.isGlobalPending=!1,this.validateWithOptionalScopeFields(n)}}validateWithOptionalScopeFields(e){return e&&e.length>0?this.port.validate({scopeFields:e}):this.port.validate()}cancelPending(){this.cancelTimeout&&(this.cancelTimeout(),this.cancelTimeout=void 0),this.pendingScopeFields=null,this.isGlobalPending=!1}}, _class18);var yt=Symbol("bit.async.validation.timeout");function St(s){let{targetFields:e,currentErrors:t,allErrors:i,asyncErrors:r,hiddenFields:n}=s;if(e&&e.length>0){let a=t,l=!1,c=()=>(l||(a={...t},l=!0),a);e.forEach(d=>{let u=d,h=t[u];if(_optionalChain([n, 'optionalAccess', _175 => _175.has, 'call', _176 => _176(d)])){h!==void 0&&delete c()[u];return}if(i[d]!==void 0)h!==i[d]&&(c()[u]=i[d]);else if(r.has(d)){let f=r.get(d);h!==f&&(c()[u]=f)}else h!==void 0&&delete c()[u]});let p=e.every(d=>_optionalChain([n, 'optionalAccess', _177 => _177.has, 'call', _178 => _178(d)])||i[d]===void 0&&!r.has(d));return{committedErrors:l?a:t,result:p,mode:"scoped"}}let o={};return r.forEach((a,l)=>{_optionalChain([n, 'optionalAccess', _179 => _179.has, 'call', _180 => _180(l)])||(o[l]=a)}),Object.entries(i).forEach(([a,l])=>{l!==void 0&&(o[a]=l)}),{committedErrors:o,result:void 0,mode:"global"}}function bt(s){let{targetFields:e,hiddenFields:t,getFieldConfig:i,forEachFieldConfig:r}=s,n=[];if(e&&e.length>0){for(let o of e){if(t.has(o))continue;_optionalChain([i, 'call', _181 => _181(o), 'optionalAccess', _182 => _182.validation, 'optionalAccess', _183 => _183.asyncValidate])&&n.push(o)}return n}return r&&r((o,a)=>{!_optionalChain([o, 'access', _184 => _184.validation, 'optionalAccess', _185 => _185.asyncValidate])||t.has(a)||n.push(a)}),n}async function vt(s){let{path:e,values:t,validationId:i,getCurrentValidationId:r,getFieldConfig:n,cancelFieldAsync:o,createAbortController:a,setAbortController:l,clearAbortController:c,setFieldValidating:p,setAsyncError:d,clearAsyncError:u}=s,h=_optionalChain([n, 'call', _186 => _186(e), 'optionalAccess', _187 => _187.validation, 'optionalAccess', _188 => _188.asyncValidate]);if(!h){u(e);return}o(e),u(e);let f=a();l(e,f),p(e,!0);try{let S=_optionalChain([n, 'call', _189 => _189(e), 'optionalAccess', _190 => _190.validation, 'optionalAccess', _191 => _191.asyncValidateTimeout]),g=h(_chunkFTXV2NZOcjs.f.call(void 0, t,e),t);if(typeof S=="number"&&S>0){let T;g=Promise.race([g,new Promise(C=>{T=setTimeout(()=>C(yt),S)})]).finally(()=>{T&&clearTimeout(T)})}let m=await g;if(f.signal.aborted||i!==r())return;m===yt||(m!=null?d(e,m):u(e))}finally{c(e,f)&&p(e,!1)}}function Bt(s){let{ctx:e,deps:t}=s,i=e.options;if(_optionalChain([i, 'optionalAccess', _192 => _192.scope])&&_optionalChain([i, 'access', _193 => _193.scopeFields, 'optionalAccess', _194 => _194.length])){t.store.config.onUnhandledError(new Error("validate received both 'scope' and 'scopeFields'. 'scopeFields' takes precedence."),"validation");return}if(!_optionalChain([e, 'access', _195 => _195.options, 'optionalAccess', _196 => _196.scopeFields, 'optionalAccess', _197 => _197.length])&&_optionalChain([e, 'access', _198 => _198.options, 'optionalAccess', _199 => _199.scope])){let r=t.store.getScopeFields(e.options.scope);r.length>0&&(e.targetFields=r)}}async function Tt(s){let{ctx:e,deps:t}=s;await t.store.emitBeforeValidate({values:e.currentState.values,state:e.currentState,scope:_optionalChain([e, 'access', _200 => _200.options, 'optionalAccess', _201 => _201.scope]),scopeFields:e.targetFields})}async function Pt(s){let{ctx:e,deps:t}=s,i=t.store.config.resolver?await t.store.config.resolver(e.currentState.values,{scopeFields:e.targetFields}):{},r=t.store.getRequiredErrors(e.currentState.values);e.allErrors={...i,...r},t.store.getHiddenFields().forEach(n=>{delete e.allErrors[n]})}async function Et(s){let{ctx:e,deps:t}=s,i=bt({targetFields:e.targetFields,hiddenFields:t.store.getHiddenFields(),getFieldConfig:n=>t.store.getFieldConfig(n),forEachFieldConfig:t.store.forEachFieldConfig});if(i.length===0)return;let r=await Promise.allSettled(i.map(n=>t.runImmediateAsyncValidation(n,e.currentState.values,e.validationId)));for(let n of r)n.status==="rejected"&&t.store.config.onUnhandledError(n.reason,"validation")}function xt(s){let{ctx:e,deps:t}=s,i=St({targetFields:e.targetFields,currentErrors:e.currentState.errors,allErrors:e.allErrors,asyncErrors:t.asyncErrors,hiddenFields:t.store.getHiddenFields()});e.committedErrors=i.committedErrors,e.isValid=!D(i.committedErrors),e.result=i.mode==="scoped"?i.result:e.isValid}async function Ue(s){let{ctx:e,deps:t}=s;e.validationId!==t.getCurrentValidationId()&&(e.aborted=!0,e.result=t.store.getState().isValid,e.halted=!0)}async function Ct(s){let{ctx:e,deps:t}=s;t.store.dispatch(se(e.committedErrors,e.isValid)),await t.store.emitAfterValidate({values:t.store.getState().values,state:t.store.getState(),scope:_optionalChain([e, 'access', _202 => _202.options, 'optionalAccess', _203 => _203.scope]),scopeFields:e.targetFields,errors:e.committedErrors,result:e.result}),e.halted=!0}var Pe=class{constructor(e){this.deps=e;this.runner=new M([{name:"validate:resolve-target-fields",run:t=>Bt({ctx:t,deps:this.deps})},{name:"validate:before-hooks",run:async t=>Tt({ctx:t,deps:this.deps})},{name:"validate:sync-track",run:async t=>Pt({ctx:t,deps:this.deps})},{name:"validate:abort-check-pre-async",run:async t=>Ue({ctx:t,deps:this.deps})},{name:"validate:async-track",run:async t=>Et({ctx:t,deps:this.deps})},{name:"validate:abort-check",run:async t=>Ue({ctx:t,deps:this.deps})},{name:"validate:async-track-merge",run:t=>xt({ctx:t,deps:this.deps})},{name:"validate:commit",run:async t=>Ct({ctx:t,deps:this.deps})}])}async run(e){await this.runner.run(e)}};var Ee= (_class19 =class{constructor(e){;_class19.prototype.__init59.call(this);_class19.prototype.__init60.call(this);_class19.prototype.__init61.call(this);this.store=e;this.schedule=_nullishCoalesce(_optionalChain([e, 'access', _204 => _204.config, 'access', _205 => _205.scheduler, 'optionalAccess', _206 => _206.schedule]), () => (((i,r)=>{let n=setTimeout(i,r);return()=>clearTimeout(n)}))),this.debouncer=new Te({schedule:(i,r)=>this.schedule(i,r),validate:i=>this.validate(i),validationDelay:_nullishCoalesce(e.config.validationDelay, () => (300))}),this.pipelineStore={getState:()=>this.store.getState(),dispatch:i=>this.store.dispatch(i),config:this.store.config,getFieldConfig:i=>this.store.getFieldConfig(i),forEachFieldConfig:i=>this.store.forEachFieldConfig(i),getScopeFields:i=>this.store.getScopeFields(i),getRequiredErrors:i=>this.store.getRequiredErrors(i),getHiddenFields:()=>this.store.getHiddenFields(),emitBeforeValidate:i=>this.store.emitBeforeValidate(i),emitAfterValidate:i=>this.store.emitAfterValidate(i)},this.asyncScheduler=new ve({schedule:(i,r)=>this.schedule(i,r),getValues:()=>this.store.getState().values,setFieldValidating:(i,r)=>this.updateFieldValidating(i,r),setAsyncError:(i,r)=>{this.asyncErrors.set(i,r),this.store.setError(i,r)},clearAsyncError:i=>{let r=this.asyncErrors.get(i);this.asyncErrors.delete(i),r&&!this.store.config.resolver&&this.store.getState().errors[i]===r&&this.store.setError(i,void 0),He({scopeFields:[i],store:this.pipelineStore,asyncErrors:this.asyncErrors}).catch(n=>{this.store.config.onUnhandledError(n,"validation")})},onValidationPassed:async i=>{await He({scopeFields:[i],store:this.pipelineStore,asyncErrors:this.asyncErrors})},onError:i=>{this.store.config.onUnhandledError(i,"validation")}});let t={store:this.pipelineStore,asyncErrors:this.asyncErrors,getCurrentValidationId:()=>this.coordinator.getCurrentValidationId(),runImmediateAsyncValidation:(i,r,n)=>this.runImmediateAsyncValidation(i,r,n)};this.validationPipeline=new Pe(t)}__init59() {this.validatingCount=0}__init60() {this.asyncErrors=new Map}__init61() {this.coordinator=new Be}updateFieldValidating(e,t){let i=this.store.getState();if(!!i.isValidating[e]===t)return;let n={...i.isValidating};t?(n[e]=!0,this.validatingCount+=1):(delete n[e],this.validatingCount=Math.max(0,this.validatingCount-1)),this.store.dispatch(v({isValidating:n}))}cancelFieldAsync(e){this.asyncScheduler.cancel(e),this.coordinator.cancelImmediate(e)}cleanupField(e){this.cancelFieldAsync(e),this.asyncErrors.delete(e),this.updateFieldValidating(e,!1)}cleanupPrefix(e){this.asyncScheduler.cleanupPrefix(e),this.coordinator.cancelImmediatePrefix(e,t=>{this.asyncErrors.delete(t),this.updateFieldValidating(t,!1)})}remapArrayPaths(e,t){let i=`${e}.`;this.asyncScheduler.remapPaths(n=>_chunkFTXV2NZOcjs.l.call(void 0, n,i,t)),this.coordinator.remapImmediateControllers(n=>_chunkFTXV2NZOcjs.l.call(void 0, n,i,t));let r=new Map;this.asyncErrors.forEach((n,o)=>{let a=_chunkFTXV2NZOcjs.l.call(void 0, o,i,t);a!==null&&r.set(a,n)}),this.asyncErrors.clear(),r.forEach((n,o)=>{this.asyncErrors.set(o,n)})}beginExternalValidation(e){this.cancelFieldAsync(e),this.updateFieldValidating(e,!0)}endExternalValidation(e){this.updateFieldValidating(e,!1)}async setExternalError(e,t){if(t){this.asyncErrors.set(e,t),this.store.setError(e,t);return}this.cancelFieldAsync(e),this.asyncErrors.delete(e),this.store.setError(e,void 0),await this.validate({scopeFields:[e]})}handleAsync(e,t){let i=this.store.getFieldConfig(e),r=_optionalChain([i, 'optionalAccess', _207 => _207.validation, 'optionalAccess', _208 => _208.asyncValidate]),n=_nullishCoalesce(_optionalChain([i, 'optionalAccess', _209 => _209.validation, 'optionalAccess', _210 => _210.asyncValidateOn]), () => ("blur"));if(!r||n!=="change"){this.cancelFieldAsync(e),this.updateFieldValidating(e,!1);return}let o=_nullishCoalesce(_optionalChain([i, 'access', _211 => _211.validation, 'optionalAccess', _212 => _212.asyncValidateDelay]), () => (500)),a=_optionalChain([i, 'access', _213 => _213.validation, 'optionalAccess', _214 => _214.asyncValidateTimeout]);this.asyncScheduler.handle(e,t,r,o,a)}hasValidationsInProgress(e){let t=this.store.getState();return e&&e.length>0?e.some(i=>!!t.isValidating[i]):Object.keys(t.isValidating).length>0}trigger(e,t){this.debouncer.trigger(e,t)}async validate(e){try{_optionalChain([e, 'optionalAccess', _215 => _215.scopeFields, 'optionalAccess', _216 => _216.length])&&e.scopeFields.forEach(i=>{this.cancelFieldAsync(i),this.updateFieldValidating(i,!1)});let t={options:e,validationId:this.coordinator.beginValidation(),currentState:this.store.getState(),targetFields:_optionalChain([e, 'optionalAccess', _217 => _217.scopeFields]),allErrors:{},committedErrors:{},isValid:!0,result:!0,aborted:!1};if(await this.validationPipeline.run(t),t.aborted){let i=this.store.getState();await this.store.emitAfterValidate({values:i.values,state:i,scope:_optionalChain([t, 'access', _218 => _218.options, 'optionalAccess', _219 => _219.scope]),scopeFields:t.targetFields,errors:i.errors,result:i.isValid,aborted:!0})}return t.result}catch(t){return this.store.config.onUnhandledError(t,"validation"),!1}}clear(e){this.cancelFieldAsync(e),this.updateFieldValidating(e,!1),this.asyncErrors.delete(e)}cancelAll(){this.validatingCount=0,this.debouncer.cancelPending(),this.asyncScheduler.cancelAll(),this.asyncErrors.clear(),this.coordinator.cancelAllImmediate(),this.store.dispatch(v({isValidating:{}}))}async runImmediateAsyncValidation(e,t,i){await vt({path:e,values:t,validationId:i,getCurrentValidationId:()=>this.coordinator.getCurrentValidationId(),getFieldConfig:r=>this.store.getFieldConfig(r),cancelFieldAsync:r=>this.cancelFieldAsync(r),createAbortController:()=>new AbortController,setAbortController:(r,n)=>{this.coordinator.setImmediateController(r,n)},clearAbortController:(r,n)=>this.coordinator.clearImmediateController(r,n),setFieldValidating:(r,n)=>this.updateFieldValidating(r,n),setAsyncError:(r,n)=>{this.asyncErrors.set(r,n)},clearAsyncError:r=>{this.asyncErrors.delete(r)}})}}, _class19);var ze= (_class20 =class{constructor() { _class20.prototype.__init62.call(this); }__init62() {this.entries=new Map}register(e,t){this.entries.set(e,t)}resolve(e){let t=this.entries.get(e);if(!t)throw new Error(`BitStore capability "${String(e)}" n\xE3o foi registrada.`);return t}toCapabilities(){return{validation:this.resolve("validation"),lifecycle:this.resolve("lifecycle"),history:this.resolve("history"),arrays:this.resolve("arrays"),scope:this.resolve("scope"),query:this.resolve("query"),error:this.resolve("error")}}}, _class20);function Vt(){return new ze}function Ci(s){let{registry:e,ports:t,fieldRegistry:i}=s;e.register("validation",new Ee(t.validationPort)),e.register("lifecycle",new Se(t.lifecyclePorts)),e.register("history",new pe(!!t.config.history.enabled,_nullishCoalesce(t.config.history.limit, () => (50)))),e.register("arrays",new le(t.arrayPort)),e.register("scope",new be(()=>t.getState(),()=>t.getBaselineValues(),r=>t.getScopeFields(r),r=>t.isPathDirty(r))),e.register("query",new ce(i,()=>t.getState(),r=>t.isPathDirty(r))),e.register("error",new de(()=>t.getState(),r=>t.dispatch(r),r=>t.config.onUnhandledError(r,"errors")))}function Ft(s){let{ports:e,fieldRegistry:t}=s,i=Vt();return Ci({registry:i,ports:e,fieldRegistry:t}),{registry:i,capabilities:i.toCapabilities()}}function wt(s){let{config:e,fieldRegistry:t,computedManager:i}=s,r=_chunkFTXV2NZOcjs.a.call(void 0, e.initialValues);e.fields&&Object.entries(e.fields).forEach(([a,l])=>{t.register(a,l,r)});let n=ne(t.getComputedEntries(r));if(n.length>0)throw new Error(n[0].message);return{values:G({values:r,normalizerEntries:t.getNormalizerEntries(r),applyComputed:(a,l)=>i.apply(a,l),onError:(a,l)=>{e.onUnhandledError(a,"derivation")}}),errors:{},touched:{},isValidating:{},persist:{isSaving:!1,isRestoring:!1,error:null},isValid:!0,isSubmitting:!1,isDirty:!1}}function At(s){return{getState:s.getState,dispatch:s.dispatch,setError:s.setError,getFieldConfig:s.getFieldConfig,forEachFieldConfig:e=>s.fieldRegistry.forEachFieldConfig((t,i)=>e(t,i)),getScopeFields:s.getScopeFields,config:s.config,getRequiredErrors:e=>s.fieldRegistry.getRequiredErrors(e),getHiddenFields:()=>s.fieldRegistry.getHiddenFields(),emitBeforeValidate:e=>s.getEffects().beforeValidate(e),emitAfterValidate:e=>s.getEffects().afterValidate(e)}}function It(s){let e={getState:s.getState,dispatch:s.dispatch,config:s.config,getFieldConfig:r=>s.fieldRegistry.getFieldConfig(r),updateDependencies:(r,n,o)=>s.fieldRegistry.updateDependencies(r,n,o),hasDependentFields:r=>s.fieldRegistry.hasDependents(r),isFieldHidden:r=>s.fieldRegistry.isHidden(r),clearFieldValidation:r=>s.getValidation().clear(r),triggerValidation:(r,n)=>s.getValidation().trigger(r,n),handleFieldAsyncValidation:(r,n)=>s.getValidation().handleAsync(r,n),updateDirtyForPath:(r,n,o)=>s.dirtyManager.updateForPath(r,n,o),getBaselineValues:s.getBaselineValues,emitFieldChange:r=>s.getEffects().onFieldChange(r)},t={getState:s.getState,dispatch:s.dispatch,config:s.config,internalSaveSnapshot:s.saveHistorySnapshot,evaluateAllDependencies:r=>s.fieldRegistry.evaluateAll(r),cancelAllValidations:()=>s.getValidation().cancelAll(),validateNow:r=>s.getValidation().validate(r),rebuildDirtyState:(r,n)=>s.dirtyManager.rebuild(r,n),clearDirtyState:s.dirtyManager.clear.bind(s.dirtyManager),getBaselineValues:s.getBaselineValues,setBaselineValues:s.setBaselineValues,resetHistory:r=>s.getHistory().reset(r),emitFieldChange:r=>s.getEffects().onFieldChange(r),triggerValidation:(r,n)=>s.getValidation().trigger(r,n)},i={getState:s.getState,dispatch:s.dispatch,batchStateUpdates:s.runStateBatch,config:s.config,getTransformEntries:s.getTransformEntries,getHiddenFields:()=>s.fieldRegistry.getHiddenFields(),cancelAllValidations:()=>s.getValidation().cancelAll(),validateNow:r=>s.getValidation().validate(r),hasValidationsInProgress:r=>s.getValidation().hasValidationsInProgress(r),buildDirtyValues:r=>s.dirtyManager.buildDirtyValues(r),setServerErrors:(r,n)=>s.setServerErrors(r,n),emitBeforeSubmit:r=>s.getEffects().beforeSubmit(r),emitAfterSubmit:r=>s.getEffects().afterSubmit(r),emitOperationalError:r=>s.getEffects().reportOperationalError(r)};return{fieldUpdate:e,values:t,submit:i}}function Mt(s){return{getState:s.getState,setFieldWithMeta:s.setFieldWithMeta,dispatch:s.dispatch,internalSaveSnapshot:s.saveHistorySnapshot,unregisterPrefix:s.unregisterPrefix,remapValidationPaths:s.remapValidationPaths,createArrayItemId:s.createArrayItemId}}function Dt(s){let{config:e,fieldRegistry:t,dirtyManager:i,baselineManager:r,runtimeContext:n}=s,{stateAccess:o,fieldAccess:a,featureAccess:l,actions:c}=n,p=At({config:e,fieldRegistry:t,getState:o.getState,dispatch:o.dispatch,setError:c.setError,getFieldConfig:a.getFieldConfig,getScopeFields:a.getScopeFields,getEffects:l.getEffects}),d=It({config:e,fieldRegistry:t,dirtyManager:i,getState:o.getState,dispatch:o.dispatch,setServerErrors:c.setServerErrors,saveHistorySnapshot:o.saveHistorySnapshot,runStateBatch:o.runStateBatch,getTransformEntries:a.getTransformEntries,getBaselineValues:()=>r.getValues(),setBaselineValues:h=>r.setValues(h),getValidation:l.getValidation,getHistory:l.getHistory,getEffects:l.getEffects}),u=Mt({getState:o.getState,dispatch:o.dispatch,setFieldWithMeta:(h,f,S)=>c.setFieldWithMeta(h,f,S),unregisterPrefix:c.unregisterPrefix,remapValidationPaths:(h,f)=>l.getValidation().remapArrayPaths(h,f),saveHistorySnapshot:o.saveHistorySnapshot,createArrayItemId:(h,f)=>e.idFactory({scope:"array",path:h,index:f})});return Ft({ports:{validationPort:p,lifecyclePorts:d,arrayPort:u,config:e,getScopeFields:a.getScopeFields,getState:o.getState,dispatch:o.dispatch,getBaselineValues:()=>r.getValues(),isPathDirty:h=>i.isPathDirty(h)},fieldRegistry:t})}function kt(s){let{config:e,fieldRegistry:t,dirtyManager:i,computedManager:r,rawConfig:n,baselineManager:o,runtimeContext:a}=s,{stateAccess:l,fieldAccess:c,featureAccess:p,actions:d}=a,u=Dt({config:e,fieldRegistry:t,dirtyManager:i,baselineManager:o,runtimeContext:{stateAccess:l,fieldAccess:c,featureAccess:p,actions:d}}),h=wt({config:e,fieldRegistry:t,computedManager:r}),f=new ae(l.getState,(g,m)=>e.onUnhandledError(g,m),e.subscriptionCacheSize),S=n.storeId||e.name||e.idFactory({scope:"store",storeName:e.name});return{state:h,subscriptions:f,capabilityRegistry:u.registry,storeId:S}}function Rt(){return{depth:0,pendingState:null,changedPathSet:null,changedPathList:null,valuesChanged:!1,pendingHistorySnapshot:!1}}function Ot(s){s.depth+=1}function jt(s){return s.depth-=1,s.depth===0}function xe(s,e){return _nullishCoalesce(e.pendingState, () => (s))}function Ht(s,e){if(s.pendingState=e.nextState,s.valuesChanged||=e.valuesChanged,e.valuesChanged&&(s.pendingHistorySnapshot=!0),e.changedPaths&&e.changedPaths.length>0){let t=_nullishCoalesce(s.changedPathSet, () => (new Set)),i=_nullishCoalesce(s.changedPathList, () => ([]));e.changedPaths.forEach(r=>{if(t.has("*")||t.has(r))return;if(r==="*"){t.clear(),i.length=0,t.add("*"),i.push("*");return}if(!i.some(o=>o!=="*"&&r.startsWith(`${o}.`))){for(let o=i.length-1;o>=0;o-=1){let a=i[o];a==="*"||!a.startsWith(`${r}.`)||(t.delete(a),i.splice(o,1))}t.add(r),i.push(r)}}),s.changedPathSet=t,s.changedPathList=i}}function Ut(s){let{currentState:e,batchState:t,applyValueDerivations:i,onDerivationError:r}=s;if(!t.pendingState)return null;let n=t.pendingState,o=_nullishCoalesce(t.changedPathList, () => (void 0)),a=t.valuesChanged;try{if(a)try{n={...n,values:i(n.values,o)}}catch(l){try{_optionalChain([r, 'optionalCall', _220 => _220(l)])}catch (e11){}}}finally{t.pendingState=null,t.changedPathSet=null,t.changedPathList=null,t.valuesChanged=!1}return{nextState:_nullishCoalesce(n, () => (e)),changedPaths:o,valuesChanged:a}}var Ce= (_class21 =class{constructor(e){;_class21.prototype.__init63.call(this);this.args=e;this.debounceMs=Math.max(0,_nullishCoalesce(e.debounceMs, () => (300)))}__init63() {this.pendingValues=null}queueSnapshot(e){if(this.debounceMs<=0){this.recordSnapshot(e);return}this.pendingValues=e,this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.flushPendingSnapshot()},this.debounceMs)}flushPendingSnapshot(){if(this.timer&&(clearTimeout(this.timer),this.timer=void 0),!this.pendingValues)return;let e=this.pendingValues;this.pendingValues=null,this.recordSnapshot(e)}dispose(){this.timer&&(clearTimeout(this.timer),this.timer=void 0),this.pendingValues=null}recordSnapshot(e){let t=this.readMetadata();this.args.history.saveSnapshot(e);let i=this.readMetadata();t.canUndo===i.canUndo&&t.canRedo===i.canRedo&&t.historyIndex===i.historyIndex&&t.historySize===i.historySize||this.args.notifyHistoryChanged()}readMetadata(){let e=this.args.history.getMetadata();return{canUndo:e.canUndo,canRedo:e.canRedo,historyIndex:e.historyIndex,historySize:e.historySize}}}, _class21);function Vi(s){let e=!1;for(let i of Object.values(s))if(i===void 0){e=!0;break}if(!e)return s;let t={};return Object.entries(s).forEach(([i,r])=>{let n=r;n!==void 0&&(t[i]=n)}),t}function qe(s){let{currentState:e,partialState:t,changedPaths:i,applyValueDerivations:r,applyComputedValues:n}=s,o=_nullishCoalesce(r, () => ((u=>n?n(u):u))),a={...e,...t},l=!!t.values;if(t.values&&(a.values=o(t.values,i)),t.errors){a.errors=Vi(t.errors);let u=!D(a.errors);a.isValid="isValid"in t?!!t.isValid:u}let c=i&&i.length>0?i:void 0,p=Fi(t),d=J(c,p);return{nextState:a,changedPaths:d,valuesChanged:l}}function Fi(s){let e=new Set,t=[s.errors,s.touched,s.isValidating];for(let i of t)if(i)for(let r in i)e.add(r);return s.persist&&e.add("persist"),"isValid"in s&&e.add("isValid"),"isDirty"in s&&e.add("isDirty"),"isSubmitting"in s&&e.add("isSubmitting"),e.size>0?Array.from(e):void 0}function wi(s){throw new Error(`BitStore: unsupported operation kind: ${String(s.kind)}`)}function Ai(s,e){switch(e.kind){case"state.patch":return e;case"field.touchMany":{if(e.paths.length===0)return null;let t={...s.touched};for(let i of e.paths)t[i]=!0;return v({touched:t},e.paths)}case"form.persistMeta":return v({persist:{...s.persist,...e.patch}});case"history.apply":return v({values:e.values,isDirty:e.isDirty},["*"]);case"validation.commit":return v({errors:e.errors,isValid:e.isValid});default:return wi(e)}}function Ii(s){let{currentState:e,operation:t,applyValueDerivations:i,onOperationError:r}=s,n=Object.prototype.hasOwnProperty.call(t.partialState,"values"),o=_nullishCoalesce(t.changedPaths, () => ((n?["*"]:void 0))),a;try{a=qe({currentState:e,partialState:t.partialState,changedPaths:o,applyValueDerivations:i})}catch(l){try{_optionalChain([r, 'optionalCall', _221 => _221(l)])}catch (e12){}try{a=qe({currentState:e,partialState:t.partialState,changedPaths:o,applyValueDerivations:c=>c})}catch (e13){a=void 0}}return a}function zt(s){let{currentState:e,operation:t,applyValueDerivations:i,onOperationError:r}=s,n=Ai(e,t);return n?Ii({currentState:e,operation:n,applyValueDerivations:(o,a)=>n.skipComputed?o:i(o,a),onOperationError:r}):null}function qt(s){let{state:e,batchState:t,operation:i,applyValueDerivations:r,onOperationError:n,onStateCommitted:o}=s,a=xe(e,t);if(t.depth>0){let c=zt({currentState:a,operation:i,applyValueDerivations:p=>p,onOperationError:n});return c&&Ht(t,c),e}let l=zt({currentState:e,operation:i,applyValueDerivations:r,onOperationError:n});return l?(o({nextState:l.nextState,changedPaths:l.changedPaths,valuesChanged:l.valuesChanged}),l.nextState):e}function _t(s){let{state:e,batchState:t,applyValueDerivations:i,onDerivationError:r,onStateCommitted:n}=s,o=Ut({currentState:e,batchState:t,applyValueDerivations:i,onDerivationError:r});return o?(n({nextState:o.nextState,changedPaths:o.changedPaths,valuesChanged:o.valuesChanged}),o.nextState):e}function Lt(s){let{batchState:e,callback:t,flushBatchedStateUpdates:i}=s;Ot(e);try{return t()}finally{jt(e)&&i()}}function Wt(s){let{payload:e,setState:t,notifySubscriptions:i,notifyEffects:r}=s;t(e.nextState),i(e.nextState,e.changedPaths),r(e.nextState,e.valuesChanged)}function Nt(s){let{state:e,batchState:t,operation:i,applyValueDerivations:r,onOperationError:n,onStateCommitted:o}=s;return qt({state:e,batchState:t,operation:i,applyValueDerivations:r,onOperationError:n,onStateCommitted:o})}function Kt(s){let{batchState:e,values:t,saveHistory:i}=s;if(e.depth>0){e.pendingHistorySnapshot=!0;return}i(t)}function $t(s){let{state:e,batchState:t,applyValueDerivations:i,onDerivationError:r,onStateCommitted:n,saveHistory:o}=s,a=_t({state:e,batchState:t,applyValueDerivations:i,onDerivationError:r,onStateCommitted:n});return t.pendingHistorySnapshot&&(t.pendingHistorySnapshot=!1,o(a.values)),a}var Ve= (_class22 =class{constructor(e){;_class22.prototype.__init64.call(this);this.args=e;this.state=e.state,this.subscriptions=e.subscriptions,this.effects=e.effects,this.capabilityRegistry=e.capabilityRegistry,this.capabilities=e.capabilityRegistry.toCapabilities(),this.historyOrchestrator=new Ce({debounceMs:e.historyDebounceMs,history:this.capabilities.history,notifyHistoryChanged:()=>{this.subscriptions.notify(this.getState(),[_chunkRHMJPKNVcjs.h.call(void 0, )])}})}__init64() {this.batchState=Rt()}getCapability(e){return this.capabilityRegistry.resolve(e)}getState(){return xe(this.state,this.batchState)}runBatch(e){return Lt({batchState:this.batchState,callback:e,flushBatchedStateUpdates:()=>this.flushBatchedStateUpdates()})}dispatch(e){this.state=Nt({state:this.state,batchState:this.batchState,operation:e,applyValueDerivations:(t,i)=>this.applyValueDerivations(t,i),onOperationError:t=>_optionalChain([this, 'access', _222 => _222.args, 'access', _223 => _223.onUnhandledError, 'optionalCall', _224 => _224(t,"derivation")]),onStateCommitted:t=>this.onStateCommitted(t)})}saveHistorySnapshot(){Kt({batchState:this.batchState,values:this.state.values,saveHistory:e=>this.historyOrchestrator.queueSnapshot(e)})}flushPendingHistorySnapshot(){this.historyOrchestrator.flushPendingSnapshot()}cleanup(){this.flushPendingHistorySnapshot(),this.historyOrchestrator.dispose(),this.subscriptions.destroy(),this.capabilities.validation.cancelAll(),this.effects.destroy()}onStateCommitted(e){Wt({payload:e,setState:t=>{this.state=t},notifySubscriptions:(t,i)=>this.subscriptions.notify(t,i),notifyEffects:(t,i)=>this.effects.onStateUpdated(t,i)})}flushBatchedStateUpdates(){this.state=$t({state:this.state,batchState:this.batchState,applyValueDerivations:(e,t)=>this.applyValueDerivations(e,t),onDerivationError:e=>_optionalChain([this, 'access', _225 => _225.args, 'access', _226 => _226.onUnhandledError, 'optionalCall', _227 => _227(e,"derivation")]),onStateCommitted:e=>this.onStateCommitted(e),saveHistory:e=>this.historyOrchestrator.queueSnapshot(e)})}applyValueDerivations(e,t){return this.args.applyValueDerivations?this.args.applyValueDerivations(e,t):e}}, _class22);function Jt(s){let{rawConfig:e,overrides:t}=s,i=tt(e),r=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _228 => _228.baselineManager]), () => (new q(i.initialValues))),n=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _229 => _229.fieldRegistry]), () => (new $(({error:g})=>{i.onUnhandledError(g,"validation")}))),o=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _230 => _230.computedManager]), () => (new _(g=>n.getComputedEntries(g),g=>i.onUnhandledError(g,"computed")))),a=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _231 => _231.dirtyManager]), () => (new L)),l=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _232 => _232.maskManager]), () => (new W)),c=()=>{n.invalidateIndexes(),o.invalidateReverseDeps()},p,d=()=>{if(!p)throw new Error("BitStore runtime kernel is not initialized yet.");return p},u=kt({rawConfig:e,config:i,fieldRegistry:n,computedManager:o,dirtyManager:a,baselineManager:r,runtimeContext:{stateAccess:{getState:()=>d().getState(),dispatch:g=>d().dispatch(g),saveHistorySnapshot:()=>d().saveHistorySnapshot(),runStateBatch:g=>d().runBatch(g)},fieldAccess:{getFieldConfig:g=>n.getFieldConfig(g),getScopeFields:g=>n.getScopeFields(g,d().getState().values),getNormalizerEntries:()=>n.getNormalizerEntries(d().getState().values),getTransformEntries:()=>n.getTransformEntries(d().getState().values)},featureAccess:{getEffects:()=>d().effects,getHistory:()=>d().getCapability("history"),getValidation:()=>d().getCapability("validation")},actions:{setError:(g,m)=>{d().getCapability("error").setError(g,m)},setServerErrors:(g,m)=>{d().getCapability("error").setServerErrors(g,m)},validate:g=>d().getCapability("validation").validate(g),setFieldWithMeta:(g,m,T={origin:"setField"})=>{d().runBatch(()=>{d().getCapability("lifecycle").updateField(g,m,T)})},unregisterPrefix:g=>{oe({prefix:g,state:d().getState(),fieldRegistry:n,subscriptions:d().subscriptions,validationCleanupPrefix:m=>d().getCapability("validation").cleanupPrefix(m),invalidateFieldIndexes:c,hasStaticConfigPath:m=>!!_optionalChain([i, 'access', _233 => _233.fields, 'optionalAccess', _234 => _234[m]]),dispatch:m=>d().dispatch(m)})},triggerValidation:(g,m)=>{d().getCapability("validation").trigger(g,m)}}}}),h=()=>{let g=d().getState();return a.buildDirtyValues(g.values)},f=g=>{d().flushPendingHistorySnapshot(),dt({values:g,state:d().getState(),initialValues:r.getValues(),validation:d().getCapability("validation"),fieldRegistry:n,dirtyManager:a,dispatch:m=>d().dispatch(m),saveHistorySnapshot:()=>d().saveHistorySnapshot()})},S=rt({storeId:u.storeId,config:i,getState:()=>d().getState(),getConfig:()=>i,getValues:()=>d().getState().values,getDirtyValues:h,applyPersistedValues:f,setPersistMetadata:g=>d().dispatch({kind:"form.persistMeta",patch:g})});return p=new Ve({state:u.state,subscriptions:u.subscriptions,effects:S,capabilityRegistry:u.capabilityRegistry,historyDebounceMs:i.history.debounceMs,onUnhandledError:(g,m)=>i.onUnhandledError(g,m),applyValueDerivations:(g,m)=>{try{return G({values:g,changedPaths:m,normalizerEntries:n.getNormalizerEntries(g),applyComputed:(T,C)=>o.apply(T,C),onError:(T,C)=>{i.onUnhandledError(T,"derivation")}})}catch(T){return i.onUnhandledError(T,"derivation"),g}}}),p.saveHistorySnapshot(),p.flushPendingHistorySnapshot(),{config:i,storeId:u.storeId,runtime:p,fieldRegistry:n,computedManager:o,dirtyManager:a,maskManager:l,baselineManager:r}}function Gt(s){let{dispatch:e,effects:t,onUnhandledError:i}=s;return ot({dispatch:e,effects:t,onUnhandledError:i})}function Yt(s){let{dispatch:e,effects:t}=s;return at({dispatch:e,effects:t})}function Xt(s){let{dispatch:e,effects:t}=s;return lt({dispatch:e,effects:t})}function Qt(s){let{history:e,applyHistoryState:t}=s,i=e.undo();i&&t(i)}function Zt(s){let{history:e,applyHistoryState:t}=s,i=e.redo();i&&t(i)}function ei(s){return s.history.getMetadata()}function ti(s,e){let t=new Set,i=(o,a)=>o===null||typeof o!="object"?o:new Proxy(o,{get:(l,c,p)=>{if(typeof c=="symbol")return Reflect.get(l,c,p);let d=String(c),u=a?`${a}.${d}`:d;t.add(u);let h=Reflect.get(l,c,p);return i(h,u)}}),r=i(s,"");e(r);let n=new Set;return t.forEach(o=>{let a=Mi(o);a&&n.add(a)}),Array.from(n)}function Mi(s){if(s)return s==="values"?"*":s.startsWith("values.")?s.slice(7):s==="errors"||s==="touched"||s==="isValidating"?"*":s.startsWith("errors.")?s.slice(7):s.startsWith("touched.")?s.slice(8):s.startsWith("isValidating.")?s.slice(13):s==="persist"||s.startsWith("persist.")?"persist":s}function Di(s,e){if(s.length!==e.length)return!1;let t=new Set(e);for(let i of s)if(!t.has(i))return!1;return!0}function ki(s,e){return s.length===0?{emitImmediately:_optionalChain([e, 'optionalAccess', _235 => _235.emitImmediately]),equalityFn:_optionalChain([e, 'optionalAccess', _236 => _236.equalityFn]),mode:"scoped",paths:["*"]}:{emitImmediately:_optionalChain([e, 'optionalAccess', _237 => _237.emitImmediately]),equalityFn:_optionalChain([e, 'optionalAccess', _238 => _238.equalityFn]),mode:"scoped",paths:s}}function ii(s){let{getState:e,subscribeSelector:t,selector:i,listener:r,options:n}=s,o=null,a=ti(e(),i),l=!1,c=!1,p=d=>{let u=o;o=t(i,h=>{r(h);let f=ti(e(),i);Di(a,f)||(a=f,!(c||l)&&(c=!0,queueMicrotask(()=>{c=!1,!l&&(_optionalChain([o, 'optionalCall', _239 => _239()]),p(a))})))},ki(d,n)),_optionalChain([u, 'optionalCall', _240 => _240()])};return p(a),()=>{l=!0,_optionalChain([o, 'optionalCall', _241 => _241()]),o=null}}function ri(s){let{getState:e,subscriptions:t,selector:i,listener:r,options:n,trackedSubscriptionsEnabled:o,onUnhandledError:a}=s,l=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _242 => _242.equalityFn]), () => (_chunkFTXV2NZOcjs.c));return _optionalChain([n, 'optionalAccess', _243 => _243.mode])==="tracked"?o?ii({getState:e,subscribeSelector:(c,p,d)=>t.subscribeSelector(c,p,d,l),selector:i,listener:r,options:n}):(_optionalChain([a, 'optionalCall', _244 => _244(new Error('BitForm: subscribeSelector com mode="tracked" est\xE1 desabilitado por padr\xE3o. Ative config.trackedSubscriptions=true para habilitar o modo avan\xE7ado.'),"subscription")]),()=>{}):t.subscribeSelector(i,r,n,l)}function si(s){let{path:e,listener:t,options:i,subscribeSelector:r}=s,n=[..._nullishCoalesce(_optionalChain([i, 'optionalAccess', _245 => _245.paths]), () => ([])),e];return r(o=>_chunkFTXV2NZOcjs.f.call(void 0, o.values,e),t,{...i,paths:n})}function ni(s){let{path:e,listener:t,getFieldState:i,subscribeSelector:r}=s;return r(()=>i(e),t,{paths:[e],equalityFn:_chunkGKNGJOB3cjs.c})}function oi(s){let{listener:e,subscribeSelector:t}=s;return t(i=>({isValid:i.isValid,isDirty:i.isDirty,isSubmitting:i.isSubmitting}),e,{paths:["isValid","isDirty","isSubmitting"],equalityFn:(i,r)=>i.isValid===r.isValid&&i.isDirty===r.isDirty&&i.isSubmitting===r.isSubmitting})}function ai(s){let{listener:e,subscribeSelector:t}=s;return t(i=>i.persist,e,{paths:["persist"],equalityFn:(i,r)=>i.isSaving===r.isSaving&&i.isRestoring===r.isRestoring&&i.error===r.error})}function li(s){let{readHistoryMeta:e,subscribeSelector:t,listener:i}=s;return t(()=>e(),i,{paths:[_chunkRHMJPKNVcjs.h.call(void 0, )],equalityFn:(r,n)=>_chunkRHMJPKNVcjs.e.call(void 0, r,n)})}function di(s){let{scopeName:e,getScopeFields:t,readScopeStatus:i,subscribeSelector:r,listener:n}=s,o=_chunkRHMJPKNVcjs.d.call(void 0, e),a=i(e),l=()=>{},c=()=>{l();let h=_chunkRHMJPKNVcjs.c.call(void 0, t(e));l=r(()=>i(e),f=>{_chunkRHMJPKNVcjs.b.call(void 0, a,f)||(a=f,n(f))},{paths:[...h,o]})};c();let p=!1,d=!1,u=r(()=>t(e).length,()=>{p||(p=!0,queueMicrotask(()=>{if(p=!1,d)return;c();let h=i(e);_chunkRHMJPKNVcjs.b.call(void 0, a,h)||(a=h,n(h))}))},{paths:[o]});return()=>{d=!0,l(),u()}}function ci(s){let{runtime:e,config:t,fieldRegistry:i,dirtyManager:r,stateReader:n}=s,o={getState:()=>_chunkFTXV2NZOcjs.a.call(void 0, n.getState()),getFieldState:d=>_chunkFTXV2NZOcjs.a.call(void 0, n.getFieldState(d)),getIsValid:()=>n.getFlag("isValid"),getIsSubmitting:()=>n.getFlag("isSubmitting"),getIsDirty:()=>n.getFlag("isDirty"),isHidden:d=>e.capabilities.query.isHidden(d),isRequired:d=>e.capabilities.query.isRequired(d),isFieldDirty:d=>e.capabilities.query.isFieldDirty(d),isFieldValidating:d=>e.capabilities.query.isFieldValidating(d),getDirtyValues:()=>r.buildDirtyValues(n.getState().values),getPersistMetadata:()=>n.getPersistMetadata(),getHistoryMetadata:()=>ei({history:e.capabilities.history}),getScopeStatus:d=>e.capabilities.scope.getScopeStatus(d),getScopeErrors:d=>e.capabilities.scope.getScopeErrors(d),getCanUndo:()=>e.capabilities.history.canUndo,getCanRedo:()=>e.capabilities.history.canRedo,getScopeFields:d=>i.getScopeFields(d,n.getState().values)},a={subscribe:d=>e.subscriptions.subscribe(d),subscribePersistMeta:d=>ai({listener:d,subscribeSelector:(u,h,f)=>a.subscribeSelector(u,h,f)}),subscribeHistoryMeta:d=>li({readHistoryMeta:()=>o.getHistoryMetadata(),subscribeSelector:(u,h,f)=>a.subscribeSelector(u,h,f),listener:d}),subscribeScopeStatus:(d,u)=>di({scopeName:d,getScopeFields:h=>o.getScopeFields(h),readScopeStatus:h=>o.getScopeStatus(h),subscribeSelector:(h,f,S)=>a.subscribeSelector(h,f,S),listener:u}),subscribeSelector:(d,u,h)=>ri({getState:()=>o.getState(),subscriptions:e.subscriptions,selector:d,listener:u,options:h,trackedSubscriptionsEnabled:!!t.trackedSubscriptions,onUnhandledError:(f,S)=>t.onUnhandledError(f,S)}),subscribePath:(d,u,h)=>si({path:d,listener:u,options:h,subscribeSelector:(f,S,g)=>a.subscribeSelector(f,S,g)}),subscribeFieldState:(d,u)=>ni({path:d,listener:u,getFieldState:h=>o.getFieldState(h),subscribeSelector:(h,f,S)=>a.subscribeSelector(h,f,S)}),subscribeFormMeta:d=>oi({listener:d,subscribeSelector:(u,h,f)=>a.subscribeSelector(u,h,f)})},l={registerField:(d,u)=>{pt({path:d,config:u,state:e.getState(),fieldRegistry:i,subscriptions:e.subscriptions,validationCleanupField:h=>e.capabilities.validation.cleanupField(h),stateReader:n,invalidateFieldIndexes:()=>{i.invalidateIndexes()},dispatch:h=>e.dispatch(h),getState:()=>e.getState(),onUnhandledError:(h,f)=>t.onUnhandledError(h,f)})},unregisterField:d=>{ht({path:d,state:e.getState(),hasStaticConfig:!!_optionalChain([t, 'access', _246 => _246.fields, 'optionalAccess', _247 => _247[d]]),fieldRegistry:i,subscriptions:e.subscriptions,validationCleanupField:u=>e.capabilities.validation.cleanupField(u),invalidateFieldIndexes:()=>{i.invalidateIndexes()},dispatch:u=>e.dispatch(u)})},unregisterPrefix:d=>{oe({prefix:d,state:e.getState(),fieldRegistry:i,subscriptions:e.subscriptions,validationCleanupPrefix:u=>e.capabilities.validation.cleanupPrefix(u),invalidateFieldIndexes:()=>{i.invalidateIndexes()},hasStaticConfigPath:u=>!!_optionalChain([t, 'access', _248 => _248.fields, 'optionalAccess', _249 => _249[u]]),dispatch:u=>e.dispatch(u)})},setField:(d,u)=>{e.runBatch(()=>{e.capabilities.lifecycle.updateField(d,u,{origin:"setField"})})},blurField:d=>{e.capabilities.query.isTouched(d)||e.runBatch(()=>{e.dispatch(Oe([d]))}),e.flushPendingHistorySnapshot(),e.capabilities.validation.trigger([d])},markFieldsTouched:d=>{d.length!==0&&e.dispatch(Oe(d))},setValues:(d,u)=>{_optionalChain([u, 'optionalAccess', _250 => _250.rebase])&&e.flushPendingHistorySnapshot(),e.capabilities.lifecycle.setValues(d,u)},setError:(d,u)=>{e.capabilities.error.setError(d,u)},setErrors:d=>{e.capabilities.error.setErrors(d)},setServerErrors:(d,u)=>{e.capabilities.error.setServerErrors(d,u)},reset:()=>{e.flushPendingHistorySnapshot(),e.runBatch(()=>{e.capabilities.lifecycle.reset()})},transaction:d=>e.runBatch(d),submit:d=>(e.flushPendingHistorySnapshot(),e.capabilities.lifecycle.submit(d)),pushItem:(d,u)=>e.capabilities.arrays.pushItem(d,u),prependItem:(d,u)=>e.capabilities.arrays.prependItem(d,u),insertItem:(d,u,h)=>e.capabilities.arrays.insertItem(d,u,h),removeItem:(d,u)=>e.capabilities.arrays.removeItem(d,u),swapItems:(d,u,h)=>e.capabilities.arrays.swapItems(d,u,h),moveItem:(d,u,h)=>e.capabilities.arrays.moveItem(d,u,h),replaceItems:(d,u)=>e.capabilities.arrays.replaceItems(d,u),clearItems:d=>e.capabilities.arrays.clearItems(d)},c=d=>e.dispatch(d);return{read:o,observe:a,write:l,feature:{undo:()=>{e.flushPendingHistorySnapshot(),Qt({history:e.capabilities.history,applyHistoryState:d=>e.capabilities.lifecycle.applyHistoryState(d)})},redo:()=>{e.flushPendingHistorySnapshot(),Zt({history:e.capabilities.history,applyHistoryState:d=>e.capabilities.lifecycle.applyHistoryState(d)})},validate:d=>e.capabilities.validation.validate(d),hasValidationsInProgress:d=>e.capabilities.validation.hasValidationsInProgress(d),triggerValidation:(d,u)=>e.capabilities.validation.trigger(d,u),restorePersisted:()=>Gt({dispatch:c,effects:e.effects,onUnhandledError:(d,u)=>t.onUnhandledError(d,u)}),forceSave:()=>Yt({dispatch:c,effects:e.effects}),clearPersisted:()=>Xt({dispatch:c,effects:e.effects}),getArrayItemIds:(d,u)=>e.capabilities.arrays.getItemIds(d,u),cleanup:()=>e.cleanup()}}}function ui(s){let e=()=>s.read.getState();return{read:{get storeId(){return s.identity.storeId},get config(){return _chunkFTXV2NZOcjs.a.call(void 0, s.identity.config)},get isValid(){return s.read.getIsValid()},get isSubmitting(){return s.read.getIsSubmitting()},get isDirty(){return s.read.getIsDirty()},getState:e,getFieldConfig:o=>{let a=s.getFieldConfig(o);return a?_chunkFTXV2NZOcjs.a.call(void 0, a):void 0},getFieldState:o=>s.read.getFieldState(o),isHidden:o=>s.read.isHidden(o),isRequired:o=>s.read.isRequired(o),isFieldDirty:o=>s.read.isFieldDirty(o),isFieldValidating:o=>s.read.isFieldValidating(o),getDirtyValues:()=>s.read.getDirtyValues(),getPersistMetadata:()=>s.read.getPersistMetadata(),getHistoryMetadata:()=>s.read.getHistoryMetadata(),getScopeStatus:o=>s.read.getScopeStatus(o),getScopeErrors:o=>s.read.getScopeErrors(o),getScopeFields:o=>s.read.getScopeFields(o)},observe:{getState:e,subscribe:o=>s.observe.subscribe(o),subscribePersistMeta:o=>s.observe.subscribePersistMeta(o),subscribeHistoryMeta:o=>s.observe.subscribeHistoryMeta(o),subscribeScopeStatus:(o,a)=>s.observe.subscribeScopeStatus(o,a),subscribeFormMeta:o=>s.observe.subscribeFormMeta(o),subscribeSelector:(o,a,l)=>s.observe.subscribeSelector(o,a,l),subscribePath:(o,a,l)=>s.observe.subscribePath(o,a,l),subscribeFieldState:(o,a)=>s.observe.subscribeFieldState(o,a)},write:{setField:(o,a)=>s.write.setField(o,a),blurField:o=>s.write.blurField(o),markFieldsTouched:o=>s.write.markFieldsTouched(o),setValues:(o,a)=>s.write.setValues(o,a),setError:(o,a)=>s.write.setError(o,a),setErrors:o=>s.write.setErrors(o),setServerErrors:(o,a)=>s.write.setServerErrors(o,a),reset:()=>s.write.reset(),transaction:o=>s.write.transaction(o),submit:o=>s.write.submit(o)},feature:{cleanup:()=>s.feature.cleanup(),validate:o=>s.feature.validate(o),triggerValidation:(o,a)=>s.feature.triggerValidation(o,a),restorePersisted:()=>s.feature.restorePersisted(),forceSave:()=>s.feature.forceSave(),clearPersisted:()=>s.feature.clearPersisted(),registerField:(o,a)=>s.write.registerField(o,a),unregisterField:o=>s.write.unregisterField(o),unregisterPrefix:o=>s.write.unregisterPrefix(o),pushItem:(o,a)=>s.write.pushItem(o,a),prependItem:(o,a)=>s.write.prependItem(o,a),insertItem:(o,a,l)=>s.write.insertItem(o,a,l),removeItem:(o,a)=>s.write.removeItem(o,a),moveItem:(o,a,l)=>s.write.moveItem(o,a,l),swapItems:(o,a,l)=>s.write.swapItems(o,a,l),replaceItems:(o,a)=>s.write.replaceItems(o,a),clearItems:o=>s.write.clearItems(o),getArrayItemIds:(o,a)=>s.feature.getArrayItemIds(o,a),get canUndo(){return s.read.getCanUndo()},get canRedo(){return s.read.getCanRedo()},hasValidationsInProgress:o=>s.feature.hasValidationsInProgress(o),resolveMask:o=>s.resolveMask(o),createArrayItemId:(o,a)=>s.createArrayItemId(o,a),undo:()=>s.feature.undo(),redo:()=>s.feature.redo()}}}var Fe= (_class23 =class{constructor(e){;_class23.prototype.__init65.call(this);this.deps=e}__init65() {this.fieldStateCache=new Map}getState(){return this.deps.getState()}getUserLayer(){let e=this.deps.getState();return{values:e.values,touched:e.touched}}getValidationLayer(){let e=this.deps.getState();return{errors:e.errors,isValidating:e.isValidating,isValid:e.isValid}}getDerivedLayer(){return{isDirty:this.deps.getState().isDirty}}getFeatureLayer(){let e=this.deps.getState();return{persist:e.persist,isSubmitting:e.isSubmitting}}getFlag(e){return this.deps.getState()[e]}getPersistMetadata(){let e=this.deps.getState(),t=e.persist,i=this.persistMetaCache;if(i&&i.state===e&&i.snapshot.isSaving===t.isSaving&&i.snapshot.isRestoring===t.isRestoring&&i.snapshot.error===t.error)return i.snapshot;let r={isSaving:t.isSaving,isRestoring:t.isRestoring,error:t.error};return this.persistMetaCache={state:e,snapshot:r},r}getFieldState(e){let t=e,i=this.deps.getState(),r=this.fieldStateCache.get(t),n=_chunkFTXV2NZOcjs.f.call(void 0, i.values,t),o=i.errors[t],a=!!i.touched[t],l=this.deps.isHidden(t),c=this.deps.isRequired(t),p=this.deps.isFieldDirty(t),d=this.deps.isFieldValidating(t);if(r){let h=r.snapshot;if(h.value===n&&h.error===o&&h.touched===a&&h.isHidden===l&&h.isRequired===c&&h.isDirty===p&&h.isValidating===d)return h}let u=Ze({state:i,path:e,value:n,isHidden:l,isRequired:c,isDirty:p,isValidating:d});return this.fieldStateCache.set(t,{state:i,snapshot:u}),u}invalidatePath(e){this.fieldStateCache.delete(e)}}, _class23);var we= (_class24 =class{__init66() {this[R]=!0}__init67() {this[k]=!0}constructor(e={}){;_class24.prototype.__init66.call(this);_class24.prototype.__init67.call(this);let t=Jt({rawConfig:e});this._config=t.config,this.storeId=t.storeId;let i=new Fe({getState:()=>t.runtime.getState(),isHidden:o=>t.runtime.capabilities.query.isHidden(o),isRequired:o=>t.runtime.capabilities.query.isRequired(o),isFieldDirty:o=>t.runtime.capabilities.query.isFieldDirty(o),isFieldValidating:o=>t.runtime.capabilities.query.isFieldValidating(o)}),r=ci({runtime:t.runtime,config:this._config,fieldRegistry:t.fieldRegistry,dirtyManager:t.dirtyManager,stateReader:i}),n=ui({identity:{storeId:this.storeId,config:this._config},read:r.read,observe:r.observe,write:r.write,feature:r.feature,getFieldConfig:o=>t.fieldRegistry.getFieldConfig(o),resolveMask:o=>Qe({path:o,getFieldConfig:a=>t.fieldRegistry.getFieldConfig(a),masks:t.maskManager.getAllMasks()}),createArrayItemId:(o,a)=>this._config.idFactory({scope:"array",path:o,index:a})});this.read=n.read,this.observe=n.observe,this.write=n.write,this.feature=n.feature,t.runtime.effects.attachStorePort({getState:()=>this.read.getState(),getHistoryMetadata:()=>this.read.getHistoryMetadata(),undo:()=>this.feature.undo(),redo:()=>this.feature.redo(),reset:()=>this.write.reset()})}}, _class24);function pi(s={}){return new we(s)}function hi(s){if(!s||typeof s!="object")return!1;let e=s;return e[R]===!0&&!!e.read&&!!e.observe&&!!e.write&&!!e.feature}function Ri(s){if(hi(s))return s;throw new Error("BitForm: o store informado n\xE3o exp\xF5e a API necess\xE1ria para hooks/framework bindings.")}function Oi(s){return!s||typeof s!="object"?!1:s[k]===!0}function ji(s){if(!hi(s))throw new Error("BitForm: o store informado n\xE3o possui branding de hooks (BIT_HOOKS_API_SYMBOL).");if(!Oi(s))throw new Error("BitForm: o store informado n\xE3o possui branding de framework (BIT_FRAMEWORK_STORE_SYMBOL).");return s}function Hi(s){return Object.defineProperty(s,R,{value:!0,enumerable:!1,configurable:!1,writable:!1}),Object.defineProperty(s,k,{value:!0,enumerable:!1,configurable:!1,writable:!1}),s}function Ui(s={}){let e=pi(s),t={read:e.read,observe:e.observe,write:e.write,feature:e.feature};return Hi(t)}function zi(s){return s.read}function qi(s){return s.observe}function _i(s){return s.write}function Li(s){return s.feature}function Wi(s,e){let t={};for(let i of e)t[i]=s[i];return t}exports.a = ke; exports.b = Bi; exports.c = Ri; exports.d = ji; exports.e = Ui; exports.f = zi; exports.g = qi; exports.h = _i; exports.i = Li; exports.j = Wi;
2
- //# sourceMappingURL=chunk-L7EAZ6K6.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/bit-form/bit-form/dist/chunk-L7EAZ6K6.cjs","../src/core/store/engines/store-field-query-engine.ts","../src/core/store/orchestration/framework-store-brand.ts","../src/core/store/orchestration/hook-brand.ts","../src/core/store/managers/core/baseline-manager.ts","../src/core/store/managers/core/computed-manager.ts"],"names":["resolveFieldMask","args","path","getFieldConfig","masks","maskOption","createFieldStateSnapshot","state","value","isHidden","isRequired","isDirty","isValidating","pathKey","BIT_FRAMEWORK_STORE_SYMBOL","BIT_HOOKS_API_SYMBOL","BitBaselineManager","baselineValues","deepClone","values","BitComputedManager","getComputedEntries","onError","changedPaths","computedEntries","entriesToRun","nextValues","failedPaths","entry","dep","newValue","error","currentValue","getDeepValue","cached","valuesEqual","canUseScalarCache","deepEqual","setDeepValue","entries","map","dependents","childIdx","segments","len","prefix","children","reverseDependencies","affectedPaths","queue","queueIndex","currentPath","dependentPath","orderedAllEntries","indexByPath","affectedEntries","entryIndex","left","right","item","entryByPath","inDegree","dependencyPath","nextDependents","orderedPaths","nextDegree","signature","ordered","orderedEntries","index"],"mappings":"AAAA,+iCAAuE,wDAA0C,wDAAmI,wDAA0C,SCU9QA,EAAAA,CAAmCC,CAAAA,CAI3B,CACtB,GAAM,CAAE,IAAA,CAAAC,CAAAA,CAAM,cAAA,CAAAC,CAAAA,CAAgB,KAAA,CAAAC,CAAM,CAAA,CAAIH,CAAAA,CAClCI,CAAAA,iBAAaF,CAAAA,mBAAeD,CAAI,CAAA,6BAAG,MAAA,CAEzC,EAAA,CAAKG,CAAAA,CAIL,OAAI,OAAOA,CAAAA,EAAe,QAAA,iBACjBD,CAAAA,4BAAAA,CAAQC,CAAgC,GAAA,CAG1CA,CACT,CAEO,SAASC,EAAAA,CAGdL,CAAAA,CAQ+C,CAC/C,GAAM,CAAE,KAAA,CAAAM,CAAAA,CAAO,IAAA,CAAAL,CAAAA,CAAM,KAAA,CAAAM,CAAAA,CAAO,QAAA,CAAAC,CAAAA,CAAU,UAAA,CAAAC,CAAAA,CAAY,OAAA,CAAAC,CAAAA,CAAS,YAAA,CAAAC,CAAa,CAAA,CACtEX,CAAAA,CACIY,CAAAA,CAAUX,CAAAA,CA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ACzD,IAAA,CAAK,qBAAA,CAAsB,CAAA,CAC3B,IAAA,CAAK,yBAAA,CAA4BsC,CAAAA,CACjC,IAAA,CAAK,mBAAA,CAAsB3B,CAC7B,CAEQ,sBAAA,CAAuBA,CAAAA,CAAwC,CACrE,OAAOA,CAAAA,CACJ,GAAA,CAAKX,CAAAA,EAAU,CAAA,EAAA","file":"/home/runner/work/bit-form/bit-form/dist/chunk-L7EAZ6K6.cjs","sourcesContent":[null,"import type { BitMask, BitMaskName } from \"../../mask/types\";\nimport type {\n BitErrors,\n BitFieldDefinition,\n BitFieldState,\n BitPath,\n BitPathValue,\n BitState,\n} from \"../contracts/types\";\n\nexport function resolveFieldMask<T extends object>(args: {\n path: string;\n getFieldConfig: (path: string) => BitFieldDefinition<T> | undefined;\n masks: Record<BitMaskName, BitMask> | undefined;\n}): BitMask | undefined {\n const { path, getFieldConfig, masks } = args;\n const maskOption = getFieldConfig(path)?.mask;\n\n if (!maskOption) {\n return undefined;\n }\n\n if (typeof maskOption === \"string\") {\n return masks?.[maskOption as keyof typeof masks];\n }\n\n return maskOption;\n}\n\nexport function createFieldStateSnapshot<\n TForm extends object,\n P extends BitPath<TForm>,\n>(args: {\n state: Readonly<BitState<TForm>>;\n path: P;\n value: BitPathValue<TForm, P>;\n isHidden: boolean;\n isRequired: boolean;\n isDirty: boolean;\n isValidating: boolean;\n}): BitFieldState<TForm, BitPathValue<TForm, P>> {\n const { state, path, value, isHidden, isRequired, isDirty, isValidating } =\n args;\n const pathKey = path as string;\n\n return {\n value,\n error: state.errors[pathKey as keyof BitErrors<TForm>],\n touched: !!state.touched[pathKey as keyof typeof state.touched],\n isHidden,\n isRequired,\n isDirty,\n isValidating,\n };\n}\n","export const BIT_FRAMEWORK_STORE_SYMBOL = Symbol.for(\n \"bit-form.framework-store-api\",\n);\n","export const BIT_HOOKS_API_SYMBOL = Symbol.for(\"bit-form.hooks-api\");\n","import { deepClone } from \"../../../utils\";\n\nexport class BitBaselineManager<T extends object> {\n constructor(baselineValues: T) {\n this.baselineValues = deepClone(baselineValues);\n }\n\n private baselineValues: T;\n private baselineSnapshot?: Readonly<T>;\n\n getValues(): T {\n if (!this.baselineSnapshot) {\n this.baselineSnapshot = Object.freeze(deepClone(this.baselineValues));\n }\n\n return this.baselineSnapshot as T;\n }\n\n setValues(values: T): void {\n this.baselineValues = deepClone(values);\n this.baselineSnapshot = undefined;\n }\n}\n","import { deepEqual, getDeepValue, setDeepValue } from \"../../../utils\";\nimport type { BitComputedFn } from \"../../contracts/types\";\n\nexport interface BitComputedEntry<T extends object> {\n path: string;\n compute: BitComputedFn<T>;\n dependsOn: readonly string[];\n}\n\nexport class BitComputedManager<T extends object> {\n private equalityCache = new Map<\n string,\n { current: unknown; next: unknown; equal: boolean }\n >();\n private reverseDepsCache: Map<string, Set<string>> | null = null;\n private childDepsIndex: Map<string, Set<string>> | null = null;\n private validatedEntriesSignature: string | null = null;\n private validatedEntriesRef: BitComputedEntry<T>[] | null = null;\n private orderedAllEntriesCache: {\n signature: string;\n ordered: BitComputedEntry<T>[];\n } | null = null;\n private orderedIndexByPathCache: {\n signature: string;\n indexByPath: Map<string, number>;\n } | null = null;\n\n constructor(\n private getComputedEntries: (values: T) => BitComputedEntry<T>[],\n private onError?: (error: unknown, path: string) => void,\n ) {}\n\n private isCacheableScalar(value: unknown): boolean {\n return (\n value === null ||\n (typeof value !== \"object\" && typeof value !== \"function\")\n );\n }\n\n invalidateReverseDeps(): void {\n this.reverseDepsCache = null;\n this.childDepsIndex = null;\n this.orderedAllEntriesCache = null;\n this.validatedEntriesSignature = null;\n this.validatedEntriesRef = null;\n this.orderedIndexByPathCache = null;\n this.equalityCache.clear();\n }\n\n apply(values: T, changedPaths?: readonly string[]): T {\n const computedEntries = this.getComputedEntries(values);\n if (computedEntries.length === 0) return values;\n\n this.ensureEntriesAreValid(computedEntries);\n\n const entriesToRun = this.resolveEntriesToRun(\n computedEntries,\n changedPaths,\n );\n\n if (entriesToRun.length === 0) {\n return values;\n }\n\n let nextValues = values;\n const failedPaths = new Set<string>();\n\n for (const entry of entriesToRun) {\n // Skip this entry if any of its declared dependencies failed in this run.\n if (entry.dependsOn.some((dep) => failedPaths.has(dep))) {\n failedPaths.add(entry.path);\n continue;\n }\n\n let newValue: unknown;\n try {\n newValue = entry.compute(nextValues);\n } catch (error) {\n this.onError?.(error, entry.path);\n failedPaths.add(entry.path);\n continue;\n }\n const currentValue = getDeepValue(nextValues, entry.path);\n\n const cached = this.equalityCache.get(entry.path);\n let valuesEqual: boolean;\n const canUseScalarCache =\n this.isCacheableScalar(currentValue) &&\n this.isCacheableScalar(newValue);\n\n if (\n canUseScalarCache &&\n cached &&\n cached.current === currentValue &&\n cached.next === newValue\n ) {\n valuesEqual = cached.equal;\n } else {\n valuesEqual = deepEqual(currentValue, newValue);\n\n if (canUseScalarCache) {\n this.equalityCache.set(entry.path, {\n current: currentValue,\n next: newValue,\n equal: valuesEqual,\n });\n } else {\n this.equalityCache.delete(entry.path);\n }\n }\n\n if (!valuesEqual) {\n nextValues = setDeepValue(nextValues, entry.path, newValue);\n }\n }\n return nextValues;\n }\n\n private getReverseDependencies(\n entries: BitComputedEntry<T>[],\n ): Map<string, Set<string>> {\n if (this.reverseDepsCache) return this.reverseDepsCache;\n\n const map = new Map<string, Set<string>>();\n\n for (const entry of entries) {\n for (const dep of entry.dependsOn) {\n let dependents = map.get(dep);\n if (!dependents) {\n dependents = new Set();\n map.set(dep, dependents);\n }\n dependents.add(entry.path);\n }\n }\n\n const childIdx = new Map<string, Set<string>>();\n\n for (const dep of map.keys()) {\n const segments = dep.split(\".\");\n for (let len = 1; len < segments.length; len++) {\n const prefix = segments.slice(0, len).join(\".\");\n let children = childIdx.get(prefix);\n if (!children) {\n children = new Set();\n childIdx.set(prefix, children);\n }\n children.add(dep);\n }\n }\n\n this.reverseDepsCache = map;\n this.childDepsIndex = childIdx;\n return map;\n }\n\n private resolveEntriesToRun(\n entries: BitComputedEntry<T>[],\n changedPaths?: readonly string[],\n ): BitComputedEntry<T>[] {\n if (\n !changedPaths ||\n changedPaths.length === 0 ||\n changedPaths.includes(\"*\")\n ) {\n return this.getOrderedAllEntries(entries);\n }\n\n const reverseDependencies = this.getReverseDependencies(entries);\n const affectedPaths = new Set<string>();\n const queue = [...changedPaths];\n let queueIndex = 0;\n\n while (queueIndex < queue.length) {\n const currentPath = queue[queueIndex++]!;\n const dependents = this.getDependentsForPath(\n reverseDependencies,\n currentPath,\n );\n\n if (!dependents) {\n continue;\n }\n\n for (const dependentPath of dependents) {\n if (affectedPaths.has(dependentPath)) {\n continue;\n }\n\n affectedPaths.add(dependentPath);\n queue.push(dependentPath);\n }\n }\n\n if (affectedPaths.size === 0) {\n return [];\n }\n\n const orderedAllEntries = this.getOrderedAllEntries(entries);\n const indexByPath = this.getOrderedIndexByPath(entries, orderedAllEntries);\n const affectedEntries: Array<{\n index: number;\n entry: BitComputedEntry<T>;\n }> = [];\n\n affectedPaths.forEach((path) => {\n const entryIndex = indexByPath.get(path);\n if (entryIndex === undefined) {\n return;\n }\n\n const entry = orderedAllEntries[entryIndex];\n if (!entry) {\n return;\n }\n\n affectedEntries.push({ index: entryIndex, entry });\n });\n\n affectedEntries.sort((left, right) => left.index - right.index);\n return affectedEntries.map((item) => item.entry);\n }\n\n private orderEntries(entries: BitComputedEntry<T>[]) {\n if (entries.length <= 1) {\n return entries;\n }\n\n const entryByPath = new Map(entries.map((entry) => [entry.path, entry]));\n const inDegree = new Map<string, number>();\n const dependents = new Map<string, Set<string>>();\n\n entries.forEach((entry) => inDegree.set(entry.path, 0));\n\n entries.forEach((entry) => {\n entry.dependsOn.forEach((dependencyPath) => {\n if (!entryByPath.has(dependencyPath)) {\n return;\n }\n\n const nextDependents = dependents.get(dependencyPath) ?? new Set();\n if (!nextDependents.has(entry.path)) {\n nextDependents.add(entry.path);\n dependents.set(dependencyPath, nextDependents);\n inDegree.set(entry.path, (inDegree.get(entry.path) ?? 0) + 1);\n }\n });\n });\n\n const queue = entries\n .filter((entry) => (inDegree.get(entry.path) ?? 0) === 0)\n .map((entry) => entry.path);\n const orderedPaths: string[] = [];\n\n while (queue.length > 0) {\n const currentPath = queue.shift()!;\n orderedPaths.push(currentPath);\n\n const nextDependents = dependents.get(currentPath);\n if (!nextDependents) {\n continue;\n }\n\n nextDependents.forEach((dependentPath) => {\n const nextDegree = (inDegree.get(dependentPath) ?? 0) - 1;\n inDegree.set(dependentPath, nextDegree);\n\n if (nextDegree === 0) {\n queue.push(dependentPath);\n }\n });\n }\n\n if (orderedPaths.length !== entries.length) {\n throw new Error(\n \"BitStore: cyclic computed dependencies detected. Check computedDependsOn definitions.\",\n );\n }\n\n return orderedPaths.map((path) => entryByPath.get(path)!);\n }\n\n private getOrderedAllEntries(entries: BitComputedEntry<T>[]) {\n const signature = this.createEntriesSignature(entries);\n if (\n this.orderedAllEntriesCache &&\n this.orderedAllEntriesCache.signature === signature\n ) {\n return this.orderedAllEntriesCache.ordered;\n }\n\n const ordered = this.orderEntries(entries);\n this.orderedAllEntriesCache = { signature, ordered };\n return ordered;\n }\n\n private getOrderedIndexByPath(\n entries: BitComputedEntry<T>[],\n orderedEntries: BitComputedEntry<T>[],\n ): Map<string, number> {\n const signature = this.createEntriesSignature(entries);\n if (\n this.orderedIndexByPathCache &&\n this.orderedIndexByPathCache.signature === signature\n ) {\n return this.orderedIndexByPathCache.indexByPath;\n }\n\n const indexByPath = new Map<string, number>();\n orderedEntries.forEach((entry, index) => {\n indexByPath.set(entry.path, index);\n });\n\n this.orderedIndexByPathCache = { signature, indexByPath };\n return indexByPath;\n }\n\n private ensureEntriesAreValid(entries: BitComputedEntry<T>[]) {\n if (this.validatedEntriesRef === entries) {\n return;\n }\n\n const signature = this.createEntriesSignature(entries);\n if (this.validatedEntriesSignature === signature) {\n this.validatedEntriesRef = entries;\n return;\n }\n\n entries.forEach((entry) => this.assertDependencies(entry));\n this.invalidateReverseDeps();\n this.validatedEntriesSignature = signature;\n this.validatedEntriesRef = entries;\n }\n\n private createEntriesSignature(entries: BitComputedEntry<T>[]): string {\n return entries\n .map((entry) => `${entry.path}:${entry.dependsOn.join(\",\")}`)\n .join(\"|\");\n }\n\n private getDependentsForPath(\n reverseDependencies: Map<string, Set<string>>,\n changedPath: string,\n ) {\n const dependents = new Set<string>();\n\n const collect = (dependencyPath: string) => {\n const listeners = reverseDependencies.get(dependencyPath);\n if (!listeners) {\n return;\n }\n\n listeners.forEach((path) => dependents.add(path));\n };\n\n collect(changedPath);\n\n const parentSegments = changedPath.split(\".\");\n while (parentSegments.length > 1) {\n parentSegments.pop();\n collect(parentSegments.join(\".\"));\n }\n\n const childKeys = this.childDepsIndex?.get(changedPath);\n if (childKeys) {\n for (const childDep of childKeys) {\n collect(childDep);\n }\n }\n\n return dependents;\n }\n\n private assertDependencies(entry: BitComputedEntry<T>) {\n if (entry.dependsOn.length === 0) {\n throw new Error(\n `BitStore: computed field \\`${entry.path}\\` requires explicit computedDependsOn in v4.`,\n );\n }\n\n if (entry.dependsOn.includes(entry.path)) {\n throw new Error(\n `BitStore: computed field \\`${entry.path}\\` cannot depend on itself.`,\n );\n }\n }\n}\n"]}