@lehnihon/bit-form 2.2.7 → 2.2.8

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 (158) hide show
  1. package/README.md +6 -6
  2. package/dist/angular/index.cjs +1 -1
  3. package/dist/angular/index.cjs.map +1 -1
  4. package/dist/angular/index.d.cts +10 -8
  5. package/dist/angular/index.d.ts +10 -8
  6. package/dist/angular/index.js +1 -1
  7. package/dist/angular/index.js.map +1 -1
  8. package/dist/{array-controller-DtkmcnUr.d.ts → array-controller-B5bfXV1W.d.cts} +4 -4
  9. package/dist/{array-controller-C1A5VKYd.d.cts → array-controller-Cx-DMH7Y.d.ts} +4 -4
  10. package/dist/bus-B2VEKrPI.d.ts +19 -0
  11. package/dist/bus-ZLQeq4Vr.d.cts +19 -0
  12. package/dist/chunk-5NA2TFPG.js +1 -0
  13. package/dist/chunk-5NA2TFPG.js.map +1 -0
  14. package/dist/chunk-63OJBMKK.js +2 -0
  15. package/dist/chunk-63OJBMKK.js.map +1 -0
  16. package/dist/chunk-BSGJ3T5S.cjs +2 -0
  17. package/dist/chunk-BSGJ3T5S.cjs.map +1 -0
  18. package/dist/chunk-CPP7ELA5.js +2 -0
  19. package/dist/chunk-CPP7ELA5.js.map +1 -0
  20. package/dist/chunk-D7JQWF6V.cjs +2 -0
  21. package/dist/chunk-D7JQWF6V.cjs.map +1 -0
  22. package/dist/chunk-E2NZR44P.js +2 -0
  23. package/dist/chunk-E2NZR44P.js.map +1 -0
  24. package/dist/chunk-EQ55DKX2.js +2 -0
  25. package/dist/chunk-EQ55DKX2.js.map +1 -0
  26. package/dist/chunk-JC4R5WCC.js +2 -0
  27. package/dist/chunk-JC4R5WCC.js.map +1 -0
  28. package/dist/chunk-M6WBNHIT.cjs +2 -0
  29. package/dist/chunk-M6WBNHIT.cjs.map +1 -0
  30. package/dist/chunk-MFSQATNZ.cjs +2 -0
  31. package/dist/chunk-MFSQATNZ.cjs.map +1 -0
  32. package/dist/chunk-MFTWAFMG.cjs +2 -0
  33. package/dist/chunk-MFTWAFMG.cjs.map +1 -0
  34. package/dist/chunk-P2YWYBWG.cjs +2 -0
  35. package/dist/chunk-P2YWYBWG.cjs.map +1 -0
  36. package/dist/chunk-RD73EBSN.js +2 -0
  37. package/dist/chunk-RD73EBSN.js.map +1 -0
  38. package/dist/chunk-T2JRSWQU.cjs +2 -0
  39. package/dist/chunk-T2JRSWQU.cjs.map +1 -0
  40. package/dist/chunk-UQ3DSUWC.js +2 -0
  41. package/dist/chunk-UQ3DSUWC.js.map +1 -0
  42. package/dist/chunk-VZHG372Q.cjs +2 -0
  43. package/dist/chunk-VZHG372Q.cjs.map +1 -0
  44. package/dist/chunk-W2E5UIXT.js +2 -0
  45. package/dist/chunk-W2E5UIXT.js.map +1 -0
  46. package/dist/chunk-W5CLDRRE.cjs +1 -0
  47. package/dist/chunk-W5CLDRRE.cjs.map +1 -0
  48. package/dist/core/bindings.cjs +2 -0
  49. package/dist/core/bindings.cjs.map +1 -0
  50. package/dist/core/bindings.d.cts +81 -0
  51. package/dist/core/bindings.d.ts +81 -0
  52. package/dist/core/bindings.js +2 -0
  53. package/dist/core/bindings.js.map +1 -0
  54. package/dist/core/status.cjs +2 -0
  55. package/dist/core/status.cjs.map +1 -0
  56. package/dist/core/status.d.cts +44 -0
  57. package/dist/core/status.d.ts +44 -0
  58. package/dist/core/status.js +2 -0
  59. package/dist/core/status.js.map +1 -0
  60. package/dist/core/store.cjs +2 -0
  61. package/dist/core/store.cjs.map +1 -0
  62. package/dist/core/store.d.cts +84 -0
  63. package/dist/core/store.d.ts +84 -0
  64. package/dist/core/store.js +2 -0
  65. package/dist/core/store.js.map +1 -0
  66. package/dist/core/utils.cjs +2 -0
  67. package/dist/core/utils.cjs.map +1 -0
  68. package/dist/core/utils.d.cts +81 -0
  69. package/dist/core/utils.d.ts +81 -0
  70. package/dist/core/utils.js +2 -0
  71. package/dist/core/utils.js.map +1 -0
  72. package/dist/core.cjs +1 -1
  73. package/dist/core.cjs.map +1 -1
  74. package/dist/core.d.cts +14 -122
  75. package/dist/core.d.ts +14 -122
  76. package/dist/core.js +1 -1
  77. package/dist/devtools/bridge.cjs +1 -1
  78. package/dist/devtools/bridge.cjs.map +1 -1
  79. package/dist/devtools/bridge.d.cts +3 -2
  80. package/dist/devtools/bridge.d.ts +3 -2
  81. package/dist/devtools/bridge.js +1 -1
  82. package/dist/devtools/index.cjs +2 -2
  83. package/dist/devtools/index.cjs.map +1 -1
  84. package/dist/devtools/index.d.cts +3 -2
  85. package/dist/devtools/index.d.ts +3 -2
  86. package/dist/devtools/index.js +1 -1
  87. package/dist/devtools/index.js.map +1 -1
  88. package/dist/{field-binding-X5TkvfUt.d.cts → field-binding-B_OX3bjp.d.cts} +1 -1
  89. package/dist/{field-binding-Bi1g-D8X.d.ts → field-binding-MX6jVQbT.d.ts} +1 -1
  90. package/dist/index.cjs +1 -1
  91. package/dist/index.cjs.map +1 -1
  92. package/dist/index.d.cts +8 -85
  93. package/dist/index.d.ts +8 -85
  94. package/dist/index.js +1 -1
  95. package/dist/mask.d.cts +2 -2
  96. package/dist/mask.d.ts +2 -2
  97. package/dist/meta-types-Bzmm21TP.d.cts +18 -0
  98. package/dist/meta-types-Bzmm21TP.d.ts +18 -0
  99. package/dist/react/index.cjs +1 -1
  100. package/dist/react/index.cjs.map +1 -1
  101. package/dist/react/index.d.cts +11 -9
  102. package/dist/react/index.d.ts +11 -9
  103. package/dist/react/index.js +1 -1
  104. package/dist/react/index.js.map +1 -1
  105. package/dist/react-native/index.cjs +1 -1
  106. package/dist/react-native/index.cjs.map +1 -1
  107. package/dist/react-native/index.d.cts +9 -7
  108. package/dist/react-native/index.d.ts +9 -7
  109. package/dist/react-native/index.js +1 -1
  110. package/dist/react-native/index.js.map +1 -1
  111. package/dist/resolvers/index.cjs +1 -1
  112. package/dist/resolvers/index.cjs.map +1 -1
  113. package/dist/resolvers/index.d.cts +3 -2
  114. package/dist/resolvers/index.d.ts +3 -2
  115. package/dist/resolvers/index.js +1 -1
  116. package/dist/resolvers/joi.d.cts +3 -2
  117. package/dist/resolvers/joi.d.ts +3 -2
  118. package/dist/resolvers/yup.d.cts +3 -2
  119. package/dist/resolvers/yup.d.ts +3 -2
  120. package/dist/resolvers/zod.d.cts +3 -2
  121. package/dist/resolvers/zod.d.ts +3 -2
  122. package/dist/store-api-types-D-ZHxzRy.d.cts +161 -0
  123. package/dist/store-api-types-DPi30jQF.d.ts +161 -0
  124. package/dist/{bus-DgilLszS.d.ts → types-CG5nYeRk.d.ts} +76 -45
  125. package/dist/{bus-rcUiufS7.d.cts → types-D6LhF5GC.d.cts} +76 -45
  126. package/dist/{types-CUXh7PqD.d.cts → types-D8DgIUhJ.d.cts} +1 -1
  127. package/dist/{types-CUXh7PqD.d.ts → types-D8DgIUhJ.d.ts} +1 -1
  128. package/dist/{upload-EXnJLq8k.d.cts → upload-C2mpfhp1.d.cts} +1 -1
  129. package/dist/{upload-EXnJLq8k.d.ts → upload-C2mpfhp1.d.ts} +1 -1
  130. package/dist/{use-bit-persist-CIKFwtdM.d.cts → use-bit-persist-BTwy8kvA.d.ts} +8 -6
  131. package/dist/{use-bit-persist-Bc06fmqZ.d.ts → use-bit-persist-C2LHNTVv.d.cts} +8 -6
  132. package/dist/utils.cjs +2 -0
  133. package/dist/utils.cjs.map +1 -0
  134. package/dist/utils.d.cts +6 -0
  135. package/dist/utils.d.ts +6 -0
  136. package/dist/utils.js +2 -0
  137. package/dist/utils.js.map +1 -0
  138. package/dist/vue/index.cjs +1 -1
  139. package/dist/vue/index.cjs.map +1 -1
  140. package/dist/vue/index.d.cts +9 -7
  141. package/dist/vue/index.d.ts +9 -7
  142. package/dist/vue/index.js +1 -1
  143. package/dist/vue/index.js.map +1 -1
  144. package/package.json +32 -10
  145. package/dist/chunk-DIEE6LUO.js +0 -2
  146. package/dist/chunk-DIEE6LUO.js.map +0 -1
  147. package/dist/chunk-FUUQB4DV.cjs +0 -2
  148. package/dist/chunk-FUUQB4DV.cjs.map +0 -1
  149. package/dist/chunk-KWLLYQOL.cjs +0 -2
  150. package/dist/chunk-KWLLYQOL.cjs.map +0 -1
  151. package/dist/chunk-LIYZPSWM.js +0 -2
  152. package/dist/chunk-LIYZPSWM.js.map +0 -1
  153. package/dist/chunk-QAL6J5GQ.cjs +0 -2
  154. package/dist/chunk-QAL6J5GQ.cjs.map +0 -1
  155. package/dist/chunk-SA47B5OP.js +0 -2
  156. package/dist/chunk-SA47B5OP.js.map +0 -1
  157. package/dist/store-api-types-9ipdute1.d.ts +0 -187
  158. package/dist/store-api-types-B6_bPoVI.d.cts +0 -187
