@betterinternship/components 3.0.4 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/README.md +45 -45
  2. package/dist/components/accordion.js.map +1 -1
  3. package/dist/components/animated-count.js.map +1 -1
  4. package/dist/components/animated-shiny-text.js +12 -0
  5. package/dist/components/animated-shiny-text.js.map +1 -0
  6. package/dist/components/app-header.js.map +1 -1
  7. package/dist/components/autocomplete.js +335 -0
  8. package/dist/components/autocomplete.js.map +1 -0
  9. package/dist/components/avatar.js.map +1 -1
  10. package/dist/components/badge.js.map +1 -1
  11. package/dist/components/banner.js.map +1 -1
  12. package/dist/components/button.js.map +1 -1
  13. package/dist/components/calendar.js.map +1 -1
  14. package/dist/components/card.js.map +1 -1
  15. package/dist/components/carousel.js +126 -0
  16. package/dist/components/carousel.js.map +1 -0
  17. package/dist/components/checkbox.js.map +1 -1
  18. package/dist/components/chip-select.js +22 -0
  19. package/dist/components/chip-select.js.map +1 -0
  20. package/dist/components/collapsible.js +45 -0
  21. package/dist/components/collapsible.js.map +1 -0
  22. package/dist/components/context-menu.js +37 -0
  23. package/dist/components/context-menu.js.map +1 -0
  24. package/dist/components/dialog.js +10 -10
  25. package/dist/components/dialog.js.map +1 -1
  26. package/dist/components/divider.js.map +1 -1
  27. package/dist/components/dot-matrix.js +163 -0
  28. package/dist/components/dot-matrix.js.map +1 -0
  29. package/dist/components/dropdown-menu.js.map +1 -1
  30. package/dist/components/dropdown.js +262 -0
  31. package/dist/components/dropdown.js.map +1 -0
  32. package/dist/components/error.js +19 -0
  33. package/dist/components/error.js.map +1 -0
  34. package/dist/components/fab.js +9 -0
  35. package/dist/components/fab.js.map +1 -0
  36. package/dist/components/file-upload.js.map +1 -1
  37. package/dist/components/filter-chip.js.map +1 -1
  38. package/dist/components/form-checkbox-group.js.map +1 -1
  39. package/dist/components/form-checkbox.js.map +1 -1
  40. package/dist/components/form-date-picker.js.map +1 -1
  41. package/dist/components/form-field.js.map +1 -1
  42. package/dist/components/form-input.js.map +1 -1
  43. package/dist/components/form-month-picker.js.map +1 -1
  44. package/dist/components/form-radio.js.map +1 -1
  45. package/dist/components/form-textarea.js.map +1 -1
  46. package/dist/components/form.js +71 -0
  47. package/dist/components/form.js.map +1 -0
  48. package/dist/components/hover-card.js +13 -0
  49. package/dist/components/hover-card.js.map +1 -0
  50. package/dist/components/input-otp.js +24 -0
  51. package/dist/components/input-otp.js.map +1 -0
  52. package/dist/components/input.js.map +1 -1
  53. package/dist/components/label.js.map +1 -1
  54. package/dist/components/loader.js.map +1 -1
  55. package/dist/components/magnetic-button.js +32 -0
  56. package/dist/components/magnetic-button.js.map +1 -0
  57. package/dist/components/messages.js +9 -0
  58. package/dist/components/messages.js.map +1 -0
  59. package/dist/components/mobile-sheet-portal.js +17 -0
  60. package/dist/components/mobile-sheet-portal.js.map +1 -0
  61. package/dist/components/page-header.js.map +1 -1
  62. package/dist/components/paginator.js +44 -0
  63. package/dist/components/paginator.js.map +1 -0
  64. package/dist/components/popover.js.map +1 -1
  65. package/dist/components/progress.js +11 -0
  66. package/dist/components/progress.js.map +1 -0
  67. package/dist/components/radio-group.js.map +1 -1
  68. package/dist/components/select.js.map +1 -1
  69. package/dist/components/sheet.d.ts +1 -1
  70. package/dist/components/sheet.js +40 -0
  71. package/dist/components/sheet.js.map +1 -0
  72. package/dist/components/skeleton.js.map +1 -1
  73. package/dist/components/slider.js +11 -0
  74. package/dist/components/slider.js.map +1 -0
  75. package/dist/components/sonner-toast.js +78 -0
  76. package/dist/components/sonner-toast.js.map +1 -0
  77. package/dist/components/stepper.js.map +1 -1
  78. package/dist/components/switch.js.map +1 -1
  79. package/dist/components/table.js.map +1 -1
  80. package/dist/components/tabs.js.map +1 -1
  81. package/dist/components/textarea.js.map +1 -1
  82. package/dist/components/time-input-native.js.map +1 -1
  83. package/dist/components/timeline.js +16 -0
  84. package/dist/components/timeline.js.map +1 -0
  85. package/dist/components/toggle.js +15 -0
  86. package/dist/components/toggle.js.map +1 -0
  87. package/dist/components/tooltip.js.map +1 -1
  88. package/dist/hooks/use-detect-click-outside.js +29 -0
  89. package/dist/hooks/use-detect-click-outside.js.map +1 -0
  90. package/dist/hooks/use-field-focus.js.map +1 -1
  91. package/dist/hooks/use-mobile-sheet-viewport.js.map +1 -1
  92. package/dist/hooks/use-mobile.js.map +1 -1
  93. package/dist/hooks/use-resource-table.js.map +1 -1
  94. package/dist/hooks/useMQJob.js.map +1 -1
  95. package/dist/index.d.ts +34 -3
  96. package/dist/index.js +30 -0
  97. package/dist/index.js.map +1 -1
  98. package/dist/lib/interaction-styles.js.map +1 -1
  99. package/dist/node_modules/embla-carousel/esm/embla-carousel.esm.js +1670 -0
  100. package/dist/node_modules/embla-carousel/esm/embla-carousel.esm.js.map +1 -0
  101. package/dist/node_modules/embla-carousel-react/esm/embla-carousel-react.esm.js +38 -0
  102. package/dist/node_modules/embla-carousel-react/esm/embla-carousel-react.esm.js.map +1 -0
  103. package/dist/node_modules/embla-carousel-reactive-utils/esm/embla-carousel-reactive-utils.esm.js +39 -0
  104. package/dist/node_modules/embla-carousel-reactive-utils/esm/embla-carousel-reactive-utils.esm.js.map +1 -0
  105. package/dist/node_modules/input-otp/dist/index.js +25 -0
  106. package/dist/node_modules/input-otp/dist/index.js.map +1 -0
  107. package/dist/node_modules/react-hook-form/dist/index.esm.js +706 -0
  108. package/dist/node_modules/react-hook-form/dist/index.esm.js.map +1 -0
  109. package/dist/utils.js.map +1 -1
  110. package/package.json +326 -291
  111. package/theme.css +355 -355
  112. package/theme.legacy.css +84 -84
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":["../../../../node_modules/react-hook-form/dist/index.esm.mjs"],"sourcesContent":["import React from 'react';\n\nvar isCheckBoxInput = (element) => element.type === 'checkbox';\n\nvar isFileInput = (element) => element.type === 'file';\n\nvar isDateObject = (value) => value instanceof Date;\n\nvar isNullOrUndefined = (value) => value == null;\n\nconst isObjectType = (value) => typeof value === 'object';\nvar isObject = (value) => !isNullOrUndefined(value) &&\n !Array.isArray(value) &&\n isObjectType(value) &&\n !isDateObject(value);\n\nvar getEventValue = (event) => isObject(event) && event.target\n ? isCheckBoxInput(event.target)\n ? event.target.checked\n : isFileInput(event.target)\n ? event.target.files\n : event.target.value\n : event;\n\nconst FIELD_PATH_RE = /[.[\\]'\"]/;\nvar stringToPath = (input) => input.split(FIELD_PATH_RE).filter(Boolean);\n\nfunction getNullAncestorValue(control, name) {\n const segments = stringToPath(name);\n let formValues = control._formValues;\n let defaultValues = control._defaultValues;\n for (let i = 0; i < segments.length - 1; i++) {\n const key = segments[i];\n formValues =\n formValues == null\n ? formValues\n : formValues[key];\n defaultValues =\n defaultValues == null\n ? defaultValues\n : defaultValues[key];\n if (formValues === null || defaultValues === null) {\n return null;\n }\n }\n return undefined;\n}\n\nvar isNameInFieldArray = (names, name) => name\n .split('.')\n .some((part, index, arr) => !isNaN(Number(part)) && names.has(arr.slice(0, index).join('.')));\n\nvar isWeb = typeof window !== 'undefined' &&\n typeof window.HTMLElement !== 'undefined' &&\n typeof document !== 'undefined';\n\nfunction cloneObject(data) {\n if (data === null || typeof data !== 'object') {\n return data;\n }\n if (data instanceof Date) {\n return new Date(data);\n }\n const isBlobInstance = typeof Blob !== 'undefined' && data instanceof Blob;\n const isFileListInstance = typeof FileList !== 'undefined' && data instanceof FileList;\n if (isWeb && (isBlobInstance || isFileListInstance)) {\n return data;\n }\n const isArray = Array.isArray(data);\n const prototype = Object.getPrototypeOf(data);\n if (!isArray && prototype && prototype.constructor !== Object) {\n return data;\n }\n const copy = isArray ? new Array(data.length) : Object.create(prototype);\n for (const key in data) {\n if (Object.prototype.hasOwnProperty.call(data, key)) {\n copy[key] = cloneObject(data[key]);\n }\n }\n return copy;\n}\n\nconst EVENTS = {\n BLUR: 'blur',\n FOCUS_OUT: 'focusout',\n CHANGE: 'change',\n SUBMIT: 'submit',\n TRIGGER: 'trigger',\n VALID: 'valid',\n};\nconst VALIDATION_MODE = {\n onBlur: 'onBlur',\n onChange: 'onChange',\n onSubmit: 'onSubmit',\n onTouched: 'onTouched',\n all: 'all',\n};\nconst INPUT_VALIDATION_RULES = {\n max: 'max',\n min: 'min',\n maxLength: 'maxLength',\n minLength: 'minLength',\n pattern: 'pattern',\n required: 'required',\n validate: 'validate',\n};\nconst REGISTER_VALIDATION_RULES = [\n INPUT_VALIDATION_RULES.required,\n INPUT_VALIDATION_RULES.min,\n INPUT_VALIDATION_RULES.max,\n INPUT_VALIDATION_RULES.minLength,\n INPUT_VALIDATION_RULES.maxLength,\n INPUT_VALIDATION_RULES.pattern,\n INPUT_VALIDATION_RULES.validate,\n];\nconst FORM_ERROR_TYPE = 'form';\nconst ROOT_ERROR_TYPE = 'root';\nconst PROTOTYPE_KEYWORDS = ['__proto__', 'constructor', 'prototype'];\n\nconst IS_KEY_RE = /^\\w*$/;\nvar isKey = (value) => IS_KEY_RE.test(value);\n\nvar isUndefined = (val) => val === undefined;\n\nvar get = (object, path, defaultValue) => {\n if (!path || !isObject(object)) {\n return defaultValue;\n }\n const paths = isKey(path) ? [path] : stringToPath(path);\n if (paths.some((key) => PROTOTYPE_KEYWORDS.includes(key))) {\n return defaultValue;\n }\n const result = paths.reduce((result, key) => {\n return isNullOrUndefined(result)\n ? undefined\n : result[key];\n }, object);\n return (isUndefined(result) || result === object\n ? isUndefined(object[path])\n ? defaultValue\n : object[path]\n : result);\n};\n\nvar isBoolean = (value) => typeof value === 'boolean';\n\nvar isFunction = (value) => typeof value === 'function';\n\nvar set = (object, path, value) => {\n let index = -1;\n const tempPath = isKey(path) ? [path] : stringToPath(path);\n const length = tempPath.length;\n const lastIndex = length - 1;\n while (++index < length) {\n const key = tempPath[index];\n let newValue = value;\n if (index !== lastIndex) {\n const objValue = object[key];\n newValue =\n isObject(objValue) || Array.isArray(objValue)\n ? objValue\n : !isNaN(+tempPath[index + 1])\n ? []\n : {};\n }\n if (PROTOTYPE_KEYWORDS.includes(key)) {\n return;\n }\n object[key] = newValue;\n object = object[key];\n }\n};\n\n/**\n * Separate context for `control` to prevent unnecessary rerenders.\n * Internal hooks that only need control use this instead of full form context.\n */\nconst HookFormControlContext = React.createContext(null);\nHookFormControlContext.displayName = 'HookFormControlContext';\n/**\n * @internal Internal hook to access only control from context.\n */\nconst useFormControlContext = () => React.useContext(HookFormControlContext);\n\nvar getProxyFormState = (formState, control, localProxyFormState, isRoot = true) => {\n const result = {};\n for (const key in formState) {\n Object.defineProperty(result, key, {\n get: () => {\n const _key = key;\n if (control._proxyFormState[_key] !== VALIDATION_MODE.all) {\n control._proxyFormState[_key] = !isRoot || VALIDATION_MODE.all;\n }\n localProxyFormState && (localProxyFormState[_key] = true);\n return formState[_key];\n },\n });\n }\n return result;\n};\n\nconst useIsomorphicLayoutEffect = isWeb\n ? React.useLayoutEffect\n : React.useEffect;\n\nvar isPlainObject = (tempObject) => {\n const prototypeCopy = tempObject.constructor && tempObject.constructor.prototype;\n return (isObject(prototypeCopy) && prototypeCopy.hasOwnProperty('isPrototypeOf'));\n};\n\nvar isPrimitive = (value) => isNullOrUndefined(value) || !isObjectType(value);\n\nconst isEmptyObjectWithCustomPrototype = (object, keys) => keys.length === 0 &&\n !Array.isArray(object) &&\n Object.getPrototypeOf(object) !== null &&\n !isPlainObject(object);\nfunction deepEqual(object1, object2, isErrorObject = false, visited = new WeakMap()) {\n if (object1 === object2) {\n return true;\n }\n if (isPrimitive(object1) || isPrimitive(object2)) {\n return Object.is(object1, object2);\n }\n if (isDateObject(object1) && isDateObject(object2)) {\n return Object.is(object1.getTime(), object2.getTime());\n }\n if (Array.isArray(object1) &&\n Array.isArray(object2) &&\n object1.length !== object2.length) {\n return false;\n }\n const keys1 = Object.keys(object1);\n const keys2 = Object.keys(object2);\n if (keys1.length !== keys2.length) {\n return false;\n }\n if (isEmptyObjectWithCustomPrototype(object1, keys1) ||\n isEmptyObjectWithCustomPrototype(object2, keys2)) {\n return Object.is(object1, object2);\n }\n if (!keys1.length && Array.isArray(object1) !== Array.isArray(object2)) {\n return false;\n }\n const visitedPairs = visited.get(object1);\n if (visitedPairs && visitedPairs.has(object2)) {\n return true;\n }\n if (visitedPairs) {\n visitedPairs.add(object2);\n }\n else {\n const ws = new WeakSet();\n ws.add(object2);\n visited.set(object1, ws);\n }\n for (const key of keys1) {\n const val1 = object1[key];\n if (!Object.prototype.hasOwnProperty.call(object2, key)) {\n return false;\n }\n if (!isErrorObject || key !== 'ref') {\n const val2 = object2[key];\n if ((isDateObject(val1) && isDateObject(val2)) ||\n ((isObject(val1) || Array.isArray(val1)) &&\n (isObject(val2) || Array.isArray(val2)))\n ? !deepEqual(val1, val2, isErrorObject, visited)\n : !Object.is(val1, val2)) {\n return false;\n }\n }\n }\n return true;\n}\n\nfunction useResyncOnReconnect(getInitialValue) {\n const _connected = React.useRef(false);\n const _initialized = React.useRef(false);\n const _prevValue = React.useRef(undefined);\n const _renderCount = React.useRef(0);\n _renderCount.current++;\n if (!_initialized.current && getInitialValue) {\n _initialized.current = true;\n _prevValue.current = cloneObject(getInitialValue());\n }\n const resyncIfNeeded = React.useCallback((enabled, getCurrentValue, setValue) => {\n if (enabled &&\n (_connected.current ||\n (_initialized.current && _renderCount.current > 1))) {\n const currentValue = getCurrentValue();\n if (!deepEqual(_prevValue.current, currentValue)) {\n setValue(currentValue);\n }\n }\n _connected.current = true;\n }, []);\n const snapshot = React.useCallback((enabled, getCurrentValue) => {\n if (enabled) {\n _prevValue.current = cloneObject(getCurrentValue());\n }\n }, []);\n return { resyncIfNeeded, snapshot };\n}\n\n/**\n * Subscribes to form state with re-renders isolated to this hook.\n * Optionally scope to specific field names to minimize re-render surface.\n *\n * @see [API](https://react-hook-form.com/docs/useformstate)\n *\n * @example\n * ```tsx\n * const { errors, isDirty } = useFormState({ control, name: \"email\" });\n * ```\n */\nfunction useFormState(props) {\n const formControl = useFormControlContext();\n const { control = formControl, disabled, name, exact } = props || {};\n const getCurrentFormState = () => ({\n ...control._formState,\n defaultValues: control._defaultValues,\n });\n const [formState, updateFormState] = React.useState(getCurrentFormState);\n const _localProxyFormState = React.useRef({\n isDirty: false,\n isLoading: false,\n dirtyFields: false,\n touchedFields: false,\n validatingFields: false,\n isValidating: false,\n isValid: false,\n errors: false,\n });\n const { resyncIfNeeded, snapshot } = useResyncOnReconnect(getCurrentFormState);\n useIsomorphicLayoutEffect(() => {\n resyncIfNeeded(!disabled, getCurrentFormState, updateFormState);\n const unsubscribe = control._subscribe({\n name,\n formState: _localProxyFormState.current,\n exact,\n callback: (formState) => {\n !disabled &&\n updateFormState({\n ...control._formState,\n ...formState,\n defaultValues: control._defaultValues,\n });\n },\n });\n return () => {\n unsubscribe();\n snapshot(!disabled, getCurrentFormState);\n };\n }, [control, name, disabled, exact, resyncIfNeeded, snapshot]);\n React.useEffect(() => {\n _localProxyFormState.current.isValid && control._setValid(true);\n }, [control]);\n return React.useMemo(() => getProxyFormState(formState, control, _localProxyFormState.current, false), [formState, control]);\n}\n\nvar isString = (value) => typeof value === 'string';\n\nvar generateWatchOutput = (names, _names, formValues, isGlobal, defaultValue) => {\n if (isString(names)) {\n isGlobal && _names.watch.add(names);\n return get(formValues, names, defaultValue);\n }\n if (Array.isArray(names)) {\n return names.map((fieldName) => (isGlobal && _names.watch.add(fieldName),\n get(formValues, fieldName, get(defaultValue, fieldName))));\n }\n isGlobal && (_names.watchAll = true);\n return formValues;\n};\n\n/**\n * Subscribes to field value changes and isolates re-renders to the hook level.\n *\n * @see [API](https://react-hook-form.com/docs/usewatch)\n *\n * @example\n * ```tsx\n * const email = useWatch({ control, name: \"email\" });\n * const all = useWatch({ control });\n * const adult = useWatch({ control, name: \"age\", compute: (v) => v >= 18 });\n * ```\n */\nfunction useWatch(props) {\n const formControl = useFormControlContext();\n const { control = formControl, name, defaultValue, disabled, exact, compute, } = props || {};\n const _defaultValue = React.useRef(defaultValue);\n const _compute = React.useRef(compute);\n const _prevControl = React.useRef(control);\n const _prevName = React.useRef(name);\n _compute.current = compute;\n const getInitialOutput = () => {\n const defaultValue = control._getWatch(name, _defaultValue.current);\n return _compute.current ? _compute.current(defaultValue) : defaultValue;\n };\n const [value, updateValue] = React.useState(getInitialOutput);\n const _computeFormValues = React.useRef(value);\n const getCurrentOutput = React.useCallback((values) => {\n const formValues = generateWatchOutput(name, control._names, values || control._formValues, false, _defaultValue.current);\n return _compute.current\n ? _compute.current(formValues)\n : formValues;\n }, [control._formValues, control._names, name]);\n const refreshValue = React.useCallback((values) => {\n if (!disabled) {\n const formValues = generateWatchOutput(name, control._names, values || control._formValues, false, _defaultValue.current);\n if (_compute.current) {\n const computedFormValues = _compute.current(formValues);\n if (!deepEqual(computedFormValues, _computeFormValues.current)) {\n updateValue(computedFormValues);\n _computeFormValues.current = computedFormValues;\n }\n }\n else {\n updateValue(formValues);\n }\n }\n }, [control._formValues, control._names, disabled, name]);\n const { resyncIfNeeded, snapshot } = useResyncOnReconnect(getInitialOutput);\n const _refreshValue = React.useRef(refreshValue);\n _refreshValue.current = refreshValue;\n const _getCurrentOutput = React.useRef(getCurrentOutput);\n _getCurrentOutput.current = getCurrentOutput;\n useIsomorphicLayoutEffect(() => {\n if (_prevControl.current !== control ||\n !deepEqual(_prevName.current, name)) {\n _prevControl.current = control;\n _prevName.current = name;\n _refreshValue.current();\n }\n else {\n resyncIfNeeded(!disabled, () => _getCurrentOutput.current(), (currentValue) => {\n const nextValue = cloneObject(currentValue);\n updateValue(nextValue);\n _computeFormValues.current = nextValue;\n });\n }\n const unsubscribe = control._subscribe({\n name,\n formState: {\n values: true,\n },\n exact,\n callback: (formState) => {\n _refreshValue.current(formState.values);\n },\n });\n return () => {\n unsubscribe();\n snapshot(!disabled, () => _getCurrentOutput.current());\n };\n }, [control, exact, name, disabled, resyncIfNeeded, snapshot]);\n React.useEffect(() => control._removeUnmounted());\n // If name or control changed for this render, synchronously reflect the\n // latest value so callers (like useController) see the correct value\n // immediately on the same render.\n // Optimize: Check control reference first before expensive deepEqual\n const controlChanged = _prevControl.current !== control;\n const prevName = _prevName.current;\n const nameChanged = React.useMemo(() => !controlChanged && !deepEqual(prevName, name), [controlChanged, name, prevName]);\n if (controlChanged || nameChanged) {\n _defaultValue.current = defaultValue;\n }\n const shouldReturnImmediate = !disabled && (controlChanged || nameChanged);\n return shouldReturnImmediate ? getCurrentOutput() : value;\n}\n\n/**\n * Hook for controlled inputs. Returns `field`, `fieldState`, and `formState`.\n * Re-renders are isolated to the hook level.\n *\n * @see [API](https://react-hook-form.com/docs/usecontroller)\n *\n * @example\n * ```tsx\n * const { field, fieldState } = useController({ control, name: \"email\" });\n * return <input {...field} />;\n * ```\n */\nfunction useController(props) {\n const formControl = useFormControlContext();\n const { name, disabled, control = formControl, shouldUnregister, defaultValue, exact = true, } = props;\n const isArrayField = isNameInFieldArray(control._names.array, name);\n const defaultValueMemo = React.useMemo(() => {\n const resolved = get(control._formValues, name, get(control._defaultValues, name, defaultValue));\n return (isUndefined(resolved) ? getNullAncestorValue(control, name) : resolved);\n }, [control, name, defaultValue]);\n const value = useWatch({\n control,\n name,\n defaultValue: defaultValueMemo,\n exact,\n });\n const formState = useFormState({\n control,\n name,\n exact,\n });\n const _props = React.useRef(props);\n const _proxyRef = React.useRef(null);\n const _registerProps = React.useRef(control.register(name, {\n ...props.rules,\n value,\n ...(isBoolean(props.disabled) ? { disabled: props.disabled } : {}),\n }));\n _props.current = props;\n const fieldState = React.useMemo(() => Object.defineProperties({}, {\n invalid: {\n enumerable: true,\n get: () => !!get(formState.errors, name),\n },\n isDirty: {\n enumerable: true,\n get: () => !!get(formState.dirtyFields, name),\n },\n isTouched: {\n enumerable: true,\n get: () => !!get(formState.touchedFields, name),\n },\n isValidating: {\n enumerable: true,\n get: () => !!get(formState.validatingFields, name),\n },\n error: {\n enumerable: true,\n get: () => get(formState.errors, name),\n },\n }), [formState, name]);\n const onChange = React.useCallback((event) => {\n const value = getEventValue(event);\n if (!get(control._fields, name)) {\n _registerProps.current = control.register(name, {\n ..._props.current.rules,\n value,\n });\n }\n return _registerProps.current.onChange({\n target: {\n value: getEventValue(event),\n name,\n },\n type: EVENTS.CHANGE,\n });\n }, [name, control]);\n const onBlur = React.useCallback(() => {\n const value = get(control._formValues, name);\n if (!get(control._fields, name)) {\n _registerProps.current = control.register(name, {\n ..._props.current.rules,\n value,\n });\n }\n return _registerProps.current.onBlur({\n target: {\n value,\n name,\n },\n type: EVENTS.BLUR,\n });\n }, [name, control]);\n const ref = React.useCallback((elm) => {\n if (elm) {\n _proxyRef.current = {\n focus: () => isFunction(elm.focus) && elm.focus(),\n select: () => isFunction(elm.select) && elm.select(),\n setCustomValidity: (message) => isFunction(elm.setCustomValidity) && elm.setCustomValidity(message),\n reportValidity: () => isFunction(elm.reportValidity) && elm.reportValidity(),\n };\n }\n const field = get(control._fields, name);\n if (field && field._f && elm) {\n field._f.ref = _proxyRef.current;\n field._f._c = true;\n }\n }, [control._fields, name]);\n const field = React.useMemo(() => ({\n name,\n value,\n ...(isBoolean(disabled) || formState.disabled\n ? { disabled: formState.disabled || disabled }\n : {}),\n onChange,\n onBlur,\n ref,\n }), [name, disabled, formState.disabled, onChange, onBlur, ref, value]);\n React.useEffect(() => {\n const _shouldUnregisterField = control._options.shouldUnregister || shouldUnregister;\n _registerProps.current = control.register(name, {\n ..._props.current.rules,\n ...(isBoolean(_props.current.disabled)\n ? { disabled: _props.current.disabled }\n : {}),\n });\n const updateMounted = (name, value) => {\n const field = get(control._fields, name);\n if (field && field._f) {\n field._f.mount = value;\n field._f._c = value;\n }\n };\n updateMounted(name, true);\n if (_shouldUnregisterField) {\n const value = cloneObject(get(shouldUnregister\n ? control._defaultValues\n : control._options.values || control._defaultValues, name, get(control._options.defaultValues, name, _props.current.defaultValue)));\n set(control._defaultValues, name, value);\n if (isUndefined(get(control._formValues, name))) {\n set(control._formValues, name, value);\n }\n }\n !isArrayField &&\n control.register(name, {\n ..._props.current.rules,\n ...(isBoolean(_props.current.disabled)\n ? { disabled: _props.current.disabled }\n : {}),\n });\n if (_proxyRef.current) {\n const field = get(control._fields, name);\n if (field && field._f) {\n field._f.ref = _proxyRef.current;\n }\n }\n return () => {\n (isArrayField\n ? _shouldUnregisterField && !control._state.action\n : _shouldUnregisterField)\n ? control.unregister(name)\n : updateMounted(name, false);\n };\n }, [name, control, isArrayField, shouldUnregister]);\n React.useEffect(() => {\n control._setDisabledField({\n disabled,\n name,\n });\n }, [disabled, name, control]);\n return React.useMemo(() => ({\n field,\n formState,\n fieldState,\n }), [field, formState, fieldState]);\n}\n\n/**\n * Component wrapper around `useController` for controlled inputs.\n *\n * @see [API](https://react-hook-form.com/docs/usecontroller/controller)\n *\n * @example\n * ```tsx\n * <Controller\n * control={control}\n * name=\"test\"\n * render={({ field, fieldState, formState }) => <input {...field} />}\n * />\n * ```\n */\nconst Controller = (props) => props.render(useController(props));\n\n/**\n * Displays the validation error for a single field.\n * Reads from `control` when provided, otherwise from the nearest `FormProvider`.\n *\n * @see [API](https://react-hook-form.com/docs/useformstate/errormessage)\n *\n * @example\n * ```tsx\n * <ErrorMessage control={control} name=\"email\" as=\"p\" />\n * <ErrorMessage name=\"email\" as=\"span\" />\n * <ErrorMessage control={control} name=\"email\"\n * render={({ message }) => <Alert>{message}</Alert>} />\n * ```\n */\nconst ErrorMessage = ({ as, control, name, render, }) => {\n const { errors } = useFormState({\n control,\n name: name,\n });\n const error = get(errors, name);\n if (!error) {\n return null;\n }\n const message = error.message || '';\n if (render) {\n return render({ message, messages: error.types });\n }\n return React.createElement(as || React.Fragment, null, message);\n};\n\nvar generateId = () => typeof crypto !== 'undefined' && crypto.randomUUID\n ? crypto.randomUUID()\n : 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = (Math.random() * 16) | 0;\n return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16);\n });\n\nvar getFocusFieldName = (name, index, options = {}) => options.shouldFocus || isUndefined(options.shouldFocus)\n ? options.focusName ||\n `${name}.${isUndefined(options.focusIndex) ? index : options.focusIndex}.`\n : '';\n\nvar getValidationModes = (mode) => ({\n isOnSubmit: !mode || mode === VALIDATION_MODE.onSubmit,\n isOnBlur: mode === VALIDATION_MODE.onBlur,\n isOnChange: mode === VALIDATION_MODE.onChange,\n isOnAll: mode === VALIDATION_MODE.all,\n isOnTouch: mode === VALIDATION_MODE.onTouched,\n});\n\nvar isWatched = (name, _names, isBlurEvent) => {\n if (isBlurEvent)\n return false;\n if (_names.watchAll || _names.watch.has(name))\n return true;\n for (const watchName of _names.watch) {\n if (name.startsWith(watchName) && name.charAt(watchName.length) === '.')\n return true;\n }\n return false;\n};\n\nconst iterateFieldsByAction = (fields, action, fieldsNames) => {\n for (const key of fieldsNames || Object.keys(fields)) {\n if (key === '_f') {\n continue;\n }\n const field = (fieldsNames ? get(fields, key) : fields[key]);\n if (field) {\n const { _f } = field;\n if (_f) {\n if (_f.refs && _f.refs[0] && action(_f.refs[0], _f.name)) {\n return true;\n }\n else if (_f.ref && action(_f.ref, _f.name)) {\n return true;\n }\n else {\n if (iterateFieldsByAction(field, action)) {\n return true;\n }\n }\n }\n else if (isObject(field) || Array.isArray(field)) {\n if (iterateFieldsByAction(field, action)) {\n return true;\n }\n }\n }\n }\n return;\n};\n\nvar updateFieldArrayRootError = (errors, error, name) => {\n const existingErrors = get(errors, name);\n const fieldArrayErrors = Array.isArray(existingErrors) ? existingErrors : [];\n set(fieldArrayErrors, ROOT_ERROR_TYPE, error[name]);\n set(errors, name, fieldArrayErrors);\n return errors;\n};\n\nvar isEmptyObject = (value) => isObject(value) && !Object.keys(value).length;\n\nvar isHTMLElement = (value) => {\n if (!isWeb) {\n return false;\n }\n const owner = value ? value.ownerDocument : 0;\n return (value instanceof\n (owner && owner.defaultView ? owner.defaultView.HTMLElement : HTMLElement));\n};\n\nvar isRadioInput = (element) => element.type === 'radio';\n\nvar isRegex = (value) => value instanceof RegExp;\n\nvar appendErrors = (name, validateAllFieldCriteria, errors, type, message) => validateAllFieldCriteria\n ? {\n ...errors[name],\n types: {\n ...(errors[name] && errors[name].types ? errors[name].types : {}),\n [type]: message || true,\n },\n }\n : {};\n\nconst defaultResult = {\n value: false,\n isValid: false,\n};\nconst validResult = { value: true, isValid: true };\nvar getCheckboxValue = (options) => {\n if (!Array.isArray(options)) {\n return defaultResult;\n }\n if (options.length > 1) {\n const values = options\n .filter((option) => option && option.checked && !option.disabled)\n .map((option) => option.value);\n return { value: values, isValid: !!values.length };\n }\n const option = options[0];\n if (!option || !option.checked || option.disabled) {\n return defaultResult;\n }\n if (!option.attributes || !('value' in option.attributes)) {\n return validResult;\n }\n return isUndefined(option.value) || option.value === ''\n ? validResult\n : { value: option.value, isValid: true };\n};\n\nconst defaultReturn = {\n isValid: false,\n value: null,\n};\nvar getRadioValue = (options) => Array.isArray(options)\n ? options.reduce((previous, option) => option && option.checked && !option.disabled\n ? {\n isValid: true,\n value: option.value,\n }\n : previous, defaultReturn)\n : defaultReturn;\n\nfunction getValidateError(result, ref, type = 'validate') {\n if (isString(result) ||\n (Array.isArray(result) && !!result.length && result.every(isString)) ||\n (isBoolean(result) && !result)) {\n return {\n type,\n message: isString(result) ? result : '',\n ref,\n };\n }\n}\n\nvar getValueAndMessage = (validationData) => isObject(validationData) && !isRegex(validationData)\n ? validationData\n : {\n value: validationData,\n message: '',\n };\n\nvar validateField = async (field, disabledFieldNames, formValues, validateAllFieldCriteria, shouldUseNativeValidation, isFieldArray) => {\n const { ref, refs, required, maxLength, minLength, min, max, pattern, validate, name, valueAsNumber, mount, _c, } = field._f;\n const inputValue = get(formValues, name);\n if (!mount || disabledFieldNames.has(name)) {\n return {};\n }\n const inputRef = refs ? refs[0] : ref;\n const setCustomValidity = (message) => {\n if (shouldUseNativeValidation && inputRef.reportValidity) {\n const validityMessage = isBoolean(message) ? '' : message || '';\n if (refs) {\n refs.forEach((ref) => isFunction(ref.setCustomValidity) &&\n ref.setCustomValidity(validityMessage));\n }\n else {\n inputRef.setCustomValidity(validityMessage);\n }\n inputRef.reportValidity();\n }\n };\n const error = {};\n const isRadio = !_c && isRadioInput(ref);\n const isCheckBox = !_c && isCheckBoxInput(ref);\n const isRadioOrCheckbox = isRadio || isCheckBox;\n const isEmpty = ((valueAsNumber || isFileInput(ref)) &&\n isUndefined(ref.value) &&\n isUndefined(inputValue)) ||\n (isHTMLElement(ref) && ref.value === '' && !_c) ||\n inputValue === '' ||\n (Array.isArray(inputValue) && !inputValue.length);\n const appendErrorsCurry = appendErrors.bind(null, name, validateAllFieldCriteria, error);\n const getMinMaxMessage = (exceedMax, maxLengthMessage, minLengthMessage, maxType = INPUT_VALIDATION_RULES.maxLength, minType = INPUT_VALIDATION_RULES.minLength) => {\n const message = exceedMax ? maxLengthMessage : minLengthMessage;\n error[name] = {\n type: exceedMax ? maxType : minType,\n message,\n ref,\n ...appendErrorsCurry(exceedMax ? maxType : minType, message),\n };\n };\n if (isFieldArray\n ? !Array.isArray(inputValue) || !inputValue.length\n : required &&\n ((!isRadioOrCheckbox && (isEmpty || isNullOrUndefined(inputValue))) ||\n (isBoolean(inputValue) && !inputValue) ||\n (isCheckBox && !getCheckboxValue(refs).isValid) ||\n (isRadio && !getRadioValue(refs).isValid))) {\n const { value, message } = isString(required)\n ? { value: !!required, message: required }\n : getValueAndMessage(required);\n if (value) {\n error[name] = {\n type: INPUT_VALIDATION_RULES.required,\n message,\n ref: inputRef,\n ...appendErrorsCurry(INPUT_VALIDATION_RULES.required, message),\n };\n if (!validateAllFieldCriteria) {\n setCustomValidity(message);\n return error;\n }\n }\n }\n if (!isEmpty && (!isNullOrUndefined(min) || !isNullOrUndefined(max))) {\n let exceedMax;\n let exceedMin;\n const maxOutput = getValueAndMessage(max);\n const minOutput = getValueAndMessage(min);\n if (!isNullOrUndefined(inputValue) &&\n !isDateObject(inputValue) &&\n !isNaN(inputValue)) {\n const valueNumber = (!_c && ref.valueAsNumber) ||\n (inputValue ? +inputValue : inputValue);\n if (!isNullOrUndefined(maxOutput.value)) {\n exceedMax = valueNumber > maxOutput.value;\n }\n if (!isNullOrUndefined(minOutput.value)) {\n exceedMin = valueNumber < minOutput.value;\n }\n }\n else {\n const valueDate = (!_c && ref.valueAsDate) ||\n new Date(inputValue);\n const convertTimeToDate = (time) => new Date(new Date().toDateString() + ' ' + time);\n const isTime = ref.type == 'time';\n const isWeek = ref.type == 'week';\n if (isString(maxOutput.value) && inputValue) {\n exceedMax = isTime\n ? convertTimeToDate(inputValue) > convertTimeToDate(maxOutput.value)\n : isWeek\n ? inputValue > maxOutput.value\n : valueDate > new Date(maxOutput.value);\n }\n if (isString(minOutput.value) && inputValue) {\n exceedMin = isTime\n ? convertTimeToDate(inputValue) < convertTimeToDate(minOutput.value)\n : isWeek\n ? inputValue < minOutput.value\n : valueDate < new Date(minOutput.value);\n }\n }\n if (exceedMax || exceedMin) {\n getMinMaxMessage(!!exceedMax, maxOutput.message, minOutput.message, INPUT_VALIDATION_RULES.max, INPUT_VALIDATION_RULES.min);\n if (!validateAllFieldCriteria) {\n setCustomValidity(error[name].message);\n return error;\n }\n }\n }\n if ((!isNullOrUndefined(maxLength) || !isNullOrUndefined(minLength)) &&\n !isEmpty &&\n (isString(inputValue) || (isFieldArray && Array.isArray(inputValue)))) {\n const maxLengthOutput = getValueAndMessage(maxLength);\n const minLengthOutput = getValueAndMessage(minLength);\n const exceedMax = !isNullOrUndefined(maxLengthOutput.value) &&\n inputValue.length > +maxLengthOutput.value;\n const exceedMin = !isNullOrUndefined(minLengthOutput.value) &&\n inputValue.length < +minLengthOutput.value;\n if (exceedMax || exceedMin) {\n getMinMaxMessage(exceedMax, maxLengthOutput.message, minLengthOutput.message);\n if (!validateAllFieldCriteria) {\n setCustomValidity(error[name].message);\n return error;\n }\n }\n }\n if (pattern && !isEmpty && isString(inputValue)) {\n const { value: patternValue, message } = getValueAndMessage(pattern);\n if (isRegex(patternValue) && !inputValue.match(patternValue)) {\n error[name] = {\n type: INPUT_VALIDATION_RULES.pattern,\n message,\n ref,\n ...appendErrorsCurry(INPUT_VALIDATION_RULES.pattern, message),\n };\n if (!validateAllFieldCriteria) {\n setCustomValidity(message);\n return error;\n }\n }\n }\n if (validate) {\n if (isFunction(validate)) {\n const result = await validate(inputValue, formValues);\n const validateError = getValidateError(result, inputRef);\n if (validateError) {\n error[name] = {\n ...validateError,\n ...appendErrorsCurry(INPUT_VALIDATION_RULES.validate, validateError.message),\n };\n if (!validateAllFieldCriteria) {\n setCustomValidity(validateError.message);\n return error;\n }\n }\n }\n else if (isObject(validate)) {\n let validationResult = {};\n for (const key in validate) {\n if (!isEmptyObject(validationResult) && !validateAllFieldCriteria) {\n break;\n }\n const validateError = getValidateError(await validate[key](inputValue, formValues), inputRef, key);\n if (validateError) {\n validationResult = {\n ...validateError,\n ...appendErrorsCurry(key, validateError.message),\n };\n if (!validateAllFieldCriteria) {\n setCustomValidity(validateError.message);\n }\n if (validateAllFieldCriteria) {\n error[name] = validationResult;\n }\n }\n }\n if (!isEmptyObject(validationResult)) {\n error[name] = {\n ref: inputRef,\n ...validationResult,\n };\n if (!validateAllFieldCriteria) {\n return error;\n }\n }\n }\n }\n const fieldError = error[name];\n setCustomValidity(fieldError ? fieldError.message : true);\n return error;\n};\n\nvar convertToArrayPayload = (value) => (Array.isArray(value) ? value : [value]);\n\nvar appendAt = (data, value) => [\n ...data,\n ...convertToArrayPayload(value),\n];\n\nvar fillEmptyArray = (value) => Array.isArray(value) ? value.map(() => undefined) : undefined;\n\nfunction insert(data, index, value) {\n return [\n ...data.slice(0, index),\n ...convertToArrayPayload(value),\n ...data.slice(index),\n ];\n}\n\nvar moveArrayAt = (data, from, to) => {\n if (!Array.isArray(data)) {\n return [];\n }\n if (isUndefined(data[to])) {\n data[to] = undefined;\n }\n data.splice(to, 0, data.splice(from, 1)[0]);\n return data;\n};\n\nvar prependAt = (data, value) => [\n ...convertToArrayPayload(value),\n ...convertToArrayPayload(data),\n];\n\nvar compact = (value) => Array.isArray(value) ? value.filter(Boolean) : [];\n\nfunction removeAtIndexes(data, indexes) {\n let i = 0;\n const temp = [...data];\n for (const index of indexes) {\n temp.splice(index - i, 1);\n i++;\n }\n return compact(temp).length ? temp : [];\n}\nvar removeArrayAt = (data, index) => isUndefined(index)\n ? []\n : removeAtIndexes(data, [...new Set(convertToArrayPayload(index))].sort((a, b) => a - b));\n\nvar swapArrayAt = (data, indexA, indexB) => {\n [data[indexA], data[indexB]] = [data[indexB], data[indexA]];\n};\n\nfunction baseGet(object, updatePath) {\n const length = updatePath.length - 1;\n let index = 0;\n while (index < length) {\n if (isNullOrUndefined(object)) {\n object = undefined;\n break;\n }\n object = object[updatePath[index]];\n index++;\n }\n return object;\n}\nfunction isEmptyArray(obj) {\n for (const key in obj) {\n if (obj.hasOwnProperty(key) && !isUndefined(obj[key])) {\n return false;\n }\n }\n return true;\n}\nfunction unset(object, path) {\n if (isString(path) && Object.prototype.hasOwnProperty.call(object, path)) {\n delete object[path];\n return object;\n }\n const paths = Array.isArray(path)\n ? path\n : isKey(path)\n ? [path]\n : stringToPath(path);\n if (paths.some((segment) => PROTOTYPE_KEYWORDS.includes(String(segment)))) {\n return object;\n }\n const childObject = paths.length === 1 ? object : baseGet(object, paths);\n const index = paths.length - 1;\n const key = paths[index];\n if (childObject) {\n delete childObject[key];\n }\n if (index !== 0 &&\n ((isObject(childObject) && isEmptyObject(childObject)) ||\n (Array.isArray(childObject) && isEmptyArray(childObject)))) {\n unset(object, paths.slice(0, -1));\n }\n return object;\n}\n\nvar updateAt = (fieldValues, index, value) => {\n fieldValues[index] = value;\n return fieldValues;\n};\n\n/**\n * Hook for dynamic field arrays. Provides `fields` and mutation methods:\n * `append`, `prepend`, `remove`, `insert`, `swap`, `move`, `update`, `replace`.\n *\n * @see [API](https://react-hook-form.com/docs/usefieldarray)\n *\n * @example\n * ```tsx\n * const { fields, append } = useFieldArray({ control, name: \"items\" });\n * return fields.map((f, i) => <input key={f.id} {...register(`items.${i}.name`)} />);\n * ```\n */\nfunction useFieldArray(props) {\n const formControl = useFormControlContext();\n const { control = formControl, name, keyName = 'id', disabled, shouldUnregister, rules, } = props;\n const getCurrentFieldArray = () => control._getFieldArray(name);\n const [fields, setFields] = React.useState(getCurrentFieldArray);\n const ids = React.useRef(control._getFieldArray(name).map(generateId));\n const _actioned = React.useRef(false);\n const { resyncIfNeeded, snapshot } = useResyncOnReconnect(getCurrentFieldArray);\n const _prevControl = React.useRef(control);\n const _prevName = React.useRef(name);\n if (!disabled) {\n control._names.array.add(name);\n }\n React.useMemo(() => !disabled &&\n rules &&\n fields &&\n control.register(name, rules), [control, name, fields, rules, disabled]);\n useIsomorphicLayoutEffect(() => {\n if (disabled) {\n return;\n }\n if (_prevControl.current === control && _prevName.current === name) {\n resyncIfNeeded(true, getCurrentFieldArray, (fieldValues) => {\n setFields(fieldValues);\n ids.current = fieldValues.map(generateId);\n });\n }\n else {\n _prevControl.current = control;\n _prevName.current = name;\n const fieldValues = getCurrentFieldArray();\n if (!deepEqual(fields, fieldValues)) {\n setFields(fieldValues);\n ids.current = fieldValues.map(generateId);\n }\n snapshot(true, getCurrentFieldArray);\n }\n const unsubscribe = control._subjects.array.subscribe({\n next: ({ values, name: fieldArrayName, }) => {\n if (fieldArrayName === name || !fieldArrayName) {\n const fieldValues = get(values, name);\n if (Array.isArray(fieldValues)) {\n setFields(fieldValues);\n ids.current = fieldValues.map(generateId);\n }\n else if (!fieldArrayName) {\n setFields([]);\n ids.current = [];\n }\n }\n },\n }).unsubscribe;\n return () => {\n unsubscribe();\n snapshot(true, getCurrentFieldArray);\n };\n }, [control, name, disabled, resyncIfNeeded, snapshot]);\n const updateValues = React.useCallback((updatedFieldArrayValues) => {\n _actioned.current = true;\n control._setFieldArray(name, updatedFieldArrayValues);\n }, [control, name]);\n const append = (value, options) => {\n if (disabled) {\n return;\n }\n const appendValue = convertToArrayPayload(cloneObject(value));\n const updatedFieldArrayValues = appendAt(control._getFieldArray(name), appendValue);\n control._names.focus = getFocusFieldName(name, updatedFieldArrayValues.length - 1, options);\n ids.current = appendAt(ids.current, appendValue.map(generateId));\n updateValues(updatedFieldArrayValues);\n setFields(updatedFieldArrayValues);\n control._setFieldArray(name, updatedFieldArrayValues, appendAt, {\n argA: fillEmptyArray(value),\n });\n };\n const prepend = (value, options) => {\n if (disabled) {\n return;\n }\n const prependValue = convertToArrayPayload(cloneObject(value));\n const updatedFieldArrayValues = prependAt(control._getFieldArray(name), prependValue);\n control._names.focus = getFocusFieldName(name, 0, options);\n ids.current = prependAt(ids.current, prependValue.map(generateId));\n updateValues(updatedFieldArrayValues);\n setFields(updatedFieldArrayValues);\n control._setFieldArray(name, updatedFieldArrayValues, prependAt, {\n argA: fillEmptyArray(value),\n });\n };\n const remove = (index) => {\n if (disabled) {\n return;\n }\n const updatedFieldArrayValues = removeArrayAt(control._getFieldArray(name), index);\n ids.current = removeArrayAt(ids.current, index);\n updateValues(updatedFieldArrayValues);\n setFields(updatedFieldArrayValues);\n !Array.isArray(get(control._fields, name)) &&\n set(control._fields, name, undefined);\n control._setFieldArray(name, updatedFieldArrayValues, removeArrayAt, {\n argA: index,\n });\n };\n const insert$1 = (index, value, options) => {\n if (disabled) {\n return;\n }\n const insertValue = convertToArrayPayload(cloneObject(value));\n const updatedFieldArrayValues = insert(control._getFieldArray(name), index, insertValue);\n control._names.focus = getFocusFieldName(name, index, options);\n ids.current = insert(ids.current, index, insertValue.map(generateId));\n updateValues(updatedFieldArrayValues);\n setFields(updatedFieldArrayValues);\n control._setFieldArray(name, updatedFieldArrayValues, insert, {\n argA: index,\n argB: fillEmptyArray(value),\n });\n };\n const swap = (indexA, indexB) => {\n if (disabled) {\n return;\n }\n const updatedFieldArrayValues = control._getFieldArray(name);\n swapArrayAt(updatedFieldArrayValues, indexA, indexB);\n swapArrayAt(ids.current, indexA, indexB);\n updateValues(updatedFieldArrayValues);\n setFields(updatedFieldArrayValues);\n control._setFieldArray(name, updatedFieldArrayValues, swapArrayAt, {\n argA: indexA,\n argB: indexB,\n }, false);\n };\n const move = (from, to) => {\n if (disabled) {\n return;\n }\n const updatedFieldArrayValues = control._getFieldArray(name);\n moveArrayAt(updatedFieldArrayValues, from, to);\n moveArrayAt(ids.current, from, to);\n updateValues(updatedFieldArrayValues);\n setFields(updatedFieldArrayValues);\n control._setFieldArray(name, updatedFieldArrayValues, moveArrayAt, {\n argA: from,\n argB: to,\n }, false);\n };\n const update = (index, value) => {\n if (disabled) {\n return;\n }\n const updateValue = cloneObject(value);\n const updatedFieldArrayValues = updateAt(control._getFieldArray(name), index, updateValue);\n ids.current = [...updatedFieldArrayValues].map((item, i) => !item || i === index ? generateId() : ids.current[i]);\n updateValues(updatedFieldArrayValues);\n setFields([...updatedFieldArrayValues]);\n control._setFieldArray(name, updatedFieldArrayValues, updateAt, {\n argA: index,\n argB: fillEmptyArray(value),\n });\n };\n const replace = (value) => {\n if (disabled) {\n return;\n }\n const updatedFieldArrayValues = convertToArrayPayload(cloneObject(value));\n ids.current = updatedFieldArrayValues.map(generateId);\n updateValues([...updatedFieldArrayValues]);\n setFields([...updatedFieldArrayValues]);\n control._setFieldArray(name, [...updatedFieldArrayValues], (data) => Array.isArray(data)\n ? data.slice(0, updatedFieldArrayValues.length)\n : data, {});\n };\n React.useEffect(() => {\n if (disabled) {\n control._state.actionArrayLengths.delete(name);\n return;\n }\n control._state.action = false;\n control._state.actionArrayLengths.delete(name);\n isWatched(name, control._names) &&\n control._subjects.state.next({\n ...control._formState,\n });\n const validationModes = getValidationModes(control._options.mode);\n const reValidateModes = getValidationModes(control._options.reValidateMode);\n if (_actioned.current &&\n (!validationModes.isOnSubmit || control._formState.isSubmitted) &&\n !reValidateModes.isOnSubmit &&\n (!validationModes.isOnBlur ||\n (control._formState.isSubmitted && reValidateModes.isOnChange))) {\n const fieldArrayValues = get(control._formValues, name);\n if (control._options.resolver) {\n control._runSchema([name]).then((result) => {\n control._updateIsValidating([name]);\n if (fieldArrayValues !== get(control._formValues, name)) {\n return;\n }\n const error = get(result.errors, name);\n const existingError = get(control._formState.errors, name);\n const existingErrorType = existingError &&\n (existingError.type ||\n (existingError.root && existingError.root.type));\n const existingErrorMessage = existingError &&\n (existingError.message ||\n (existingError.root && existingError.root.message));\n if (existingError\n ? (!error && existingErrorType) ||\n (error &&\n (existingErrorType !== error.type ||\n existingErrorMessage !== error.message))\n : error && error.type) {\n if (error) {\n isObject(error) &&\n !Object.keys(error).some((key) => !Number.isNaN(+key))\n ? updateFieldArrayRootError(control._formState.errors, { [name]: error }, name)\n : set(control._formState.errors, name, error);\n }\n else {\n unset(control._formState.errors, name);\n }\n control._formState.errors = { ...control._formState.errors };\n control._subjects.state.next({\n errors: control._formState.errors,\n });\n }\n });\n }\n else {\n const field = get(control._fields, name);\n if (field && field._f) {\n validateField(field, control._names.disabled, control._formValues, control._options.criteriaMode === VALIDATION_MODE.all, control._options.shouldUseNativeValidation, true).then((error) => {\n if (fieldArrayValues !== get(control._formValues, name)) {\n return;\n }\n if (!isEmptyObject(error)) {\n updateFieldArrayRootError(control._formState.errors, error, name);\n control._formState.errors = { ...control._formState.errors };\n control._subjects.state.next({\n errors: control._formState.errors,\n });\n }\n else {\n const existingError = get(control._formState.errors, name);\n if (existingError && existingError[ROOT_ERROR_TYPE]) {\n unset(control._formState.errors, `${name}.${ROOT_ERROR_TYPE}`);\n control._formState.errors = { ...control._formState.errors };\n control._subjects.state.next({\n errors: control._formState.errors,\n });\n }\n }\n });\n }\n }\n }\n // External updates that change `fields` (e.g. reset() or setValue() on\n // the array) already notify subscribers with the up-to-date values\n // themselves, so only re-broadcast here for genuine array method calls.\n _actioned.current &&\n control._subjects.state.next({\n name,\n values: cloneObject(control._formValues),\n });\n control._names.focus &&\n iterateFieldsByAction(control._fields, (ref, key) => {\n if (control._names.focus &&\n key.startsWith(control._names.focus) &&\n ref.focus) {\n ref.focus();\n return 1;\n }\n return;\n });\n control._names.focus = '';\n control._setValid();\n _actioned.current = false;\n }, [fields, name, control, disabled]);\n React.useEffect(() => {\n if (!disabled) {\n isUndefined(get(control._formValues, name)) &&\n control._setFieldArray(name);\n }\n return () => {\n control._state.actionArrayLengths.delete(name);\n control._state.actionArrayLengths.size || (control._state.action = false);\n if (disabled) {\n return;\n }\n const shouldKeepFieldArrayValues = !(control._options.shouldUnregister || shouldUnregister);\n const updateMounted = (name, value) => {\n const field = get(control._fields, name);\n if (field && field._f) {\n field._f.mount = value;\n }\n };\n if (_actioned.current && shouldKeepFieldArrayValues) {\n control._subjects.state.next({\n name,\n values: cloneObject(control._formValues),\n });\n }\n if (!shouldKeepFieldArrayValues &&\n control._state.action &&\n [...control._state.actionArrayLengths.keys()].some((arrayName) => name.startsWith(arrayName + '.'))) {\n return;\n }\n shouldKeepFieldArrayValues\n ? updateMounted(name, false)\n : control.unregister(name);\n };\n }, [name, control, keyName, shouldUnregister, disabled]);\n return {\n swap: React.useCallback(swap, [updateValues, name, control, disabled]),\n move: React.useCallback(move, [updateValues, name, control, disabled]),\n prepend: React.useCallback(prepend, [\n updateValues,\n name,\n control,\n disabled,\n ]),\n append: React.useCallback(append, [updateValues, name, control, disabled]),\n remove: React.useCallback(remove, [updateValues, name, control, disabled]),\n insert: React.useCallback(insert$1, [updateValues, name, control, disabled]),\n update: React.useCallback(update, [updateValues, name, control, disabled]),\n replace: React.useCallback(replace, [\n updateValues,\n name,\n control,\n disabled,\n ]),\n fields: React.useMemo(() => fields.map((field, index) => ({\n ...field,\n ...(isBoolean(disabled) ? { disabled } : {}),\n [keyName]: ids.current[index] || generateId(),\n })), [fields, keyName, disabled]),\n };\n}\n\n/**\n * Component based on `useFieldArray` hook to work with controlled component.\n *\n * @example\n * ```tsx\n * function App() {\n * const { control, register } = useForm<FormValues>({\n * defaultValues: {\n * test: [\n * {\n * value: '',\n * },\n * ],\n * },\n * });\n *\n * return (\n * <form>\n * <FieldArray\n * control={control}\n * name=\"test\"\n * render={({ fields }) =>\n * fields.map((field, index) => (\n * <input key={field.id} {...register(`test.${index}.value`)} />\n * ))\n * }\n * />\n * </form>\n * );\n * }\n * ```\n */\nconst FieldArray = (props) => props.render(useFieldArray(props));\n\nconst isFileLike = (value) => (typeof Blob !== 'undefined' && value instanceof Blob) ||\n (typeof File !== 'undefined' && value instanceof File);\nconst isFileListLike = (value) => typeof FileList !== 'undefined' && value instanceof FileList;\nconst flatten = (obj) => {\n const output = {};\n for (const key of Object.keys(obj)) {\n if (isObjectType(obj[key]) &&\n obj[key] !== null &&\n !isDateObject(obj[key]) &&\n !isFileLike(obj[key]) &&\n !isFileListLike(obj[key])) {\n const nested = flatten(obj[key]);\n for (const nestedKey of Object.keys(nested)) {\n output[`${key}.${nestedKey}`] = nested[nestedKey];\n }\n }\n else {\n output[key] = obj[key];\n }\n }\n return output;\n};\n\nfunction jsonToFormData(json) {\n const result = new FormData();\n const flattenFormValues = flatten(json);\n for (const key in flattenFormValues) {\n const value = flattenFormValues[key];\n if (isUndefined(value)) {\n continue;\n }\n if (typeof FileList !== 'undefined' && value instanceof FileList) {\n for (let index = 0; index < value.length; index++) {\n const file = value[index];\n file && result.append(key, file);\n }\n continue;\n }\n result.append(key, value);\n }\n return result;\n}\n\nfunction safeJSONStringify(value) {\n try {\n return JSON.stringify(value);\n }\n catch (_a) {\n return '';\n }\n}\n\nfunction noop() { }\n\nconst POST_REQUEST = 'post';\nfunction defaultValidateStatus(status) {\n return status >= 200 && status < 300;\n}\n/**\n * Form component that handles submission, including optional `action` fetch and server error wiring.\n *\n * @see [API](https://react-hook-form.com/docs/useform/form)\n *\n * @example\n * ```tsx\n * <Form action=\"/api\" control={control}>\n * <input {...register(\"name\")} />\n * <p>{errors?.root?.server && 'Server error'}</p>\n * <button>Submit</button>\n * </Form>\n * ```\n */\nfunction Form(props) {\n const formControl = useFormControlContext();\n const [mounted, setMounted] = React.useState(false);\n const { control = formControl, onSubmit = noop, children, action, method = POST_REQUEST, headers, encType, onError = noop, render, onSuccess = noop, validateStatus = defaultValidateStatus, ...rest } = props;\n const handleSubmit = React.useMemo(() => {\n return control.handleSubmit(async (data, event) => {\n const formData = jsonToFormData(data);\n const formDataJson = safeJSONStringify(data);\n if (onSubmit) {\n await onSubmit({\n data,\n event,\n method,\n formData,\n formDataJson,\n });\n }\n if (isString(action)) {\n try {\n const hasContentType = (type) => (headers &&\n Object.entries(headers).some(([name, value]) => name.toLowerCase() === 'content-type' && type.test(value))) ||\n (encType && type.test(encType));\n let body = formData;\n if (hasContentType(/json/i)) {\n body = formDataJson;\n }\n else if (hasContentType(/^\\s*application\\/x-www-form-urlencoded\\s*(;|$)/i)) {\n body = new URLSearchParams(Array.from(formData, ([name, value]) => [\n name,\n isString(value) ? value : value.name,\n ]));\n }\n else if (hasContentType(/^\\s*text\\/plain\\s*(;|$)/i)) {\n body = Array.from(formData, ([name, value]) => `${name}=${isString(value) ? value : value.name}\\r\\n`).join('');\n }\n const isMultipart = (value) => /^\\s*multipart\\/form-data\\s*(;|$)/i.test(value);\n const response = await fetch(action, {\n method,\n headers: {\n ...Object.fromEntries(Object.entries(headers || {}).filter(([name, value]) => name.toLowerCase() !== 'content-type' ||\n !isMultipart(value))),\n ...(encType &&\n !isMultipart(encType) && { 'Content-Type': encType }),\n },\n body,\n });\n if (response && !validateStatus(response.status)) {\n onError({ response });\n return { type: String(response.status) };\n }\n else {\n onSuccess({ response });\n }\n }\n catch (error) {\n onError({ error });\n return { type: '' };\n }\n }\n if (isFunction(action)) {\n try {\n await action(formData);\n }\n catch (error) {\n onError({ error });\n return { type: '' };\n }\n }\n // Return nothing when successful.\n return;\n });\n }, [\n control,\n onSubmit,\n method,\n action,\n headers,\n encType,\n validateStatus,\n onError,\n onSuccess,\n ]);\n const submit = React.useCallback(async (event) => {\n const err = await handleSubmit(event);\n if (err && control) {\n control._subjects.state.next({ isSubmitSuccessful: false });\n control.setError('root.server', err);\n }\n }, [handleSubmit, control]);\n React.useEffect(() => {\n setMounted(true);\n }, []);\n if (render) {\n return render({ submit });\n }\n // React forbids passing `method`/`encType` alongside a function `action`\n // (a Server-Action-style submission) -- it manages those itself and warns\n // if they're present, so they're only rendered for string/URL actions.\n return (React.createElement(\"form\", { noValidate: mounted, action: action, ...(!isFunction(action) && { method, encType }), onSubmit: submit, ...rest }, children));\n}\n\nconst FormState = ({ control, disabled, exact, name, render, }) => render(useFormState({ control, name, disabled, exact }));\n/** @deprecated Use `FormState` instead. Kept as an alias for backward compatibility. */\nconst FormStateSubscribe = FormState;\n\nvar createSubject = () => {\n let _observers = new Set();\n let _iterationCount = 0;\n const next = (value) => {\n const observers = _observers;\n _iterationCount++;\n for (const observer of observers) {\n observer.next && observer.next(value);\n }\n observers === _observers && _iterationCount--;\n };\n const subscribe = (observer) => {\n _observers.add(observer);\n return {\n unsubscribe: () => {\n if (_iterationCount) {\n _observers = new Set(_observers);\n _iterationCount = 0;\n }\n _observers.delete(observer);\n },\n };\n };\n const unsubscribe = () => {\n _observers = new Set();\n _iterationCount = 0;\n };\n return {\n get observers() {\n return Array.from(_observers);\n },\n next,\n subscribe,\n unsubscribe,\n };\n};\n\nfunction extractFormValues(fieldsState, formValues) {\n const values = (Array.isArray(fieldsState) ? [] : {});\n for (const key in fieldsState) {\n if (Object.prototype.hasOwnProperty.call(fieldsState, key)) {\n const fieldState = fieldsState[key];\n const fieldValue = formValues[key];\n if (fieldState &&\n (isObject(fieldState) || Array.isArray(fieldState)) &&\n fieldValue) {\n values[key] = extractFormValues(fieldState, fieldValue);\n }\n else if (fieldsState[key]) {\n values[key] = fieldValue;\n }\n }\n }\n return values;\n}\n\nconst hasOwn = (value, key) => value !== null &&\n isObjectType(value) &&\n Object.prototype.hasOwnProperty.call(value, key);\nvar has = (object, path) => {\n if (!path) {\n return false;\n }\n let result = object;\n for (const key of isKey(path) ? [path] : stringToPath(path)) {\n if (!hasOwn(result, key)) {\n // `get` also resolves a path held as a single literal key, eg `{ 'a.b': 1 }`\n return hasOwn(object, path);\n }\n result = result[key];\n }\n return true;\n};\n\nvar isMultipleSelect = (element) => element.type === `select-multiple`;\n\nconst isSelectEdited = (select) => {\n const options = [...select.options];\n return !select.multiple &&\n select.size < 2 &&\n !options.some((option) => option.defaultSelected)\n ? select.selectedIndex !== options.findIndex((option) => !option.disabled)\n : options.some((option) => option.selected !== option.defaultSelected);\n};\nvar isEdited = (ref) => isCheckBoxInput(ref)\n ? ref.checked !== ref.defaultChecked\n : ref.type === 'select-one' || isMultipleSelect(ref)\n ? isSelectEdited(ref)\n : !isRadioInput(ref) &&\n 'defaultValue' in ref &&\n ref.value !== ref.defaultValue;\n\nvar isRadioOrCheckbox = (ref) => isRadioInput(ref) || isCheckBoxInput(ref);\n\nvar live = (ref) => isHTMLElement(ref) && ref.isConnected;\n\nfunction isDirtyContainer(value) {\n return Array.isArray(value) || isObject(value);\n}\nfunction collectDirtyFieldNames(dirtyTree, cachedDirtyFields, prefix = '', names = []) {\n for (const key in dirtyTree) {\n const path = prefix ? `${prefix}.${key}` : key;\n const value = dirtyTree[key];\n if (isDirtyContainer(value) &&\n isDirtyContainer(get(cachedDirtyFields, path))) {\n collectDirtyFieldNames(value, cachedDirtyFields, path, names);\n }\n else {\n names.push(path);\n }\n }\n return names;\n}\n\nvar objectHasFunction = (data) => {\n for (const key in data) {\n if (isFunction(data[key])) {\n return true;\n }\n }\n return false;\n};\n\nfunction isTraversable(value) {\n return Array.isArray(value) || (isObject(value) && !objectHasFunction(value));\n}\nfunction isRegisteredLeaf(fieldRef) {\n return !!(fieldRef && '_f' in fieldRef);\n}\nfunction isEmptyDirtyContainer(value) {\n return Array.isArray(value)\n ? !value.some((item) => !isUndefined(item))\n : !Object.keys(value).length;\n}\nfunction clearDirtyField(container, key) {\n if (Array.isArray(container)) {\n container[key] = undefined;\n }\n else {\n delete container[key];\n }\n}\nfunction markFieldsDirty(data, fields = {}, fieldRefs) {\n for (const key in data) {\n const value = data[key];\n const fieldRef = fieldRefs && fieldRefs[key];\n if (isTraversable(value) &&\n (!Array.isArray(value) || !isRegisteredLeaf(fieldRef))) {\n fields[key] = Array.isArray(value) ? [] : {};\n markFieldsDirty(value, fields[key], fieldRef);\n if (isEmptyDirtyContainer(fields[key])) {\n clearDirtyField(fields, key);\n }\n }\n else if (!isUndefined(value)) {\n fields[key] = true;\n }\n }\n return fields;\n}\nfunction getDirtyFields(data, formValues, dirtyFieldsFromValues, fieldRefs) {\n if (!dirtyFieldsFromValues) {\n dirtyFieldsFromValues = markFieldsDirty(formValues, (Array.isArray(isNullOrUndefined(formValues) ? data : formValues)\n ? []\n : {}), fieldRefs);\n }\n for (const key in data) {\n const value = data[key];\n const fieldRef = fieldRefs && fieldRefs[key];\n if (isTraversable(value) &&\n (!Array.isArray(value) || !isRegisteredLeaf(fieldRef))) {\n if (isUndefined(formValues) || isPrimitive(dirtyFieldsFromValues[key])) {\n dirtyFieldsFromValues[key] = markFieldsDirty(value, (Array.isArray(value) ? [] : {}), fieldRef);\n }\n else {\n getDirtyFields(value, isNullOrUndefined(formValues) ? {} : formValues[key], dirtyFieldsFromValues[key], fieldRef);\n }\n if (isEmptyDirtyContainer(dirtyFieldsFromValues[key])) {\n clearDirtyField(dirtyFieldsFromValues, key);\n }\n }\n else if (deepEqual(value, isNullOrUndefined(formValues) ? undefined : formValues[key])) {\n clearDirtyField(dirtyFieldsFromValues, key);\n }\n else {\n dirtyFieldsFromValues[key] = true;\n }\n }\n return dirtyFieldsFromValues;\n}\n\nvar getFieldArrayItemNames = (names, name) => {\n const segments = name.split('.');\n const matches = [];\n let prefix = segments[0];\n for (let i = 1; i < segments.length; prefix += '.' + segments[i++]) {\n if (!isNaN(+segments[i]) && names.has(prefix)) {\n matches.push(`${prefix}.${segments[i]}`);\n }\n }\n return matches;\n};\n\nvar getFieldValueAs = (value, { valueAsNumber, valueAsDate, setValueAs }) => isUndefined(value)\n ? value\n : valueAsNumber\n ? value === ''\n ? NaN\n : value\n ? +value\n : value\n : valueAsDate && isString(value)\n ? new Date(value)\n : setValueAs\n ? setValueAs(value)\n : value;\n\nfunction getFieldValue(_f) {\n const ref = _f.ref;\n if (isFileInput(ref)) {\n return ref.files;\n }\n if (isRadioInput(ref)) {\n return getRadioValue(_f.refs).value;\n }\n if (isMultipleSelect(ref)) {\n return [...ref.selectedOptions].map(({ value }) => value);\n }\n if (isCheckBoxInput(ref)) {\n return getCheckboxValue(_f.refs).value;\n }\n return getFieldValueAs(ref.value, _f);\n}\n\nvar getResolverOptions = (fieldsNames, _fields, criteriaMode, shouldUseNativeValidation) => {\n const fields = {};\n for (const name of fieldsNames) {\n const field = get(_fields, name);\n field && set(fields, name, field._f);\n }\n return {\n criteriaMode,\n names: [...fieldsNames],\n fields,\n shouldUseNativeValidation,\n };\n};\n\nvar getRuleValue = (rule) => isUndefined(rule)\n ? rule\n : isRegex(rule)\n ? rule.source\n : isObject(rule)\n ? isRegex(rule.value)\n ? rule.value.source\n : rule.value\n : rule;\n\nconst ASYNC_FUNCTION = 'AsyncFunction';\nvar hasPromiseValidation = (fieldReference) => {\n if (!fieldReference || !fieldReference.validate)\n return false;\n if (isFunction(fieldReference.validate)) {\n return fieldReference.validate.constructor.name === ASYNC_FUNCTION;\n }\n if (isObject(fieldReference.validate)) {\n for (const key in fieldReference.validate) {\n if (fieldReference.validate[key].constructor.name === ASYNC_FUNCTION) {\n return true;\n }\n }\n }\n return false;\n};\n\nvar hasValidation = (options) => options.mount &&\n (options.required ||\n (!isUndefined(options.required) && options.required !== false) ||\n !isUndefined(options.min) ||\n !isUndefined(options.max) ||\n !isUndefined(options.maxLength) ||\n !isUndefined(options.minLength) ||\n options.pattern ||\n options.validate);\n\nfunction schemaErrorLookup(errors, _fields, name) {\n const error = get(errors, name);\n if ((error && (error.type || error.message)) || Array.isArray(error)) {\n return {\n error,\n name,\n };\n }\n const names = name.split('.');\n while (names.length) {\n const fieldName = names.join('.');\n const field = get(_fields, fieldName);\n const foundError = get(errors, fieldName);\n if (field && !Array.isArray(field) && name !== fieldName) {\n return { name };\n }\n if (foundError && foundError.type) {\n return {\n name: fieldName,\n error: foundError,\n };\n }\n if (foundError && foundError.root && foundError.root.type) {\n return {\n name: `${fieldName}.root`,\n error: foundError.root,\n };\n }\n names.pop();\n }\n return {\n name,\n };\n}\n\nvar shouldRenderFormState = (formStateData, _proxyFormState, isRoot) => {\n const keys = Object.keys(formStateData).filter((key) => key !== 'name');\n return (!keys.length ||\n (isRoot && keys.length >= Object.keys(_proxyFormState).length) ||\n keys.find((key) => _proxyFormState[key] ===\n (!isRoot || VALIDATION_MODE.all)));\n};\n\nconst isNameMatch = (currentName, signalName, exact) => exact\n ? currentName === signalName || currentName.startsWith(signalName + '.')\n : currentName.startsWith(signalName) || signalName.startsWith(currentName);\nvar shouldSubscribeByName = (name, signalName, exact) => {\n if (!name || !signalName || name === signalName) {\n return true;\n }\n if (!Array.isArray(name)) {\n return isNameMatch(name, signalName, exact);\n }\n for (const currentName of name) {\n if (currentName && isNameMatch(currentName, signalName, exact)) {\n return true;\n }\n }\n return false;\n};\n\nvar skipValidation = (isBlurEvent, isTouched, isSubmitted, reValidateMode, mode) => {\n if (mode.isOnAll) {\n return false;\n }\n else if (!isSubmitted && mode.isOnTouch) {\n return !(isTouched || isBlurEvent);\n }\n else if (isSubmitted ? reValidateMode.isOnBlur : mode.isOnBlur) {\n return !isBlurEvent;\n }\n else if (isSubmitted ? reValidateMode.isOnChange : mode.isOnChange) {\n return isBlurEvent;\n }\n return true;\n};\n\nvar unsetEmptyArray = (ref, name) => {\n const array = get(ref, name);\n !compact(array).length &&\n !(array && array.root) &&\n unset(ref, name);\n};\n\nconst defaultOptions = {\n mode: VALIDATION_MODE.onSubmit,\n reValidateMode: VALIDATION_MODE.onChange,\n shouldFocusError: true,\n};\nconst replaceDirtyFieldsInPlace = (dirtyFields, nextDirtyFields) => {\n for (const key in dirtyFields) {\n delete dirtyFields[key];\n }\n Object.assign(dirtyFields, nextDirtyFields);\n};\nconst DEFAULT_FORM_STATE = {\n submitCount: 0,\n isDirty: false,\n isReady: false,\n isValidating: false,\n isSubmitted: false,\n isSubmitting: false,\n isSubmitSuccessful: false,\n isValid: false,\n touchedFields: {},\n dirtyFields: {},\n validatingFields: {},\n};\nfunction createFormControl(props = {}) {\n let _options = {\n ...defaultOptions,\n ...props,\n };\n let _formState = {\n ...cloneObject(DEFAULT_FORM_STATE),\n isLoading: isFunction(_options.defaultValues),\n errors: cloneObject(_options.errors) || {},\n disabled: _options.disabled || false,\n };\n let _fields = {};\n let _defaultValues = isObject(_options.defaultValues) || isObject(_options.values)\n ? cloneObject(_options.defaultValues || _options.values) || {}\n : {};\n let _formValues = _options.shouldUnregister\n ? {}\n : cloneObject(_defaultValues);\n let _state = {\n action: false,\n actionArrayLengths: new Map(),\n mount: false,\n watch: false,\n keepIsValid: false,\n };\n let _dirtyFieldsStale = false;\n let _names = {\n mount: new Set(),\n disabled: new Set(),\n unMount: new Set(),\n array: new Set(),\n watch: new Set(),\n registerName: new Set(),\n };\n const delayErrorCallbacks = {};\n const timers = {};\n const _valuesSubscribers = new Set();\n let _validationModeBeforeSubmit = getValidationModes(_options.mode);\n let _validationModeAfterSubmit = getValidationModes(_options.reValidateMode);\n const defaultProxyFormState = {\n isDirty: false,\n dirtyFields: false,\n validatingFields: false,\n touchedFields: false,\n isValidating: false,\n isValid: false,\n errors: false,\n };\n const _proxyFormState = {\n ...defaultProxyFormState,\n };\n const _proxySubscribeFormState = {};\n const _isTracked = (...keys) => keys.some((key) => _proxyFormState[key] || _proxySubscribeFormState[key]);\n const _hasValuesSubscriber = (name) => {\n for (const subscriber of _valuesSubscribers) {\n if (shouldSubscribeByName(subscriber.name, name, subscriber.exact)) {\n return true;\n }\n }\n return false;\n };\n const _subjects = {\n array: createSubject(),\n state: createSubject(),\n };\n let _setValidCallId = 0;\n let _resetCallId = 0;\n let _registerCallId = 0;\n const _registerCallIds = {};\n let shouldDisplayAllAssociatedErrors = _options.criteriaMode === VALIDATION_MODE.all;\n const debounce = (name, callback) => (wait) => {\n clearTimeout(timers[name]);\n timers[name] = setTimeout(callback, wait);\n };\n const cancelDelayedError = (name) => {\n clearTimeout(timers[name]);\n delete timers[name];\n delete delayErrorCallbacks[name];\n };\n const cancelDelayedErrorTree = (name) => {\n cancelDelayedError(name);\n const prefix = `${name}.`;\n for (const key of Object.keys(delayErrorCallbacks)) {\n key.startsWith(prefix) && cancelDelayedError(key);\n }\n };\n const _setValid = async (shouldUpdateValid) => {\n if (_state.keepIsValid) {\n return;\n }\n if (!_options.disabled && (_isTracked('isValid') || shouldUpdateValid)) {\n const callId = ++_setValidCallId;\n let isValid;\n if (_options.resolver) {\n isValid = isEmptyObject((await _runSchema()).errors);\n callId === _setValidCallId && _updateIsValidating();\n }\n else {\n isValid = await executeBuiltInValidation({\n fields: _fields,\n onlyCheckValid: true,\n eventType: EVENTS.VALID,\n });\n }\n if (callId === _setValidCallId && isValid !== _formState.isValid) {\n _subjects.state.next({\n isValid,\n });\n }\n }\n };\n const _updateValidatingFields = (names, isValidating) => {\n const fieldNames = [...names];\n if (!fieldNames.some((name) => name &&\n (isValidating\n ? get(_formState.validatingFields, name) !== true\n : has(_formState.validatingFields, name)))) {\n return;\n }\n const validatingFields = cloneObject(_formState.validatingFields);\n for (const name of fieldNames) {\n if (name) {\n isValidating\n ? set(validatingFields, name, true)\n : unset(validatingFields, name);\n }\n }\n if (!deepEqual(_formState.validatingFields, validatingFields)) {\n _formState.validatingFields = validatingFields;\n }\n };\n const _updateIsValidating = (names, isValidating) => {\n if (!_options.disabled && _isTracked('isValidating', 'validatingFields')) {\n _updateValidatingFields(names || _names.mount, isValidating);\n _subjects.state.next({\n validatingFields: _formState.validatingFields,\n isValidating: !isEmptyObject(_formState.validatingFields),\n });\n }\n };\n const _updateDirtyFields = () => {\n _formState.dirtyFields = getDirtyFields(_defaultValues, _formValues, undefined, _fields);\n };\n const _setFieldArray = (name, values = [], method, args, shouldSetValues = true, shouldUpdateFieldsAndState = true) => {\n if (args && method && !_options.disabled) {\n _state.action = true;\n _state.keepIsValid = false;\n const field = get(_fields, name);\n const rootField = field && field._f;\n const fields = rootField ? Object.assign([], field) : field;\n if (!_state.actionArrayLengths.has(name)) {\n _state.actionArrayLengths.set(name, Array.isArray(fields) ? fields.length : 0);\n }\n if (shouldUpdateFieldsAndState && Array.isArray(fields)) {\n const fieldValues = method(fields, args.argA, args.argB) || fields;\n rootField\n ? set(_fields, name, { ...fieldValues, _f: rootField })\n : shouldSetValues && set(_fields, name, fieldValues);\n }\n const fieldArrayErrors = get(_formState.errors, name);\n if (shouldUpdateFieldsAndState && Array.isArray(fieldArrayErrors)) {\n const rootError = fieldArrayErrors.root;\n const errors = method(fieldArrayErrors, args.argA, args.argB) || fieldArrayErrors;\n if (rootError) {\n errors.root = rootError;\n }\n shouldSetValues && set(_formState.errors, name, errors);\n unsetEmptyArray(_formState.errors, name);\n _formState.errors = { ..._formState.errors };\n }\n const touchedFieldsArray = get(_formState.touchedFields, name);\n const shouldUpdateTouchedFields = shouldUpdateFieldsAndState && Array.isArray(touchedFieldsArray);\n if (shouldUpdateTouchedFields) {\n const touchedFields = method(touchedFieldsArray, args.argA, args.argB);\n shouldSetValues && set(_formState.touchedFields, name, touchedFields);\n }\n const dirtyFieldsArray = get(_formState.dirtyFields, name);\n if (shouldUpdateFieldsAndState && Array.isArray(dirtyFieldsArray)) {\n const dirtyFields = method(dirtyFieldsArray, args.argA, args.argB) || dirtyFieldsArray;\n shouldSetValues && set(_formState.dirtyFields, name, dirtyFields);\n }\n if (_isTracked('dirtyFields')) {\n _updateDirtyFields();\n }\n else {\n _dirtyFieldsStale = true;\n }\n _subjects.state.next({\n name,\n isDirty: _getDirty(name, values),\n dirtyFields: _formState.dirtyFields,\n ...(shouldUpdateTouchedFields && {\n touchedFields: _formState.touchedFields,\n }),\n errors: _formState.errors,\n isValid: _formState.isValid,\n });\n }\n else {\n set(_formValues, name, values);\n }\n };\n const updateErrors = (name, error) => {\n set(_formState.errors, name, error);\n _formState.errors = { ..._formState.errors };\n _subjects.state.next({\n errors: _formState.errors,\n });\n };\n const _setErrors = (errors) => {\n Object.keys(delayErrorCallbacks).forEach(cancelDelayedError);\n const hasErrors = !isEmptyObject(errors);\n _formState.errors = cloneObject(errors);\n _subjects.state.next({\n errors: _formState.errors,\n ...(hasErrors ? { isValid: false } : {}),\n });\n !hasErrors && _state.mount && _setValid();\n };\n const toPath = (name) => isKey(name) ? [name] : stringToPath(name);\n const hasExplicitNullIntermediate = (name) => {\n const segments = toPath(name);\n let formValues = _formValues;\n let defaultValues = _defaultValues;\n for (let i = 0; i < segments.length - 1; i++) {\n const key = segments[i];\n formValues = isNullOrUndefined(formValues) ? formValues : formValues[key];\n defaultValues = isNullOrUndefined(defaultValues)\n ? defaultValues\n : defaultValues[key];\n if (formValues === null && defaultValues !== null) {\n return true;\n }\n }\n return false;\n };\n const isStaleArrayField = (name) => {\n if (!_state.actionArrayLengths.size) {\n return false;\n }\n const segments = toPath(name);\n let node = _formValues;\n let path = '';\n let ownerDepth = -1;\n let ownerPreActionLength = 0;\n for (let i = 0; i < segments.length; i++) {\n if (isNullOrUndefined(node)) {\n return false;\n }\n const key = segments[i];\n path = path ? `${path}.${key}` : key;\n if (Array.isArray(node) && +key >= node.length) {\n return ownerDepth === -1\n ? false\n : i === ownerDepth\n ? +key < ownerPreActionLength\n : true;\n }\n if (_state.actionArrayLengths.has(path)) {\n ownerDepth = i + 1;\n ownerPreActionLength = _state.actionArrayLengths.get(path);\n }\n node = node[key];\n if (isUndefined(node) &&\n ownerDepth !== -1 &&\n i > ownerDepth &&\n +segments[ownerDepth] < ownerPreActionLength) {\n return true;\n }\n }\n return false;\n };\n const isPastArrayEnd = (name) => {\n let node = _formValues;\n for (const key of toPath(name)) {\n if (Array.isArray(node) && +key >= node.length) {\n return true;\n }\n node = node && node[key];\n }\n return false;\n };\n const updateValidAndValue = (name, shouldSkipSetValueAs, value, ref) => {\n const field = get(_fields, name);\n if (field) {\n if (hasExplicitNullIntermediate(name) || isStaleArrayField(name)) {\n return;\n }\n const wasUnsetInFormValues = isUndefined(get(_formValues, name));\n const defaultValue = get(_formValues, name, isUndefined(value) ? get(_defaultValues, name) : value);\n const isEditedBeforeReady = !!ref && !_formState.isReady && isEdited(ref);\n if (isUndefined(defaultValue) ||\n (ref && ref.defaultChecked) ||\n isEditedBeforeReady ||\n shouldSkipSetValueAs) {\n const fieldValue = shouldSkipSetValueAs\n ? defaultValue\n : getFieldValue(field._f);\n if (!isUndefined(fieldValue) || !isPastArrayEnd(name)) {\n if (_isTracked('dirtyFields') &&\n !deepEqual(get(_formValues, name), fieldValue)) {\n _dirtyFieldsStale = true;\n }\n set(_formValues, name, fieldValue);\n if (isEditedBeforeReady) {\n updateTouchAndDirty(name, fieldValue);\n }\n }\n }\n else {\n setFieldValue(name, defaultValue);\n }\n if (_state.mount && !_state.action) {\n if (_options.resolver &&\n _isTracked('isValidating', 'validatingFields')) {\n Promise.resolve().then(() => _setValid());\n }\n else {\n _setValid();\n }\n if (wasUnsetInFormValues &&\n _formState.isDirty &&\n _isTracked('isDirty')) {\n const isDirty = _getDirty();\n if (!isDirty) {\n _formState.isDirty = false;\n _subjects.state.next({ ..._formState });\n }\n }\n if (_options.shouldUnregister &&\n wasUnsetInFormValues &&\n !isUndefined(get(_formValues, name)) &&\n isWatched(name, _names)) {\n _state.watch = true;\n }\n }\n }\n };\n const updateTouchAndDirty = (name, fieldValue, isBlurEvent, shouldDirty, shouldRender) => {\n let shouldUpdateField = false;\n let isPreviousDirty = false;\n const output = {\n name,\n };\n if (!_options.disabled || shouldDirty === true) {\n if (!isBlurEvent || shouldDirty) {\n const isCurrentFieldPristine = deepEqual(get(_defaultValues, name), fieldValue);\n if (_isTracked('isDirty')) {\n isPreviousDirty = _formState.isDirty;\n _formState.isDirty = output.isDirty =\n !isCurrentFieldPristine || _getDirty();\n shouldUpdateField = isPreviousDirty !== output.isDirty;\n }\n isPreviousDirty = !!get(_formState.dirtyFields, name);\n if (isCurrentFieldPristine) {\n unset(_formState.dirtyFields, name);\n }\n else {\n const defaultFieldValue = get(_defaultValues, name);\n const field = get(_fields, name);\n const dirtyValue = !(field && field._f) &&\n (isObject(defaultFieldValue) || Array.isArray(defaultFieldValue))\n ? getDirtyFields(defaultFieldValue, fieldValue, undefined, field)\n : true;\n set(_formState.dirtyFields, name, dirtyValue);\n }\n let didResyncDirtyFields = false;\n if (_dirtyFieldsStale ||\n (isCurrentFieldPristine &&\n (_isTracked('isDirty') ? _formState.isDirty : _getDirty()))) {\n _dirtyFieldsStale = false;\n const nextDirtyFields = getDirtyFields(_defaultValues, _formValues, undefined, _fields);\n if (!deepEqual(_formState.dirtyFields, nextDirtyFields)) {\n didResyncDirtyFields = true;\n replaceDirtyFieldsInPlace(_formState.dirtyFields, nextDirtyFields);\n }\n }\n output.dirtyFields = _formState.dirtyFields;\n shouldUpdateField =\n shouldUpdateField ||\n (_isTracked('dirtyFields') &&\n (didResyncDirtyFields ||\n isPreviousDirty !== !isCurrentFieldPristine));\n }\n if (isBlurEvent) {\n const isPreviousFieldTouched = has(_formState.touchedFields, name)\n ? get(_formState.touchedFields, name)\n : undefined;\n if (!isPreviousFieldTouched) {\n set(_formState.touchedFields, name, isBlurEvent);\n output.touchedFields = _formState.touchedFields;\n shouldUpdateField =\n shouldUpdateField ||\n (_isTracked('touchedFields') &&\n isPreviousFieldTouched !== isBlurEvent);\n }\n }\n shouldUpdateField && shouldRender && _subjects.state.next(output);\n }\n return shouldUpdateField ? output : {};\n };\n const shouldRenderByError = (name, isValid, error, fieldState) => {\n const previousFieldError = get(_formState.errors, name);\n const shouldUpdateValid = _isTracked('isValid') &&\n isBoolean(isValid) &&\n _formState.isValid !== isValid;\n if (_options.delayError && error) {\n delayErrorCallbacks[name] = debounce(name, () => updateErrors(name, error));\n delayErrorCallbacks[name](_options.delayError);\n }\n else {\n cancelDelayedError(name);\n error\n ? set(_formState.errors, name, error)\n : unset(_formState.errors, name);\n _formState.errors = { ..._formState.errors };\n }\n if ((error\n ? !deepEqual(previousFieldError, error, true)\n : previousFieldError) ||\n !isEmptyObject(fieldState) ||\n shouldUpdateValid) {\n const updatedFormState = {\n ...fieldState,\n ...(shouldUpdateValid && isBoolean(isValid) ? { isValid } : {}),\n errors: _formState.errors,\n name,\n };\n _subjects.state.next(updatedFormState);\n }\n };\n const _runSchema = async (name) => {\n _updateIsValidating(name, true);\n return await _options.resolver(_formValues, _options.context, getResolverOptions(name || _names.mount, _fields, _options.criteriaMode, _options.shouldUseNativeValidation));\n };\n const executeSchemaAndUpdateState = async (names) => {\n const resetCallId = _resetCallId;\n const registerCallId = _registerCallId;\n const registeredNames = names\n ? names.filter((name) => get(_fields, name))\n : [];\n const { errors } = await _runSchema(names);\n if (resetCallId !== _resetCallId) {\n return errors;\n }\n _updateIsValidating(names);\n if (names) {\n for (const name of names) {\n if (registeredNames.includes(name) &&\n (!get(_fields, name) || _registerCallIds[name] > registerCallId)) {\n unset(errors, name);\n continue;\n }\n const error = get(errors, name);\n cancelDelayedErrorTree(name);\n const isFieldArrayRootError = _names.array.has(name) &&\n isObject(error) &&\n !Object.keys(error).some((key) => !Number.isNaN(Number(key)));\n const field = get(_fields, name);\n const hasNestedFields = isObject(field) && Object.keys(field).some((key) => key !== '_f');\n isFieldArrayRootError\n ? updateFieldArrayRootError(_formState.errors, { [name]: error }, name)\n : (error && (error.type || error.message)) ||\n Array.isArray(error) ||\n (isObject(error) && hasNestedFields)\n ? set(_formState.errors, name, error)\n : unset(_formState.errors, name);\n }\n _formState.errors = { ..._formState.errors };\n }\n else {\n Object.keys(delayErrorCallbacks).forEach(cancelDelayedError);\n _formState.errors = errors;\n }\n return errors;\n };\n const validateForm = async ({ name, eventType, }) => {\n if (_options.validate) {\n const resetCallId = _resetCallId;\n const result = await _options.validate({\n formValues: _formValues,\n formState: _formState,\n name,\n eventType,\n });\n if (resetCallId !== _resetCallId) {\n return true;\n }\n if (isObject(result)) {\n let isValid = true;\n clearErrors(FORM_ERROR_TYPE);\n for (const key in result) {\n const error = result[key];\n if (error) {\n isValid = false;\n setError(`${FORM_ERROR_TYPE}.${key}`, {\n message: isString(error.message) ? error.message : '',\n type: error.type || INPUT_VALIDATION_RULES.validate,\n });\n }\n }\n return isValid;\n }\n else if (isString(result) || !result) {\n setError(FORM_ERROR_TYPE, {\n message: result || '',\n type: INPUT_VALIDATION_RULES.validate,\n });\n return false;\n }\n else {\n clearErrors(FORM_ERROR_TYPE);\n return true;\n }\n }\n return true;\n };\n const executeBuiltInValidation = async ({ fields, onlyCheckValid, name, eventType, context = {\n valid: true,\n runRootValidation: false,\n }, }) => {\n const resetCallId = _resetCallId;\n if (_options.validate && !context.runRootValidation) {\n context.runRootValidation = true;\n const result = await validateForm({\n name,\n eventType,\n });\n if (!result) {\n context.valid = false;\n if (onlyCheckValid) {\n return context.valid;\n }\n }\n }\n for (const name in fields) {\n const field = fields[name];\n if (field) {\n const { _f, ...fieldValue } = field;\n if (_f) {\n const isFieldArrayRoot = _names.array.has(_f.name);\n const isPromiseFunction = field._f && hasPromiseValidation(field._f);\n const shouldTrackIsValidatingState = _isTracked('isValidating', 'validatingFields');\n if (isPromiseFunction && shouldTrackIsValidatingState) {\n _updateIsValidating([_f.name], true);\n }\n const registerCallId = _registerCallId;\n const fieldError = await validateField(field, _names.disabled, _formValues, shouldDisplayAllAssociatedErrors, _options.shouldUseNativeValidation && !onlyCheckValid, isFieldArrayRoot);\n if (resetCallId !== _resetCallId) {\n return context.valid;\n }\n if (isPromiseFunction && shouldTrackIsValidatingState) {\n _updateIsValidating([_f.name]);\n }\n if (!get(_fields, _f.name) ||\n _registerCallIds[_f.name] > registerCallId) {\n continue;\n }\n if (fieldError[_f.name]) {\n context.valid = false;\n if (onlyCheckValid) {\n break;\n }\n }\n if (!onlyCheckValid) {\n cancelDelayedError(_f.name);\n get(fieldError, _f.name)\n ? isFieldArrayRoot\n ? updateFieldArrayRootError(_formState.errors, fieldError, _f.name)\n : set(_formState.errors, _f.name, fieldError[_f.name])\n : unset(_formState.errors, _f.name);\n }\n if (_options.shouldUseNativeValidation && fieldError[_f.name]) {\n break;\n }\n }\n !isEmptyObject(fieldValue) &&\n (await executeBuiltInValidation({\n context,\n onlyCheckValid,\n fields: fieldValue,\n name: name,\n eventType,\n }));\n }\n }\n return context.valid;\n };\n const _removeUnmounted = () => {\n for (const name of _names.unMount) {\n const field = get(_fields, name);\n field &&\n (field._f.refs\n ? field._f.refs.every((ref) => !live(ref))\n : !live(field._f.ref)) &&\n unregister(name);\n }\n _names.unMount = new Set();\n };\n const _getDirty = (name, data) => (name && !isUndefined(data) && set(_formValues, name, data),\n !deepEqual(_state.mount ? _formValues : _defaultValues, _defaultValues));\n const _getWatch = (names, defaultValue, isGlobal) => {\n const values = _state.mount\n ? _formValues\n : isUndefined(defaultValue) || !isUndefined(names)\n ? _defaultValues\n : defaultValue;\n return generateWatchOutput(names, _names, isUndefined(names) ? { ...values } : values, isGlobal, defaultValue);\n };\n const _getFieldArray = (name) => compact(get(_state.mount ? _formValues : _defaultValues, name, _options.shouldUnregister ? get(_defaultValues, name, []) : []));\n const setFieldValue = (name, value, options = {}, skipClone = false, skipRender = false, skipValueRender = false) => {\n const field = get(_fields, name);\n let fieldValue = value;\n if (field) {\n const fieldReference = field._f;\n if (fieldReference) {\n !fieldReference.disabled &&\n set(_formValues, name, getFieldValueAs(value, fieldReference));\n fieldValue =\n isHTMLElement(fieldReference.ref) && isNullOrUndefined(value)\n ? ''\n : value;\n if (isMultipleSelect(fieldReference.ref)) {\n [...fieldReference.ref.options].forEach((optionRef) => (optionRef.selected = fieldValue.includes(optionRef.value)));\n }\n else if (fieldReference.refs) {\n if (isCheckBoxInput(fieldReference.ref)) {\n fieldReference.refs.forEach((checkboxRef) => {\n if (!checkboxRef.defaultChecked || !checkboxRef.disabled) {\n if (Array.isArray(fieldValue)) {\n checkboxRef.checked = !!fieldValue.find((data) => data === checkboxRef.value);\n }\n else {\n checkboxRef.checked =\n fieldValue === checkboxRef.value || !!fieldValue;\n }\n }\n });\n }\n else {\n fieldReference.refs.forEach((radioRef) => (radioRef.checked = radioRef.value === fieldValue));\n }\n }\n else if (isFileInput(fieldReference.ref)) {\n fieldReference.ref.value = '';\n }\n else {\n fieldReference.ref.value = fieldValue;\n if (!fieldReference.ref.type && !skipRender && !skipValueRender) {\n _subjects.state.next({\n name,\n values: skipClone\n ? _formValues\n : _hasValuesSubscriber(name)\n ? cloneObject(_formValues)\n : undefined,\n });\n }\n }\n }\n }\n (options.shouldDirty || options.shouldTouch) &&\n updateTouchAndDirty(name, field &&\n field._f &&\n !field._f.disabled &&\n (field._f.valueAsNumber ||\n field._f.valueAsDate ||\n field._f.setValueAs)\n ? getFieldValueAs(value, field._f)\n : fieldValue, options.shouldTouch, options.shouldDirty, !skipRender);\n options.shouldValidate &&\n trigger(name, {\n delayError: options.delayError,\n });\n if (options.shouldValidate &&\n field &&\n field._f &&\n field._f.deps &&\n (!Array.isArray(field._f.deps) || field._f.deps.length > 0)) {\n trigger(field._f.deps);\n }\n };\n const setFieldValues = (name, value, options, skipClone = false, skipRender = false, skipValueRender = false) => {\n for (const fieldKey in value) {\n if (!Object.prototype.hasOwnProperty.call(value, fieldKey)) {\n continue;\n }\n const fieldValue = value[fieldKey];\n const fieldName = name + '.' + fieldKey;\n const field = get(_fields, fieldName);\n if (_names.array.has(fieldName)) {\n _subjects.array.next({\n name: fieldName,\n values: skipClone ? _formValues : cloneObject(_formValues),\n });\n }\n (_names.array.has(name) ||\n isObject(fieldValue) ||\n (field && !field._f)) &&\n !isDateObject(fieldValue)\n ? setFieldValues(fieldName, fieldValue, options, skipClone, skipRender, skipValueRender)\n : setFieldValue(fieldName, fieldValue, options, skipClone, skipRender, skipValueRender);\n }\n };\n const _setValue = (name, value, options, skipClone, skipStateEmit = false) => {\n const field = get(_fields, name);\n const isFieldArray = _names.array.has(name);\n const cloneValue = skipClone ? value : cloneObject(value);\n const previousValue = get(_formValues, name);\n const isValueUnchanged = deepEqual(previousValue, cloneValue);\n if (!isValueUnchanged) {\n set(_formValues, name, cloneValue);\n }\n if (isFieldArray) {\n _subjects.array.next({\n name,\n values: skipClone ? _formValues : cloneObject(_formValues),\n });\n if (_isTracked('isDirty', 'dirtyFields') && options.shouldDirty) {\n _updateDirtyFields();\n _formState.isDirty = _getDirty(name, cloneValue);\n if (!skipStateEmit) {\n _subjects.state.next({\n name,\n dirtyFields: _formState.dirtyFields,\n isDirty: _formState.isDirty,\n });\n }\n }\n options.shouldValidate &&\n trigger(name, {\n delayError: options.delayError,\n });\n }\n else {\n const isEmpty = (Array.isArray(cloneValue) && !cloneValue.length) ||\n isEmptyObject(cloneValue);\n const skipValueRender = !isValueUnchanged && !skipStateEmit;\n if (!field || field._f || isNullOrUndefined(cloneValue) || isEmpty) {\n setFieldValue(name, cloneValue, options, skipClone, skipStateEmit, skipValueRender);\n }\n else {\n setFieldValues(name, cloneValue, options, skipClone, skipStateEmit, skipValueRender);\n }\n }\n if (!isValueUnchanged && !skipStateEmit) {\n const watched = isWatched(name, _names);\n const emittedName = _state.mount || watched ? name : undefined;\n const fieldArrayItemNames = isFieldArray\n ? []\n : getFieldArrayItemNames(_names.array, name);\n const values = skipClone\n ? _formValues\n : _hasValuesSubscriber(emittedName) ||\n fieldArrayItemNames.some(_hasValuesSubscriber)\n ? cloneObject(_formValues)\n : undefined;\n _subjects.state.next({\n ...(watched && _formState),\n name: emittedName,\n values,\n });\n for (const itemName of fieldArrayItemNames) {\n _subjects.state.next({ name: itemName, values });\n }\n }\n };\n const setValue = (name, value, options = {}) => _setValue(name, value, options, false);\n const setValues = (formValues, options = {}) => {\n const updatedFormValues = isFunction(formValues)\n ? formValues(_formValues)\n : formValues;\n if (!deepEqual(_formValues, updatedFormValues)) {\n _formValues = {\n ..._formValues,\n ...updatedFormValues,\n };\n for (const fieldName of new Set([..._names.mount, ..._names.array])) {\n if (has(updatedFormValues, fieldName)) {\n _setValue(fieldName, get(updatedFormValues, fieldName), options, true, true);\n }\n }\n _subjects.state.next({\n ..._formState,\n name: undefined,\n type: undefined,\n ...(_valuesSubscribers.size ? { values: _formValues } : {}),\n });\n if (options.shouldValidate) {\n _setValid();\n }\n }\n };\n const onChange = async (event) => {\n _state.mount = true;\n const target = event.target;\n let name = target.name;\n let isFieldValueUpdated = true;\n const field = get(_fields, name);\n const registerCallId = _registerCallId;\n const _updateIsFieldValueUpdated = (fieldValue) => {\n isFieldValueUpdated =\n !!get(_fields, name) &&\n !(_registerCallIds[name] > registerCallId) &&\n deepEqual(fieldValue, get(_formValues, name, fieldValue));\n };\n if (field) {\n _state.keepIsValid = false;\n let error;\n let isValid;\n let shouldFlushError = false;\n const fieldValue = target.type\n ? getFieldValue(field._f)\n : getEventValue(event);\n const isBlurEvent = event.type === EVENTS.BLUR || event.type === EVENTS.FOCUS_OUT;\n const hasNoValidationEffect = !hasValidation(field._f) &&\n !_options.validate &&\n !_options.resolver &&\n !get(_formState.errors, name) &&\n !field._f.deps;\n const shouldSkipValidation = hasNoValidationEffect ||\n skipValidation(isBlurEvent, get(_formState.touchedFields, name), _formState.isSubmitted, _validationModeAfterSubmit, _validationModeBeforeSubmit);\n const watched = isWatched(name, _names, isBlurEvent);\n set(_formValues, name, cloneObject(fieldValue));\n if (isBlurEvent) {\n if (!target || !target.readOnly) {\n field._f.onBlur && field._f.onBlur(event);\n if (Object.prototype.hasOwnProperty.call(delayErrorCallbacks, name)) {\n shouldFlushError = true;\n delayErrorCallbacks[name](0);\n }\n }\n }\n else if (field._f.onChange) {\n field._f.onChange(event);\n }\n const fieldState = updateTouchAndDirty(name, fieldValue, isBlurEvent);\n const shouldRender = !isEmptyObject(fieldState) || watched;\n !isBlurEvent &&\n _subjects.state.next({\n name,\n type: event.type,\n ...(_hasValuesSubscriber(name)\n ? { values: cloneObject(_formValues) }\n : {}),\n });\n if (shouldSkipValidation) {\n if ((!hasNoValidationEffect || !_formState.isValid) &&\n _isTracked('isValid')) {\n if (_options.mode === 'onBlur') {\n if (isBlurEvent) {\n _setValid();\n }\n }\n else if (!isBlurEvent) {\n _setValid();\n }\n }\n return (shouldRender &&\n _subjects.state.next({ name, ...(watched ? {} : fieldState) }));\n }\n if (!_options.resolver && _options.validate) {\n await validateForm({\n name: name,\n eventType: event.type,\n });\n }\n !isBlurEvent && watched && _subjects.state.next({ ..._formState });\n if (_options.resolver) {\n const resetCallId = _resetCallId;\n const { errors } = await _runSchema([name]);\n if (resetCallId !== _resetCallId) {\n return;\n }\n _updateIsValidating([name]);\n _updateIsFieldValueUpdated(fieldValue);\n if (!isFieldValueUpdated) {\n !isEmptyObject(fieldState) && _subjects.state.next(fieldState);\n return;\n }\n const previousErrorLookupResult = schemaErrorLookup(_formState.errors, _fields, name);\n const errorLookupResult = schemaErrorLookup(errors, _fields, previousErrorLookupResult.name || name);\n error = errorLookupResult.error;\n name = errorLookupResult.name;\n isValid = isEmptyObject(errors);\n }\n else {\n const resetCallId = _resetCallId;\n const setValidCallId = ++_setValidCallId;\n _updateIsValidating([name], true);\n error = (await validateField(field, _names.disabled, _formValues, shouldDisplayAllAssociatedErrors, _options.shouldUseNativeValidation))[name];\n if (resetCallId !== _resetCallId) {\n return;\n }\n _updateIsValidating([name]);\n _updateIsFieldValueUpdated(fieldValue);\n if (isFieldValueUpdated) {\n if (error) {\n isValid = false;\n }\n else if (_isTracked('isValid')) {\n isValid = await executeBuiltInValidation({\n fields: _fields,\n onlyCheckValid: true,\n name: name,\n eventType: event.type,\n });\n if (resetCallId !== _resetCallId) {\n return;\n }\n _updateIsFieldValueUpdated(fieldValue);\n if (setValidCallId !== _setValidCallId) {\n isValid = undefined;\n }\n }\n }\n }\n if (isFieldValueUpdated) {\n field._f.deps &&\n (!Array.isArray(field._f.deps) || field._f.deps.length > 0) &&\n trigger(field._f.deps);\n shouldRenderByError(name, isValid, error, fieldState);\n shouldFlushError &&\n Object.prototype.hasOwnProperty.call(delayErrorCallbacks, name) &&\n delayErrorCallbacks[name](0);\n }\n }\n };\n const _focusInput = (ref, key) => {\n if (get(_formState.errors, key) && ref.focus) {\n ref.focus();\n return 1;\n }\n return;\n };\n const trigger = async (name, options = {}) => {\n _state.keepIsValid = false;\n let isValid;\n let validationResult;\n const fieldNames = convertToArrayPayload(name);\n const resetCallId = _resetCallId;\n if (_options.resolver) {\n const errors = await executeSchemaAndUpdateState(isUndefined(name) ? name : fieldNames);\n isValid = isEmptyObject(errors);\n validationResult = name\n ? !fieldNames.some((name) => get(errors, name))\n : isValid;\n }\n else if (name) {\n validationResult = (await Promise.all(fieldNames.map(async (fieldName) => {\n const field = get(_fields, fieldName);\n return await executeBuiltInValidation({\n fields: field && field._f ? { [fieldName]: field } : field,\n eventType: EVENTS.TRIGGER,\n });\n }))).every(Boolean);\n !(!validationResult && !_formState.isValid) && _setValid();\n }\n else {\n validationResult = isValid = await executeBuiltInValidation({\n fields: _fields,\n name,\n eventType: EVENTS.TRIGGER,\n });\n }\n if (resetCallId !== _resetCallId) {\n return validationResult;\n }\n if (options.delayError && _options.delayError && isString(name)) {\n const error = get(_formState.errors, name);\n if (error) {\n unset(_formState.errors, name);\n delayErrorCallbacks[name] = debounce(name, () => updateErrors(name, error));\n delayErrorCallbacks[name](_options.delayError);\n }\n else {\n cancelDelayedError(name);\n }\n }\n if (options.shouldTouch) {\n for (const fieldName of name ? fieldNames : _names.mount) {\n !_names.array.has(fieldName) &&\n set(_formState.touchedFields, fieldName, true);\n }\n }\n _formState.errors = { ..._formState.errors };\n _subjects.state.next({\n ...(!isString(name) ||\n (_isTracked('isValid') && isValid !== _formState.isValid)\n ? {}\n : { name }),\n ...(_options.resolver || !name ? { isValid } : {}),\n ...(options.shouldTouch && _isTracked('touchedFields')\n ? { touchedFields: _formState.touchedFields }\n : {}),\n errors: _formState.errors,\n });\n options.shouldFocus &&\n !validationResult &&\n iterateFieldsByAction(_fields, _focusInput, name ? fieldNames : _names.mount);\n return validationResult;\n };\n const getValues = ((fieldNames, config) => {\n let values = isUndefined(fieldNames) && !config\n ? { ...(_state.mount ? _formValues : _defaultValues) }\n : _state.mount\n ? _formValues\n : _defaultValues;\n if (config) {\n values = extractFormValues(config.dirtyFields ? _formState.dirtyFields : _formState.touchedFields, values);\n }\n return isUndefined(fieldNames)\n ? values\n : isString(fieldNames)\n ? get(values, fieldNames)\n : fieldNames.map((name) => get(values, name));\n });\n const getErrors = ((fieldNames) => isUndefined(fieldNames)\n ? { ..._formState.errors }\n : isString(fieldNames)\n ? get(_formState.errors, fieldNames)\n : fieldNames.map((name) => get(_formState.errors, name)));\n const getFieldState = (name, formState) => {\n const targetFormState = formState || _formState;\n const error = get(targetFormState.errors, name);\n return {\n invalid: !!error,\n isDirty: !!get(targetFormState.dirtyFields, name),\n error,\n isValidating: !!get(targetFormState.validatingFields, name),\n isTouched: !!get(targetFormState.touchedFields, name),\n };\n };\n const clearErrors = (name) => {\n const names = name ? convertToArrayPayload(name) : undefined;\n if (names) {\n names.forEach((inputName) => {\n cancelDelayedErrorTree(inputName);\n unset(_formState.errors, inputName);\n _formState.errors = { ..._formState.errors };\n _subjects.state.next({\n name: inputName,\n errors: _formState.errors,\n });\n });\n }\n else {\n Object.keys(delayErrorCallbacks).forEach(cancelDelayedError);\n _formState.errors = {};\n _subjects.state.next({\n errors: _formState.errors,\n });\n }\n };\n const setError = (name, error, options) => {\n cancelDelayedErrorTree(name);\n const field = get(_fields, name, { _f: {} });\n const ref = field._f && field._f.ref;\n const currentError = get(_formState.errors, name) || {};\n const { ref: currentRef, message, type, types, ...restOfErrorTree } = currentError;\n set(_formState.errors, name, {\n ...restOfErrorTree,\n ...error,\n ref,\n });\n _formState.errors = { ..._formState.errors };\n _subjects.state.next({\n name,\n errors: _formState.errors,\n isValid: false,\n });\n options && options.shouldFocus && ref && ref.focus && ref.focus();\n };\n const watch = (name, defaultValue) => {\n if (isFunction(name)) {\n const valuesSubscriber = {};\n _valuesSubscribers.add(valuesSubscriber);\n const { unsubscribe } = _subjects.state.subscribe({\n next: (payload) => 'values' in payload &&\n name(payload.values || _getWatch(undefined, defaultValue), payload),\n });\n return {\n unsubscribe: () => {\n _valuesSubscribers.delete(valuesSubscriber);\n unsubscribe();\n },\n };\n }\n return _getWatch(name, defaultValue, true);\n };\n const _subscribe = (props) => {\n const valuesSubscriber = { name: props.name, exact: props.exact };\n props.formState &&\n props.formState.values &&\n _valuesSubscribers.add(valuesSubscriber);\n const { unsubscribe } = _subjects.state.subscribe({\n next: (formState) => {\n if (shouldSubscribeByName(props.name, formState.name, props.exact) &&\n shouldRenderFormState(formState, props.formState || _proxyFormState, props.reRenderRoot)) {\n const values = formState.values || { ..._formValues };\n props.callback({\n ..._formState,\n ...formState,\n validatingFields: _formState.validatingFields,\n isValidating: _formState.isValidating,\n values,\n defaultValues: _defaultValues,\n });\n }\n },\n });\n return () => {\n _valuesSubscribers.delete(valuesSubscriber);\n unsubscribe();\n };\n };\n const subscribe = (props) => {\n _state.mount = true;\n const trackedKeys = Object.keys(props.formState || {}).filter((key) => props.formState && props.formState[key]);\n for (const key of trackedKeys) {\n _proxySubscribeFormState[key] = (_proxySubscribeFormState[key] || 0) + 1;\n }\n const unsubscribe = _subscribe({\n ...props,\n formState: {\n ...defaultProxyFormState,\n ...props.formState,\n },\n });\n return () => {\n // splice(0) empties the list, so a repeated unsubscribe releases nothing\n for (const key of trackedKeys.splice(0)) {\n _proxySubscribeFormState[key]--;\n }\n unsubscribe();\n };\n };\n const unregister = (name, options = {}) => {\n const fieldNames = name\n ? convertToArrayPayload(name)\n : _names.mount;\n if (!options.keepIsValidating) {\n _updateValidatingFields(fieldNames);\n }\n for (const fieldName of fieldNames) {\n _names.mount.delete(fieldName);\n _names.array.delete(fieldName);\n _names.disabled.delete(fieldName);\n unset(_fields, fieldName);\n !options.keepValue && unset(_formValues, fieldName);\n if (!options.keepError) {\n cancelDelayedErrorTree(fieldName);\n unset(_formState.errors, fieldName);\n }\n !options.keepDirty && unset(_formState.dirtyFields, fieldName);\n !options.keepTouched && unset(_formState.touchedFields, fieldName);\n !_options.shouldUnregister &&\n !options.keepDefaultValue &&\n unset(_defaultValues, fieldName);\n }\n if (!options.keepError) {\n _formState.errors = { ..._formState.errors };\n }\n _valuesSubscribers.size &&\n _subjects.state.next({\n values: cloneObject(_formValues),\n });\n _subjects.state.next({\n ..._formState,\n ...(options.keepDirty ? {} : { isDirty: _getDirty() }),\n ...(options.keepIsValidating\n ? {}\n : { isValidating: !isEmptyObject(_formState.validatingFields) }),\n });\n !options.keepIsValid && _setValid();\n };\n const _setDisabledField = ({ disabled, name, }) => {\n if ((isBoolean(disabled) && _state.mount) ||\n !!disabled ||\n _names.disabled.has(name)) {\n const wasDisabled = _names.disabled.has(name);\n const isDisabled = !!disabled;\n const disabledStateChanged = wasDisabled !== isDisabled;\n disabled ? _names.disabled.add(name) : _names.disabled.delete(name);\n disabledStateChanged && _state.mount && !_state.action && _setValid();\n }\n };\n const register = (name, options = {}) => {\n let field = get(_fields, name);\n const disabledIsDefined = isBoolean(options.disabled) || isBoolean(_options.disabled);\n const shouldRevalidateRemount = !_names.registerName.has(name) && field && field._f && !field._f.mount;\n if (!field || !field._f) {\n _registerCallIds[name] = ++_registerCallId;\n }\n set(_fields, name, {\n ...(field || {}),\n _f: {\n ...(field && field._f ? field._f : { ref: { name } }),\n name,\n mount: true,\n ...options,\n },\n });\n _names.mount.add(name);\n if (field && field._f) {\n const nextField = get(_fields, name);\n for (const rule of REGISTER_VALIDATION_RULES) {\n if (!(rule in options)) {\n delete nextField._f[rule];\n }\n }\n }\n if (field && !shouldRevalidateRemount) {\n _setDisabledField({\n disabled: isBoolean(options.disabled)\n ? options.disabled\n : _options.disabled,\n name,\n });\n }\n else {\n updateValidAndValue(name, true, options.value);\n }\n return {\n ...(disabledIsDefined\n ? { disabled: options.disabled || _options.disabled }\n : {}),\n ...(_options.progressive\n ? {\n required: !!getRuleValue(options.required),\n min: getRuleValue(options.min),\n max: getRuleValue(options.max),\n minLength: getRuleValue(options.minLength),\n maxLength: getRuleValue(options.maxLength),\n pattern: getRuleValue(options.pattern),\n }\n : {}),\n name,\n onChange,\n onBlur: onChange,\n ref: (ref) => {\n if (ref) {\n _names.registerName.add(name);\n register(name, options);\n _names.registerName.delete(name);\n field = get(_fields, name);\n const fieldRef = isUndefined(ref.value)\n ? ref.querySelectorAll\n ? ref.querySelectorAll('input,select,textarea')[0] || ref\n : ref\n : ref;\n const radioOrCheckbox = isRadioOrCheckbox(fieldRef);\n const refs = field._f.refs || [];\n if (radioOrCheckbox\n ? refs.find((option) => option === fieldRef)\n : fieldRef === field._f.ref) {\n return;\n }\n const newField = {\n ...field._f,\n };\n if (radioOrCheckbox) {\n newField.refs = [\n ...refs.filter(live),\n fieldRef,\n ...(Array.isArray(get(_defaultValues, name))\n ? [{}]\n : []),\n ];\n newField.ref = { type: fieldRef.type, name };\n }\n else {\n newField.ref = fieldRef;\n delete newField.refs;\n }\n set(_fields, name, {\n _f: newField,\n });\n updateValidAndValue(name, false, undefined, fieldRef);\n }\n else {\n field = get(_fields, name, {});\n if (field._f) {\n field._f.mount = false;\n }\n (_options.shouldUnregister || options.shouldUnregister) &&\n !(isNameInFieldArray(_names.array, name) && _state.action) &&\n _names.unMount.add(name);\n }\n },\n };\n };\n const _focusError = () => _options.shouldFocusError &&\n !_options.shouldUseNativeValidation &&\n iterateFieldsByAction(_fields, _focusInput, _names.mount);\n const _disableForm = (disabled) => {\n if (isBoolean(disabled)) {\n _subjects.state.next({ disabled });\n iterateFieldsByAction(_fields, (ref, name) => {\n const currentField = get(_fields, name);\n if (currentField) {\n ref.disabled = currentField._f.disabled || disabled;\n if (Array.isArray(currentField._f.refs)) {\n currentField._f.refs.forEach((inputRef) => {\n inputRef.disabled = currentField._f.disabled || disabled;\n });\n }\n }\n }, 0);\n }\n };\n const handleSubmit = (onValid, onInvalid) => async (e) => {\n let result = undefined;\n let onValidError = undefined;\n if (e) {\n e.preventDefault && e.preventDefault();\n e.persist && e.persist();\n }\n let fieldValues = cloneObject(_formValues);\n _subjects.state.next({\n isSubmitting: true,\n });\n const resetCallId = _resetCallId;\n const onSubmitError = (error) => {\n if (resetCallId === _resetCallId) {\n _subjects.state.next({ isSubmitting: false });\n }\n throw error;\n };\n if (_options.resolver) {\n let validationResult;\n try {\n validationResult = await _runSchema();\n }\n catch (error) {\n onSubmitError(error);\n }\n const { errors, values } = validationResult;\n if (resetCallId !== _resetCallId) {\n return;\n }\n _updateIsValidating();\n Object.keys(delayErrorCallbacks).forEach(cancelDelayedError);\n _formState.errors = errors;\n fieldValues = cloneObject(values);\n }\n else {\n try {\n await executeBuiltInValidation({\n fields: _fields,\n eventType: EVENTS.SUBMIT,\n });\n }\n catch (error) {\n onSubmitError(error);\n }\n if (resetCallId !== _resetCallId) {\n return;\n }\n unset(_formState.errors, ROOT_ERROR_TYPE);\n _formState.errors = { ..._formState.errors };\n }\n if (_names.disabled.size) {\n for (const name of _names.disabled) {\n unset(fieldValues, name);\n }\n }\n if (isEmptyObject(_formState.errors)) {\n _subjects.state.next({\n errors: {},\n });\n try {\n result = await onValid(fieldValues, e);\n }\n catch (error) {\n onValidError = error;\n }\n }\n else {\n if (onInvalid) {\n try {\n await onInvalid({ ..._formState.errors }, e);\n }\n catch (error) {\n onSubmitError(error);\n }\n }\n _focusError();\n setTimeout(_focusError);\n }\n _subjects.state.next({\n isSubmitted: true,\n isSubmitting: false,\n isSubmitSuccessful: isEmptyObject(_formState.errors) && !onValidError,\n submitCount: _formState.submitCount + 1,\n errors: _formState.errors,\n });\n if (onValidError) {\n throw onValidError;\n }\n return result;\n };\n const resetField = (name, options = {}) => {\n if (get(_fields, name)) {\n _updateValidatingFields([name]);\n if (isUndefined(options.defaultValue)) {\n setValue(name, cloneObject(get(_defaultValues, name)));\n }\n else {\n setValue(name, options.defaultValue);\n set(_defaultValues, name, cloneObject(options.defaultValue));\n }\n if (!options.keepTouched) {\n unset(_formState.touchedFields, name);\n }\n if (!options.keepDirty) {\n unset(_formState.dirtyFields, name);\n _formState.isDirty = !isUndefined(options.defaultValue)\n ? _getDirty(name, cloneObject(get(_defaultValues, name)))\n : _getDirty();\n }\n if (!options.keepError) {\n cancelDelayedErrorTree(name);\n unset(_formState.errors, name);\n _formState.errors = { ..._formState.errors };\n _setValid();\n }\n _subjects.state.next({\n ..._formState,\n isValidating: !isEmptyObject(_formState.validatingFields),\n });\n }\n };\n const _reset = (formValues, keepStateOptions = {}) => {\n _resetCallId++;\n _setValidCallId++;\n const updatedValues = formValues ? cloneObject(formValues) : _defaultValues;\n const cloneUpdatedValues = cloneObject(updatedValues);\n const isEmptyResetValues = isEmptyObject(formValues);\n const values = cloneUpdatedValues;\n const fieldRefs = _fields;\n Object.keys(delayErrorCallbacks).forEach(cancelDelayedError);\n if (!keepStateOptions.keepDefaultValues) {\n _defaultValues = updatedValues;\n }\n if (!keepStateOptions.keepValues) {\n if (keepStateOptions.keepDirtyValues) {\n const fieldsToCheck = new Set([\n ..._names.mount,\n ...collectDirtyFieldNames(getDirtyFields(_defaultValues, _formValues, undefined, fieldRefs), _formState.dirtyFields),\n ]);\n for (const fieldName of fieldsToCheck) {\n const isDirty = get(_formState.dirtyFields, fieldName);\n const existingValue = get(_formValues, fieldName);\n const newValue = get(values, fieldName);\n if (isDirty && !isUndefined(existingValue)) {\n set(values, fieldName, existingValue);\n }\n else if (!isDirty && !isUndefined(newValue)) {\n setValue(fieldName, newValue);\n }\n }\n }\n else {\n if (isWeb && isUndefined(formValues)) {\n for (const name of _names.mount) {\n const field = get(_fields, name);\n if (field && field._f) {\n const fieldReference = Array.isArray(field._f.refs)\n ? field._f.refs[0]\n : field._f.ref;\n if (isHTMLElement(fieldReference)) {\n const form = fieldReference.closest('form');\n if (form) {\n form.reset();\n break;\n }\n }\n }\n }\n }\n if (keepStateOptions.keepFieldsRef) {\n for (const fieldName of _names.mount) {\n setValue(fieldName, get(values, fieldName));\n }\n }\n else {\n _fields = {};\n }\n }\n if (_options.shouldUnregister) {\n _formValues = keepStateOptions.keepDefaultValues\n ? cloneObject(_defaultValues)\n : {};\n if (keepStateOptions.keepFieldsRef) {\n for (const fieldName of _names.mount) {\n set(_formValues, fieldName, get(values, fieldName));\n }\n }\n }\n else {\n _formValues = cloneObject(values);\n }\n _subjects.array.next({\n values: { ...values },\n });\n _subjects.state.next({\n name: undefined,\n type: undefined,\n values: { ...values },\n });\n }\n _names = {\n mount: keepStateOptions.keepDirtyValues ? _names.mount : new Set(),\n unMount: new Set(),\n array: new Set(),\n registerName: new Set(),\n disabled: keepStateOptions.keepValues ||\n keepStateOptions.keepDirtyValues ||\n keepStateOptions.keepFieldsRef\n ? new Set([..._names.disabled].filter((name) => get(_fields, name)))\n : new Set(),\n watch: new Set(),\n watchAll: false,\n focus: '',\n };\n _state.mount =\n !_proxyFormState.isValid ||\n !!keepStateOptions.keepIsValid ||\n !!keepStateOptions.keepDirtyValues ||\n (!_options.shouldUnregister && !isEmptyObject(values));\n _state.watch = !!_options.shouldUnregister;\n _state.keepIsValid = !!keepStateOptions.keepIsValid;\n _state.action = false;\n _state.actionArrayLengths.clear();\n _dirtyFieldsStale = false;\n if (!keepStateOptions.keepErrors) {\n _formState.errors = {};\n }\n _subjects.state.next({\n submitCount: keepStateOptions.keepSubmitCount\n ? _formState.submitCount\n : 0,\n isDirty: isEmptyResetValues\n ? false\n : keepStateOptions.keepDirty\n ? _formState.isDirty\n : keepStateOptions.keepValues\n ? _getDirty()\n : !!(keepStateOptions.keepDefaultValues &&\n formValues &&\n !deepEqual(formValues, _defaultValues)),\n isSubmitted: keepStateOptions.keepIsSubmitted\n ? _formState.isSubmitted\n : false,\n dirtyFields: (isEmptyResetValues\n ? {}\n : keepStateOptions.keepDirtyValues\n ? keepStateOptions.keepDefaultValues && _formValues\n ? getDirtyFields(_defaultValues, _formValues, undefined, fieldRefs)\n : _formState.dirtyFields\n : keepStateOptions.keepDefaultValues && formValues\n ? getDirtyFields(_defaultValues, formValues, undefined, fieldRefs)\n : keepStateOptions.keepDirty\n ? _formState.dirtyFields\n : keepStateOptions.keepValues\n ? getDirtyFields(_defaultValues, _formValues, undefined, fieldRefs)\n : {}),\n touchedFields: keepStateOptions.keepTouched\n ? _formState.touchedFields\n : {},\n ...(!keepStateOptions.keepIsValidating &&\n (_formState.isValidating || !isEmptyObject(_formState.validatingFields))\n ? { validatingFields: {}, isValidating: false }\n : null),\n errors: keepStateOptions.keepErrors ? _formState.errors : {},\n isSubmitSuccessful: keepStateOptions.keepIsSubmitSuccessful\n ? _formState.isSubmitSuccessful\n : false,\n isSubmitting: false,\n defaultValues: _defaultValues,\n });\n };\n const reset = (formValues, keepStateOptions) => _reset(isFunction(formValues) ? formValues(_formValues) : formValues, {\n ..._options.resetOptions,\n ...keepStateOptions,\n });\n const setFocus = (name, options = {}) => {\n const field = get(_fields, name);\n const fieldReference = field && field._f;\n if (fieldReference) {\n const fieldRef = (fieldReference.refs ? fieldReference.refs[0] : fieldReference.ref);\n if (fieldRef.focus) {\n setTimeout(() => {\n fieldRef.focus();\n options.shouldSelect &&\n isFunction(fieldRef.select) &&\n fieldRef.select();\n });\n }\n }\n };\n const _setFormState = (updatedFormState) => {\n // `name`, `type`, and `values` describe the event that produced this\n // update, not the form's persisted state (they aren't part of\n // `FormState`). Merging them in would leak a stale `name`/`type` from\n // one event into a later, unrelated notification that doesn't specify\n // its own.\n const { name, type, values, ...formState } = updatedFormState;\n if (Object.keys(formState).length) {\n _formState = {\n ..._formState,\n ...formState,\n };\n }\n };\n _subjects.state.subscribe({ next: _setFormState });\n const _resetDefaultValues = () => isFunction(_options.defaultValues) &&\n _options.defaultValues().then((values) => {\n reset(values, _options.resetOptions);\n _subjects.state.next({\n isLoading: false,\n });\n });\n const resetDefaultValues = (values, options = {}) => {\n _defaultValues = cloneObject(values);\n if (!options.keepDirty) {\n const newDirtyFields = getDirtyFields(_defaultValues, _formValues, undefined, _fields);\n _formState.dirtyFields = newDirtyFields;\n _formState.isDirty = !isEmptyObject(newDirtyFields);\n }\n if (!options.keepIsValid) {\n _setValid();\n }\n _subjects.state.next({\n ..._formState,\n defaultValues: _defaultValues,\n });\n };\n const methods = {\n control: {\n register,\n unregister,\n getFieldState,\n handleSubmit,\n setError,\n _subscribe,\n _runSchema,\n _updateIsValidating,\n _focusError,\n _getWatch,\n _getDirty,\n _setValid,\n _setFieldArray,\n _setDisabledField,\n _setErrors,\n _getFieldArray,\n _reset,\n _resetDefaultValues,\n _removeUnmounted,\n _disableForm,\n _subjects,\n _proxyFormState,\n get _fields() {\n return _fields;\n },\n get _formValues() {\n return _formValues;\n },\n get _state() {\n return _state;\n },\n set _state(value) {\n _state = value;\n },\n get _defaultValues() {\n return _defaultValues;\n },\n get _names() {\n return _names;\n },\n set _names(value) {\n _names = value;\n },\n get _formState() {\n return _formState;\n },\n get _options() {\n return _options;\n },\n set _options(value) {\n _options = {\n ..._options,\n ...value,\n };\n _validationModeBeforeSubmit = getValidationModes(_options.mode);\n _validationModeAfterSubmit = getValidationModes(_options.reValidateMode);\n shouldDisplayAllAssociatedErrors =\n _options.criteriaMode === VALIDATION_MODE.all;\n },\n },\n subscribe,\n trigger,\n register,\n handleSubmit,\n watch,\n setValue,\n setValues,\n getValues,\n getErrors,\n reset,\n resetField,\n resetDefaultValues,\n clearErrors,\n unregister,\n setError,\n setFocus,\n getFieldState,\n };\n return {\n ...methods,\n formControl: methods,\n };\n}\n\nconst RESET_OPTIONS = {\n mode: defaultOptions.mode,\n reValidateMode: defaultOptions.reValidateMode,\n shouldFocusError: defaultOptions.shouldFocusError,\n resolver: undefined,\n criteriaMode: undefined,\n delayError: undefined,\n shouldUnregister: undefined,\n shouldUseNativeValidation: undefined,\n context: undefined,\n progressive: undefined,\n resetOptions: undefined,\n};\n/**\n * Core hook for managing a form. Returns all methods and state for\n * registration, validation, and submission.\n *\n * @see [API](https://react-hook-form.com/docs/useform)\n *\n * @example\n * ```tsx\n * const { register, handleSubmit, formState: { errors } } = useForm<FormValues>();\n * <form onSubmit={handleSubmit(onSubmit)}>\n * <input {...register(\"email\", { required: true })} />\n * </form>\n * ```\n */\nfunction useForm(props = {}) {\n const _formControl = React.useRef(undefined);\n const _values = React.useRef(undefined);\n const _formControlProp = React.useRef(props.formControl);\n const _hadDisabled = React.useRef(false);\n const _hadValidate = React.useRef(!!props.validate);\n const _hadErrors = React.useRef(!!props.errors);\n const _isMounted = React.useRef(false);\n const [formState, updateFormState] = React.useState(() => ({\n ...cloneObject(DEFAULT_FORM_STATE),\n isLoading: isFunction(props.defaultValues),\n errors: props.errors || {},\n disabled: props.disabled || false,\n defaultValues: isFunction(props.defaultValues)\n ? undefined\n : props.defaultValues,\n }));\n if (!_formControl.current ||\n (props.formControl && _formControlProp.current !== props.formControl)) {\n _formControlProp.current = props.formControl;\n _hadDisabled.current = false;\n if (props.formControl) {\n _formControl.current = {\n ...props.formControl,\n formState,\n };\n if (props.defaultValues && !isFunction(props.defaultValues)) {\n props.formControl.reset(props.defaultValues, props.resetOptions);\n }\n }\n else {\n const { formControl, ...rest } = createFormControl(props);\n _formControl.current = {\n ...rest,\n formState,\n };\n }\n }\n const control = _formControl.current.control;\n const previousOptions = control._options;\n const removedOptions = {};\n for (const key in RESET_OPTIONS) {\n if (key in previousOptions && !(key in props)) {\n removedOptions[key] = RESET_OPTIONS[key];\n }\n }\n if (_hadDisabled.current && !props.disabled) {\n removedOptions.disabled = false;\n }\n control._options = {\n ...removedOptions,\n ...props,\n validate: props.validate,\n };\n const getCurrentFormState = () => ({\n ...control._formState,\n defaultValues: control._defaultValues,\n });\n const { resyncIfNeeded, snapshot } = useResyncOnReconnect(getCurrentFormState);\n useIsomorphicLayoutEffect(() => {\n resyncIfNeeded(true, getCurrentFormState, updateFormState);\n const unsubscribe = control._subscribe({\n formState: control._proxyFormState,\n callback: () => updateFormState({\n ...control._formState,\n defaultValues: control._defaultValues,\n }),\n reRenderRoot: true,\n });\n updateFormState((data) => ({\n ...data,\n isReady: true,\n }));\n control._formState.isReady = true;\n control._subjects.state.next({ isReady: true });\n return () => {\n unsubscribe();\n snapshot(true, getCurrentFormState);\n };\n }, [control, resyncIfNeeded, snapshot]);\n React.useEffect(() => {\n control._disableForm(_hadDisabled.current && !props.disabled ? false : props.disabled);\n _hadDisabled.current = !!props.disabled;\n }, [control, props.disabled]);\n React.useEffect(() => {\n if (props.mode) {\n control._options.mode = props.mode;\n }\n if (props.reValidateMode) {\n control._options.reValidateMode = props.reValidateMode;\n }\n }, [control, props.mode, props.reValidateMode]);\n React.useEffect(() => {\n if (props.errors) {\n control._setErrors(props.errors);\n control._focusError();\n }\n else if (_hadErrors.current) {\n control._setErrors({});\n }\n _hadErrors.current = !!props.errors;\n }, [control, props.errors]);\n React.useEffect(() => {\n if (_hadValidate.current && !props.validate) {\n _formControl.current && _formControl.current.clearErrors(FORM_ERROR_TYPE);\n }\n _hadValidate.current = !!props.validate;\n }, [props.validate]);\n React.useEffect(() => {\n props.shouldUnregister &&\n control._subjects.state.next({\n values: control._getWatch(),\n });\n }, [control, props.shouldUnregister]);\n React.useEffect(() => {\n if (control._proxyFormState.isDirty) {\n const isDirty = control._getDirty();\n if (isDirty !== formState.isDirty) {\n control._subjects.state.next({\n isDirty,\n });\n }\n }\n }, [control, formState.isDirty]);\n React.useEffect(() => {\n if (props.values && !deepEqual(props.values, _values.current)) {\n control._reset(props.values, {\n keepFieldsRef: true,\n ...control._options.resetOptions,\n });\n if (!(control._options.resetOptions &&\n control._options.resetOptions.keepIsValid)) {\n control._setValid();\n }\n _values.current = props.values;\n updateFormState((state) => ({ ...state }));\n }\n else {\n control._resetDefaultValues();\n }\n }, [control, props.values]);\n React.useEffect(() => {\n if (!control._state.mount || (!_isMounted.current && !props.values)) {\n control._setValid();\n control._state.mount = true;\n }\n _isMounted.current = true;\n if (control._state.watch) {\n control._state.watch = false;\n control._subjects.state.next({ ...control._formState });\n }\n control._removeUnmounted();\n });\n _formControl.current.formState = React.useMemo(() => getProxyFormState(formState, control), [control, formState]);\n return _formControl.current;\n}\n\nconst HookFormContext = React.createContext(null);\nHookFormContext.displayName = 'HookFormContext';\n/**\n * Retrieves all `useForm` methods from the nearest `FormProvider`.\n * Use in deeply nested components to avoid prop-drilling.\n *\n * @see [API](https://react-hook-form.com/docs/useformcontext)\n *\n * @example\n * ```tsx\n * const { register } = useFormContext<FormValues>();\n * ```\n */\nconst useFormContext = () => React.useContext(HookFormContext);\n/**\n * Provides all `useForm` methods to the component tree via React Context.\n * Pair with `useFormContext` to consume them in any descendant.\n *\n * @see [API](https://react-hook-form.com/docs/useformcontext)\n *\n * @example\n * ```tsx\n * <FormProvider {...methods}>\n * <form onSubmit={methods.handleSubmit(onSubmit)}>{children}</form>\n * </FormProvider>\n * ```\n */\nconst FormProvider = ({ children, watch, getValues, getErrors, getFieldState, setError, clearErrors, setValue, setValues, trigger, formState, resetField, reset, resetDefaultValues, handleSubmit, unregister, control, register, setFocus, subscribe, }) => {\n const memoizedValue = React.useMemo(() => ({\n watch,\n getValues,\n getErrors,\n getFieldState,\n setError,\n clearErrors,\n setValue,\n setValues,\n trigger,\n formState,\n resetField,\n reset,\n resetDefaultValues,\n handleSubmit,\n unregister,\n control,\n register,\n setFocus,\n subscribe,\n }), [\n clearErrors,\n control,\n formState,\n getErrors,\n getFieldState,\n getValues,\n handleSubmit,\n register,\n reset,\n resetDefaultValues,\n resetField,\n setError,\n setFocus,\n setValue,\n setValues,\n subscribe,\n trigger,\n unregister,\n watch,\n ]);\n return (React.createElement(HookFormContext.Provider, { value: memoizedValue },\n React.createElement(HookFormControlContext.Provider, { value: memoizedValue.control }, children)));\n};\n\n/**\n * Component wrapper around `useWatch`. Re-renders only when watched fields change.\n *\n * @see [API](https://react-hook-form.com/docs/usewatch)\n *\n * @example\n * ```tsx\n * <Watch\n * control={control}\n * names={[\"foo\", \"bar\"]}\n * render={([foo, bar]) => <span>{foo} {bar}</span>}\n * />\n * ```\n */\nconst Watch = (props) => props.render(useWatch({ name: props.names, ...props }));\n\nexport { Controller, ErrorMessage, FieldArray, Form, FormProvider, FormState, FormStateSubscribe, Watch, appendErrors, createFormControl, get, set, useController, useFieldArray, useForm, useFormContext, useFormState, useWatch };\n//# sourceMappingURL=index.esm.mjs.map\n"],"names":["React"],"mappings":";;AAEA,IAAI,eAAe,GAAG,CAAC,OAAO,KAAK,OAAO,CAAC,IAAI,KAAK,UAAU;;AAE9D,IAAI,WAAW,GAAG,CAAC,OAAO,KAAK,OAAO,CAAC,IAAI,KAAK,MAAM;;AAEtD,IAAI,YAAY,GAAG,CAAC,KAAK,KAAK,KAAK,YAAY,I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ACb,QAAQ,kBAAkB;AAC1B,QAAQ,UAAU;AAClB,QAAQ,QAAQ;AAChB,QAAQ,QAAQ;AAChB,QAAQ,QAAQ;AAChB,QAAQ,SAAS;AACjB,QAAQ,SAAS;AACjB,QAAQ,OAAO;AACf,QAAQ,UAAU;AAClB,QAAQ,KAAK;AACb,KAAK,CAAC;AACN,IAAI,QAAQA,cAAK,CAAC,aAAa,CAAC,eAAe,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE;AAClF,QAAQA,cAAK,CAAC,aAAa,CAAC,sBAAsB,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,aAAa,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC,CAAC;AACzG;;;;","x_google_ignoreList":[0]}
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../src/utils.ts"],"sourcesContent":["import { clsx, type ClassValue } from \"clsx\";\r\nimport { twMerge } from \"tailwind-merge\";\r\n\r\nexport function cn(...inputs: ClassValue[]) {\r\n return twMerge(clsx(inputs));\r\n}"],"names":[],"mappings":";;;AAGM,SAAU,EAAE,CAAC,GAAG,MAAoB,EAAA;AACxC,IAAA,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC9B;;;;"}
1
+ {"version":3,"file":"utils.js","sources":["../src/utils.ts"],"sourcesContent":["import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}"],"names":[],"mappings":";;;AAGM,SAAU,EAAE,CAAC,GAAG,MAAoB,EAAA;AACxC,IAAA,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC9B;;;;"}