@lehnihon/bit-form 2.2.5 → 2.2.7

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 (121) hide show
  1. package/README.md +80 -24
  2. package/dist/angular/index.cjs +1 -1
  3. package/dist/angular/index.cjs.map +1 -1
  4. package/dist/angular/index.d.cts +18 -20
  5. package/dist/angular/index.d.ts +18 -20
  6. package/dist/angular/index.js +1 -1
  7. package/dist/angular/index.js.map +1 -1
  8. package/dist/array-controller-C1A5VKYd.d.cts +23 -0
  9. package/dist/array-controller-DtkmcnUr.d.ts +23 -0
  10. package/dist/{bus-B4zZmB9C.d.ts → bus-DgilLszS.d.ts} +83 -15
  11. package/dist/{bus-BeAeZwWu.d.cts → bus-rcUiufS7.d.cts} +83 -15
  12. package/dist/chunk-DIEE6LUO.js +2 -0
  13. package/dist/chunk-DIEE6LUO.js.map +1 -0
  14. package/dist/chunk-FUUQB4DV.cjs +2 -0
  15. package/dist/chunk-FUUQB4DV.cjs.map +1 -0
  16. package/dist/chunk-IV32WXCF.cjs +2 -0
  17. package/dist/chunk-IV32WXCF.cjs.map +1 -0
  18. package/dist/chunk-K5X37E3U.js +2 -0
  19. package/dist/chunk-K5X37E3U.js.map +1 -0
  20. package/dist/chunk-KWLLYQOL.cjs +2 -0
  21. package/dist/chunk-KWLLYQOL.cjs.map +1 -0
  22. package/dist/chunk-LIYZPSWM.js +2 -0
  23. package/dist/chunk-LIYZPSWM.js.map +1 -0
  24. package/dist/chunk-O5UPA33R.js +2 -0
  25. package/dist/chunk-O5UPA33R.js.map +1 -0
  26. package/dist/chunk-QAL6J5GQ.cjs +2 -0
  27. package/dist/chunk-QAL6J5GQ.cjs.map +1 -0
  28. package/dist/chunk-QKGTVKBU.cjs +2 -0
  29. package/dist/chunk-QKGTVKBU.cjs.map +1 -0
  30. package/dist/chunk-SA47B5OP.js +2 -0
  31. package/dist/chunk-SA47B5OP.js.map +1 -0
  32. package/dist/cli/index.cjs +22 -22
  33. package/dist/core.cjs +2 -0
  34. package/dist/core.cjs.map +1 -0
  35. package/dist/core.d.cts +122 -0
  36. package/dist/core.d.ts +122 -0
  37. package/dist/core.js +2 -0
  38. package/dist/core.js.map +1 -0
  39. package/dist/devtools/bridge.cjs +1 -1
  40. package/dist/devtools/bridge.cjs.map +1 -1
  41. package/dist/devtools/bridge.d.cts +4 -1
  42. package/dist/devtools/bridge.d.ts +4 -1
  43. package/dist/devtools/bridge.js +1 -1
  44. package/dist/devtools/bridge.js.map +1 -1
  45. package/dist/devtools/index.cjs +18 -18
  46. package/dist/devtools/index.cjs.map +1 -1
  47. package/dist/devtools/index.d.cts +26 -2
  48. package/dist/devtools/index.d.ts +26 -2
  49. package/dist/devtools/index.js +18 -18
  50. package/dist/devtools/index.js.map +1 -1
  51. package/dist/devtools/protocol.cjs +2 -0
  52. package/dist/devtools/protocol.cjs.map +1 -0
  53. package/dist/devtools/protocol.d.cts +54 -0
  54. package/dist/devtools/protocol.d.ts +54 -0
  55. package/dist/devtools/protocol.js +2 -0
  56. package/dist/devtools/protocol.js.map +1 -0
  57. package/dist/field-binding-Bi1g-D8X.d.ts +25 -0
  58. package/dist/field-binding-X5TkvfUt.d.cts +25 -0
  59. package/dist/index.cjs +1 -1
  60. package/dist/index.cjs.map +1 -1
  61. package/dist/index.d.cts +64 -150
  62. package/dist/index.d.ts +64 -150
  63. package/dist/index.js +1 -1
  64. package/dist/mask.d.cts +2 -2
  65. package/dist/mask.d.ts +2 -2
  66. package/dist/react/index.cjs +1 -1
  67. package/dist/react/index.cjs.map +1 -1
  68. package/dist/react/index.d.cts +8 -7
  69. package/dist/react/index.d.ts +8 -7
  70. package/dist/react/index.js +1 -1
  71. package/dist/react/index.js.map +1 -1
  72. package/dist/react-native/index.cjs +1 -1
  73. package/dist/react-native/index.cjs.map +1 -1
  74. package/dist/react-native/index.d.cts +7 -6
  75. package/dist/react-native/index.d.ts +7 -6
  76. package/dist/react-native/index.js +1 -1
  77. package/dist/react-native/index.js.map +1 -1
  78. package/dist/resolvers/index.cjs +1 -1
  79. package/dist/resolvers/index.cjs.map +1 -1
  80. package/dist/resolvers/index.d.cts +2 -2
  81. package/dist/resolvers/index.d.ts +2 -2
  82. package/dist/resolvers/index.js +1 -1
  83. package/dist/resolvers/joi.d.cts +2 -2
  84. package/dist/resolvers/joi.d.ts +2 -2
  85. package/dist/resolvers/yup.d.cts +2 -2
  86. package/dist/resolvers/yup.d.ts +2 -2
  87. package/dist/resolvers/zod.d.cts +2 -2
  88. package/dist/resolvers/zod.d.ts +2 -2
  89. package/dist/store-api-types-9ipdute1.d.ts +187 -0
  90. package/dist/store-api-types-B6_bPoVI.d.cts +187 -0
  91. package/dist/{types-D8DgIUhJ.d.cts → types-CUXh7PqD.d.cts} +1 -1
  92. package/dist/{types-D8DgIUhJ.d.ts → types-CUXh7PqD.d.ts} +1 -1
  93. package/dist/{use-bit-persist-iPWLbD8l.d.ts → use-bit-persist-Bc06fmqZ.d.ts} +12 -14
  94. package/dist/{use-bit-persist-CIVN-oIi.d.cts → use-bit-persist-CIKFwtdM.d.cts} +12 -14
  95. package/dist/vue/index.cjs +1 -1
  96. package/dist/vue/index.cjs.map +1 -1
  97. package/dist/vue/index.d.cts +15 -18
  98. package/dist/vue/index.d.ts +15 -18
  99. package/dist/vue/index.js +1 -1
  100. package/dist/vue/index.js.map +1 -1
  101. package/package.json +20 -11
  102. package/dist/chunk-2FDEJYA5.js +0 -2
  103. package/dist/chunk-2FDEJYA5.js.map +0 -1
  104. package/dist/chunk-3CARTBEN.cjs +0 -2
  105. package/dist/chunk-3CARTBEN.cjs.map +0 -1
  106. package/dist/chunk-64KSP4TP.js +0 -2
  107. package/dist/chunk-64KSP4TP.js.map +0 -1
  108. package/dist/chunk-JIWR4KSZ.cjs +0 -2
  109. package/dist/chunk-JIWR4KSZ.cjs.map +0 -1
  110. package/dist/chunk-OZKLQRO6.cjs +0 -2
  111. package/dist/chunk-OZKLQRO6.cjs.map +0 -1
  112. package/dist/chunk-QWH2NBVB.js +0 -2
  113. package/dist/chunk-QWH2NBVB.js.map +0 -1
  114. package/dist/chunk-UMKOKAPD.js +0 -2
  115. package/dist/chunk-UMKOKAPD.js.map +0 -1
  116. package/dist/chunk-VQ7MK5VB.cjs +0 -2
  117. package/dist/chunk-VQ7MK5VB.cjs.map +0 -1
  118. package/dist/field-binding-BXw0Ku2c.d.cts +0 -12
  119. package/dist/field-binding-BXw0Ku2c.d.ts +0 -12
  120. package/dist/public-types-BQXaxmAE.d.cts +0 -94
  121. package/dist/public-types-CVgFf_qY.d.ts +0 -94