@@ -1,2 +0,0 @@
1
- import{b as nt,c as ot}from"./chunk-3NUJVIAM.js";function F(i){if(i===null||typeof i!="object")return i;if(typeof structuredClone=="function")return structuredClone(i);if(i instanceof Date)return new Date(i.getTime());if(i instanceof RegExp)return new RegExp(i.source,i.flags);if(Array.isArray(i))return i.map(e=>F(e));let t={};for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(t[e]=F(i[e]));return t}function u(i){return F(i)}function E(i,t){if(t===void 0)return u(i);if(t===null||typeof t!="object"||t instanceof Date||t instanceof RegExp||Array.isArray(t))return u(t);let e=i&&typeof i=="object"&&!Array.isArray(i)?u(i):{};for(let r of Object.keys(t)){let s=t[r],n=e[r];if(s!==null&&typeof s=="object"&&!Array.isArray(s)&&!(s instanceof Date)&&!(s instanceof RegExp)){e[r]=E(n,s);continue}e[r]=u(s)}return e}function T(i,t){return i===t?!0:i===null||typeof i!="object"||t===null||typeof t!="object"?!1:S(i,t)}function S(i,t){if(i===t)return!0;if(i===null||typeof i!="object"||t===null||typeof t!="object")return!1;if(i instanceof Date&&t instanceof Date)return i.getTime()===t.getTime();if(i instanceof RegExp&&t instanceof RegExp)return i.toString()===t.toString();let e=Object.keys(i),r=Object.keys(t);if(e.length!==r.length)return!1;for(let s of e)if(!Object.prototype.hasOwnProperty.call(t,s)||!S(i[s],t[s]))return!1;return!0}function lt(i,t,e="",r=new Set){if(T(i,t))return r;if(i===null||typeof i!="object"||t===null||typeof t!="object")return e&&r.add(e),r;if(Array.isArray(i)||Array.isArray(t))return!T(i,t)&&e&&r.add(e),r;let s=new Set;for(let n of Object.keys(i||{}))s.add(n);for(let n of Object.keys(t||{}))s.add(n);for(let n of s){let o=e?`${e}.${n}`:n;lt(i?.[n],t?.[n],o,r)}return r}var Ae=5e3,B=new Map;function De(i,t){if(B.has(i))B.delete(i);else if(B.size>=Ae){let e=B.keys().next().value;e!==void 0&&B.delete(e)}B.set(i,t)}function x(i){let t=B.get(i);if(t)return t;let e=i.split(".");return De(i,e),e}function h(i,t){if(!t)return i;let e=x(t),r=i;for(let s of e){if(r==null)return;r=r[s]}return r}function m(i,t,e){if(!t)return e;let r=x(t),s=Array.isArray(i)?[...i]:{...i},n=s;for(let o=0;o<r.length-1;o++){let a=r[o],l=r[o+1],d=Number(l),c=Number.isInteger(d)&&String(d)===l,g=n[a];g==null?n[a]=c?[]:{}:n[a]=Array.isArray(g)?[...g]:{...g},n=n[a]}return n[r[r.length-1]]=e,s}function St(i,t){if(t.length===0)return i;let e=Array.isArray(i)?[...i]:{...i},r=new WeakSet;e&&typeof e=="object"&&r.add(e);for(let[s,n]of t){let o=x(s),a=e;for(let l=0;l<o.length-1;l++){let d=o[l],c=o[l+1],g=Number(c),y=Number.isInteger(g)&&String(g)===c,f=a[d];f==null?(a[d]=y?[]:{},r.add(a[d])):typeof f=="object"?r.has(f)||(a[d]=Array.isArray(f)?[...f]:{...f},r.add(a[d])):(a[d]=y?[]:{},r.add(a[d])),a=a[d]}a[o[o.length-1]]=n}return e}function bt(i,t){if(!t)return Array.isArray(i)?[]:{};let e=x(t),r=Array.isArray(i)?[...i]:{...i},s=r;for(let o=0;o<e.length-1;o++){let a=e[o],l=s?.[a];if(l==null)return r;s[a]=Array.isArray(l)?[...l]:{...l},s=s[a]}let n=e[e.length-1];return Array.isArray(s)?s.splice(Number(n),1):s&&typeof s=="object"&&delete s[n],r}function ke(i,t){let e={},r=`${t}.`;for(let s in i)s!==t&&!s.startsWith(r)&&(e[s]=i[s]);return e}function Bt(i,t,e){let r={},s={},n={},o=`${t}.`;for(let a of Object.keys(i.errors)){let l=at(a,o,e);l&&(r[l]=i.errors[a])}for(let a of Object.keys(i.touched)){let l=at(a,o,e);l&&(s[l]=i.touched[a])}for(let a of Object.keys(i.isValidating)){let l=at(a,o,e);l&&(n[l]=i.isValidating[a])}return{errors:r,touched:s,isValidating:n}}function at(i,t,e){if(!i.startsWith(t))return i;let s=i.substring(t.length).split("."),n=parseInt(s[0],10),o=e(n);if(o===null)return null;let a=s.slice(1).join(".");return a?`${t}${o}.${a}`:`${t}${o}`}function V(i){if(typeof i!="object"||i===null||Array.isArray(i))return!1;let t=i.errors??i;return typeof t!="object"||t===null||Array.isArray(t)?!1:Object.values(t).every(e=>typeof e=="string"||Array.isArray(e)&&e.every(r=>typeof r=="string"))}function dt(i){return V(i)?i.errors??i:{}}function Tt(i){let{path:t,getFieldConfig:e,masks:r}=i,s=e(t)?.mask;if(s)return typeof s=="string"?r?.[s]:s}function vt(i){let{state:t,path:e,value:r,isHidden:s,isRequired:n,isDirty:o,isValidating:a}=i,l=e;return{value:r,error:t.errors[l],touched:!!t.touched[l],isHidden:s,isRequired:n,isDirty:o,isValidating:a}}function p(i,t,e){return{kind:"state.patch",partialState:i,changedPaths:t,skipComputed:e?.skipComputed}}function ct(i){return{kind:"field.touchMany",paths:i}}function b(i){return{kind:"form.persistMeta",patch:i}}function C(i,t){return{kind:"validation.commit",errors:i,isValid:t}}var M=class{constructor(t){this.getComputedEntries=t}equalityCache=new Map;reverseDepsCache=null;childDepsIndex=null;validatedEntriesSignature=null;orderedAllEntriesCache=null;invalidateReverseDeps(){this.reverseDepsCache=null,this.childDepsIndex=null,this.orderedAllEntriesCache=null,this.equalityCache.clear()}apply(t,e){let r=this.getComputedEntries();if(r.length===0)return t;this.ensureEntriesAreValid(r);let s=this.resolveEntriesToRun(r,e);if(s.length===0)return t;let n=t;for(let o of s){let a=o.compute(n),l=h(n,o.path),d=this.equalityCache.get(o.path),c;d&&d.current===l&&d.next===a?c=d.equal:(c=S(l,a),this.equalityCache.set(o.path,{current:l,next:a,equal:c})),c||(n=m(n,o.path,a))}return n}getReverseDependencies(t){if(this.reverseDepsCache)return this.reverseDepsCache;let e=new Map;for(let s of t)for(let n of s.dependsOn){let o=e.get(n);o||(o=new Set,e.set(n,o)),o.add(s.path)}let r=new Map;for(let s of e.keys()){let n=s.split(".");for(let o=1;o<n.length;o++){let a=n.slice(0,o).join("."),l=r.get(a);l||(l=new Set,r.set(a,l)),l.add(s)}}return this.reverseDepsCache=e,this.childDepsIndex=r,e}resolveEntriesToRun(t,e){if(!e||e.length===0||e.includes("*"))return this.getOrderedAllEntries(t);let r=this.getReverseDependencies(t),s=new Set,n=[...e];for(;n.length>0;){let o=n.shift(),a=this.getDependentsForPath(r,o);if(a)for(let l of a)s.has(l)||(s.add(l),n.push(l))}return s.size===0?[]:this.orderEntries(t.filter(o=>s.has(o.path)))}orderEntries(t){if(t.length<=1)return t;let e=new Map(t.map(a=>[a.path,a])),r=new Map,s=new Map;t.forEach(a=>r.set(a.path,0)),t.forEach(a=>{a.dependsOn.forEach(l=>{if(!e.has(l))return;let d=s.get(l)??new Set;d.has(a.path)||(d.add(a.path),s.set(l,d),r.set(a.path,(r.get(a.path)??0)+1))})});let n=t.filter(a=>(r.get(a.path)??0)===0).map(a=>a.path),o=[];for(;n.length>0;){let a=n.shift();o.push(a);let l=s.get(a);l&&l.forEach(d=>{let c=(r.get(d)??0)-1;r.set(d,c),c===0&&n.push(d)})}if(o.length!==t.length)throw new Error("BitStore: cyclic computed dependencies detected. Check computedDependsOn definitions.");return o.map(a=>e.get(a))}getOrderedAllEntries(t){let e=this.createEntriesSignature(t);if(this.orderedAllEntriesCache&&this.orderedAllEntriesCache.signature===e)return this.orderedAllEntriesCache.ordered;let r=this.orderEntries(t);return this.orderedAllEntriesCache={signature:e,ordered:r},r}ensureEntriesAreValid(t){let e=this.createEntriesSignature(t);this.validatedEntriesSignature!==e&&(t.forEach(r=>this.assertDependencies(r)),this.validatedEntriesSignature=e,this.invalidateReverseDeps())}createEntriesSignature(t){return t.map(e=>`${e.path}:${e.dependsOn.join(",")}`).join("|")}getDependentsForPath(t,e){let r=new Set,s=a=>{let l=t.get(a);l&&l.forEach(d=>r.add(d))};s(e);let n=e.split(".");for(;n.length>1;)n.pop(),s(n.join("."));let o=this.childDepsIndex?.get(e);if(o)for(let a of o)s(a);return r}assertDependencies(t){if(t.dependsOn.length===0)throw new Error(`BitStore: computed field \`${t.path}\` requires explicit computedDependsOn in v4.`);if(t.dependsOn.includes(t.path))throw new Error(`BitStore: computed field \`${t.path}\` cannot depend on itself.`)}};var A=class{dirtyPaths=new Set;dirtyPathIndex=new Set;dirtyPrefixRefCount=new Map;childrenByPrefix=new Map;updateForPath(t,e,r){this.removeDirtyChildren(t);let s=h(e,t),n=h(r,t);return T(s,n)?this.removeDirtyPath(t):this.addDirtyPath(t),this.dirtyPaths.size>0}rebuild(t,e){return this.dirtyPaths=lt(t,e),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(t){if(this.dirtyPathIndex.has(t))return!0;let e=t.split(".");for(;e.length>1;)if(e.pop(),this.dirtyPaths.has(e.join(".")))return!0;return!1}buildDirtyValues(t){if(this.dirtyPaths.size===0)return{};let e={},r=new Set;for(let s of this.dirtyPaths){let n=s.match(/^(.+)\.\d+/);if(n){let o=n[1];if(r.has(o))continue;r.add(o);let a=h(t,o);e=m(e,o,a)}else{let o=h(t,s);e=m(e,s,o)}}return e}rebuildIndex(){let t=new Set,e=new Map,r=new Map;for(let s of this.dirtyPaths)this.forEachPathPrefix(s,n=>{t.add(n),e.set(n,(e.get(n)??0)+1)}),this.forEachAncestorPrefix(s,n=>{let o=r.get(n);o?o.add(s):r.set(n,new Set([s]))});this.dirtyPathIndex=t,this.dirtyPrefixRefCount=e,this.childrenByPrefix=r}removeDirtyChildren(t){let e=this.childrenByPrefix.get(t);if(!(!e||e.size===0))for(let r of[...e])this.removeDirtyPath(r)}addDirtyPath(t){this.dirtyPaths.has(t)||(this.dirtyPaths.add(t),this.forEachPathPrefix(t,e=>{this.dirtyPathIndex.add(e),this.dirtyPrefixRefCount.set(e,(this.dirtyPrefixRefCount.get(e)??0)+1)}),this.forEachAncestorPrefix(t,e=>{let r=this.childrenByPrefix.get(e);r?r.add(t):this.childrenByPrefix.set(e,new Set([t]))}))}removeDirtyPath(t){this.dirtyPaths.has(t)&&(this.dirtyPaths.delete(t),this.forEachPathPrefix(t,e=>{let r=(this.dirtyPrefixRefCount.get(e)??0)-1;if(r<=0){this.dirtyPrefixRefCount.delete(e),this.dirtyPathIndex.delete(e);return}this.dirtyPrefixRefCount.set(e,r)}),this.forEachAncestorPrefix(t,e=>{this.childrenByPrefix.get(e)?.delete(t)}))}forEachPathPrefix(t,e){let r=t.split("."),s="";for(let n of r)s=s?`${s}.${n}`:n,e(s)}forEachAncestorPrefix(t,e){let r=t.split("."),s="";for(let n=0;n<r.length-1;n++)s=s?`${s}.${r[n]}`:r[n],e(s)}};var D=class{masks={};registerMask(t,e){this.masks={...this.masks,[t]:e}}unregisterMask(t){if(!(t in this.masks))return;let{[t]:e,...r}=this.masks;this.masks=r}resolveMask(t){return this.masks[t]}getAllMasks(){return this.masks}clear(){this.masks={}}};var k=class{fieldConfigs=new Map;scopeFieldsIndex=null;computedEntriesCache=null;transformEntriesCache=null;get(t){return this.fieldConfigs.get(t)}set(t,e){this.fieldConfigs.set(t,e),this.registerCachedIndexes(t,e)}delete(t){let e=this.fieldConfigs.get(t);return this.fieldConfigs.delete(t),this.unregisterCachedIndexes(t,e),e}has(t){return this.fieldConfigs.has(t)}forEach(t){this.fieldConfigs.forEach((e,r)=>t(e,r))}entries(){return Array.from(this.fieldConfigs.entries())}getScopeFields(t){if(!this.scopeFieldsIndex){let e=new Map;this.forEach((r,s)=>{if(!r.scope)return;let n=e.get(r.scope)??[];n.push(s),e.set(r.scope,n)}),this.scopeFieldsIndex=e}return this.scopeFieldsIndex.get(t)??[]}getComputedEntries(){if(!this.computedEntriesCache){let t=[];this.forEach((e,r)=>{e.computed&&t.push({path:r,compute:e.computed,dependsOn:e.computedDependsOn})}),this.computedEntriesCache=t}return this.computedEntriesCache}getTransformEntries(){if(!this.transformEntriesCache){let t=[];this.forEach((e,r)=>{e.transform&&t.push([r,e.transform])}),this.transformEntriesCache=t}return this.transformEntriesCache}invalidateIndexes(){this.scopeFieldsIndex=null,this.computedEntriesCache=null,this.transformEntriesCache=null}registerCachedIndexes(t,e){if(this.scopeFieldsIndex&&e.scope){let r=this.scopeFieldsIndex.get(e.scope)??[];r.includes(t)||(r.push(t),this.scopeFieldsIndex.set(e.scope,r))}this.computedEntriesCache&&e.computed&&this.computedEntriesCache.push({path:t,compute:e.computed,dependsOn:e.computedDependsOn}),this.transformEntriesCache&&e.transform&&this.transformEntriesCache.push([t,e.transform])}unregisterCachedIndexes(t,e){if(!e){this.invalidateIndexes();return}if(this.scopeFieldsIndex&&e.scope){let r=this.scopeFieldsIndex.get(e.scope);if(r){let s=r.filter(n=>n!==t);s.length>0?this.scopeFieldsIndex.set(e.scope,s):this.scopeFieldsIndex.delete(e.scope)}}this.computedEntriesCache&&e.computed&&(this.computedEntriesCache=this.computedEntriesCache.filter(r=>r.path!==t)),this.transformEntriesCache&&e.transform&&(this.transformEntriesCache=this.transformEntriesCache.filter(([r])=>r!==t))}};var R=class{constructor(t){this.getFieldConfig=t}dependencies=new Map;hiddenFields=new Set;conditionalVisibilityPaths=new Set;requiredPathsByDependency=new Map;requiredConditionalPaths=new Set;requiredEvaluationCache=new WeakMap;requiredEvaluationCacheDirty=!1;getHiddenFields(){return this.hiddenFields}onRegister(t,e,r){e.conditional?.showIf&&this.conditionalVisibilityPaths.add(t);let s=e.conditional?.dependsOn;s&&s.forEach(n=>{this.dependencies.has(n)||this.dependencies.set(n,new Set),this.dependencies.get(n).add(t)}),s&&e.conditional?.requiredIf&&(this.requiredConditionalPaths.add(t),s.forEach(n=>{this.requiredPathsByDependency.has(n)||this.requiredPathsByDependency.set(n,new Set),this.requiredPathsByDependency.get(n).add(t)})),this.requiredEvaluationCacheDirty=!0,this.evaluateFieldCondition(t,r)}onUnregister(t,e){this.hiddenFields.delete(t),this.conditionalVisibilityPaths.delete(t),this.dependencies.delete(t),this.requiredEvaluationCacheDirty=!0,this.requiredConditionalPaths.delete(t),e?.conditional?.dependsOn?.forEach(r=>{let s=this.requiredPathsByDependency.get(r);s&&(s.delete(t),s.size===0&&this.requiredPathsByDependency.delete(r))}),this.dependencies.forEach(r=>{r.delete(t)})}isHidden(t){return this.hiddenFields.has(t)}hasDependents(t){return(this.dependencies.get(t)?.size??0)>0}isRequired(t,e){let r=this.getFieldConfig(t);if(!r||this.isHidden(t)||!r.conditional?.requiredIf)return!1;this.requiredEvaluationCacheDirty&&(this.requiredEvaluationCache=new WeakMap,this.requiredEvaluationCacheDirty=!1);let s=this.requiredEvaluationCache.get(e);if(s||(s=new Map,this.requiredEvaluationCache.set(e,s)),s.has(t))return s.get(t);let n=!!r.conditional.requiredIf(e);return s.set(t,n),n}getRequiredErrors(t){let e={};return this.requiredConditionalPaths.forEach(r=>{let s=this.getFieldConfig(r);if(s&&this.isRequired(r,t)){let n=h(t,r);this.isEmpty(n)&&(e[r]=s.conditional?.requiredMessage??"required field")}}),e}evaluateAll(t){this.conditionalVisibilityPaths.forEach(e=>{this.evaluateFieldCondition(e,t)})}updateDependencies(t,e){let r=[],s=[t],n=new Set;for(;s.length>0;){let o=s.shift();if(n.has(o))continue;n.add(o);let a=this.dependencies.get(o);a&&a.forEach(l=>{let d=this.isHidden(l);this.evaluateFieldCondition(l,e);let c=this.isHidden(l);d!==c&&r.push(l),s.push(l)})}return r}evaluateFieldCondition(t,e){let s=this.getFieldConfig(t)?.conditional?.showIf;s&&(s(e)?this.hiddenFields.delete(t):this.hiddenFields.add(t))}isEmpty(t){return t==null||typeof t=="string"&&t.trim()===""||Array.isArray(t)&&t.length===0}};var w=class{catalog=new k;conditions=new R(t=>this.catalog.get(t));getFieldConfig(t){return this.catalog.get(t)}forEachFieldConfig(t){this.catalog.forEach((e,r)=>t(e,r))}hasFieldConfig(t){return this.catalog.has(t)}getHiddenFields(){return this.conditions.getHiddenFields()}register(t,e,r){this.catalog.set(t,e),this.conditions.onRegister(t,e,r)}unregister(t){let e=this.catalog.delete(t);this.conditions.onUnregister(t,e)}unregisterPrefix(t){let e=[];return this.catalog.forEach((r,s)=>{s.startsWith(t)&&e.push([s,r])}),e.forEach(([r])=>this.unregister(r)),e}isHidden(t){return this.conditions.isHidden(t)}hasDependents(t){return this.conditions.hasDependents(t)}isRequired(t,e){return this.conditions.isRequired(t,e)}getRequiredErrors(t){return this.conditions.getRequiredErrors(t)}evaluateAll(t){this.conditions.evaluateAll(t)}updateDependencies(t,e){return this.conditions.updateDependencies(t,e)}getScopeFields(t){return this.catalog.getScopeFields(t)}getComputedEntries(){return this.catalog.getComputedEntries()}getTransformEntries(){return this.catalog.getTransformEntries()}invalidateIndexes(){this.catalog.invalidateIndexes()}};function Re(){return`bit-form-${Math.random().toString(36).slice(2,9)}`}function Pt(i={}){let t=i.initialValues??{},e=i.validation,r=i.history,s=i.name?`bit-form:${i.name}:draft`:"bit-form:draft",n={enabled:i.persist?.enabled??!1,key:i.persist?.key??s,storage:i.persist?.storage,autoSave:i.persist?.autoSave??!0,debounceMs:i.persist?.debounceMs??300,mode:i.persist?.mode??"values",serialize:i.persist?.serialize??JSON.stringify,deserialize:i.persist?.deserialize??(o=>JSON.parse(o)),onError:i.persist?.onError};return{name:i.name,initialValues:u(t),resolver:e?.resolver,validationDelay:e?.delay??300,history:{enabled:r?.enabled??!1,limit:r?.limit??50},masks:i.masks,fields:i.fields,devTools:i.devTools,persist:n,idFactory:i.idFactory??Re,plugins:i.plugins??[],scheduler:i.scheduler,subscriptionCacheSize:i.subscriptionCacheSize,bus:i.bus}}function we(){if(typeof globalThis>"u")return;let i=globalThis.localStorage;if(i)return{getItem:t=>i.getItem(t),setItem:(t,e)=>i.setItem(t,e),removeItem:t=>i.removeItem(t)}}var I=class{constructor(t,e,r,s){this.config=t;this.getValues=e;this.getDirtyValues=r;this.applyRestoredValues=s}timer;getStorage(){return this.config.storage||we()}canPersist(){return!!(this.config.enabled&&this.config.key&&this.getStorage())}handleError(t){this.config.onError?.(t)}async saveNow(){if(!this.canPersist())return;let t=this.getStorage();if(t)try{let e=this.config.mode==="dirtyValues"?this.getDirtyValues():this.getValues(),r=this.config.serialize(e);await t.setItem(this.config.key,r)}catch(e){this.handleError(e)}}queueSave(){!this.canPersist()||!this.config.autoSave||(this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.saveNow()},this.config.debounceMs))}async restore(){if(!this.canPersist())return!1;let t=this.getStorage();if(!t)return!1;try{let e=await t.getItem(this.config.key);if(!e)return!1;let r=this.config.deserialize(e);return!r||typeof r!="object"?!1:(this.applyRestoredValues(r),!0)}catch(e){return this.handleError(e),!1}}async clear(){if(!this.canPersist())return;let t=this.getStorage();if(t)try{await t.removeItem(this.config.key)}catch(e){this.handleError(e)}}destroy(){this.timer&&(clearTimeout(this.timer),this.timer=void 0)}};var O=class{constructor(t,e){this.plugins=t;this.contextFactory=e}teardownFns=[];notifyingError=!1;setupAll(){let t=this.contextFactory();this.plugins.forEach(e=>{if(e.setup)try{let r=e.setup(t);typeof r=="function"&&this.teardownFns.push(r)}catch(r){this.reportError("setup",r,void 0,e.name)}})}async beforeValidate(t){await this.emitHook("beforeValidate",t)}async afterValidate(t){await this.emitHook("afterValidate",t)}async beforeSubmit(t){await this.emitHook("beforeSubmit",t)}async afterSubmit(t){await this.emitHook("afterSubmit",t)}onFieldChange(t){let e=this.contextFactory();this.plugins.forEach(r=>{let s=r.hooks?.onFieldChange;if(s)try{let n=s(t,e);Promise.resolve(n).catch(o=>{this.reportError("onFieldChange",o,t,r.name)})}catch(n){this.reportError("onFieldChange",n,t,r.name)}})}async reportError(t,e,r,s){if(this.notifyingError)return;this.notifyingError=!0;let n=this.contextFactory(),o={source:t,pluginName:s,error:e,event:r,values:n.getState().values,state:n.getState()};for(let a of this.plugins){let l=a.hooks?.onError;if(l)try{await l(o,n)}catch{}}this.notifyingError=!1}destroy(){for(let t=this.teardownFns.length-1;t>=0;t-=1){let e=this.teardownFns[t];try{e()}catch(r){this.reportError("teardown",r)}}this.teardownFns=[]}async emitHook(t,e){let r=this.contextFactory();for(let s of this.plugins){let n=s.hooks?.[t];if(n)try{await n(e,r)}catch(o){await this.reportError(t,o,e,s.name)}}}};var H=class{constructor(t,e,r,s,n,o=!0){this.storeId=t;this.storeInstance=e;this.bus=r;this.persistManager=s;this.pluginManager=n;this.enableBusDispatch=o}initialize(){this.pluginManager.setupAll(),this.enableBusDispatch&&(this.bus.stores[this.storeId]=this.storeInstance)}onStateUpdated(t,e){e&&this.persistManager.queueSave(),this.enableBusDispatch&&this.bus.dispatch(this.storeId,t)}restorePersisted(){return this.persistManager.restore()}savePersistedNow(){return this.persistManager.saveNow()}clearPersisted(){return this.persistManager.clear()}beforeValidate(t){return this.pluginManager.beforeValidate(t)}afterValidate(t){return this.pluginManager.afterValidate(t)}beforeSubmit(t){return this.pluginManager.beforeSubmit(t)}afterSubmit(t){return this.pluginManager.afterSubmit(t)}onFieldChange(t){this.pluginManager.onFieldChange(t)}reportOperationalError(t){return this.pluginManager.reportError(t.source,t.error,t.payload)}destroy(){this.persistManager.destroy(),this.pluginManager.destroy(),this.enableBusDispatch&&delete this.bus.stores[this.storeId]}};var v=class{constructor(t){this.steps=t}async run(t){for(let e of this.steps){if(t.halted)break;await e.run(t)}}},j=class{constructor(t){this.steps=t}run(t){for(let e of this.steps){if(t.halted)break;e.run(t)}}};function P(i){for(let t in i)return!0;return!1}function Ft(i){let{targetFields:t,currentErrors:e,allErrors:r,asyncErrors:s}=i;if(t&&t.length>0){let o={...e};t.forEach(l=>{r[l]?o[l]=r[l]:s.has(l)?o[l]=s.get(l):delete o[l]});let a=t.every(l=>!r[l]&&!s.has(l));return{committedErrors:o,result:a,mode:"scoped"}}return{committedErrors:{...Object.fromEntries(s.entries()),...r},result:void 0,mode:"global"}}function Et(i){let{targetFields:t,hiddenFields:e,getFieldConfig:r,forEachFieldConfig:s}=i,n=[];if(t&&t.length>0){for(let o of t){if(e.has(o))continue;r(o)?.validation?.asyncValidate&&n.push(o)}return n}return s&&s((o,a)=>{!o.validation?.asyncValidate||e.has(a)||n.push(a)}),n}async function xt(i){let{path:t,values:e,validationId:r,currentValidationId:s,getFieldConfig:n,cancelFieldAsync:o,createAbortController:a,setAbortController:l,clearAbortController:d,setFieldValidating:c,setAsyncError:g,clearAsyncError:y}=i,f=n(t)?.validation?.asyncValidate;if(!f){y(t);return}o(t);let st=a();l(t,st),c(t,!0);try{let mt=await f(h(e,t),e);if(st.signal.aborted||r!==s)return;mt?g(t,mt):y(t)}finally{!st.signal.aborted&&r===s&&c(t,!1),d(t)}}var q=class{constructor(t){this.port=t}cancelSchedulerTimeout;abortControllers=new Map;pendingJobs=new Map;handle(t,e,r,s){if(!r){this.cancel(t),this.port.setFieldValidating(t,!1);return}this.cancel(t),this.port.setFieldValidating(t,!0);let n=new AbortController;this.abortControllers.set(t,n),this.pendingJobs.set(t,{value:e,dueAt:Date.now()+s,validate:r,controller:n}),this.schedulePendingJobs()}cancel(t){this.pendingJobs.has(t)&&(this.pendingJobs.delete(t),this.schedulePendingJobs());let e=this.abortControllers.get(t);e&&(e.abort(),this.abortControllers.delete(t))}cleanupPrefix(t){for(let e of this.pendingJobs.keys())(e===t||e.startsWith(`${t}.`))&&(this.cancel(e),this.port.clearAsyncError(e),this.port.setFieldValidating(e,!1))}cancelAll(){this.cancelSchedulerTimeout&&(this.cancelSchedulerTimeout(),this.cancelSchedulerTimeout=void 0),this.pendingJobs.clear(),this.abortControllers.forEach(t=>t.abort()),this.abortControllers.clear()}schedulePendingJobs(){this.cancelSchedulerTimeout&&(this.cancelSchedulerTimeout(),this.cancelSchedulerTimeout=void 0);let t=Number.POSITIVE_INFINITY;for(let e of this.pendingJobs.values())e.dueAt<t&&(t=e.dueAt);Number.isFinite(t)&&(this.cancelSchedulerTimeout=this.port.schedule(()=>{this.cancelSchedulerTimeout=void 0,this.flushPendingJobs()},Math.max(0,t-Date.now())))}async flushPendingJobs(){this.cancelSchedulerTimeout=void 0;let t=Date.now(),e=Array.from(this.pendingJobs.entries()).filter(([,r])=>r.dueAt<=t);if(e.length===0){this.schedulePendingJobs();return}e.forEach(([r])=>{this.pendingJobs.delete(r)}),await Promise.all(e.map(([r,s])=>this.runJob(r,s))),this.schedulePendingJobs()}async runJob(t,e){if(!e.controller.signal.aborted)try{let r=await e.validate(e.value,this.port.getValues());if(e.controller.signal.aborted)return;r?this.port.setAsyncError(t,r):(this.port.clearAsyncError(t),await this.port.onValidationPassed(t))}finally{e.controller.signal.aborted||this.port.setFieldValidating(t,!1),this.abortControllers.delete(t)}}};var _=class{constructor(t){this.port=t}cancelTimeout;pendingScopeFields=null;trigger(t,e){this.cancelTimeout&&(this.cancelTimeout(),this.cancelTimeout=void 0);let r=this.port.validationDelay??300,s=e?.forceDebounce?Math.max(1,r):r;if(s>0){if(t&&t.length>0)if(!this.pendingScopeFields)this.pendingScopeFields=new Set(t);else for(let o of t)this.pendingScopeFields.add(o);else this.pendingScopeFields=null;let n=this.pendingScopeFields?Array.from(this.pendingScopeFields):void 0;this.cancelTimeout=this.port.schedule(()=>{this.pendingScopeFields=null,this.cancelTimeout=void 0,this.port.validate({scopeFields:n})},s)}else this.pendingScopeFields=null,this.port.validate({scopeFields:t})}cancelPending(){this.cancelTimeout&&(this.cancelTimeout(),this.cancelTimeout=void 0),this.pendingScopeFields=null}};var U=class{constructor(t){this.store=t;this.schedule=t.config.scheduler?.schedule??((e,r)=>{let s=setTimeout(e,r);return()=>clearTimeout(s)}),this.debouncer=new _({schedule:(e,r)=>this.schedule(e,r),validate:e=>this.validate(e),validationDelay:t.config.validationDelay??300}),this.asyncScheduler=new q({schedule:(e,r)=>this.schedule(e,r),getValues:()=>this.store.getState().values,setFieldValidating:(e,r)=>this.updateFieldValidating(e,r),setAsyncError:(e,r)=>{this.asyncErrors.set(e,r),this.store.setError(e,r)},clearAsyncError:e=>{this.asyncErrors.delete(e)},onValidationPassed:async e=>{await this.commitSynchronousScopeValidation([e])}}),this.validationPipeline=new v([{name:"validate:resolve-target-fields",run:e=>this.resolveTargetFields(e)},{name:"validate:before-hooks",run:async e=>this.runBeforeValidateHooks(e)},{name:"validate:sync-track",run:async e=>this.runSynchronousTrack(e)},{name:"validate:async-track",run:async e=>this.runAsyncTrack(e)},{name:"validate:abort-check",run:async e=>this.abortIfOutdated(e)},{name:"validate:async-track-merge",run:e=>this.mergeAsyncTrack(e)},{name:"validate:commit",run:async e=>this.commitValidation(e)}])}currentValidationId=0;validatingCount=0;asyncErrors=new Map;immediateAbortControllers=new Map;validationPipeline;schedule;asyncScheduler;debouncer;updateFieldValidating(t,e){let r=this.store.getState();if(!!r.isValidating[t]===e)return;let n={...r.isValidating};e?(n[t]=!0,this.validatingCount+=1):(delete n[t],this.validatingCount=Math.max(0,this.validatingCount-1)),this.store.dispatch(p({isValidating:n}))}cancelFieldAsync(t){this.asyncScheduler.cancel(t);let e=this.immediateAbortControllers.get(t);e&&(e.abort(),this.immediateAbortControllers.delete(t))}cleanupField(t){this.cancelFieldAsync(t),this.asyncErrors.delete(t),this.updateFieldValidating(t,!1)}cleanupPrefix(t){this.asyncScheduler.cleanupPrefix(t);for(let e of this.immediateAbortControllers.keys())(e===t||e.startsWith(`${t}.`))&&this.cleanupField(e)}beginExternalValidation(t){this.cancelFieldAsync(t),this.updateFieldValidating(t,!0)}endExternalValidation(t){this.updateFieldValidating(t,!1)}async setExternalError(t,e){if(e){this.asyncErrors.set(t,e),this.store.setError(t,e);return}if(this.asyncErrors.delete(t),this.store.validate){await this.store.validate({scopeFields:[t]});return}let r={...this.store.getState().errors};delete r[t],this.store.dispatch(C(r,!P(r)))}handleAsync(t,e){let r=this.store.getFieldConfig(t),s=r?.validation?.asyncValidate,n=r?.validation?.asyncValidateOn??"blur";if(!s||n!=="change"){this.cancelFieldAsync(t),this.updateFieldValidating(t,!1);return}let o=r.validation?.asyncValidateDelay??500;this.asyncScheduler.handle(t,e,s,o)}hasValidationsInProgress(t){let e=this.store.getState();return t&&t.length>0?t.some(r=>!!e.isValidating[r]):this.validatingCount>0}trigger(t,e){this.debouncer.trigger(t,e)}async validate(t){let e={options:t,validationId:++this.currentValidationId,currentState:this.store.getState(),targetFields:t?.scopeFields,allErrors:{},committedErrors:{},isValid:!0,result:!0,aborted:!1};return await this.validationPipeline.run(e),e.result}clear(t){this.cancelFieldAsync(t),this.updateFieldValidating(t,!1),this.asyncErrors.delete(t)}cancelAll(){this.validatingCount=0,this.debouncer.cancelPending(),this.asyncScheduler.cancelAll(),this.asyncErrors.clear(),this.immediateAbortControllers.forEach(t=>{t.abort()}),this.immediateAbortControllers.clear(),this.store.dispatch(p({isValidating:{}}))}resolveTargetFields(t){if(t.options?.scope){let e=this.store.getScopeFields(t.options.scope);e.length>0&&(t.targetFields=e)}}async runBeforeValidateHooks(t){await this.store.emitBeforeValidate({values:t.currentState.values,state:t.currentState,scope:t.options?.scope,scopeFields:t.targetFields})}async runSynchronousTrack(t){let e=this.store.config.resolver?await this.store.config.resolver(t.currentState.values,{scopeFields:t.targetFields}):{},r=this.store.getRequiredErrors(t.currentState.values);t.allErrors={...e,...r},this.store.getHiddenFields().forEach(s=>{delete t.allErrors[s],this.asyncErrors.delete(s)})}async runAsyncTrack(t){let e=Et({targetFields:t.targetFields,hiddenFields:this.store.getHiddenFields(),getFieldConfig:r=>this.store.getFieldConfig(r),forEachFieldConfig:this.store.forEachFieldConfig});e.length!==0&&await Promise.all(e.map(r=>this.runImmediateAsyncValidation(r,t.currentState.values,t.validationId)))}mergeAsyncTrack(t){let e=Ft({targetFields:t.targetFields,currentErrors:t.currentState.errors,allErrors:t.allErrors,asyncErrors:this.asyncErrors});t.committedErrors=e.committedErrors,t.isValid=!P(e.committedErrors),t.result=e.mode==="scoped"?e.result:t.isValid}async abortIfOutdated(t){t.validationId!==this.currentValidationId&&(t.aborted=!0,t.result=t.currentState.isValid,await this.store.emitAfterValidate({values:this.store.getState().values,state:this.store.getState(),scope:t.options?.scope,scopeFields:t.targetFields,errors:this.store.getState().errors,result:t.currentState.isValid,aborted:!0}),t.halted=!0)}async commitValidation(t){this.store.dispatch(C(t.committedErrors,t.isValid)),await this.store.emitAfterValidate({values:this.store.getState().values,state:this.store.getState(),scope:t.options?.scope,scopeFields:t.targetFields,errors:t.committedErrors,result:t.result}),t.halted=!0}async runImmediateAsyncValidation(t,e,r){await xt({path:t,values:e,validationId:r,currentValidationId:this.currentValidationId,getFieldConfig:s=>this.store.getFieldConfig(s),cancelFieldAsync:s=>this.cancelFieldAsync(s),createAbortController:()=>new AbortController,setAbortController:(s,n)=>{this.immediateAbortControllers.set(s,n)},clearAbortController:s=>{this.immediateAbortControllers.delete(s)},setFieldValidating:(s,n)=>this.updateFieldValidating(s,n),setAsyncError:(s,n)=>{this.asyncErrors.set(s,n)},clearAsyncError:s=>{this.asyncErrors.delete(s)}})}async commitSynchronousScopeValidation(t){let e=this.store.getState(),r=this.store.config.resolver?await this.store.config.resolver(e.values,{scopeFields:t}):{},s=this.store.getRequiredErrors(e.values),n={...r,...s};this.store.getHiddenFields().forEach(a=>{delete n[a],this.asyncErrors.delete(a)});let o={...e.errors};t.forEach(a=>{n[a]?o[a]=n[a]:this.asyncErrors.has(a)?o[a]=this.asyncErrors.get(a):delete o[a]}),this.store.dispatch(C(o,!P(o)))}};var z=class{constructor(t){this.store=t;this.fieldUpdatePipeline=new j([{name:"field:clear-current-error",run:e=>this.clearCurrentError(e)},{name:"field:update-dependencies",run:e=>this.updateDependencies(e)},{name:"field:update-dirty",run:e=>this.updateDirtyState(e)},{name:"field:commit-state",run:e=>this.commitFieldState(e)},{name:"field:emit-change",run:e=>this.emitFieldChange(e)},{name:"field:trigger-validate",run:e=>this.triggerResolverValidation(e)},{name:"field:trigger-async-validate",run:e=>this.triggerAsyncValidation(e)}])}fieldUpdatePipeline;reusableContext={path:"",value:void 0,meta:{origin:"setField"},previousValue:void 0,nextValues:{},nextErrors:{},hasMutatedErrors:!1,toggledFields:[],isDirty:!1};isReusableContextBusy=!1;updateField(t,e,r={origin:"setField"}){let s=this.store.getState(),n=this.acquireContext();n.path=t,n.value=e,n.meta=r,n.previousValue=h(s.values,t),n.nextValues=m(s.values,t,e),n.nextErrors=s.errors,n.hasMutatedErrors=!1,n.toggledFields.length=0,n.isDirty=!1;let o=n===this.reusableContext;o&&(this.isReusableContextBusy=!0);try{this.fieldUpdatePipeline.run(n)}finally{o&&(this.isReusableContextBusy=!1)}}acquireContext(){return this.isReusableContextBusy?{path:"",value:void 0,meta:{origin:"setField"},previousValue:void 0,nextValues:{},nextErrors:{},hasMutatedErrors:!1,toggledFields:[],isDirty:!1}:this.reusableContext}clearCurrentError(t){let e=Object.prototype.hasOwnProperty.call(t.nextErrors,t.path);e&&!t.hasMutatedErrors&&(t.nextErrors={...t.nextErrors},t.hasMutatedErrors=!0),e&&delete t.nextErrors[t.path],this.store.clearFieldValidation(t.path)}updateDependencies(t){if(typeof this.store.hasDependentFields=="function"&&!this.store.hasDependentFields(t.path)){t.toggledFields.length=0;return}t.toggledFields=this.store.updateDependencies(t.path,t.nextValues),t.toggledFields.forEach(e=>{if(this.store.isFieldHidden(e)){let r=Object.prototype.hasOwnProperty.call(t.nextErrors,e);r&&!t.hasMutatedErrors&&(t.nextErrors={...t.nextErrors},t.hasMutatedErrors=!0),r&&delete t.nextErrors[e],this.store.clearFieldValidation(e)}})}updateDirtyState(t){t.isDirty=this.store.updateDirtyForPath(t.path,t.nextValues,this.store.getInitialValues())}commitFieldState(t){this.store.dispatch(p({values:t.nextValues,errors:t.nextErrors,isDirty:t.isDirty},[t.path,...t.toggledFields]))}emitFieldChange(t){this.store.emitFieldChange({path:t.path,previousValue:t.previousValue,nextValue:t.value,values:this.store.getState().values,state:this.store.getState(),meta:t.meta})}triggerResolverValidation(t){this.store.config.resolver&&this.store.triggerValidation([t.path])}triggerAsyncValidation(t){(typeof this.store.getFieldConfig=="function"?this.store.getFieldConfig(t.path)?.validation?.asyncValidateOn:void 0)==="change"&&this.store.handleFieldAsyncValidation(t.path,t.value)}};var N=class{constructor(t){this.store=t}setValues(t,e){if(e?.rebase){this.rebaseValues(t);return}if(e?.partial){this.hydrateValues(t);return}this.replaceValuesInternal(t,"replaceValues")}hydrateValues(t){let e=E(this.store.getState().values,t);this.replaceValuesInternal(e,"hydrate")}rebaseValues(t){let e=this.store.getState().values,r=u(t);this.store.setInitialValues(u(r)),this.store.cancelAllValidations(),this.store.evaluateAllDependencies(r),this.store.clearDirtyState(),this.store.dispatch(p({values:r,errors:{},touched:{},isValidating:{},isValid:!0,isDirty:!1,isSubmitting:!1},["*"])),this.store.internalSaveSnapshot(),this.store.validateNow(),this.store.emitFieldChange({path:"*",previousValue:e,nextValue:r,values:this.store.getState().values,state:this.store.getState(),meta:{origin:"rebase"}})}applyHistoryState(t){let e=this.store.rebuildDirtyState(t,this.store.getInitialValues());this.store.dispatch(p({values:t,isDirty:e},["*"])),this.store.triggerValidation(void 0,{forceDebounce:!0})}reset(){this.store.cancelAllValidations();let t=u(this.store.getInitialValues());this.store.evaluateAllDependencies(t),this.store.clearDirtyState(),this.store.dispatch(p({values:t,errors:{},touched:{},isValidating:{},isValid:!0,isDirty:!1,isSubmitting:!1},["*"])),this.store.resetHistory(t)}replaceValuesInternal(t,e="replaceValues"){let r=this.store.getState().values,s=u(t);this.store.cancelAllValidations(),this.store.evaluateAllDependencies(s);let n=this.store.rebuildDirtyState(s,this.store.getInitialValues());this.store.dispatch(p({values:s,errors:{},isValidating:{},isValid:!0,isDirty:n,isSubmitting:!1},["*"])),this.store.internalSaveSnapshot(),this.store.validateNow(),this.store.emitFieldChange({path:"*",previousValue:r,nextValue:s,values:this.store.getState().values,state:this.store.getState(),meta:{origin:e}})}};var L=class{constructor(t){this.store=t;this.submitPipeline=new v([{name:"submit:start",run:async e=>this.startSubmit(e)},{name:"submit:invalid",run:async e=>this.handleInvalidSubmit(e)},{name:"submit:prepare",run:e=>this.prepareSubmitValues(e)},{name:"submit:before-hooks",run:async e=>this.runBeforeSubmitHooks(e)},{name:"submit:user-handler",run:async e=>this.runSubmitHandler(e)},{name:"submit:after-hooks",run:async e=>this.runAfterSubmitHooks(e)}])}submitPipeline;async submit(t){if(this.store.getState().isSubmitting||this.store.hasValidationsInProgress())return;this.store.cancelAllValidations();let r={onSuccess:t,isValid:!1,valuesToSubmit:u(this.store.getState().values),dirtyValues:{}};try{await this.submitPipeline.run(r)}catch(s){r.error=s,await this.store.emitOperationalError({source:"submit",error:s}),await this.store.emitAfterSubmit({values:this.store.getState().values,dirtyValues:this.store.buildDirtyValues(this.store.getState().values),state:this.store.getState(),success:!1,error:s}),console.error(s)}finally{this.store.dispatch(p({isSubmitting:!1}))}}async startSubmit(t){this.store.dispatch(p({isSubmitting:!0})),t.isValid=await this.store.validateNow()}async handleInvalidSubmit(t){if(t.isValid)return;let e=this.store.getState().errors,r={...this.store.getState().touched};Object.keys(e).forEach(s=>{r[s]=!0}),this.store.batchStateUpdates(()=>{this.store.dispatch(p({touched:r}))}),t.dirtyValues=this.store.buildDirtyValues(this.store.getState().values),t.invalid=!0,await this.store.emitAfterSubmit({values:this.store.getState().values,dirtyValues:t.dirtyValues,state:this.store.getState(),success:!1,invalid:!0}),t.halted=!0}prepareSubmitValues(t){let e=[];this.store.getHiddenFields().forEach(r=>{e.push([r,void 0])});for(let[r,s]of this.store.getTransformEntries()){let n=h(t.valuesToSubmit,r);e.push([r,s(n,this.store.getState().values)])}e.length>0&&(t.valuesToSubmit=St(t.valuesToSubmit,e)),t.dirtyValues=this.store.buildDirtyValues(t.valuesToSubmit)}async runBeforeSubmitHooks(t){await this.store.emitBeforeSubmit({values:t.valuesToSubmit,dirtyValues:t.dirtyValues,state:this.store.getState()})}async runSubmitHandler(t){await t.onSuccess(t.valuesToSubmit,t.dirtyValues)}async runAfterSubmitHooks(t){await this.store.emitAfterSubmit({values:t.valuesToSubmit,dirtyValues:t.dirtyValues,state:this.store.getState(),success:!0})}};var K=class{constructor(t){this.store=t;this.fieldUpdate=new z(t),this.values=new N(t),this.submitFlow=new L(t)}fieldUpdate;values;submitFlow;updateField(t,e,r={origin:"setField"}){this.fieldUpdate.updateField(t,e,r)}setValues(t,e){this.values.setValues(t,e)}hydrateValues(t){this.values.hydrateValues(t)}rebaseValues(t){this.values.rebaseValues(t)}applyHistoryState(t){this.values.applyHistoryState(t)}async submit(t){return this.submitFlow.submit(t)}reset(){this.values.reset()}};function Vt(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp)}function Ct(i,t){let e=[],r=(s,n,o,a,l)=>{if(!(a&&l&&S(s,n))){if(Vt(s)&&Vt(n)&&a&&l){let d=new Set([...Object.keys(s),...Object.keys(n)]);for(let c of d){let g=o?`${o}.${c}`:c,y=Object.prototype.hasOwnProperty.call(s,c),f=Object.prototype.hasOwnProperty.call(n,c);r(s[c],n[c],g,y,f)}return}e.push({path:o,previousValue:u(s),nextValue:u(n),hadPreviousValue:a,hasNextValue:l})}};return r(i,t,"",!0,!0),{operations:e}}function W(i,t,e){let r=i;for(let s of t.operations){let n=e==="undo"?s.hadPreviousValue:s.hasNextValue,o=e==="undo"?s.previousValue:s.nextValue;if(!s.path){r=n?u(o):{};continue}r=n?m(r,s.path,u(o)):bt(r,s.path)}return r}var $=class{constructor(t,e=15){this.enableHistory=t;this.maxHistory=e}baseSnapshot=null;currentSnapshot=null;patches=[];historyIndex=-1;historySize=0;saveSnapshot(t){if(!this.enableHistory)return;if(!this.currentSnapshot||this.baseSnapshot===null){this.reset(t);return}if(S(this.currentSnapshot,t))return;this.historyIndex<this.historySize-1&&(this.patches.splice(this.historyIndex),this.historySize=this.historyIndex+1);let e=Ct(this.currentSnapshot,t);if(e.operations.length!==0)for(this.patches.push(e),this.currentSnapshot=u(t),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 t=this.patches[this.historyIndex-1],e=W(this.currentSnapshot,t,"undo");return this.currentSnapshot=u(e),this.historyIndex-=1,e}redo(){if(!this.canRedo||!this.currentSnapshot)return null;let t=this.patches[this.historyIndex],e=W(this.currentSnapshot,t,"redo");return this.currentSnapshot=u(e),this.historyIndex+=1,e}reset(t){if(!this.enableHistory){this.baseSnapshot=null,this.currentSnapshot=null,this.patches=[],this.historyIndex=-1,this.historySize=0;return}this.baseSnapshot=u(t),this.currentSnapshot=u(t),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 t=this.patches.shift();!t||this.baseSnapshot===null||(this.baseSnapshot=W(this.baseSnapshot,t,"redo"),this.historySize=Math.max(1,this.historySize-1),this.historyIndex=Math.max(0,this.historyIndex-1))}getCapacity(){return Math.max(1,this.maxHistory)}};var J=class{constructor(t){this.store=t}pushItem(t,e){this.mutateArrayWithSetField(t,r=>[...r,e],{origin:"array",operation:"push"})}prependItem(t,e){this.mutateArrayWithSetField(t,r=>[e,...r],{origin:"array",operation:"prepend"})}insertItem(t,e,r){this.mutateArrayWithSetField(t,s=>{let n=[...s];return n.splice(e,0,r),n},{origin:"array",operation:"insert",index:e})}removeItem(t,e){let r=this.store.getState(),s=h(r.values,t);if(!Array.isArray(s))return;let n=[...s];this.store.unregisterPrefix&&this.store.unregisterPrefix(`${t}.${e}.`);let o=s.filter((a,l)=>l!==e);this.commitReindexedArrayMutation({path:t,previousArray:n,nextArray:o,meta:{origin:"array",operation:"remove",index:e},reindex:a=>a===e?null:a>e?a-1:a})}swapItems(t,e,r){let s=this.store.getState(),n=[...h(s.values,t)||[]],o=[...n];[n[e],n[r]]=[n[r],n[e]],this.commitReindexedArrayMutation({path:t,previousArray:o,nextArray:n,meta:{origin:"array",operation:"swap",from:e,to:r},reindex:a=>a===e?r:a===r?e:a})}moveItem(t,e,r){let s=this.store.getState(),n=[...h(s.values,t)||[]],o=[...n],[a]=n.splice(e,1);n.splice(r,0,a),this.commitReindexedArrayMutation({path:t,previousArray:o,nextArray:n,meta:{origin:"array",operation:"move",from:e,to:r},reindex:l=>l===e?r:e<r&&l>e&&l<=r?l-1:e>r&&l>=r&&l<e?l+1:l})}revalidate(t){this.store.triggerValidation([t])}mutateArrayWithSetField(t,e,r){let s=h(this.store.getState().values,t)||[];this.store.setFieldWithMeta(t,e(s),r),this.store.internalSaveSnapshot()}commitReindexedArrayMutation(t){let{path:e,previousArray:r,nextArray:s,meta:n,reindex:o}=t,a=this.store.getState(),l=m(a.values,e,s),d=this.store.updateDirtyForPath(e,l,this.store.getConfig().initialValues),c=Bt(a,e,o);this.store.dispatch(p({values:l,errors:c.errors,touched:c.touched,isValidating:c.isValidating,isDirty:d},[e])),this.store.emitFieldChange({path:e,previousValue:r,nextValue:s,values:this.store.getState().values,state:this.store.getState(),meta:n}),this.store.internalSaveSnapshot(),this.revalidate(e)}};var G=class{constructor(t,e,r,s){this.getState=t;this.getInitialValues=e;this.getScopeFields=r;this.isPathDirty=s}getStepStatus(t){let e=this.getScopeFields(t),r=this.getState(),s=e.some(a=>!!r.errors[a]),n=e.some(a=>this.isPathDirty(a)),o=this.getStepErrors(t);return{hasErrors:s,isDirty:n,errors:o}}getStepErrors(t){let e=this.getScopeFields(t),r=this.getState(),s={};for(let n of e){let o=r.errors[n];o&&(s[n]=o)}return s}};var X=class{constructor(t,e,r){this.fieldRegistry=t;this.getState=e;this.isPathDirty=r}requiredValuesRef=null;isHidden(t){return this.fieldRegistry.isHidden(t)}isRequired(t){let e=this.getState().values;return this.requiredValuesRef!==e&&(this.requiredValuesRef=e),this.fieldRegistry.isRequired(t,e)}isFieldDirty(t){return this.isPathDirty(t)}isFieldValidating(t){return!!this.getState().isValidating[t]}isTouched(t){return!!this.getState().touched[t]}};var Z=class{constructor(t,e){this.getState=t;this.dispatch=e}setError(t,e){let r={...this.getState().errors,[t]:e};e||delete r[t],this.dispatch(p({errors:r}))}setErrors(t){this.dispatch(p({errors:{...this.getState().errors,...t}}))}setServerErrors(t){let e={};for(let[r,s]of Object.entries(t))e[r]=Array.isArray(s)?s[0]:s;this.setErrors(e)}};var ut=typeof globalThis<"u"?globalThis:typeof global<"u"?global:window;ut.__BIT_FORM__||(ut.__BIT_FORM__={stores:{},listeners:new Set,dispatch(i,t){this.listeners.forEach(e=>e(i,t))},subscribe(i){return this.listeners.add(i),()=>{this.listeners.delete(i)}}});var Y=ut.__BIT_FORM__,Ie={stores:{},listeners:new Set,dispatch:()=>{},subscribe:()=>()=>{}};function Mt(){return Ie}function At(){let i=new Set;return{stores:{},listeners:i,dispatch(t,e){i.forEach(r=>r(t,e))},subscribe(t){return i.add(t),()=>i.delete(t)}}}function Oe(i){return i.bus?!0:typeof i.devTools=="boolean"?i.devTools:i.devTools&&typeof i.devTools=="object"?i.devTools.enabled!==!1:!1}function Dt(i){let{ports:t,fieldRegistry:e}=i;return{validation:new U(t.validationPort),lifecycle:new K(t.lifecyclePort),history:new $(!!t.config.history.enabled,t.config.history.limit??50),arrays:new J(t.arrayPort),scope:new G(()=>t.getState(),()=>t.getInitialValues(),r=>t.getScopeFields(r),r=>t.isPathDirty(r)),query:new X(e,()=>t.getState(),r=>t.isPathDirty(r)),error:new Z(()=>t.getState(),r=>t.dispatch(r))}}function kt(i){let{storeId:t,storeInstance:e,config:r,getState:s,getConfig:n,getValues:o,getDirtyValues:a,applyPersistedValues:l}=i,d=new I(r.persist,o,a,l),c=new O([...r.plugins],()=>({storeId:t,getState:()=>s(),getConfig:()=>n()})),g=Oe(r),y=g?r.bus??Y:Mt(),f=new H(t,e,y,d,c,g);return f.initialize(),f}function Rt(i){let{config:t,fieldRegistry:e,computedManager:r}=i,s=u(t.initialValues);return t.fields&&Object.entries(t.fields).forEach(([o,a])=>{e.register(o,a,s)}),{values:r.apply(s),errors:{},touched:{},isValidating:{},persist:{isSaving:!1,isRestoring:!1,error:null},isValid:!0,isSubmitting:!1,isDirty:!1}}async function wt(i){let{dispatch:t,effects:e}=i;t(b({isRestoring:!0,error:null}));try{return await e.restorePersisted()}catch(r){return t(b({isRestoring:!1,error:r instanceof Error?r:new Error(String(r))})),!1}finally{t(b({isRestoring:!1}))}}async function It(i){let{dispatch:t,effects:e}=i;t(b({isSaving:!0,error:null}));try{await e.savePersistedNow()}catch(r){t(b({isSaving:!1,error:r instanceof Error?r:new Error(String(r))}));return}t(b({isSaving:!1}))}async function Ot(i){let{dispatch:t,effects:e}=i;t(b({error:null}));try{await e.clearPersisted()}catch(r){t(b({error:r instanceof Error?r:new Error(String(r))}))}}function Ht(i){let{values:t,state:e,initialValues:r,validation:s,fieldRegistry:n,dirtyManager:o,dispatch:a,saveHistorySnapshot:l}=i,d=u({...r,...t});s.cancelAll(),n.evaluateAll(d);let c=o.rebuild(d,r);a(p({values:d,errors:{},touched:{},isValidating:{},persist:{...e.persist,error:null},isValid:!0,isDirty:c,isSubmitting:!1})),l(),s.validate()}function jt(i){let{dispatch:t,effects:e}=i;return wt({dispatch:t,effects:e})}function qt(i){let{dispatch:t,effects:e}=i;return It({dispatch:t,effects:e})}function _t(i){let{dispatch:t,effects:e}=i;return Ot({dispatch:t,effects:e})}function Ut(i){let{history:t,applyHistoryState:e}=i,r=t.undo();r&&e(r)}function zt(i){let{history:t,applyHistoryState:e}=i,r=t.redo();r&&e(r)}function Nt(i){return i.history.getMetadata()}var Q=Symbol.for("bit-form.hooks-api");function Lt(i){let{state:t,path:e}=i,r={...t.errors},s={...t.touched},n=!1;return r[e]&&(delete r[e],n=!0),s[e]&&(delete s[e],n=!0),n?{errors:r,touched:s}:null}function Kt(i){let{path:t,config:e,state:r,fieldRegistry:s,subscriptions:n,invalidateFieldIndexes:o}=i;s.register(t,e,r.values),o(),s.isHidden(t)&&n.notify(r,[t])}function Wt(i){let{path:t,state:e,hasStaticConfig:r,fieldRegistry:s,validationCleanupField:n,invalidateFieldIndexes:o,dispatch:a}=i;if(r)return;n(t),s.unregister(t),o();let l=Lt({state:e,path:t});l&&a(p({errors:l.errors,touched:l.touched}))}function $t(i){let{prefix:t,fieldRegistry:e,validationCleanupPrefix:r,invalidateFieldIndexes:s}=i;r(t),e.unregisterPrefix(t),s()}function Jt(i,t){let e=new Set,r=(o,a)=>o===null||typeof o!="object"?o:new Proxy(o,{get:(l,d,c)=>{if(typeof d=="symbol")return Reflect.get(l,d,c);let g=String(d),y=a?`${a}.${g}`:g;e.add(y);let f=Reflect.get(l,d,c);return r(f,y)}}),s=r(i,"");t(s);let n=new Set;return e.forEach(o=>{let a=He(o);a&&n.add(a)}),Array.from(n)}function He(i){if(i)return i==="values"?"*":i.startsWith("values.")?i.slice(7):i==="errors"||i==="touched"||i==="isValidating"?"*":i.startsWith("errors.")?i.slice(7):i.startsWith("touched.")?i.slice(8):i.startsWith("isValidating.")?i.slice(13):i==="persist"||i.startsWith("persist.")?"persist":i}function je(i,t){if(i.length!==t.length)return!1;let e=new Set(t);for(let r of i)if(!e.has(r))return!1;return!0}function qe(i,t){return i.length===0?{...t,paths:["*"]}:{...t,paths:i}}function Gt(i){let{getState:t,subscribeSelector:e,selector:r,listener:s,options:n}=i,o=null,a=Jt(t(),r),l=!1,d=!1,c=g=>{o=e(r,y=>{s(y);let f=Jt(t(),r);je(a,f)||(a=f,!(d||l)&&(d=!0,queueMicrotask(()=>{d=!1,!l&&(o?.(),c(a))})))},qe(g,n))};return c(a),()=>{l=!0,o?.(),o=null}}function ht(i,t){return i.canUndo===t.canUndo&&i.canRedo===t.canRedo&&i.historyIndex===t.historyIndex&&i.historySize===t.historySize}function pt(i){let t=i.getHistoryMetadata();return{canUndo:t.canUndo,canRedo:t.canRedo,historyIndex:t.historyIndex,historySize:t.historySize}}function _e(i,t){return t(pt(i)),i.subscribeHistoryMeta(()=>{t(pt(i))})}function Xt(i,t){let e=Object.keys(i),r=Object.keys(t);return e.length!==r.length?!1:e.every(s=>i[s]===t[s])}function gt(i,t){return i.hasErrors===t.hasErrors&&i.isDirty===t.isDirty&&Xt(i.errors,t.errors)}function ft(i){return[...i,"isDirty"]}function Ue(i,t,e){return e(i.getStepStatus(t)),i.subscribeScopeStatus(t,e)}function Zt(i){let{subscriptions:t,selector:e,listener:r,options:s}=i,n=s?.equalityFn??T;return t.subscribeSelector(e,r,s,n)}function Yt(i){let{getState:t,subscribeSelector:e,selector:r,listener:s,options:n}=i;return Gt({getState:t,subscribeSelector:(o,a,l)=>e(o,a,l),selector:r,listener:s,options:n})}function Qt(i){let{path:t,listener:e,options:r,subscribeSelector:s}=i,n=[...r?.paths??[],t];return s(o=>h(o.values,t),e,{...r,paths:n})}function te(i){let{path:t,listener:e,getFieldState:r,subscribeSelector:s}=i;return s(()=>r(t),e,{paths:[t],equalityFn:(n,o)=>n.value===o.value&&n.error===o.error&&n.touched===o.touched&&n.isHidden===o.isHidden&&n.isRequired===o.isRequired&&n.isDirty===o.isDirty&&n.isValidating===o.isValidating})}function ee(i){let{listener:t,subscribeSelector:e}=i;return e(r=>({isValid:r.isValid,isDirty:r.isDirty,isSubmitting:r.isSubmitting}),t,{paths:["isValid","isDirty","isSubmitting"],equalityFn:(r,s)=>r.isValid===s.isValid&&r.isDirty===s.isDirty&&r.isSubmitting===s.isSubmitting})}function ie(i){let{listener:t,subscribeSelector:e}=i;return e(r=>r.persist,t,{paths:["persist"],equalityFn:(r,s)=>r.isSaving===s.isSaving&&r.isRestoring===s.isRestoring&&r.error===s.error})}function re(i){let{readHistoryMeta:t,subscribe:e,listener:r}=i,s=t();return e(()=>{let n=t();ht(s,n)||(s=n,r(n))})}function se(i){let{scopeName:t,readScopeStatus:e,getScopeFields:r,subscribeSelector:s,listener:n}=i,o=e(t);return s(a=>({errors:a.errors,isDirty:a.isDirty}),()=>{let a=e(t);gt(o,a)||(o=a,n(a))},{paths:ft(r(t))})}var tt=class{constructor(t,e=500){this.getState=t;this.MAX_EXPANDED_CACHE_SIZE=e,this.MAX_CHANGED_LOOKUP_CACHE_SIZE=e}listeners=new Set;pathScopedSubscriptions=new Map;pathSelectorIndex=new Map;expandedPathCache=new Map;changedPathLookupCache=new Map;subscriptionSeenVersion=new Map;notifyVersion=0;MAX_EXPANDED_CACHE_SIZE;MAX_CHANGED_LOOKUP_CACHE_SIZE;subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}subscribeSelector(t,e,r,s){let n=t(this.getState()),o={notify:l=>{let d=t(l);s(n,d)||(n=d,e(d))}},a=this.normalizeSubscriptionPaths(r?.paths);if(a.length===0)throw new Error("BitStore: subscribeSelector requires explicit `paths`.");return this.pathScopedSubscriptions.set(o,a),a.forEach(l=>{this.expandPathForIndexing(l).forEach(d=>{let c=this.pathSelectorIndex.get(d)??new Set;c.add(o),this.pathSelectorIndex.set(d,c)})}),r?.emitImmediately&&e(n),()=>{this.subscriptionSeenVersion.delete(o);let l=this.pathScopedSubscriptions.get(o);l&&(l.forEach(d=>{this.expandPathForIndexing(d).forEach(c=>{let g=this.pathSelectorIndex.get(c);g&&(g.delete(o),g.size===0&&this.pathSelectorIndex.delete(c))})}),this.pathScopedSubscriptions.delete(o))}}notify(t,e){if(this.listeners.forEach(n=>n()),this.pathScopedSubscriptions.size===0)return;let r=e?this.normalizeSubscriptionPaths(Array.from(e)):[];if(r.length===0||r.includes("*")){this.pathScopedSubscriptions.forEach((n,o)=>{o.notify(t)});return}this.collectSubscribersForChangedPaths(r).forEach(n=>{n.notify(t)})}destroy(){this.listeners.clear(),this.pathScopedSubscriptions.clear(),this.pathSelectorIndex.clear(),this.expandedPathCache.clear(),this.changedPathLookupCache.clear(),this.subscriptionSeenVersion.clear()}normalizeSubscriptionPaths(t){if(!t||t.length===0)return[];let e=new Set,r=[];for(let s of t){let n=s.trim();n.length===0||e.has(n)||(e.add(n),r.push(n))}return r}collectSubscribersForChangedPaths(t){let e=[],r=++this.notifyVersion,s=n=>{let o=this.pathSelectorIndex.get(n);o&&o.forEach(a=>{(this.subscriptionSeenVersion.get(a)??0)>=r||(this.subscriptionSeenVersion.set(a,r),e.push(a))})};return t.forEach(n=>{this.expandChangedPathForLookup(n).forEach(s)}),e}expandChangedPathForLookup(t){let e=this.changedPathLookupCache.get(t);if(e)return e;let r=t.split("."),s=[t];for(;r.length>1;)r.pop(),s.push(r.join("."));return this.setBoundedCacheEntry(this.changedPathLookupCache,t,s,this.MAX_CHANGED_LOOKUP_CACHE_SIZE),s}expandPathForIndexing(t){let e=this.expandedPathCache.get(t);if(e)return e;let r=t.split("."),s=[];for(let n=1;n<=r.length;n++)s.push(r.slice(0,n).join("."));return this.setBoundedCacheEntry(this.expandedPathCache,t,s,this.MAX_EXPANDED_CACHE_SIZE),s}setBoundedCacheEntry(t,e,r,s){if(t.size>=s){let n=t.keys().next().value;n!==void 0&&t.delete(n)}t.set(e,r)}};function ne(i){return{getState:()=>i.getState(),dispatch:t=>i.dispatch(t),setError:(t,e)=>i.setError(t,e),validate:t=>i.validate(t),getFieldConfig:t=>i.getFieldConfig(t),forEachFieldConfig:t=>i.fieldRegistry.forEachFieldConfig((e,r)=>t(e,r)),getScopeFields:t=>i.getScopeFields(t),config:i.config,getRequiredErrors:t=>i.fieldRegistry.getRequiredErrors(t),getHiddenFields:()=>i.fieldRegistry.getHiddenFields(),emitBeforeValidate:t=>i.getEffects().beforeValidate(t),emitAfterValidate:t=>i.getEffects().afterValidate(t)}}function oe(i){return{getState:()=>i.getState(),dispatch:t=>i.dispatch(t),internalSaveSnapshot:()=>i.saveHistorySnapshot(),batchStateUpdates:t=>i.runStateBatch(t),config:i.config,getFieldConfig:t=>i.fieldRegistry.getFieldConfig(t),getTransformEntries:()=>i.getTransformEntries(),updateDependencies:(t,e)=>i.fieldRegistry.updateDependencies(t,e),hasDependentFields:t=>i.fieldRegistry.hasDependents(t),isFieldHidden:t=>i.fieldRegistry.isHidden(t),evaluateAllDependencies:t=>i.fieldRegistry.evaluateAll(t),getHiddenFields:()=>i.fieldRegistry.getHiddenFields(),clearFieldValidation:t=>i.getValidation().clear(t),triggerValidation:(t,e)=>i.getValidation().trigger(t,e),handleFieldAsyncValidation:(t,e)=>i.getValidation().handleAsync(t,e),cancelAllValidations:()=>i.getValidation().cancelAll(),validateNow:t=>i.getValidation().validate(t),hasValidationsInProgress:t=>i.getValidation().hasValidationsInProgress(t),updateDirtyForPath:(t,e,r)=>i.dirtyManager.updateForPath(t,e,r),rebuildDirtyState:(t,e)=>i.dirtyManager.rebuild(t,e),clearDirtyState:()=>i.dirtyManager.clear(),buildDirtyValues:t=>i.dirtyManager.buildDirtyValues(t),getInitialValues:()=>i.getInitialValues(),setInitialValues:t=>i.setInitialValues(t),resetHistory:t=>i.getHistory().reset(t),emitFieldChange:t=>i.getEffects().onFieldChange(t),emitBeforeSubmit:t=>i.getEffects().beforeSubmit(t),emitAfterSubmit:t=>i.getEffects().afterSubmit(t),emitOperationalError:t=>i.getEffects().reportOperationalError(t)}}function ae(i){return{getState:()=>i.getState(),setFieldWithMeta:(t,e,r)=>i.setFieldWithMeta(t,e,r),emitFieldChange:t=>i.getEffects().onFieldChange(t),dispatch:t=>i.dispatch(t),internalSaveSnapshot:()=>i.saveHistorySnapshot(),unregisterPrefix:t=>i.unregisterPrefix(t),triggerValidation:t=>i.triggerValidation(t),updateDirtyForPath:(t,e,r)=>i.dirtyManager.updateForPath(t,e,r),getConfig:()=>i.getConfig()}}function le(i){let t=ne({config:i.config,fieldRegistry:i.fieldRegistry,getState:()=>i.getState(),dispatch:l=>i.dispatch(l),setError:(l,d)=>i.setError(l,d),validate:l=>i.validate(l),getFieldConfig:l=>i.getFieldConfig(l),getScopeFields:l=>i.getScopeFields(l),getEffects:()=>i.getEffects()}),e=oe({config:i.config,fieldRegistry:i.fieldRegistry,dirtyManager:i.dirtyManager,getState:()=>i.getState(),dispatch:l=>i.dispatch(l),saveHistorySnapshot:()=>i.saveHistorySnapshot(),runStateBatch:l=>i.runStateBatch(l),getTransformEntries:()=>i.getTransformEntries(),getInitialValues:()=>i.initialValuesRef.get(),setInitialValues:l=>i.initialValuesRef.set(l),getValidation:()=>i.getValidation(),getHistory:()=>i.getHistory(),getEffects:()=>i.getEffects()}),r=ae({getState:()=>i.getState(),dispatch:l=>i.dispatch(l),setFieldWithMeta:(l,d,c)=>i.setFieldWithMeta(l,d,c),unregisterPrefix:l=>i.unregisterPrefix(l),triggerValidation:(l,d)=>i.triggerValidation(l,d),dirtyManager:i.dirtyManager,getConfig:()=>i.getConfig(),getEffects:()=>i.getEffects(),saveHistorySnapshot:()=>i.saveHistorySnapshot()}),s=Dt({ports:{config:i.config,validationPort:t,lifecyclePort:e,arrayPort:r,getScopeFields:l=>i.getScopeFields(l),getState:()=>i.getState(),dispatch:l=>i.dispatch(l),getInitialValues:()=>i.initialValuesRef.get(),isPathDirty:l=>i.dirtyManager.isPathDirty(l)},fieldRegistry:i.fieldRegistry}),n=Rt({config:i.config,fieldRegistry:i.fieldRegistry,computedManager:i.computedManager}),o=new tt(()=>i.getState(),i.config.subscriptionCacheSize),a=i.rawConfig.storeId||i.config.name||i.config.idFactory({scope:"store",storeName:i.config.name});return{state:n,subscriptions:o,capabilities:s,storeId:a}}function de(){return{depth:0,pendingState:null,changedPathSet:null,valuesChanged:!1,pendingHistorySnapshot:!1}}function ce(i){i.depth+=1}function ue(i){return i.depth-=1,i.depth===0}function et(i,t){return t.pendingState??i}function pe(i,t){if(i.pendingState=t.nextState,i.valuesChanged||=t.valuesChanged,t.changedPaths&&t.changedPaths.length>0){let e=i.changedPathSet??new Set;t.changedPaths.forEach(r=>e.add(r)),i.changedPathSet=e}}function he(i){let{currentState:t,batchState:e,applyComputedValues:r}=i;if(!e.pendingState)return e.pendingHistorySnapshot=!1,null;let s=e.pendingState,n=e.changedPathSet??void 0,o=e.valuesChanged;if(o){let a=n?[...n]:void 0;s={...s,values:r(s.values,a)}}return e.pendingState=null,e.changedPathSet=null,e.valuesChanged=!1,{nextState:s??t,changedPaths:n,valuesChanged:o}}function ze(i){let t=!1;for(let r of Object.values(i))if(r===void 0){t=!0;break}if(!t)return i;let e={};return Object.entries(i).forEach(([r,s])=>{s!==void 0&&(e[r]=s)}),e}function ge(i){let{currentState:t,partialState:e,changedPaths:r,applyComputedValues:s}=i,n={...t,...e},o=!!e.values;e.values&&(n.values=s(e.values)),e.errors&&(n.errors=ze(e.errors),n.isValid=!P(n.errors));let a=r&&r.length>0?r:void 0,l=Ne(e),d=Le(a,l);return{nextState:n,changedPaths:d,valuesChanged:o}}function Ne(i){let t=new Set,e=[i.errors,i.touched,i.isValidating];for(let r of e)if(r)for(let s in r)t.add(s);return i.persist&&t.add("persist"),"isValid"in i&&t.add("isValid"),"isDirty"in i&&t.add("isDirty"),"isSubmitting"in i&&t.add("isSubmitting"),t.size>0?Array.from(t):void 0}function Le(i,t){if(!i?.length)return t;if(!t?.length)return i;let e=new Set;for(let r of i)e.add(r);for(let r of t)e.add(r);return Array.from(e)}function Ke(i,t){if(t.kind==="state.patch")return t;if(t.kind==="field.touchMany"){if(t.paths.length===0)return null;let e={...i.touched};for(let r of t.paths)e[r]=!0;return p({touched:e},t.paths)}return t.kind==="form.persistMeta"?p({persist:{...i.persist,...t.patch}}):t.kind==="history.apply"?p({values:t.values,isDirty:t.isDirty},["*"]):p({errors:t.errors,isValid:t.isValid})}function We(i){let{currentState:t,operation:e,applyComputedValues:r}=i,s=Object.prototype.hasOwnProperty.call(e.partialState,"values"),n=e.changedPaths??(s?["*"]:void 0);return ge({currentState:t,partialState:e.partialState,changedPaths:n,applyComputedValues:o=>r(o,n)})}function fe(i){let{currentState:t,operation:e,applyComputedValues:r}=i,s=Ke(t,e);return s?We({currentState:t,operation:s,applyComputedValues:(n,o)=>s.skipComputed?n:r(n,o)}):null}function ye(i){let{state:t,batchState:e,operation:r,applyComputedValues:s,onStateCommitted:n}=i,o=et(t,e);if(e.depth>0){let l=fe({currentState:o,operation:r,applyComputedValues:d=>d});return l&&pe(e,l),t}let a=fe({currentState:t,operation:r,applyComputedValues:s});return a?(n({nextState:a.nextState,changedPaths:a.changedPaths,valuesChanged:a.valuesChanged}),a.nextState):t}function me(i){let{state:t,batchState:e,applyComputedValues:r,onStateCommitted:s}=i,n=he({currentState:t,batchState:e,applyComputedValues:r});return n?(s({nextState:n.nextState,changedPaths:n.changedPaths,valuesChanged:n.valuesChanged}),n.nextState):t}function Se(i){let{batchState:t,callback:e,flushBatchedStateUpdates:r}=i;ce(t);try{return e()}finally{ue(t)&&r()}}function be(i){let{payload:t,setState:e,notifySubscriptions:r,notifyEffects:s}=i;e(t.nextState),r(t.nextState,t.changedPaths),s(t.nextState,t.valuesChanged)}function Be(i){let{state:t,batchState:e,operation:r,applyComputedValues:s,onStateCommitted:n}=i;return ye({state:t,batchState:e,operation:r,applyComputedValues:s,onStateCommitted:n})}function Te(i){let{batchState:t,values:e,saveHistory:r}=i;if(t.depth>0){t.pendingHistorySnapshot=!0;return}r(e)}function ve(i){let{state:t,batchState:e,applyComputedValues:r,onStateCommitted:s,saveHistory:n}=i,o=me({state:t,batchState:e,applyComputedValues:r,onStateCommitted:s});return e.pendingHistorySnapshot&&(e.pendingHistorySnapshot=!1,n(o.values)),o}var it=class{constructor(t){this.args=t;this.state=t.state,this.subscriptions=t.subscriptions,this.effects=t.effects,this.capabilities=t.capabilities}state;batchState=de();subscriptions;effects;capabilities;getState(){return et(this.state,this.batchState)}runBatch(t){return Se({batchState:this.batchState,callback:t,flushBatchedStateUpdates:()=>this.flushBatchedStateUpdates()})}dispatch(t){this.state=Be({state:this.state,batchState:this.batchState,operation:t,applyComputedValues:(e,r)=>{let s=r?Array.from(r):void 0;return this.args.computedManager.apply(e,s)},onStateCommitted:e=>this.onStateCommitted(e)})}saveHistorySnapshot(){Te({batchState:this.batchState,values:this.state.values,saveHistory:t=>this.capabilities.history.saveSnapshot(t)})}cleanup(){this.subscriptions.destroy(),this.capabilities.validation.cancelAll(),this.effects.destroy()}onStateCommitted(t){be({payload:t,setState:e=>{this.state=e},notifySubscriptions:(e,r)=>this.subscriptions.notify(e,r),notifyEffects:(e,r)=>this.effects.onStateUpdated(e,r)})}flushBatchedStateUpdates(){this.state=ve({state:this.state,batchState:this.batchState,applyComputedValues:(t,e)=>{let r=e?Array.from(e):void 0;return this.args.computedManager.apply(t,r)},onStateCommitted:t=>this.onStateCommitted(t),saveHistory:t=>this.capabilities.history.saveSnapshot(t)})}};var rt=class{[Q]=!0;runtime;maskManager;_config;_cachedConfig;_initialValues;storeId;get config(){return this._cachedConfig??this._config}fieldRegistry;computedManager;dirtyManager;invalidateFieldIndexes(){this.fieldRegistry.invalidateIndexes(),this.computedManager.invalidateReverseDeps()}constructor(t={}){this._config=Pt(t),this._initialValues=this._config.initialValues,this.fieldRegistry=new w,this.computedManager=new M(()=>this.getComputedEntries()),this.dirtyManager=new A,this.maskManager=new D,this._config.masks&&Object.entries(this._config.masks).forEach(([n,o])=>{this.maskManager.registerMask(n,o)});let e=null,r=le({rawConfig:t,config:this._config,fieldRegistry:this.fieldRegistry,computedManager:this.computedManager,dirtyManager:this.dirtyManager,initialValuesRef:{get:()=>this._initialValues,set:n=>{this._initialValues=n}},getState:()=>e?.getState()??r.state,dispatch:n=>e?.dispatch(n),setError:(n,o)=>this.setError(n,o),validate:n=>this.validate(n),getFieldConfig:n=>this.getFieldConfig(n),getScopeFields:n=>this.getScopeFields(n),getEffects:()=>e.effects,saveHistorySnapshot:()=>e?.saveHistorySnapshot(),runStateBatch:n=>e.runBatch(n),getTransformEntries:()=>this.getTransformEntries(),getHistory:()=>e.capabilities.history,getValidation:()=>e.capabilities.validation,setFieldWithMeta:(n,o,a)=>this.setFieldWithMeta(n,o,a),unregisterPrefix:n=>this.unregisterPrefix(n),triggerValidation:(n,o)=>this.triggerValidation(n,o),getConfig:()=>this.getConfig()});this.storeId=r.storeId;let s=kt({storeId:this.storeId,storeInstance:this,config:this._config,getState:()=>e?.getState()??r.state,getConfig:()=>this.getConfig(),getValues:()=>(e?.getState()??r.state).values,getDirtyValues:()=>this.getDirtyValues(),applyPersistedValues:n=>this.applyPersistedValues(n)});e=new it({state:r.state,subscriptions:r.subscriptions,effects:s,capabilities:r.capabilities,computedManager:this.computedManager}),this.runtime=e,this.runtime.saveHistorySnapshot(),this._cachedConfig=this._config}getConfig(){return this._cachedConfig??this._config}getFieldConfig(t){return this.fieldRegistry.getFieldConfig(t)}getScopeFields(t){return this.fieldRegistry.getScopeFields(t)}getComputedEntries(){return this.fieldRegistry.getComputedEntries()}getTransformEntries(){return this.fieldRegistry.getTransformEntries()}resolveMask(t){return Tt({path:t,getFieldConfig:e=>this.getFieldConfig(e),masks:this.maskManager.getAllMasks()})}createArrayItemId(t,e){return this._config.idFactory({scope:"array",path:t,index:e})}getState(){return this.runtime.getState()}getFieldState(t){let e=this.getState(),r=h(e.values,t);return vt({state:e,path:t,value:r,isHidden:this.isHidden(t),isRequired:this.isRequired(t),isDirty:this.isFieldDirty(t),isValidating:this.isFieldValidating(t)})}get isValid(){return this.getState().isValid}get isSubmitting(){return this.getState().isSubmitting}get isDirty(){return this.getState().isDirty}registerField(t,e){Kt({path:t,config:e,state:this.getState(),fieldRegistry:this.fieldRegistry,subscriptions:this.runtime.subscriptions,invalidateFieldIndexes:()=>this.invalidateFieldIndexes()})}unregisterField(t){Wt({path:t,state:this.getState(),hasStaticConfig:!!this._config.fields?.[t],fieldRegistry:this.fieldRegistry,validationCleanupField:e=>this.runtime.capabilities.validation.cleanupField(e),invalidateFieldIndexes:()=>this.invalidateFieldIndexes(),dispatch:e=>this.runtime.dispatch(e)})}unregisterPrefix(t){$t({prefix:t,fieldRegistry:this.fieldRegistry,validationCleanupPrefix:e=>this.runtime.capabilities.validation.cleanupPrefix(e),invalidateFieldIndexes:()=>this.invalidateFieldIndexes()})}isHidden(t){return this.runtime.capabilities.query.isHidden(t)}isRequired(t){return this.runtime.capabilities.query.isRequired(t)}isFieldDirty(t){return this.runtime.capabilities.query.isFieldDirty(t)}isFieldValidating(t){return this.runtime.capabilities.query.isFieldValidating(t)}subscribe(t){return this.runtime.subscriptions.subscribe(t)}subscribePersistMeta(t){return ie({listener:t,subscribeSelector:(e,r,s)=>this.subscribeSelector(e,r,s)})}subscribeHistoryMeta(t){return re({readHistoryMeta:()=>this.getHistoryMetadata(),subscribe:e=>this.subscribe(e),listener:t})}subscribeScopeStatus(t,e){return se({scopeName:t,readScopeStatus:r=>this.getStepStatus(r),getScopeFields:r=>this.getScopeFields(r),subscribeSelector:(r,s,n)=>this.subscribeSelector(r,s,n),listener:e})}subscribeSelector(t,e,r){return Zt({subscriptions:this.runtime.subscriptions,selector:t,listener:e,options:r})}subscribeTracked(t,e,r){return Yt({getState:()=>this.getState(),subscribeSelector:(s,n,o)=>this.subscribeSelector(s,n,o),selector:t,listener:e,options:r})}subscribePath(t,e,r){return Qt({path:t,listener:e,options:r,subscribeSelector:(s,n,o)=>this.subscribeSelector(s,n,o)})}subscribeFieldState(t,e){return te({path:t,listener:e,getFieldState:r=>this.getFieldState(r),subscribeSelector:(r,s,n)=>this.subscribeSelector(r,s,n)})}subscribeFormMeta(t){return ee({listener:t,subscribeSelector:(e,r,s)=>this.subscribeSelector(e,r,s)})}setField(t,e){this.setFieldWithMeta(t,e,{origin:"setField"})}setFieldWithMeta(t,e,r={origin:"setField"}){this.runtime.capabilities.lifecycle.updateField(t,e,r)}blurField(t){this.runtime.saveHistorySnapshot(),this.runtime.capabilities.query.isTouched(t)||this.runtime.runBatch(()=>{this.runtime.dispatch(ct([t]))}),this.runtime.capabilities.validation.trigger([t])}markFieldsTouched(t){t.length!==0&&this.runtime.dispatch(ct(t))}setValues(t,e){this.runtime.capabilities.lifecycle.setValues(t,e)}setError(t,e){this.runtime.capabilities.error.setError(t,e)}setErrors(t){this.runtime.capabilities.error.setErrors(t)}setServerErrors(t){this.runtime.capabilities.error.setServerErrors(t)}reset(){this.runtime.capabilities.lifecycle.reset()}transaction(t){return this.runtime.runBatch(t)}async submit(t){return this.runtime.capabilities.lifecycle.submit(t)}getDirtyValues(){return this.dirtyManager.buildDirtyValues(this.getState().values)}getPersistMetadata(){return this.getState().persist}async restorePersisted(){return jt({dispatch:t=>this.runtime.dispatch(t),effects:this.runtime.effects})}async forceSave(){return qt({dispatch:t=>this.runtime.dispatch(t),effects:this.runtime.effects})}async clearPersisted(){return _t({dispatch:t=>this.runtime.dispatch(t),effects:this.runtime.effects})}pushItem(t,e){this.runtime.capabilities.arrays.pushItem(t,e)}prependItem(t,e){this.runtime.capabilities.arrays.prependItem(t,e)}insertItem(t,e,r){this.runtime.capabilities.arrays.insertItem(t,e,r)}removeItem(t,e){this.runtime.capabilities.arrays.removeItem(t,e)}swapItems(t,e,r){this.runtime.capabilities.arrays.swapItems(t,e,r)}moveItem(t,e,r){this.runtime.capabilities.arrays.moveItem(t,e,r)}get canUndo(){return this.runtime.capabilities.history.canUndo}get canRedo(){return this.runtime.capabilities.history.canRedo}undo(){Ut({history:this.runtime.capabilities.history,applyHistoryState:t=>this.runtime.capabilities.lifecycle.applyHistoryState(t)})}redo(){zt({history:this.runtime.capabilities.history,applyHistoryState:t=>this.runtime.capabilities.lifecycle.applyHistoryState(t)})}getHistoryMetadata(){return Nt({history:this.runtime.capabilities.history})}validate(t){return this.runtime.capabilities.validation.validate(t)}hasValidationsInProgress(t){return this.runtime.capabilities.validation.hasValidationsInProgress(t)}triggerValidation(t,e){this.runtime.capabilities.validation.trigger(t,e)}getStepStatus(t){return this.runtime.capabilities.scope.getStepStatus(t)}getStepErrors(t){return this.runtime.capabilities.scope.getStepErrors(t)}applyPersistedValues(t){Ht({values:t,state:this.getState(),initialValues:this._initialValues,validation:this.runtime.capabilities.validation,fieldRegistry:this.fieldRegistry,dirtyManager:this.dirtyManager,dispatch:e=>this.runtime.dispatch(e),saveHistorySnapshot:()=>this.runtime.saveHistorySnapshot()})}cleanup(){this.runtime.cleanup()}};function $e(i){return!i||typeof i!="object"?!1:i[Q]===!0}function Je(i){if($e(i))return i;throw new Error("BitForm: o store informado n\xE3o exp\xF5e a API necess\xE1ria para hooks/framework bindings.")}function Ge(i={}){return new rt(i)}function Xe(i,t){return t&&t.value===i.value&&t.error===i.error&&t.touched===i.touched&&t.isHidden===i.isHidden&&t.isRequired===i.isRequired&&t.isDirty===i.isDirty&&t.isValidating===i.isValidating?t:{value:i.value,error:i.error,touched:i.touched,isHidden:i.isHidden,isRequired:i.isRequired,isDirty:i.isDirty,isValidating:i.isValidating}}function Ze(i,t){return i===t?!0:!i||!t?!1:S(i.value,t.value)&&i.error===t.error&&i.touched===t.touched&&i.isHidden===t.isHidden&&i.isRequired===t.isRequired&&i.isDirty===t.isDirty&&i.isValidating===t.isValidating}function yt(i){let t=i.getState();return{isValid:t.isValid,isDirty:t.isDirty,isSubmitting:t.isSubmitting}}function Pe(i,t){return i.subscribeFormMeta(()=>t())}function Ye(i,t){return t(yt(i)),Pe(i,()=>{t(yt(i))})}function Fe(i){return i.getPersistMetadata()}function Qe(i,t){return i.subscribePersistMeta(()=>t())}function ti(i,t){return t(Fe(i)),i.subscribePersistMeta(e=>{t(e)})}async function Ee(i,t,e,r){try{let s=await i(t,e);r.onSuccess(s)}catch(s){if(V(s)){r.onServerErrors(dt(s));return}r.onUnhandledError(s instanceof Error?s:new Error(String(s)))}}function Ve(i){return{setField:(t,e)=>i.setField(t,e),blurField:t=>i.blurField(t),setValues:(t,e)=>i.setValues(t,e),setError:(t,e)=>i.setError(t,e),setErrors:t=>i.setErrors(t),setServerErrors:t=>i.setServerErrors(t),validate:t=>i.validate(t),transaction:t=>i.transaction(t)}}function xe(i,t){i?.preventDefault?.(),t?.stopPropagation&&i?.stopPropagation?.()}function Ce(i,t,e){return{submit:o=>a=>(xe(a,e),i.submit(o)),onSubmit:o=>a=>(xe(a,e),t.setSubmissionError(null),i.submit(async(l,d)=>{await Ee(o,l,d,{onSuccess:c=>{t.setSubmissionResult(c),t.setSubmissionError(null)},onServerErrors:c=>{i.setServerErrors(c)},onUnhandledError:c=>{t.setSubmissionError(c)}})})),reset:()=>{i.reset(),t.clearSubmissionState()},getValues:()=>i.getState().values,getErrors:()=>i.getState().errors,getTouched:()=>i.getState().touched,getDirtyValues:()=>i.getDirtyValues()}}function ei(i,t,e){return{controller:Ce(i,t,e),actions:Ve(i)}}function ii(i,t,e){return i.subscribeFieldState(t,e)}function Me(i,t,e){return{setValue:o=>{let a=e();i.setField(t,ot(o,a))},setBlur:()=>i.blurField(t),displayValue:o=>nt(o,e())}}function ri(i,t){return{fieldController:Me(i,t,()=>i.resolveMask(t))}}function si(i,t){let e=[],r=o=>i.createArrayItemId(t,o),s=o=>Array.isArray(o)?o:[],n=o=>{if(o.length!==e.length)if(o.length>e.length){let a=o.length-e.length;e=[...e,...Array.from({length:a},(l,d)=>r(e.length+d))]}else e=e.slice(0,o.length);return o};return{readItems(){let o=h(i.getState().values,t);return n(s(o))},getFields(o){return o.map((a,l)=>({key:e[l]||`temp-${l}`,value:a,index:l}))},append(o){e=[...e,r(e.length)],i.pushItem(t,o)},prepend(o){e=[r(0),...e],i.prependItem(t,o)},insert(o,a){let l=[...e];l.splice(o,0,r(o)),e=l,i.insertItem(t,o,a)},remove(o){e=e.filter((a,l)=>l!==o),i.removeItem(t,o)},move(o,a){let l=[...e],[d]=l.splice(o,1);l.splice(a,0,d),e=l,i.moveItem(t,o,a)},swap(o,a){let l=[...e];[l[o],l[a]]=[l[a],l[o]],e=l,i.swapItems(t,o,a)},replace(o){e=o.map((a,l)=>r(l)),i.setField(t,o)},clear(){e=[],i.setField(t,[])}}}function ni(i,t){i.unregisterField?.(t)}function oi(i,t){i.unregisterPrefix?.(t)}function ai(i){let t=i.touched?i.error:void 0,e=!!i.error;return{error:t,touched:i.touched,invalid:!!(i.touched&&i.error),isValidating:i.isValidating,isDirty:i.isDirty,isHidden:i.isHidden,isRequired:i.isRequired,hasError:e}}export{u as a,E as b,T as c,S as d,h as e,m as f,ke as g,V as h,dt as i,Y as j,At as k,ht as l,pt as m,_e as n,Xt as o,gt as p,ft as q,Ue as r,Je as s,Ge as t,Xe as u,Ze as v,yt as w,Pe as x,Ye as y,Fe as z,Qe as A,ti as B,ei as C,ii as D,ri as E,si as F,ni as G,oi as H,ai as I};
2
- //# sourceMappingURL=chunk-SA47B5OP.js.map