{"version":3,"file":"useFormControl.mjs","names":[],"sources":["../../../../../../../react-form/src/hooks/useFormControl.ts"],"sourcesContent":["\"use client\";\n\nimport events, { EventSubscription } from \"@mongez/events\";\nimport { ReactNode, useEffect, useMemo, useRef, useState } from \"react\";\nimport { getFormConfig } from \"../configurations\";\nimport { standardSchemaToRule } from \"../standard-schema/adapter\";\nimport {\n  FormContextData,\n  FormControl,\n  FormControlChangeOptions,\n  FormControlHook,\n  FormControlOptions,\n  FormControlProps,\n  InputRule,\n  InputRuleOptions,\n  ValidateOn,\n} from \"../types\";\nimport { useControlId } from \"./form-hooks\";\nimport { useForm } from \"./useForm\";\n\nexport const defaultFormControlOptions = {\n  collectUnchecked: true,\n  uncheckedValue: false,\n  transformValue: (value: any, formControl?: FormControl) => {\n    if (formControl?.multiple && !Array.isArray(value)) {\n      return [value];\n    }\n\n    return value;\n  },\n};\n\n/**\n * Sentinel returned by the per-rule applier when a rule passed (or was a\n * non-short-circuiting failure under `validateAll`) so the pipeline keeps going.\n */\nconst VALIDATION_CONTINUE = Symbol(\"validation.continue\");\n\nconst isDomAvailable = () =>\n  typeof document !== \"undefined\" && typeof window !== \"undefined\";\n\nconst isElementOrAncestorHidden = (element: HTMLElement) => {\n  if (!element) {\n    return false;\n  }\n\n  if (element.hidden) {\n    return true;\n  }\n\n  if (!element.parentElement) {\n    return false;\n  }\n\n  return isElementOrAncestorHidden(element.parentElement);\n};\n\nconst initializeValue = (\n  props: FormControlProps,\n  options: FormControlOptions,\n  form: FormContextData,\n  name: string\n) => {\n  if (![undefined, null].includes(props.value)) {\n    return options.transformValue?.(props.value);\n  }\n\n  if (![undefined, null].includes(props.defaultValue)) {\n    return options.transformValue?.(props.defaultValue);\n  }\n\n  if (form && name) {\n    const value = form.getInitialValue(name);\n\n    if (value !== undefined) return value;\n  }\n\n  return props.multiple ? [] : \"\";\n};\n\nexport function useFormControl<T extends FormControlProps>(\n  baseProps: T,\n  incomingFormControlOptions: FormControlOptions = {}\n) {\n  const {\n    id: incomingId,\n    name: incomingName,\n    onChange,\n    rules = [],\n    errors = {},\n    type = \"text\",\n    errorKeys = {},\n    onError,\n    disabled: incomingDisabled,\n    validate: incomingValidate,\n    schema: incomingSchema,\n    validateOn: incomingValidateOn,\n    value: incomingValue,\n    defaultValue: _dv,\n    checked: _checked,\n    defaultChecked: _defaultChecked,\n    ...props\n  } = baseProps;\n\n  const name = useMemo(\n    () =>\n      String(incomingName)\n        .replace(\"][\", \".\")\n        .replace(\"[\", \".\")\n        .replace(\"]\", \"\"),\n    [incomingName]\n  );\n\n  const id = useControlId({\n    id: incomingId,\n    name,\n  });\n\n  const errorId = `${id}-error`;\n\n  const formControlOptions = {\n    ...defaultFormControlOptions,\n    ...incomingFormControlOptions,\n  };\n\n  const [disabled, setDisabled] = useState(Boolean(incomingDisabled));\n\n  const inputRef = useRef<any>();\n  const visibleElementRef = useRef<any>();\n  const form = useForm();\n\n  // Monotonic token guarding against stale async validation results: each\n  // validation run captures the current value; if a newer run starts before an\n  // async rule resolves, the stale result is discarded.\n  const validationSeq = useRef(0);\n\n  // Count of async validation runs still in flight. `isValidating` clears only\n  // when this returns to 0, so a sync run that supersedes an async run cannot\n  // leave the flag stuck `true`.\n  const asyncInFlight = useRef(0);\n\n  const [state, setState] = useState<{\n    error: ReactNode;\n    value: any;\n    checked: boolean;\n    isValidating: boolean;\n  }>(() => {\n    return {\n      error: null,\n      isValidating: false,\n      value: initializeValue(baseProps, formControlOptions, form, name),\n      checked:\n        _checked ??\n        (_defaultChecked !== undefined\n          ? _defaultChecked\n          : (form && name ? form.getInitialValue(name) : undefined) ??\n            (type === \"checkbox\" ? false : undefined)),\n    };\n  });\n\n  const { value, checked, error, isValidating } = state;\n\n  const updateError = (error: ReactNode) => {\n    setState((state) => ({\n      ...state,\n      error,\n    }));\n  };\n\n  const setError = (error: ReactNode) => {\n    updateError(error);\n    onError?.(error);\n  };\n\n  const setValidating = (isValidating: boolean) => {\n    setState((state) => ({\n      ...state,\n      isValidating,\n    }));\n  };\n\n  const setValue = (value = formControl.value) => {\n    setState((state) => ({\n      ...state,\n      value,\n    }));\n  };\n\n  const setCheckedState = (checked: boolean) => {\n    setState((state) => ({\n      ...state,\n      checked,\n    }));\n  };\n\n  const updateFormControlValidityState = (error: any) => {\n    formControl.error = error;\n    formControl.isValid = !error;\n\n    if (error) {\n      form?.invalidControl(formControl);\n    } else {\n      form?.validControl(formControl);\n    }\n\n    form?.checkIfIsValid();\n  };\n\n  /**\n   * Resolve the active validation trigger: per-control > form-level > global\n   * config > `\"change\"`.\n   */\n  const resolveValidateOn = (): ValidateOn =>\n    (incomingValidateOn as ValidateOn) ||\n    form?.validateOn ||\n    (getFormConfig(\"validateOn\", \"change\") as ValidateOn);\n\n  /**\n   * Whether a value change should trigger validation now. For `\"blur\"` /\n   * `\"submit\"` modes we still revalidate on change once the field has already\n   * errored or the form has been submitted — so cleared errors update live.\n   */\n  const shouldValidateOnChange = (): boolean => {\n    const mode = resolveValidateOn();\n\n    if (mode === \"change\") return true;\n\n    return formControl.isValid === false || form?.wasSubmitted === true;\n  };\n\n  /**\n   * Build the ordered rule list: per-instance `validate` first, then the\n   * passed `rules`, then a per-field `schema` (if any) last.\n   */\n  const buildRules = (): InputRule[] => {\n    const list: InputRule[] = [];\n\n    if (incomingValidate) {\n      list.push({\n        validate: incomingValidate,\n        name: \"custom\",\n        requiresValue: true,\n      });\n    }\n\n    list.push(...rules);\n\n    const schema = incomingSchema || incomingFormControlOptions.schema;\n\n    if (schema) {\n      list.push(standardSchemaToRule(schema, \"schema\"));\n    }\n\n    return list;\n  };\n\n  /**\n   * Run the rule pipeline. Returns `{ error, errorsList }` synchronously when\n   * every rule resolves synchronously (preserving the engine's original\n   * timing), and a `Promise` of the same shape only when a rule returns one —\n   * so async validation genuinely gates submission without making the common\n   * sync path async.\n   *\n   * Each run owns a fresh `errorsList` (assigned onto `formControl.errorsList`\n   * up front so rules like `strongRule` that write per-criterion keys land in\n   * it). The committer reassigns `formControl.errorsList` only for the latest\n   * run, so a discarded stale async run cannot poison a fresh result.\n   */\n  const runValidationRules = ():\n    | { error: ReactNode; errorsList: Record<string, ReactNode> }\n    | Promise<{ error: ReactNode; errorsList: Record<string, ReactNode> }> => {\n    if (!errorKeys.name) {\n      errorKeys.name = String(baseProps.label || baseProps.placeholder || name);\n    }\n\n    const runErrors: Record<string, ReactNode> = {};\n\n    // Expose this run's error map to the rules (strongRule et al. write here).\n    formControl.errorsList = runErrors;\n\n    const validationData: InputRuleOptions = {\n      ...baseProps,\n      value: formControl.value,\n      name,\n      checked: formControl.checked,\n      formControl,\n      errorKeys,\n      form,\n    };\n\n    const rulesList = buildRules();\n\n    const applyResult = (\n      rule: InputRule,\n      result: ReactNode\n    ): ReactNode | typeof VALIDATION_CONTINUE => {\n      if (result) {\n        const ruleName = rule.name || \"custom\";\n        const errorMessage = errors[ruleName] || result;\n\n        runErrors[ruleName] = errorMessage;\n\n        if (!incomingFormControlOptions.validateAll) {\n          return errorMessage;\n        }\n      }\n\n      return VALIDATION_CONTINUE;\n    };\n\n    const finalize = (): ReactNode => {\n      if (\n        Object.keys(runErrors).length > 0 &&\n        !incomingFormControlOptions.validateAll\n      ) {\n        return Object.keys(runErrors).map((key) => runErrors[key]);\n      }\n\n      return null;\n    };\n\n    const process = (\n      index: number\n    ):\n      | { error: ReactNode; errorsList: Record<string, ReactNode> }\n      | Promise<{ error: ReactNode; errorsList: Record<string, ReactNode> }> => {\n      for (let i = index; i < rulesList.length; i++) {\n        const rule = rulesList[i];\n\n        if (rule.requiresType && rule.requiresType !== formControl.type)\n          continue;\n\n        const requiresValue =\n          rule.requiresValue === undefined || rule.requiresValue;\n\n        if (\n          requiresValue &&\n          [undefined, null, \"\"].includes(formControl.value)\n        ) {\n          continue;\n        }\n\n        const result = rule.validate(validationData) as\n          | ReactNode\n          | Promise<ReactNode>;\n\n        if (result instanceof Promise) {\n          return result.then((resolved) => {\n            const applied = applyResult(rule, resolved as ReactNode);\n\n            if (applied !== VALIDATION_CONTINUE) {\n              return { error: applied, errorsList: runErrors };\n            }\n\n            return process(i + 1);\n          });\n        }\n\n        const applied = applyResult(rule, result as ReactNode);\n\n        if (applied !== VALIDATION_CONTINUE) {\n          return { error: applied, errorsList: runErrors };\n        }\n      }\n\n      return { error: finalize(), errorsList: runErrors };\n    };\n\n    return process(0);\n  };\n\n  /**\n   * Validate the control and commit the result (error + validity). Sync rules\n   * commit synchronously; async rules flip `isValidating` and commit on resolve.\n   *\n   * Stale-result handling uses two independent guards:\n   * - a sequence token (`validationSeq`) so only the latest run commits its\n   *   error / validity / errorsList;\n   * - an in-flight counter (`asyncInFlight`) so `isValidating` clears exactly\n   *   when the last outstanding async run settles — even if a later *sync* run\n   *   superseded it (which previously left the flag stuck `true`).\n   */\n  const validateFormControl = (): ReactNode | Promise<ReactNode> => {\n    const seq = ++validationSeq.current;\n\n    const outcome = runValidationRules();\n\n    if (outcome instanceof Promise) {\n      asyncInFlight.current++;\n      formControl.isValidating = true;\n      setValidating(true);\n\n      return outcome.then((result) => {\n        const isLatest = seq === validationSeq.current;\n        const settledAll = --asyncInFlight.current === 0;\n\n        if (settledAll) {\n          formControl.isValidating = false;\n          setValidating(false);\n        }\n\n        if (!isLatest) {\n          // Superseded run: discard its error/validity/errorsList entirely.\n          return result.error;\n        }\n\n        formControl.errorsList = result.errorsList;\n        setError(result.error);\n        updateFormControlValidityState(result.error);\n\n        return result.error;\n      });\n    }\n\n    // Sync completion. If an async run was superseded by this one, it stays\n    // in-flight and will clear `isValidating` when it settles; only clear here\n    // when nothing async is pending.\n    if (asyncInFlight.current === 0 && formControl.isValidating) {\n      formControl.isValidating = false;\n      setValidating(false);\n    }\n\n    formControl.errorsList = outcome.errorsList;\n    setError(outcome.error);\n    updateFormControlValidityState(outcome.error);\n\n    return outcome.error;\n  };\n\n  // Reset baseline — what `form.reset()` restores this control to. It prefers\n  // an explicit `defaultValue` (control- then form-level) over the reactive\n  // hydration snapshot, so live-loaded `values` never become the reset target.\n  // Falls back to the initial display value when no default exists.\n  const resetBaseline = (() => {\n    if (![undefined, null].includes(baseProps.value)) {\n      return formControlOptions.transformValue?.(baseProps.value);\n    }\n\n    if (![undefined, null].includes(baseProps.defaultValue)) {\n      return formControlOptions.transformValue?.(baseProps.defaultValue);\n    }\n\n    if (form && name) {\n      const baseline = form.getResetBaseline(name);\n      if (baseline !== undefined) return baseline;\n    }\n\n    return value;\n  })();\n\n  const formControl: FormControl = useMemo(() => {\n    const formControlData: FormControl = {\n      initialValue: resetBaseline,\n      initialChecked: checked,\n      collectUnchecked: formControlOptions.collectUnchecked,\n      uncheckedValue: formControlOptions.uncheckedValue,\n      value,\n      isDirty: false,\n      isValidating: false,\n      errorsList: {},\n      isTouched: false,\n      isControlled:\n        baseProps.value !== undefined || baseProps.checked !== undefined,\n      id,\n      name,\n      checked,\n      defaultValue: _dv,\n      disabled,\n      isValid: null, // null means not validated yet\n      disable(isDisabled) {\n        isDisabled = Boolean(isDisabled);\n        setDisabled(isDisabled);\n        formControl.disabled = isDisabled;\n      },\n      type,\n      inputRef,\n      rendered: false,\n      visibleElementRef,\n      error,\n      setError,\n      props: baseProps,\n      setChecked: (checked: boolean) => {\n        formControl.checked = checked;\n        formControl.isDirty = true;\n\n        setCheckedState(checked);\n\n        if (shouldValidateOnChange()) {\n          validateFormControl();\n        }\n\n        onChange?.(checked, {\n          formControl,\n        });\n\n        // Emit the same wrapper shape as change() so `formControl.onChange`\n        // subscribers always receive `{ value, checked, formControl }`.\n        events.trigger(`form.control.${id}.change`, {\n          value: formControl.value,\n          checked: formControl.checked,\n          formControl,\n        });\n      },\n      isVisible: () => {\n        // On non-DOM platforms (e.g. React Native) we cannot inspect the\n        // rendered tree for visibility, so treat every control as visible.\n        if (!isDomAvailable()) return true;\n        return isElementOrAncestorHidden(visibleElementRef.current) === false;\n      },\n      focus: () => {\n        inputRef.current?.focus();\n      },\n      blur: () => {\n        inputRef.current?.blur();\n      },\n      clear: () => {\n        formControl.cancelValidation();\n\n        formControl.change(formControl.multiple ? [] : \"\", {\n          updateState: true,\n          validate: false,\n          checked: false,\n        });\n\n        formControl.setError(null);\n        formControl.isValid = null;\n        formControl.isDirty = false;\n        formControl.isTouched = false;\n\n        events.trigger(`form.control.${id}.clear`, formControl);\n      },\n      cancelValidation: () => {\n        // Invalidate any in-flight async run (so it won't commit) and clear the\n        // validating flag. The pending run still settles and decrements the\n        // in-flight counter; it just won't apply its result.\n        validationSeq.current++;\n\n        if (formControl.isValidating) {\n          formControl.isValidating = false;\n          setValidating(false);\n        }\n      },\n      reset: () => {\n        formControl.cancelValidation();\n\n        // Clear the dirty flag BEFORE firing change() so the form-level\n        // listener registered in FormEngine.register sees `isDirty === false`\n        // and removes this control from `dirtyControls`. We pass\n        // `dirty: false` so change() does not clobber the flag back to true.\n        formControl.isDirty = false;\n\n        formControl.change(formControl.initialValue, {\n          checked: formControl.initialChecked,\n          updateState: true,\n          validate: false,\n          dirty: false,\n        });\n\n        formControl.setError(null);\n        formControl.isValid = null;\n        formControl.isDirty = false;\n        formControl.isTouched = false;\n\n        events.trigger(`form.control.${id}.reset`, formControl);\n      },\n      multiple: formControlOptions.multiple,\n      validate: validateFormControl,\n      change(\n        value,\n        {\n          updateState = true,\n          validate = true,\n          dirty = true,\n          ...other\n        }: FormControlChangeOptions = {}\n      ) {\n        if (value !== undefined) {\n          value = formControlOptions.transformValue?.(value, formControl);\n          formControl.value = value;\n        }\n\n        if (typeof other.checked !== \"undefined\") {\n          formControl.checked = other.checked;\n        }\n\n        formControl.isDirty = dirty;\n\n        events.trigger(`form.control.${id}.change`, {\n          value: formControl.value,\n          checked: formControl.checked,\n          ...other,\n          formControl,\n        });\n\n        if (updateState) {\n          // Value updates synchronously so the rendered input and\n          // `form.value(name)` reflect the change immediately. Validation is\n          // separate and may resolve asynchronously.\n          if (other.checked !== undefined) {\n            setCheckedState(formControl.checked);\n          }\n\n          setValue(formControl.value);\n\n          if (validate && shouldValidateOnChange()) {\n            validateFormControl();\n          }\n        }\n      },\n      onChange: (callback: any) => {\n        return events.subscribe(`form.control.${id}.change`, callback);\n      },\n      onDestroy: (callback: any) => {\n        return events.subscribe(`form.control.${id}.destroy`, callback);\n      },\n      onReset: (callback: any) => {\n        return events.subscribe(`form.control.${id}.reset`, callback);\n      },\n      onClear: (callback: any) => {\n        return events.subscribe(`form.control.${id}.clear`, callback);\n      },\n      unregister() {\n        events.trigger(`form.control.${id}.destroy`, formControl);\n      },\n      isCollectable() {\n        if (formControlOptions.isCollectable) {\n          return formControlOptions.isCollectable(formControl);\n        }\n\n        if (formControl.disabled) return false;\n\n        if (\n          [\"checkbox\", \"radio\"].includes(formControl.type) &&\n          !formControl.checked\n        ) {\n          return Boolean(formControlOptions.collectUnchecked);\n        }\n\n        return formControl.value !== undefined && formControl.value !== null;\n      },\n      collectValue() {\n        if (formControlOptions.collectValue) {\n          return formControlOptions.collectValue(formControl);\n        }\n\n        if ([\"checkbox\", \"radio\"].includes(formControl.type)) {\n          if (\n            !formControl.checked &&\n            formControlOptions.uncheckedValue !== undefined\n          ) {\n            return formControlOptions.uncheckedValue;\n          } else if (formControl.checked) {\n            return formControl.value || true;\n          }\n\n          return false;\n        }\n\n        if (formControl.multiple && !Array.isArray(formControl.value)) {\n          return [formControl.value];\n        }\n\n        return formControl.value;\n      },\n    };\n\n    return formControlData;\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, []);\n\n  // Hold a stable reference to the latest rest props so the `onInit` effect\n  // below does not need `props` (a fresh object every render) as a dep.\n  const latestPropsRef = useRef(props);\n  latestPropsRef.current = props;\n\n  // Build a stable identity for `rules` so consumers passing a fresh\n  // array literal each render do not retrigger the `onInit` subscription\n  // loop below. Two arrays with the same rule names (in the same order)\n  // are treated as equal.\n  const rulesKey = useMemo(\n    () =>\n      rules.map((rule, index) => rule.name ?? `__anonymous_${index}`).join(\"|\"),\n    [rules]\n  );\n\n  useEffect(() => {\n    // now find all rules that have onInit method and call it\n    const subscriptions: EventSubscription[] = [];\n    for (const rule of rules) {\n      if ((rule as any).onInit) {\n        const output = (rule as any).onInit({\n          formControl,\n          form,\n          ...latestPropsRef.current,\n        });\n\n        if (output) {\n          subscriptions.push(output);\n        }\n      }\n    }\n\n    return () => {\n      subscriptions.forEach((subscription) => subscription?.unsubscribe());\n    };\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [form, formControl, rulesKey]);\n\n  const changeValue = (value: any, options: any) => {\n    formControl.change(value, {\n      ...options,\n      updateState: !formControl.isControlled,\n    });\n\n    onChange?.(value, {\n      ...options,\n      formControl,\n    });\n  };\n\n  /**\n   * Blur handler — marks the control touched and triggers validation when the\n   * resolved mode is `\"blur\"`.\n   */\n  const handleBlur = () => {\n    formControl.isTouched = true;\n\n    if (resolveValidateOn() === \"blur\") {\n      validateFormControl();\n    }\n  };\n\n  useEffect(() => {\n    if (!formControl.isControlled || formControl.rendered === false) return;\n\n    formControl.change(incomingValue);\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [incomingValue]);\n\n  useEffect(() => {\n    if (!formControl.isControlled || formControl.rendered === false) {\n      return;\n    }\n\n    formControl.checked = _checked;\n    formControl.isDirty = true;\n\n    setCheckedState(_checked as boolean);\n\n    if (shouldValidateOnChange()) {\n      validateFormControl();\n    }\n\n    // Consistent wrapper payload (see setChecked / change).\n    events.trigger(`form.control.${id}.change`, {\n      value: formControl.value,\n      checked: formControl.checked,\n      formControl,\n    });\n\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [_checked]);\n\n  useEffect(() => {\n    formControl.disable(Boolean(incomingDisabled));\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [incomingDisabled]);\n\n  useEffect(() => {\n    // Check if the form control is touched.\n    // This hook auto-binds a `focus` listener on the DOM input to mark the\n    // control as touched. On React Native there is no DOM, so we skip it —\n    // native inputs should set `formControl.isTouched = true` from their\n    // own `onFocus` handler if touched-state tracking is needed.\n    if (formControl.isTouched) return;\n    if (!isDomAvailable()) return;\n\n    const input: HTMLInputElement | undefined =\n      formControl.inputRef?.current || document.getElementById(formControl.id);\n\n    if (!input || typeof (input as any).addEventListener !== \"function\") return;\n\n    const updateTouchState = () => (formControl.isTouched = true);\n\n    input.addEventListener(\"focus\", updateTouchState);\n\n    return () => {\n      input.removeEventListener(\"focus\", updateTouchState);\n    };\n  }, [formControl]);\n\n  useEffect(() => {\n    // Keep the frozen formControl identity's name in sync with the latest\n    // (memoized) name. This is what makes `useFieldArray` reorders/removals\n    // carry each row's value: when a row's index shifts, its input name\n    // changes, this effect re-runs, and the control is re-registered under the\n    // new name while keeping its (persisted) value.\n    formControl.name = name;\n\n    // Mark as committed synchronously (post-commit) so the controlled-prop sync\n    // effects above — which run before this on mount and bail while\n    // `rendered === false` — proceed on subsequent updates.\n    formControl.rendered = true;\n\n    let resetEvent: EventSubscription | undefined;\n    if (form) {\n      form.register(formControl);\n      resetEvent = form.on(\"reset\", formControl.reset);\n    }\n\n    return () => {\n      // Abandon any in-flight async validation so its `.then` doesn't retain\n      // this (now unmounted) control's closure and won't setState after unmount.\n      formControl.cancelValidation();\n\n      if (form) {\n        form.unregister(formControl);\n      } else {\n        formControl.unregister();\n      }\n\n      resetEvent?.unsubscribe();\n    };\n  }, [form, formControl, name]);\n\n  // Stable signature of the rest props so `outputProps` keeps a stable identity\n  // across renders when the props are shallowly unchanged (the raw `props`\n  // object is a fresh literal every render, which would bust the memo).\n  const propsSignature = Object.keys(props)\n    .sort()\n    .map((key) => `${key}=${String((props as any)[key])}`)\n    .join(\"&\");\n\n  const outputProps = useMemo(() => {\n    let finalProps = { ...props };\n\n    const except = (props: any, keys: string[]) => {\n      const newProps = { ...props };\n      for (const key of keys) {\n        delete newProps[key];\n      }\n      return newProps;\n    };\n\n    for (const rule of rules) {\n      if (rule.preservedProps) {\n        finalProps = except(finalProps, rule.preservedProps);\n      }\n    }\n\n    return finalProps;\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [rulesKey, propsSignature]);\n\n  const getInputProps = (overrides: Record<string, any> = {}) => {\n    const isCheckable = [\"checkbox\", \"radio\"].includes(type);\n\n    const base: Record<string, any> = {\n      id,\n      name,\n      ref: inputRef,\n      disabled,\n      onBlur: handleBlur,\n      // Drive both ARIA attributes off the displayed `error` so they stay\n      // consistent: when an error is shown, the input is marked invalid AND\n      // points at the error node (was previously gated on `isTouched`, which\n      // left a submit-revealed error described but not marked invalid).\n      \"aria-invalid\": error ? true : undefined,\n      \"aria-required\": baseProps.required || undefined,\n      \"aria-describedby\": error ? errorId : undefined,\n    };\n\n    if (isCheckable) {\n      base.checked = Boolean(checked);\n      base.onChange = (e: any) =>\n        formControl.setChecked(e?.target ? e.target.checked : Boolean(e));\n    } else {\n      base.value = value ?? \"\";\n      base.onChange = (e: any) =>\n        changeValue(e?.target ? e.target.value : e, undefined);\n    }\n\n    return { ...base, ...outputProps, ...overrides };\n  };\n\n  const getErrorProps = () => ({\n    id: errorId,\n    role: \"alert\" as const,\n    \"aria-live\": \"polite\" as const,\n  });\n\n  const output: FormControlHook = {\n    id,\n    name,\n    value,\n    type,\n    error,\n    errorId,\n    setError,\n    inputRef,\n    visibleElementRef,\n    formControl,\n    validate: validateFormControl,\n    changeValue,\n    onBlur: handleBlur,\n    checked,\n    disabled,\n    isValidating,\n    errorsList: formControl.errorsList,\n    disable: formControl.disable.bind(formControl, true),\n    enable: formControl.disable.bind(formControl, false),\n    setChecked: formControl.setChecked.bind(formControl),\n    otherProps: outputProps,\n    getInputProps,\n    getErrorProps,\n    get isInvalid() {\n      return formControl.isTouched && formControl.isValid === false;\n    },\n  };\n\n  return output;\n}\n"],"mappings":";;;;;;;;;;AAoBA,MAAa,4BAA4B;CACvC,kBAAkB;CAClB,gBAAgB;CAChB,iBAAiB,OAAY,gBAA8B;EACzD,IAAI,aAAa,YAAY,CAAC,MAAM,QAAQ,KAAK,GAC/C,OAAO,CAAC,KAAK;EAGf,OAAO;CACT;AACF;;;;;AAMA,MAAM,sBAAsB,OAAO,qBAAqB;AAExD,MAAM,uBACJ,OAAO,aAAa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