@lehnihon/bit-form 2.2.18 → 2.2.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/angular/index.cjs +1 -1
- package/dist/angular/index.js +1 -1
- package/dist/angular/index.js.map +1 -1
- package/dist/chunk-23DHXQOC.js +2 -0
- package/dist/chunk-23DHXQOC.js.map +1 -0
- package/dist/{chunk-DD6XWUMR.cjs → chunk-27LJCW56.cjs} +2 -2
- package/dist/chunk-27LJCW56.cjs.map +1 -0
- package/dist/chunk-32RH5MSM.js +2 -0
- package/dist/chunk-32RH5MSM.js.map +1 -0
- package/dist/{chunk-P5YQ62YN.cjs → chunk-33TGLA5D.cjs} +2 -2
- package/dist/{chunk-P5YQ62YN.cjs.map → chunk-33TGLA5D.cjs.map} +1 -1
- package/dist/chunk-3CPIJF3Z.cjs +2 -0
- package/dist/chunk-3CPIJF3Z.cjs.map +1 -0
- package/dist/{chunk-SYEUXL2E.js → chunk-3WNZPBME.js} +2 -2
- package/dist/chunk-4WPLTOBT.cjs +2 -0
- package/dist/chunk-4WPLTOBT.cjs.map +1 -0
- package/dist/chunk-5ILGCBKG.cjs +2 -0
- package/dist/chunk-5ILGCBKG.cjs.map +1 -0
- package/dist/chunk-725CMNAV.cjs +2 -0
- package/dist/chunk-725CMNAV.cjs.map +1 -0
- package/dist/{chunk-GKNGJOB3.cjs → chunk-7IO2KLSJ.cjs} +2 -2
- package/dist/{chunk-GKNGJOB3.cjs.map → chunk-7IO2KLSJ.cjs.map} +1 -1
- package/dist/{chunk-HE6EQZTH.js → chunk-AJUX7LYB.js} +2 -2
- package/dist/chunk-B45EMB4Q.js +2 -0
- package/dist/chunk-B45EMB4Q.js.map +1 -0
- package/dist/chunk-CIS3YZSK.cjs +2 -0
- package/dist/chunk-CIS3YZSK.cjs.map +1 -0
- package/dist/chunk-DGEGYNQL.js +2 -0
- package/dist/{chunk-3NUJVIAM.js.map → chunk-DGEGYNQL.js.map} +1 -1
- package/dist/{chunk-AVUK52JW.cjs → chunk-EPBSLPRL.cjs} +2 -2
- package/dist/{chunk-AVUK52JW.cjs.map → chunk-EPBSLPRL.cjs.map} +1 -1
- package/dist/chunk-HTMNDK6W.js +2 -0
- package/dist/chunk-HTMNDK6W.js.map +1 -0
- package/dist/chunk-JUDBIEZK.js +2 -0
- package/dist/chunk-JUDBIEZK.js.map +1 -0
- package/dist/{chunk-77PK7U73.cjs → chunk-K2JSAJAF.cjs} +2 -2
- package/dist/chunk-K2JSAJAF.cjs.map +1 -0
- package/dist/chunk-K2KCQEER.js +2 -0
- package/dist/chunk-K2KCQEER.js.map +1 -0
- package/dist/chunk-K65TKDQ2.cjs +2 -0
- package/dist/chunk-K65TKDQ2.cjs.map +1 -0
- package/dist/chunk-S5A65JVL.cjs +2 -0
- package/dist/chunk-S5A65JVL.cjs.map +1 -0
- package/dist/chunk-SFVGMVIE.js +2 -0
- package/dist/chunk-SFVGMVIE.js.map +1 -0
- package/dist/chunk-T7TOEIOH.js +2 -0
- package/dist/chunk-T7TOEIOH.js.map +1 -0
- package/dist/chunk-TLUCO2ZN.cjs +2 -0
- package/dist/chunk-TLUCO2ZN.cjs.map +1 -0
- package/dist/chunk-WEZ5Q6YO.js +2 -0
- package/dist/chunk-WEZ5Q6YO.js.map +1 -0
- package/dist/{chunk-YO4TZ6N6.js → chunk-Y34N5TWV.js} +2 -2
- package/dist/cli/index.cjs +5 -5
- package/dist/core/bindings.cjs +1 -1
- package/dist/core/bindings.js +1 -1
- package/dist/core/store.cjs +1 -1
- package/dist/core/store.js +1 -1
- package/dist/core/utils.cjs +1 -1
- package/dist/core/utils.js +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/devtools/bridge.cjs +1 -1
- package/dist/devtools/bridge.js +1 -1
- package/dist/devtools/index.cjs +10 -10
- package/dist/devtools/index.cjs.map +1 -1
- package/dist/devtools/index.js +10 -10
- package/dist/devtools/index.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/mask.cjs +1 -1
- package/dist/mask.js +1 -1
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react-native/index.cjs +1 -1
- package/dist/react-native/index.cjs.map +1 -1
- package/dist/react-native/index.js +1 -1
- package/dist/react-native/index.js.map +1 -1
- package/dist/resolvers/index.cjs +1 -1
- package/dist/resolvers/index.js +1 -1
- package/dist/resolvers/joi.cjs +1 -1
- package/dist/resolvers/joi.js +1 -1
- package/dist/resolvers/yup.cjs +1 -1
- package/dist/resolvers/yup.js +1 -1
- package/dist/resolvers/zod.cjs +1 -1
- package/dist/resolvers/zod.js +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +1 -1
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.d.cts +18 -17
- package/dist/vue/index.d.ts +18 -17
- package/dist/vue/index.js +1 -1
- package/dist/vue/index.js.map +1 -1
- package/package.json +7 -6
- package/dist/chunk-3774TIGK.js +0 -2
- package/dist/chunk-3774TIGK.js.map +0 -1
- package/dist/chunk-3NUJVIAM.js +0 -2
- package/dist/chunk-77PK7U73.cjs.map +0 -1
- package/dist/chunk-CTURHI75.cjs +0 -2
- package/dist/chunk-CTURHI75.cjs.map +0 -1
- package/dist/chunk-DD6XWUMR.cjs.map +0 -1
- package/dist/chunk-FGJB4DHQ.js +0 -2
- package/dist/chunk-FGJB4DHQ.js.map +0 -1
- package/dist/chunk-FTXV2NZO.cjs +0 -2
- package/dist/chunk-FTXV2NZO.cjs.map +0 -1
- package/dist/chunk-G3EHXKOS.js +0 -2
- package/dist/chunk-G3EHXKOS.js.map +0 -1
- package/dist/chunk-GDRNKTHO.js +0 -2
- package/dist/chunk-GDRNKTHO.js.map +0 -1
- package/dist/chunk-GSZTHF7Z.js +0 -2
- package/dist/chunk-GSZTHF7Z.js.map +0 -1
- package/dist/chunk-GUU6EXFN.js +0 -2
- package/dist/chunk-GUU6EXFN.js.map +0 -1
- package/dist/chunk-L7EAZ6K6.cjs +0 -2
- package/dist/chunk-L7EAZ6K6.cjs.map +0 -1
- package/dist/chunk-LIHWJJIM.js +0 -2
- package/dist/chunk-LIHWJJIM.js.map +0 -1
- package/dist/chunk-M2XR4C7T.js +0 -2
- package/dist/chunk-M2XR4C7T.js.map +0 -1
- package/dist/chunk-PFPGASVZ.cjs +0 -2
- package/dist/chunk-PFPGASVZ.cjs.map +0 -1
- package/dist/chunk-QCKCONCU.js +0 -2
- package/dist/chunk-QCKCONCU.js.map +0 -1
- package/dist/chunk-RSH6LQVC.cjs +0 -2
- package/dist/chunk-RSH6LQVC.cjs.map +0 -1
- package/dist/chunk-U5TBWV74.cjs +0 -2
- package/dist/chunk-U5TBWV74.cjs.map +0 -1
- package/dist/chunk-UT63HKR6.cjs +0 -2
- package/dist/chunk-UT63HKR6.cjs.map +0 -1
- package/dist/chunk-WRNR6SXK.cjs +0 -2
- package/dist/chunk-WRNR6SXK.cjs.map +0 -1
- /package/dist/{chunk-SYEUXL2E.js.map → chunk-3WNZPBME.js.map} +0 -0
- /package/dist/{chunk-HE6EQZTH.js.map → chunk-AJUX7LYB.js.map} +0 -0
- /package/dist/{chunk-YO4TZ6N6.js.map → chunk-Y34N5TWV.js.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{f as c}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{f as c}from"./chunk-T7TOEIOH.js";import{b as u,c as d}from"./chunk-DGEGYNQL.js";function m(e){let t=e.read.getState();return{isValid:t.isValid,isDirty:t.isDirty,isSubmitting:t.isSubmitting}}function f(e,t){return e.observe.subscribeFormMeta(()=>t())}function g(e,t){return t(m(e)),f(e,()=>{t(m(e))})}function B(e){return e.read.getPersistMetadata()}function v(e,t){return e.observe.subscribePersistMeta(()=>t())}function x(e,t){return t(B(e)),e.observe.subscribePersistMeta(o=>{t(o)})}function M(e,t){let o=!1,a=r=>Array.isArray(r)?r:r==null?[]:((!(typeof process<"u")||process.env.NODE_ENV!=="production")&&!o&&(o=!0,console.warn(`[bit-form] createArrayBinding expected an array at path "${String(t)}" but received ${typeof r}. Returning an empty array.`)),[]),p=r=>e.feature.getArrayItemIds(t,r);return{readItems(){let r=c(e.read.getState().values,t);return a(r)},getFields(r){let i=p(r.length);return r.map((s,n)=>({key:i[n]||`temp-${n}`,value:s,index:n}))},append(r){e.feature.pushItem(t,r)},prepend(r){e.feature.prependItem(t,r)},insert(r,i){e.feature.insertItem(t,r,i)},remove(r){e.feature.removeItem(t,r)},move(r,i){e.feature.moveItem(t,r,i)},swap(r,i){e.feature.swapItems(t,r,i)},replace(r){e.feature.replaceItems(t,r)},clear(){e.feature.clearItems(t)}}}function b(e,t,o){return{setValue:i=>{let s=o();e.setField(t,d(i,s))},setBlur:()=>e.blurField(t),displayValue:i=>u(i,o())}}function w(e,t){return{fieldController:b({setField(a,p){e.write.setField(a,p)},blurField(a){e.write.blurField(a)}},t,()=>e.feature.resolveMask(t))}}function F(e,t){e?.preventDefault?.(),t?.stopPropagation&&e?.stopPropagation?.()}function y(e,t,o){return{submit:i=>async s=>{F(s,o),await e.submit(i)},onSubmit:i=>async s=>{F(s,o),t.setSubmissionError(null);let n,l=await e.submit(async(P,S)=>{n=await i(P,S)});if(l.status==="submitted"){t.setSubmissionResult(n),t.setSubmissionError(null);return}l.status==="failed"&&t.setSubmissionError(l.error instanceof Error?l.error:new Error(String(l.error)))},reset:()=>{e.reset(),t.clearSubmissionState()},getValues:()=>e.getState().values,getErrors:()=>e.getState().errors,getTouched:()=>e.getState().touched,getDirtyValues:()=>e.getDirtyValues()}}function T(e,t,o){let a={getState:e.read.getState,getDirtyValues:e.read.getDirtyValues,submit:e.write.submit,reset:e.write.reset,setServerErrors:e.write.setServerErrors};return{controller:y(a,t,o),actions:{setField:e.write.setField.bind(e.write),blurField:e.write.blurField.bind(e.write),setValues:e.write.setValues.bind(e.write),setError:e.write.setError.bind(e.write),setErrors:e.write.setErrors.bind(e.write),setServerErrors:e.write.setServerErrors.bind(e.write),validate:e.feature.validate.bind(e.feature),transaction:e.write.transaction.bind(e.write)}}}function A(e,t){e.feature?.unregisterField?.(t)}function k(e,t){e.feature?.unregisterPrefix?.(t)}export{m as a,f as b,g as c,B as d,v as e,x as f,M as g,w as h,T as i,A as j,k};
|
|
2
|
+
//# sourceMappingURL=chunk-3WNZPBME.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});function s(r){return r.replace(/\[(\d+)\]/g,".$1").replace(/^\.+/,"").replace(/\.{2,}/g,".")}function a(r,t){return r===t||r.startsWith(`${t}.`)||t.startsWith(`${r}.`)}function l(r,t,n){let e=s(t);!e||!n||e==="__proto__"||e==="constructor"||e==="prototype"||r[e]||(r[e]=n)}function p(r,t){if(!t||t.length===0)return r;let n=t.map(o=>s(o)).filter(o=>o.length>0);if(n.length===0)return{};let e={};for(let[o,f]of Object.entries(r)){let c=s(o);if(f&&n.some(i=>a(c,i))){let i=o;e[i]=f}}return e}exports.a = s; exports.b = l; exports.c = p;
|
|
2
|
+
//# sourceMappingURL=chunk-4WPLTOBT.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/resolvers/utils.ts"],"names":["normalizeErrorPath","path","matchScopePath","errorPath","scopePath"],"mappings":"AAEO,kFAASA,CAAAA,CAAmBC,CAAAA,CAAsB,CACvD,OAAOA,CAAAA,CACJ,OAAA,CAAQ,YAAA,CAAc,KAAK,CAAA,CAC3B,OAAA,CAAQ,MAAA,CAAQ,EAAE,CAAA,CAClB,OAAA,CAAQ,SAAA,CAAW,GAAG,CAC3B,CAEA,SAASC,CAAAA,CAAeC,CAAAA,CAAmBC,CAAAA,CAA4B,CACrE,OACED,CAAAA,GAAcC,CAAAA,EACdD,CAAAA,CAAU,UAAA,CAAW,CAAA,EAAA","file":"/home/runner/work/bit-form/bit-form/dist/chunk-4WPLTOBT.cjs","sourcesContent":["import { BitErrors } from \"../core\";\n\nexport function normalizeErrorPath(path: string): string {\n return path\n .replace(/\\[(\\d+)\\]/g, \".$1\")\n .replace(/^\\.+/, \"\")\n .replace(/\\.{2,}/g, \".\");\n}\n\nfunction matchScopePath(errorPath: string, scopePath: string): boolean {\n return (\n errorPath === scopePath ||\n errorPath.startsWith(`${scopePath}.`) ||\n scopePath.startsWith(`${errorPath}.`)\n );\n}\n\nexport function setFirstError<T extends object>(\n errors: BitErrors<T>,\n path: string,\n message: string | undefined,\n) {\n const normalizedPath = normalizeErrorPath(path);\n\n if (!normalizedPath || !message) {\n return;\n }\n\n if (\n normalizedPath === \"__proto__\" ||\n normalizedPath === \"constructor\" ||\n normalizedPath === \"prototype\"\n ) {\n return;\n }\n\n if (!errors[normalizedPath as keyof BitErrors<T>]) {\n errors[normalizedPath as keyof BitErrors<T>] = message;\n }\n}\n\nexport function filterErrorsByScope<T extends object>(\n errors: BitErrors<T>,\n scopeFields?: string[],\n): BitErrors<T> {\n if (!scopeFields || scopeFields.length === 0) {\n return errors;\n }\n\n const normalizedScopeFields = scopeFields\n .map((scopeField) => normalizeErrorPath(scopeField))\n .filter((scopeField) => scopeField.length > 0);\n\n if (normalizedScopeFields.length === 0) {\n return {};\n }\n\n const filtered: BitErrors<T> = {};\n\n for (const [key, message] of Object.entries(errors)) {\n const normalizedKey = normalizeErrorPath(key);\n if (\n message &&\n normalizedScopeFields.some((scopeField) =>\n matchScopePath(normalizedKey, scopeField),\n )\n ) {\n const typedKey = key as keyof BitErrors<T>;\n filtered[typedKey] = message as BitErrors<T>[typeof typedKey];\n }\n }\n\n return filtered;\n}\n"]}
|
|
@@ -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 _chunk4WPLTOBTcjs = require('./chunk-4WPLTOBT.cjs');var _yup = require('yup');var y=(l,s)=>async(p,o)=>{let e={};if(_optionalChain([o, 'optionalAccess', _ => _.scopeFields])&&o.scopeFields.length>0)return await Promise.all(o.scopeFields.map(async t=>{try{await l.validateAt(t,p,{abortEarly:_nullishCoalesce(_optionalChain([s, 'optionalAccess', _2 => _2.abortEarly]), () => (!1))})}catch(r){if(r instanceof _yup.ValidationError)if(r.inner&&r.inner.length>0)for(let n of r.inner)n.path&&_chunk4WPLTOBTcjs.b.call(void 0, e,_chunk4WPLTOBTcjs.a.call(void 0, n.path),n.message);else r.path&&_chunk4WPLTOBTcjs.b.call(void 0, e,_chunk4WPLTOBTcjs.a.call(void 0, r.path),r.message);else throw r}})),e;try{return await l.validate(p,{abortEarly:_nullishCoalesce(_optionalChain([s, 'optionalAccess', _3 => _3.abortEarly]), () => (!1)),stripUnknown:_nullishCoalesce(_optionalChain([s, 'optionalAccess', _4 => _4.stripUnknown]), () => (!1))}),{}}catch(t){if(t instanceof _yup.ValidationError){for(let r of _nullishCoalesce(t.inner, () => ([])))r.path&&_chunk4WPLTOBTcjs.b.call(void 0, e,_chunk4WPLTOBTcjs.a.call(void 0, r.path),r.message);return _chunk4WPLTOBTcjs.c.call(void 0, e,_optionalChain([o, 'optionalAccess', _5 => _5.scopeFields]))}throw t}};exports.a = y;
|
|
2
|
+
//# sourceMappingURL=chunk-5ILGCBKG.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bit-form/bit-form/dist/chunk-5ILGCBKG.cjs","../src/resolvers/yup.ts"],"names":["yupResolver","schema","config","values","options","errors","field","error","ValidationError","item","setFirstError","normalizeErrorPath","filterErrorsByScope"],"mappings":"AAAA,yuBAAsD,0BCAd,IAS3BA,CAAAA,CAAc,CACzBC,CAAAA,CACAC,CAAAA,CAAAA,EAEO,KAAA,CACLC,CAAAA,CACAC,CAAAA,CAAAA,EAC0B,CAC1B,IAAMC,CAAAA,CAAuB,CAAC,CAAA,CAE9B,EAAA,iBAAID,CAAAA,2BAAS,aAAA,EAAeA,CAAAA,CAAQ,WAAA,CAAY,MAAA,CAAS,CAAA,CACvD,OAAA,MAAM,OAAA,CAAQ,GAAA,CACZA,CAAAA,CAAQ,WAAA,CAAY,GAAA,CAAI,MAAOE,CAAAA,EAAU,CACvC,GAAI,CACF,MAAML,CAAAA,CAAO,UAAA,CAAWK,CAAAA,CAAOH,CAAAA,CAAQ,CACrC,UAAA,kCAAYD,CAAAA,6BAAQ,YAAA,SAAc,CAAA,GACpC,CAAC,CACH,CAAA,KAAA,CAASK,CAAAA,CAAgB,CACvB,EAAA,CAAIA,EAAAA,WAAiBC,oBAAAA,CACnB,EAAA,CAAID,CAAAA,CAAM,KAAA,EAASA,CAAAA,CAAM,KAAA,CAAM,MAAA,CAAS,CAAA,CACtC,GAAA,CAAA,IAAWE,EAAAA,GAAQF,CAAAA,CAAM,KAAA,CACnBE,CAAAA,CAAK,IAAA,EACPC,iCAAAA,CAAcL,CAAQM,iCAAAA,CAAmBF,CAAK,IAAI,CAAA,CAAGA,CAAAA,CAAK,OAAO,CAAA,CAAA,KAG5DF,CAAAA,CAAM,IAAA,EACfG,iCAAAA,CAAcL,CAAQM,iCAAAA,CAAmBJ,CAAM,IAAI,CAAA,CAAGA,CAAAA,CAAM,OAAO,CAAA,CAAA,KAGrE,MAAMA,CAEV,CACF,CAAC,CACH,CAAA,CACOF,CAAAA,CAGT,GAAI,CACF,OAAA,MAAMJ,CAAAA,CAAO,QAAA,CAASE,CAAAA,CAAQ,CAC5B,UAAA,kCAAYD,CAAAA,6BAAQ,YAAA,SAAc,CAAA,GAAA,CAClC,YAAA,kCAAcA,CAAAA,6BAAQ,cAAA,SAAgB,CAAA,GACxC,CAAC,CAAA,CACM,CAAC,CACV,CAAA,KAAA,CAASK,CAAAA,CAAgB,CACvB,EAAA,CAAIA,EAAAA,WAAiBC,oBAAAA,CAAiB,CACpC,GAAA,CAAA,IAAWC,EAAAA,oBAAQF,CAAAA,CAAM,KAAA,SAAS,CAAC,GAAA,CAC7BE,CAAAA,CAAK,IAAA,EACPC,iCAAAA,CAAcL,CAAQM,iCAAAA,CAAmBF,CAAK,IAAI,CAAA,CAAGA,CAAAA,CAAK,OAAO,CAAA,CAIrE,OAAOG,iCAAAA,CAAoBP,iBAAQD,CAAAA,6BAAS,aAAW,CACzD,CAEA,MAAMG,CACR,CACF,CAAA,CAAA,cAAA","file":"/home/runner/work/bit-form/bit-form/dist/chunk-5ILGCBKG.cjs","sourcesContent":[null,"import { ValidationError, Schema } from \"yup\";\nimport { BitErrors } from \"../core\";\nimport {\n filterErrorsByScope,\n normalizeErrorPath,\n setFirstError,\n} from \"./utils\";\nimport { BitResolverScopeOptions, BitYupResolverConfig } from \"./types\";\n\nexport const yupResolver = <T extends object>(\n schema: Schema<T>,\n config?: BitYupResolverConfig,\n) => {\n return async (\n values: T,\n options?: BitResolverScopeOptions,\n ): Promise<BitErrors<T>> => {\n const errors: BitErrors<T> = {};\n\n if (options?.scopeFields && options.scopeFields.length > 0) {\n await Promise.all(\n options.scopeFields.map(async (field) => {\n try {\n await schema.validateAt(field, values, {\n abortEarly: config?.abortEarly ?? false,\n });\n } catch (error: unknown) {\n if (error instanceof ValidationError) {\n if (error.inner && error.inner.length > 0) {\n for (const item of error.inner) {\n if (item.path) {\n setFirstError(errors, normalizeErrorPath(item.path), item.message);\n }\n }\n } else if (error.path) {\n setFirstError(errors, normalizeErrorPath(error.path), error.message);\n }\n } else {\n throw error;\n }\n }\n }),\n );\n return errors;\n }\n\n try {\n await schema.validate(values, {\n abortEarly: config?.abortEarly ?? false,\n stripUnknown: config?.stripUnknown ?? false,\n });\n return {};\n } catch (error: unknown) {\n if (error instanceof ValidationError) {\n for (const item of error.inner ?? []) {\n if (item.path) {\n setFirstError(errors, normalizeErrorPath(item.path), item.message);\n }\n }\n\n return filterErrorsByScope(errors, options?.scopeFields);\n }\n\n throw error;\n }\n };\n};\n"]}
|
|
@@ -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 r(t){return t!=null&&typeof t=="object"&&"target"in t}var e=(t,n)=>{if(t==null||t==="")return"";if(!n)return String(t);try{return n.format(t)}catch (e2){return String(t)}},i= exports.c =(t,n)=>{if(!n)return t;try{return n.parse(String(_nullishCoalesce(t, () => (""))))}catch (e3){return String(_nullishCoalesce(t, () => ("")))}};exports.a = r; exports.b = e; exports.c = i;
|
|
2
|
+
//# sourceMappingURL=chunk-725CMNAV.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/mask/field-binding.ts"],"names":["isBitFieldInputEventObject","value","formatMaskedValue","mask","parseMaskedInput"],"mappings":"AAkBO,sLAASA,CAAAA,CACdC,CAAAA,CAIA,CACA,OAAOA,CAAAA,EAAS,IAAA,EAAQ,OAAOA,CAAAA,EAAU,QAAA,EAAY,QAAA,GAAYA,CACnE,CAEO,IAAMC,CAAAA,CAAoB,CAACD,CAAAA,CAAgBE,CAAAA,CAAAA,EAA2B,CAC3E,EAAA,CAA2BF,CAAAA,EAAU,IAAA,EAAQA,CAAAA,GAAU,EAAA,CACrD,MAAO,EAAA,CAGT,EAAA,CAAI,CAACE,CAAAA,CACH,OAAO,MAAA,CAAOF,CAAK,CAAA,CAGrB,GAAI,CACF,OAAOE,CAAAA,CAAK,MAAA,CAAOF,CAAK,CAC1B,CAAA,UAAQ,CACN,OAAO,MAAA,CAAOA,CAAK,CACrB,CACF,CAAA,CAEaG,CAAAA,aAAmB,CAACH,CAAAA,CAAgBE,CAAAA,CAAAA,EAA4B,CAC3E,EAAA,CAAI,CAACA,CAAAA,CACH,OAAOF,CAAAA,CAGT,GAAI,CACF,OAAOE,CAAAA,CAAK,KAAA,CAAM,MAAA,kBAAOF,CAAAA,SAAS,IAAE,CAAC,CACvC,CAAA,UAAQ,CACN,OAAO,MAAA,kBAAOA,CAAAA,SAAS,IAAE,CAC3B,CACF,CAAA,CAAA,4CAAA","file":"/home/runner/work/bit-form/bit-form/dist/chunk-725CMNAV.cjs","sourcesContent":["import type { BitMask } from \"./types\";\n\n/**\n * Tipo de entrada aceito pelos handlers de campo.\n * Cobre eventos nativos (`e.target.value`), eventos sintéticos e valores diretos.\n * Definido aqui para ser compartilhado entre todos os frameworks.\n */\nexport type BitFieldInputEvent =\n | { target?: { value?: string | number | null } }\n | string\n | number\n | null\n | undefined;\n\n/**\n * Type guard: verifica se o valor de entrada é um objeto de evento\n * (com propriedade `target`), diferenciando-o de um valor direto.\n */\nexport function isBitFieldInputEventObject(\n value: BitFieldInputEvent,\n): value is Extract<\n BitFieldInputEvent,\n { target?: { value?: string | number | null } }\n> {\n return value != null && typeof value === \"object\" && \"target\" in value;\n}\n\nexport const formatMaskedValue = (value: unknown, mask?: BitMask): string => {\n if (value === undefined || value === null || value === \"\") {\n return \"\";\n }\n\n if (!mask) {\n return String(value);\n }\n\n try {\n return mask.format(value);\n } catch {\n return String(value);\n }\n};\n\nexport const parseMaskedInput = (value: unknown, mask?: BitMask): unknown => {\n if (!mask) {\n return value;\n }\n\n try {\n return mask.parse(String(value ?? \"\"));\n } catch {\n return String(value ?? \"\");\n }\n};\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkCIS3YZSKcjs = require('./chunk-CIS3YZSK.cjs');function o(i,e){return e&&e.value===i.value&&e.error===i.error&&e.touched===i.touched&&e.isHidden===i.isHidden&&e.isRequired===i.isRequired&&e.isDirty===i.isDirty&&e.isValidating===i.isValidating?e:{value:i.value,error:i.error,touched:i.touched,isHidden:i.isHidden,isRequired:i.isRequired,isDirty:i.isDirty,isValidating:i.isValidating}}function d(i,e){return i===e?!0:!i||!e?!1:_chunkCIS3YZSKcjs.d.call(void 0, i.value,e.value)&&i.error===e.error&&i.touched===e.touched&&i.isHidden===e.isHidden&&i.isRequired===e.isRequired&&i.isDirty===e.isDirty&&i.isValidating===e.isValidating}var n=d;exports.a = o; exports.b = d; exports.c = n;
|
|
2
|
+
//# sourceMappingURL=chunk-7IO2KLSJ.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/bit-form/bit-form/dist/chunk-
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/bit-form/bit-form/dist/chunk-7IO2KLSJ.cjs","../src/core/utils/field-state-snapshot.ts"],"names":["createFieldStateSnapshot","nextState","lastSnapshot","areFieldSnapshotsEqual","snapshotA","snapshotB","deepEqual","areFieldStatesEqual"],"mappings":"AAAA,iIAAwC,SCqCxBA,CAAAA,CACdC,CAAAA,CASAC,CAAAA,CAC0B,CAE1B,OAAIA,CAAAA,EAEAA,CAAAA,CAAa,KAAA,GAAUD,CAAAA,CAAU,KAAA,EACjCC,CAAAA,CAAa,KAAA,GAAUD,CAAAA,CAAU,KAAA,EACjCC,CAAAA,CAAa,OAAA,GAAYD,CAAAA,CAAU,OAAA,EACnCC,CAAAA,CAAa,QAAA,GAAaD,CAAAA,CAAU,QAAA,EACpCC,CAAAA,CAAa,UAAA,GAAeD,CAAAA,CAAU,UAAA,EACtCC,CAAAA,CAAa,OAAA,GAAYD,CAAAA,CAAU,OAAA,EACnCC,CAAAA,CAAa,YAAA,GAAiBD,CAAAA,CAAU,YAAA,CAGjCC,CAAAA,CAIJ,CACL,KAAA,CAAOD,CAAAA,CAAU,KAAA,CACjB,KAAA,CAAOA,CAAAA,CAAU,KAAA,CACjB,OAAA,CAASA,CAAAA,CAAU,OAAA,CACnB,QAAA,CAAUA,CAAAA,CAAU,QAAA,CACpB,UAAA,CAAYA,CAAAA,CAAU,UAAA,CACtB,OAAA,CAASA,CAAAA,CAAU,OAAA,CACnB,YAAA,CAAcA,CAAAA,CAAU,YAC1B,CACF,CAUO,SAASE,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACS,CACT,OAAID,CAAAA,GAAcC,CAAAA,CAAkB,CAAA,CAAA,CAChC,CAACD,CAAAA,EAAa,CAACC,CAAAA,CAAkB,CAAA,CAAA,CAGnCC,iCAAAA,CAAUF,CAAU,KAAA,CAAOC,CAAAA,CAAU,KAAK,CAAA,EAC1CD,CAAAA,CAAU,KAAA,GAAUC,CAAAA,CAAU,KAAA,EAC9BD,CAAAA,CAAU,OAAA,GAAYC,CAAAA,CAAU,OAAA,EAChCD,CAAAA,CAAU,QAAA,GAAaC,CAAAA,CAAU,QAAA,EACjCD,CAAAA,CAAU,UAAA,GAAeC,CAAAA,CAAU,UAAA,EACnCD,CAAAA,CAAU,OAAA,GAAYC,CAAAA,CAAU,OAAA,EAChCD,CAAAA,CAAU,YAAA,GAAiBC,CAAAA,CAAU,YAEzC,CAEO,IAAME,CAAAA,CAAsBJ,CAAAA,CAAAA,4CAAAA","file":"/home/runner/work/bit-form/bit-form/dist/chunk-7IO2KLSJ.cjs","sourcesContent":[null,"/**\n * Field State Snapshot Utilities\n *\n * Shared utilities for creating and managing field state snapshots across frameworks\n * (React, Vue, Angular). Reduces code duplication while maintaining type safety.\n */\n\nimport type { BitFieldState } from \"../store/contracts/types\";\nimport { deepEqual } from \"../utils\";\n\n/**\n * Represents a stable snapshot of field state that can be compared for equality.\n */\nexport type BitFieldSnapshot<TValue = unknown> = BitFieldState<\n Record<string, unknown>,\n TValue\n>;\n\n/**\n * Creates or reuses a field state snapshot with shallow equality checking.\n *\n * This function prevents unnecessary re-renders in frameworks like React by\n * returning the same object reference when field state hasn't changed.\n *\n * @param nextState - The new field state from the store\n * @param lastSnapshot - The previous snapshot (can be null on first call)\n * @returns A stable snapshot object that can be used for equality comparison\n *\n * @example\n * ```typescript\n * const snapshot = createFieldStateSnapshot(store.getFieldState(\"email\"), lastSnapshot);\n * if (snapshot !== lastSnapshot) {\n * // Field state changed, update component\n * render(snapshot);\n * }\n * ```\n */\nexport function createFieldStateSnapshot<TValue = unknown>(\n nextState: {\n value: TValue;\n error: string | undefined;\n touched: boolean;\n isHidden: boolean;\n isRequired: boolean;\n isDirty: boolean;\n isValidating: boolean;\n },\n lastSnapshot: BitFieldSnapshot<TValue> | null,\n): BitFieldSnapshot<TValue> {\n // Use shallow equality: return cached if all fields are equal by reference\n if (lastSnapshot) {\n const shallowEqual =\n lastSnapshot.value === nextState.value &&\n lastSnapshot.error === nextState.error &&\n lastSnapshot.touched === nextState.touched &&\n lastSnapshot.isHidden === nextState.isHidden &&\n lastSnapshot.isRequired === nextState.isRequired &&\n lastSnapshot.isDirty === nextState.isDirty &&\n lastSnapshot.isValidating === nextState.isValidating;\n\n if (shallowEqual) {\n return lastSnapshot;\n }\n }\n\n return {\n value: nextState.value,\n error: nextState.error,\n touched: nextState.touched,\n isHidden: nextState.isHidden,\n isRequired: nextState.isRequired,\n isDirty: nextState.isDirty,\n isValidating: nextState.isValidating,\n };\n}\n\n/**\n * Deep comparison utility for field state snapshots.\n * Useful for scenarios where shallow comparison isn't sufficient (e.g., object/array values).\n *\n * @param snapshotA - First snapshot\n * @param snapshotB - Second snapshot\n * @returns true if snapshots are deeply equal\n */\nexport function areFieldSnapshotsEqual(\n snapshotA: BitFieldSnapshot | null | undefined,\n snapshotB: BitFieldSnapshot | null | undefined,\n): boolean {\n if (snapshotA === snapshotB) return true;\n if (!snapshotA || !snapshotB) return false;\n\n return (\n deepEqual(snapshotA.value, snapshotB.value) &&\n snapshotA.error === snapshotB.error &&\n snapshotA.touched === snapshotB.touched &&\n snapshotA.isHidden === snapshotB.isHidden &&\n snapshotA.isRequired === snapshotB.isRequired &&\n snapshotA.isDirty === snapshotB.isDirty &&\n snapshotA.isValidating === snapshotB.isValidating\n );\n}\n\nexport const areFieldStatesEqual = areFieldSnapshotsEqual;\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{d as r}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{d as r}from"./chunk-T7TOEIOH.js";function o(i,e){return e&&e.value===i.value&&e.error===i.error&&e.touched===i.touched&&e.isHidden===i.isHidden&&e.isRequired===i.isRequired&&e.isDirty===i.isDirty&&e.isValidating===i.isValidating?e:{value:i.value,error:i.error,touched:i.touched,isHidden:i.isHidden,isRequired:i.isRequired,isDirty:i.isDirty,isValidating:i.isValidating}}function d(i,e){return i===e?!0:!i||!e?!1:r(i.value,e.value)&&i.error===e.error&&i.touched===e.touched&&i.isHidden===e.isHidden&&i.isRequired===e.isRequired&&i.isDirty===e.isDirty&&i.isValidating===e.isValidating}var n=d;export{o as a,d as b,n as c};
|
|
2
|
+
//# sourceMappingURL=chunk-AJUX7LYB.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{b as ke,c as Ge,d as D,e as Ye,h as z}from"./chunk-UIKO6GGW.js";import{c as Qe}from"./chunk-AJUX7LYB.js";import{a as T,b as _e,c as E,d as I,e as Le,f as m,g as w,h as A,i as We,k as Ne,l as U,m as Ke,n as $e}from"./chunk-T7TOEIOH.js";import{L as Je}from"./chunk-32RH5MSM.js";function Xe(s){let{path:e,getFieldConfig:t,masks:i}=s,r=t(e)?.mask;if(r)return typeof r=="string"?i?.[r]:r}function Ze(s){let{state:e,path:t,value:i,isHidden:r,isRequired:n,isDirty:o,isValidating:a}=s,l=t;return{value:i,error:e.errors[l],touched:!!e.touched[l],isHidden:r,isRequired:n,isDirty:o,isValidating:a}}var O=Symbol.for("bit-form.framework-store-api");var j=Symbol.for("bit-form.hooks-api");var q=class{constructor(e){this.baselineValues=T(e)}baselineValues;baselineSnapshot;getValues(){return this.baselineSnapshot||(this.baselineSnapshot=Object.freeze(T(this.baselineValues))),this.baselineSnapshot}setValues(e){this.baselineValues=T(e),this.baselineSnapshot=void 0}};var _=class{constructor(e,t){this.getComputedEntries=e;this.onError=t}equalityCache=new Map;reverseDepsCache=null;childDepsIndex=null;validatedEntriesSignature=null;validatedEntriesRef=null;orderedAllEntriesCache=null;orderedIndexByPathCache=null;isCacheableScalar(e){return e===null||typeof e!="object"&&typeof e!="function"}invalidateReverseDeps(){this.reverseDepsCache=null,this.childDepsIndex=null,this.orderedAllEntriesCache=null,this.validatedEntriesSignature=null,this.validatedEntriesRef=null,this.orderedIndexByPathCache=null,this.equalityCache.clear()}apply(e,t){let i=this.getComputedEntries(e);if(i.length===0)return e;this.ensureEntriesAreValid(i);let r=this.resolveEntriesToRun(i,t);if(r.length===0)return e;let n=e,o=new Set;for(let a of r){if(a.dependsOn.some(h=>o.has(h))){o.add(a.path);continue}let l;try{l=a.compute(n)}catch(h){this.onError?.(h,a.path),o.add(a.path);continue}let c=m(n,a.path),p=this.equalityCache.get(a.path),d,u=this.isCacheableScalar(c)&&this.isCacheableScalar(l);u&&p&&p.current===c&&p.next===l?d=p.equal:(d=I(c,l),u?(this.equalityCache.size>1e3&&this.equalityCache.clear(),this.equalityCache.set(a.path,{current:c,next:l,equal:d})):this.equalityCache.delete(a.path)),d||(n=w(n,a.path,l))}return n}getReverseDependencies(e){if(this.reverseDepsCache)return this.reverseDepsCache;let t=new Map;for(let r of e)for(let n of r.dependsOn){let o=t.get(n);o||(o=new Set,t.set(n,o)),o.add(r.path)}let i=new Map;for(let r of t.keys()){let n=r.split(".");for(let o=1;o<n.length;o++){let a=n.slice(0,o).join("."),l=i.get(a);l||(l=new Set,i.set(a,l)),l.add(r)}}return this.reverseDepsCache=t,this.childDepsIndex=i,t}resolveEntriesToRun(e,t){if(!t||t.length===0||t.includes("*"))return this.getOrderedAllEntries(e);let i=this.getReverseDependencies(e),r=new Set,n=[...t],o=0;for(;o<n.length;){let p=n[o++],d=this.getDependentsForPath(i,p);if(d)for(let u of d)r.has(u)||(r.add(u),n.push(u))}if(r.size===0)return[];let a=this.getOrderedAllEntries(e),l=this.getOrderedIndexByPath(e,a),c=[];return r.forEach(p=>{let d=l.get(p);if(d===void 0)return;let u=a[d];u&&c.push({index:d,entry:u})}),c.sort((p,d)=>p.index-d.index),c.map(p=>p.entry)}orderEntries(e){if(e.length<=1)return e;let t=new Map(e.map(a=>[a.path,a])),i=new Map,r=new Map;e.forEach(a=>i.set(a.path,0)),e.forEach(a=>{a.dependsOn.forEach(l=>{if(!t.has(l))return;let c=r.get(l)??new Set;c.has(a.path)||(c.add(a.path),r.set(l,c),i.set(a.path,(i.get(a.path)??0)+1))})});let n=e.filter(a=>(i.get(a.path)??0)===0).map(a=>a.path),o=[];for(;n.length>0;){let a=n.shift();o.push(a);let l=r.get(a);l&&l.forEach(c=>{let p=(i.get(c)??0)-1;i.set(c,p),p===0&&n.push(c)})}if(o.length!==e.length)throw new Error("BitStore: cyclic computed dependencies detected. Check computedDependsOn definitions.");return o.map(a=>t.get(a))}getOrderedAllEntries(e){let t=this.createEntriesSignature(e);if(this.orderedAllEntriesCache&&this.orderedAllEntriesCache.signature===t)return this.orderedAllEntriesCache.ordered;let i=this.orderEntries(e);return this.orderedAllEntriesCache={signature:t,ordered:i},i}getOrderedIndexByPath(e,t){let i=this.createEntriesSignature(e);if(this.orderedIndexByPathCache&&this.orderedIndexByPathCache.signature===i)return this.orderedIndexByPathCache.indexByPath;let r=new Map;return t.forEach((n,o)=>{r.set(n.path,o)}),this.orderedIndexByPathCache={signature:i,indexByPath:r},r}ensureEntriesAreValid(e){if(this.validatedEntriesRef===e)return;let t=this.createEntriesSignature(e);if(this.validatedEntriesSignature===t){this.validatedEntriesRef=e;return}e.forEach(i=>this.assertDependencies(i)),this.invalidateReverseDeps(),this.validatedEntriesSignature=t,this.validatedEntriesRef=e}createEntriesSignature(e){return e.map(t=>`${t.path}:${t.dependsOn.join(",")}`).join("|")}getDependentsForPath(e,t){let i=new Set,r=a=>{let l=e.get(a);l&&l.forEach(c=>i.add(c))};r(t);let n=t.split(".");for(;n.length>1;)n.pop(),r(n.join("."));let o=this.childDepsIndex?.get(t);if(o)for(let a of o)r(a);return i}assertDependencies(e){if(e.dependsOn.length===0)throw new Error(`BitStore: computed field \`${e.path}\` requires explicit computedDependsOn in v4.`);if(e.dependsOn.includes(e.path))throw new Error(`BitStore: computed field \`${e.path}\` cannot depend on itself.`)}};var L=class{dirtyPaths=new Set;dirtyPathIndex=new Set;dirtyPrefixRefCount=new Map;childrenByPrefix=new Map;updateForPath(e,t,i){this.removeDirtyChildren(e);let r=m(t,e),n=m(i,e);return E(r,n)?this.removeDirtyPath(e):this.addDirtyPath(e),this.dirtyPaths.size>0}rebuild(e,t){return this.dirtyPaths=Le(e,t),this.dirtyPrefixRefCount.clear(),this.rebuildIndex(),this.dirtyPaths.size>0}clear(){this.dirtyPaths.clear(),this.dirtyPathIndex.clear(),this.dirtyPrefixRefCount.clear(),this.childrenByPrefix.clear()}get isDirty(){return this.dirtyPaths.size>0}getDirtyPaths(){return this.dirtyPaths}isPathDirty(e){if(this.dirtyPathIndex.has(e))return!0;let t=e.lastIndexOf(".");for(;t>-1;){let i=e.slice(0,t);if((this.dirtyPrefixRefCount.get(i)??0)>0)return!0;t=e.lastIndexOf(".",t-1)}return!1}buildDirtyValues(e){if(this.dirtyPaths.size===0)return{};let t=[],i=[...this.dirtyPaths].sort(),r=new Set,n=new Set,o=a=>{let l=a.lastIndexOf(".");for(;l>-1;){if(n.has(a.slice(0,l)))return!0;l=a.lastIndexOf(".",l-1)}return!1};for(let a of i){if(o(a))continue;let l=a.match(/^(.+)\.\d+/);if(l){let c=l[1];if(r.has(c))continue;r.add(c);let p=m(e,c);t.push([c,p]),n.add(c)}else{let c=m(e,a);t.push([a,c]),n.add(a)}}return t.length===0?{}:A({},t)}rebuildIndex(){let e=new Set,t=new Map,i=new Map;for(let r of this.dirtyPaths)this.forEachPathPrefix(r,n=>{e.add(n),t.set(n,(t.get(n)??0)+1)}),this.forEachAncestorPrefix(r,n=>{let o=i.get(n);o?o.add(r):i.set(n,new Set([r]))});this.dirtyPathIndex=e,this.dirtyPrefixRefCount=t,this.childrenByPrefix=i}removeDirtyChildren(e){let t=this.childrenByPrefix.get(e);if(!(!t||t.size===0))for(let i of[...t])this.removeDirtyPath(i)}addDirtyPath(e){this.dirtyPaths.has(e)||(this.dirtyPaths.add(e),this.forEachPathPrefix(e,t=>{this.dirtyPathIndex.add(t),this.dirtyPrefixRefCount.set(t,(this.dirtyPrefixRefCount.get(t)??0)+1)}),this.forEachAncestorPrefix(e,t=>{let i=this.childrenByPrefix.get(t);i?i.add(e):this.childrenByPrefix.set(t,new Set([e]))}))}removeDirtyPath(e){this.dirtyPaths.has(e)&&(this.dirtyPaths.delete(e),this.forEachPathPrefix(e,t=>{let i=(this.dirtyPrefixRefCount.get(t)??0)-1;if(i<=0){this.dirtyPrefixRefCount.delete(t),this.dirtyPathIndex.delete(t);return}this.dirtyPrefixRefCount.set(t,i)}),this.forEachAncestorPrefix(e,t=>{this.childrenByPrefix.get(t)?.delete(e)}))}forEachPathPrefix(e,t){let i=e.split("."),r="";for(let n of i)r=r?`${r}.${n}`:n,t(r)}forEachAncestorPrefix(e,t){let i=e.split("."),r="";for(let n=0;n<i.length-1;n++)r=r?`${r}.${i[n]}`:i[n],t(r)}};var W=class{masks=new Map;constructor(){Object.entries(Je).forEach(([e,t])=>{this.masks.set(e,t)})}registerMask(e,t){this.masks.set(e,t)}unregisterMask(e){this.masks.has(e)&&this.masks.delete(e)}resolveMask(e){return this.masks.get(e)}getAllMasks(){return Object.fromEntries(this.masks.entries())}clear(){this.masks.clear()}};function yi(s){return s==null?"":s.replace(/\.+$/g,"")}function F(s){return s==null?"":yi(s.trim())}function x(s,e){if(s==null||e==null)return!1;let t=F(e);return t.length===0?!1:s===t||s.startsWith(`${t}.`)}function C(s,e){return s==null?"":F(e===void 0?s:`${s}.${e}`)}function V(s){return s.includes(".*.")||s.endsWith(".*")}function et(s){let t=s.replace(/\./g,"\\.").replace(/\*/g,"\\d+");return new RegExp(`^${t}$`)}function H(s,e){if(!V(s))return[s];let t=s.split("."),i=[""];for(let r=0;r<t.length;r++){let n=t[r],o=[];for(let a of i)if(n==="*"){let l=a.replace(/\.$/,""),c=l?m(e,l):e;if(Array.isArray(c)&&c.length>0)for(let p=0;p<c.length;p++)o.push(`${a}${p}.`)}else o.push(`${a}${n}.`);i=o}return i.map(r=>r.replace(/\.$/,""))}function Ie(s,e,t){if(!V(s)||!V(t))return s;let i=t.replace(/\./g,"\\.").replace(/\*/g,"(\\d+)"),r=new RegExp(`^${i}$`),n=e.match(r);if(!n)return s;let o=n.slice(1),a=0,l=s.split("*"),c=l[0];for(let p=1;p<l.length;p++){let d=a<o.length?o[a++]:"*";c+=d+l[p]}return c}var N=class{fieldConfigs=new Map;wildcardConfigs=new Map;wildcardRegexes=new Map;scopeFieldsIndex=null;computedEntriesCache=null;normalizerEntriesCache=null;transformEntriesCache=null;get(e){let t=this.fieldConfigs.get(e);if(t)return t;for(let[i,r]of this.wildcardConfigs.entries()){let n=this.wildcardRegexes.get(i);if(n&&n.test(e))return r}}set(e,t){V(e)?(this.wildcardConfigs.set(e,t),this.wildcardRegexes.set(e,et(e))):this.fieldConfigs.set(e,t),this.registerCachedIndexes(e,t)}delete(e){let t;return V(e)?(t=this.wildcardConfigs.get(e),this.wildcardConfigs.delete(e),this.wildcardRegexes.delete(e)):(t=this.fieldConfigs.get(e),this.fieldConfigs.delete(e)),this.unregisterCachedIndexes(e,t),t}has(e){if(this.fieldConfigs.has(e)||this.wildcardConfigs.has(e))return!0;for(let t of this.wildcardRegexes.values())if(t.test(e))return!0;return!1}forEach(e){this.fieldConfigs.forEach((t,i)=>e(t,i)),this.wildcardConfigs.forEach((t,i)=>e(t,i))}entries(){return[...Array.from(this.fieldConfigs.entries()),...Array.from(this.wildcardConfigs.entries())]}getScopeFields(e,t){if(!this.scopeFieldsIndex){let n=new Map;this.forEach((o,a)=>{if(!o.scope)return;let l=n.get(o.scope)??new Set;l.add(a),n.set(o.scope,l)}),this.scopeFieldsIndex=n}let i=Array.from(this.scopeFieldsIndex.get(e)??[]);if(i.length===0)return[];let r=new Set;for(let n of i)V(n)?H(n,t).forEach(a=>r.add(a)):r.add(n);return Array.from(r)}getComputedEntries(e){if(!this.computedEntriesCache){let i=[];this.forEach((r,n)=>{r.computed&&i.push({path:n,compute:r.computed,dependsOn:r.computedDependsOn})}),this.computedEntriesCache=i}let t=[];for(let i of this.computedEntriesCache)if(V(i.path)){let r=H(i.path,e);for(let n of r)t.push({path:n,compute:o=>i.compute(o,n),dependsOn:i.dependsOn.map(o=>Ie(o,n,i.path))})}else t.push({path:i.path,compute:r=>i.compute(r,i.path),dependsOn:i.dependsOn});return t}getTransformEntries(e){if(!this.transformEntriesCache){let i=[];this.forEach((r,n)=>{r.transform&&i.push([n,r.transform])}),this.transformEntriesCache=i}let t=[];for(let[i,r]of this.transformEntriesCache)if(V(i)){let n=H(i,e);for(let o of n)t.push([o,(a,l)=>r(a,l,o)])}else t.push([i,(n,o)=>r(n,o,i)]);return t}getNormalizerEntries(e){if(!this.normalizerEntriesCache){let i=[];this.forEach((r,n)=>{r.normalize&&i.push({path:n,normalize:r.normalize,dependsOn:r.normalizeDependsOn?.length?r.normalizeDependsOn:[n]})}),this.normalizerEntriesCache=i}let t=[];for(let i of this.normalizerEntriesCache)if(V(i.path)){let r=H(i.path,e);for(let n of r)t.push({path:n,normalize:(o,a)=>i.normalize(o,a,n),dependsOn:i.dependsOn.map(o=>Ie(o,n,i.path))})}else t.push({path:i.path,normalize:(r,n)=>i.normalize(r,n,i.path),dependsOn:i.dependsOn});return t}invalidateIndexes(){this.scopeFieldsIndex=null,this.computedEntriesCache=null,this.normalizerEntriesCache=null,this.transformEntriesCache=null}registerCachedIndexes(e,t){if(this.scopeFieldsIndex&&t.scope){let i=this.scopeFieldsIndex.get(t.scope)??new Set;i.add(e),this.scopeFieldsIndex.set(t.scope,i)}this.computedEntriesCache&&t.computed&&this.computedEntriesCache.push({path:e,compute:t.computed,dependsOn:t.computedDependsOn}),this.normalizerEntriesCache&&t.normalize&&this.normalizerEntriesCache.push({path:e,normalize:t.normalize,dependsOn:t.normalizeDependsOn?.length?t.normalizeDependsOn:[e]}),this.transformEntriesCache&&t.transform&&this.transformEntriesCache.push([e,t.transform])}unregisterCachedIndexes(e,t){if(!t){this.invalidateIndexes();return}if(this.scopeFieldsIndex&&t.scope){let i=this.scopeFieldsIndex.get(t.scope);i&&(i.delete(e),i.size>0?this.scopeFieldsIndex.set(t.scope,i):this.scopeFieldsIndex.delete(t.scope))}this.computedEntriesCache&&t.computed&&(this.computedEntriesCache=this.computedEntriesCache.filter(i=>i.path!==e)),this.normalizerEntriesCache&&t.normalize&&(this.normalizerEntriesCache=this.normalizerEntriesCache.filter(i=>i.path!==e)),this.transformEntriesCache&&t.transform&&(this.transformEntriesCache=this.transformEntriesCache.filter(([i])=>i!==e))}};var K=class{constructor(e,t){this.getFieldConfig=e;this.onConditionError=t}dependencies=new Map;hiddenFields=new Set;conditionalVisibilityPaths=new Set;requiredPathsByDependency=new Map;requiredConditionalPaths=new Set;requiredEvaluationVersion=0;requiredEvaluationCache=new Map;getHiddenFields(){return this.hiddenFields}onRegister(e,t,i){let r=!!t.conditional?.showIf,n=t.conditional?.dependsOn;if(n){if(this.wouldCreateCycle(e,n)){let o=new Error(`Circular dependency detected: "${e}" \u2192 [${n.join(", ")}]`);return this.onConditionError?.({path:e,kind:"showIf",error:o}),r&&this.hiddenFields.add(e),this.conditionalVisibilityPaths.delete(e),this.requiredConditionalPaths.delete(e),!1}n.forEach(o=>{this.dependencies.has(o)||this.dependencies.set(o,new Set),this.dependencies.get(o).add(e)})}return r&&this.conditionalVisibilityPaths.add(e),n&&t.conditional?.requiredIf&&(this.requiredConditionalPaths.add(e),n.forEach(o=>{this.requiredPathsByDependency.has(o)||this.requiredPathsByDependency.set(o,new Set),this.requiredPathsByDependency.get(o).add(e)})),this.requiredEvaluationVersion+=1,this.requiredEvaluationCache.clear(),this.evaluateFieldCondition(e,i),!0}onUnregister(e,t,i){this.hiddenFields.delete(e),this.conditionalVisibilityPaths.delete(e),i?.preserveIncomingDependents||this.dependencies.delete(e),this.requiredEvaluationVersion+=1,this.requiredEvaluationCache.clear(),this.requiredConditionalPaths.delete(e),t?.conditional?.dependsOn?.forEach(r=>{let n=this.requiredPathsByDependency.get(r);n&&(n.delete(e),n.size===0&&this.requiredPathsByDependency.delete(r))}),this.dependencies.forEach(r=>{r.delete(e)})}isHidden(e){return this.hiddenFields.has(e)}hasDependents(e){return(this.dependencies.get(e)?.size??0)>0}isRequired(e,t){let i=this.getFieldConfig(e);if(!i||this.isHidden(e)||!i.conditional?.requiredIf)return!1;let r=this.requiredEvaluationCache.get(e);if(r&&r.version===this.requiredEvaluationVersion&&I(r.valuesRef,t))return r.result;let n=!1;try{n=!!i.conditional.requiredIf(t)}catch(o){this.onConditionError?.({path:e,kind:"requiredIf",error:o})}return this.requiredEvaluationCache.set(e,{version:this.requiredEvaluationVersion,valuesRef:t,result:n}),n}getRequiredErrors(e){let t={};return this.requiredConditionalPaths.forEach(i=>{let r=this.getFieldConfig(i);if(r&&!this.isHidden(i)&&this.isRequired(i,e)){let n=m(e,i);this.isEmpty(n)&&(t[i]=r.conditional?.requiredMessage??"required field")}}),t}evaluateAll(e){this.conditionalVisibilityPaths.forEach(t=>{this.evaluateFieldCondition(t,e)})}updateDependencies(e,t,i){let r=new Set,n=new Set,o=new Set,a=[e],l=new Set;for(;a.length>0;){let c=a.shift();if(l.has(c))continue;l.add(c);let p=this.dependencies.get(c);p&&p.forEach(d=>{r.add(d);let u=this.isHidden(d),h=this.isRequired(d,t);this.evaluateFieldCondition(d,i);let f=this.isHidden(d),S=this.isRequired(d,i);u!==f&&n.add(d),h!==S&&o.add(d),a.push(d)})}return{affectedFields:Array.from(r),visibilityChanged:Array.from(n),requiredChanged:Array.from(o)}}evaluateFieldCondition(e,t){let r=this.getFieldConfig(e)?.conditional?.showIf;if(r)try{r(t)?this.hiddenFields.delete(e):this.hiddenFields.add(e)}catch(n){this.onConditionError?.({path:e,kind:"showIf",error:n})}}wouldCreateCycle(e,t){for(let i of t){let r=[e],n=new Set;for(;r.length>0;){let o=r.shift();if(o===i)return!0;if(n.has(o))continue;n.add(o);let a=this.dependencies.get(o);a&&r.push(...a)}}return!1}isEmpty(e){return e==null||typeof e=="string"&&e.trim()===""||Array.isArray(e)&&e.length===0}};var $=class{catalog=new N;conditions;constructor(e){this.conditions=new K(t=>this.catalog.get(t),e)}getFieldConfig(e){return this.catalog.get(e)}forEachFieldConfig(e){this.catalog.forEach((t,i)=>e(t,i))}hasFieldConfig(e){return this.catalog.has(e)}getHiddenFields(){return this.conditions.getHiddenFields()}register(e,t,i){let r=this.catalog.get(e);r&&this.conditions.onUnregister(e,r,{preserveIncomingDependents:!0}),this.catalog.set(e,t),!(this.conditions.onRegister(e,t,i)||!r)&&(this.catalog.set(e,r),this.conditions.onRegister(e,r,i))}unregister(e){let t=this.catalog.delete(e);this.conditions.onUnregister(e,t)}unregisterPrefix(e){let t=[],i=F(e);return i.length===0||(this.catalog.forEach((r,n)=>{x(n,i)&&t.push([n,r])}),t.forEach(([r,n])=>{this.catalog.delete(r),this.conditions.onUnregister(r,n)})),t}isHidden(e){return this.conditions.isHidden(e)}hasDependents(e){return this.conditions.hasDependents(e)}isRequired(e,t){return this.conditions.isRequired(e,t)}getRequiredErrors(e){return this.conditions.getRequiredErrors(e)}evaluateAll(e){this.conditions.evaluateAll(e)}updateDependencies(e,t,i){return this.conditions.updateDependencies(e,t,i)}getScopeFields(e,t){return this.catalog.getScopeFields(e,t)}getComputedEntries(e){return this.catalog.getComputedEntries(e)}getTransformEntries(e){return this.catalog.getTransformEntries(e)}getNormalizerEntries(e){return this.catalog.getNormalizerEntries(e)}invalidateIndexes(){this.catalog.invalidateIndexes()}};function mi(){return`bit-form-${Math.random().toString(36).slice(2,9)}`}function De(s){typeof console<"u"&&typeof console.error=="function"&&console.error(s)}function tt(s={}){let e=s.initialValues??{},t=s.validation,i=s.history,r=s.name?`bit-form:${s.name}:draft`:"bit-form:draft",n=s.onUnhandledError??De,o=(c,p)=>{try{n(c,p)}catch(d){De(c),De(d)}},a=s.persist?.onError,l={enabled:s.persist?.enabled??!1,key:s.persist?.key??r,storage:s.persist?.storage,autoSave:s.persist?.autoSave??!0,debounceMs:s.persist?.debounceMs??300,mode:s.persist?.mode??"values",serialize:s.persist?.serialize??JSON.stringify,deserialize:s.persist?.deserialize??(c=>JSON.parse(c)),onError:c=>{if(a){a(c);return}o(c,"persist")}};return{name:s.name,initialValues:T(e),resolver:t?.resolver,validationDelay:t?.delay??300,history:{enabled:i?.enabled??!1,limit:i?.limit??50,debounceMs:i?.debounceMs??300},fields:s.fields,devTools:s.devTools,persist:l,idFactory:s.idFactory??mi,plugins:s.plugins??[],scheduler:s.scheduler,subscriptionCacheSize:s.subscriptionCacheSize,trackedSubscriptions:s.trackedSubscriptions??!1,bus:s.bus,onUnhandledError:o}}function J(s,e){if((!s||s.length===0)&&(!e||e.length===0))return;let t=new Set(s??[]);return e?.forEach(i=>t.add(i)),Array.from(t)}function Si(s){let e=s?.includes("*")??!1,t=new Set(s??[]),i=new Set;for(let r of t){i.add(r);let n=r.lastIndexOf(".");for(;n>-1;)i.add(r.slice(0,n)),n=r.lastIndexOf(".",n-1)}return r=>{if(!s||s.length===0||e||t.has(r)||i.has(r))return!0;let n=r.lastIndexOf(".");for(;n>-1;){if(t.has(r.slice(0,n)))return!0;n=r.lastIndexOf(".",n-1)}return!1}}function bi(s,e){if(!e||e.length===0||e.includes("*"))return s;let t=Si(e);return s.filter(i=>i.dependsOn.some(r=>t(r)))}function vi(s){if(s.length<=1)return{orderedEntries:[...s],cyclePaths:[]};let e=new Map(s.map(a=>[a.path,a])),t=new Map,i=new Map,r=new Map(s.map((a,l)=>[a.path,l]));s.forEach(a=>t.set(a.path,0)),s.forEach(a=>{a.dependsOn.forEach(l=>{if(l===a.path||!e.has(l))return;let c=i.get(l)??new Set;c.has(a.path)||(c.add(a.path),i.set(l,c),t.set(a.path,(t.get(a.path)??0)+1))})});let n=s.filter(a=>(t.get(a.path)??0)===0).map(a=>a.path),o=[];for(;n.length>0;){n.sort((c,p)=>(r.get(c)??0)-(r.get(p)??0));let a=n.shift();o.push(a);let l=i.get(a);l&&l.forEach(c=>{let p=(t.get(c)??0)-1;t.set(c,p),p===0&&n.push(c)})}if(o.length!==s.length){let a=s.filter(l=>(t.get(l.path)??0)>0).map(l=>l.path);return{orderedEntries:o.map(l=>e.get(l)),cyclePaths:a}}return{orderedEntries:o.map(a=>e.get(a)),cyclePaths:[]}}function G(s){let{values:e,changedPaths:t,normalizerEntries:i,applyComputed:r,onError:n}=s,o=vi(bi(i,t)),{orderedEntries:a,cyclePaths:l}=o;if(l.length>0&&n?.(new Error(`BitStore: cyclic normalizer dependencies detected. Check normalizeDependsOn definitions for: ${l.join(", ")}.`),l[0]??"*"),a.length===0)return r(e,t);let c=[],p=e;for(let u of a){let h=m(p,u.path),f;try{f=u.normalize(h,p)}catch(S){n?.(S,u.path);continue}E(h,f)||(c.push([u.path,f]),p=w(p,u.path,f))}let d=J(t,c.map(([u])=>u));return r(p,d)}function it(s){let{values:e,sourceValues:t,transformEntries:i,onError:r}=s;if(i.length===0)return e;let n=e,o=t;for(let[a,l]of i){let c=m(n,a),p;try{p=l(c,o)}catch(d){r?.(d,a);continue}E(c,p)||(n=w(n,a,p),o=w(o,a,p))}return n}var Y=class{effects;constructor(e){this.effects=e.getAll()}attachStorePort(e){this.effects.forEach(t=>t.attachStorePort?.(e))}initialize(){this.effects.forEach(e=>e.initialize?.())}onStateUpdated(e,t){this.effects.forEach(i=>{try{i.onStateUpdated?.(e,t)}catch(r){this.logEffectHookError(i.name,"onStateUpdated",r)}})}async restorePersisted(){let e=!1,t=null;for(let i of this.effects)if(i.restorePersisted)try{e=await i.restorePersisted()||e}catch(r){this.logEffectHookError(i.name,"restorePersisted",r),t??=r}if(t)throw t;return e}async savePersistedNow(){for(let e of this.effects)e.savePersistedNow&&await e.savePersistedNow()}async clearPersisted(){for(let e of this.effects)e.clearPersisted&&await e.clearPersisted()}async beforeValidate(e){for(let t of this.effects)if(t.beforeValidate)try{await t.beforeValidate(e)}catch(i){this.logEffectHookError(t.name,"beforeValidate",i)}}async afterValidate(e){for(let t of this.effects)if(t.afterValidate)try{await t.afterValidate(e)}catch(i){this.logEffectHookError(t.name,"afterValidate",i)}}async beforeSubmit(e){for(let t of this.effects)if(t.beforeSubmit)try{await t.beforeSubmit(e)}catch(i){this.logEffectHookError(t.name,"beforeSubmit",i)}}async afterSubmit(e){for(let t of this.effects)if(t.afterSubmit)try{await t.afterSubmit(e)}catch(i){this.logEffectHookError(t.name,"afterSubmit",i)}}onFieldChange(e){this.effects.forEach(t=>{try{t.onFieldChange?.(e)}catch(i){this.logEffectHookError(t.name,"onFieldChange",i)}})}async reportOperationalError(e){for(let t of this.effects)if(t.reportOperationalError)try{await t.reportOperationalError(e)}catch(i){this.logEffectHookError(t.name,"reportOperationalError",i)}}logEffectHookError(e,t,i){console.error(`BitStoreEffectEngine: effect "${e}" failed in hook "${t}"`,i)}destroy(){for(let e=this.effects.length-1;e>=0;e-=1)this.effects[e].destroy?.()}};var Q=class{constructor(e,t,i=!0,r){this.storeId=e;this.bus=t;this.enableBusDispatch=i;this.storeBusPort=r}storeBusPort;attachStorePort(e){this.storeBusPort=e,this.enableBusDispatch&&(this.bus.stores[this.storeId]=e)}initialize(){!this.enableBusDispatch||!this.storeBusPort||(this.bus.stores[this.storeId]=this.storeBusPort)}onStateUpdated(e){this.enableBusDispatch&&this.bus.dispatch(this.storeId,e)}destroy(){this.enableBusDispatch&&(delete this.bus.stores[this.storeId],this.storeBusPort=void 0)}};var X=class{effects=new Map;register(e){this.effects.set(e.name,e)}getAll(){return Array.from(this.effects.values())}};var Z=class{constructor(e){this.persistManager=e}onStateUpdated(e,t){t&&this.persistManager.queueSave()}restorePersisted(){return this.persistManager.restore()}savePersistedNow(){return this.persistManager.saveNow()}clearPersisted(){return this.persistManager.clear()}destroy(){this.persistManager.destroy()}};var ee=class{constructor(e){this.pluginManager=e}initialize(){this.pluginManager.setupAll()}beforeValidate(e){return this.pluginManager.beforeValidate(e)}afterValidate(e){return this.pluginManager.afterValidate(e)}beforeSubmit(e){return this.pluginManager.beforeSubmit(e)}afterSubmit(e){return this.pluginManager.afterSubmit(e)}onFieldChange(e){this.pluginManager.onFieldChange(e)}reportOperationalError(e){return this.pluginManager.reportError(e.source,e.error,e.payload)}destroy(){this.pluginManager.destroy()}};function Bi(){if(typeof globalThis>"u")return;let s;try{s=globalThis.localStorage??void 0}catch{return}if(s)return{getItem:e=>s.getItem(e),setItem:(e,t)=>s.setItem(e,t),removeItem:e=>s.removeItem(e)}}var te=class{constructor(e,t,i,r,n={}){this.config=e;this.getValues=t;this.getDirtyValues=i;this.applyRestoredValues=r;this.callbacks=n}timer;writeQueue=Promise.resolve();activeWrites=0;isDestroyed=!1;getStorage(){return this.config.storage||Bi()}canPersist(){return!!(this.config.enabled&&this.config.key&&this.getStorage())}handleError(e){this.callbacks.onError?.(e),this.config.onError?.(e)}enqueueWriteOperation(e){this.activeWrites+=1;try{this.activeWrites===1&&this.callbacks.onWriteStart?.()}catch(r){throw this.activeWrites=Math.max(0,this.activeWrites-1),r}let t=this.writeQueue.then(e,e);return this.writeQueue=t.then(()=>{},()=>{}),t.then(()=>({ok:!0,error:void 0}),r=>({ok:!1,error:r})).then(r=>{if(this.activeWrites=Math.max(0,this.activeWrites-1),r.ok){if(this.activeWrites===0)try{this.callbacks.onWriteSuccess?.()}finally{this.callbacks.onWriteSettled?.()}return}try{this.callbacks.onWriteError?.(r.error)}finally{this.activeWrites===0&&this.callbacks.onWriteSettled?.()}throw r.error})}async persistPayload(){let e=this.getStorage();if(!e)return;let t=this.config.mode==="dirtyValues"?this.getDirtyValues():this.getValues(),i=this.config.serialize(t);await e.setItem(this.config.key,i)}async saveNow(){this.canPersist()&&await this.enqueueWriteOperation(async()=>{try{await this.persistPayload()}catch(e){throw this.handleError(e),e}})}queueSave(){!this.canPersist()||!this.config.autoSave||(this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,!this.isDestroyed&&this.saveNow().catch(()=>{})},this.config.debounceMs))}async restore(){if(this.isDestroyed||!this.canPersist())return!1;let e=this.getStorage();if(!e)return!1;try{let t=await e.getItem(this.config.key);if(this.isDestroyed||!t)return!1;let i=this.config.deserialize(t);return!i||typeof i!="object"||this.isDestroyed?!1:(this.applyRestoredValues(i),!0)}catch(t){throw this.handleError(t),t}}async clear(){if(!this.canPersist())return;let e=this.getStorage();e&&await this.enqueueWriteOperation(async()=>{try{await e.removeItem(this.config.key)}catch(t){throw this.handleError(t),t}})}destroy(){this.isDestroyed=!0,this.timer&&(clearTimeout(this.timer),this.timer=void 0)}};var ie=class{constructor(e,t){this.plugins=e;this.contextFactory=t}teardownFns=[];notifyingError=!1;pendingErrorQueue=[];cachedContext=null;setupAll(){let e=this.getContext();this.plugins.forEach(t=>{if(t.setup)try{let i=t.setup(e);typeof i=="function"&&this.teardownFns.push(i)}catch(i){this.reportError("setup",i,void 0,t.name)}})}async beforeValidate(e){await this.emitHook("beforeValidate",e)}async afterValidate(e){await this.emitHook("afterValidate",e)}async beforeSubmit(e){await this.emitHook("beforeSubmit",e)}async afterSubmit(e){await this.emitHook("afterSubmit",e)}onFieldChange(e){let t=this.getContext();this.plugins.forEach(i=>{let r=i.hooks?.onFieldChange;if(r)try{let n=r(e,t);Promise.resolve(n).catch(o=>{this.reportError("onFieldChange",o,e,i.name)})}catch(n){this.reportError("onFieldChange",n,e,i.name)}})}async reportError(e,t,i,r){if(this.pendingErrorQueue.push({source:e,pluginName:r,error:t,event:i}),!this.notifyingError){this.notifyingError=!0;try{for(;this.pendingErrorQueue.length>0;){let n=this.pendingErrorQueue.shift();if(!n)break;let o=this.contextFactory().getState(),a={source:n.source,pluginName:n.pluginName,error:n.error,event:n.event,values:o.values,state:o};for(let l of this.plugins){let c=l.hooks?.onError;if(c)try{await c(a,this.contextFactory())}catch{}}}}finally{this.notifyingError=!1}if(this.pendingErrorQueue.length>0){this.notifyingError=!0;try{for(;this.pendingErrorQueue.length>0;){let n=this.pendingErrorQueue.shift();if(!n)break;let o=this.contextFactory().getState(),a={source:n.source,pluginName:n.pluginName,error:n.error,event:n.event,values:o.values,state:o};for(let l of this.plugins){let c=l.hooks?.onError;if(c)try{await c(a,this.contextFactory())}catch{}}}}finally{this.notifyingError=!1}}}}destroy(){for(let e=this.teardownFns.length-1;e>=0;e-=1){let t=this.teardownFns[e];try{t()}catch(i){this.reportError("teardown",i)}}this.teardownFns=[],this.cachedContext=null}async emitHook(e,t){let i=this.getContext();for(let r of this.plugins){let n=r.hooks?.[e];if(n)try{await n(t,i)}catch(o){await this.reportError(e,o,t,r.name)}}}getContext(){return this.cachedContext||(this.cachedContext=this.contextFactory()),this.cachedContext}};var Me=typeof globalThis<"u"?globalThis:typeof global<"u"?global:window;Me.__BIT_FORM__||(Me.__BIT_FORM__={stores:{},listeners:new Set,dispatch(s,e){this.listeners.forEach(t=>{try{t(s,e)}catch{}})},subscribe(s){return this.listeners.add(s),()=>{this.listeners.delete(s)}}});var Re=Me.__BIT_FORM__,Ti={stores:{},listeners:new Set,dispatch:()=>{},subscribe:()=>()=>{}};function Oe(){return Ti}function Pi(){let s=new Set;return{stores:{},listeners:s,dispatch(e,t){s.forEach(i=>{try{i(e,t)}catch{}})},subscribe(e){return s.add(e),()=>s.delete(e)}}}function Ei(s){return s.bus?!0:typeof s.devTools=="boolean"?s.devTools:s.devTools&&typeof s.devTools=="object"?s.devTools.enabled!==!1:!1}function rt(s){let{storeId:e,storeBusPort:t,config:i,getState:r,getConfig:n,getValues:o,getDirtyValues:a,applyPersistedValues:l,setPersistMetadata:c}=s,p=new te(i.persist,o,a,l,{onWriteStart:()=>c?.({isSaving:!0,error:null}),onWriteSuccess:()=>c?.({isSaving:!1,error:null}),onWriteError:b=>c?.({error:b instanceof Error?b:new Error(String(b))}),onWriteSettled:()=>c?.({isSaving:!1}),onError:b=>i.onUnhandledError(b,"persist")}),d=new ie([...i.plugins],()=>({storeId:e,getState:()=>T(r()),getConfig:()=>T(n())})),u=Ei(i),h=typeof process<"u"&&typeof process.env<"u"&&process.env.VITEST==="true",f=u?i.bus??(h?Oe():Re):Oe(),S=new X,g=!1,y=new Z(p);S.register({name:"persist",onStateUpdated:(b,gi)=>y.onStateUpdated(b,gi),restorePersisted:async()=>{if(g)return!1;let b=await y.restorePersisted();return g?!1:b},savePersistedNow:()=>y.savePersistedNow(),clearPersisted:()=>y.clearPersisted(),destroy:()=>{g=!0,y.destroy()}});let B=new ee(d);S.register({name:"plugins",initialize:()=>B.initialize(),beforeValidate:b=>B.beforeValidate(b),afterValidate:b=>B.afterValidate(b),beforeSubmit:b=>B.beforeSubmit(b),afterSubmit:b=>B.afterSubmit(b),onFieldChange:b=>B.onFieldChange(b),reportOperationalError:b=>B.reportOperationalError(b),destroy:()=>B.destroy()});let P=new Q(e,f,u,t);S.register({name:"bus",attachStorePort:b=>P.attachStorePort(b),initialize:()=>P.initialize(),onStateUpdated:b=>P.onStateUpdated(b),destroy:()=>P.destroy()});let R=new Y(S);try{R.initialize()}catch(b){console.error("BitStoreEffects: initialize() failed \u2014 store will operate without initialized effects",b)}return R}function v(s,e,t){return{kind:"state.patch",partialState:s,changedPaths:e,skipComputed:t?.skipComputed}}function je(s){return{kind:"field.touchMany",paths:s}}function re(s){return{kind:"form.persistMeta",patch:s}}function se(s,e){return{kind:"validation.commit",errors:s,isValid:e}}var st=new WeakMap,nt=new WeakMap;function xi(s){let{dispatch:e}=s,t=st,i=nt,r=t.get(e)??0;t.set(e,r+1),r===0&&(i.set(e,null),e(re({isRestoring:!0,error:null})))}function Ci(s){let{dispatch:e,error:t}=s,i=st,r=nt,n=i.get(e)??0;if(n<=0)return;let o=n-1;if(t&&r.set(e,t),o>0){i.set(e,o);let l=r.get(e)??null;l&&e(re({error:l}));return}i.delete(e),t||r.set(e,null);let a=r.get(e)??null;r.delete(e),e(re({isRestoring:!1,error:a}))}async function ot(s){let{dispatch:e,effects:t,onUnhandledError:i}=s;xi({dispatch:e,type:"restoring"});let r=null;try{return await t.restorePersisted()}catch(n){return r=n instanceof Error?n:new Error(String(n)),i?.(r,"persist"),!1}finally{Ci({dispatch:e,type:"restoring",error:r})}}async function at(s){let{effects:e,onUnhandledError:t}=s;try{await e.savePersistedNow()}catch(i){throw t?.(i,"persist"),i}}async function lt(s){let{effects:e,onUnhandledError:t}=s;try{await e.clearPersisted()}catch(i){throw t?.(i,"persist"),i}}function dt(s){let{values:e,state:t,initialValues:i,validation:r,fieldRegistry:n,dirtyManager:o,dispatch:a,saveHistorySnapshot:l}=s,c=T(_e(i,e));r.cancelAll(),n.evaluateAll(c);let p=o.rebuild(c,i);a(v({values:c,errors:{},touched:{},isValidating:{},persist:{...t.persist,error:null},isValid:!1,isDirty:p})),l(),r.validate().catch(d=>{console.error("BitStore: post-persist validation failed \u2014 form values persisted but validation error may be stale",d)})}function ct(s){let{state:e,path:t}=s,i=`${t}.`,r={...e.errors},n={...e.touched},o=!1;for(let a of Object.keys(r))(a===t||a.startsWith(i))&&(delete r[a],o=!0);for(let a of Object.keys(n))(a===t||a.startsWith(i))&&(delete n[a],o=!0);return o?{errors:r,touched:n}:null}function ne(s){let e=[],t=new Map,i=new Set(s.map(a=>a.path));for(let a of s)if(t.has(a.path)||t.set(a.path,new Set),a.dependsOn)for(let l of a.dependsOn)i.has(l)&&t.get(a.path).add(l);let r=new Set,n=new Set,o=(a,l)=>{r.add(a),n.add(a),l.push(a);let c=t.get(a)||new Set;for(let p of c)if(r.has(p)){if(n.has(p)){let d=l.indexOf(p),u=[...l.slice(d),p];return{cycle:u,paths:Array.from(t.keys()).filter(h=>u.includes(h)),message:`Circular dependency detected: ${u.join(" \u2192 ")}. Check your computed field definitions.`}}}else{let d=o(p,[...l]);if(d)return d}return n.delete(a),null};for(let a of t.keys())if(!r.has(a)){let l=o(a,[]);l&&!e.some(c=>c.message===l.message)&&e.push(l)}return e}function ut(s){return!!(s?.computed||s?.normalize)}function pt(s){let{path:e,config:t,state:i,fieldRegistry:r,subscriptions:n,validationCleanupField:o,stateReader:a,invalidateFieldIndexes:l,dispatch:c,getState:p,onUnhandledError:d}=s,u=r.getFieldConfig(e),h=u?.validation?.asyncValidate,f=t.validation?.asyncValidate,S=u?.validation?.asyncValidateOn??"blur",g=t.validation?.asyncValidateOn??"blur";u&&h&&(f!==h||g!==S)&&o(e);let B=!!(u?.computed||t.computed),P=ut(u)||ut(t);if(r.register(e,t,i.values),l(),B){let b=ne(r.getComputedEntries(i.values));if(b.length>0){u?r.register(e,u,i.values):r.unregister(e),l(),n.invalidatePathExpansionCache(e),a.invalidatePath(e),d(new Error(b[0].message),"computed");return}}n.invalidatePathExpansionCache(e),a.invalidatePath(e),P&&c(v({values:i.values},["*"]));let R=p();t.scope&&n.notify(R,[D(t.scope)]),r.isHidden(e)&&n.notify(R,[e])}function ht(s){let{path:e,state:t,hasStaticConfig:i,fieldRegistry:r,subscriptions:n,validationCleanupField:o,invalidateFieldIndexes:a,dispatch:l}=s;if(i)return;let c=r.getFieldConfig(e);o(e),r.unregister(e),a(),n.invalidatePathExpansionCache(e),c?.scope&&n.notify(t,[D(c.scope)]);let p=ct({state:t,path:e});p&&l(v({errors:p.errors,touched:p.touched}))}function oe(s){let{prefix:e,state:t,fieldRegistry:i,subscriptions:r,validationCleanupPrefix:n,invalidateFieldIndexes:o,dispatch:a,hasStaticConfigPath:l}=s;n(e);let c=F(e),p=l??(()=>!1),d=[];i.forEachFieldConfig((y,B)=>{x(B,c)&&(p(B)||d.push(B))});let u=[];d.forEach(y=>{let B=i.getFieldConfig(y);B&&(i.unregister(y),u.push([y,B]))}),o(),r.invalidatePathExpansionCache(e),new Set(u.map(([,y])=>y.scope).filter(y=>!!y)).forEach(y=>{r.notify(t,[D(y)])});let f={...t.errors},S={...t.touched},g=!1;for(let[y]of u)f[y]&&(delete f[y],g=!0),S[y]&&(delete S[y],g=!0);g&&a(v({errors:f,touched:S}))}var Vi="subscription",ae=class{constructor(e,t,i=500){this.getState=e;if(typeof t=="function"){this.onError=t,this.MAX_PATH_EXPANSION_CACHE_SIZE=i;return}this.MAX_PATH_EXPANSION_CACHE_SIZE=t??i}listeners=new Set;pathScopedSubscriptions=new Map;pathSelectorIndex=new Map;pathExpansionCache=new Map;subscriptionSeenVersion=new Map;notifyVersion=0;MAX_PATH_EXPANSION_CACHE_SIZE;cacheHits=0;cacheMisses=0;cacheEvictions=0;onError;subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}subscribeSelector(e,t,i,r){let n=e(this.getState()),o={notify:l=>{try{let c=e(l);if(r(n,c))return;n=c,t(c)}catch(c){this.reportError(c)}}},a=this.normalizeSubscriptionPaths(i.paths);if(this.pathScopedSubscriptions.set(o,a),a.forEach(l=>{this.forEachIndexPath(l,c=>{let p=this.pathSelectorIndex.get(c)??new Set;p.add(o),this.pathSelectorIndex.set(c,p)})}),i.emitImmediately)try{t(n)}catch(l){this.reportError(l)}return()=>{this.subscriptionSeenVersion.delete(o);let l=this.pathScopedSubscriptions.get(o);l&&(l.forEach(c=>{this.forEachIndexPath(c,p=>{let d=this.pathSelectorIndex.get(p);d&&(d.delete(o),d.size===0&&this.pathSelectorIndex.delete(p))})}),this.pathScopedSubscriptions.delete(o))}}notify(e,t){if(this.listeners.forEach(n=>{try{n()}catch(o){this.reportError(o)}}),this.pathScopedSubscriptions.size===0)return;let i=this.normalizeChangedPathIterable(t);if(i.length===0||i.includes("*")){this.notifyScopedSubscribers(this.pathScopedSubscriptions.keys(),e);return}if(i.length===1&&this.isSimplePath(i[0])){let n=this.collectSubscribersForSingleChangedPath(i[0]);this.notifyScopedSubscribers(n,e);return}let r=this.collectSubscribersForChangedPaths(i);this.notifyScopedSubscribers(r,e)}notifyScopedSubscribers(e,t){for(let i of e)try{i.notify(t)}catch(r){this.reportError(r)}}reportError(e){try{if(this.onError){this.onError(e,Vi);return}console.error("Subscription listener error:",e)}catch{}}destroy(){this.listeners.clear(),this.pathScopedSubscriptions.clear(),this.pathSelectorIndex.clear(),this.pathExpansionCache.clear(),this.subscriptionSeenVersion.clear()}getPathExpansionCacheStats(){return{cacheSize:this.pathExpansionCache.size,cacheLimit:this.MAX_PATH_EXPANSION_CACHE_SIZE,cacheHits:this.cacheHits,cacheMisses:this.cacheMisses,cacheEvictions:this.cacheEvictions}}getActiveSubscribersCount(){return this.pathScopedSubscriptions.size}invalidatePathExpansionCache(e){if(!e){this.pathExpansionCache.clear();return}let t=F(e);if(t.length===0){this.pathExpansionCache.clear();return}for(let i of this.pathExpansionCache.keys())(x(i,t)||x(t,i))&&this.pathExpansionCache.delete(i)}normalizeSubscriptionPaths(e){if(!e||e.length===0)return[];let t=new Set,i=[];for(let r of e){if(r==null)continue;let n=r.trim();n.length===0||t.has(n)||(t.add(n),i.push(n))}return i}normalizeChangedPathIterable(e){if(!e)return[];let t=new Set,i=[];for(let r of e){if(r==null)continue;let n=r.trim();n.length===0||t.has(n)||(t.add(n),i.push(n))}return i}collectSubscribersForChangedPaths(e){let t=[];this.notifyVersion=this.notifyVersion+1|0;let i=this.notifyVersion,r=n=>{let o=this.pathSelectorIndex.get(n);o&&o.forEach(a=>{(this.subscriptionSeenVersion.get(a)??Number.NaN)!==i&&(this.subscriptionSeenVersion.set(a,i),t.push(a))})};return e.forEach(n=>{this.forEachLookupPath(n,r)}),t}collectSubscribersForSingleChangedPath(e){let t=[];this.notifyVersion=this.notifyVersion+1|0;let i=this.notifyVersion,r=n=>{let o=this.pathSelectorIndex.get(n);o&&o.forEach(a=>{(this.subscriptionSeenVersion.get(a)??Number.NaN)!==i&&(this.subscriptionSeenVersion.set(a,i),t.push(a))})};return this.forEachLookupPath(e,r),t}expandChangedPathForLookup(e){return this.expandPathGeneric(e)}expandPathForIndexing(e){return this.expandPathGeneric(e)}forEachIndexPath(e,t){if(!this.isSimplePath(e)){this.expandPathForIndexing(e).forEach(t);return}let i=e.split("."),r="";for(let n=0;n<i.length;n+=1)r=r?`${r}.${i[n]}`:i[n],t(r)}forEachLookupPath(e,t){if(!this.isSimplePath(e)){this.expandChangedPathForLookup(e).forEach(t);return}t(e);let i=e.lastIndexOf(".");for(;i>-1;)t(e.slice(0,i)),i=e.lastIndexOf(".",i-1)}isSimplePath(e){return!e.includes("*")&&!e.includes("[")&&!e.includes("]")}expandPathGeneric(e){let t=this.pathExpansionCache.get(e);if(t)return this.cacheHits+=1,t;this.cacheMisses+=1;let i=e.split("."),r=[];for(let n=1;n<=i.length;n++)r.push(i.slice(0,n).join("."));return this.setBoundedCacheEntry(this.pathExpansionCache,e,r,this.MAX_PATH_EXPANSION_CACHE_SIZE),r}setBoundedCacheEntry(e,t,i,r){if(e.size>=r){let n=e.keys().next().value;n!==void 0&&(e.delete(n),this.cacheEvictions+=1)}e.set(t,i)}};var le=class{constructor(e){this.store=e}pathIds=new Map;getItemIds(e,t){let i=typeof t=="number"?Math.max(0,t):this.getCurrentArrayLength(e);return[...this.ensureIds(e,i)]}pushItem(e,t){this.withPathIds(e,i=>(i.push(this.store.createArrayItemId(e,i.length)),i)),this.store.unregisterPrefix?.(C(e)),this.commitArrayMutationWithFieldPipeline({path:e,nextArray:[...m(this.store.getState().values,e)??[],t],meta:{origin:"array",operation:"push"},reindex:i=>i})}prependItem(e,t){this.withPathIds(e,r=>(r.unshift(this.store.createArrayItemId(e,0)),r)),this.store.unregisterPrefix?.(C(e));let i=m(this.store.getState().values,e)??[];this.commitArrayMutationWithFieldPipeline({path:e,nextArray:[t,...i],meta:{origin:"array",operation:"prepend"},reindex:r=>r+1})}insertItem(e,t,i){let r=this.getCurrentArrayLength(e),n=Math.max(0,Math.min(t,r));if(this.withPathIds(e,l=>{let c=[...l];return c.splice(n,0,this.store.createArrayItemId(e,n)),c}),this.store.unregisterPrefix)for(let l=n;l<r;l++)this.store.unregisterPrefix(C(e,l));let a=[...m(this.store.getState().values,e)??[]];a.splice(n,0,i),this.commitArrayMutationWithFieldPipeline({path:e,nextArray:a,meta:{origin:"array",operation:"insert",index:n},reindex:l=>l<n?l:l+1})}removeItem(e,t){let i=this.store.getState(),r=m(i.values,e);if(!Array.isArray(r)||t<0||t>=r.length)return;this.withPathIds(e,o=>{let a=[...o];return a.splice(t,1),a}),this.store.unregisterPrefix&&this.store.unregisterPrefix(C(e,t));let n=r.filter((o,a)=>a!==t);this.commitArrayMutationWithFieldPipeline({path:e,nextArray:n,meta:{origin:"array",operation:"remove",index:t},reindex:o=>o===t?null:o>t?o-1:o})}swapItems(e,t,i){let r=this.store.getState(),n=m(r.values,e);if(!Array.isArray(n)||t<0||t>=n.length||i<0||i>=n.length)return;this.withPathIds(e,a=>{let l=[...a];return[l[t],l[i]]=[l[i],l[t]],l});let o=[...n];[o[t],o[i]]=[o[i],o[t]],this.store.unregisterPrefix&&(this.store.unregisterPrefix(C(e,t)),this.store.unregisterPrefix(C(e,i))),this.commitArrayMutationWithFieldPipeline({path:e,nextArray:o,meta:{origin:"array",operation:"swap",from:t,to:i},reindex:a=>a===t?i:a===i?t:a})}moveItem(e,t,i){let r=this.store.getState(),n=m(r.values,e);if(!Array.isArray(n)||t<0||t>=n.length||i<0||i>=n.length)return;this.withPathIds(e,l=>{let c=[...l],[p]=c.splice(t,1);return c.splice(i,0,p),c});let o=[...n],[a]=o.splice(t,1);if(o.splice(i,0,a),this.store.unregisterPrefix){let l=Math.min(t,i),c=Math.max(t,i);for(let p=l;p<=c;p+=1)this.store.unregisterPrefix(C(e,p))}this.commitArrayMutationWithFieldPipeline({path:e,nextArray:o,meta:{origin:"array",operation:"move",from:t,to:i},reindex:l=>l===t?i:t<i&&l>t&&l<=i?l-1:t>i&&l>=i&&l<t?l+1:l})}replaceItems(e,t){this.store.unregisterPrefix?.(C(e)),t.length===0?this.pathIds.delete(e):this.pathIds.set(e,t.map((i,r)=>this.store.createArrayItemId(e,r))),this.commitArrayMutationWithFieldPipeline({path:e,nextArray:t,meta:{origin:"array",operation:"replace"},reindex:i=>i<t.length?i:null})}clearItems(e){this.pathIds.delete(e),this.store.unregisterPrefix&&this.store.unregisterPrefix(C(e)),this.commitArrayMutationWithFieldPipeline({path:e,nextArray:[],meta:{origin:"array",operation:"clear"},reindex:()=>null})}mutateArrayWithSetField(e,t,i){let r=m(this.store.getState().values,e)||[];this.store.setFieldWithMeta(e,t(r),i),this.store.internalSaveSnapshot()}withPathIds(e,t){let i=this.getCurrentArrayLength(e),r=this.ensureIds(e,i),n=t(r);n.length===0?this.pathIds.delete(e):this.pathIds.set(e,n)}ensureIds(e,t){let i=this.pathIds.get(e)??[];if(i.length===t)return i;if(i.length<t){let n=[...i];for(let o=i.length;o<t;o+=1)n.push(this.store.createArrayItemId(e,o));return this.pathIds.set(e,n),n}let r=i.slice(0,t);return r.length===0?this.pathIds.delete(e):this.pathIds.set(e,r),r}getCurrentArrayLength(e){let t=m(this.store.getState().values,e);return Array.isArray(t)?t.length:0}commitArrayMutationWithFieldPipeline(e){let{path:t,nextArray:i,meta:r,reindex:n}=e,o=this.store.getState();this.store.setFieldWithMeta(t,i,r);let a=Ne(o,t,n);this.store.remapValidationPaths?.(t,n),this.store.dispatch(v({errors:a.errors,touched:a.touched,isValidating:a.isValidating},[t])),this.store.internalSaveSnapshot()}};var de=class{constructor(e,t,i){this.getState=e;this.dispatch=t;this.reportError=i}reportInvalidInput(e,t){this.reportError?.(new Error(t===void 0?e:`${e}: ${String(t)}`))}setError(e,t){if(!e||typeof e!="string"){this.reportInvalidInput("setError received an invalid path",e);return}if(t!==void 0&&typeof t!="string"){this.reportInvalidInput("setError received an invalid message",t);return}let i={...this.getState().errors,[e]:t};t===void 0&&delete i[e],this.dispatch(v({errors:i}))}setErrors(e){if(!e||typeof e!="object"){this.reportInvalidInput("setErrors received an invalid payload");return}let t={};Object.entries(e).forEach(([i,r])=>{if(!i){this.reportInvalidInput("setErrors ignored an empty path");return}if(r!==void 0&&typeof r!="string"){this.reportInvalidInput("setErrors ignored a non-string message",i);return}t[i]=r}),this.dispatch(v({errors:{...this.getState().errors,...t}}))}setServerErrors(e,t){let i=t?.arrayStrategy??"first",r=t?.joinSeparator??"; ",n={};for(let[o,a]of Object.entries(e)){if(!o){this.reportInvalidInput("setServerErrors ignored an empty path");continue}if(Array.isArray(a)){let l=a.filter(c=>typeof c=="string"&&c.length>0);if(l.length===0)continue;n[o]=i==="join"?l.join(r):l[0];continue}n[o]=a}this.setErrors(n)}};var ce=class{constructor(e,t,i){this.fieldMetadataProvider=e;this.getState=t;this.isPathDirty=i}requiredValuesRef=null;isHidden(e){return this.fieldMetadataProvider.isHidden(e)}isRequired(e){let t=this.getState().values;return this.requiredValuesRef!==t&&(this.requiredValuesRef=t),this.fieldMetadataProvider.isRequired(e,t)}isFieldDirty(e){return this.isPathDirty(e)}isFieldValidating(e){return!!this.getState().isValidating[e]}isTouched(e){return!!this.getState().touched[e]}};function ft(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)&&!(s instanceof Date)&&!(s instanceof RegExp)}function gt(s,e){let t=[],i=new Map,r=(n,o,a,l,c)=>{if(!(l&&c&&I(n,o))){if(n!==null&&typeof n=="object"&&o!==null&&typeof o=="object"){let p=i.get(n);if(p?.has(o))return;p?p.add(o):i.set(n,new Set([o]))}try{if(ft(n)&&ft(o)&&l&&c){let p=new Set([...Object.keys(n),...Object.keys(o)]);for(let d of p){let u=a?`${a}.${d}`:d,h=Object.prototype.hasOwnProperty.call(n,d),f=Object.prototype.hasOwnProperty.call(o,d);r(n[d],o[d],u,h,f)}return}t.push({path:a,previousValue:T(n),nextValue:T(o),hadPreviousValue:l,hasNextValue:c})}finally{if(n!==null&&typeof n=="object"&&o!==null&&typeof o=="object"){let p=i.get(n);p?.delete(o),p&&p.size===0&&i.delete(n)}}}};return r(s,e,"",!0,!0),{operations:t}}function ue(s,e,t){let i=s,r=[],n=[];for(let o of e.operations){let a=t==="undo"?o.hadPreviousValue:o.hasNextValue,l=t==="undo"?o.previousValue:o.nextValue;if(!o.path){i=a?l:{},r.length=0,n.length=0;continue}if(a){r.push([o.path,l]);continue}n.push(o.path)}return r.length>0&&(i=A(i,r)),n.length>0&&(i=We(i,n)),i}var pe=class{constructor(e,t){this.enableHistory=e;this.maxHistory=t}baseSnapshot=null;currentSnapshot=null;patches=[];historyIndex=-1;historySize=0;saveSnapshot(e){if(!this.enableHistory)return;if(!this.currentSnapshot||this.baseSnapshot===null){this.reset(e);return}let t=gt(this.currentSnapshot,e);if(t.operations.length!==0)for(this.historyIndex<this.historySize-1&&(this.patches.splice(this.historyIndex),this.historySize=this.historyIndex+1),this.patches.push(t),this.currentSnapshot=e,this.historyIndex+=1,this.historySize=this.historyIndex+1;this.historySize>this.getCapacity();)this.compactOldestSnapshot()}get canUndo(){return this.enableHistory?this.historyIndex>0:!1}get canRedo(){return this.enableHistory?this.historyIndex<this.historySize-1:!1}undo(){if(!this.canUndo||!this.currentSnapshot)return null;let e=this.patches[this.historyIndex-1],t=ue(this.currentSnapshot,e,"undo");return this.currentSnapshot=t,this.historyIndex-=1,t}redo(){if(!this.canRedo||!this.currentSnapshot)return null;let e=this.patches[this.historyIndex],t=ue(this.currentSnapshot,e,"redo");return this.currentSnapshot=t,this.historyIndex+=1,t}reset(e){if(!this.enableHistory){this.baseSnapshot=null,this.currentSnapshot=null,this.patches=[],this.historyIndex=-1,this.historySize=0;return}this.baseSnapshot=T(e),this.currentSnapshot=this.baseSnapshot,this.patches=[],this.historyIndex=0,this.historySize=1}getMetadata(){return{enabled:this.enableHistory,canUndo:this.canUndo,canRedo:this.canRedo,historyIndex:this.historyIndex,historySize:this.historySize}}compactOldestSnapshot(){let e=this.patches.shift();!e||this.baseSnapshot===null||(this.baseSnapshot=ue(this.baseSnapshot,e,"redo"),this.historySize=Math.max(1,this.historySize-1),this.historyIndex=Math.max(0,this.historyIndex-1))}getCapacity(){return Math.max(1,this.maxHistory)}};function He(s,e,t){if(!Object.prototype.hasOwnProperty.call(s,e))return[s,t];let r=s,n=t;return n||(r={...s},n=!0),delete r[e],[r,n]}var M=class{constructor(e){this.steps=e}async run(e){for(let t of this.steps){if(e.halted)break;await t.run(e)}}},he=class{constructor(e){this.steps=e}run(e){for(let t of this.steps){if(e.halted)break;let i=t.run(e);if(i!=null&&typeof i.then=="function")throw new Error(`BitSyncPipelineRunner: step "${t.name}" returned a Promise. Use BitPipelineRunner for async steps.`)}}};var fe=class{constructor(e){this.store=e;this.fieldUpdatePipeline=new he([{name:"field:clear-current-error",run:t=>this.clearCurrentError(t)},{name:"field:update-dependencies",run:t=>this.updateDependencies(t)},{name:"field:update-dirty",run:t=>this.updateDirtyState(t)},{name:"field:commit-state",run:t=>this.commitFieldState(t)},{name:"field:emit-change",run:t=>this.emitFieldChange(t)},{name:"field:trigger-validate",run:t=>this.triggerResolverValidation(t)},{name:"field:trigger-async-validate",run:t=>this.triggerAsyncValidation(t)}])}fieldUpdatePipeline;updateField(e,t,i={origin:"setField"}){let r=this.store.getState(),n=m(r.values,e),o={path:e,value:t,meta:i,previousValue:n,nextValues:w(r.values,e,t),nextErrors:r.errors,hasMutatedErrors:!1,dependencyDiff:{affectedFields:[],visibilityChanged:[],requiredChanged:[]},isDirty:!1};this.fieldUpdatePipeline.run(o)}clearCurrentError(e){[e.nextErrors,e.hasMutatedErrors]=He(e.nextErrors,e.path,e.hasMutatedErrors),this.store.clearFieldValidation(e.path)}updateDependencies(e){if(typeof this.store.hasDependentFields=="function"&&!this.store.hasDependentFields(e.path)){e.dependencyDiff.affectedFields.length=0,e.dependencyDiff.visibilityChanged.length=0,e.dependencyDiff.requiredChanged.length=0;return}e.dependencyDiff=this.store.updateDependencies(e.path,this.store.getState().values,e.nextValues),new Set([...e.dependencyDiff.visibilityChanged,...e.dependencyDiff.requiredChanged]).forEach(i=>{[e.nextErrors,e.hasMutatedErrors]=He(e.nextErrors,i,e.hasMutatedErrors),this.store.clearFieldValidation(i)})}updateDirtyState(e){e.isDirty=this.store.updateDirtyForPath(e.path,e.nextValues,this.store.getBaselineValues())}commitFieldState(e){let t=Array.from(new Set([e.path,...e.dependencyDiff.visibilityChanged,...e.dependencyDiff.requiredChanged]));this.store.dispatch(v({values:e.nextValues,errors:e.nextErrors,isDirty:e.isDirty},t))}emitFieldChange(e){this.store.emitFieldChange({path:e.path,previousValue:e.previousValue,nextValue:e.value,values:this.store.getState().values,state:this.store.getState(),meta:e.meta})}triggerResolverValidation(e){let t=Array.from(new Set([e.path,...e.dependencyDiff.visibilityChanged,...e.dependencyDiff.requiredChanged]));(this.store.config.resolver||e.dependencyDiff.visibilityChanged.length>0||e.dependencyDiff.requiredChanged.length>0)&&this.store.triggerValidation(t)}triggerAsyncValidation(e){this.store.isFieldHidden(e.path)||(typeof this.store.getFieldConfig=="function"?this.store.getFieldConfig(e.path)?.validation?.asyncValidateOn:void 0)!=="change"||this.store.handleFieldAsyncValidation(e.path,e.value)}};var ge=class{executors=new Map;register(e,t){let i=this.executors.get(e)??[];i.push(t),this.executors.set(e,i)}async execute(e){let t=this.getOrderedExecutors(e.kind);for(let i of t)await i.execute(e)}executeSync(e){let t=this.getOrderedExecutors(e.kind);for(let i of t){let r=i.execute(e);if(r&&typeof r.then=="function")throw new Error(`BitLifecycleOrchestrator: executor async em modo sync para kind "${e.kind}".`)}}getOrderedExecutors(e){return[...this.executors.get(e)??[]].sort((i,r)=>i.phase-r.phase)}};var ye=class{constructor(e){this.store=e;this.submitPipeline=new M([{name:"submit:start",run:async t=>this.startSubmit(t)},{name:"submit:invalid",run:async t=>this.handleInvalidSubmit(t)},{name:"submit:prepare",run:t=>this.prepareSubmitValues(t)},{name:"submit:before-hooks",run:async t=>this.runBeforeSubmitHooks(t)},{name:"submit:user-handler",run:async t=>this.runSubmitHandler(t)},{name:"submit:after-hooks",run:async t=>this.runAfterSubmitHooks(t)}])}submitPipeline;async submit(e){if(this.store.getState().isSubmitting)return{status:"blocked",reason:"isSubmitting"};if(this.store.hasValidationsInProgress())return{status:"blocked",reason:"validating"};this.store.cancelAllValidations();let i={onSuccess:e,isValid:!1,valuesToSubmit:T(this.store.getState().values),dirtyValues:{}};try{return await this.submitPipeline.run(i),i.invalid?{status:"invalid"}:{status:"submitted"}}catch(r){return i.error=r,await this.store.emitOperationalError({source:"submit",error:r}),await this.store.emitAfterSubmit({values:i.valuesToSubmit,dirtyValues:i.dirtyValues,state:this.store.getState(),success:!1,error:r}),this.store.config.onUnhandledError(r,"submit"),{status:"failed",error:r}}finally{this.store.dispatch(v({isSubmitting:!1}))}}async startSubmit(e){this.store.dispatch(v({isSubmitting:!0})),e.isValid=await this.store.validateNow()}async handleInvalidSubmit(e){if(e.isValid)return;let t=this.store.getState().errors,i={...this.store.getState().touched};Object.keys(t).forEach(r=>{i[r]=!0}),this.store.batchStateUpdates(()=>{this.store.dispatch(v({touched:i}))}),e.dirtyValues=this.store.buildDirtyValues(this.store.getState().values),e.invalid=!0,await this.store.emitAfterSubmit({values:this.store.getState().values,dirtyValues:e.dirtyValues,state:this.store.getState(),success:!1,invalid:!0}),e.halted=!0}prepareSubmitValues(e){let t=[],i=this.store.getHiddenFields();i.forEach(r=>{t.push([r,void 0])}),t.length>0&&(e.valuesToSubmit=A(e.valuesToSubmit,t)),e.valuesToSubmit=it({values:e.valuesToSubmit,sourceValues:e.valuesToSubmit,transformEntries:this.store.getTransformEntries().filter(([r])=>!i.has(r)),onError:r=>{throw r}}),e.dirtyValues=this.store.buildDirtyValues(e.valuesToSubmit)}async runBeforeSubmitHooks(e){await this.store.emitBeforeSubmit({values:e.valuesToSubmit,dirtyValues:e.dirtyValues,state:this.store.getState()})}async runSubmitHandler(e){try{await e.onSuccess(e.valuesToSubmit,e.dirtyValues)}catch(t){if(Ke(t)){this.store.setServerErrors($e(t)),await this.store.emitAfterSubmit({values:e.valuesToSubmit,dirtyValues:e.dirtyValues,state:this.store.getState(),success:!1,invalid:!0}),e.invalid=!0,e.halted=!0;return}throw t}}async runAfterSubmitHooks(e){await this.store.emitAfterSubmit({values:e.valuesToSubmit,dirtyValues:e.dirtyValues,state:this.store.getState(),success:!0})}};var me=class{constructor(e){this.store=e}collectChangedUpdates(e,t="",i=[],r=new WeakSet){if(e&&typeof e=="object"){if(r.has(e))return i;r.add(e)}try{Object.entries(e).forEach(([n,o])=>{let a=t?`${t}.${n}`:n;if(o&&typeof o=="object"&&!Array.isArray(o)&&Object.keys(o).length>0){if(r.has(o))return;this.collectChangedUpdates(o,a,i,r);return}i.push([a,o])})}finally{e&&typeof e=="object"&&r.delete(e)}return i}setValues(e,t){if(t?.rebase){this.rebaseValues(e);return}if(t?.partial){this.hydrateValues(e);return}this.replaceValuesInternal(e,"replaceValues")}hydrateValues(e){let t=this.collectChangedUpdates(e),i=t.map(([n])=>n),r=t.length>0?A(this.store.getState().values,t):this.store.getState().values;this.replaceValuesInternal(r,"hydrate",i.length>0?i:["*"])}rebaseValues(e){let t=this.store.getState().values,i=T(e);this.store.setBaselineValues(i),this.store.cancelAllValidations(),this.store.evaluateAllDependencies(i),this.store.clearDirtyState(),this.store.dispatch(v({values:i,errors:{},touched:{},isValidating:{},isValid:!1,isDirty:!1},["*"])),this.store.resetHistory(i),this.store.validateNow().catch(r=>{this.store.config?.onUnhandledError(r,"rebaseValues")}),this.store.emitFieldChange({path:"*",previousValue:t,nextValue:i,values:this.store.getState().values,state:this.store.getState(),meta:{origin:"rebase"}})}applyHistoryState(e){this.store.cancelAllValidations();let t=this.store.rebuildDirtyState(e,this.store.getBaselineValues());this.store.dispatch(v({values:e,errors:{},isValid:!1,isDirty:t},["*"])),this.store.validateNow().catch(i=>{this.store.config?.onUnhandledError(i,"applyHistoryState")})}reset(){this.store.cancelAllValidations();let e=T(this.store.getBaselineValues());this.store.evaluateAllDependencies(e),this.store.clearDirtyState(),this.store.dispatch(v({values:e,errors:{},touched:{},isValidating:{},isValid:!1,isDirty:!1},["*"])),this.store.resetHistory(e)}replaceValuesInternal(e,t="replaceValues",i=["*"]){let r=this.store.getState().values,n=T(e);this.store.cancelAllValidations(),this.store.evaluateAllDependencies(n);let o=this.store.rebuildDirtyState(n,this.store.getBaselineValues());this.store.dispatch(v({values:n,errors:{},isValidating:{},isValid:!1,isDirty:o},i)),this.store.internalSaveSnapshot(),this.store.validateNow().catch(a=>{this.store.config?.onUnhandledError(a,"replaceValuesInternal")}),this.store.emitFieldChange({path:"*",previousValue:r,nextValue:n,values:this.store.getState().values,state:this.store.getState(),meta:{origin:t}})}};var Se=class{constructor(e){this.ports=e;this.fieldUpdate=new fe(e.fieldUpdate),this.values=new me(e.values),this.submitFlow=new ye(e.submit),this.orchestrator.register("updateField",{phase:1,execute:t=>this.fieldUpdate.updateField(t.path,t.value,t.meta??{origin:"setField"})}),this.orchestrator.register("setValues",{phase:2,execute:t=>this.values.setValues(t.newValues,t.options)}),this.orchestrator.register("hydrateValues",{phase:2,execute:t=>this.values.hydrateValues(t.newValues)}),this.orchestrator.register("rebaseValues",{phase:2,execute:t=>this.values.rebaseValues(t.newValues)}),this.orchestrator.register("applyHistoryState",{phase:2,execute:t=>this.values.applyHistoryState(t.snapshot)}),this.orchestrator.register("submit",{phase:3,execute:async t=>{t.submitResult=await this.submitFlow.submit(t.onSuccess)}}),this.orchestrator.register("reset",{phase:4,execute:()=>this.values.reset()})}fieldUpdate;values;submitFlow;orchestrator=new ge;updateField(e,t,i={origin:"setField"}){this.orchestrator.executeSync({kind:"updateField",path:e,value:t,meta:i})}setValues(e,t){this.orchestrator.executeSync({kind:"setValues",newValues:e,options:t})}hydrateValues(e){this.orchestrator.executeSync({kind:"hydrateValues",newValues:e})}rebaseValues(e){this.orchestrator.executeSync({kind:"rebaseValues",newValues:e})}applyHistoryState(e){this.orchestrator.executeSync({kind:"applyHistoryState",snapshot:e})}async submit(e){let t={kind:"submit",onSuccess:e};return await this.orchestrator.execute(t),t.submitResult}reset(){this.orchestrator.executeSync({kind:"reset"})}};var be=class{constructor(e,t,i,r){this.getState=e;this.getInitialValues=t;this.getScopeFields=i;this.isPathDirty=r}getScopeStatus(e){let t=this.getScopeFields(e),i=this.getState(),r=t.some(a=>!!i.errors[a]),n=t.some(a=>this.isPathDirty(a)),o=this.getScopeErrors(e);return{hasErrors:r,isDirty:n,errors:o}}getScopeErrors(e){let t=this.getScopeFields(e),i=this.getState(),r={};for(let n of t){let o=i.errors[n];o&&(r[n]=o)}return r}};var yt=Symbol("bit.async.validation.timeout"),ve=class{constructor(e){this.port=e}_cancellingAll=!1;cancelSchedulerTimeout;abortControllers=new Map;pendingJobs=new Map;handle(e,t,i,r,n){if(!i){this.cancel(e),this.port.setFieldValidating(e,!1);return}this.cancel(e),this.port.clearAsyncError(e),this.port.setFieldValidating(e,!0);let o=new AbortController;this.abortControllers.set(e,o),this.pendingJobs.set(e,{value:t,dueAt:Date.now()+r,validate:i,controller:o,timeoutMs:n}),this.schedulePendingJobs()}cancel(e){this.cancelInternal(e,!0)}cancelInternal(e,t){this.pendingJobs.has(e)&&(this.pendingJobs.delete(e),t&&this.schedulePendingJobs());let i=this.abortControllers.get(e);i&&(i.abort(),this.abortControllers.delete(e))}cleanupPrefix(e){let t=!1,i=new Set([...this.pendingJobs.keys(),...this.abortControllers.keys()]);for(let r of i)x(r,e)&&(this.cancelInternal(r,!1),t=!0,this.port.clearAsyncError(r),this.port.setFieldValidating(r,!1));t&&this.schedulePendingJobs()}remapPaths(e){let t=!1,i=new Map;for(let[n,o]of this.pendingJobs.entries()){let a=e(n);if(!a){o.controller.abort(),t=!0;continue}a!==n&&(t=!0),i.set(a,o)}let r=new Map;for(let[n,o]of this.abortControllers.entries()){let a=e(n);if(!a){o.abort();continue}r.set(a,o)}this.pendingJobs.clear(),i.forEach((n,o)=>{this.pendingJobs.set(o,n)}),this.abortControllers.clear(),r.forEach((n,o)=>{this.abortControllers.set(o,n)}),t&&this.schedulePendingJobs()}cancelAll(){this._cancellingAll=!0;try{if(this.cancelSchedulerTimeout)try{this.cancelSchedulerTimeout()}catch{}finally{this.cancelSchedulerTimeout=void 0}this.abortControllers.forEach((e,t)=>{try{e.abort()}catch{}this.port.setFieldValidating(t,!1)}),this.pendingJobs.forEach((e,t)=>{this.port.setFieldValidating(t,!1)}),this.pendingJobs.clear(),this.abortControllers.clear()}finally{this._cancellingAll=!1}}schedulePendingJobs(){this.cancelSchedulerTimeout&&(this.cancelSchedulerTimeout(),this.cancelSchedulerTimeout=void 0);let e=Number.POSITIVE_INFINITY;for(let t of this.pendingJobs.values())t.dueAt<e&&(e=t.dueAt);Number.isFinite(e)&&(this.cancelSchedulerTimeout=this.port.schedule(()=>{this.cancelSchedulerTimeout=void 0,this.flushPendingJobs().catch(t=>{this.port.onError(t)})},Math.max(0,e-Date.now())))}async flushPendingJobs(){this.cancelSchedulerTimeout=void 0;let e=Date.now(),t=[];for(let[r,n]of this.pendingJobs.entries())n.dueAt<=e&&t.push([r,n]);if(t.length===0){this.schedulePendingJobs();return}t.forEach(([r])=>{this.pendingJobs.delete(r)});let i=await Promise.allSettled(t.map(([r,n])=>this.runJob(r,n)));for(let r of i)r.status==="rejected"&&this.port.onError(r.reason);this.schedulePendingJobs()}async runJob(e,t){if(!t.controller.signal.aborted)try{let i=t.validate(t.value,this.port.getValues());if(typeof t.timeoutMs=="number"&&t.timeoutMs>0){let o;i=Promise.race([i,new Promise(a=>{o=setTimeout(()=>a(yt),t.timeoutMs)})]).finally(()=>{o&&clearTimeout(o)})}let r=await i;if(t.controller.signal.aborted)return;let n=m(this.port.getValues(),e);if(!E(n,t.value)||r===yt)return;r!=null?this.port.setAsyncError(e,r):(this.port.clearAsyncError(e),await this.port.onValidationPassed(e))}finally{let i=this.findControllerPath(t.controller)??e;this._cancellingAll||this.port.setFieldValidating(i,!1),this.abortControllers.get(i)===t.controller&&this.abortControllers.delete(i)}}findControllerPath(e){for(let[t,i]of this.abortControllers.entries())if(i===e)return t}};function k(s){for(let e of Object.keys(s))if(s[e]!==void 0)return!0;return!1}async function Ue(s){let{scopeFields:e,store:t,asyncErrors:i}=s,r=t.getState(),n=new Set(t.getHiddenFields()),o=t.config.resolver?await t.config.resolver(r.values,{scopeFields:e}):{},a=t.getState(),l=e.some(f=>!E(m(r.values,f),m(a.values,f))),c=t.getHiddenFields(),p=e.some(f=>n.has(f)!==c.has(f));if(l||p)return;let d=t.getRequiredErrors(a.values),u={...o,...d};c.forEach(f=>{delete u[f]});let h={...a.errors};e.forEach(f=>{u[f]?h[f]=u[f]:i.has(f)?h[f]=i.get(f):delete h[f]}),t.dispatch(se(h,!k(h)&&!k(a.errors)))}var Be=class{currentValidationId=0;immediateAbortControllers=new Map;beginValidation(){return this.currentValidationId+=1,this.currentValidationId}getCurrentValidationId(){return this.currentValidationId}isValidationCurrent(e){return e===this.currentValidationId}setImmediateController(e,t){this.immediateAbortControllers.set(e,t)}clearImmediateController(e,t){return this.immediateAbortControllers.get(e)===t?(this.immediateAbortControllers.delete(e),!0):!1}cancelImmediate(e){let t=this.immediateAbortControllers.get(e);t&&(t.abort(),this.immediateAbortControllers.delete(e))}cancelImmediatePrefix(e,t){for(let i of this.immediateAbortControllers.keys())x(i,e)&&(this.cancelImmediate(i),t(i))}remapImmediateControllers(e){let t=new Map;for(let[i,r]of this.immediateAbortControllers.entries()){let n=e(i);if(!n){r.abort();continue}t.set(n,r)}this.immediateAbortControllers.clear(),t.forEach((i,r)=>{this.immediateAbortControllers.set(r,i)})}cancelAllImmediate(){this.immediateAbortControllers.forEach(e=>{e.abort()}),this.immediateAbortControllers.clear()}};var Te=class{constructor(e){this.port=e}cancelTimeout;pendingScopeFields=null;isGlobalPending=!1;trigger(e,t){this.cancelTimeout&&(this.cancelTimeout(),this.cancelTimeout=void 0);let i=this.port.validationDelay??300,r=t?.forceDebounce?Math.max(1,i):i;if(r>0){if(!e||e.length===0)this.pendingScopeFields=null,this.isGlobalPending=!0;else if(!this.isGlobalPending)if(!this.pendingScopeFields)this.pendingScopeFields=new Set(e);else for(let n of e)this.pendingScopeFields.add(n);this.cancelTimeout=this.port.schedule(()=>{let n=this.pendingScopeFields?Array.from(this.pendingScopeFields):void 0;this.pendingScopeFields=null,this.isGlobalPending=!1,this.cancelTimeout=void 0,this.validateWithOptionalScopeFields(n)},r)}else{let n=e;if(this.isGlobalPending)n=void 0;else if(this.pendingScopeFields){if(e)for(let o of e)this.pendingScopeFields.add(o);n=Array.from(this.pendingScopeFields)}this.pendingScopeFields=null,this.isGlobalPending=!1,this.validateWithOptionalScopeFields(n)}}validateWithOptionalScopeFields(e){return e&&e.length>0?this.port.validate({scopeFields:e}):this.port.validate()}cancelPending(){this.cancelTimeout&&(this.cancelTimeout(),this.cancelTimeout=void 0),this.pendingScopeFields=null,this.isGlobalPending=!1}};var mt=Symbol("bit.async.validation.timeout");function St(s){let{targetFields:e,currentErrors:t,allErrors:i,asyncErrors:r,hiddenFields:n}=s;if(e&&e.length>0){let a=t,l=!1,c=()=>(l||(a={...t},l=!0),a);e.forEach(d=>{let u=d,h=t[u];if(n?.has(d)){h!==void 0&&delete c()[u];return}if(i[d]!==void 0)h!==i[d]&&(c()[u]=i[d]);else if(r.has(d)){let f=r.get(d);h!==f&&(c()[u]=f)}else h!==void 0&&delete c()[u]});let p=e.every(d=>n?.has(d)||i[d]===void 0&&!r.has(d));return{committedErrors:l?a:t,result:p,mode:"scoped"}}let o={};return r.forEach((a,l)=>{n?.has(l)||(o[l]=a)}),Object.entries(i).forEach(([a,l])=>{l!==void 0&&(o[a]=l)}),{committedErrors:o,result:void 0,mode:"global"}}function bt(s){let{targetFields:e,hiddenFields:t,getFieldConfig:i,forEachFieldConfig:r}=s,n=[];if(e&&e.length>0){for(let o of e){if(t.has(o))continue;i(o)?.validation?.asyncValidate&&n.push(o)}return n}return r&&r((o,a)=>{!o.validation?.asyncValidate||t.has(a)||n.push(a)}),n}async function vt(s){let{path:e,values:t,validationId:i,getCurrentValidationId:r,getFieldConfig:n,cancelFieldAsync:o,createAbortController:a,setAbortController:l,clearAbortController:c,setFieldValidating:p,setAsyncError:d,clearAsyncError:u}=s,h=n(e)?.validation?.asyncValidate;if(!h){u(e);return}o(e),u(e);let f=a();l(e,f),p(e,!0);try{let S=n(e)?.validation?.asyncValidateTimeout,g=h(m(t,e),t);if(typeof S=="number"&&S>0){let B;g=Promise.race([g,new Promise(P=>{B=setTimeout(()=>P(mt),S)})]).finally(()=>{B&&clearTimeout(B)})}let y=await g;if(f.signal.aborted||i!==r())return;y===mt||(y!=null?d(e,y):u(e))}finally{c(e,f)&&p(e,!1)}}function Bt(s){let{ctx:e,deps:t}=s,i=e.options;if(i?.scope&&i.scopeFields?.length){t.store.config.onUnhandledError(new Error("validate received both 'scope' and 'scopeFields'. 'scopeFields' takes precedence."),"validation");return}if(!e.options?.scopeFields?.length&&e.options?.scope){let r=t.store.getScopeFields(e.options.scope);r.length>0&&(e.targetFields=r)}}async function Tt(s){let{ctx:e,deps:t}=s;await t.store.emitBeforeValidate({values:e.currentState.values,state:e.currentState,scope:e.options?.scope,scopeFields:e.targetFields})}async function Pt(s){let{ctx:e,deps:t}=s,i=t.store.config.resolver?await t.store.config.resolver(e.currentState.values,{scopeFields:e.targetFields}):{},r=t.store.getRequiredErrors(e.currentState.values);e.allErrors={...i,...r},t.store.getHiddenFields().forEach(n=>{delete e.allErrors[n]})}async function Et(s){let{ctx:e,deps:t}=s,i=bt({targetFields:e.targetFields,hiddenFields:t.store.getHiddenFields(),getFieldConfig:n=>t.store.getFieldConfig(n),forEachFieldConfig:t.store.forEachFieldConfig});if(i.length===0)return;let r=await Promise.allSettled(i.map(n=>t.runImmediateAsyncValidation(n,e.currentState.values,e.validationId)));for(let n of r)n.status==="rejected"&&t.store.config.onUnhandledError(n.reason,"validation")}function xt(s){let{ctx:e,deps:t}=s,i=St({targetFields:e.targetFields,currentErrors:e.currentState.errors,allErrors:e.allErrors,asyncErrors:t.asyncErrors,hiddenFields:t.store.getHiddenFields()});e.committedErrors=i.committedErrors,e.isValid=!k(i.committedErrors),e.result=i.mode==="scoped"?i.result:e.isValid}async function ze(s){let{ctx:e,deps:t}=s;e.validationId!==t.getCurrentValidationId()&&(e.aborted=!0,e.result=t.store.getState().isValid,e.halted=!0)}async function Ct(s){let{ctx:e,deps:t}=s;t.store.dispatch(se(e.committedErrors,e.isValid)),await t.store.emitAfterValidate({values:t.store.getState().values,state:t.store.getState(),scope:e.options?.scope,scopeFields:e.targetFields,errors:e.committedErrors,result:e.result}),e.halted=!0}var Pe=class{constructor(e){this.deps=e;this.runner=new M([{name:"validate:resolve-target-fields",run:t=>Bt({ctx:t,deps:this.deps})},{name:"validate:before-hooks",run:async t=>Tt({ctx:t,deps:this.deps})},{name:"validate:sync-track",run:async t=>Pt({ctx:t,deps:this.deps})},{name:"validate:abort-check-pre-async",run:async t=>ze({ctx:t,deps:this.deps})},{name:"validate:async-track",run:async t=>Et({ctx:t,deps:this.deps})},{name:"validate:abort-check",run:async t=>ze({ctx:t,deps:this.deps})},{name:"validate:async-track-merge",run:t=>xt({ctx:t,deps:this.deps})},{name:"validate:commit",run:async t=>Ct({ctx:t,deps:this.deps})}])}runner;async run(e){await this.runner.run(e)}};var Ee=class{constructor(e){this.store=e;this.schedule=e.config.scheduler?.schedule??((i,r)=>{let n=setTimeout(i,r);return()=>clearTimeout(n)}),this.debouncer=new Te({schedule:(i,r)=>this.schedule(i,r),validate:i=>this.validate(i),validationDelay:e.config.validationDelay??300}),this.pipelineStore={getState:()=>this.store.getState(),dispatch:i=>this.store.dispatch(i),config:this.store.config,getFieldConfig:i=>this.store.getFieldConfig(i),forEachFieldConfig:i=>this.store.forEachFieldConfig(i),getScopeFields:i=>this.store.getScopeFields(i),getRequiredErrors:i=>this.store.getRequiredErrors(i),getHiddenFields:()=>this.store.getHiddenFields(),emitBeforeValidate:i=>this.store.emitBeforeValidate(i),emitAfterValidate:i=>this.store.emitAfterValidate(i)},this.asyncScheduler=new ve({schedule:(i,r)=>this.schedule(i,r),getValues:()=>this.store.getState().values,setFieldValidating:(i,r)=>this.updateFieldValidating(i,r),setAsyncError:(i,r)=>{this.asyncErrors.set(i,r),this.store.setError(i,r)},clearAsyncError:i=>{let r=this.asyncErrors.get(i);this.asyncErrors.delete(i),r&&!this.store.config.resolver&&this.store.getState().errors[i]===r&&this.store.setError(i,void 0),Ue({scopeFields:[i],store:this.pipelineStore,asyncErrors:this.asyncErrors}).catch(n=>{this.store.config.onUnhandledError(n,"validation")})},onValidationPassed:async i=>{await Ue({scopeFields:[i],store:this.pipelineStore,asyncErrors:this.asyncErrors})},onError:i=>{this.store.config.onUnhandledError(i,"validation")}});let t={store:this.pipelineStore,asyncErrors:this.asyncErrors,getCurrentValidationId:()=>this.coordinator.getCurrentValidationId(),runImmediateAsyncValidation:(i,r,n)=>this.runImmediateAsyncValidation(i,r,n)};this.validationPipeline=new Pe(t)}validatingCount=0;asyncErrors=new Map;coordinator=new Be;validationPipeline;pipelineStore;schedule;asyncScheduler;debouncer;updateFieldValidating(e,t){let i=this.store.getState();if(!!i.isValidating[e]===t)return;let n={...i.isValidating};t?(n[e]=!0,this.validatingCount+=1):(delete n[e],this.validatingCount=Math.max(0,this.validatingCount-1)),this.store.dispatch(v({isValidating:n}))}cancelFieldAsync(e){this.asyncScheduler.cancel(e),this.coordinator.cancelImmediate(e)}cleanupField(e){this.cancelFieldAsync(e),this.asyncErrors.delete(e),this.updateFieldValidating(e,!1)}cleanupPrefix(e){this.asyncScheduler.cleanupPrefix(e),this.coordinator.cancelImmediatePrefix(e,t=>{this.asyncErrors.delete(t),this.updateFieldValidating(t,!1)})}remapArrayPaths(e,t){let i=`${e}.`;this.asyncScheduler.remapPaths(n=>U(n,i,t)),this.coordinator.remapImmediateControllers(n=>U(n,i,t));let r=new Map;this.asyncErrors.forEach((n,o)=>{let a=U(o,i,t);a!==null&&r.set(a,n)}),this.asyncErrors.clear(),r.forEach((n,o)=>{this.asyncErrors.set(o,n)})}beginExternalValidation(e){this.cancelFieldAsync(e),this.updateFieldValidating(e,!0)}endExternalValidation(e){this.updateFieldValidating(e,!1)}async setExternalError(e,t){if(t){this.asyncErrors.set(e,t),this.store.setError(e,t);return}this.cancelFieldAsync(e),this.asyncErrors.delete(e),this.store.setError(e,void 0),await this.validate({scopeFields:[e]})}handleAsync(e,t){let i=this.store.getFieldConfig(e),r=i?.validation?.asyncValidate,n=i?.validation?.asyncValidateOn??"blur";if(!r||n!=="change"){this.cancelFieldAsync(e),this.updateFieldValidating(e,!1);return}let o=i.validation?.asyncValidateDelay??500,a=i.validation?.asyncValidateTimeout;this.asyncScheduler.handle(e,t,r,o,a)}hasValidationsInProgress(e){let t=this.store.getState();return e&&e.length>0?e.some(i=>!!t.isValidating[i]):Object.keys(t.isValidating).length>0}trigger(e,t){this.debouncer.trigger(e,t)}async validate(e){try{e?.scopeFields?.length&&e.scopeFields.forEach(i=>{this.cancelFieldAsync(i),this.updateFieldValidating(i,!1)});let t={options:e,validationId:this.coordinator.beginValidation(),currentState:this.store.getState(),targetFields:e?.scopeFields,allErrors:{},committedErrors:{},isValid:!0,result:!0,aborted:!1};if(await this.validationPipeline.run(t),t.aborted){let i=this.store.getState();await this.store.emitAfterValidate({values:i.values,state:i,scope:t.options?.scope,scopeFields:t.targetFields,errors:i.errors,result:i.isValid,aborted:!0})}return t.result}catch(t){return this.store.config.onUnhandledError(t,"validation"),!1}}clear(e){this.cancelFieldAsync(e),this.updateFieldValidating(e,!1),this.asyncErrors.delete(e)}cancelAll(){this.validatingCount=0,this.debouncer.cancelPending(),this.asyncScheduler.cancelAll(),this.asyncErrors.clear(),this.coordinator.cancelAllImmediate(),this.store.dispatch(v({isValidating:{}}))}async runImmediateAsyncValidation(e,t,i){await vt({path:e,values:t,validationId:i,getCurrentValidationId:()=>this.coordinator.getCurrentValidationId(),getFieldConfig:r=>this.store.getFieldConfig(r),cancelFieldAsync:r=>this.cancelFieldAsync(r),createAbortController:()=>new AbortController,setAbortController:(r,n)=>{this.coordinator.setImmediateController(r,n)},clearAbortController:(r,n)=>this.coordinator.clearImmediateController(r,n),setFieldValidating:(r,n)=>this.updateFieldValidating(r,n),setAsyncError:(r,n)=>{this.asyncErrors.set(r,n)},clearAsyncError:r=>{this.asyncErrors.delete(r)}})}};var qe=class{entries=new Map;register(e,t){this.entries.set(e,t)}resolve(e){let t=this.entries.get(e);if(!t)throw new Error(`BitStore capability "${String(e)}" n\xE3o foi registrada.`);return t}toCapabilities(){return{validation:this.resolve("validation"),lifecycle:this.resolve("lifecycle"),history:this.resolve("history"),arrays:this.resolve("arrays"),scope:this.resolve("scope"),query:this.resolve("query"),error:this.resolve("error")}}};function Vt(){return new qe}function Fi(s){let{registry:e,ports:t,fieldRegistry:i}=s;e.register("validation",new Ee(t.validationPort)),e.register("lifecycle",new Se(t.lifecyclePorts)),e.register("history",new pe(!!t.config.history.enabled,t.config.history.limit??50)),e.register("arrays",new le(t.arrayPort)),e.register("scope",new be(()=>t.getState(),()=>t.getBaselineValues(),r=>t.getScopeFields(r),r=>t.isPathDirty(r))),e.register("query",new ce(i,()=>t.getState(),r=>t.isPathDirty(r))),e.register("error",new de(()=>t.getState(),r=>t.dispatch(r),r=>t.config.onUnhandledError(r,"errors")))}function Ft(s){let{ports:e,fieldRegistry:t}=s,i=Vt();return Fi({registry:i,ports:e,fieldRegistry:t}),{registry:i,capabilities:i.toCapabilities()}}function wt(s){let{config:e,fieldRegistry:t,computedManager:i}=s,r=T(e.initialValues);e.fields&&Object.entries(e.fields).forEach(([a,l])=>{t.register(a,l,r)});let n=ne(t.getComputedEntries(r));if(n.length>0)throw new Error(n[0].message);return{values:G({values:r,normalizerEntries:t.getNormalizerEntries(r),applyComputed:(a,l)=>i.apply(a,l),onError:(a,l)=>{e.onUnhandledError(a,"derivation")}}),errors:{},touched:{},isValidating:{},persist:{isSaving:!1,isRestoring:!1,error:null},isValid:!0,isSubmitting:!1,isDirty:!1}}function At(s){return{getState:s.getState,dispatch:s.dispatch,setError:s.setError,getFieldConfig:s.getFieldConfig,forEachFieldConfig:e=>s.fieldRegistry.forEachFieldConfig((t,i)=>e(t,i)),getScopeFields:s.getScopeFields,config:s.config,getRequiredErrors:e=>s.fieldRegistry.getRequiredErrors(e),getHiddenFields:()=>s.fieldRegistry.getHiddenFields(),emitBeforeValidate:e=>s.getEffects().beforeValidate(e),emitAfterValidate:e=>s.getEffects().afterValidate(e)}}function kt(s){let e={getState:s.getState,dispatch:s.dispatch,config:s.config,getFieldConfig:r=>s.fieldRegistry.getFieldConfig(r),updateDependencies:(r,n,o)=>s.fieldRegistry.updateDependencies(r,n,o),hasDependentFields:r=>s.fieldRegistry.hasDependents(r),isFieldHidden:r=>s.fieldRegistry.isHidden(r),clearFieldValidation:r=>s.getValidation().clear(r),triggerValidation:(r,n)=>s.getValidation().trigger(r,n),handleFieldAsyncValidation:(r,n)=>s.getValidation().handleAsync(r,n),updateDirtyForPath:(r,n,o)=>s.dirtyManager.updateForPath(r,n,o),getBaselineValues:s.getBaselineValues,emitFieldChange:r=>s.getEffects().onFieldChange(r)},t={getState:s.getState,dispatch:s.dispatch,config:s.config,internalSaveSnapshot:s.saveHistorySnapshot,evaluateAllDependencies:r=>s.fieldRegistry.evaluateAll(r),cancelAllValidations:()=>s.getValidation().cancelAll(),validateNow:r=>s.getValidation().validate(r),rebuildDirtyState:(r,n)=>s.dirtyManager.rebuild(r,n),clearDirtyState:s.dirtyManager.clear.bind(s.dirtyManager),getBaselineValues:s.getBaselineValues,setBaselineValues:s.setBaselineValues,resetHistory:r=>s.getHistory().reset(r),emitFieldChange:r=>s.getEffects().onFieldChange(r),triggerValidation:(r,n)=>s.getValidation().trigger(r,n)},i={getState:s.getState,dispatch:s.dispatch,batchStateUpdates:s.runStateBatch,config:s.config,getTransformEntries:s.getTransformEntries,getHiddenFields:()=>s.fieldRegistry.getHiddenFields(),cancelAllValidations:()=>s.getValidation().cancelAll(),validateNow:r=>s.getValidation().validate(r),hasValidationsInProgress:r=>s.getValidation().hasValidationsInProgress(r),buildDirtyValues:r=>s.dirtyManager.buildDirtyValues(r),setServerErrors:(r,n)=>s.setServerErrors(r,n),emitBeforeSubmit:r=>s.getEffects().beforeSubmit(r),emitAfterSubmit:r=>s.getEffects().afterSubmit(r),emitOperationalError:r=>s.getEffects().reportOperationalError(r)};return{fieldUpdate:e,values:t,submit:i}}function It(s){return{getState:s.getState,setFieldWithMeta:s.setFieldWithMeta,dispatch:s.dispatch,internalSaveSnapshot:s.saveHistorySnapshot,unregisterPrefix:s.unregisterPrefix,remapValidationPaths:s.remapValidationPaths,createArrayItemId:s.createArrayItemId}}function Dt(s){let{config:e,fieldRegistry:t,dirtyManager:i,baselineManager:r,runtimeContext:n}=s,{stateAccess:o,fieldAccess:a,featureAccess:l,actions:c}=n,p=At({config:e,fieldRegistry:t,getState:o.getState,dispatch:o.dispatch,setError:c.setError,getFieldConfig:a.getFieldConfig,getScopeFields:a.getScopeFields,getEffects:l.getEffects}),d=kt({config:e,fieldRegistry:t,dirtyManager:i,getState:o.getState,dispatch:o.dispatch,setServerErrors:c.setServerErrors,saveHistorySnapshot:o.saveHistorySnapshot,runStateBatch:o.runStateBatch,getTransformEntries:a.getTransformEntries,getBaselineValues:()=>r.getValues(),setBaselineValues:h=>r.setValues(h),getValidation:l.getValidation,getHistory:l.getHistory,getEffects:l.getEffects}),u=It({getState:o.getState,dispatch:o.dispatch,setFieldWithMeta:(h,f,S)=>c.setFieldWithMeta(h,f,S),unregisterPrefix:c.unregisterPrefix,remapValidationPaths:(h,f)=>l.getValidation().remapArrayPaths(h,f),saveHistorySnapshot:o.saveHistorySnapshot,createArrayItemId:(h,f)=>e.idFactory({scope:"array",path:h,index:f})});return Ft({ports:{validationPort:p,lifecyclePorts:d,arrayPort:u,config:e,getScopeFields:a.getScopeFields,getState:o.getState,dispatch:o.dispatch,getBaselineValues:()=>r.getValues(),isPathDirty:h=>i.isPathDirty(h)},fieldRegistry:t})}function Mt(s){let{config:e,fieldRegistry:t,dirtyManager:i,computedManager:r,rawConfig:n,baselineManager:o,runtimeContext:a}=s,{stateAccess:l,fieldAccess:c,featureAccess:p,actions:d}=a,u=Dt({config:e,fieldRegistry:t,dirtyManager:i,baselineManager:o,runtimeContext:{stateAccess:l,fieldAccess:c,featureAccess:p,actions:d}}),h=wt({config:e,fieldRegistry:t,computedManager:r}),f=new ae(l.getState,(g,y)=>e.onUnhandledError(g,y),e.subscriptionCacheSize),S=n.storeId||e.name||e.idFactory({scope:"store",storeName:e.name});return{state:h,subscriptions:f,capabilityRegistry:u.registry,storeId:S}}function Rt(){return{depth:0,pendingState:null,changedPathSet:null,changedPathList:null,valuesChanged:!1,pendingHistorySnapshot:!1}}function Ot(s){s.depth+=1}function jt(s){return s.depth-=1,s.depth===0}function xe(s,e){return e.pendingState??s}function Ht(s,e){if(s.pendingState=e.nextState,s.valuesChanged||=e.valuesChanged,e.valuesChanged&&(s.pendingHistorySnapshot=!0),e.changedPaths&&e.changedPaths.length>0){let t=s.changedPathSet??new Set,i=s.changedPathList??[];e.changedPaths.forEach(r=>{if(t.has("*")||t.has(r))return;if(r==="*"){t.clear(),i.length=0,t.add("*"),i.push("*");return}if(!i.some(o=>o!=="*"&&r.startsWith(`${o}.`))){for(let o=i.length-1;o>=0;o-=1){let a=i[o];a==="*"||!a.startsWith(`${r}.`)||(t.delete(a),i.splice(o,1))}t.add(r),i.push(r)}}),s.changedPathSet=t,s.changedPathList=i}}function Ut(s){let{currentState:e,batchState:t,applyValueDerivations:i,onDerivationError:r}=s;if(!t.pendingState)return null;let n={...t.pendingState},o=t.changedPathList??void 0,a=t.valuesChanged;try{if(a)try{n={...n,values:i(n.values,o)}}catch(l){try{r?.(l)}catch{}}}finally{t.pendingState=null,t.changedPathSet=null,t.changedPathList=null,t.valuesChanged=!1}return{nextState:n??e,changedPaths:o,valuesChanged:a}}var Ce=class{constructor(e){this.args=e;this.debounceMs=Math.max(0,e.debounceMs??300)}debounceMs;timer;pendingValues=null;queueSnapshot(e){if(this.debounceMs<=0){this.recordSnapshot(e);return}this.pendingValues=e,this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.flushPendingSnapshot()},this.debounceMs)}flushPendingSnapshot(){if(this.timer&&(clearTimeout(this.timer),this.timer=void 0),!this.pendingValues)return;let e=this.pendingValues;this.pendingValues=null,this.recordSnapshot(e)}dispose(){this.timer&&(clearTimeout(this.timer),this.timer=void 0),this.pendingValues=null}recordSnapshot(e){let t=this.readMetadata();this.args.history.saveSnapshot(e);let i=this.readMetadata();t.canUndo===i.canUndo&&t.canRedo===i.canRedo&&t.historyIndex===i.historyIndex&&t.historySize===i.historySize||this.args.notifyHistoryChanged()}readMetadata(){let e=this.args.history.getMetadata();return{canUndo:e.canUndo,canRedo:e.canRedo,historyIndex:e.historyIndex,historySize:e.historySize}}};function wi(s){let e=!1;for(let i of Object.values(s))if(i===void 0){e=!0;break}if(!e)return s;let t={};return Object.entries(s).forEach(([i,r])=>{let n=r;n!==void 0&&(t[i]=n)}),t}function Ve(s){let{currentState:e,partialState:t,changedPaths:i,applyValueDerivations:r,applyComputedValues:n}=s,o=r??(u=>n?n(u):u),a={...e,...t},l=!!t.values;if(t.values&&(a.values=o(t.values,i)),t.errors){a.errors=wi(t.errors);let u=!k(a.errors);a.isValid="isValid"in t?!!t.isValid:u}let c=i&&i.length>0?i:void 0,p=Ai(t),d=J(c,p);return{nextState:a,changedPaths:d,valuesChanged:l}}function Ai(s){let e=new Set,t=[s.errors,s.touched,s.isValidating];for(let i of t)if(i)for(let r in i)e.add(r);return s.persist&&e.add("persist"),"isValid"in s&&e.add("isValid"),"isDirty"in s&&e.add("isDirty"),"isSubmitting"in s&&e.add("isSubmitting"),e.size>0?Array.from(e):void 0}function ki(s){throw new Error(`BitStore: unsupported operation kind: ${String(s.kind)}`)}function Ii(s,e){switch(e.kind){case"state.patch":return e;case"field.touchMany":{if(e.paths.length===0)return null;let t={...s.touched};for(let i of e.paths)t[i]=!0;return v({touched:t},e.paths)}case"form.persistMeta":return v({persist:{...s.persist,...e.patch}});case"history.apply":return v({values:e.values,isDirty:e.isDirty},["*"]);case"validation.commit":return v({errors:e.errors,isValid:e.isValid});default:return ki(e)}}function Di(s){let{currentState:e,operation:t,applyValueDerivations:i,onOperationError:r}=s,n=Object.prototype.hasOwnProperty.call(t.partialState,"values"),o=t.changedPaths??(n?["*"]:void 0),a;try{a=Ve({currentState:e,partialState:t.partialState,changedPaths:o,applyValueDerivations:i})}catch(l){try{r?.(l)}catch{}try{a=Ve({currentState:e,partialState:t.partialState,changedPaths:o,applyValueDerivations:c=>c})}catch{try{let{values:c,...p}=t.partialState;Object.keys(p).length>0&&(a=Ve({currentState:e,partialState:p,changedPaths:o,applyValueDerivations:d=>d}))}catch{let c=new Error("BitStore: all commit fallback strategies failed \u2014 operation lost");try{r?.(c)}catch{}a=void 0}}}return a}function zt(s){let{currentState:e,operation:t,applyValueDerivations:i,onOperationError:r}=s,n=Ii(e,t);return n?Di({currentState:e,operation:n,applyValueDerivations:(o,a)=>n.skipComputed?o:i(o,a),onOperationError:r}):null}function qt(s){let{state:e,batchState:t,operation:i,applyValueDerivations:r,onOperationError:n,onStateCommitted:o}=s,a=xe(e,t);if(t.depth>0){let c=zt({currentState:a,operation:i,applyValueDerivations:p=>p,onOperationError:n});return c&&Ht(t,c),e}let l=zt({currentState:e,operation:i,applyValueDerivations:r,onOperationError:n});return l?(o({nextState:l.nextState,changedPaths:l.changedPaths,valuesChanged:l.valuesChanged}),l.nextState):e}function _t(s){let{state:e,batchState:t,applyValueDerivations:i,onDerivationError:r,onStateCommitted:n}=s,o=Ut({currentState:e,batchState:t,applyValueDerivations:i,onDerivationError:r});return o?(n({nextState:o.nextState,changedPaths:o.changedPaths,valuesChanged:o.valuesChanged}),o.nextState):e}function Lt(s){let{batchState:e,callback:t,flushBatchedStateUpdates:i}=s;Ot(e);try{return t()}finally{jt(e)&&i()}}function Wt(s){let{payload:e,setState:t,notifySubscriptions:i,notifyEffects:r}=s;t(e.nextState),i(e.nextState,e.changedPaths),r(e.nextState,e.valuesChanged)}function Nt(s){let{state:e,batchState:t,operation:i,applyValueDerivations:r,onOperationError:n,onStateCommitted:o}=s;return qt({state:e,batchState:t,operation:i,applyValueDerivations:r,onOperationError:n,onStateCommitted:o})}function Kt(s){let{batchState:e,values:t,saveHistory:i}=s;if(e.depth>0){e.pendingHistorySnapshot=!0;return}i(t)}function $t(s){let{state:e,batchState:t,applyValueDerivations:i,onDerivationError:r,onStateCommitted:n,saveHistory:o}=s,a=_t({state:e,batchState:t,applyValueDerivations:i,onDerivationError:r,onStateCommitted:n});return t.pendingHistorySnapshot&&(t.pendingHistorySnapshot=!1,a!==e&&o(a.values)),a}var Fe=class{constructor(e){this.args=e;this.state=e.state,this.subscriptions=e.subscriptions,this.effects=e.effects,this.capabilityRegistry=e.capabilityRegistry,this.capabilities=e.capabilityRegistry.toCapabilities(),this.historyOrchestrator=new Ce({debounceMs:e.historyDebounceMs,history:this.capabilities.history,notifyHistoryChanged:()=>{this.subscriptions.notify(this.getState(),[z()])}})}state;batchState=Rt();historyOrchestrator;subscriptions;effects;capabilityRegistry;capabilities;getCapability(e){return this.capabilityRegistry.resolve(e)}getState(){return xe(this.state,this.batchState)}runBatch(e){return Lt({batchState:this.batchState,callback:e,flushBatchedStateUpdates:()=>this.flushBatchedStateUpdates()})}dispatch(e){this.state=Nt({state:this.state,batchState:this.batchState,operation:e,applyValueDerivations:(t,i)=>this.applyValueDerivations(t,i),onOperationError:t=>this.args.onUnhandledError?.(t,"derivation"),onStateCommitted:t=>this.onStateCommitted(t)})}saveHistorySnapshot(){Kt({batchState:this.batchState,values:this.state.values,saveHistory:e=>this.historyOrchestrator.queueSnapshot(e)})}flushPendingHistorySnapshot(){this.historyOrchestrator.flushPendingSnapshot()}cancelPendingHistorySnapshot(){this.batchState.pendingHistorySnapshot=!1}cleanup(){this.flushPendingHistorySnapshot(),this.historyOrchestrator.dispose(),this.subscriptions.destroy(),this.capabilities.validation.cancelAll(),this.effects.destroy()}onStateCommitted(e){Wt({payload:e,setState:t=>{this.state=t},notifySubscriptions:(t,i)=>this.subscriptions.notify(t,i),notifyEffects:(t,i)=>this.effects.onStateUpdated(t,i)})}flushBatchedStateUpdates(){this.state=$t({state:this.state,batchState:this.batchState,applyValueDerivations:(e,t)=>this.applyValueDerivations(e,t),onDerivationError:e=>this.args.onUnhandledError?.(e,"derivation"),onStateCommitted:e=>this.onStateCommitted(e),saveHistory:e=>this.historyOrchestrator.queueSnapshot(e)})}applyValueDerivations(e,t){return this.args.applyValueDerivations?this.args.applyValueDerivations(e,t):e}};function Jt(s){let{rawConfig:e,overrides:t}=s,i=tt(e),r=t?.baselineManager??new q(i.initialValues),n=t?.fieldRegistry??new $(({error:g})=>{i.onUnhandledError(g,"validation")}),o=t?.computedManager??new _(g=>n.getComputedEntries(g),g=>i.onUnhandledError(g,"computed")),a=t?.dirtyManager??new L,l=t?.maskManager??new W,c=()=>{n.invalidateIndexes(),o.invalidateReverseDeps()},p,d=()=>{if(!p)throw new Error("BitStore runtime kernel is not initialized yet.");return p},u=Mt({rawConfig:e,config:i,fieldRegistry:n,computedManager:o,dirtyManager:a,baselineManager:r,runtimeContext:{stateAccess:{getState:()=>d().getState(),dispatch:g=>d().dispatch(g),saveHistorySnapshot:()=>d().saveHistorySnapshot(),runStateBatch:g=>d().runBatch(g)},fieldAccess:{getFieldConfig:g=>n.getFieldConfig(g),getScopeFields:g=>n.getScopeFields(g,d().getState().values),getNormalizerEntries:()=>n.getNormalizerEntries(d().getState().values),getTransformEntries:()=>n.getTransformEntries(d().getState().values)},featureAccess:{getEffects:()=>d().effects,getHistory:()=>d().getCapability("history"),getValidation:()=>d().getCapability("validation")},actions:{setError:(g,y)=>{d().getCapability("error").setError(g,y)},setServerErrors:(g,y)=>{d().getCapability("error").setServerErrors(g,y)},validate:g=>d().getCapability("validation").validate(g),setFieldWithMeta:(g,y,B={origin:"setField"})=>{d().runBatch(()=>{d().getCapability("lifecycle").updateField(g,y,B)})},unregisterPrefix:g=>{oe({prefix:g,state:d().getState(),fieldRegistry:n,subscriptions:d().subscriptions,validationCleanupPrefix:y=>d().getCapability("validation").cleanupPrefix(y),invalidateFieldIndexes:c,hasStaticConfigPath:y=>!!i.fields?.[y],dispatch:y=>d().dispatch(y)})},triggerValidation:(g,y)=>{d().getCapability("validation").trigger(g,y)}}}}),h=()=>{let g=d().getState();return a.buildDirtyValues(g.values)},f=g=>{d().flushPendingHistorySnapshot(),dt({values:g,state:d().getState(),initialValues:r.getValues(),validation:d().getCapability("validation"),fieldRegistry:n,dirtyManager:a,dispatch:y=>d().dispatch(y),saveHistorySnapshot:()=>d().saveHistorySnapshot()})},S=rt({storeId:u.storeId,config:i,getState:()=>d().getState(),getConfig:()=>i,getValues:()=>d().getState().values,getDirtyValues:h,applyPersistedValues:f,setPersistMetadata:g=>d().dispatch({kind:"form.persistMeta",patch:g})});return p=new Fe({state:u.state,subscriptions:u.subscriptions,effects:S,capabilityRegistry:u.capabilityRegistry,historyDebounceMs:i.history.debounceMs,onUnhandledError:(g,y)=>i.onUnhandledError(g,y),applyValueDerivations:(g,y)=>{try{return G({values:g,changedPaths:y,normalizerEntries:n.getNormalizerEntries(g),applyComputed:(B,P)=>o.apply(B,P),onError:(B,P)=>{i.onUnhandledError(B,"derivation")}})}catch(B){return i.onUnhandledError(B,"derivation"),g}}}),p.saveHistorySnapshot(),p.flushPendingHistorySnapshot(),{config:i,storeId:u.storeId,runtime:p,fieldRegistry:n,computedManager:o,dirtyManager:a,maskManager:l,baselineManager:r}}function Gt(s){let{dispatch:e,effects:t,onUnhandledError:i}=s;return ot({dispatch:e,effects:t,onUnhandledError:i})}function Yt(s){let{dispatch:e,effects:t,onUnhandledError:i}=s;return at({dispatch:e,effects:t,onUnhandledError:i})}function Qt(s){let{dispatch:e,effects:t,onUnhandledError:i}=s;return lt({dispatch:e,effects:t,onUnhandledError:i})}function Xt(s){let{history:e,applyHistoryState:t}=s,i=e.undo();i&&t(i)}function Zt(s){let{history:e,applyHistoryState:t}=s,i=e.redo();i&&t(i)}function ei(s){return s.history.getMetadata()}function ti(s,e){let t=new Set,i=(o,a,l=new WeakSet)=>o===null||typeof o!="object"||l.has(o)?o:(l.add(o),new Proxy(o,{get:(c,p,d)=>{if(typeof p=="symbol")return Reflect.get(c,p,d);let u=String(p),h=a?`${a}.${u}`:u;t.add(h);let f=Reflect.get(c,p,d);return i(f,h)}})),r=i(s,"");e(r);let n=new Set;return t.forEach(o=>{let a=Mi(o);a&&n.add(a)}),Array.from(n)}function Mi(s){if(s)return s==="values"?"*":s.startsWith("values.")?s.slice(7):s==="errors"||s==="touched"||s==="isValidating"?"*":s.startsWith("errors.")?s.slice(7):s.startsWith("touched.")?s.slice(8):s.startsWith("isValidating.")?s.slice(13):s==="persist"||s.startsWith("persist.")?"persist":s}function Ri(s,e){if(s.length!==e.length)return!1;let t=new Set(e);for(let i of s)if(!t.has(i))return!1;return!0}function Oi(s,e){return s.length===0?{emitImmediately:e?.emitImmediately,equalityFn:e?.equalityFn,mode:"scoped",paths:["*"]}:{emitImmediately:e?.emitImmediately,equalityFn:e?.equalityFn,mode:"scoped",paths:s}}function ii(s){let{getState:e,subscribeSelector:t,selector:i,listener:r,options:n}=s,o=null,a=ti(e(),i),l=!1,c=!1,p=d=>{let u=o;o=t(i,h=>{r(h);let f=ti(e(),i);Ri(a,f)||(a=f,!(c||l)&&(c=!0,queueMicrotask(()=>{c=!1,!l&&(o?.(),p(a))})))},Oi(d,n)),u?.()};return p(a),()=>{l=!0,o?.(),o=null}}function ri(s){let{getState:e,subscriptions:t,selector:i,listener:r,options:n,trackedSubscriptionsEnabled:o,onUnhandledError:a}=s,l=n?.equalityFn??E;return n?.mode==="tracked"?o?ii({getState:e,subscribeSelector:(c,p,d)=>t.subscribeSelector(c,p,d,l),selector:i,listener:r,options:n}):(a?.(new Error('BitForm: subscribeSelector com mode="tracked" est\xE1 desabilitado por padr\xE3o. Ative config.trackedSubscriptions=true para habilitar o modo avan\xE7ado.'),"subscription"),()=>{}):t.subscribeSelector(i,r,n,l)}function si(s){let{path:e,listener:t,options:i,subscribeSelector:r}=s,n=[...i?.paths??[],e];return r(o=>m(o.values,e),t,{...i,paths:n})}function ni(s){let{path:e,listener:t,getFieldState:i,subscribeSelector:r}=s;return r(()=>i(e),t,{paths:[e],equalityFn:Qe})}function oi(s){let{listener:e,subscribeSelector:t}=s;return t(i=>({isValid:i.isValid,isDirty:i.isDirty,isSubmitting:i.isSubmitting}),e,{paths:["isValid","isDirty","isSubmitting"],equalityFn:(i,r)=>i.isValid===r.isValid&&i.isDirty===r.isDirty&&i.isSubmitting===r.isSubmitting})}function ai(s){let{listener:e,subscribeSelector:t}=s;return t(i=>i.persist,e,{paths:["persist"],equalityFn:(i,r)=>i.isSaving===r.isSaving&&i.isRestoring===r.isRestoring&&i.error===r.error})}function li(s){let{readHistoryMeta:e,subscribeSelector:t,listener:i}=s;return t(()=>e(),i,{paths:[z()],equalityFn:(r,n)=>Ye(r,n)})}function di(s){let{scopeName:e,getScopeFields:t,readScopeStatus:i,subscribeSelector:r,listener:n}=s,o=D(e),a=i(e),l=()=>{},c=()=>{l();let h=Ge(t(e));l=r(()=>i(e),f=>{ke(a,f)||(a=f,n(f))},{paths:[...h,o]})};c();let p=!1,d=!1,u=r(()=>t(e).length,()=>{p||(p=!0,queueMicrotask(()=>{if(p=!1,d){l();return}c();let h=i(e);ke(a,h)||(a=h,n(h))}))},{paths:[o]});return()=>{d=!0,l(),u()}}function ci(s){let{runtime:e,config:t,fieldRegistry:i,dirtyManager:r,stateReader:n}=s,o={getState:()=>T(n.getState()),getFieldState:d=>T(n.getFieldState(d)),getIsValid:()=>n.getFlag("isValid"),getIsSubmitting:()=>n.getFlag("isSubmitting"),getIsDirty:()=>n.getFlag("isDirty"),isHidden:d=>e.capabilities.query.isHidden(d),isRequired:d=>e.capabilities.query.isRequired(d),isFieldDirty:d=>e.capabilities.query.isFieldDirty(d),isFieldValidating:d=>e.capabilities.query.isFieldValidating(d),getDirtyValues:()=>r.buildDirtyValues(n.getState().values),getPersistMetadata:()=>n.getPersistMetadata(),getHistoryMetadata:()=>ei({history:e.capabilities.history}),getScopeStatus:d=>e.capabilities.scope.getScopeStatus(d),getScopeErrors:d=>e.capabilities.scope.getScopeErrors(d),getCanUndo:()=>e.capabilities.history.canUndo,getCanRedo:()=>e.capabilities.history.canRedo,getScopeFields:d=>i.getScopeFields(d,n.getState().values)},a={subscribe:d=>e.subscriptions.subscribe(d),subscribePersistMeta:d=>ai({listener:d,subscribeSelector:(u,h,f)=>a.subscribeSelector(u,h,f)}),subscribeHistoryMeta:d=>li({readHistoryMeta:()=>o.getHistoryMetadata(),subscribeSelector:(u,h,f)=>a.subscribeSelector(u,h,f),listener:d}),subscribeScopeStatus:(d,u)=>di({scopeName:d,getScopeFields:h=>o.getScopeFields(h),readScopeStatus:h=>o.getScopeStatus(h),subscribeSelector:(h,f,S)=>a.subscribeSelector(h,f,S),listener:u}),subscribeSelector:(d,u,h)=>ri({getState:()=>o.getState(),subscriptions:e.subscriptions,selector:d,listener:u,options:h,trackedSubscriptionsEnabled:!!t.trackedSubscriptions,onUnhandledError:(f,S)=>t.onUnhandledError(f,S)}),subscribePath:(d,u,h)=>si({path:d,listener:u,options:h,subscribeSelector:(f,S,g)=>a.subscribeSelector(f,S,g)}),subscribeFieldState:(d,u)=>ni({path:d,listener:u,getFieldState:h=>o.getFieldState(h),subscribeSelector:(h,f,S)=>a.subscribeSelector(h,f,S)}),subscribeFormMeta:d=>oi({listener:d,subscribeSelector:(u,h,f)=>a.subscribeSelector(u,h,f)})},l={registerField:(d,u)=>{pt({path:d,config:u,state:e.getState(),fieldRegistry:i,subscriptions:e.subscriptions,validationCleanupField:h=>e.capabilities.validation.cleanupField(h),stateReader:n,invalidateFieldIndexes:()=>{i.invalidateIndexes()},dispatch:h=>e.dispatch(h),getState:()=>e.getState(),onUnhandledError:(h,f)=>t.onUnhandledError(h,f)})},unregisterField:d=>{ht({path:d,state:e.getState(),hasStaticConfig:!!t.fields?.[d],fieldRegistry:i,subscriptions:e.subscriptions,validationCleanupField:u=>e.capabilities.validation.cleanupField(u),invalidateFieldIndexes:()=>{i.invalidateIndexes()},dispatch:u=>e.dispatch(u)})},unregisterPrefix:d=>{oe({prefix:d,state:e.getState(),fieldRegistry:i,subscriptions:e.subscriptions,validationCleanupPrefix:u=>e.capabilities.validation.cleanupPrefix(u),invalidateFieldIndexes:()=>{i.invalidateIndexes()},hasStaticConfigPath:u=>!!t.fields?.[u],dispatch:u=>e.dispatch(u)})},setField:(d,u)=>{e.runBatch(()=>{e.capabilities.lifecycle.updateField(d,u,{origin:"setField"})})},blurField:d=>{e.capabilities.query.isTouched(d)||e.runBatch(()=>{e.dispatch(je([d]))}),e.flushPendingHistorySnapshot(),e.capabilities.validation.trigger([d])},markFieldsTouched:d=>{d.length!==0&&e.dispatch(je(d))},setValues:(d,u)=>{u?.rebase&&e.flushPendingHistorySnapshot(),e.capabilities.lifecycle.setValues(d,u)},setError:(d,u)=>{e.capabilities.error.setError(d,u)},setErrors:d=>{e.capabilities.error.setErrors(d)},setServerErrors:(d,u)=>{e.capabilities.error.setServerErrors(d,u)},reset:()=>{e.flushPendingHistorySnapshot(),e.runBatch(()=>{e.capabilities.lifecycle.reset(),e.cancelPendingHistorySnapshot()})},transaction:d=>e.runBatch(d),submit:d=>(e.flushPendingHistorySnapshot(),e.capabilities.lifecycle.submit(d)),pushItem:(d,u)=>e.capabilities.arrays.pushItem(d,u),prependItem:(d,u)=>e.capabilities.arrays.prependItem(d,u),insertItem:(d,u,h)=>e.capabilities.arrays.insertItem(d,u,h),removeItem:(d,u)=>e.capabilities.arrays.removeItem(d,u),swapItems:(d,u,h)=>e.capabilities.arrays.swapItems(d,u,h),moveItem:(d,u,h)=>e.capabilities.arrays.moveItem(d,u,h),replaceItems:(d,u)=>e.capabilities.arrays.replaceItems(d,u),clearItems:d=>e.capabilities.arrays.clearItems(d)},c=d=>e.dispatch(d);return{read:o,observe:a,write:l,feature:{undo:()=>{e.flushPendingHistorySnapshot(),Xt({history:e.capabilities.history,applyHistoryState:d=>e.capabilities.lifecycle.applyHistoryState(d)})},redo:()=>{e.flushPendingHistorySnapshot(),Zt({history:e.capabilities.history,applyHistoryState:d=>e.capabilities.lifecycle.applyHistoryState(d)})},validate:d=>e.capabilities.validation.validate(d),hasValidationsInProgress:d=>e.capabilities.validation.hasValidationsInProgress(d),triggerValidation:(d,u)=>e.capabilities.validation.trigger(d,u),restorePersisted:()=>Gt({dispatch:c,effects:e.effects,onUnhandledError:(d,u)=>t.onUnhandledError(d,u)}),forceSave:()=>Yt({dispatch:c,effects:e.effects,onUnhandledError:(d,u)=>t.onUnhandledError(d,u)}),clearPersisted:()=>Qt({dispatch:c,effects:e.effects,onUnhandledError:(d,u)=>t.onUnhandledError(d,u)}),getArrayItemIds:(d,u)=>e.capabilities.arrays.getItemIds(d,u),cleanup:()=>e.cleanup()}}}var ui=s=>Object.freeze(T(s));function pi(s){let e=()=>s.read.getState();return{read:{get storeId(){return s.identity.storeId},get config(){return ui(s.identity.config)},get isValid(){return s.read.getIsValid()},get isSubmitting(){return s.read.getIsSubmitting()},get isDirty(){return s.read.getIsDirty()},getState:e,getFieldConfig:o=>{let a=s.getFieldConfig(o);return a?ui(a):void 0},getFieldState:o=>s.read.getFieldState(o),isHidden:o=>s.read.isHidden(o),isRequired:o=>s.read.isRequired(o),isFieldDirty:o=>s.read.isFieldDirty(o),isFieldValidating:o=>s.read.isFieldValidating(o),getDirtyValues:()=>s.read.getDirtyValues(),getPersistMetadata:()=>s.read.getPersistMetadata(),getHistoryMetadata:()=>s.read.getHistoryMetadata(),getScopeStatus:o=>s.read.getScopeStatus(o),getScopeErrors:o=>s.read.getScopeErrors(o),getScopeFields:o=>s.read.getScopeFields(o)},observe:{getState:e,subscribe:o=>s.observe.subscribe(o),subscribePersistMeta:o=>s.observe.subscribePersistMeta(o),subscribeHistoryMeta:o=>s.observe.subscribeHistoryMeta(o),subscribeScopeStatus:(o,a)=>s.observe.subscribeScopeStatus(o,a),subscribeFormMeta:o=>s.observe.subscribeFormMeta(o),subscribeSelector:(o,a,l)=>s.observe.subscribeSelector(o,a,l),subscribePath:(o,a,l)=>s.observe.subscribePath(o,a,l),subscribeFieldState:(o,a)=>s.observe.subscribeFieldState(o,a)},write:{setField:(o,a)=>s.write.setField(o,a),blurField:o=>s.write.blurField(o),markFieldsTouched:o=>s.write.markFieldsTouched(o),setValues:(o,a)=>s.write.setValues(o,a),setError:(o,a)=>s.write.setError(o,a),setErrors:o=>s.write.setErrors(o),setServerErrors:(o,a)=>s.write.setServerErrors(o,a),reset:()=>s.write.reset(),transaction:o=>s.write.transaction(o),submit:o=>s.write.submit(o)},feature:{cleanup:()=>s.feature.cleanup(),validate:o=>s.feature.validate(o),triggerValidation:(o,a)=>s.feature.triggerValidation(o,a),restorePersisted:()=>s.feature.restorePersisted(),forceSave:()=>s.feature.forceSave(),clearPersisted:()=>s.feature.clearPersisted(),registerField:(o,a)=>s.write.registerField(o,a),unregisterField:o=>s.write.unregisterField(o),unregisterPrefix:o=>s.write.unregisterPrefix(o),pushItem:(o,a)=>s.write.pushItem(o,a),prependItem:(o,a)=>s.write.prependItem(o,a),insertItem:(o,a,l)=>s.write.insertItem(o,a,l),removeItem:(o,a)=>s.write.removeItem(o,a),moveItem:(o,a,l)=>s.write.moveItem(o,a,l),swapItems:(o,a,l)=>s.write.swapItems(o,a,l),replaceItems:(o,a)=>s.write.replaceItems(o,a),clearItems:o=>s.write.clearItems(o),getArrayItemIds:(o,a)=>s.feature.getArrayItemIds(o,a),get canUndo(){return s.read.getCanUndo()},get canRedo(){return s.read.getCanRedo()},hasValidationsInProgress:o=>s.feature.hasValidationsInProgress(o),resolveMask:o=>s.resolveMask(o),createArrayItemId:(o,a)=>s.createArrayItemId(o,a),undo:()=>s.feature.undo(),redo:()=>s.feature.redo()}}}var we=class{constructor(e){this.deps=e}fieldStateCache=new Map;persistMetaCache;getState(){return this.deps.getState()}getUserLayer(){let e=this.deps.getState();return{values:e.values,touched:e.touched}}getValidationLayer(){let e=this.deps.getState();return{errors:e.errors,isValidating:e.isValidating,isValid:e.isValid}}getDerivedLayer(){return{isDirty:this.deps.getState().isDirty}}getFeatureLayer(){let e=this.deps.getState();return{persist:e.persist,isSubmitting:e.isSubmitting}}getFlag(e){return this.deps.getState()[e]}getPersistMetadata(){let e=this.deps.getState(),t=e.persist,i=this.persistMetaCache;if(i&&i.state===e&&i.snapshot.isSaving===t.isSaving&&i.snapshot.isRestoring===t.isRestoring&&i.snapshot.error===t.error)return i.snapshot;let r={isSaving:t.isSaving,isRestoring:t.isRestoring,error:t.error};return this.persistMetaCache={state:e,snapshot:r},r}getFieldState(e){let t=e,i=this.deps.getState(),r=this.fieldStateCache.get(t),n=m(i.values,t),o=i.errors[t],a=!!i.touched[t],l=this.deps.isHidden(t),c=this.deps.isRequired(t),p=this.deps.isFieldDirty(t),d=this.deps.isFieldValidating(t);if(r){let h=r.snapshot;if(h.value===n&&h.error===o&&h.touched===a&&h.isHidden===l&&h.isRequired===c&&h.isDirty===p&&h.isValidating===d)return h}let u=Ze({state:i,path:e,value:n,isHidden:l,isRequired:c,isDirty:p,isValidating:d});return this.fieldStateCache.set(t,{state:i,snapshot:u}),u}invalidatePath(e){this.fieldStateCache.delete(e)}invalidatePathTree(e){let t=`${e}.`;for(let i of this.fieldStateCache.keys())(i===e||i.startsWith(t))&&this.fieldStateCache.delete(i)}};var Ae=class{[j]=!0;[O]=!0;storeId;_config;read;observe;write;feature;constructor(e={}){let t=Jt({rawConfig:e});this._config=t.config,this.storeId=t.storeId;let i=new we({getState:()=>t.runtime.getState(),isHidden:o=>t.runtime.capabilities.query.isHidden(o),isRequired:o=>t.runtime.capabilities.query.isRequired(o),isFieldDirty:o=>t.runtime.capabilities.query.isFieldDirty(o),isFieldValidating:o=>t.runtime.capabilities.query.isFieldValidating(o)}),r=ci({runtime:t.runtime,config:this._config,fieldRegistry:t.fieldRegistry,dirtyManager:t.dirtyManager,stateReader:i}),n=pi({identity:{storeId:this.storeId,config:this._config},read:r.read,observe:r.observe,write:r.write,feature:r.feature,getFieldConfig:o=>t.fieldRegistry.getFieldConfig(o),resolveMask:o=>Xe({path:o,getFieldConfig:a=>t.fieldRegistry.getFieldConfig(a),masks:t.maskManager.getAllMasks()}),createArrayItemId:(o,a)=>this._config.idFactory({scope:"array",path:o,index:a})});this.read=n.read,this.observe=n.observe,this.write=n.write,this.feature=n.feature,t.runtime.effects.attachStorePort({getState:()=>this.read.getState(),getHistoryMetadata:()=>this.read.getHistoryMetadata(),undo:()=>this.feature.undo(),redo:()=>this.feature.redo(),reset:()=>this.write.reset()})}};function hi(s={}){return new Ae(s)}function fi(s){if(!s||typeof s!="object")return!1;let e=s;return e[j]===!0&&!!e.read&&!!e.observe&&!!e.write&&!!e.feature}function ji(s){if(fi(s))return s;throw new Error("BitForm: o store informado n\xE3o exp\xF5e a API necess\xE1ria para hooks/framework bindings.")}function Hi(s){return!s||typeof s!="object"?!1:s[O]===!0}function Ui(s){if(!fi(s))throw new Error("BitForm: o store informado n\xE3o possui branding de hooks (BIT_HOOKS_API_SYMBOL).");if(!Hi(s))throw new Error("BitForm: o store informado n\xE3o possui branding de framework (BIT_FRAMEWORK_STORE_SYMBOL).");return s}function zi(s){return Object.defineProperty(s,j,{value:!0,enumerable:!1,configurable:!1,writable:!1}),Object.defineProperty(s,O,{value:!0,enumerable:!1,configurable:!1,writable:!1}),s}function qi(s={}){let e=hi(s),t={read:e.read,observe:e.observe,write:e.write,feature:e.feature};return zi(t)}function _i(s){return s.read}function Li(s){return s.observe}function Wi(s){return s.write}function Ni(s){return s.feature}function Ki(s,e){let t={};for(let i of e)t[i]=s[i];return t}export{Re as a,Pi as b,ji as c,Ui as d,qi as e,_i as f,Li as g,Wi as h,Ni as i,Ki as j};
|
|
2
|
+
//# sourceMappingURL=chunk-B45EMB4Q.js.map
|