@@ -0,0 +1,2 @@
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 _chunkPFPGASVZcjs = require('./chunk-PFPGASVZ.cjs');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(_optionalChain([i, 'optionalAccess', _2 => _2[n]]),_optionalChain([t, 'optionalAccess', _3 => _3[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=_optionalChain([s, 'optionalAccess', _4 => _4[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=_nullishCoalesce(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)?_nullishCoalesce(i.errors, () => (i)):{}}function Tt(i){let{path:t,getFieldConfig:e,masks:r}=i,s=_optionalChain([e, 'call', _5 => _5(t), 'optionalAccess', _6 => _6.mask]);if(s)return typeof s=="string"?_optionalChain([r, 'optionalAccess', _7 => _7[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:_optionalChain([e, 'optionalAccess', _8 => _8.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 =class{constructor(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);this.getComputedEntries=t}__init() {this.equalityCache=new Map}__init2() {this.reverseDepsCache=null}__init3() {this.childDepsIndex=null}__init4() {this.validatedEntriesSignature=null}__init5() {this.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=_nullishCoalesce(s.get(l), () => (new Set));d.has(a.path)||(d.add(a.path),s.set(l,d),r.set(a.path,(_nullishCoalesce(r.get(a.path), () => (0)))+1))})});let n=t.filter(a=>(_nullishCoalesce(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=(_nullishCoalesce(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=_optionalChain([this, 'access', _9 => _9.childDepsIndex, 'optionalAccess', _10 => _10.get, 'call', _11 => _11(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.`)}}, _class);var A= (_class2 =class{constructor() { _class2.prototype.__init6.call(this);_class2.prototype.__init7.call(this);_class2.prototype.__init8.call(this);_class2.prototype.__init9.call(this); }__init6() {this.dirtyPaths=new Set}__init7() {this.dirtyPathIndex=new Set}__init8() {this.dirtyPrefixRefCount=new Map}__init9() {this.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,(_nullishCoalesce(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,(_nullishCoalesce(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=(_nullishCoalesce(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=>{_optionalChain([this, 'access', _12 => _12.childrenByPrefix, 'access', _13 => _13.get, 'call', _14 => _14(e), 'optionalAccess', _15 => _15.delete, 'call', _16 => _16(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)}}, _class2);var D= (_class3 =class{constructor() { _class3.prototype.__init10.call(this); }__init10() {this.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={}}}, _class3);var k= (_class4 =class{constructor() { _class4.prototype.__init11.call(this);_class4.prototype.__init12.call(this);_class4.prototype.__init13.call(this);_class4.prototype.__init14.call(this); }__init11() {this.fieldConfigs=new Map}__init12() {this.scopeFieldsIndex=null}__init13() {this.computedEntriesCache=null}__init14() {this.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=_nullishCoalesce(e.get(r.scope), () => ([]));n.push(s),e.set(r.scope,n)}),this.scopeFieldsIndex=e}return _nullishCoalesce(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=_nullishCoalesce(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))}}, _class4);var R= (_class5 =class{constructor(t){;_class5.prototype.__init15.call(this);_class5.prototype.__init16.call(this);_class5.prototype.__init17.call(this);_class5.prototype.__init18.call(this);_class5.prototype.__init19.call(this);_class5.prototype.__init20.call(this);_class5.prototype.__init21.call(this);this.getFieldConfig=t}__init15() {this.dependencies=new Map}__init16() {this.hiddenFields=new Set}__init17() {this.conditionalVisibilityPaths=new Set}__init18() {this.requiredPathsByDependency=new Map}__init19() {this.requiredConditionalPaths=new Set}__init20() {this.requiredEvaluationCache=new WeakMap}__init21() {this.requiredEvaluationCacheDirty=!1}getHiddenFields(){return this.hiddenFields}onRegister(t,e,r){_optionalChain([e, 'access', _17 => _17.conditional, 'optionalAccess', _18 => _18.showIf])&&this.conditionalVisibilityPaths.add(t);let s=_optionalChain([e, 'access', _19 => _19.conditional, 'optionalAccess', _20 => _20.dependsOn]);s&&s.forEach(n=>{this.dependencies.has(n)||this.dependencies.set(n,new Set),this.dependencies.get(n).add(t)}),s&&_optionalChain([e, 'access', _21 => _21.conditional, 'optionalAccess', _22 => _22.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),_optionalChain([e, 'optionalAccess', _23 => _23.conditional, 'optionalAccess', _24 => _24.dependsOn, 'optionalAccess', _25 => _25.forEach, 'call', _26 => _26(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(_nullishCoalesce(_optionalChain([this, 'access', _27 => _27.dependencies, 'access', _28 => _28.get, 'call', _29 => _29(t), 'optionalAccess', _30 => _30.size]), () => (0)))>0}isRequired(t,e){let r=this.getFieldConfig(t);if(!r||this.isHidden(t)||!_optionalChain([r, 'access', _31 => _31.conditional, 'optionalAccess', _32 => _32.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]=_nullishCoalesce(_optionalChain([s, 'access', _33 => _33.conditional, 'optionalAccess', _34 => _34.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=_optionalChain([this, 'access', _35 => _35.getFieldConfig, 'call', _36 => _36(t), 'optionalAccess', _37 => _37.conditional, 'optionalAccess', _38 => _38.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}}, _class5);var w= (_class6 =class{constructor() { _class6.prototype.__init22.call(this);_class6.prototype.__init23.call(this); }__init22() {this.catalog=new k}__init23() {this.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()}}, _class6);function Re(){return`bit-form-${Math.random().toString(36).slice(2,9)}`}function Pt(i={}){let t=_nullishCoalesce(i.initialValues, () => ({})),e=i.validation,r=i.history,s=i.name?`bit-form:${i.name}:draft`:"bit-form:draft",n={enabled:_nullishCoalesce(_optionalChain([i, 'access', _39 => _39.persist, 'optionalAccess', _40 => _40.enabled]), () => (!1)),key:_nullishCoalesce(_optionalChain([i, 'access', _41 => _41.persist, 'optionalAccess', _42 => _42.key]), () => (s)),storage:_optionalChain([i, 'access', _43 => _43.persist, 'optionalAccess', _44 => _44.storage]),autoSave:_nullishCoalesce(_optionalChain([i, 'access', _45 => _45.persist, 'optionalAccess', _46 => _46.autoSave]), () => (!0)),debounceMs:_nullishCoalesce(_optionalChain([i, 'access', _47 => _47.persist, 'optionalAccess', _48 => _48.debounceMs]), () => (300)),mode:_nullishCoalesce(_optionalChain([i, 'access', _49 => _49.persist, 'optionalAccess', _50 => _50.mode]), () => ("values")),serialize:_nullishCoalesce(_optionalChain([i, 'access', _51 => _51.persist, 'optionalAccess', _52 => _52.serialize]), () => (JSON.stringify)),deserialize:_nullishCoalesce(_optionalChain([i, 'access', _53 => _53.persist, 'optionalAccess', _54 => _54.deserialize]), () => ((o=>JSON.parse(o)))),onError:_optionalChain([i, 'access', _55 => _55.persist, 'optionalAccess', _56 => _56.onError])};return{name:i.name,initialValues:u(t),resolver:_optionalChain([e, 'optionalAccess', _57 => _57.resolver]),validationDelay:_nullishCoalesce(_optionalChain([e, 'optionalAccess', _58 => _58.delay]), () => (300)),history:{enabled:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _59 => _59.enabled]), () => (!1)),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _60 => _60.limit]), () => (50))},masks:i.masks,fields:i.fields,devTools:i.devTools,persist:n,idFactory:_nullishCoalesce(i.idFactory, () => (Re)),plugins:_nullishCoalesce(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}getStorage(){return this.config.storage||we()}canPersist(){return!!(this.config.enabled&&this.config.key&&this.getStorage())}handleError(t){_optionalChain([this, 'access', _61 => _61.config, 'access', _62 => _62.onError, 'optionalCall', _63 => _63(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= (_class7 =class{constructor(t,e){;_class7.prototype.__init24.call(this);_class7.prototype.__init25.call(this);this.plugins=t;this.contextFactory=e}__init24() {this.teardownFns=[]}__init25() {this.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=_optionalChain([r, 'access', _64 => _64.hooks, 'optionalAccess', _65 => _65.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=_optionalChain([a, 'access', _66 => _66.hooks, 'optionalAccess', _67 => _67.onError]);if(l)try{await l(o,n)}catch (e2){}}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=_optionalChain([s, 'access', _68 => _68.hooks, 'optionalAccess', _69 => _69[t]]);if(n)try{await n(e,r)}catch(o){await this.reportError(t,o,e,s.name)}}}}, _class7);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;_optionalChain([r, 'call', _70 => _70(o), 'optionalAccess', _71 => _71.validation, 'optionalAccess', _72 => _72.asyncValidate])&&n.push(o)}return n}return s&&s((o,a)=>{!_optionalChain([o, 'access', _73 => _73.validation, 'optionalAccess', _74 => _74.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=_optionalChain([n, 'call', _75 => _75(t), 'optionalAccess', _76 => _76.validation, 'optionalAccess', _77 => _77.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= (_class8 =class{constructor(t){;_class8.prototype.__init26.call(this);_class8.prototype.__init27.call(this);this.port=t}__init26() {this.abortControllers=new Map}__init27() {this.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)}}}, _class8);var _= (_class9 =class{constructor(t){;_class9.prototype.__init28.call(this);this.port=t}__init28() {this.pendingScopeFields=null}trigger(t,e){this.cancelTimeout&&(this.cancelTimeout(),this.cancelTimeout=void 0);let r=_nullishCoalesce(this.port.validationDelay, () => (300)),s=_optionalChain([e, 'optionalAccess', _78 => _78.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}}, _class9);var U= (_class10 =class{constructor(t){;_class10.prototype.__init29.call(this);_class10.prototype.__init30.call(this);_class10.prototype.__init31.call(this);_class10.prototype.__init32.call(this);this.store=t;this.schedule=_nullishCoalesce(_optionalChain([t, 'access', _79 => _79.config, 'access', _80 => _80.scheduler, 'optionalAccess', _81 => _81.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:_nullishCoalesce(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)}])}__init29() {this.currentValidationId=0}__init30() {this.validatingCount=0}__init31() {this.asyncErrors=new Map}__init32() {this.immediateAbortControllers=new Map}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=_optionalChain([r, 'optionalAccess', _82 => _82.validation, 'optionalAccess', _83 => _83.asyncValidate]),n=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _84 => _84.validation, 'optionalAccess', _85 => _85.asyncValidateOn]), () => ("blur"));if(!s||n!=="change"){this.cancelFieldAsync(t),this.updateFieldValidating(t,!1);return}let o=_nullishCoalesce(_optionalChain([r, 'access', _86 => _86.validation, 'optionalAccess', _87 => _87.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:_optionalChain([t, 'optionalAccess', _88 => _88.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(_optionalChain([t, 'access', _89 => _89.options, 'optionalAccess', _90 => _90.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:_optionalChain([t, 'access', _91 => _91.options, 'optionalAccess', _92 => _92.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:_optionalChain([t, 'access', _93 => _93.options, 'optionalAccess', _94 => _94.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:_optionalChain([t, 'access', _95 => _95.options, 'optionalAccess', _96 => _96.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)))}}, _class10);var z= (_class11 =class{constructor(t){;_class11.prototype.__init33.call(this);_class11.prototype.__init34.call(this);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)}])}__init33() {this.reusableContext={path:"",value:void 0,meta:{origin:"setField"},previousValue:void 0,nextValues:{},nextErrors:{},hasMutatedErrors:!1,toggledFields:[],isDirty:!1}}__init34() {this.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"?_optionalChain([this, 'access', _97 => _97.store, 'access', _98 => _98.getFieldConfig, 'call', _99 => _99(t.path), 'optionalAccess', _100 => _100.validation, 'optionalAccess', _101 => _101.asyncValidateOn]):void 0)==="change"&&this.store.handleFieldAsyncValidation(t.path,t.value)}}, _class11);var N=class{constructor(t){this.store=t}setValues(t,e){if(_optionalChain([e, 'optionalAccess', _102 => _102.rebase])){this.rebaseValues(t);return}if(_optionalChain([e, 'optionalAccess', _103 => _103.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)}])}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)}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 $= (_class12 =class{constructor(t,e=15){;_class12.prototype.__init35.call(this);_class12.prototype.__init36.call(this);_class12.prototype.__init37.call(this);_class12.prototype.__init38.call(this);_class12.prototype.__init39.call(this);this.enableHistory=t;this.maxHistory=e}__init35() {this.baseSnapshot=null}__init36() {this.currentSnapshot=null}__init37() {this.patches=[]}__init38() {this.historyIndex=-1}__init39() {this.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)}}, _class12);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= (_class13 =class{constructor(t,e,r){;_class13.prototype.__init40.call(this);this.fieldRegistry=t;this.getState=e;this.isPathDirty=r}__init40() {this.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]}}, _class13);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,_nullishCoalesce(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?_nullishCoalesce(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&&(_optionalChain([o, 'optionalCall', _104 => _104()]),c(a))})))},qe(g,n))};return c(a),()=>{l=!0,_optionalChain([o, 'optionalCall', _105 => _105()]),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=_nullishCoalesce(_optionalChain([s, 'optionalAccess', _106 => _106.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=[..._nullishCoalesce(_optionalChain([r, 'optionalAccess', _107 => _107.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= (_class14 =class{constructor(t,e=500){;_class14.prototype.__init41.call(this);_class14.prototype.__init42.call(this);_class14.prototype.__init43.call(this);_class14.prototype.__init44.call(this);_class14.prototype.__init45.call(this);_class14.prototype.__init46.call(this);_class14.prototype.__init47.call(this);this.getState=t;this.MAX_EXPANDED_CACHE_SIZE=e,this.MAX_CHANGED_LOOKUP_CACHE_SIZE=e}__init41() {this.listeners=new Set}__init42() {this.pathScopedSubscriptions=new Map}__init43() {this.pathSelectorIndex=new Map}__init44() {this.expandedPathCache=new Map}__init45() {this.changedPathLookupCache=new Map}__init46() {this.subscriptionSeenVersion=new Map}__init47() {this.notifyVersion=0}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(_optionalChain([r, 'optionalAccess', _108 => _108.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=_nullishCoalesce(this.pathSelectorIndex.get(d), () => (new Set));c.add(o),this.pathSelectorIndex.set(d,c)})}),_optionalChain([r, 'optionalAccess', _109 => _109.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=>{(_nullishCoalesce(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)}}, _class14);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 _nullishCoalesce(t.pendingState, () => (i))}function pe(i,t){if(i.pendingState=t.nextState,i.valuesChanged||=t.valuesChanged,t.changedPaths&&t.changedPaths.length>0){let e=_nullishCoalesce(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=_nullishCoalesce(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:_nullishCoalesce(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(!_optionalChain([i, 'optionalAccess', _110 => _110.length]))return t;if(!_optionalChain([t, 'optionalAccess', _111 => _111.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=_nullishCoalesce(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= (_class15 =class{constructor(t){;_class15.prototype.__init48.call(this);this.args=t;this.state=t.state,this.subscriptions=t.subscriptions,this.effects=t.effects,this.capabilities=t.capabilities}__init48() {this.batchState=de()}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)})}}, _class15);var rt= (_class16 =class{__init49() {this[Q]=!0}get config(){return _nullishCoalesce(this._cachedConfig, () => (this._config))}invalidateFieldIndexes(){this.fieldRegistry.invalidateIndexes(),this.computedManager.invalidateReverseDeps()}constructor(t={}){;_class16.prototype.__init49.call(this);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:()=>_nullishCoalesce(_optionalChain([e, 'optionalAccess', _112 => _112.getState, 'call', _113 => _113()]), () => (r.state)),dispatch:n=>_optionalChain([e, 'optionalAccess', _114 => _114.dispatch, 'call', _115 => _115(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:()=>_optionalChain([e, 'optionalAccess', _116 => _116.saveHistorySnapshot, 'call', _117 => _117()]),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:()=>_nullishCoalesce(_optionalChain([e, 'optionalAccess', _118 => _118.getState, 'call', _119 => _119()]), () => (r.state)),getConfig:()=>this.getConfig(),getValues:()=>(_nullishCoalesce(_optionalChain([e, 'optionalAccess', _120 => _120.getState, 'call', _121 => _121()]), () => (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 _nullishCoalesce(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:!!_optionalChain([this, 'access', _122 => _122._config, 'access', _123 => _123.fields, 'optionalAccess', _124 => _124[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()}}, _class16);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){_optionalChain([i, 'optionalAccess', _125 => _125.preventDefault, 'optionalCall', _126 => _126()]),_optionalChain([t, 'optionalAccess', _127 => _127.stopPropagation])&&_optionalChain([i, 'optionalAccess', _128 => _128.stopPropagation, 'optionalCall', _129 => _129()])}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,_chunkPFPGASVZcjs.c.call(void 0, o,a))},setBlur:()=>i.blurField(t),displayValue:o=>_chunkPFPGASVZcjs.b.call(void 0, 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){_optionalChain([i, 'access', _130 => _130.unregisterField, 'optionalCall', _131 => _131(t)])}function oi(i,t){_optionalChain([i, 'access', _132 => _132.unregisterPrefix, 'optionalCall', _133 => _133(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}}exports.a = u; exports.b = E; exports.c = T; exports.d = S; exports.e = h; exports.f = m; exports.g = ke; exports.h = V; exports.i = dt; exports.j = Y; exports.k = At; exports.l = ht; exports.m = pt; exports.n = _e; exports.o = Xt; exports.p = gt; exports.q = ft; exports.r = Ue; exports.s = Je; exports.t = Ge; exports.u = Xe; exports.v = Ze; exports.w = yt; exports.x = Pe; exports.y = Ye; exports.z = Fe; exports.A = Qe; exports.B = ti; exports.C = ei; exports.D = ii; exports.E = ri; exports.F = si; exports.G = ni; exports.H = oi; exports.I = ai;
2
+ //# sourceMappingURL=chunk-FUUQB4DV.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/bit-form/bit-form/dist/chunk-FUUQB4DV.cjs","../src/core/utils/clone.ts","../src/core/utils.ts"],"names":["cloneValue","obj","item","clone","key","deepClone","deepMerge","target","source","base","sourceValue","baseValue","valueEqual","a","b","deepEqual","keysA","keysB","collectDirtyPaths","initial","prefix","result","allKeys","k","p"],"mappings":"AAA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A,GAAY,IAAA,EACZ,OAAOA,CAAAA,EAAY,QAAA,CAEnB,OAAIC,CAAAA,EAAQC,CAAAA,CAAO,GAAA,CAAID,CAAM,CAAA,CACtBC,CAAAA,CAET,EAAA,CAAI,KAAA,CAAM,OAAA,CAAQpB,CAAG,CAAA,EAAK,KAAA,CAAM,OAAA,CAAQkB,CAAO,CAAA,CAC7C,MAAI,CAACP,CAAAA,CAAWX,CAAAA,CAAKkB,CAAO,CAAA,EAAKC,CAAAA,EAAQC,CAAAA,CAAO,GAAA,CAAID,CAAM,CAAA,CACnDC,CAAAA,CAET,IAAMC,CAAAA,CAAU,IAAI,GAAA,CACpB,GAAA,CAAA,IAAWlB,EAAAA,GAAO,MAAA,CAAO,IAAA,CAAKH,CAAAA,EAAO,CAAC,CAAC,CAAA,CACrCqB,CAAAA,CAAQ,GAAA,CAAIlB,CAAG,CAAA,CAEjB,GAAA,CAAA,IAAWA,EAAAA,GAAO,MAAA,CAAO,IAAA,CAAKe,CAAAA,EAAW,CAAC,CAAC,CAAA,CACzCG,CAAAA,CAAQ,GAAA,CAAIlB,CAAG,CAAA,CAEjB,GAAA,CAAA,IAAWmB,EAAAA,GAAKD,CAAAA,CAAS,CACvB,IAAME,CAAAA,CAAIJ,CAAAA,CAAS,CAAA,EAAA","file":"/home/runner/work/bit-form/bit-form/dist/chunk-FUUQB4DV.cjs","sourcesContent":[null,"export function cloneValue<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") {\n return obj;\n }\n\n if (typeof structuredClone === \"function\") {\n return structuredClone(obj);\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 (Array.isArray(obj)) {\n return obj.map((item) => cloneValue(item)) as any as T;\n }\n\n const clone: any = {};\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n clone[key] = cloneValue((obj as any)[key]);\n }\n }\n\n return clone as T;\n}\n","import { cloneValue } from \"./utils/clone\";\n\nexport function deepClone<T>(obj: T): T {\n return cloneValue(obj);\n}\n\nexport function deepMerge<T>(target: T, source: any): 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 base =\n target && typeof target === \"object\" && !Array.isArray(target)\n ? deepClone(target as any)\n : ({} as Record<string, unknown>);\n\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 );\n continue;\n }\n\n (base as Record<string, unknown>)[key] = deepClone(sourceValue);\n }\n\n return base as T;\n}\n\n/**\n * Fast equality for single values. Uses === for primitives, deepEqual for objects/arrays.\n * Prefer over deepEqual when comparing a single field value (e.g. isFieldDirty, getStepStatus).\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 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 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 !deepEqual(a[key], b[key])\n ) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Collects all paths where obj differs from initial. Used to rebuild dirtyPaths after full state replacement.\n */\nexport function collectDirtyPaths(\n obj: any,\n initial: any,\n prefix = \"\",\n result: Set<string> = new Set(),\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 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((obj as any)?.[k], (initial as any)?.[k], p, result);\n }\n return result;\n}\n\n/**\n * Path keys cache configuration\n *\n * Caching the split path strings prevents repeated string splitting operations.\n * This is especially important in hotspots like setField(), getDeepValue(), and\n * field change detection where the same paths are accessed repeatedly.\n *\n * Cache size: 5000 entries\n * When cache reaches capacity, it's cleared (rotational eviction strategy)\n * Typical hit rate: >80% in most forms with 100-1000 fields\n */\nconst PATH_CACHE_MAX = 5000;\nconst pathCache = new Map<string, string[]>();\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\nexport function getDeepValue(obj: any, path: string): any {\n if (!path) return obj;\n\n const keys = getPathKeys(path);\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\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 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 updates) {\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 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 current.splice(Number(leafKey), 1);\n } else if (current && typeof current === \"object\") {\n delete current[leafKey];\n }\n\n return root;\n}\n\nexport 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 // Iterate each dictionary directly to avoid building a union Set of all keys.\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\nfunction remapIndexedPath(\n key: string,\n prefix: string,\n remapIndex: (index: number) => number | null,\n) {\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 = parseInt(parts[0], 10);\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 = parseInt(parts[0], 10);\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\n/**\n * Checks if a value looks like a server validation error response.\n * Handles shapes like { email: \"Taken\" }, { errors: { email: [\"Taken\"] } }, etc.\n */\nexport 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 return Object.values(obj as Record<string, unknown>).every(\n (v) =>\n typeof v === \"string\" ||\n (Array.isArray(v) && v.every((i) => typeof i === \"string\")),\n );\n}\n\n/**\n * Extracts server errors in the format expected by setServerErrors.\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, unknown>).errors ?? x;\n return obj as Record<string, string | string[]>;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});function a(n,t,e){return async o=>{if(o){e.setLoading(!0),e.setError(n,void 0);try{let r=await t(o);e.setValue(r.url),e.setUploadKey(r.key),e.setError(n,void 0)}catch(r){let d=r instanceof Error?r.message:"Upload failed";e.setError(n,d)}finally{e.setLoading(!1)}}}}function l(n,t,e){return async()=>{let o=e.getUploadKey();if(o&&t)try{await t(o)}catch(r){let d=r instanceof Error?r.message:"Delete failed";e.setError(n,d);return}e.setValue(null),e.setUploadKey(null),e.setError(n,void 0)}}exports.a = a; exports.b = l;
2
+ //# sourceMappingURL=chunk-IV32WXCF.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/adapters/upload-kernel.ts"],"names":["createUploadHandler","fieldPath","uploadFn","callbacks","file","result","error","message","createRemoveHandler","deleteFile","uploadKey"],"mappings":"AAqCO,kFAASA,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CACkD,CAClD,OAAO,MAAOC,CAAAA,EAAS,CACrB,EAAA,CAAKA,CAAAA,CAEL,CAAAD,CAAAA,CAAU,UAAA,CAAW,CAAA,CAAI,CAAA,CAC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sourcesContent":["/**\n * Framework-agnostic upload kernel.\n *\n * Encapsulates the side-effect logic for uploading/removing files so that\n * React, Vue, and Angular adapters share a single implementation and only\n * differ in how they wire reactive state.\n */\n\nimport type { BitUploadFn, BitDeleteUploadFn } from \"../types/upload\";\n\nexport interface UploadKernelCallbacks {\n /** Called with `true` when upload starts and `false` when it finishes. */\n setLoading: (loading: boolean) => void;\n /** Set or clear a field-level error message. */\n setError: (path: string, message: string | undefined) => void;\n /** Set the stored file URL after a successful upload (or `null` on remove). */\n setValue: (value: string | null) => void;\n /** Return the key of the last uploaded file (used when deleting). */\n getUploadKey: () => string | null;\n /** Persist the upload key returned by the upload function. */\n setUploadKey: (key: string | null) => void;\n}\n\n/**\n * Creates a type-safe `upload` handler for a field.\n *\n * @example\n * ```ts\n * const upload = createUploadHandler(\"avatar\", myUploadFn, {\n * setLoading: (v) => (isUploading.value = v),\n * setError: (p, m) => store.setError(p, m),\n * setValue: (v) => field.setValue(v),\n * getUploadKey: () => uploadKey,\n * setUploadKey: (k) => (uploadKey = k),\n * });\n * ```\n */\nexport function createUploadHandler(\n fieldPath: string,\n uploadFn: BitUploadFn,\n callbacks: UploadKernelCallbacks,\n): (file: File | null | undefined) => Promise<void> {\n return async (file) => {\n if (!file) return;\n\n callbacks.setLoading(true);\n callbacks.setError(fieldPath, undefined);\n\n try {\n const result = await uploadFn(file);\n\n callbacks.setValue(result.url);\n callbacks.setUploadKey(result.key);\n callbacks.setError(fieldPath, undefined);\n } catch (error) {\n const message = error instanceof Error ? error.message : \"Upload failed\";\n callbacks.setError(fieldPath, message);\n } finally {\n callbacks.setLoading(false);\n }\n };\n}\n\n/**\n * Creates a type-safe `remove` handler for a field.\n */\nexport function createRemoveHandler(\n fieldPath: string,\n deleteFile: BitDeleteUploadFn | undefined,\n callbacks: UploadKernelCallbacks,\n): () => Promise<void> {\n return async () => {\n const uploadKey = callbacks.getUploadKey();\n\n if (uploadKey && deleteFile) {\n try {\n await deleteFile(uploadKey);\n } catch (error) {\n const message =\n error instanceof Error ? error.message : \"Delete failed\";\n callbacks.setError(fieldPath, message);\n return;\n }\n }\n\n callbacks.setValue(null);\n callbacks.setUploadKey(null);\n callbacks.setError(fieldPath, undefined);\n };\n}\n"]}
@@ -0,0 +1,2 @@
1
+ var r=1;function n(o){return o.protocolVersion===1}function s(o){if(!o||typeof o!="object")return!1;let e=o;return typeof e.storeId=="string"&&(e.action==="undo"||e.action==="redo"||e.action==="reset")}function a(o){if(!o||typeof o!="object")return!1;let e=o;return e.type==="ACTION"&&n(e)&&s(e.payload)}function l(o){if(!o||typeof o!="object")return!1;let e=o;return e.type==="STATE_UPDATE"&&n(e)}function i(o){if(!o||typeof o!="object")return!1;let e=o;return e.type==="PING"&&n(e)}function c(o){if(!o||typeof o!="object")return!1;let e=o;if(e.type!=="HELLO"||!e.payload||!n(e))return!1;let t=e.payload;return(t.role==="client"||t.role==="server")&&t.protocolVersion===1}export{r as a,s as b,a as c,l as d,i as e,c as f};
2
+ //# sourceMappingURL=chunk-K5X37E3U.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/devtools/protocol.ts"],"sourcesContent":["export type DevToolsActionName = \"undo\" | \"redo\" | \"reset\";\n\nexport const DEVTOOLS_PROTOCOL_VERSION = 1;\n\nexport interface DevToolsProtocolMessageBase {\n protocolVersion: number;\n}\n\nexport interface DevToolsHistoryMeta {\n canUndo: boolean;\n canRedo: boolean;\n totalSteps: number;\n currentIndex: number;\n}\n\nexport interface DevToolsStoreSnapshot {\n values: unknown;\n errors: Record<string, unknown>;\n touched: Record<string, unknown>;\n isValid: boolean;\n isDirty: boolean;\n isSubmitting: boolean;\n isValidating?: Record<string, unknown>;\n persist?: unknown;\n _meta: DevToolsHistoryMeta;\n}\n\nexport type DevToolsStoreSnapshots = Record<string, DevToolsStoreSnapshot>;\n\nexport interface DevToolsActionPayload {\n storeId: string;\n action: DevToolsActionName;\n}\n\nexport interface DevToolsStateUpdateMessage extends DevToolsProtocolMessageBase {\n type: \"STATE_UPDATE\";\n payload: DevToolsStoreSnapshots;\n}\n\nexport interface DevToolsPingMessage extends DevToolsProtocolMessageBase {\n type: \"PING\";\n}\n\nexport interface DevToolsActionMessage extends DevToolsProtocolMessageBase {\n type: \"ACTION\";\n payload: DevToolsActionPayload;\n}\n\nexport interface DevToolsHelloPayload {\n role: \"client\" | \"server\";\n protocolVersion: number;\n}\n\nexport interface DevToolsHelloMessage extends DevToolsProtocolMessageBase {\n type: \"HELLO\";\n payload: DevToolsHelloPayload;\n}\n\nexport type DevToolsRemoteMessage =\n | DevToolsStateUpdateMessage\n | DevToolsPingMessage\n | DevToolsActionMessage\n | DevToolsHelloMessage;\n\nfunction hasSupportedProtocolVersion(candidate: { protocolVersion?: unknown }) {\n return candidate.protocolVersion === DEVTOOLS_PROTOCOL_VERSION;\n}\n\nexport function isDevToolsActionPayload(\n payload: unknown,\n): payload is DevToolsActionPayload {\n if (!payload || typeof payload !== \"object\") {\n return false;\n }\n\n const candidate = payload as {\n storeId?: unknown;\n action?: unknown;\n };\n\n return (\n typeof candidate.storeId === \"string\" &&\n (candidate.action === \"undo\" ||\n candidate.action === \"redo\" ||\n candidate.action === \"reset\")\n );\n}\n\nexport function isDevToolsActionMessage(\n message: unknown,\n): message is DevToolsActionMessage {\n if (!message || typeof message !== \"object\") {\n return false;\n }\n\n const candidate = message as {\n type?: unknown;\n payload?: unknown;\n protocolVersion?: unknown;\n };\n\n return (\n candidate.type === \"ACTION\" &&\n hasSupportedProtocolVersion(candidate) &&\n isDevToolsActionPayload(candidate.payload)\n );\n}\n\nexport function isDevToolsStateUpdateMessage(\n message: unknown,\n): message is DevToolsStateUpdateMessage {\n if (!message || typeof message !== \"object\") {\n return false;\n }\n\n const candidate = message as {\n type?: unknown;\n protocolVersion?: unknown;\n };\n\n return (\n candidate.type === \"STATE_UPDATE\" && hasSupportedProtocolVersion(candidate)\n );\n}\n\nexport function isDevToolsPingMessage(\n message: unknown,\n): message is DevToolsPingMessage {\n if (!message || typeof message !== \"object\") {\n return false;\n }\n\n const candidate = message as {\n type?: unknown;\n protocolVersion?: unknown;\n };\n\n return candidate.type === \"PING\" && hasSupportedProtocolVersion(candidate);\n}\n\nexport function isDevToolsHelloMessage(\n message: unknown,\n): message is DevToolsHelloMessage {\n if (!message || typeof message !== \"object\") {\n return false;\n }\n\n const candidate = message as {\n type?: unknown;\n payload?: unknown;\n protocolVersion?: unknown;\n };\n\n if (\n candidate.type !== \"HELLO\" ||\n !candidate.payload ||\n !hasSupportedProtocolVersion(candidate)\n ) {\n return false;\n }\n\n const payload = candidate.payload as {\n role?: unknown;\n protocolVersion?: unknown;\n };\n\n return (\n (payload.role === \"client\" || payload.role === \"server\") &&\n payload.protocolVersion === DEVTOOLS_PROTOCOL_VERSION\n );\n}\n"],"mappings":"AAEO,IAAMA,EAA4B,EA8DzC,SAASC,EAA4BC,EAA0C,CAC7E,OAAOA,EAAU,kBAAoB,CACvC,CAEO,SAASC,EACdC,EACkC,CAClC,GAAI,CAACA,GAAW,OAAOA,GAAY,SACjC,MAAO,GAGT,IAAMF,EAAYE,EAKlB,OACE,OAAOF,EAAU,SAAY,WAC5BA,EAAU,SAAW,QACpBA,EAAU,SAAW,QACrBA,EAAU,SAAW,QAE3B,CAEO,SAASG,EACdC,EACkC,CAClC,GAAI,CAACA,GAAW,OAAOA,GAAY,SACjC,MAAO,GAGT,IAAMJ,EAAYI,EAMlB,OACEJ,EAAU,OAAS,UACnBD,EAA4BC,CAAS,GACrCC,EAAwBD,EAAU,OAAO,CAE7C,CAEO,SAASK,EACdD,EACuC,CACvC,GAAI,CAACA,GAAW,OAAOA,GAAY,SACjC,MAAO,GAGT,IAAMJ,EAAYI,EAKlB,OACEJ,EAAU,OAAS,gBAAkBD,EAA4BC,CAAS,CAE9E,CAEO,SAASM,EACdF,EACgC,CAChC,GAAI,CAACA,GAAW,OAAOA,GAAY,SACjC,MAAO,GAGT,IAAMJ,EAAYI,EAKlB,OAAOJ,EAAU,OAAS,QAAUD,EAA4BC,CAAS,CAC3E,CAEO,SAASO,EACdH,EACiC,CACjC,GAAI,CAACA,GAAW,OAAOA,GAAY,SACjC,MAAO,GAGT,IAAMJ,EAAYI,EAMlB,GACEJ,EAAU,OAAS,SACnB,CAACA,EAAU,SACX,CAACD,EAA4BC,CAAS,EAEtC,MAAO,GAGT,IAAME,EAAUF,EAAU,QAK1B,OACGE,EAAQ,OAAS,UAAYA,EAAQ,OAAS,WAC/CA,EAAQ,kBAAoB,CAEhC","names":["DEVTOOLS_PROTOCOL_VERSION","hasSupportedProtocolVersion","candidate","isDevToolsActionPayload","payload","isDevToolsActionMessage","message","isDevToolsStateUpdateMessage","isDevToolsPingMessage","isDevToolsHelloMessage"]}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var _chunkFUUQB4DVcjs = require('./chunk-FUUQB4DV.cjs');var _react = require('react');var _jsxruntime = require('react/jsx-runtime');var H=_react.createContext.call(void 0, null),pt= exports.a =({store:t,children:e})=>_jsxruntime.jsx.call(void 0, H.Provider,{value:_chunkFUUQB4DVcjs.s.call(void 0, t),children:e}),l= exports.b =()=>{let t=_react.useContext.call(void 0, H);if(!t)throw new Error("BitForm hooks devem ser usados dentro de um BitFormProvider");return t};function Ft(){let t=l(),[e,r]=_react.useState.call(void 0, null),[n,s]=_react.useState.call(void 0, null),o=_react.useRef.call(void 0, null),u=_react.useCallback.call(void 0, p=>_chunkFUUQB4DVcjs.x.call(void 0, t,p),[t]),m=_react.useCallback.call(void 0, ()=>{let p=_chunkFUUQB4DVcjs.w.call(void 0, t);return o.current&&o.current.isValid===p.isValid&&o.current.isDirty===p.isDirty&&o.current.isSubmitting===p.isSubmitting?o.current:(o.current=p,p)},[t]),S=_react.useSyncExternalStore.call(void 0, u,m,m),c=_react.useMemo.call(void 0, ()=>_chunkFUUQB4DVcjs.C.call(void 0, t,{clearSubmissionState:()=>{r(null),s(null)},setSubmissionResult:p=>{s(p)},setSubmissionError:p=>{r(p)}}),[t]),{controller:i,actions:h}=c,x=_react.useCallback.call(void 0, i.submit,[i]),v=_react.useCallback.call(void 0, i.onSubmit,[i]),T=_react.useCallback.call(void 0, i.reset,[i]),a=_react.useCallback.call(void 0, i.getValues,[i]),f=_react.useCallback.call(void 0, i.getErrors,[i]),g=_react.useCallback.call(void 0, i.getTouched,[i]),b=_react.useCallback.call(void 0, i.getDirtyValues,[i]);return{meta:_react.useMemo.call(void 0, ()=>({...S,submitError:e,lastResponse:n}),[S,e,n]),getValues:a,getErrors:f,getTouched:g,getDirtyValues:b,submit:x,onSubmit:v,reset:T,...h}}function Tt(t){let e=l(),r=_react.useMemo.call(void 0, ()=>_chunkFUUQB4DVcjs.F.call(void 0, e,t),[e,t]),n=_react.useCallback.call(void 0, ()=>r.readItems(),[r]),s=_react.useCallback.call(void 0, m=>e.subscribePath(t,()=>m()),[e,t]),o=_react.useSyncExternalStore.call(void 0, s,n,n);return{fields:_react.useMemo.call(void 0, ()=>r.getFields(o),[r,o]),length:o.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}}function kt(t){let e=l(),r=e.getScopeFields(t),n=_react.useRef.call(void 0, null),s=_react.useCallback.call(void 0, ()=>{let c=e.getStepStatus(t);return n.current&&_chunkFUUQB4DVcjs.p.call(void 0, n.current,c)?n.current:(n.current=c,c)},[e,t]),o=_react.useCallback.call(void 0, c=>e.subscribeScopeStatus(t,()=>c()),[e,t]),u=_react.useSyncExternalStore.call(void 0, o,s,s),m=_react.useCallback.call(void 0, async()=>{let c=await e.validate({scope:t}),i=e.getStepErrors(t);return{valid:c,errors:i}},[e,t]),S=_react.useCallback.call(void 0, ()=>e.getStepErrors(t),[e,t]);return{scopeName:t,status:u,errors:u.errors,validate:m,getErrors:S,isValid:!u.hasErrors,isDirty:u.isDirty}}function Ut(t){let e=l(),[r,n]=_react.useState.call(void 0, 0),s=_nullishCoalesce(t[r], () => ("")),o=_react.useRef.call(void 0, null),u=_react.useCallback.call(void 0, ()=>{let a=e.getStepStatus(s);return o.current&&_chunkFUUQB4DVcjs.p.call(void 0, o.current,a)?o.current:(o.current=a,a)},[e,s]),m=_react.useSyncExternalStore.call(void 0, _react.useCallback.call(void 0, a=>e.subscribeScopeStatus(s,()=>a()),[e,s]),u,u),S=_react.useCallback.call(void 0, async()=>{let a=await e.validate({scope:s}),f=e.getStepErrors(s);return{valid:a,errors:f}},[e,s]),c=_react.useCallback.call(void 0, ()=>e.getStepErrors(s),[e,s]),i=_react.useCallback.call(void 0, async()=>{let a=e.getScopeFields(s);if(e.hasValidationsInProgress(a))return!1;let f=await e.validate({scope:s});if(f)n(g=>Math.min(g+1,t.length-1));else{let g=e.getStepErrors(s),b=Object.keys(g);b.length>0&&e.markFieldsTouched(b)}return f},[e,s,t.length]),h=_react.useCallback.call(void 0, ()=>{n(a=>Math.max(a-1,0))},[]),x=_react.useCallback.call(void 0, a=>{n(Math.max(0,Math.min(a-1,t.length-1)))},[t.length]),v=r===0,T=r>=t.length-1;return{step:r+1,stepIndex:r,scope:s,next:i,prev:h,goTo:x,isFirst:v,isLast:T,status:m,errors:m.errors,isValid:!m.hasErrors,isDirty:m.isDirty,validate:S,getErrors:c}}function Ot(t){let e=l(),r=_react.useRef.call(void 0, null),n=_react.useCallback.call(void 0, ()=>{let o=_chunkFUUQB4DVcjs.e.call(void 0, e.getState().values,t);return r.current!==null&&_chunkFUUQB4DVcjs.c.call(void 0, r.current,o)?r.current:(r.current=o,o)},[e,t]),s=_react.useCallback.call(void 0, o=>e.subscribePath(t,()=>o()),[e,t]);return _react.useSyncExternalStore.call(void 0, s,n,n)}function Qt(){let t=l(),e=_react.useSyncExternalStore.call(void 0, u=>_chunkFUUQB4DVcjs.A.call(void 0, t,u),()=>_chunkFUUQB4DVcjs.z.call(void 0, t),()=>_chunkFUUQB4DVcjs.z.call(void 0, t)),r=_react.useCallback.call(void 0, async()=>t.restorePersisted(),[t]),n=_react.useCallback.call(void 0, async()=>{await t.forceSave()},[t]),s=_react.useCallback.call(void 0, async()=>{await t.clearPersisted()},[t]),o=_react.useMemo.call(void 0, ()=>({isSaving:e.isSaving,isRestoring:e.isRestoring,error:e.error}),[e]);return{restore:r,save:n,clear:s,meta:o}}function ee(t){let e=l(),r=_react.useRef.call(void 0, null);_react.useEffect.call(void 0, ()=>()=>_chunkFUUQB4DVcjs.G.call(void 0, e,t),[e,t]);let n=_react.useCallback.call(void 0, ()=>{let S=e.getFieldState(t),c=_chunkFUUQB4DVcjs.u.call(void 0, S,r.current);return r.current=c,c},[e,t]),s=_react.useCallback.call(void 0, S=>_chunkFUUQB4DVcjs.D.call(void 0, e,t,()=>S()),[e,t]),o=_react.useSyncExternalStore.call(void 0, s,n,n),u=_react.useCallback.call(void 0, S=>e.setField(t,S),[e,t]),m=_react.useCallback.call(void 0, ()=>e.blurField(t),[e,t]);return{fieldState:o,setValue:u,setBlur:m,store:e}}exports.a = pt; exports.b = l; exports.c = Ft; exports.d = ee; exports.e = Tt; exports.f = kt; exports.g = Ut; exports.h = Ot; exports.i = Qt;
2
+ //# sourceMappingURL=chunk-KWLLYQOL.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/bit-form/bit-form/dist/chunk-KWLLYQOL.cjs","../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"],"names":["BitContext","createContext","BitFormProvider","store","children","jsx","resolveBitStoreForHooks","useBitStore","useContext","useBitForm","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","useBitArray","path","createArrayBindingController","getSnapshot","subscribeArray","data","useBitScope","scopeName","scopeFields","lastStatus","getStatusSnapshot","nextStatus","isScopeStatusEqual","subscribe","status","validate","valid","errors","useBitSteps","scopeNames","stepIndex","setStepIndex","scope","next","s","pathsWithErrors","prev","goTo","targetStep","isFirst","isLast","useBitWatch","lastValue","value","getDeepValue","valueEqual","useBitPersist","persistMeta","subscribePersistMetaSnapshot","readPersistMetaSnapshot","restore","save","clear","meta","useBitFieldBase","lastSnapshot","useEffect","cleanupRegisteredField","nextState","snapshot","createFieldStateSnapshot","subscribeFieldState","fieldState","setValue","val","setBlur"],"mappings":"AAAA,qOAAuH,8BCAtE,+CAa/C,IATIA,CAAAA,CAAaC,kCAAAA,IAAiD,CAAA,CAEvDC,EAAAA,aAAkB,CAAC,CAC9B,KAAA,CAAAC,CAAAA,CACA,QAAA,CAAAC,CACF,CAAA,CAAA,EAIEC,6BAAAA,CAACL,CAAW,QAAA,CAAX,CAAoB,KAAA,CAAOM,iCAAAA,CAA6B,CAAA,CACtD,QAAA,CAAAF,CAAAA,CACH,CAAA,CAGWG,CAAAA,aAAc,CAAA,CAAA,EAAwB,CACjD,IAAMJ,CAAAA,CAAQK,+BAAAA,CAAqB,CAAA,CACnC,EAAA,CAAI,CAACL,CAAAA,CACH,MAAM,IAAI,KAAA,CACR,6DACF,CAAA,CACF,OAAOA,CACT,CAAA,CCzBA,SAegBM,EAAAA,CAAAA,CAAoD,CAClE,IAAMN,CAAAA,CAAQI,CAAAA,CAAe,CAAA,CAEvB,CAACG,CAAAA,CAAaC,CAAc,CAAA,CAAIC,6BAAAA,IAA2B,CAAA,CAC3D,CAACC,CAAAA,CAAcC,CAAe,CAAA,CAAIF,6BAAAA,IAAsB,CAAA,CACxDG,CAAAA,CAAWC,2BAAAA,IAEjB,CAAA,CAEMC,CAAAA,CAAgBC,gCAAAA,CACnBC,EAAmBC,iCAAAA,CAA0BjB,CAAOgB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AA,CAAM,aAAA,CAAcsC,CAAI,CAAA,CACpCgD,CAAAA,CAAWC,iCAAAA,CAAyBF,CAAWH,CAAAA,CAAa,OAAO,CAAA,CACzE,OAAAA,CAAAA,CAAa,OAAA,CAAUI,CAAAA,CAChBA,CACT,CAAA,CAAG,CAACtF,CAAAA,CAAOsC,CAAI,CAAC,CAAA,CAEVY,CAAAA,CAAYnC,gCAAAA,CACfC,EAAmBwE,iCAAAA,CAAoBxF,CAAOsC,CAAAA,CAAM,CAAA,CAAA,EAAMtB,CAAAA,CAAG,CAAC,CAAA,CAC/D,CAAChB,CAAAA,CAAOsC,CAAI,CACd,CAAA,CAEMmD,CAAAA,CAAanE,yCAAAA,CAAqB4B,CAAWV,CAAAA,CAAaA,CAAW,CAAA,CAErEkD,CAAAA,CAAW3E,gCAAAA,CACd4E,EAAgC3F,CAAAA,CAAM,QAAA,CAASsC,CAAAA,CAAMqD,CAAG,CAAA,CACzD,CAAC3F,CAAAA,CAAOsC,CAAI,CACd,CAAA,CAEMsD,CAAAA,CAAU7E,gCAAAA,CAAY,CAAA,EAAMf,CAAAA,CAAM,SAAA,CAAUsC,CAAI,CAAA,CAAG,CAACtC,CAAAA,CAAOsC,CAAI,CAAC,CAAA,CAEtE,MAAO,CAAE,UAAA,CAAAmD,CAAAA,CAAY,QAAA,CAAAC,CAAAA,CAAU,OAAA,CAAAE,CAAAA,CAAS,KAAA,CAAA5F,CAAM,CAChD,CAAA,8IAAA","file":"/home/runner/work/bit-form/bit-form/dist/chunk-KWLLYQOL.cjs","sourcesContent":[null,"import React, { createContext, useContext } from \"react\";\nimport type { BitFormBindingApi, BitStoreHooksApi } from \"../core\";\nimport { resolveBitStoreForHooks } from \"../core\";\n\nconst BitContext = createContext<BitFormBindingApi<any> | null>(null);\n\nexport const BitFormProvider = ({\n store,\n children,\n}: {\n store: BitStoreHooksApi<any>;\n children: React.ReactNode;\n}) => (\n <BitContext.Provider value={resolveBitStoreForHooks(store)}>\n {children}\n </BitContext.Provider>\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 BitFormBindingApi<T>;\n};\n","import {\n useCallback,\n useSyncExternalStore,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { useBitStore } from \"./context\";\nimport {\n createFrameworkFormBinding,\n readFormMetaSnapshot,\n subscribeFormMetaSnapshot,\n} from \"../core\";\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 {\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","import { useCallback, useSyncExternalStore, useMemo } from \"react\";\nimport { useBitStore } from \"./context\";\nimport { createArrayBindingController, BitArrayPath } from \"../core\";\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 () => createArrayBindingController<TForm, P>(store, path),\n [store, path],\n );\n\n const getSnapshot = useCallback(() => {\n return controller.readItems();\n }, [controller]);\n\n const subscribeArray = useCallback(\n (cb: () => void) => store.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 return {\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}\n","import { useCallback, useSyncExternalStore, useRef } 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 const scopeFields = store.getScopeFields(scopeName);\n\n const lastStatus = useRef<ScopeStatus | null>(null);\n\n const getStatusSnapshot = useCallback(() => {\n const nextStatus = store.getStepStatus(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) => store.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.validate({ scope: scopeName });\n const errors = store.getStepErrors(scopeName);\n return { valid, errors };\n }, [store, scopeName]);\n\n const getErrors = useCallback(() => {\n return store.getStepErrors(scopeName);\n }, [store, scopeName]);\n\n return {\n scopeName,\n status,\n errors: status.errors,\n validate,\n getErrors,\n isValid: !status.hasErrors,\n isDirty: status.isDirty,\n };\n}\n","import { useCallback, useSyncExternalStore, useRef, useState } 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.getStepStatus(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.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.validate({ scope });\n const errors = store.getStepErrors(scope);\n return { valid, errors };\n }, [store, scope]);\n\n const getErrors = useCallback(() => {\n return store.getStepErrors(scope);\n }, [store, scope]);\n\n const next = useCallback(async (): Promise<boolean> => {\n const scopeFields = store.getScopeFields(scope);\n\n if (store.hasValidationsInProgress(scopeFields)) {\n return false;\n }\n\n const valid = await store.validate({ scope });\n if (valid) {\n setStepIndex((s) => Math.min(s + 1, scopeNames.length - 1));\n } else {\n const errors = store.getStepErrors(scope);\n const pathsWithErrors = Object.keys(errors);\n if (pathsWithErrors.length > 0) {\n store.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 {\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","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.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.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 { useBitStore } from \"./context\";\nimport { readPersistMetaSnapshot, subscribePersistMetaSnapshot } from \"../core\";\nimport type { UseBitPersistResult } from \"./types\";\n\nexport function useBitPersist(): UseBitPersistResult {\n const store = useBitStore<any>();\n\n const persistMeta = useSyncExternalStore(\n (cb) => subscribePersistMetaSnapshot(store, cb),\n () => readPersistMetaSnapshot(store),\n () => readPersistMetaSnapshot(store),\n );\n\n const restore = useCallback(async () => {\n return store.restorePersisted();\n }, [store]);\n\n const save = useCallback(async () => {\n await store.forceSave();\n }, [store]);\n\n const clear = useCallback(async () => {\n await store.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 {\n restore,\n save,\n clear,\n meta,\n };\n}\n","import { useCallback, useSyncExternalStore, useRef, useEffect } from \"react\";\nimport { useBitStore } from \"./context\";\nimport {\n BitFieldSnapshot,\n BitPath,\n BitPathValue,\n cleanupRegisteredField,\n createFieldStateSnapshot,\n subscribeFieldState,\n} from \"../core\";\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.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) => subscribeFieldState(store, 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.setField(path, val),\n [store, path],\n );\n\n const setBlur = useCallback(() => store.blurField(path), [store, path]);\n\n return { fieldState, setValue, setBlur, store };\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import{A as D,C as U,D as j,F as I,G as q,c as V,e as M,p as F,s as k,u as C,w,x as A,z as E}from"./chunk-SA47B5OP.js";import{createContext as J,useContext as K}from"react";import{jsx as Q}from"react/jsx-runtime";var H=J(null),pt=({store:t,children:e})=>Q(H.Provider,{value:k(t),children:e}),l=()=>{let t=K(H);if(!t)throw new Error("BitForm hooks devem ser usados dentro de um BitFormProvider");return t};import{useCallback as d,useSyncExternalStore as X,useMemo as L,useRef as Y,useState as W}from"react";function Ft(){let t=l(),[e,r]=W(null),[n,s]=W(null),o=Y(null),u=d(p=>A(t,p),[t]),m=d(()=>{let p=w(t);return o.current&&o.current.isValid===p.isValid&&o.current.isDirty===p.isDirty&&o.current.isSubmitting===p.isSubmitting?o.current:(o.current=p,p)},[t]),S=X(u,m,m),c=L(()=>U(t,{clearSubmissionState:()=>{r(null),s(null)},setSubmissionResult:p=>{s(p)},setSubmissionError:p=>{r(p)}}),[t]),{controller:i,actions:h}=c,x=d(i.submit,[i]),v=d(i.onSubmit,[i]),T=d(i.reset,[i]),a=d(i.getValues,[i]),f=d(i.getErrors,[i]),g=d(i.getTouched,[i]),b=d(i.getDirtyValues,[i]);return{meta:L(()=>({...S,submitError:e,lastResponse:n}),[S,e,n]),getValues:a,getErrors:f,getTouched:g,getDirtyValues:b,submit:x,onSubmit:v,reset:T,...h}}import{useCallback as O,useSyncExternalStore as Z,useMemo as z}from"react";function Tt(t){let e=l(),r=z(()=>I(e,t),[e,t]),n=O(()=>r.readItems(),[r]),s=O(m=>e.subscribePath(t,()=>m()),[e,t]),o=Z(s,n,n);return{fields:z(()=>r.getFields(o),[r,o]),length:o.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}}import{useCallback as y,useSyncExternalStore as _,useRef as $}from"react";function kt(t){let e=l(),r=e.getScopeFields(t),n=$(null),s=y(()=>{let c=e.getStepStatus(t);return n.current&&F(n.current,c)?n.current:(n.current=c,c)},[e,t]),o=y(c=>e.subscribeScopeStatus(t,()=>c()),[e,t]),u=_(o,s,s),m=y(async()=>{let c=await e.validate({scope:t}),i=e.getStepErrors(t);return{valid:c,errors:i}},[e,t]),S=y(()=>e.getStepErrors(t),[e,t]);return{scopeName:t,status:u,errors:u.errors,validate:m,getErrors:S,isValid:!u.hasErrors,isDirty:u.isDirty}}import{useCallback as B,useSyncExternalStore as N,useRef as tt,useState as et}from"react";function Ut(t){let e=l(),[r,n]=et(0),s=t[r]??"",o=tt(null),u=B(()=>{let a=e.getStepStatus(s);return o.current&&F(o.current,a)?o.current:(o.current=a,a)},[e,s]),m=N(B(a=>e.subscribeScopeStatus(s,()=>a()),[e,s]),u,u),S=B(async()=>{let a=await e.validate({scope:s}),f=e.getStepErrors(s);return{valid:a,errors:f}},[e,s]),c=B(()=>e.getStepErrors(s),[e,s]),i=B(async()=>{let a=e.getScopeFields(s);if(e.hasValidationsInProgress(a))return!1;let f=await e.validate({scope:s});if(f)n(g=>Math.min(g+1,t.length-1));else{let g=e.getStepErrors(s),b=Object.keys(g);b.length>0&&e.markFieldsTouched(b)}return f},[e,s,t.length]),h=B(()=>{n(a=>Math.max(a-1,0))},[]),x=B(a=>{n(Math.max(0,Math.min(a-1,t.length-1)))},[t.length]),v=r===0,T=r>=t.length-1;return{step:r+1,stepIndex:r,scope:s,next:i,prev:h,goTo:x,isFirst:v,isLast:T,status:m,errors:m.errors,isValid:!m.hasErrors,isDirty:m.isDirty,validate:S,getErrors:c}}import{useCallback as G,useSyncExternalStore as rt,useRef as st}from"react";function Ot(t){let e=l(),r=st(null),n=G(()=>{let o=M(e.getState().values,t);return r.current!==null&&V(r.current,o)?r.current:(r.current=o,o)},[e,t]),s=G(o=>e.subscribePath(t,()=>o()),[e,t]);return rt(s,n,n)}import{useCallback as R,useMemo as ot,useSyncExternalStore as nt}from"react";function Qt(){let t=l(),e=nt(u=>D(t,u),()=>E(t),()=>E(t)),r=R(async()=>t.restorePersisted(),[t]),n=R(async()=>{await t.forceSave()},[t]),s=R(async()=>{await t.clearPersisted()},[t]),o=ot(()=>({isSaving:e.isSaving,isRestoring:e.isRestoring,error:e.error}),[e]);return{restore:r,save:n,clear:s,meta:o}}import{useCallback as P,useSyncExternalStore as it,useRef as at,useEffect as ut}from"react";function ee(t){let e=l(),r=at(null);ut(()=>()=>q(e,t),[e,t]);let n=P(()=>{let S=e.getFieldState(t),c=C(S,r.current);return r.current=c,c},[e,t]),s=P(S=>j(e,t,()=>S()),[e,t]),o=it(s,n,n),u=P(S=>e.setField(t,S),[e,t]),m=P(()=>e.blurField(t),[e,t]);return{fieldState:o,setValue:u,setBlur:m,store:e}}export{pt as a,l as b,Ft as c,ee as d,Tt as e,kt as f,Ut as g,Ot as h,Qt as i};
2
+ //# sourceMappingURL=chunk-LIYZPSWM.js.map
@@ -0,0 +1 @@
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 { BitFormBindingApi, BitStoreHooksApi } from \"../core\";\nimport { resolveBitStoreForHooks } from \"../core\";\n\nconst BitContext = createContext<BitFormBindingApi<any> | null>(null);\n\nexport const BitFormProvider = ({\n store,\n children,\n}: {\n store: BitStoreHooksApi<any>;\n children: React.ReactNode;\n}) => (\n <BitContext.Provider value={resolveBitStoreForHooks(store)}>\n {children}\n </BitContext.Provider>\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 BitFormBindingApi<T>;\n};\n","import {\n useCallback,\n useSyncExternalStore,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { useBitStore } from \"./context\";\nimport {\n createFrameworkFormBinding,\n readFormMetaSnapshot,\n subscribeFormMetaSnapshot,\n} from \"../core\";\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 {\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","import { useCallback, useSyncExternalStore, useMemo } from \"react\";\nimport { useBitStore } from \"./context\";\nimport { createArrayBindingController, BitArrayPath } from \"../core\";\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 () => createArrayBindingController<TForm, P>(store, path),\n [store, path],\n );\n\n const getSnapshot = useCallback(() => {\n return controller.readItems();\n }, [controller]);\n\n const subscribeArray = useCallback(\n (cb: () => void) => store.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 return {\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}\n","import { useCallback, useSyncExternalStore, useRef } 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 const scopeFields = store.getScopeFields(scopeName);\n\n const lastStatus = useRef<ScopeStatus | null>(null);\n\n const getStatusSnapshot = useCallback(() => {\n const nextStatus = store.getStepStatus(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) => store.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.validate({ scope: scopeName });\n const errors = store.getStepErrors(scopeName);\n return { valid, errors };\n }, [store, scopeName]);\n\n const getErrors = useCallback(() => {\n return store.getStepErrors(scopeName);\n }, [store, scopeName]);\n\n return {\n scopeName,\n status,\n errors: status.errors,\n validate,\n getErrors,\n isValid: !status.hasErrors,\n isDirty: status.isDirty,\n };\n}\n","import { useCallback, useSyncExternalStore, useRef, useState } 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.getStepStatus(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.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.validate({ scope });\n const errors = store.getStepErrors(scope);\n return { valid, errors };\n }, [store, scope]);\n\n const getErrors = useCallback(() => {\n return store.getStepErrors(scope);\n }, [store, scope]);\n\n const next = useCallback(async (): Promise<boolean> => {\n const scopeFields = store.getScopeFields(scope);\n\n if (store.hasValidationsInProgress(scopeFields)) {\n return false;\n }\n\n const valid = await store.validate({ scope });\n if (valid) {\n setStepIndex((s) => Math.min(s + 1, scopeNames.length - 1));\n } else {\n const errors = store.getStepErrors(scope);\n const pathsWithErrors = Object.keys(errors);\n if (pathsWithErrors.length > 0) {\n store.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 {\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","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.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.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 { useBitStore } from \"./context\";\nimport { readPersistMetaSnapshot, subscribePersistMetaSnapshot } from \"../core\";\nimport type { UseBitPersistResult } from \"./types\";\n\nexport function useBitPersist(): UseBitPersistResult {\n const store = useBitStore<any>();\n\n const persistMeta = useSyncExternalStore(\n (cb) => subscribePersistMetaSnapshot(store, cb),\n () => readPersistMetaSnapshot(store),\n () => readPersistMetaSnapshot(store),\n );\n\n const restore = useCallback(async () => {\n return store.restorePersisted();\n }, [store]);\n\n const save = useCallback(async () => {\n await store.forceSave();\n }, [store]);\n\n const clear = useCallback(async () => {\n await store.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 {\n restore,\n save,\n clear,\n meta,\n };\n}\n","import { useCallback, useSyncExternalStore, useRef, useEffect } from \"react\";\nimport { useBitStore } from \"./context\";\nimport {\n BitFieldSnapshot,\n BitPath,\n BitPathValue,\n cleanupRegisteredField,\n createFieldStateSnapshot,\n subscribeFieldState,\n} from \"../core\";\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.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) => subscribeFieldState(store, 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.setField(path, val),\n [store, path],\n );\n\n const setBlur = useCallback(() => store.blurField(path), [store, path]);\n\n return { fieldState, setValue, setBlur, store };\n}\n"],"mappings":"uHAAA,OAAgB,iBAAAA,EAAe,cAAAC,MAAkB,QAa/C,cAAAC,MAAA,oBATF,IAAMC,EAAaC,EAA6C,IAAI,EAEvDC,GAAkB,CAAC,CAC9B,MAAAC,EACA,SAAAC,CACF,IAIEL,EAACC,EAAW,SAAX,CAAoB,MAAOK,EAAwBF,CAAK,EACtD,SAAAC,EACH,EAGWE,EAAc,IAAwB,CACjD,IAAMH,EAAQI,EAAWP,CAAU,EACnC,GAAI,CAACG,EACH,MAAM,IAAI,MACR,6DACF,EACF,OAAOA,CACT,ECzBA,OACE,eAAAK,EACA,wBAAAC,EACA,WAAAC,EACA,UAAAC,EACA,YAAAC,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,EACAI,EACAA,CACF,EAEMK,EAAUC,EACd,IACEC,EAA2BpB,EAAO,CAChC,qBAAsB,IAAM,CAC1BG,EAAe,IAAI,EACnBG,EAAgB,IAAI,CACtB,EACA,oBAAsBe,GAAW,CAC/Bf,EAAgBe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Context","jsx","BitContext","createContext","BitFormProvider","store","children","resolveBitStoreForHooks","useBitStore","useContext","useCallback","useSyncExternalStore","useMemo","useRef","useState","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","useCallback","useSyncExternalStore","useMemo","useBitArray","path","store","useBitStore","controller","useMemo","createArrayBindingController","getSnapshot","useCallback","subscribeArray","cb","data","useSyncExternalStore","useCallback","useSyncExternalStore","useRef","useBitScope","scopeName","store","useBitStore","scopeFields","lastStatus","useRef","getStatusSnapshot","useCallback","nextStatus","isScopeStatusEqual","subscribe","cb","status","useSyncExternalStore","validate","valid","errors","getErrors","useCallback","useSyncExternalStore","useRef","useState","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","useCallback","useSyncExternalStore","useRef","useBitWatch","path","store","useBitStore","lastValue","useRef","getSnapshot","useCallback","value","getDeepValue","valueEqual","subscribe","cb","useSyncExternalStore","useCallback","useMemo","useSyncExternalStore","useBitPersist","store","useBitStore","persistMeta","useSyncExternalStore","cb","subscribePersistMetaSnapshot","readPersistMetaSnapshot","restore","useCallback","save","clear","meta","useMemo","useCallback","useSyncExternalStore","useRef","useEffect","useBitFieldBase","path","store","useBitStore","lastSnapshot","useRef","useEffect","cleanupRegisteredField","getSnapshot","useCallback","nextState","snapshot","createFieldStateSnapshot","subscribe","cb","subscribeFieldState","fieldState","useSyncExternalStore","setValue","val","setBlur"]}
@@ -0,0 +1,2 @@
1
+ function a(n,t,e){return async o=>{if(o){e.setLoading(!0),e.setError(n,void 0);try{let r=await t(o);e.setValue(r.url),e.setUploadKey(r.key),e.setError(n,void 0)}catch(r){let d=r instanceof Error?r.message:"Upload failed";e.setError(n,d)}finally{e.setLoading(!1)}}}}function l(n,t,e){return async()=>{let o=e.getUploadKey();if(o&&t)try{await t(o)}catch(r){let d=r instanceof Error?r.message:"Delete failed";e.setError(n,d);return}e.setValue(null),e.setUploadKey(null),e.setError(n,void 0)}}export{a,l as b};
2
+ //# sourceMappingURL=chunk-O5UPA33R.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/adapters/upload-kernel.ts"],"sourcesContent":["/**\n * Framework-agnostic upload kernel.\n *\n * Encapsulates the side-effect logic for uploading/removing files so that\n * React, Vue, and Angular adapters share a single implementation and only\n * differ in how they wire reactive state.\n */\n\nimport type { BitUploadFn, BitDeleteUploadFn } from \"../types/upload\";\n\nexport interface UploadKernelCallbacks {\n /** Called with `true` when upload starts and `false` when it finishes. */\n setLoading: (loading: boolean) => void;\n /** Set or clear a field-level error message. */\n setError: (path: string, message: string | undefined) => void;\n /** Set the stored file URL after a successful upload (or `null` on remove). */\n setValue: (value: string | null) => void;\n /** Return the key of the last uploaded file (used when deleting). */\n getUploadKey: () => string | null;\n /** Persist the upload key returned by the upload function. */\n setUploadKey: (key: string | null) => void;\n}\n\n/**\n * Creates a type-safe `upload` handler for a field.\n *\n * @example\n * ```ts\n * const upload = createUploadHandler(\"avatar\", myUploadFn, {\n * setLoading: (v) => (isUploading.value = v),\n * setError: (p, m) => store.setError(p, m),\n * setValue: (v) => field.setValue(v),\n * getUploadKey: () => uploadKey,\n * setUploadKey: (k) => (uploadKey = k),\n * });\n * ```\n */\nexport function createUploadHandler(\n fieldPath: string,\n uploadFn: BitUploadFn,\n callbacks: UploadKernelCallbacks,\n): (file: File | null | undefined) => Promise<void> {\n return async (file) => {\n if (!file) return;\n\n callbacks.setLoading(true);\n callbacks.setError(fieldPath, undefined);\n\n try {\n const result = await uploadFn(file);\n\n callbacks.setValue(result.url);\n callbacks.setUploadKey(result.key);\n callbacks.setError(fieldPath, undefined);\n } catch (error) {\n const message = error instanceof Error ? error.message : \"Upload failed\";\n callbacks.setError(fieldPath, message);\n } finally {\n callbacks.setLoading(false);\n }\n };\n}\n\n/**\n * Creates a type-safe `remove` handler for a field.\n */\nexport function createRemoveHandler(\n fieldPath: string,\n deleteFile: BitDeleteUploadFn | undefined,\n callbacks: UploadKernelCallbacks,\n): () => Promise<void> {\n return async () => {\n const uploadKey = callbacks.getUploadKey();\n\n if (uploadKey && deleteFile) {\n try {\n await deleteFile(uploadKey);\n } catch (error) {\n const message =\n error instanceof Error ? error.message : \"Delete failed\";\n callbacks.setError(fieldPath, message);\n return;\n }\n }\n\n callbacks.setValue(null);\n callbacks.setUploadKey(null);\n callbacks.setError(fieldPath, undefined);\n };\n}\n"],"mappings":"AAqCO,SAASA,EACdC,EACAC,EACAC,EACkD,CAClD,MAAO,OAAOC,GAAS,CACrB,GAAKA,EAEL,CAAAD,EAAU,WAAW,EAAI,EACzBA,EAAU,SAASF,EAAW,MAAS,EAEvC,GAAI,CACF,IAAMI,EAAS,MAAMH,EAASE,CAAI,EAElCD,EAAU,SAASE,EAAO,GAAG,EAC7BF,EAAU,aAAaE,EAAO,GAAG,EACjCF,EAAU,SAASF,EAAW,MAAS,CACzC,OAASK,EAAO,CACd,IAAMC,EAAUD,aAAiB,MAAQA,EAAM,QAAU,gBACzDH,EAAU,SAASF,EAAWM,CAAO,CACvC,QAAE,CACAJ,EAAU,WAAW,EAAK,CAC5B,EACF,CACF,CAKO,SAASK,EACdP,EACAQ,EACAN,EACqB,CACrB,MAAO,UAAY,CACjB,IAAMO,EAAYP,EAAU,aAAa,EAEzC,GAAIO,GAAaD,EACf,GAAI,CACF,MAAMA,EAAWC,CAAS,CAC5B,OAASJ,EAAO,CACd,IAAMC,EACJD,aAAiB,MAAQA,EAAM,QAAU,gBAC3CH,EAAU,SAASF,EAAWM,CAAO,EACrC,MACF,CAGFJ,EAAU,SAAS,IAAI,EACvBA,EAAU,aAAa,IAAI,EAC3BA,EAAU,SAASF,EAAW,MAAS,CACzC,CACF","names":["createUploadHandler","fieldPath","uploadFn","callbacks","file","result","error","message","createRemoveHandler","deleteFile","uploadKey"]}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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 _chunkQKGTVKBUcjs = require('./chunk-QKGTVKBU.cjs');var _chunkFUUQB4DVcjs = require('./chunk-FUUQB4DV.cjs');function b(e){if(!e||typeof e!="object")return!1;let o=e;return typeof o.getState=="function"&&typeof o.getHistoryMetadata=="function"}function B(e){if(!b(e))return!1;let o=e;return typeof o.undo=="function"&&typeof o.redo=="function"&&typeof o.reset=="function"}function D(e,o){let t=e[o];return B(t)?t:null}function w(e){return{values:e.values,errors:e.errors,touched:e.touched,isValid:e.isValid,isDirty:e.isDirty,isSubmitting:e.isSubmitting,isValidating:e.isValidating,persist:e.persist}}function I(e){let o=e.getHistoryMetadata();return{...w(e.getState()),_meta:{canUndo:o.canUndo,canRedo:o.canRedo,totalSteps:o.historySize,currentIndex:o.historyIndex}}}function y(e){let o={};for(let[t,i]of Object.entries(e))b(i)&&(o[t]=I(i));return o}var S=null,x=50;function _(e,o=_chunkFUUQB4DVcjs.j){S&&(console.warn("[bit-form] Reiniciando ponte do DevTools (Fast Refresh detectado)."),S());let t=null,i=null,f,n=null,a=new Set,T=!1,d=r=>{_optionalChain([t, 'optionalAccess', _2 => _2.readyState])===WebSocket.OPEN&&t.send(JSON.stringify(r))},R=()=>{if(a.size===0)return;let r=y(Array.from(a).reduce((s,l)=>{let u=o.stores[l];return u&&(s[l]=u),s},{}));a.clear(),n=null,Object.keys(r).length>0&&d({type:"STATE_UPDATE",protocolVersion:1,payload:r})},k=()=>{n||(n=setTimeout(()=>{R()},x))},m=()=>{T=!1,t=new WebSocket(e),t.onopen=()=>{console.log("[bit-form] \u{1F50C} Conectado ao CLI DevTools via WebSocket."),d({type:"HELLO",protocolVersion:1,payload:{role:"server",protocolVersion:1}});let r=y(o.stores);Object.keys(r).length>0&&d({type:"STATE_UPDATE",protocolVersion:1,payload:r}),i=o.subscribe((s,l)=>{a.add(s),k()}),f=setInterval(()=>{d({type:"PING",protocolVersion:1})},3e4)},t.onmessage=r=>{try{let s=JSON.parse(r.data);if(_chunkQKGTVKBUcjs.c.call(void 0, s)){let{storeId:l,action:u}=s.payload,p=D(o.stores,l);if(!p)return;switch(u){case"undo":p.undo();break;case"redo":p.redo();break;case"reset":p.reset();break}}}catch(s){console.warn("[bit-form] Erro ao processar comando do CLI:",s)}},t.onclose=()=>{i&&i(),clearInterval(f),n&&(clearTimeout(n),n=null),a.clear(),T?console.log("[bit-form] Ponte antiga encerrada com sucesso."):(console.log("[bit-form] Conex\xE3o perdida. Reconectando em 3s..."),setTimeout(m,3e3))}};m();let g=()=>{T=!0,i&&i(),clearInterval(f),n&&(clearTimeout(n),n=null),a.clear(),t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING)&&t.close(),S=null};return S=g,g}exports.a = D; exports.b = y; exports.c = _;
2
+ //# sourceMappingURL=chunk-QAL6J5GQ.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/bit-form/bit-form/dist/chunk-QAL6J5GQ.cjs","../src/devtools/store-port.ts","../src/devtools/store-snapshot.ts","../src/devtools/bridge.ts"],"names":["isDevToolsReadableStore","value","candidate","isDevToolsActionableStore","getDevToolsActionableStore","stores","storeId","store","normalizeStoreState","state","createDevToolsStoreSnapshot","historyMeta","createDevToolsSnapshotMap","snapshots","instance","activeBridgeCleanup","STATE_BATCH_INTERVAL_MS","setupRemoteBridge","url","bus","bitBus","socket","unsubscribeBus","heartbeatInterval","batchFlushTimeout","pendingStoreIds","isIntentionalDisconnect","sendWhenOpen","message","flushPendingStoreUpdates","payload","acc","storeInstance","scheduleStoreFlush","connect","initialState","_newState","event","isDevToolsActionMessage","action","e","cleanup"],"mappings":"AAAA,qoBAA+C,wDAAyC,SCexEA,CAAAA,CACdC,CAAAA,CAC2C,CAC3C,EAAA,CAAI,CAACA,CAAAA,EAAS,OAAOA,CAAAA,EAAU,QAAA,CAC7B,MAAO,CAAA,CAAA,CAGT,IAAMC,CAAAA,CAAYD,CAAAA,CAElB,OACE,OAAOC,CAAAA,CAAU,QAAA,EAAa,UAAA,EAC9B,OAAOA,CAAAA,CAAU,kBAAA,EAAuB,UAE5C,CAEO,SAASC,CAAAA,CACdF,CAAAA,CAC6C,CAC7C,EAAA,CAAI,CAACD,CAAAA,CAAwBC,CAAK,CAAA,CAChC,MAAO,CAAA,CAAA,CAGT,IAAMC,CAAAA,CAAYD,CAAAA,CAElB,OACE,OAAOC,CAAAA,CAAU,IAAA,EAAS,UAAA,EAC1B,OAAOA,CAAAA,CAAU,IAAA,EAAS,UAAA,EAC1B,OAAOA,CAAAA,CAAU,KAAA,EAAU,UAE/B,CAEO,SAASE,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CAC2C,CAC3C,IAAMC,CAAAA,CAAQF,CAAAA,CAAOC,CAAO,CAAA,CAC5B,OAAOH,CAAAA,CAA0BI,CAAK,CAAA,CAAIA,CAAAA,CAAQ,IACpD,CChDA,SAASC,CAAAA,CACPC,CAAAA,CACsC,CACtC,MAAO,CACL,MAAA,CAAQA,CAAAA,CAAM,MAAA,CACd,MAAA,CAAQA,CAAAA,CAAM,MAAA,CACd,OAAA,CAASA,CAAAA,CAAM,OAAA,CACf,OAAA,CAASA,CAAAA,CAAM,OAAA,CACf,OAAA,CAASA,CAA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AAAA,CAAAA,CAAsB0B,CAAAA,CAEfA,CACT,CAAA,4CAAA","file":"/home/runner/work/bit-form/bit-form/dist/chunk-QAL6J5GQ.cjs","sourcesContent":[null,"import type { BitHistoryMetadata, BitState } from \"../core\";\n\nexport interface BitDevToolsReadableStore<T extends object = object> {\n getState: () => Readonly<BitState<T>>;\n getHistoryMetadata: () => BitHistoryMetadata;\n}\n\nexport interface BitDevToolsActionableStore<\n T extends object = object,\n> extends BitDevToolsReadableStore<T> {\n undo: () => void;\n redo: () => void;\n reset: () => void;\n}\n\nexport function isDevToolsReadableStore(\n value: unknown,\n): value is BitDevToolsReadableStore<object> {\n if (!value || typeof value !== \"object\") {\n return false;\n }\n\n const candidate = value as unknown as Record<string, unknown>;\n\n return (\n typeof candidate.getState === \"function\" &&\n typeof candidate.getHistoryMetadata === \"function\"\n );\n}\n\nexport function isDevToolsActionableStore(\n value: unknown,\n): value is BitDevToolsActionableStore<object> {\n if (!isDevToolsReadableStore(value)) {\n return false;\n }\n\n const candidate = value as unknown as Record<string, unknown>;\n\n return (\n typeof candidate.undo === \"function\" &&\n typeof candidate.redo === \"function\" &&\n typeof candidate.reset === \"function\"\n );\n}\n\nexport function getDevToolsActionableStore(\n stores: Record<string, unknown>,\n storeId: string,\n): BitDevToolsActionableStore<object> | null {\n const store = stores[storeId];\n return isDevToolsActionableStore(store) ? store : null;\n}\n","import type { BitState } from \"../core\";\nimport type { DevToolsStoreSnapshot, DevToolsStoreSnapshots } from \"./protocol\";\nimport { isDevToolsReadableStore } from \"./store-port\";\n\nfunction normalizeStoreState<T extends object>(\n state: Readonly<BitState<T>>,\n): Omit<DevToolsStoreSnapshot, \"_meta\"> {\n return {\n values: state.values,\n errors: state.errors as Record<string, unknown>,\n touched: state.touched as Record<string, unknown>,\n isValid: state.isValid,\n isDirty: state.isDirty,\n isSubmitting: state.isSubmitting,\n isValidating: state.isValidating as Record<string, unknown>,\n persist: state.persist,\n };\n}\n\nexport function createDevToolsStoreSnapshot<T extends object>(store: {\n getState: () => Readonly<BitState<T>>;\n getHistoryMetadata: () => {\n canUndo: boolean;\n canRedo: boolean;\n historySize: number;\n historyIndex: number;\n };\n}): DevToolsStoreSnapshot {\n const historyMeta = store.getHistoryMetadata();\n\n return {\n ...normalizeStoreState(store.getState()),\n _meta: {\n canUndo: historyMeta.canUndo,\n canRedo: historyMeta.canRedo,\n totalSteps: historyMeta.historySize,\n currentIndex: historyMeta.historyIndex,\n },\n };\n}\n\nexport function createDevToolsSnapshotMap(\n stores: Record<string, unknown>,\n): DevToolsStoreSnapshots {\n const snapshots: DevToolsStoreSnapshots = {};\n\n for (const [storeId, instance] of Object.entries(stores)) {\n if (!isDevToolsReadableStore(instance)) {\n continue;\n }\n\n snapshots[storeId] = createDevToolsStoreSnapshot(instance);\n }\n\n return snapshots;\n}\n","import { bitBus } from \"../core\";\nimport type { BitBus } from \"../core\";\nimport { DEVTOOLS_PROTOCOL_VERSION, isDevToolsActionMessage } from \"./protocol\";\nimport { createDevToolsSnapshotMap } from \"./store-snapshot\";\nimport { getDevToolsActionableStore } from \"./store-port\";\n\nlet activeBridgeCleanup: (() => void) | null = null;\nconst STATE_BATCH_INTERVAL_MS = 50;\n\nexport function setupRemoteBridge(url: string, bus: BitBus = bitBus) {\n if (activeBridgeCleanup) {\n console.warn(\n \"[bit-form] Reiniciando ponte do DevTools (Fast Refresh detectado).\",\n );\n activeBridgeCleanup();\n }\n\n let socket: WebSocket | null = null;\n let unsubscribeBus: (() => void) | null = null;\n let heartbeatInterval: ReturnType<typeof setInterval>;\n let batchFlushTimeout: ReturnType<typeof setTimeout> | null = null;\n const pendingStoreIds = new Set<string>();\n let isIntentionalDisconnect = false;\n\n const sendWhenOpen = (message: Record<string, unknown>) => {\n if (socket?.readyState !== WebSocket.OPEN) {\n return;\n }\n\n socket.send(JSON.stringify(message));\n };\n\n const flushPendingStoreUpdates = () => {\n if (pendingStoreIds.size === 0) {\n return;\n }\n\n const payload = createDevToolsSnapshotMap(\n Array.from(pendingStoreIds).reduce<Record<string, unknown>>(\n (acc, storeId) => {\n const storeInstance = bus.stores[storeId];\n if (storeInstance) {\n acc[storeId] = storeInstance;\n }\n return acc;\n },\n {},\n ),\n );\n\n pendingStoreIds.clear();\n batchFlushTimeout = null;\n\n if (Object.keys(payload).length > 0) {\n sendWhenOpen({\n type: \"STATE_UPDATE\",\n protocolVersion: DEVTOOLS_PROTOCOL_VERSION,\n payload,\n });\n }\n };\n\n const scheduleStoreFlush = () => {\n if (batchFlushTimeout) {\n return;\n }\n\n batchFlushTimeout = setTimeout(() => {\n flushPendingStoreUpdates();\n }, STATE_BATCH_INTERVAL_MS);\n };\n\n const connect = () => {\n isIntentionalDisconnect = false;\n socket = new WebSocket(url);\n\n socket.onopen = () => {\n console.log(\"[bit-form] 🔌 Conectado ao CLI DevTools via WebSocket.\");\n\n sendWhenOpen({\n type: \"HELLO\",\n protocolVersion: DEVTOOLS_PROTOCOL_VERSION,\n payload: { role: \"server\", protocolVersion: DEVTOOLS_PROTOCOL_VERSION },\n });\n\n const initialState = createDevToolsSnapshotMap(bus.stores);\n if (Object.keys(initialState).length > 0) {\n sendWhenOpen({\n type: \"STATE_UPDATE\",\n protocolVersion: DEVTOOLS_PROTOCOL_VERSION,\n payload: initialState,\n });\n }\n\n unsubscribeBus = bus.subscribe((storeId, _newState) => {\n pendingStoreIds.add(storeId);\n scheduleStoreFlush();\n });\n\n heartbeatInterval = setInterval(() => {\n sendWhenOpen({\n type: \"PING\",\n protocolVersion: DEVTOOLS_PROTOCOL_VERSION,\n });\n }, 30000);\n };\n\n socket.onmessage = (event) => {\n try {\n const message = JSON.parse(event.data) as unknown;\n\n if (isDevToolsActionMessage(message)) {\n const { storeId, action } = message.payload;\n const store = getDevToolsActionableStore(bus.stores, storeId);\n\n if (!store) {\n return;\n }\n\n switch (action) {\n case \"undo\":\n store.undo();\n break;\n case \"redo\":\n store.redo();\n break;\n case \"reset\":\n store.reset();\n break;\n }\n }\n } catch (e) {\n console.warn(\"[bit-form] Erro ao processar comando do CLI:\", e);\n }\n };\n\n socket.onclose = () => {\n if (unsubscribeBus) unsubscribeBus();\n clearInterval(heartbeatInterval);\n if (batchFlushTimeout) {\n clearTimeout(batchFlushTimeout);\n batchFlushTimeout = null;\n }\n pendingStoreIds.clear();\n\n if (!isIntentionalDisconnect) {\n console.log(\"[bit-form] Conexão perdida. Reconectando em 3s...\");\n setTimeout(connect, 3000);\n } else {\n console.log(\"[bit-form] Ponte antiga encerrada com sucesso.\");\n }\n };\n };\n\n connect();\n\n const cleanup = () => {\n isIntentionalDisconnect = true;\n\n if (unsubscribeBus) unsubscribeBus();\n clearInterval(heartbeatInterval);\n if (batchFlushTimeout) {\n clearTimeout(batchFlushTimeout);\n batchFlushTimeout = null;\n }\n pendingStoreIds.clear();\n if (\n socket &&\n (socket.readyState === WebSocket.OPEN ||\n socket.readyState === WebSocket.CONNECTING)\n ) {\n socket.close();\n }\n activeBridgeCleanup = null;\n };\n\n activeBridgeCleanup = cleanup;\n\n return cleanup;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var r=1;function n(o){return o.protocolVersion===1}function s(o){if(!o||typeof o!="object")return!1;let e=o;return typeof e.storeId=="string"&&(e.action==="undo"||e.action==="redo"||e.action==="reset")}function a(o){if(!o||typeof o!="object")return!1;let e=o;return e.type==="ACTION"&&n(e)&&s(e.payload)}function l(o){if(!o||typeof o!="object")return!1;let e=o;return e.type==="STATE_UPDATE"&&n(e)}function i(o){if(!o||typeof o!="object")return!1;let e=o;return e.type==="PING"&&n(e)}function c(o){if(!o||typeof o!="object")return!1;let e=o;if(e.type!=="HELLO"||!e.payload||!n(e))return!1;let t=e.payload;return(t.role==="client"||t.role==="server")&&t.protocolVersion===1}exports.a = r; exports.b = s; exports.c = a; exports.d = l; exports.e = i; exports.f = c;
2
+ //# sourceMappingURL=chunk-QKGTVKBU.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/devtools/protocol.ts"],"names":["DEVTOOLS_PROTOCOL_VERSION","hasSupportedProtocolVersion","candidate","isDevToolsActionPayload","payload","isDevToolsActionMessage","message","isDevToolsStateUpdateMessage","isDevToolsPingMessage","isDevToolsHelloMessage"],"mappings":"AAEO,6EAAMA,CAAAA,CAA4B,CAAA,CA8DzC,SAASC,CAAAA,CAA4BC,CAAAA,CAA0C,CAC7E,OAAOA,CAAAA,CAAU,eAAA,GAAoB,CACvC,CAEO,SAASC,CAAAA,CACdC,CAAAA,CACkC,CAClC,EAAA,CAAI,CAACA,CAAAA,EAAW,OAAOA,CAAAA,EAAY,QAAA,CACjC,MAAO,CAAA,CAAA,CAGT,IAAMF,CAAAA,CAAYE,CAAAA,CAKlB,OACE,OAAOF,CAAAA,CAAU,OAAA,EAAY,QAAA,EAAA,CAC5BA,CAAAA,CAAU,MAAA,GAAW,MAAA,EACpBA,CAAAA,CAAU,MAAA,GAAW,MAAA,EACrBA,CAAAA,CAAU,MAAA,GAAW,OAAA,CAE3B,CAEO,SAASG,CAAAA,CACdC,CAAAA,CACkC,CAClC,EAAA,CAAI,CAACA,CAAAA,EAAW,OAAOA,CAAAA,EAAY,QAAA,CACjC,MAAO,CAAA,CAAA,CAGT,IAAMJ,CAAAA,CAAYI,CAAAA,CAMlB,OACEJ,CAAAA,CAAU,IAAA,GAAS,QAAA,EACnBD,CAAAA,CAA4BC,CAAS,CAAA,EACrCC,CAAAA,CAAwBD,CAAAA,CAAU,OAAO,CAE7C,CAEO,SAASK,CAAAA,CACdD,CAAAA,CACuC,CACvC,EAAA,CAAI,CAACA,CAAAA,EAAW,OAAOA,CAAAA,EAAY,QAAA,CACjC,MAAO,CAAA,CAAA,CAGT,IAAMJ,CAAAA,CAAYI,CAAAA,CAKlB,OACEJ,CAAAA,CAAU,IAAA,GAAS,cAAA,EAAkBD,CAAAA,CAA4BC,CAAS,CAE9E,CAEO,SAASM,CAAAA,CACdF,CAAAA,CACgC,CAChC,EAAA,CAAI,CAACA,CAAAA,EAAW,OAAOA,CAAAA,EAAY,QAAA,CACjC,MAAO,CAAA,CAAA,CAGT,IAAMJ,CAAAA,CAAYI,CAAAA,CAKlB,OAAOJ,CAAAA,CAAU,IAAA,GAAS,MAAA,EAAUD,CAAAA,CAA4BC,CAAS,CAC3E,CAEO,SAASO,CAAAA,CACdH,CAAAA,CACiC,CACjC,EAAA,CAAI,CAACA,CAAAA,EAAW,OAAOA,CAAAA,EAAY,QAAA,CACjC,MAAO,CAAA,CAAA,CAGT,IAAMJ,CAAAA,CAAYI,CAAAA,CAMlB,EAAA,CACEJ,CAAAA,CAAU,IAAA,GAAS,OAAA,EACnB,CAACA,CAAAA,CAAU,OAAA,EACX,CAACD,CAAAA,CAA4BC,CAAS,CAAA,CAEtC,MAAO,CAAA,CAAA,CAGT,IAAME,CAAAA,CAAUF,CAAAA,CAAU,OAAA,CAK1B,MAAA,CACGE,CAAAA,CAAQ,IAAA,GAAS,QAAA,EAAYA,CAAAA,CAAQ,IAAA,GAAS,QAAA,CAAA,EAC/CA,CAAAA,CAAQ,eAAA,GAAoB,CAEhC,CAAA,yFAAA","file":"/home/runner/work/bit-form/bit-form/dist/chunk-QKGTVKBU.cjs","sourcesContent":["export type DevToolsActionName = \"undo\" | \"redo\" | \"reset\";\n\nexport const DEVTOOLS_PROTOCOL_VERSION = 1;\n\nexport interface DevToolsProtocolMessageBase {\n protocolVersion: number;\n}\n\nexport interface DevToolsHistoryMeta {\n canUndo: boolean;\n canRedo: boolean;\n totalSteps: number;\n currentIndex: number;\n}\n\nexport interface DevToolsStoreSnapshot {\n values: unknown;\n errors: Record<string, unknown>;\n touched: Record<string, unknown>;\n isValid: boolean;\n isDirty: boolean;\n isSubmitting: boolean;\n isValidating?: Record<string, unknown>;\n persist?: unknown;\n _meta: DevToolsHistoryMeta;\n}\n\nexport type DevToolsStoreSnapshots = Record<string, DevToolsStoreSnapshot>;\n\nexport interface DevToolsActionPayload {\n storeId: string;\n action: DevToolsActionName;\n}\n\nexport interface DevToolsStateUpdateMessage extends DevToolsProtocolMessageBase {\n type: \"STATE_UPDATE\";\n payload: DevToolsStoreSnapshots;\n}\n\nexport interface DevToolsPingMessage extends DevToolsProtocolMessageBase {\n type: \"PING\";\n}\n\nexport interface DevToolsActionMessage extends DevToolsProtocolMessageBase {\n type: \"ACTION\";\n payload: DevToolsActionPayload;\n}\n\nexport interface DevToolsHelloPayload {\n role: \"client\" | \"server\";\n protocolVersion: number;\n}\n\nexport interface DevToolsHelloMessage extends DevToolsProtocolMessageBase {\n type: \"HELLO\";\n payload: DevToolsHelloPayload;\n}\n\nexport type DevToolsRemoteMessage =\n | DevToolsStateUpdateMessage\n | DevToolsPingMessage\n | DevToolsActionMessage\n | DevToolsHelloMessage;\n\nfunction hasSupportedProtocolVersion(candidate: { protocolVersion?: unknown }) {\n return candidate.protocolVersion === DEVTOOLS_PROTOCOL_VERSION;\n}\n\nexport function isDevToolsActionPayload(\n payload: unknown,\n): payload is DevToolsActionPayload {\n if (!payload || typeof payload !== \"object\") {\n return false;\n }\n\n const candidate = payload as {\n storeId?: unknown;\n action?: unknown;\n };\n\n return (\n typeof candidate.storeId === \"string\" &&\n (candidate.action === \"undo\" ||\n candidate.action === \"redo\" ||\n candidate.action === \"reset\")\n );\n}\n\nexport function isDevToolsActionMessage(\n message: unknown,\n): message is DevToolsActionMessage {\n if (!message || typeof message !== \"object\") {\n return false;\n }\n\n const candidate = message as {\n type?: unknown;\n payload?: unknown;\n protocolVersion?: unknown;\n };\n\n return (\n candidate.type === \"ACTION\" &&\n hasSupportedProtocolVersion(candidate) &&\n isDevToolsActionPayload(candidate.payload)\n );\n}\n\nexport function isDevToolsStateUpdateMessage(\n message: unknown,\n): message is DevToolsStateUpdateMessage {\n if (!message || typeof message !== \"object\") {\n return false;\n }\n\n const candidate = message as {\n type?: unknown;\n protocolVersion?: unknown;\n };\n\n return (\n candidate.type === \"STATE_UPDATE\" && hasSupportedProtocolVersion(candidate)\n );\n}\n\nexport function isDevToolsPingMessage(\n message: unknown,\n): message is DevToolsPingMessage {\n if (!message || typeof message !== \"object\") {\n return false;\n }\n\n const candidate = message as {\n type?: unknown;\n protocolVersion?: unknown;\n };\n\n return candidate.type === \"PING\" && hasSupportedProtocolVersion(candidate);\n}\n\nexport function isDevToolsHelloMessage(\n message: unknown,\n): message is DevToolsHelloMessage {\n if (!message || typeof message !== \"object\") {\n return false;\n }\n\n const candidate = message as {\n type?: unknown;\n payload?: unknown;\n protocolVersion?: unknown;\n };\n\n if (\n candidate.type !== \"HELLO\" ||\n !candidate.payload ||\n !hasSupportedProtocolVersion(candidate)\n ) {\n return false;\n }\n\n const payload = candidate.payload as {\n role?: unknown;\n protocolVersion?: unknown;\n };\n\n return (\n (payload.role === \"client\" || payload.role === \"server\") &&\n payload.protocolVersion === DEVTOOLS_PROTOCOL_VERSION\n );\n}\n"]}