@powerhousedao/powerhouse-vetra-packages 6.2.3-dev.11 → 6.2.3-dev.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/{chunk-CRPLlQ3x.js → chunk-BVTlhY3a.js} +1 -5
- package/dist/browser/{editor-BO_s5gTQ.js → editor-CQ4wUFK5.js} +3 -3
- package/dist/browser/{editor-BO_s5gTQ.js.map → editor-CQ4wUFK5.js.map} +1 -1
- package/dist/browser/editors/document-model-editor/module.js +1 -1
- package/dist/browser/editors/generic-drive-explorer/index.js +10 -4
- package/dist/browser/editors/generic-drive-explorer/index.js.map +1 -1
- package/dist/browser/{graphql-editor-BMhHl2XP.js → graphql-editor-DoXZvdNr.js} +2 -2
- package/dist/browser/{graphql-editor-BMhHl2XP.js.map → graphql-editor-DoXZvdNr.js.map} +1 -1
- package/dist/browser/{state-schemas-DuA5rB1e.js → state-schemas-B47wHvDV.js} +2 -2
- package/dist/browser/{state-schemas-DuA5rB1e.js.map → state-schemas-B47wHvDV.js.map} +1 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-BO_s5gTQ.js","names":["r","e","s","i","t","n","o","r","e","Label","React","React","LabelPrimitive.Root","React","zodResolver","compactButtonStyle"],"sources":["../../../../node_modules/.pnpm/clsx@2.0.0/node_modules/clsx/dist/clsx.mjs","../../../../node_modules/.pnpm/class-variance-authority@0.7.0/node_modules/class-variance-authority/dist/index.mjs","../../../../node_modules/.pnpm/react-hook-form@7.71.2_react@19.2.6/node_modules/react-hook-form/dist/index.esm.mjs","../../editors/document-model-editor/components/divider.tsx","../../../../node_modules/.pnpm/@hookform+resolvers@5.2.2_react-hook-form@7.71.2_react@19.2.6_/node_modules/@hookform/resolvers/dist/resolvers.mjs","../../../../node_modules/.pnpm/@hookform+resolvers@5.2.2_react-hook-form@7.71.2_react@19.2.6_/node_modules/@hookform/resolvers/zod/dist/zod.mjs","../../editors/document-model-editor/schemas/inputs.ts","../../editors/document-model-editor/context/form-context.ts","../../editors/document-model-editor/hooks/useFormField.ts","../../../../node_modules/.pnpm/@radix-ui+react-label@2.1.8_@types+react-dom@19.2.3_@types+react@19.2.14__@types+react@_8d35ec453e0b59eefe06771bb1432577/node_modules/@radix-ui/react-label/dist/index.mjs","../../editors/document-model-editor/components/label.tsx","../../editors/document-model-editor/components/form.tsx","../../editors/document-model-editor/components/text-area.tsx","../../editors/document-model-editor/components/text-field.tsx","../../editors/document-model-editor/components/model-metadata-form.tsx","../../editors/document-model-editor/components/module-form.tsx","../../editors/document-model-editor/components/operation-form.tsx","../../editors/document-model-editor/components/operation-description-form.tsx","../../editors/document-model-editor/components/operation-error-form.tsx","../../editors/document-model-editor/components/operation-errors.tsx","../../editors/document-model-editor/components/operation.tsx","../../editors/document-model-editor/components/operations.tsx","../../editors/document-model-editor/components/module.tsx","../../editors/document-model-editor/components/modules.tsx","../../editors/document-model-editor/components/version-controls.tsx","../../editors/document-model-editor/components/version-advisory-modal.tsx","../../editors/document-model-editor/config.ts","../../editors/document-model-editor/hooks/useDocumentModelDocument.ts","../../editors/document-model-editor/utils/change-classification.ts","../../editors/document-model-editor/hooks/useVersionAdvisory.ts","../../editors/document-model-editor/editor.tsx"],"sourcesContent":["function r(e){var t,f,n=\"\";if(\"string\"==typeof e||\"number\"==typeof e)n+=e;else if(\"object\"==typeof e)if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=\" \"),n+=f);else for(t in e)e[t]&&(n&&(n+=\" \"),n+=t);return n}export function clsx(){for(var e,t,f=0,n=\"\";f<arguments.length;)(e=arguments[f++])&&(t=r(e))&&(n&&(n+=\" \"),n+=t);return n}export default clsx;","import { clsx } from \"clsx\";\nconst falsyToString = (value)=>typeof value === \"boolean\" ? \"\".concat(value) : value === 0 ? \"0\" : value;\nexport const cx = clsx;\nexport const cva = (base, config)=>{\n return (props)=>{\n var ref;\n if ((config === null || config === void 0 ? void 0 : config.variants) == null) return cx(base, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);\n const { variants , defaultVariants } = config;\n const getVariantClassNames = Object.keys(variants).map((variant)=>{\n const variantProp = props === null || props === void 0 ? void 0 : props[variant];\n const defaultVariantProp = defaultVariants === null || defaultVariants === void 0 ? void 0 : defaultVariants[variant];\n if (variantProp === null) return null;\n const variantKey = falsyToString(variantProp) || falsyToString(defaultVariantProp);\n return variants[variant][variantKey];\n });\n const propsWithoutUndefined = props && Object.entries(props).reduce((acc, param)=>{\n let [key, value] = param;\n if (value === undefined) {\n return acc;\n }\n acc[key] = value;\n return acc;\n }, {});\n const getCompoundVariantClassNames = config === null || config === void 0 ? void 0 : (ref = config.compoundVariants) === null || ref === void 0 ? void 0 : ref.reduce((acc, param1)=>{\n let { class: cvClass , className: cvClassName , ...compoundVariantOptions } = param1;\n return Object.entries(compoundVariantOptions).every((param)=>{\n let [key, value] = param;\n return Array.isArray(value) ? value.includes({\n ...defaultVariants,\n ...propsWithoutUndefined\n }[key]) : ({\n ...defaultVariants,\n ...propsWithoutUndefined\n })[key] === value;\n }) ? [\n ...acc,\n cvClass,\n cvClassName\n ] : acc;\n }, []);\n return cx(base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);\n };\n};\n\n\n//# sourceMappingURL=index.mjs.map","import React from 'react';\n\nvar isCheckBoxInput = (element) => element.type === 'checkbox';\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 : event.target.value\n : event;\n\nvar getNodeParentName = (name) => name.substring(0, name.search(/\\.\\d+(\\.|$)/)) || name;\n\nvar isNameInFieldArray = (names, name) => names.has(getNodeParentName(name));\n\nvar isPlainObject = (tempObject) => {\n const prototypeCopy = tempObject.constructor && tempObject.constructor.prototype;\n return (isObject(prototypeCopy) && prototypeCopy.hasOwnProperty('isPrototypeOf'));\n};\n\nvar isWeb = typeof window !== 'undefined' &&\n typeof window.HTMLElement !== 'undefined' &&\n typeof document !== 'undefined';\n\nfunction cloneObject(data) {\n if (data instanceof Date) {\n return new Date(data);\n }\n const isFileListInstance = typeof FileList !== 'undefined' && data instanceof FileList;\n if (isWeb && (data instanceof Blob || isFileListInstance)) {\n return data;\n }\n const isArray = Array.isArray(data);\n if (!isArray && !(isObject(data) && isPlainObject(data))) {\n return data;\n }\n const copy = isArray ? [] : Object.create(Object.getPrototypeOf(data));\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\nvar isKey = (value) => /^\\w*$/.test(value);\n\nvar isUndefined = (val) => val === undefined;\n\nvar compact = (value) => Array.isArray(value) ? value.filter(Boolean) : [];\n\nvar stringToPath = (input) => compact(input.replace(/[\"|']|\\]/g, '').split(/\\.|\\[/));\n\nvar get = (object, path, defaultValue) => {\n if (!path || !isObject(object)) {\n return defaultValue;\n }\n const result = (isKey(path) ? [path] : stringToPath(path)).reduce((result, key) => isNullOrUndefined(result) ? result : result[key], 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 (key === '__proto__' || key === 'constructor' || key === 'prototype') {\n return;\n }\n object[key] = newValue;\n object = object[key];\n }\n};\n\nconst EVENTS = {\n BLUR: 'blur',\n FOCUS_OUT: 'focusout',\n CHANGE: 'change',\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};\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 defaultValues: control._defaultValues,\n };\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 = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;\n\n/**\n * This custom hook allows you to subscribe to each form state, and isolate the re-render at the custom hook level. It has its scope in terms of form state subscription, so it would not affect other useFormState and useForm. Using this hook can reduce the re-render impact on large and complex form application.\n *\n * @remarks\n * [API](https://react-hook-form.com/docs/useformstate) • [Demo](https://codesandbox.io/s/useformstate-75xly)\n *\n * @param props - include options on specify fields to subscribe. {@link UseFormStateReturn}\n *\n * @example\n * ```tsx\n * function App() {\n * const { register, handleSubmit, control } = useForm({\n * defaultValues: {\n * firstName: \"firstName\"\n * }});\n * const { dirtyFields } = useFormState({\n * control\n * });\n * const onSubmit = (data) => console.log(data);\n *\n * return (\n * <form onSubmit={handleSubmit(onSubmit)}>\n * <input {...register(\"firstName\")} placeholder=\"First Name\" />\n * {dirtyFields.firstName && <p>Field is dirty.</p>}\n * <input type=\"submit\" />\n * </form>\n * );\n * }\n * ```\n */\nfunction useFormState(props) {\n const formControl = useFormControlContext();\n const { control = formControl, disabled, name, exact } = props || {};\n const [formState, updateFormState] = React.useState(control._formState);\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 useIsomorphicLayoutEffect(() => control._subscribe({\n name,\n formState: _localProxyFormState.current,\n exact,\n callback: (formState) => {\n !disabled &&\n updateFormState({\n ...control._formState,\n ...formState,\n });\n },\n }), [name, disabled, exact]);\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)));\n }\n isGlobal && (_names.watchAll = true);\n return formValues;\n};\n\nvar isPrimitive = (value) => isNullOrUndefined(value) || !isObjectType(value);\n\nfunction deepEqual(object1, object2, _internal_visited = new WeakSet()) {\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 const keys1 = Object.keys(object1);\n const keys2 = Object.keys(object2);\n if (keys1.length !== keys2.length) {\n return false;\n }\n if (_internal_visited.has(object1) || _internal_visited.has(object2)) {\n return true;\n }\n _internal_visited.add(object1);\n _internal_visited.add(object2);\n for (const key of keys1) {\n const val1 = object1[key];\n if (!keys2.includes(key)) {\n return false;\n }\n if (key !== 'ref') {\n const val2 = object2[key];\n if ((isDateObject(val1) && isDateObject(val2)) ||\n (isObject(val1) && isObject(val2)) ||\n (Array.isArray(val1) && Array.isArray(val2))\n ? !deepEqual(val1, val2, _internal_visited)\n : !Object.is(val1, val2)) {\n return false;\n }\n }\n }\n return true;\n}\n\n/**\n * Custom hook to subscribe to field change and isolate re-rendering at the component level.\n *\n * @remarks\n *\n * [API](https://react-hook-form.com/docs/usewatch) • [Demo](https://codesandbox.io/s/react-hook-form-v7-ts-usewatch-h9i5e)\n *\n * @example\n * ```tsx\n * const { control } = useForm();\n * const values = useWatch({\n * name: \"fieldName\"\n * control,\n * })\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 _computeFormValues = React.useRef(undefined);\n const _prevControl = React.useRef(control);\n const _prevName = React.useRef(name);\n _compute.current = compute;\n const [value, updateValue] = React.useState(() => {\n const defaultValue = control._getWatch(name, _defaultValue.current);\n return _compute.current ? _compute.current(defaultValue) : defaultValue;\n });\n const getCurrentOutput = React.useCallback((values) => {\n const formValues = generateWatchOutput(name, control._names, values || control._formValues, false, _defaultValue.current);\n return _compute.current ? _compute.current(formValues) : 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 useIsomorphicLayoutEffect(() => {\n if (_prevControl.current !== control ||\n !deepEqual(_prevName.current, name)) {\n _prevControl.current = control;\n _prevName.current = name;\n refreshValue();\n }\n return control._subscribe({\n name,\n formState: {\n values: true,\n },\n exact,\n callback: (formState) => {\n refreshValue(formState.values);\n },\n });\n }, [control, exact, name, refreshValue]);\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 // Cache the computed output to avoid duplicate calls within the same render\n // We include shouldReturnImmediate in deps to ensure proper recomputation\n const computedOutput = React.useMemo(() => {\n if (disabled) {\n return null;\n }\n const nameChanged = !controlChanged && !deepEqual(prevName, name);\n const shouldReturnImmediate = controlChanged || nameChanged;\n return shouldReturnImmediate ? getCurrentOutput() : null;\n }, [disabled, controlChanged, name, prevName, getCurrentOutput]);\n return computedOutput !== null ? computedOutput : value;\n}\n\n/**\n * Custom hook to work with controlled component, this function provide you with both form and field level state. Re-render is isolated at the hook level.\n *\n * @remarks\n * [API](https://react-hook-form.com/docs/usecontroller) • [Demo](https://codesandbox.io/s/usecontroller-0o8px)\n *\n * @param props - the path name to the form field value, and validation rules.\n *\n * @returns field properties, field and form state. {@link UseControllerReturn}\n *\n * @example\n * ```tsx\n * function Input(props) {\n * const { field, fieldState, formState } = useController(props);\n * return (\n * <div>\n * <input {...field} placeholder={props.name} />\n * <p>{fieldState.isTouched && \"Touched\"}</p>\n * <p>{formState.isSubmitted ? \"submitted\" : \"\"}</p>\n * </div>\n * );\n * }\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(() => get(control._formValues, name, get(control._defaultValues, name, defaultValue)), [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 _previousNameRef = React.useRef(undefined);\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) => _registerProps.current.onChange({\n target: {\n value: getEventValue(event),\n name: name,\n },\n type: EVENTS.CHANGE,\n }), [name]);\n const onBlur = React.useCallback(() => _registerProps.current.onBlur({\n target: {\n value: get(control._formValues, name),\n name: name,\n },\n type: EVENTS.BLUR,\n }), [name, control._formValues]);\n const ref = React.useCallback((elm) => {\n const field = get(control._fields, name);\n if (field && field._f && elm) {\n field._f.ref = {\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 }, [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 const previousName = _previousNameRef.current;\n if (previousName && previousName !== name && !isArrayField) {\n control.unregister(previousName);\n }\n 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 }\n };\n updateMounted(name, true);\n if (_shouldUnregisterField) {\n const value = cloneObject(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 && control.register(name);\n _previousNameRef.current = name;\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 based on `useController` hook to work with controlled component.\n *\n * @remarks\n * [API](https://react-hook-form.com/docs/usecontroller/controller) • [Demo](https://codesandbox.io/s/react-hook-form-v6-controller-ts-jwyzw) • [Video](https://www.youtube.com/watch?v=N2UNk_UCVyA)\n *\n * @param props - the path name to the form field value, and validation rules.\n *\n * @returns provide field handler functions, field and form state.\n *\n * @example\n * ```tsx\n * function App() {\n * const { control } = useForm<FormValues>({\n * defaultValues: {\n * test: \"\"\n * }\n * });\n *\n * return (\n * <form>\n * <Controller\n * control={control}\n * name=\"test\"\n * render={({ field: { onChange, onBlur, value, ref }, formState, fieldState }) => (\n * <>\n * <input\n * onChange={onChange} // send value to hook form\n * onBlur={onBlur} // notify when input is touched\n * value={value} // return updated value\n * ref={ref} // set ref for focus management\n * />\n * <p>{formState.isSubmitted ? \"submitted\" : \"\"}</p>\n * <p>{fieldState.isTouched ? \"touched\" : \"\"}</p>\n * </>\n * )}\n * />\n * </form>\n * );\n * }\n * ```\n */\nconst Controller = (props) => props.render(useController(props));\n\nconst flatten = (obj) => {\n const output = {};\n for (const key of Object.keys(obj)) {\n if (isObjectType(obj[key]) && obj[key] !== null) {\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\nconst HookFormContext = React.createContext(null);\nHookFormContext.displayName = 'HookFormContext';\n/**\n * This custom hook allows you to access the form context. useFormContext is intended to be used in deeply nested structures, where it would become inconvenient to pass the context as a prop. To be used with {@link FormProvider}.\n *\n * @remarks\n * [API](https://react-hook-form.com/docs/useformcontext) • [Demo](https://codesandbox.io/s/react-hook-form-v7-form-context-ytudi)\n *\n * @returns return all useForm methods\n *\n * @example\n * ```tsx\n * function App() {\n * const methods = useForm();\n * const onSubmit = data => console.log(data);\n *\n * return (\n * <FormProvider {...methods} >\n * <form onSubmit={methods.handleSubmit(onSubmit)}>\n * <NestedInput />\n * <input type=\"submit\" />\n * </form>\n * </FormProvider>\n * );\n * }\n *\n * function NestedInput() {\n * const { register } = useFormContext(); // retrieve all hook methods\n * return <input {...register(\"test\")} />;\n * }\n * ```\n */\nconst useFormContext = () => React.useContext(HookFormContext);\n/**\n * A provider component that propagates the `useForm` methods to all children components via [React Context](https://react.dev/reference/react/useContext) API. To be used with {@link useFormContext}.\n *\n * @remarks\n * [API](https://react-hook-form.com/docs/useformcontext) • [Demo](https://codesandbox.io/s/react-hook-form-v7-form-context-ytudi)\n *\n * @param props - all useForm methods\n *\n * @example\n * ```tsx\n * function App() {\n * const methods = useForm();\n * const onSubmit = data => console.log(data);\n *\n * return (\n * <FormProvider {...methods} >\n * <form onSubmit={methods.handleSubmit(onSubmit)}>\n * <NestedInput />\n * <input type=\"submit\" />\n * </form>\n * </FormProvider>\n * );\n * }\n *\n * function NestedInput() {\n * const { register } = useFormContext(); // retrieve all hook methods\n * return <input {...register(\"test\")} />;\n * }\n * ```\n */\nconst FormProvider = (props) => {\n const { children, watch, getValues, getFieldState, setError, clearErrors, setValue, trigger, formState, resetField, reset, handleSubmit, unregister, control, register, setFocus, subscribe, } = props;\n return (React.createElement(HookFormContext.Provider, { value: React.useMemo(() => ({\n watch,\n getValues,\n getFieldState,\n setError,\n clearErrors,\n setValue,\n trigger,\n formState,\n resetField,\n reset,\n handleSubmit,\n unregister,\n control,\n register,\n setFocus,\n subscribe,\n }), [\n clearErrors,\n control,\n formState,\n getFieldState,\n getValues,\n handleSubmit,\n register,\n reset,\n resetField,\n setError,\n setFocus,\n setValue,\n subscribe,\n trigger,\n unregister,\n watch,\n ]) },\n React.createElement(HookFormControlContext.Provider, { value: control }, children)));\n};\n\nconst POST_REQUEST = 'post';\n/**\n * Form component to manage submission.\n *\n * @param props - to setup submission detail. {@link FormProps}\n *\n * @returns form component or headless render prop.\n *\n * @example\n * ```tsx\n * function App() {\n * const { control, formState: { errors } } = useForm();\n *\n * return (\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 * }\n * ```\n */\nfunction Form(props) {\n const methods = useFormContext();\n const [mounted, setMounted] = React.useState(false);\n const { control = methods.control, onSubmit, children, action, method = POST_REQUEST, headers, encType, onError, render, onSuccess, validateStatus, ...rest } = props;\n const submit = async (event) => {\n let hasError = false;\n let type = '';\n await control.handleSubmit(async (data) => {\n const formData = new FormData();\n let formDataJson = '';\n try {\n formDataJson = JSON.stringify(data);\n }\n catch (_a) { }\n const flattenFormValues = flatten(control._formValues);\n for (const key in flattenFormValues) {\n formData.append(key, flattenFormValues[key]);\n }\n if (onSubmit) {\n await onSubmit({\n data,\n event,\n method,\n formData,\n formDataJson,\n });\n }\n if (action) {\n try {\n const shouldStringifySubmissionData = [\n headers && headers['Content-Type'],\n encType,\n ].some((value) => value && value.includes('json'));\n const response = await fetch(String(action), {\n method,\n headers: {\n ...headers,\n ...(encType && encType !== 'multipart/form-data'\n ? { 'Content-Type': encType }\n : {}),\n },\n body: shouldStringifySubmissionData ? formDataJson : formData,\n });\n if (response &&\n (validateStatus\n ? !validateStatus(response.status)\n : response.status < 200 || response.status >= 300)) {\n hasError = true;\n onError && onError({ response });\n type = String(response.status);\n }\n else {\n onSuccess && onSuccess({ response });\n }\n }\n catch (error) {\n hasError = true;\n onError && onError({ error });\n }\n }\n })(event);\n if (hasError && props.control) {\n props.control._subjects.state.next({\n isSubmitSuccessful: false,\n });\n props.control.setError('root.server', {\n type,\n });\n }\n };\n React.useEffect(() => {\n setMounted(true);\n }, []);\n return render ? (React.createElement(React.Fragment, null, render({\n submit,\n }))) : (React.createElement(\"form\", { noValidate: mounted, action: action, method: method, encType: encType, onSubmit: submit, ...rest }, children));\n}\n\nconst FormStateSubscribe = ({ control, disabled, exact, name, render, }) => render(useFormState({ control, name, disabled, exact }));\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\nvar convertToArrayPayload = (value) => (Array.isArray(value) ? value : [value]);\n\nvar createSubject = () => {\n let _observers = [];\n const next = (value) => {\n for (const observer of _observers) {\n observer.next && observer.next(value);\n }\n };\n const subscribe = (observer) => {\n _observers.push(observer);\n return {\n unsubscribe: () => {\n _observers = _observers.filter((o) => o !== observer);\n },\n };\n };\n const unsubscribe = () => {\n _observers = [];\n };\n return {\n get observers() {\n return _observers;\n },\n next,\n subscribe,\n unsubscribe,\n };\n};\n\nfunction extractFormValues(fieldsState, formValues) {\n const values = {};\n for (const key in fieldsState) {\n if (fieldsState.hasOwnProperty(key)) {\n const fieldState = fieldsState[key];\n const fieldValue = formValues[key];\n if (fieldState && isObject(fieldState) && fieldValue) {\n const nestedFieldsState = extractFormValues(fieldState, fieldValue);\n if (isObject(nestedFieldsState)) {\n values[key] = nestedFieldsState;\n }\n }\n else if (fieldsState[key]) {\n values[key] = fieldValue;\n }\n }\n }\n return values;\n}\n\nvar isEmptyObject = (value) => isObject(value) && !Object.keys(value).length;\n\nvar isFileInput = (element) => element.type === 'file';\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 isMultipleSelect = (element) => element.type === `select-multiple`;\n\nvar isRadioInput = (element) => element.type === 'radio';\n\nvar isRadioOrCheckbox = (ref) => isRadioInput(ref) || isCheckBoxInput(ref);\n\nvar live = (ref) => isHTMLElement(ref) && ref.isConnected;\n\nfunction baseGet(object, updatePath) {\n const length = updatePath.slice(0, -1).length;\n let index = 0;\n while (index < length) {\n object = isUndefined(object) ? index++ : object[updatePath[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 const paths = Array.isArray(path)\n ? path\n : isKey(path)\n ? [path]\n : stringToPath(path);\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 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 markFieldsDirty(data, fields = {}) {\n for (const key in data) {\n const value = data[key];\n if (isTraversable(value)) {\n fields[key] = Array.isArray(value) ? [] : {};\n markFieldsDirty(value, fields[key]);\n }\n else if (!isUndefined(value)) {\n fields[key] = true;\n }\n }\n return fields;\n}\nfunction getDirtyFields(data, formValues, dirtyFieldsFromValues) {\n if (!dirtyFieldsFromValues) {\n dirtyFieldsFromValues = markFieldsDirty(formValues);\n }\n for (const key in data) {\n const value = data[key];\n if (isTraversable(value)) {\n if (isUndefined(formValues) || isPrimitive(dirtyFieldsFromValues[key])) {\n dirtyFieldsFromValues[key] = markFieldsDirty(value, Array.isArray(value) ? [] : {});\n }\n else {\n getDirtyFields(value, isNullOrUndefined(formValues) ? {} : formValues[key], dirtyFieldsFromValues[key]);\n }\n }\n else {\n const formValue = formValues[key];\n dirtyFieldsFromValues[key] = !deepEqual(value, formValue);\n }\n }\n return dirtyFieldsFromValues;\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 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 return options[0].checked && !options[0].disabled\n ? // @ts-expect-error expected to work in the browser\n options[0].attributes && !isUndefined(options[0].attributes.value)\n ? isUndefined(options[0].value) || options[0].value === ''\n ? validResult\n : { value: options[0].value, isValid: true }\n : validResult\n : defaultResult;\n }\n return defaultResult;\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\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 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(isUndefined(ref.value) ? _f.ref.value : 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 isRegex = (value) => value instanceof RegExp;\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\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\nconst ASYNC_FUNCTION = 'AsyncFunction';\nvar hasPromiseValidation = (fieldReference) => !!fieldReference &&\n !!fieldReference.validate &&\n !!((isFunction(fieldReference.validate) &&\n fieldReference.validate.constructor.name === ASYNC_FUNCTION) ||\n (isObject(fieldReference.validate) &&\n Object.values(fieldReference.validate).find((validateFunction) => validateFunction.constructor.name === ASYNC_FUNCTION)));\n\nvar hasValidation = (options) => options.mount &&\n (options.required ||\n options.min ||\n options.max ||\n options.maxLength ||\n options.minLength ||\n options.pattern ||\n options.validate);\n\nvar isWatched = (name, _names, isBlurEvent) => !isBlurEvent &&\n (_names.watchAll ||\n _names.watch.has(name) ||\n [..._names.watch].some((watchName) => name.startsWith(watchName) &&\n /^\\.\\w+/.test(name.slice(watchName.length))));\n\nconst iterateFieldsByAction = (fields, action, fieldsNames, abortEarly) => {\n for (const key of fieldsNames || Object.keys(fields)) {\n const field = get(fields, key);\n if (field) {\n const { _f, ...currentField } = field;\n if (_f) {\n if (_f.refs && _f.refs[0] && action(_f.refs[0], key) && !abortEarly) {\n return true;\n }\n else if (_f.ref && action(_f.ref, _f.name) && !abortEarly) {\n return true;\n }\n else {\n if (iterateFieldsByAction(currentField, action)) {\n break;\n }\n }\n }\n else if (isObject(currentField)) {\n if (iterateFieldsByAction(currentField, action)) {\n break;\n }\n }\n }\n }\n return;\n};\n\nfunction schemaErrorLookup(errors, _fields, name) {\n const error = get(errors, name);\n if (error || isKey(name)) {\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, updateFormState, isRoot) => {\n updateFormState(formStateData);\n const { name, ...formState } = formStateData;\n return (isEmptyObject(formState) ||\n Object.keys(formState).length >= Object.keys(_proxyFormState).length ||\n Object.keys(formState).find((key) => _proxyFormState[key] ===\n (!isRoot || VALIDATION_MODE.all)));\n};\n\nvar shouldSubscribeByName = (name, signalName, exact) => !name ||\n !signalName ||\n name === signalName ||\n convertToArrayPayload(name).some((currentName) => currentName &&\n (exact\n ? currentName === signalName\n : currentName.startsWith(signalName) ||\n signalName.startsWith(currentName)));\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) => !compact(get(ref, name)).length && unset(ref, name);\n\nvar updateFieldArrayRootError = (errors, error, name) => {\n const fieldArrayErrors = convertToArrayPayload(get(errors, name));\n set(fieldArrayErrors, 'root', error[name]);\n set(errors, name, fieldArrayErrors);\n return errors;\n};\n\nfunction getValidateError(result, ref, type = 'validate') {\n if (isString(result) ||\n (Array.isArray(result) && 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, } = 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 inputRef.setCustomValidity(isBoolean(message) ? '' : message || '');\n inputRef.reportValidity();\n }\n };\n const error = {};\n const isRadio = isRadioInput(ref);\n const isCheckBox = 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 === '') ||\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) && !isNaN(inputValue)) {\n const valueNumber = 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 = ref.valueAsDate || 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 ((maxLength || 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 setCustomValidity(validateError.message);\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 setCustomValidity(true);\n return error;\n};\n\nconst defaultOptions = {\n mode: VALIDATION_MODE.onSubmit,\n reValidateMode: VALIDATION_MODE.onChange,\n shouldFocusError: true,\n};\nfunction createFormControl(props = {}) {\n let _options = {\n ...defaultOptions,\n ...props,\n };\n let _formState = {\n submitCount: 0,\n isDirty: false,\n isReady: false,\n isLoading: isFunction(_options.defaultValues),\n isValidating: false,\n isSubmitted: false,\n isSubmitting: false,\n isSubmitSuccessful: false,\n isValid: false,\n touchedFields: {},\n dirtyFields: {},\n validatingFields: {},\n errors: _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 mount: false,\n watch: false,\n keepIsValid: false,\n };\n let _names = {\n mount: new Set(),\n disabled: new Set(),\n unMount: new Set(),\n array: new Set(),\n watch: new Set(),\n };\n let delayErrorCallback;\n let timer = 0;\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 let _proxySubscribeFormState = {\n ..._proxyFormState,\n };\n const _subjects = {\n array: createSubject(),\n state: createSubject(),\n };\n const shouldDisplayAllAssociatedErrors = _options.criteriaMode === VALIDATION_MODE.all;\n const debounce = (callback) => (wait) => {\n clearTimeout(timer);\n timer = setTimeout(callback, wait);\n };\n const _setValid = async (shouldUpdateValid) => {\n if (_state.keepIsValid) {\n return;\n }\n if (!_options.disabled &&\n (_proxyFormState.isValid ||\n _proxySubscribeFormState.isValid ||\n shouldUpdateValid)) {\n let isValid;\n if (_options.resolver) {\n isValid = isEmptyObject((await _runSchema()).errors);\n _updateIsValidating();\n }\n else {\n isValid = await executeBuiltInValidation(_fields, true);\n }\n if (isValid !== _formState.isValid) {\n _subjects.state.next({\n isValid,\n });\n }\n }\n };\n const _updateIsValidating = (names, isValidating) => {\n if (!_options.disabled &&\n (_proxyFormState.isValidating ||\n _proxyFormState.validatingFields ||\n _proxySubscribeFormState.isValidating ||\n _proxySubscribeFormState.validatingFields)) {\n (names || Array.from(_names.mount)).forEach((name) => {\n if (name) {\n isValidating\n ? set(_formState.validatingFields, name, isValidating)\n : unset(_formState.validatingFields, name);\n }\n });\n _subjects.state.next({\n validatingFields: _formState.validatingFields,\n isValidating: !isEmptyObject(_formState.validatingFields),\n });\n }\n };\n const _setFieldArray = (name, values = [], method, args, shouldSetValues = true, shouldUpdateFieldsAndState = true) => {\n if (args && method && !_options.disabled) {\n _state.action = true;\n if (shouldUpdateFieldsAndState && Array.isArray(get(_fields, name))) {\n const fieldValues = method(get(_fields, name), args.argA, args.argB);\n shouldSetValues && set(_fields, name, fieldValues);\n }\n if (shouldUpdateFieldsAndState &&\n Array.isArray(get(_formState.errors, name))) {\n const errors = method(get(_formState.errors, name), args.argA, args.argB);\n shouldSetValues && set(_formState.errors, name, errors);\n unsetEmptyArray(_formState.errors, name);\n }\n if ((_proxyFormState.touchedFields ||\n _proxySubscribeFormState.touchedFields) &&\n shouldUpdateFieldsAndState &&\n Array.isArray(get(_formState.touchedFields, name))) {\n const touchedFields = method(get(_formState.touchedFields, name), args.argA, args.argB);\n shouldSetValues && set(_formState.touchedFields, name, touchedFields);\n }\n if (_proxyFormState.dirtyFields || _proxySubscribeFormState.dirtyFields) {\n _formState.dirtyFields = getDirtyFields(_defaultValues, _formValues);\n }\n _subjects.state.next({\n name,\n isDirty: _getDirty(name, values),\n dirtyFields: _formState.dirtyFields,\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 _subjects.state.next({\n errors: _formState.errors,\n });\n };\n const _setErrors = (errors) => {\n _formState.errors = errors;\n _subjects.state.next({\n errors: _formState.errors,\n isValid: false,\n });\n };\n const updateValidAndValue = (name, shouldSkipSetValueAs, value, ref) => {\n const field = get(_fields, name);\n if (field) {\n const defaultValue = get(_formValues, name, isUndefined(value) ? get(_defaultValues, name) : value);\n isUndefined(defaultValue) ||\n (ref && ref.defaultChecked) ||\n shouldSkipSetValueAs\n ? set(_formValues, name, shouldSkipSetValueAs ? defaultValue : getFieldValue(field._f))\n : setFieldValue(name, defaultValue);\n _state.mount && !_state.action && _setValid();\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) {\n if (!isBlurEvent || shouldDirty) {\n if (_proxyFormState.isDirty || _proxySubscribeFormState.isDirty) {\n isPreviousDirty = _formState.isDirty;\n _formState.isDirty = output.isDirty = _getDirty();\n shouldUpdateField = isPreviousDirty !== output.isDirty;\n }\n const isCurrentFieldPristine = deepEqual(get(_defaultValues, name), fieldValue);\n isPreviousDirty = !!get(_formState.dirtyFields, name);\n isCurrentFieldPristine\n ? unset(_formState.dirtyFields, name)\n : set(_formState.dirtyFields, name, true);\n output.dirtyFields = _formState.dirtyFields;\n shouldUpdateField =\n shouldUpdateField ||\n ((_proxyFormState.dirtyFields ||\n _proxySubscribeFormState.dirtyFields) &&\n isPreviousDirty !== !isCurrentFieldPristine);\n }\n if (isBlurEvent) {\n const isPreviousFieldTouched = get(_formState.touchedFields, name);\n if (!isPreviousFieldTouched) {\n set(_formState.touchedFields, name, isBlurEvent);\n output.touchedFields = _formState.touchedFields;\n shouldUpdateField =\n shouldUpdateField ||\n ((_proxyFormState.touchedFields ||\n _proxySubscribeFormState.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 = (_proxyFormState.isValid || _proxySubscribeFormState.isValid) &&\n isBoolean(isValid) &&\n _formState.isValid !== isValid;\n if (_options.delayError && error) {\n delayErrorCallback = debounce(() => updateErrors(name, error));\n delayErrorCallback(_options.delayError);\n }\n else {\n clearTimeout(timer);\n delayErrorCallback = null;\n error\n ? set(_formState.errors, name, error)\n : unset(_formState.errors, name);\n }\n if ((error ? !deepEqual(previousFieldError, error) : previousFieldError) ||\n !isEmptyObject(fieldState) ||\n shouldUpdateValid) {\n const updatedFormState = {\n ...fieldState,\n ...(shouldUpdateValid && isBoolean(isValid) ? { isValid } : {}),\n errors: _formState.errors,\n name,\n };\n _formState = {\n ..._formState,\n ...updatedFormState,\n };\n _subjects.state.next(updatedFormState);\n }\n };\n const _runSchema = async (name) => {\n _updateIsValidating(name, true);\n const result = await _options.resolver(_formValues, _options.context, getResolverOptions(name || _names.mount, _fields, _options.criteriaMode, _options.shouldUseNativeValidation));\n return result;\n };\n const executeSchemaAndUpdateState = async (names) => {\n const { errors } = await _runSchema(names);\n _updateIsValidating(names);\n if (names) {\n for (const name of names) {\n const error = get(errors, name);\n error\n ? set(_formState.errors, name, error)\n : unset(_formState.errors, name);\n }\n }\n else {\n _formState.errors = errors;\n }\n return errors;\n };\n const executeBuiltInValidation = async (fields, shouldOnlyCheckValid, context = {\n valid: true,\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 if (isPromiseFunction && _proxyFormState.validatingFields) {\n _updateIsValidating([_f.name], true);\n }\n const fieldError = await validateField(field, _names.disabled, _formValues, shouldDisplayAllAssociatedErrors, _options.shouldUseNativeValidation && !shouldOnlyCheckValid, isFieldArrayRoot);\n if (isPromiseFunction && _proxyFormState.validatingFields) {\n _updateIsValidating([_f.name]);\n }\n if (fieldError[_f.name]) {\n context.valid = false;\n if (shouldOnlyCheckValid || props.shouldUseNativeValidation) {\n break;\n }\n }\n !shouldOnlyCheckValid &&\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 !isEmptyObject(fieldValue) &&\n (await executeBuiltInValidation(fieldValue, shouldOnlyCheckValid, context));\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) => !_options.disabled &&\n (name && data && set(_formValues, name, data),\n !deepEqual(getValues(), _defaultValues));\n const _getWatch = (names, defaultValue, isGlobal) => generateWatchOutput(names, _names, {\n ...(_state.mount\n ? _formValues\n : isUndefined(defaultValue)\n ? _defaultValues\n : isString(names)\n ? { [names]: defaultValue }\n : defaultValue),\n }, isGlobal, defaultValue);\n const _getFieldArray = (name) => compact(get(_state.mount ? _formValues : _defaultValues, name, _options.shouldUnregister ? get(_defaultValues, name, []) : []));\n const setFieldValue = (name, value, options = {}) => {\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) {\n _subjects.state.next({\n name,\n values: cloneObject(_formValues),\n });\n }\n }\n }\n }\n (options.shouldDirty || options.shouldTouch) &&\n updateTouchAndDirty(name, fieldValue, options.shouldTouch, options.shouldDirty, true);\n options.shouldValidate && trigger(name);\n };\n const setValues = (name, value, options) => {\n for (const fieldKey in value) {\n if (!value.hasOwnProperty(fieldKey)) {\n return;\n }\n const fieldValue = value[fieldKey];\n const fieldName = name + '.' + fieldKey;\n const field = get(_fields, fieldName);\n (_names.array.has(name) ||\n isObject(fieldValue) ||\n (field && !field._f)) &&\n !isDateObject(fieldValue)\n ? setValues(fieldName, fieldValue, options)\n : setFieldValue(fieldName, fieldValue, options);\n }\n };\n const setValue = (name, value, options = {}) => {\n const field = get(_fields, name);\n const isFieldArray = _names.array.has(name);\n const cloneValue = cloneObject(value);\n set(_formValues, name, cloneValue);\n if (isFieldArray) {\n _subjects.array.next({\n name,\n values: cloneObject(_formValues),\n });\n if ((_proxyFormState.isDirty ||\n _proxyFormState.dirtyFields ||\n _proxySubscribeFormState.isDirty ||\n _proxySubscribeFormState.dirtyFields) &&\n options.shouldDirty) {\n _subjects.state.next({\n name,\n dirtyFields: getDirtyFields(_defaultValues, _formValues),\n isDirty: _getDirty(name, cloneValue),\n });\n }\n }\n else {\n field && !field._f && !isNullOrUndefined(cloneValue)\n ? setValues(name, cloneValue, options)\n : setFieldValue(name, cloneValue, options);\n }\n if (isWatched(name, _names)) {\n _subjects.state.next({\n ..._formState,\n name,\n values: cloneObject(_formValues),\n });\n }\n else {\n _subjects.state.next({\n name: _state.mount ? name : undefined,\n values: cloneObject(_formValues),\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 _updateIsFieldValueUpdated = (fieldValue) => {\n isFieldValueUpdated =\n Number.isNaN(fieldValue) ||\n (isDateObject(fieldValue) && isNaN(fieldValue.getTime())) ||\n deepEqual(fieldValue, get(_formValues, name, fieldValue));\n };\n const validationModeBeforeSubmit = getValidationModes(_options.mode);\n const validationModeAfterSubmit = getValidationModes(_options.reValidateMode);\n if (field) {\n let error;\n let isValid;\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 shouldSkipValidation = (!hasValidation(field._f) &&\n !_options.resolver &&\n !get(_formState.errors, name) &&\n !field._f.deps) ||\n skipValidation(isBlurEvent, get(_formState.touchedFields, name), _formState.isSubmitted, validationModeAfterSubmit, validationModeBeforeSubmit);\n const watched = isWatched(name, _names, isBlurEvent);\n set(_formValues, name, fieldValue);\n if (isBlurEvent) {\n if (!target || !target.readOnly) {\n field._f.onBlur && field._f.onBlur(event);\n delayErrorCallback && delayErrorCallback(0);\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 values: cloneObject(_formValues),\n });\n if (shouldSkipValidation) {\n if (_proxyFormState.isValid || _proxySubscribeFormState.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 !isBlurEvent && watched && _subjects.state.next({ ..._formState });\n if (_options.resolver) {\n const { errors } = await _runSchema([name]);\n _updateIsValidating([name]);\n _updateIsFieldValueUpdated(fieldValue);\n if (isFieldValueUpdated) {\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 }\n else {\n _updateIsValidating([name], true);\n error = (await validateField(field, _names.disabled, _formValues, shouldDisplayAllAssociatedErrors, _options.shouldUseNativeValidation))[name];\n _updateIsValidating([name]);\n _updateIsFieldValueUpdated(fieldValue);\n if (isFieldValueUpdated) {\n if (error) {\n isValid = false;\n }\n else if (_proxyFormState.isValid ||\n _proxySubscribeFormState.isValid) {\n isValid = await executeBuiltInValidation(_fields, true);\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 }\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 let isValid;\n let validationResult;\n const fieldNames = convertToArrayPayload(name);\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(field && field._f ? { [fieldName]: field } : field);\n }))).every(Boolean);\n !(!validationResult && !_formState.isValid) && _setValid();\n }\n else {\n validationResult = isValid = await executeBuiltInValidation(_fields);\n }\n _subjects.state.next({\n ...(!isString(name) ||\n ((_proxyFormState.isValid || _proxySubscribeFormState.isValid) &&\n isValid !== _formState.isValid)\n ? {}\n : { name }),\n ...(_options.resolver || !name ? { isValid } : {}),\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 = {\n ...(_state.mount ? _formValues : _defaultValues),\n };\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 getFieldState = (name, formState) => ({\n invalid: !!get((formState || _formState).errors, name),\n isDirty: !!get((formState || _formState).dirtyFields, name),\n error: get((formState || _formState).errors, name),\n isValidating: !!get(_formState.validatingFields, name),\n isTouched: !!get((formState || _formState).touchedFields, name),\n });\n const clearErrors = (name) => {\n const names = name ? convertToArrayPayload(name) : undefined;\n names === null || names === void 0 ? void 0 : names.forEach((inputName) => unset(_formState.errors, inputName));\n if (names) {\n // Emit for each cleared field with the field name so that\n // shouldSubscribeByName can filter and avoid broad re-renders\n names.forEach((inputName) => {\n _subjects.state.next({\n name: inputName,\n errors: _formState.errors,\n });\n });\n }\n else {\n // Clear all errors - emit without name to notify all subscribers\n _subjects.state.next({\n errors: {},\n });\n }\n };\n const setError = (name, error, options) => {\n const ref = (get(_fields, name, { _f: {} })._f || {}).ref;\n const currentError = get(_formState.errors, name) || {};\n // Don't override existing error messages elsewhere in the object tree.\n const { ref: currentRef, message, type, ...restOfErrorTree } = currentError;\n set(_formState.errors, name, {\n ...restOfErrorTree,\n ...error,\n ref,\n });\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) => isFunction(name)\n ? _subjects.state.subscribe({\n next: (payload) => 'values' in payload &&\n name(_getWatch(undefined, defaultValue), payload),\n })\n : _getWatch(name, defaultValue, true);\n const _subscribe = (props) => _subjects.state.subscribe({\n next: (formState) => {\n if (shouldSubscribeByName(props.name, formState.name, props.exact) &&\n shouldRenderFormState(formState, props.formState || _proxyFormState, _setFormState, props.reRenderRoot)) {\n props.callback({\n values: { ..._formValues },\n ..._formState,\n ...formState,\n defaultValues: _defaultValues,\n });\n }\n },\n }).unsubscribe;\n const subscribe = (props) => {\n _state.mount = true;\n _proxySubscribeFormState = {\n ..._proxySubscribeFormState,\n ...props.formState,\n };\n return _subscribe({\n ...props,\n formState: {\n ...defaultProxyFormState,\n ...props.formState,\n },\n });\n };\n const unregister = (name, options = {}) => {\n for (const fieldName of name ? convertToArrayPayload(name) : _names.mount) {\n _names.mount.delete(fieldName);\n _names.array.delete(fieldName);\n if (!options.keepValue) {\n unset(_fields, fieldName);\n unset(_formValues, fieldName);\n }\n !options.keepError && unset(_formState.errors, fieldName);\n !options.keepDirty && unset(_formState.dirtyFields, fieldName);\n !options.keepTouched && unset(_formState.touchedFields, fieldName);\n !options.keepIsValidating &&\n unset(_formState.validatingFields, fieldName);\n !_options.shouldUnregister &&\n !options.keepDefaultValue &&\n unset(_defaultValues, fieldName);\n }\n _subjects.state.next({\n values: cloneObject(_formValues),\n });\n _subjects.state.next({\n ..._formState,\n ...(!options.keepDirty ? {} : { isDirty: _getDirty() }),\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 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) {\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: !!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 register(name, options);\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 set(_fields, name, {\n _f: {\n ...field._f,\n ...(radioOrCheckbox\n ? {\n refs: [\n ...refs.filter(live),\n fieldRef,\n ...(Array.isArray(get(_defaultValues, name)) ? [{}] : []),\n ],\n ref: { type: fieldRef.type, name },\n }\n : { ref: fieldRef }),\n },\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 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, false);\n }\n };\n const handleSubmit = (onValid, onInvalid) => async (e) => {\n let onValidError = undefined;\n if (e) {\n e.preventDefault && e.preventDefault();\n e.persist &&\n e.persist();\n }\n let fieldValues = cloneObject(_formValues);\n _subjects.state.next({\n isSubmitting: true,\n });\n if (_options.resolver) {\n const { errors, values } = await _runSchema();\n _updateIsValidating();\n _formState.errors = errors;\n fieldValues = cloneObject(values);\n }\n else {\n await executeBuiltInValidation(_fields);\n }\n if (_names.disabled.size) {\n for (const name of _names.disabled) {\n unset(fieldValues, name);\n }\n }\n unset(_formState.errors, 'root');\n if (isEmptyObject(_formState.errors)) {\n _subjects.state.next({\n errors: {},\n });\n try {\n await onValid(fieldValues, e);\n }\n catch (error) {\n onValidError = error;\n }\n }\n else {\n if (onInvalid) {\n await onInvalid({ ..._formState.errors }, e);\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 };\n const resetField = (name, options = {}) => {\n if (get(_fields, 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 = options.defaultValue\n ? _getDirty(name, cloneObject(get(_defaultValues, name)))\n : _getDirty();\n }\n if (!options.keepError) {\n unset(_formState.errors, name);\n _proxyFormState.isValid && _setValid();\n }\n _subjects.state.next({ ..._formState });\n }\n };\n const _reset = (formValues, keepStateOptions = {}) => {\n const updatedValues = formValues ? cloneObject(formValues) : _defaultValues;\n const cloneUpdatedValues = cloneObject(updatedValues);\n const isEmptyResetValues = isEmptyObject(formValues);\n const values = isEmptyResetValues ? _defaultValues : cloneUpdatedValues;\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 ...Object.keys(getDirtyFields(_defaultValues, _formValues)),\n ]);\n for (const fieldName of Array.from(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 _formValues = _options.shouldUnregister\n ? keepStateOptions.keepDefaultValues\n ? cloneObject(_defaultValues)\n : {}\n : cloneObject(values);\n _subjects.array.next({\n values: { ...values },\n });\n _subjects.state.next({\n values: { ...values },\n });\n }\n _names = {\n mount: keepStateOptions.keepDirtyValues ? _names.mount : new Set(),\n unMount: new Set(),\n array: new Set(),\n disabled: 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 // Clear errors synchronously to prevent validation errors on subsequent submissions\n // This fixes the issue where form.reset() causes validation errors on subsequent\n // submissions in Next.js 16 with Server Actions\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.keepDefaultValues &&\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)\n : _formState.dirtyFields\n : keepStateOptions.keepDefaultValues && formValues\n ? getDirtyFields(_defaultValues, formValues)\n : keepStateOptions.keepDirty\n ? _formState.dirtyFields\n : {},\n touchedFields: keepStateOptions.keepTouched\n ? _formState.touchedFields\n : {},\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)\n ? formValues(_formValues)\n : formValues, { ..._options.resetOptions, ...keepStateOptions });\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\n ? fieldReference.refs[0]\n : fieldReference.ref;\n if (fieldRef.focus) {\n // Use setTimeout to ensure focus happens after any pending state updates\n // This fixes the issue where setFocus doesn't work immediately after setError\n setTimeout(() => {\n fieldRef.focus();\n options.shouldSelect &&\n isFunction(fieldRef.select) &&\n fieldRef.select();\n });\n }\n }\n };\n const _setFormState = (updatedFormState) => {\n _formState = {\n ..._formState,\n ...updatedFormState,\n };\n };\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 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 },\n },\n subscribe,\n trigger,\n register,\n handleSubmit,\n watch,\n setValue,\n getValues,\n reset,\n resetField,\n clearErrors,\n unregister,\n setError,\n setFocus,\n getFieldState,\n };\n return {\n ...methods,\n formControl: methods,\n };\n}\n\nvar generateId = () => {\n if (typeof crypto !== 'undefined' && crypto.randomUUID) {\n return crypto.randomUUID();\n }\n const d = typeof performance === 'undefined' ? Date.now() : performance.now() * 1000;\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = ((Math.random() * 16 + d) % 16) | 0;\n return (c == 'x' ? r : (r & 0x3) | 0x8).toString(16);\n });\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 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\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, convertToArrayPayload(index).sort((a, b) => a - b));\n\nvar swapArrayAt = (data, indexA, indexB) => {\n [data[indexA], data[indexB]] = [data[indexB], data[indexA]];\n};\n\nvar updateAt = (fieldValues, index, value) => {\n fieldValues[index] = value;\n return fieldValues;\n};\n\n/**\n * A custom hook that exposes convenient methods to perform operations with a list of dynamic inputs that need to be appended, updated, removed etc. • [Demo](https://codesandbox.io/s/react-hook-form-usefieldarray-ssugn) • [Video](https://youtu.be/4MrbfGSFY2A)\n *\n * @remarks\n * [API](https://react-hook-form.com/docs/usefieldarray) • [Demo](https://codesandbox.io/s/react-hook-form-usefieldarray-ssugn)\n *\n * @param props - useFieldArray props\n *\n * @returns methods - functions to manipulate with the Field Arrays (dynamic inputs) {@link UseFieldArrayReturn}\n *\n * @example\n * ```tsx\n * function App() {\n * const { register, control, handleSubmit, reset, trigger, setError } = useForm({\n * defaultValues: {\n * test: []\n * }\n * });\n * const { fields, append } = useFieldArray({\n * control,\n * name: \"test\"\n * });\n *\n * return (\n * <form onSubmit={handleSubmit(data => console.log(data))}>\n * {fields.map((item, index) => (\n * <input key={item.id} {...register(`test.${index}.firstName`)} />\n * ))}\n * <button type=\"button\" onClick={() => append({ firstName: \"bill\" })}>\n * append\n * </button>\n * <input type=\"submit\" />\n * </form>\n * );\n * }\n * ```\n */\nfunction useFieldArray(props) {\n const formControl = useFormControlContext();\n const { control = formControl, name, keyName = 'id', shouldUnregister, rules, } = props;\n const [fields, setFields] = React.useState(control._getFieldArray(name));\n const ids = React.useRef(control._getFieldArray(name).map(generateId));\n const _actioned = React.useRef(false);\n control._names.array.add(name);\n React.useMemo(() => rules &&\n fields.length >= 0 &&\n control.register(name, rules), [control, name, fields.length, rules]);\n useIsomorphicLayoutEffect(() => 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 }\n },\n }).unsubscribe, [control, name]);\n const updateValues = React.useCallback((updatedFieldArrayValues) => {\n _actioned.current = true;\n control._setFieldArray(name, updatedFieldArrayValues);\n }, [control, name]);\n const append = (value, options) => {\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 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 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 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 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 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 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: updateValue,\n }, true, false);\n };\n const replace = (value) => {\n const updatedFieldArrayValues = convertToArrayPayload(cloneObject(value));\n ids.current = updatedFieldArrayValues.map(generateId);\n updateValues([...updatedFieldArrayValues]);\n setFields([...updatedFieldArrayValues]);\n control._setFieldArray(name, [...updatedFieldArrayValues], (data) => data, {}, true, false);\n };\n React.useEffect(() => {\n control._state.action = false;\n isWatched(name, control._names) &&\n control._subjects.state.next({\n ...control._formState,\n });\n if (_actioned.current &&\n (!getValidationModes(control._options.mode).isOnSubmit ||\n control._formState.isSubmitted) &&\n !getValidationModes(control._options.reValidateMode).isOnSubmit) {\n if (control._options.resolver) {\n control._runSchema([name]).then((result) => {\n control._updateIsValidating([name]);\n const error = get(result.errors, name);\n const existingError = get(control._formState.errors, name);\n if (existingError\n ? (!error && existingError.type) ||\n (error &&\n (existingError.type !== error.type ||\n existingError.message !== error.message))\n : error && error.type) {\n error\n ? set(control._formState.errors, name, error)\n : unset(control._formState.errors, name);\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 &&\n field._f &&\n !(getValidationModes(control._options.reValidateMode).isOnSubmit &&\n getValidationModes(control._options.mode).isOnSubmit)) {\n validateField(field, control._names.disabled, control._formValues, control._options.criteriaMode === VALIDATION_MODE.all, control._options.shouldUseNativeValidation, true).then((error) => !isEmptyObject(error) &&\n control._subjects.state.next({\n errors: updateFieldArrayRootError(control._formState.errors, error, name),\n }));\n }\n }\n }\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]);\n React.useEffect(() => {\n !get(control._formValues, name) && control._setFieldArray(name);\n return () => {\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 control._options.shouldUnregister || shouldUnregister\n ? control.unregister(name)\n : updateMounted(name, false);\n };\n }, [name, control, keyName, shouldUnregister]);\n return {\n swap: React.useCallback(swap, [updateValues, name, control]),\n move: React.useCallback(move, [updateValues, name, control]),\n prepend: React.useCallback(prepend, [updateValues, name, control]),\n append: React.useCallback(append, [updateValues, name, control]),\n remove: React.useCallback(remove, [updateValues, name, control]),\n insert: React.useCallback(insert$1, [updateValues, name, control]),\n update: React.useCallback(update, [updateValues, name, control]),\n replace: React.useCallback(replace, [updateValues, name, control]),\n fields: React.useMemo(() => fields.map((field, index) => ({\n ...field,\n [keyName]: ids.current[index] || generateId(),\n })), [fields, keyName]),\n };\n}\n\n/**\n * Custom hook to manage the entire form.\n *\n * @remarks\n * [API](https://react-hook-form.com/docs/useform) • [Demo](https://codesandbox.io/s/react-hook-form-get-started-ts-5ksmm) • [Video](https://www.youtube.com/watch?v=RkXv4AXXC_4)\n *\n * @param props - form configuration and validation parameters.\n *\n * @returns methods - individual functions to manage the form state. {@link UseFormReturn}\n *\n * @example\n * ```tsx\n * function App() {\n * const { register, handleSubmit, watch, formState: { errors } } = useForm();\n * const onSubmit = data => console.log(data);\n *\n * console.log(watch(\"example\"));\n *\n * return (\n * <form onSubmit={handleSubmit(onSubmit)}>\n * <input defaultValue=\"test\" {...register(\"example\")} />\n * <input {...register(\"exampleRequired\", { required: true })} />\n * {errors.exampleRequired && <span>This field is required</span>}\n * <button>Submit</button>\n * </form>\n * );\n * }\n * ```\n */\nfunction useForm(props = {}) {\n const _formControl = React.useRef(undefined);\n const _values = React.useRef(undefined);\n const [formState, updateFormState] = React.useState({\n isDirty: false,\n isValidating: false,\n isLoading: isFunction(props.defaultValues),\n isSubmitted: false,\n isSubmitting: false,\n isSubmitSuccessful: false,\n isValid: false,\n submitCount: 0,\n dirtyFields: {},\n touchedFields: {},\n validatingFields: {},\n errors: props.errors || {},\n disabled: props.disabled || false,\n isReady: false,\n defaultValues: isFunction(props.defaultValues)\n ? undefined\n : props.defaultValues,\n });\n if (!_formControl.current) {\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 control._options = props;\n useIsomorphicLayoutEffect(() => {\n const sub = control._subscribe({\n formState: control._proxyFormState,\n callback: () => updateFormState({ ...control._formState }),\n reRenderRoot: true,\n });\n updateFormState((data) => ({\n ...data,\n isReady: true,\n }));\n control._formState.isReady = true;\n return sub;\n }, [control]);\n React.useEffect(() => control._disableForm(props.disabled), [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 }, [control, props.errors]);\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 var _a;\n if (props.values && !deepEqual(props.values, _values.current)) {\n control._reset(props.values, {\n keepFieldsRef: true,\n ...control._options.resetOptions,\n });\n if (!((_a = control._options.resetOptions) === null || _a === void 0 ? void 0 : _a.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) {\n control._setValid();\n control._state.mount = true;\n }\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\n/**\n * Watch component that subscribes to form field changes and re-renders when watched fields update.\n *\n * @param control - The form control object from useForm\n * @param name - Can be field name, array of field names, or undefined to watch the entire form\n * @param disabled - Disable subscription\n * @param exact - Whether to watch exact field names or not\n * @param defaultValue - The default value to use if the field is not yet set\n * @param compute - Function to compute derived values from watched fields\n * @param render - The function that receives watched values and returns ReactNode\n * @returns The result of calling render function with watched values\n *\n * @example\n * The `Watch` component only re-render when the values of `foo`, `bar`, and `baz.qux` change.\n * The types of `foo`, `bar`, and `baz.qux` are precisely inferred.\n *\n * ```tsx\n * const { control } = useForm();\n *\n * <Watch\n * control={control}\n * names={['foo', 'bar', 'baz.qux']}\n * render={([foo, bar, baz_qux]) => <div>{foo}{bar}{baz_qux}</div>}\n * />\n * ```\n */\nconst Watch = (props) => props.render(useWatch({ name: props.names, ...props }));\n\nexport { Controller, Form, FormProvider, FormStateSubscribe, Watch, appendErrors, createFormControl, get, set, useController, useFieldArray, useForm, useFormContext, useFormState, useWatch };\n//# sourceMappingURL=index.esm.mjs.map\n","import { twMerge } from \"tailwind-merge\";\n\ntype Props = {\n className?: string;\n size?: \"sm\" | \"md\" | \"lg\";\n margin?: \"sm\" | \"md\" | \"lg\";\n};\nexport function Divider({ className, size = \"sm\", margin = \"md\" }: Props) {\n function getSize() {\n if (size === \"sm\") return \"h-px\";\n if (size === \"md\") return \"h-1\";\n return \"h-1.5\";\n }\n\n function getMargin() {\n if (margin === \"sm\") return \"my-4\";\n if (margin === \"md\") return \"my-6\";\n return \"my-8\";\n }\n\n const sizeClass = getSize();\n const marginClass = getMargin();\n return (\n <div\n className={twMerge(\"bg-secondary\", sizeClass, marginClass, className)}\n />\n );\n}\n","import{get as e,set as t}from\"react-hook-form\";const r=(t,r,o)=>{if(t&&\"reportValidity\"in t){const s=e(o,r);t.setCustomValidity(s&&s.message||\"\"),t.reportValidity()}},o=(e,t)=>{for(const o in t.fields){const s=t.fields[o];s&&s.ref&&\"reportValidity\"in s.ref?r(s.ref,o,e):s&&s.refs&&s.refs.forEach(t=>r(t,o,e))}},s=(r,s)=>{s.shouldUseNativeValidation&&o(r,s);const n={};for(const o in r){const f=e(s.fields,o),c=Object.assign(r[o]||{},{ref:f&&f.ref});if(i(s.names||Object.keys(r),o)){const r=Object.assign({},e(n,o));t(r,\"root\",c),t(n,o,r)}else t(n,o,c)}return n},i=(e,t)=>{const r=n(t);return e.some(e=>n(e).match(`^${r}\\\\.\\\\d+`))};function n(e){return e.replace(/\\]|\\[/g,\"\")}export{s as toNestErrors,o as validateFieldsNatively};\n//# sourceMappingURL=resolvers.mjs.map\n","import{validateFieldsNatively as r,toNestErrors as e}from\"@hookform/resolvers\";import{appendErrors as o}from\"react-hook-form\";import*as n from\"zod/v4/core\";function t(r,e){try{var o=r()}catch(r){return e(r)}return o&&o.then?o.then(void 0,e):o}function s(r,e){for(var n={};r.length;){var t=r[0],s=t.code,i=t.message,a=t.path.join(\".\");if(!n[a])if(\"unionErrors\"in t){var u=t.unionErrors[0].errors[0];n[a]={message:u.message,type:u.code}}else n[a]={message:i,type:s};if(\"unionErrors\"in t&&t.unionErrors.forEach(function(e){return e.errors.forEach(function(e){return r.push(e)})}),e){var c=n[a].types,f=c&&c[t.code];n[a]=o(a,e,n,s,f?[].concat(f,t.message):t.message)}r.shift()}return n}function i(r,e){for(var n={};r.length;){var t=r[0],s=t.code,i=t.message,a=t.path.join(\".\");if(!n[a])if(\"invalid_union\"===t.code&&t.errors.length>0){var u=t.errors[0][0];n[a]={message:u.message,type:u.code}}else n[a]={message:i,type:s};if(\"invalid_union\"===t.code&&t.errors.forEach(function(e){return e.forEach(function(e){return r.push(e)})}),e){var c=n[a].types,f=c&&c[t.code];n[a]=o(a,e,n,s,f?[].concat(f,t.message):t.message)}r.shift()}return n}function a(o,a,u){if(void 0===u&&(u={}),function(r){return\"_def\"in r&&\"object\"==typeof r._def&&\"typeName\"in r._def}(o))return function(n,i,c){try{return Promise.resolve(t(function(){return Promise.resolve(o[\"sync\"===u.mode?\"parse\":\"parseAsync\"](n,a)).then(function(e){return c.shouldUseNativeValidation&&r({},c),{errors:{},values:u.raw?Object.assign({},n):e}})},function(r){if(function(r){return Array.isArray(null==r?void 0:r.issues)}(r))return{values:{},errors:e(s(r.errors,!c.shouldUseNativeValidation&&\"all\"===c.criteriaMode),c)};throw r}))}catch(r){return Promise.reject(r)}};if(function(r){return\"_zod\"in r&&\"object\"==typeof r._zod}(o))return function(s,c,f){try{return Promise.resolve(t(function(){return Promise.resolve((\"sync\"===u.mode?n.parse:n.parseAsync)(o,s,a)).then(function(e){return f.shouldUseNativeValidation&&r({},f),{errors:{},values:u.raw?Object.assign({},s):e}})},function(r){if(function(r){return r instanceof n.$ZodError}(r))return{values:{},errors:e(i(r.issues,!f.shouldUseNativeValidation&&\"all\"===f.criteriaMode),f)};throw r}))}catch(r){return Promise.reject(r)}};throw new Error(\"Invalid input: not a Zod schema\")}export{a as zodResolver};\n//# sourceMappingURL=zod.module.js.map\n","import { z } from \"zod\";\nimport { snakeCase, constantCase } from \"change-case\";\n\nconst isUppercase = (value: string) => !/\\p{Ll}/u.test(value);\nconst isLowercase = (value: string) => !/\\p{Lu}/u.test(value);\n\nconst whitespaceRegex = /\\s+/g;\n\nexport function containsSpaces(s: string) {\n return whitespaceRegex.test(s);\n}\n\nexport function replaceSpaces(s: string) {\n return s.replace(whitespaceRegex, \"_\");\n}\n\ntype SchemaOptions = {\n required?: boolean;\n allowEmpty?: boolean;\n unique?: string[];\n};\n\nexport function createNameSchema(options: SchemaOptions = {}) {\n const { required = false, allowEmpty = false, unique = [] } = options;\n\n const baseSchema = allowEmpty ? z.string() : z.string().min(1);\n\n const uniqueRefinement = baseSchema.refine(\n (value) => {\n if (!value && allowEmpty) return true;\n return !unique\n .map((n) => n.toLowerCase())\n .includes(value.replace(/^\\s+|\\s+$/g, \"_\").toLowerCase());\n },\n { message: \"Item with this name already exists\" },\n );\n\n if (!required) {\n return unique.length > 0\n ? z\n .string()\n .optional()\n .refine(\n (value) => {\n if (value === undefined) return true;\n if (!value && allowEmpty) return true;\n return !unique\n .map((n) => n.toLowerCase())\n .includes(value.replace(/^\\s+|\\s+$/g, \"_\").toLowerCase());\n },\n { message: \"Item with this name already exists\" },\n )\n : z.string().optional();\n }\n\n return unique.length > 0 ? uniqueRefinement : baseSchema;\n}\n\nexport function createConstantCaseSchema(options: SchemaOptions = {}) {\n return createNameSchema(options)\n .transform((value) => (value ? value.toUpperCase() : value))\n .refine((value) => !value || isUppercase(value), {\n message: \"Must be uppercase\",\n });\n}\n\nexport function createLowercaseSnakeCaseSchema(options: SchemaOptions = {}) {\n return createNameSchema(options)\n .transform((value) => (value ? value.toLowerCase() : value))\n .refine((value) => !value || isLowercase(value), {\n message: \"Must be lowercase\",\n });\n}\n\nexport function toLowercaseSnakeCase(\n value: string,\n options: SchemaOptions = {},\n) {\n return createLowercaseSnakeCaseSchema(options).parse(\n snakeCase(value),\n ) as LowercaseSnakeCase;\n}\n\nexport function toConstantCase(value: string, options: SchemaOptions = {}) {\n return createConstantCaseSchema(options).parse(\n constantCase(value),\n ) as ConstantCase;\n}\n\nexport type SnakeCase = `${string}_${string}`;\nexport type LowercaseSnakeCase = Lowercase<SnakeCase>;\nexport type ConstantCase = Uppercase<SnakeCase>;\nexport type Prettify<T> = {\n [K in keyof T]: T[K];\n} & {};\n\nexport const AuthorSchema = z\n .object({\n name: createNameSchema({ allowEmpty: true }),\n website: z\n .union([z.url(), z.literal(\"\")])\n .optional()\n .default(\"\"),\n })\n .default({\n name: \"\",\n website: \"\",\n });\n","import React from \"react\";\nimport type { FieldValues, FieldPath } from \"react-hook-form\";\n\nexport type FormFieldContextValue<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> = {\n name: TName;\n};\n\nexport const FormFieldContext = React.createContext<FormFieldContextValue>(\n {} as FormFieldContextValue,\n);\n\nexport type FormItemContextValue = {\n id: string;\n};\n\nexport const FormItemContext = React.createContext<FormItemContextValue>(\n {} as FormItemContextValue,\n);\n","import React from \"react\";\nimport { useFormContext } from \"react-hook-form\";\nimport { FormFieldContext, FormItemContext } from \"../context/form-context.js\";\n\nexport const useFormField = () => {\n const fieldContext = React.useContext(FormFieldContext);\n const itemContext = React.useContext(FormItemContext);\n const { getFieldState, formState } = useFormContext();\n\n const fieldState = getFieldState(fieldContext.name, formState);\n\n if (!fieldContext) {\n throw new Error(\"useFormField should be used within <FormField>\");\n }\n\n const { id } = itemContext;\n\n return {\n id,\n name: fieldContext.name,\n formItemId: `${id}-form-item`,\n formDescriptionId: `${id}-form-item-description`,\n formMessageId: `${id}-form-item-message`,\n ...fieldState,\n };\n};\n","\"use client\";\n\n// src/label.tsx\nimport * as React from \"react\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { jsx } from \"react/jsx-runtime\";\nvar NAME = \"Label\";\nvar Label = React.forwardRef((props, forwardedRef) => {\n return /* @__PURE__ */ jsx(\n Primitive.label,\n {\n ...props,\n ref: forwardedRef,\n onMouseDown: (event) => {\n const target = event.target;\n if (target.closest(\"button, input, select, textarea\")) return;\n props.onMouseDown?.(event);\n if (!event.defaultPrevented && event.detail > 1) event.preventDefault();\n }\n }\n );\n});\nLabel.displayName = NAME;\nvar Root = Label;\nexport {\n Label,\n Root\n};\n//# sourceMappingURL=index.mjs.map\n","import * as React from \"react\";\nimport * as LabelPrimitive from \"@radix-ui/react-label\";\nimport type { VariantProps } from \"class-variance-authority\";\nimport { cva } from \"class-variance-authority\";\nimport { twMerge } from \"tailwind-merge\";\n\nconst labelVariants = cva(\n \"text-sm leading-none font-medium peer-disabled:disabled-effect\",\n);\n\nconst Label = React.forwardRef<\n React.ElementRef<typeof LabelPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &\n VariantProps<typeof labelVariants>\n>(({ className, ...props }, ref) => (\n <LabelPrimitive.Root\n ref={ref}\n className={twMerge(labelVariants(), className)}\n {...props}\n />\n));\nLabel.displayName = LabelPrimitive.Root.displayName;\n\nexport { Label };\n","import * as React from \"react\";\nimport type * as LabelPrimitive from \"@radix-ui/react-label\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport type { ControllerProps, FieldPath, FieldValues } from \"react-hook-form\";\nimport { Controller, FormProvider } from \"react-hook-form\";\nimport { FormFieldContext, FormItemContext } from \"../context/form-context.js\";\nimport { useFormField } from \"../hooks/useFormField.js\";\nimport { twMerge } from \"tailwind-merge\";\nimport { Label } from \"./label.js\";\n\nconst Form = FormProvider;\n\nconst FormField = <\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>({\n ...props\n}: ControllerProps<TFieldValues, TName>) => {\n return (\n <FormFieldContext.Provider value={{ name: props.name }}>\n <Controller {...props} />\n </FormFieldContext.Provider>\n );\n};\n\nconst FormItem = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => {\n const id = React.useId();\n\n return (\n <FormItemContext.Provider value={{ id }}>\n <div ref={ref} className={className} {...props} />\n </FormItemContext.Provider>\n );\n});\nFormItem.displayName = \"FormItem\";\n\nconst FormLabel = React.forwardRef<\n React.ElementRef<typeof LabelPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>\n>(({ className, ...props }, ref) => {\n const { error, formItemId } = useFormField();\n\n return (\n <Label\n ref={ref}\n className={twMerge(error && \"text-destructive\", className)}\n htmlFor={formItemId}\n {...props}\n />\n );\n});\nFormLabel.displayName = \"FormLabel\";\n\nconst FormControl = React.forwardRef<\n React.ElementRef<typeof Slot>,\n React.ComponentPropsWithoutRef<typeof Slot>\n>(({ ...props }, ref) => {\n const { error, formItemId, formDescriptionId, formMessageId } =\n useFormField();\n\n return (\n <Slot\n ref={ref}\n id={formItemId}\n aria-describedby={\n !error ? formDescriptionId : `${formDescriptionId} ${formMessageId}`\n }\n aria-invalid={!!error}\n {...props}\n />\n );\n});\nFormControl.displayName = \"FormControl\";\n\nconst FormDescription = React.forwardRef<\n HTMLParagraphElement,\n React.HTMLAttributes<HTMLParagraphElement>\n>(({ className, ...props }, ref) => {\n const { formDescriptionId } = useFormField();\n\n return (\n <p\n ref={ref}\n id={formDescriptionId}\n className={twMerge(\"text-sm text-foreground\", className)}\n {...props}\n />\n );\n});\nFormDescription.displayName = \"FormDescription\";\n\nconst FormMessage = React.forwardRef<\n HTMLParagraphElement,\n React.HTMLAttributes<HTMLParagraphElement>\n>(({ className, children, ...props }, ref) => {\n const { error, formMessageId } = useFormField();\n const body = error ? String(error.message) : children;\n\n if (!body) {\n return null;\n }\n\n return (\n <p\n ref={ref}\n id={formMessageId}\n className={twMerge(\"text-sm font-medium text-destructive\", className)}\n {...props}\n >\n {body}\n </p>\n );\n});\nFormMessage.displayName = \"FormMessage\";\n\nexport {\n Form,\n FormItem,\n FormLabel,\n FormControl,\n FormDescription,\n FormMessage,\n FormField,\n};\n","import * as React from \"react\";\nimport { forwardRef, useCallback, useImperativeHandle, useRef } from \"react\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport interface TextareaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {}\n\nexport interface TextareaHandle {\n focus: () => void;\n element: HTMLTextAreaElement | null;\n}\n\nexport const Textarea = forwardRef<TextareaHandle, TextareaProps>(\n ({ className, ...props }, ref) => {\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n\n const adjustHeight = useCallback((textarea: HTMLTextAreaElement) => {\n textarea.style.height = \"auto\";\n const newHeight = Math.max(textarea.scrollHeight, textarea.offsetHeight);\n textarea.style.height = `${newHeight}px`;\n }, []);\n\n const handleInput = useCallback(\n (e: React.FormEvent<HTMLTextAreaElement>) => {\n adjustHeight(e.currentTarget);\n },\n [adjustHeight],\n );\n\n React.useEffect(() => {\n if (textareaRef.current) {\n adjustHeight(textareaRef.current);\n }\n }, [adjustHeight]);\n\n useImperativeHandle(ref, () => ({\n focus: () => textareaRef.current?.focus(),\n element: textareaRef.current,\n }));\n\n return (\n <textarea\n {...props}\n className={twMerge(\n \"min-h-10 w-full resize-none rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground focus-visible:outline-none disabled:disabled-effect\",\n className,\n )}\n ref={textareaRef}\n onInput={handleInput}\n />\n );\n },\n);\nTextarea.displayName = \"Textarea\";\n","import { zodResolver } from \"@hookform/resolvers/zod\";\nimport {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useImperativeHandle,\n useRef,\n} from \"react\";\nimport type { FieldValues, Resolver } from \"react-hook-form\";\nimport { useForm } from \"react-hook-form\";\nimport { z } from \"zod\";\nimport { createNameSchema } from \"../schemas/inputs.js\";\nimport { compareStringsWithoutWhitespace } from \"../utils/helpers.js\";\nimport {\n Form,\n FormControl,\n FormField,\n FormItem,\n FormLabel,\n FormMessage,\n} from \"./form.js\";\nimport type { TextareaHandle } from \"./text-area.js\";\nimport { Textarea } from \"./text-area.js\";\n\ntype TextFieldProps = {\n name: string;\n value: string | null | undefined;\n onSubmit: (value: string) => void;\n label?: string;\n placeholder?: string;\n className?: string;\n rows?: number;\n focusOnMount?: boolean;\n required?: boolean;\n allowEmpty?: boolean;\n unique?: string[];\n shouldReset?: boolean;\n onChange?: (value: string) => void;\n};\n\ntype TextFieldHandle = {\n focus: () => void;\n};\n\nexport const TextField = forwardRef<TextFieldHandle, TextFieldProps>(\n (\n {\n name,\n value,\n onSubmit,\n label,\n placeholder,\n unique,\n className = \"\",\n rows = 1,\n focusOnMount = false,\n required = false,\n allowEmpty = false,\n shouldReset = false,\n onChange,\n },\n ref,\n ) => {\n const textareaRef = useRef<TextareaHandle | null>(null);\n const id = useId();\n useEffect(() => {\n if (focusOnMount && textareaRef.current) {\n textareaRef.current.focus();\n }\n }, [focusOnMount]);\n\n const fieldSchema = z.object({\n [name]: createNameSchema({ required, allowEmpty, unique }),\n });\n\n const form = useForm({\n resolver: zodResolver(\n fieldSchema as unknown as Parameters<typeof zodResolver>[0],\n ) as Resolver<FieldValues>,\n defaultValues: {\n [name]: value ?? \"\",\n },\n });\n\n const handleSubmit = useCallback(\n (values: FieldValues) => {\n const newValue = values[name] as string | undefined;\n if (newValue === undefined || value === newValue) return;\n onSubmit(newValue);\n if (shouldReset) form.reset({ [name]: \"\" });\n },\n [name, value, onSubmit, form, shouldReset],\n );\n\n const handleBlur = useCallback(async () => {\n const currentValue = (form.getValues()[name] as string | undefined) ?? \"\";\n\n if (value === null || value === undefined) {\n if (!currentValue || currentValue.trim() === \"\") return;\n }\n\n if (compareStringsWithoutWhitespace(currentValue, value ?? \"\")) return;\n\n try {\n await form.trigger(); // Trigger validation\n if (form.formState.isValid) {\n await form.handleSubmit(handleSubmit)();\n }\n } catch (_e) {\n // Allow blur to proceed even if validation fails\n }\n }, [form, handleSubmit, name, value]);\n\n const onEnterKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n (e.target as HTMLTextAreaElement).blur();\n }\n },\n [],\n );\n\n const handleChange = useCallback(\n (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n const newValue = e.target.value;\n onChange?.(newValue);\n },\n [onChange],\n );\n\n useImperativeHandle(ref, () => ({\n focus: () => textareaRef.current?.focus(),\n }));\n\n useEffect(() => {\n form.reset({ [name]: value ?? \"\" });\n }, [form, name, value]);\n\n return (\n <Form {...form}>\n <FormField\n control={form.control}\n name={name}\n render={({ field }) => (\n <FormItem className=\"grid h-full grid-rows-[auto,1fr] gap-2 overflow-visible\">\n {!!label && (\n <FormLabel\n htmlFor={name}\n className=\"text-sm font-medium text-foreground\"\n >\n {label}\n </FormLabel>\n )}\n <FormControl>\n <Textarea\n {...field}\n id={id}\n name={name}\n ref={(node) => {\n if (node) {\n field.ref(node.element);\n textareaRef.current = node;\n }\n }}\n placeholder={placeholder}\n onBlur={() => void handleBlur()}\n onChange={(e) => {\n field.onChange(e);\n handleChange(e);\n }}\n onKeyDown={onEnterKeyDown}\n rows={rows}\n className={className}\n />\n </FormControl>\n <FormMessage />\n </FormItem>\n )}\n />\n </Form>\n );\n },\n);\n\nTextField.displayName = \"TextField\";\n","import { useCallback } from \"react\";\nimport { z } from \"zod\";\nimport type { Scope } from \"../types/documents.js\";\nimport {\n handleModelNameChange,\n makeInitialSchemaDoc,\n renameSchemaType,\n} from \"../utils/helpers.js\";\nimport { TextField } from \"./text-field.js\";\n\nexport const MetadataFormSchema = z.object({\n name: z.string(),\n documentType: z.string(),\n extension: z.string().optional().default(\"\"),\n description: z.string(),\n authorName: z.string(),\n authorWebsite: z.string(),\n});\n\nexport type MetadataFormValues = z.infer<typeof MetadataFormSchema>;\n\ntype Props = MetadataFormValues & {\n globalStateSchema: string;\n localStateSchema: string;\n setModelName: (name: string) => void;\n setModelId: (id: string) => void;\n setModelExtension: (extension: string) => void;\n setModelDescription: (description: string) => void;\n setAuthorName: (authorName: string) => void;\n setAuthorWebsite: (authorWebsite: string) => void;\n setStateSchema: (schema: string, scope: Scope) => void;\n};\n\nexport default function ModelMetadata(props: Props) {\n return (\n <div>\n <ModelNameForm {...props} />\n <div className=\"flex h-full flex-col gap-4\">\n <div className=\"grid flex-1 grid-cols-3 items-start gap-4\">\n <div className=\"col-span-2 flex h-full flex-col gap-4\">\n <div className=\"shrink-0\">\n <DocumentTypeForm {...props} />\n </div>\n <div className=\"min-h-0 flex-1\">\n <DescriptionForm {...props} />\n </div>\n </div>\n <div className=\"col-span-1 flex flex-col gap-4\">\n <AuthorNameForm {...props} />\n <AuthorWebsiteForm {...props} />\n <ModelExtensionForm {...props} />\n </div>\n </div>\n </div>\n </div>\n );\n}\n\nexport function ModelNameForm(props: Props) {\n const {\n name,\n globalStateSchema,\n localStateSchema,\n setModelName,\n setStateSchema,\n } = props;\n\n const onSubmit = useCallback(\n (newName: string) => {\n if (name === newName) {\n return;\n }\n setModelName(newName);\n\n const hasExistingSchema = !!globalStateSchema;\n\n if (!hasExistingSchema) {\n const initialSchemaDoc = makeInitialSchemaDoc(newName, \"global\");\n setStateSchema(initialSchemaDoc, \"global\");\n return;\n }\n const newSchema = renameSchemaType(\n globalStateSchema,\n name,\n newName,\n \"global\",\n );\n setStateSchema(newSchema, \"global\");\n\n if (localStateSchema) {\n const newLocalStateSchema = renameSchemaType(\n localStateSchema,\n name,\n newName,\n \"local\",\n );\n setStateSchema(newLocalStateSchema, \"local\");\n }\n handleModelNameChange({\n oldName: name,\n newName,\n globalStateSchema,\n localStateSchema,\n setStateSchema,\n });\n },\n [name, globalStateSchema, localStateSchema, setStateSchema, setModelName],\n );\n\n return (\n <TextField\n name=\"name\"\n value={name}\n onSubmit={onSubmit}\n placeholder=\"Model name\"\n className=\"border-none pl-0 text-xl font-bold text-foreground\"\n required\n focusOnMount\n />\n );\n}\n\nexport function DocumentTypeForm(props: Props) {\n const { documentType, setModelId } = props;\n\n return (\n <TextField\n label=\"Document Type *\"\n name=\"powerhouse/document-model\"\n value={documentType}\n onSubmit={setModelId}\n placeholder=\"Document Type\"\n required\n />\n );\n}\n\nexport function ModelExtensionForm(props: Props) {\n const { extension, setModelExtension } = props;\n\n return (\n <TextField\n name=\"extension\"\n value={extension}\n onSubmit={setModelExtension}\n label=\"Model Extension\"\n placeholder=\"Example .phdm\"\n allowEmpty\n />\n );\n}\n\nexport function DescriptionForm(props: Props) {\n const { description, setModelDescription } = props;\n\n return (\n <TextField\n name=\"description\"\n label=\"Model Description\"\n value={description}\n onSubmit={setModelDescription}\n placeholder=\"Describe your document to others\"\n allowEmpty\n className=\"h-full\"\n />\n );\n}\n\nexport function AuthorNameForm(props: Props) {\n const { authorName, setAuthorName } = props;\n\n return (\n <TextField\n name=\"authorName\"\n value={authorName}\n onSubmit={setAuthorName}\n label=\"Author Name\"\n placeholder=\"Username or organisation\"\n allowEmpty\n />\n );\n}\n\nexport function AuthorWebsiteForm(props: Props) {\n const { authorWebsite, setAuthorWebsite } = props;\n\n return (\n <TextField\n name=\"authorWebsite\"\n value={authorWebsite}\n label=\"Website URL\"\n onSubmit={(newAuthorWebsite) => {\n if (!!authorWebsite && !newAuthorWebsite) return;\n setAuthorWebsite(newAuthorWebsite);\n }}\n placeholder=\"https://www.powerhouse.inc/\"\n allowEmpty\n />\n );\n}\n","import type { ModuleSpecification } from \"@powerhousedao/shared/document-model\";\nimport { toLowercaseSnakeCase } from \"../schemas/inputs.js\";\nimport { TextField } from \"./text-field.js\";\n\ntype Props = {\n modules?: ModuleSpecification[];\n module?: ModuleSpecification;\n onAddModule: (name: string) => Promise<string | undefined>;\n updateModuleName: (id: string, name: string) => void;\n};\n\nexport function ModuleForm({\n module,\n onAddModule,\n updateModuleName,\n modules = [],\n}: Props) {\n const isEdit = !!module;\n const moduleNames = modules.map((m) => m.name);\n\n const handleSubmit = async (name: string) => {\n const formattedName = toLowercaseSnakeCase(name);\n if (!formattedName.length) return;\n\n if (isEdit) {\n if (formattedName !== module.name) {\n updateModuleName(module.id, formattedName);\n }\n } else {\n await onAddModule(formattedName);\n }\n };\n\n return (\n <TextField\n key={module?.id ?? \"new\"}\n name=\"name\"\n label={isEdit ? \"Module name *\" : \"Add module *\"}\n value={module?.name}\n onSubmit={(name) => void handleSubmit(name)}\n placeholder=\"Add module\"\n unique={moduleNames}\n shouldReset={!isEdit}\n required\n />\n );\n}\n","import type { ModuleSpecification } from \"@powerhousedao/shared/document-model\";\nimport { toConstantCase } from \"../schemas/inputs.js\";\nimport { TextField } from \"./text-field.js\";\n\ntype Props = {\n module: ModuleSpecification;\n operation?: ModuleSpecification[\"operations\"][number];\n focusOnMount?: boolean;\n allOperationNames: string[];\n onAddOperationAndInitialSchema: (\n moduleId: string,\n name: string,\n ) => Promise<string | undefined>;\n updateOperationName: (id: string, name: string) => void;\n deleteOperation: (id: string) => void;\n};\n\nexport function OperationForm({\n operation,\n module,\n focusOnMount,\n allOperationNames,\n onAddOperationAndInitialSchema,\n updateOperationName,\n deleteOperation,\n}: Props) {\n const isEdit = !!operation;\n\n const handleSubmit = async (name: string) => {\n if (isEdit && name === \"\") {\n deleteOperation(operation.id);\n return;\n }\n\n const formattedName = toConstantCase(name);\n\n if (isEdit) {\n if (formattedName !== operation.name) {\n updateOperationName(operation.id, formattedName);\n }\n } else {\n await onAddOperationAndInitialSchema(module.id, formattedName);\n }\n };\n\n const handleChange = (value: string) => {\n if (isEdit && value === \"\") {\n deleteOperation(operation.id);\n }\n };\n\n return (\n <TextField\n name=\"name\"\n value={operation?.name}\n label={isEdit ? \"Operation name *\" : \"Add operation *\"}\n onSubmit={(name) => void handleSubmit(name)}\n onChange={handleChange}\n placeholder=\"Add operation\"\n required={!isEdit}\n allowEmpty={!isEdit}\n shouldReset={!isEdit}\n focusOnMount={focusOnMount}\n unique={allOperationNames}\n />\n );\n}\n","import type { ModuleSpecification } from \"@powerhousedao/shared/document-model\";\nimport { useEffect, useRef } from \"react\";\nimport { TextField } from \"./text-field.js\";\n\ntype Props = {\n operation: ModuleSpecification[\"operations\"][number];\n focusOnMount?: boolean;\n setOperationDescription: (id: string, description: string) => void;\n};\n\nexport function OperationDescriptionForm({\n operation,\n focusOnMount,\n setOperationDescription,\n}: Props) {\n const textFieldRef = useRef<{ focus: () => void } | null>(null);\n\n useEffect(() => {\n if (focusOnMount && textFieldRef.current) {\n textFieldRef.current.focus();\n }\n }, [focusOnMount]);\n\n return (\n <TextField\n ref={textFieldRef}\n name=\"description\"\n value={operation.description}\n onSubmit={(newDescription) =>\n setOperationDescription(operation.id, newDescription)\n }\n label=\"Operation description\"\n allowEmpty\n placeholder=\"Operation Description\"\n />\n );\n}\n","import type {\n ModuleSpecification,\n OperationErrorSpecification,\n} from \"@powerhousedao/shared/document-model\";\nimport { pascalCase } from \"change-case\";\nimport { useRef } from \"react\";\nimport { TextField } from \"./text-field.js\";\n\ntype Props = {\n operation: ModuleSpecification[\"operations\"][number];\n error?: OperationErrorSpecification;\n focusOnMount?: boolean;\n onSubmit?: () => void;\n onAddOperationError: (\n operationId: string,\n errorName: string,\n ) => Promise<string | undefined>;\n deleteOperationError: (id: string) => void;\n setOperationErrorName: (\n operationId: string,\n errorId: string,\n name: string,\n ) => void;\n};\n\nexport function OperationErrorForm({\n operation,\n error,\n focusOnMount,\n onSubmit,\n onAddOperationError,\n deleteOperationError,\n setOperationErrorName,\n}: Props) {\n const textFieldRef = useRef<{ focus: () => void } | null>(null);\n const isEdit = !!error;\n const allOperationErrorNames = operation.errors\n .map((o) => o.name)\n .filter((n) => n !== null);\n\n const handleSubmit = (name: string) => {\n if (isEdit && name === \"\") {\n deleteOperationError(error.id);\n return;\n }\n\n const formattedName = pascalCase(name);\n\n if (isEdit) {\n setOperationErrorName(operation.id, error.id, formattedName);\n } else {\n void onAddOperationError(operation.id, formattedName);\n }\n onSubmit?.();\n };\n\n const handleChange = (value: string) => {\n if (isEdit && value === \"\") {\n deleteOperationError(error.id);\n }\n };\n\n return (\n <TextField\n ref={textFieldRef}\n name=\"name\"\n value={error?.name}\n onSubmit={handleSubmit}\n onChange={handleChange}\n placeholder=\"Add exception\"\n required={!isEdit}\n allowEmpty={!isEdit}\n shouldReset={!isEdit}\n unique={allOperationErrorNames}\n focusOnMount={focusOnMount}\n />\n );\n}\n","import type { ModuleSpecification } from \"@powerhousedao/shared/document-model\";\nimport { useCallback, useId, useState } from \"react\";\nimport { OperationErrorForm } from \"./operation-error-form.js\";\n\ntype Props = {\n operation: ModuleSpecification[\"operations\"][number];\n addOperationError: (\n operationId: string,\n errorName: string,\n ) => Promise<string | undefined>;\n deleteOperationError: (id: string) => void;\n setOperationErrorName: (\n operationId: string,\n errorId: string,\n name: string,\n ) => void;\n};\n\nexport function OperationErrors({\n operation,\n addOperationError,\n deleteOperationError,\n setOperationErrorName,\n}: Props) {\n const addErrorFormId = useId();\n const [shouldFocusAddForm, setShouldFocusAddForm] = useState(false);\n\n const onAddOperationError = useCallback(\n async (operationId: string, error: string) => {\n const errorId = await addOperationError(operationId, error);\n if (errorId) {\n setShouldFocusAddForm(true);\n }\n return errorId;\n },\n [addOperationError, setShouldFocusAddForm],\n );\n\n const onAddOperationErrorSubmit = useCallback(\n () => setShouldFocusAddForm(false),\n [setShouldFocusAddForm],\n );\n\n return (\n <ul className=\"ml-4 list-disc\">\n {operation.errors.map((error) => (\n <li key={error.id}>\n <OperationErrorForm\n error={error}\n operation={operation}\n onAddOperationError={onAddOperationError}\n deleteOperationError={deleteOperationError}\n setOperationErrorName={setOperationErrorName}\n />\n </li>\n ))}\n <li>\n <OperationErrorForm\n operation={operation}\n onAddOperationError={onAddOperationError}\n deleteOperationError={deleteOperationError}\n setOperationErrorName={setOperationErrorName}\n key={`${addErrorFormId}-${shouldFocusAddForm}`}\n focusOnMount={shouldFocusAddForm}\n onSubmit={onAddOperationErrorSubmit}\n />\n </li>\n </ul>\n );\n}\n","import type { ModuleSpecification } from \"@powerhousedao/shared/document-model\";\nimport { lazy, Suspense, useCallback } from \"react\";\nimport type { DocumentActionHandlers } from \"../types/documents.js\";\nimport { isEmptyOperationSchema } from \"../utils/helpers.js\";\nimport { ensureValidOperationSchemaInputName } from \"../utils/linting.js\";\nimport { OperationDescriptionForm } from \"./operation-description-form.js\";\nimport { OperationErrors } from \"./operation-errors.js\";\nimport { OperationForm } from \"./operation-form.js\";\nconst GraphqlEditor = lazy(() => import(\"./code-editors/graphql-editor.js\"));\nexport type WrappedHandlers = DocumentActionHandlers & {\n addOperationAndInitialSchema: (\n moduleId: string,\n name: string,\n ) => Promise<string | undefined>;\n};\ntype Props = {\n lastCreatedOperationId: string | null;\n operation: ModuleSpecification[\"operations\"][number];\n module: ModuleSpecification;\n allOperationNames: string[];\n onAddOperationAndInitialSchema: (\n moduleId: string,\n name: string,\n ) => Promise<string | undefined>;\n updateOperationName: (id: string, name: string) => void;\n deleteOperation: (id: string) => void;\n updateOperationSchema: (id: string, newDoc: string) => void;\n setOperationDescription: (id: string, description: string) => void;\n addOperationError: (\n operationId: string,\n errorName: string,\n ) => Promise<string | undefined>;\n deleteOperationError: (id: string) => void;\n setOperationErrorName: (\n operationId: string,\n errorId: string,\n name: string,\n ) => void;\n toggleNoInputRequired: (id: string, noInputRequired: boolean) => void;\n};\nexport function Operation(props: Props) {\n const {\n operation,\n module,\n allOperationNames,\n lastCreatedOperationId,\n onAddOperationAndInitialSchema,\n updateOperationName,\n deleteOperation,\n updateOperationSchema,\n setOperationDescription,\n addOperationError,\n deleteOperationError,\n setOperationErrorName,\n toggleNoInputRequired,\n } = props;\n\n const noInputRequired = isEmptyOperationSchema(operation.schema);\n\n const handleToggleNoInput = useCallback(\n (checked: boolean) => toggleNoInputRequired(operation.id, checked),\n [operation.id, toggleNoInputRequired],\n );\n\n const handleUpdateDocument = useCallback(\n (newDoc: string) => updateOperationSchema(operation.id, newDoc),\n [operation.id, updateOperationSchema],\n );\n\n const customLinter = useCallback(\n (doc: string) =>\n operation.name\n ? ensureValidOperationSchemaInputName(doc, operation.name)\n : [],\n [operation.name],\n );\n\n return (\n <div\n className=\"mt-4 grid grid-cols-2 gap-x-12\"\n style={{\n gridTemplateAreas: `\n \"left editor\"\n \"errors editor\"\n `,\n gridTemplateRows: \"auto 1fr\",\n }}\n >\n <div className=\"flex flex-col gap-2\" style={{ gridArea: \"left\" }}>\n <OperationForm\n operation={operation}\n onAddOperationAndInitialSchema={onAddOperationAndInitialSchema}\n updateOperationName={updateOperationName}\n deleteOperation={deleteOperation}\n module={module}\n allOperationNames={allOperationNames}\n />\n <OperationDescriptionForm\n operation={operation}\n focusOnMount={operation.id === lastCreatedOperationId}\n setOperationDescription={setOperationDescription}\n />\n </div>\n\n <div className=\"relative top-8\" style={{ gridArea: \"editor\" }}>\n <label className=\"mb-2 flex cursor-pointer items-center gap-2\">\n <input\n type=\"checkbox\"\n checked={noInputRequired}\n onChange={(e) => handleToggleNoInput(e.target.checked)}\n className=\"size-4 rounded-sm border-border\"\n />\n <span className=\"text-sm text-foreground\">\n Operation with no inputs\n </span>\n </label>\n {!noInputRequired && (\n <Suspense>\n <GraphqlEditor\n doc={operation.schema ?? \"\"}\n updateDocumentInModel={handleUpdateDocument}\n customLinter={customLinter}\n />\n </Suspense>\n )}\n </div>\n\n <div style={{ gridArea: \"errors\" }}>\n <h3 className=\"my-2 text-sm font-medium text-foreground\">\n Reducer Exceptions\n </h3>\n <OperationErrors\n operation={operation}\n addOperationError={addOperationError}\n deleteOperationError={deleteOperationError}\n setOperationErrorName={setOperationErrorName}\n />\n </div>\n </div>\n );\n}\n","import { OperationForm } from \"./operation-form.js\";\nimport type { ModuleSpecification } from \"@powerhousedao/shared/document-model\";\nimport { useCallback, useId, useState } from \"react\";\nimport { Operation } from \"./operation.js\";\n\ntype Props = {\n module: ModuleSpecification;\n allOperations: ModuleSpecification[\"operations\"];\n shouldFocusNewOperation: boolean;\n updateOperationName: (id: string, name: string) => void;\n deleteOperation: (id: string) => void;\n addOperationAndInitialSchema: (\n moduleId: string,\n name: string,\n ) => Promise<string | undefined>;\n updateOperationSchema: (id: string, newDoc: string) => void;\n setOperationDescription: (id: string, description: string) => void;\n addOperationError: (\n operationId: string,\n errorName: string,\n ) => Promise<string | undefined>;\n deleteOperationError: (id: string) => void;\n setOperationErrorName: (\n operationId: string,\n errorId: string,\n name: string,\n ) => void;\n toggleNoInputRequired: (id: string, noInputRequired: boolean) => void;\n};\nexport function Operations({\n module,\n allOperations,\n shouldFocusNewOperation,\n updateOperationName,\n deleteOperation,\n addOperationAndInitialSchema,\n addOperationError,\n deleteOperationError,\n setOperationErrorName,\n updateOperationSchema,\n setOperationDescription,\n toggleNoInputRequired,\n}: Props) {\n const [lastCreatedOperationId, setLastCreatedOperationId] = useState<\n string | null\n >(null);\n const addOperationFormId = useId();\n const allOperationNames = allOperations\n .map((o) => o.name)\n .filter((n) => n !== null);\n\n const onAddOperationAndInitialSchema = useCallback(\n async (moduleId: string, name: string) => {\n const operationId = await addOperationAndInitialSchema(moduleId, name);\n if (operationId) {\n setLastCreatedOperationId(operationId);\n }\n return operationId;\n },\n [addOperationAndInitialSchema, setLastCreatedOperationId],\n );\n\n return (\n <div>\n {module.operations.map((operation) => (\n <div key={operation.id}>\n <Operation\n operation={operation}\n module={module}\n lastCreatedOperationId={lastCreatedOperationId}\n allOperationNames={allOperationNames}\n addOperationError={addOperationError}\n deleteOperationError={deleteOperationError}\n setOperationErrorName={setOperationErrorName}\n onAddOperationAndInitialSchema={onAddOperationAndInitialSchema}\n updateOperationName={updateOperationName}\n deleteOperation={deleteOperation}\n updateOperationSchema={updateOperationSchema}\n setOperationDescription={setOperationDescription}\n toggleNoInputRequired={toggleNoInputRequired}\n />\n </div>\n ))}\n <div className=\"mt-6 w-1/2 pr-6\">\n <OperationForm\n key={addOperationFormId}\n onAddOperationAndInitialSchema={onAddOperationAndInitialSchema}\n updateOperationName={updateOperationName}\n deleteOperation={deleteOperation}\n module={module}\n allOperationNames={allOperationNames}\n focusOnMount={shouldFocusNewOperation}\n />\n </div>\n </div>\n );\n}\n","import type { ModuleSpecification as TModule } from \"@powerhousedao/shared/document-model\";\nimport { ModuleForm } from \"./module-form.js\";\nimport { Operations } from \"./operations.js\";\ntype Props = {\n module?: TModule;\n modules?: TModule[];\n allOperations: TModule[\"operations\"];\n lastCreatedModuleId: string | null;\n onAddModule: (name: string) => Promise<string | undefined>;\n updateModuleName: (id: string, name: string) => void;\n deleteModule: (id: string) => void;\n updateOperationName: (id: string, name: string) => void;\n deleteOperation: (id: string) => void;\n addOperationAndInitialSchema: (\n moduleId: string,\n name: string,\n ) => Promise<string | undefined>;\n updateOperationSchema: (id: string, newDoc: string) => void;\n setOperationDescription: (id: string, description: string) => void;\n addOperationError: (\n operationId: string,\n errorName: string,\n ) => Promise<string | undefined>;\n deleteOperationError: (id: string) => void;\n setOperationErrorName: (\n operationId: string,\n errorId: string,\n name: string,\n ) => void;\n toggleNoInputRequired: (id: string, noInputRequired: boolean) => void;\n};\nexport function Module(props: Props) {\n const {\n module,\n modules,\n allOperations,\n lastCreatedModuleId,\n onAddModule,\n updateModuleName,\n deleteModule,\n updateOperationName,\n deleteOperation,\n addOperationAndInitialSchema,\n updateOperationSchema,\n setOperationDescription,\n addOperationError,\n deleteOperationError,\n setOperationErrorName,\n toggleNoInputRequired,\n } = props;\n return (\n <div className=\"relative rounded-3xl bg-muted p-6\">\n <div className=\"mb-2 w-1/2 pr-6\">\n <ModuleForm\n modules={modules}\n module={module}\n onAddModule={onAddModule}\n updateModuleName={updateModuleName}\n />\n {!!module && (\n <button\n aria-label=\"Delete module\"\n tabIndex={-1}\n className=\"absolute top-1 right-1 p-2 text-foreground transition-colors hover:hover-effect\"\n onClick={() => {\n deleteModule(module.id);\n }}\n >\n <svg className=\"size-6\" viewBox=\"0 0 24 24\" fill=\"currentcolor\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M16.9993 8.51506L15.4844 7L11.9994 10.4852L8.51497 7.00057L7 8.51562L10.4844 12.0003L7.00056 15.4843L8.51552 16.9994L11.9994 13.5153L15.4838 17L16.9988 15.4849L13.5144 12.0003L16.9993 8.51506Z\"\n />\n </svg>\n </button>\n )}\n </div>\n {!!module && (\n <Operations\n module={module}\n allOperations={allOperations}\n shouldFocusNewOperation={module.id === lastCreatedModuleId}\n updateOperationName={updateOperationName}\n deleteOperation={deleteOperation}\n addOperationAndInitialSchema={addOperationAndInitialSchema}\n updateOperationSchema={updateOperationSchema}\n setOperationDescription={setOperationDescription}\n addOperationError={addOperationError}\n deleteOperationError={deleteOperationError}\n setOperationErrorName={setOperationErrorName}\n toggleNoInputRequired={toggleNoInputRequired}\n />\n )}\n </div>\n );\n}\n","import type { ModuleSpecification as TModule } from \"@powerhousedao/shared/document-model\";\nimport { useCallback, useRef, useState } from \"react\";\nimport { Module } from \"./module.js\";\n\ntype Props = {\n modules: TModule[];\n allOperations: TModule[\"operations\"];\n addModule: (name: string) => Promise<string | undefined>;\n updateModuleName: (id: string, name: string) => void;\n deleteModule: (id: string) => void;\n updateOperationName: (id: string, name: string) => void;\n deleteOperation: (id: string) => void;\n addOperationAndInitialSchema: (\n moduleId: string,\n name: string,\n ) => Promise<string | undefined>;\n updateOperationSchema: (id: string, newDoc: string) => void;\n setOperationDescription: (id: string, description: string) => void;\n addOperationError: (\n operationId: string,\n errorName: string,\n ) => Promise<string | undefined>;\n deleteOperationError: (id: string) => void;\n setOperationErrorName: (\n operationId: string,\n errorId: string,\n name: string,\n ) => void;\n toggleNoInputRequired: (id: string, noInputRequired: boolean) => void;\n};\nexport default function Modules({\n modules,\n allOperations,\n addModule,\n updateModuleName,\n deleteModule,\n updateOperationName,\n deleteOperation,\n addOperationAndInitialSchema,\n updateOperationSchema,\n setOperationDescription,\n addOperationError,\n deleteOperationError,\n setOperationErrorName,\n toggleNoInputRequired,\n}: Props) {\n const [lastCreatedModuleId, setLastCreatedModuleId] = useState<string | null>(\n null,\n );\n const focusTrapRef = useRef<HTMLDivElement>(null);\n\n const onAddModule = useCallback(\n async (name: string) => {\n const moduleId = await addModule(name);\n if (moduleId) {\n setLastCreatedModuleId(moduleId);\n focusTrapRef.current?.focus();\n }\n return moduleId;\n },\n [addModule, setLastCreatedModuleId],\n );\n\n return (\n <div className=\"flex flex-col gap-2\">\n {modules.map((module) => (\n <Module\n key={module.id}\n module={module}\n modules={modules}\n allOperations={allOperations}\n lastCreatedModuleId={lastCreatedModuleId}\n onAddModule={onAddModule}\n updateModuleName={updateModuleName}\n deleteModule={deleteModule}\n updateOperationName={updateOperationName}\n deleteOperation={deleteOperation}\n addOperationAndInitialSchema={addOperationAndInitialSchema}\n updateOperationSchema={updateOperationSchema}\n setOperationDescription={setOperationDescription}\n addOperationError={addOperationError}\n deleteOperationError={deleteOperationError}\n setOperationErrorName={setOperationErrorName}\n toggleNoInputRequired={toggleNoInputRequired}\n />\n ))}\n <Module\n key=\"add-module\"\n modules={modules}\n allOperations={allOperations}\n lastCreatedModuleId={lastCreatedModuleId}\n onAddModule={onAddModule}\n updateModuleName={updateModuleName}\n deleteModule={deleteModule}\n updateOperationName={updateOperationName}\n deleteOperation={deleteOperation}\n addOperationAndInitialSchema={addOperationAndInitialSchema}\n updateOperationSchema={updateOperationSchema}\n setOperationDescription={setOperationDescription}\n addOperationError={addOperationError}\n deleteOperationError={deleteOperationError}\n setOperationErrorName={setOperationErrorName}\n toggleNoInputRequired={toggleNoInputRequired}\n />\n {/* Focus trap to prevent tabbing out of the editor */}\n <div\n ref={focusTrapRef}\n tabIndex={0}\n className=\"size-0 overflow-hidden\"\n aria-hidden=\"true\"\n />\n </div>\n );\n}\n","import { Modal } from \"@powerhousedao/design-system\";\nimport {\n ConnectSelect,\n ModalButton,\n} from \"@powerhousedao/design-system/connect\";\nimport type { DocumentSpecification } from \"@powerhousedao/shared/document-model\";\nimport { useState } from \"react\";\nimport { Button } from \"./button.js\";\n\nconst compactButtonStyle =\n \"min-h-0 min-w-0 flex-none rounded-lg px-6 py-1.5 text-sm whitespace-nowrap\";\n\ntype VersionControlsProps = {\n specifications: DocumentSpecification[];\n viewedVersion: number;\n onViewVersion: (version: number | \"latest\") => void;\n onReleaseNewVersion: () => void;\n};\n\nexport function VersionControls(props: VersionControlsProps) {\n const { specifications, viewedVersion, onViewVersion, onReleaseNewVersion } =\n props;\n const [showReleaseModal, setShowReleaseModal] = useState(false);\n const latestVersion = specifications[specifications.length - 1].version;\n const nextVersion = latestVersion + 1;\n\n return (\n <div className=\"mb-4 flex items-center justify-between gap-4\">\n <div className=\"flex items-center gap-2\">\n <span\n className=\"rounded-md bg-muted px-2 py-0.5 font-mono text-xs text-foreground\"\n data-testid=\"model-version-badge\"\n >\n Version {viewedVersion}\n </span>\n {specifications.length >= 2 && (\n <div\n aria-label=\"Document model version\"\n data-testid=\"model-version-switcher\"\n >\n <ConnectSelect\n absolutePositionMenu\n containerClassName=\"z-10 [&_svg]:size-4\"\n id=\"model-version-switcher\"\n itemClassName=\"gap-1 px-2 py-1 font-mono text-xs leading-none [&_p:empty]:hidden\"\n items={specifications.map((spec) => ({\n value: String(spec.version),\n displayValue: (\n <span className=\"normal-case\">\n {spec.version === latestVersion\n ? `v${spec.version} (latest)`\n : `v${spec.version} (frozen)`}\n </span>\n ),\n }))}\n listClassName=\"border border-t-0 border-border shadow-md\"\n menuClassName=\"min-w-0 pr-1.5\"\n onChange={(value) => {\n const version = Number(value);\n onViewVersion(version === latestVersion ? \"latest\" : version);\n }}\n value={String(viewedVersion)}\n />\n </div>\n )}\n </div>\n <Button\n className=\"inline-flex h-8 items-center justify-center py-0\"\n data-testid=\"release-new-version-button\"\n onClick={() => setShowReleaseModal(true)}\n type=\"button\"\n >\n Release new version\n </Button>\n <Modal\n open={showReleaseModal}\n onOpenChange={(status: boolean) => {\n if (!status) setShowReleaseModal(false);\n }}\n >\n <div className=\"w-[440px] p-6\">\n <div className=\"pb-2 text-2xl font-bold text-foreground\">\n Release version {nextVersion}\n </div>\n <div className=\"my-4 rounded-md bg-background p-4 text-left text-sm text-foreground\">\n <p>\n Version {latestVersion} will be frozen as-is. Version{\" \"}\n {nextVersion} starts as an identical copy, and all further edits\n apply to version {nextVersion}.\n </p>\n <p className=\"mt-3\">\n Existing version {latestVersion} documents will be upgradeable\n once you define the migration.\n </p>\n </div>\n <div className=\"mt-4 flex justify-between gap-3\">\n <ModalButton\n className={compactButtonStyle}\n onClick={() => setShowReleaseModal(false)}\n variant=\"cancel\"\n >\n Cancel\n </ModalButton>\n <ModalButton\n className={compactButtonStyle}\n data-testid=\"confirm-release-button\"\n onClick={() => {\n setShowReleaseModal(false);\n onReleaseNewVersion();\n }}\n variant=\"confirm\"\n >\n Release version {nextVersion}\n </ModalButton>\n </div>\n </div>\n </Modal>\n </div>\n );\n}\n\nexport function FrozenVersionBanner(props: {\n viewedVersion: number;\n latestVersion: number;\n}) {\n const { viewedVersion, latestVersion } = props;\n return (\n <div\n className=\"mb-4 rounded-md border border-border bg-muted p-3 text-sm text-foreground\"\n data-testid=\"frozen-version-banner\"\n >\n Version {viewedVersion} is frozen. You're viewing it read-only. Edits\n go to version {latestVersion}.\n </div>\n );\n}\n","import { Modal } from \"@powerhousedao/design-system\";\nimport { ModalButton } from \"@powerhousedao/design-system/connect\";\nimport type { VersionAdvisoryPrompt } from \"../hooks/useVersionAdvisory.js\";\n\nconst compactButtonStyle =\n \"min-h-0 min-w-0 flex-none rounded-lg px-4 py-1.5 text-sm whitespace-nowrap\";\n\nfunction FieldDiffList(props: { label: string; fields: string[] }) {\n const { label, fields } = props;\n if (fields.length === 0) return null;\n return (\n <div className=\"mt-3\">\n <p className=\"mb-1.5\">{label}</p>\n <div className=\"flex flex-col items-start gap-1\">\n {fields.map((field) => (\n <span\n className=\"rounded-md bg-muted px-2 py-0.5 font-mono text-xs text-foreground\"\n key={field}\n >\n {field}\n </span>\n ))}\n </div>\n </div>\n );\n}\n\ntype VersionAdvisoryModalProps = {\n prompt: VersionAdvisoryPrompt | undefined;\n onReleaseFirst: () => void;\n onKeepEditing: () => void;\n onCancel: () => void;\n};\n\nexport function VersionAdvisoryModal(props: VersionAdvisoryModalProps) {\n const { prompt, onReleaseFirst, onKeepEditing, onCancel } = props;\n if (!prompt) return null;\n const { version, reason, diff } = prompt;\n const nextVersion = version + 1;\n\n return (\n <Modal\n open\n onOpenChange={(status: boolean) => {\n if (!status) onCancel();\n }}\n >\n <div className=\"w-[440px] p-6\" data-testid=\"version-advisory-modal\">\n <div className=\"pb-2 text-2xl font-bold text-foreground\">\n Is version {version} of this model already in use?\n </div>\n <div className=\"my-4 rounded-md bg-background p-4 text-left text-sm text-foreground\">\n <p>\n {reason} Documents that were already created with version {version}{\" \"}\n may stop working correctly.\n </p>\n {diff && (\n <>\n <FieldDiffList fields={diff.addedFields} label=\"New fields:\" />\n <FieldDiffList\n fields={diff.removedFields}\n label=\"Removed fields:\"\n />\n <FieldDiffList\n fields={diff.changedFields}\n label=\"Changed fields:\"\n />\n </>\n )}\n <p className=\"mt-3\">\n If others are already using version {version}, release version{\" \"}\n {nextVersion} first. Your change will go into version {nextVersion},\n and existing documents can be updated safely.\n </p>\n </div>\n <div className=\"mt-4 flex flex-col gap-2\">\n <ModalButton\n className={compactButtonStyle}\n data-testid=\"advisory-release-first\"\n onClick={onReleaseFirst}\n variant=\"confirm\"\n >\n {`It's in use — release v${nextVersion} first`}\n </ModalButton>\n <ModalButton\n className={compactButtonStyle}\n data-testid=\"advisory-keep-editing\"\n onClick={onKeepEditing}\n variant=\"cancel\"\n >\n Still in development — keep editing v{version}\n </ModalButton>\n </div>\n </div>\n </Modal>\n );\n}\n","import type { PHDocumentEditorConfig } from \"@powerhousedao/reactor-browser\";\n\nexport const editorConfig: PHDocumentEditorConfig = {\n isExternalControlsEnabled: false,\n};\n","import {\n useDocumentOfType,\n useSelectedDocumentOfType,\n} from \"@powerhousedao/reactor-browser\";\nimport type {\n DocumentModelAction,\n DocumentModelDocument,\n} from \"@powerhousedao/shared/document-model\";\n\nexport function useDocumentModelDocument(\n documentId: string | undefined | null,\n): ReturnType<\n typeof useDocumentOfType<DocumentModelDocument, DocumentModelAction>\n> {\n return useDocumentOfType<DocumentModelDocument, DocumentModelAction>(\n documentId,\n \"powerhouse/document-model\",\n );\n}\n\nexport function useSelectedDocumentModelDocument(): ReturnType<\n typeof useSelectedDocumentOfType<DocumentModelDocument, DocumentModelAction>\n> {\n return useSelectedDocumentOfType<DocumentModelDocument, DocumentModelAction>(\n \"powerhouse/document-model\",\n );\n}\n","import type {\n DefinitionNode,\n DocumentNode,\n EnumTypeDefinitionNode,\n InputObjectTypeDefinitionNode,\n ObjectTypeDefinitionNode,\n} from \"graphql\";\nimport { Kind, parse, print } from \"graphql\";\nimport type {\n DocumentModelAction,\n DocumentSpecification,\n ModuleSpecification,\n OperationSpecification,\n} from \"@powerhousedao/shared/document-model\";\nimport { compareStringsWithoutWhitespace } from \"./helpers.js\";\n\nexport type StateShapeDiff = {\n addedFields: string[];\n removedFields: string[];\n changedFields: string[];\n};\n\ntype FieldMap = Map<string, string>;\ntype TypeFields = Map<string, Map<string, string>>;\n\ntype ShapeTypeNode =\n | ObjectTypeDefinitionNode\n | InputObjectTypeDefinitionNode\n | EnumTypeDefinitionNode;\n\nfunction isShapeTypeNode(node: DefinitionNode): node is ShapeTypeNode {\n return (\n node.kind === Kind.OBJECT_TYPE_DEFINITION ||\n node.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION ||\n node.kind === Kind.ENUM_TYPE_DEFINITION\n );\n}\n\nfunction collectTypeFields(doc: DocumentNode): TypeFields {\n const types: TypeFields = new Map();\n for (const definition of doc.definitions) {\n if (!isShapeTypeNode(definition)) continue;\n const fields = new Map<string, string>();\n if (definition.kind === Kind.ENUM_TYPE_DEFINITION) {\n for (const value of definition.values ?? []) {\n fields.set(value.name.value, \"value\");\n }\n } else {\n for (const field of definition.fields ?? []) {\n fields.set(field.name.value, print(field.type));\n }\n }\n types.set(definition.name.value, fields);\n }\n return types;\n}\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nfunction replaceTypeName(\n printedType: string,\n oldName: string,\n newName: string,\n): string {\n return printedType.replace(\n new RegExp(`\\\\b${escapeRegExp(oldName)}\\\\b`, \"g\"),\n newName,\n );\n}\n\nfunction typeSignature(name: string, fields: Map<string, string>): string {\n return [...fields.entries()]\n .map(\n ([field, type]) => `${field}:${replaceTypeName(type, name, \"__SELF__\")}`,\n )\n .sort()\n .join(\"|\");\n}\n\nfunction detectTypeRenames(\n oldTypes: TypeFields,\n newTypes: TypeFields,\n): Map<string, string> {\n const renames = new Map<string, string>();\n const removed = [...oldTypes.keys()].filter((name) => !newTypes.has(name));\n const added = new Set(\n [...newTypes.keys()].filter((name) => !oldTypes.has(name)),\n );\n for (const oldName of removed) {\n const oldSignature = typeSignature(oldName, oldTypes.get(oldName)!);\n for (const newName of added) {\n if (typeSignature(newName, newTypes.get(newName)!) === oldSignature) {\n renames.set(oldName, newName);\n added.delete(newName);\n break;\n }\n }\n }\n return renames;\n}\n\nfunction flattenFields(\n types: TypeFields,\n renames: Map<string, string>,\n): FieldMap {\n const fields: FieldMap = new Map();\n for (const [typeName, typeFields] of types) {\n const resolvedTypeName = renames.get(typeName) ?? typeName;\n for (const [fieldName, printedType] of typeFields) {\n let resolvedType = printedType;\n for (const [oldName, newName] of renames) {\n resolvedType = replaceTypeName(resolvedType, oldName, newName);\n }\n fields.set(`${resolvedTypeName}.${fieldName}`, resolvedType);\n }\n }\n return fields;\n}\n\nexport function hasShapeChange(diff: StateShapeDiff): boolean {\n return (\n diff.addedFields.length > 0 ||\n diff.removedFields.length > 0 ||\n diff.changedFields.length > 0\n );\n}\n\nexport function diffSdlShapes(oldSdl: string, newSdl: string): StateShapeDiff {\n const empty: StateShapeDiff = {\n addedFields: [],\n removedFields: [],\n changedFields: [],\n };\n let oldDoc: DocumentNode;\n let newDoc: DocumentNode;\n try {\n oldDoc = parse(oldSdl);\n newDoc = parse(newSdl);\n } catch {\n return empty;\n }\n const oldTypes = collectTypeFields(oldDoc);\n const newTypes = collectTypeFields(newDoc);\n const renames = detectTypeRenames(oldTypes, newTypes);\n const oldFields = flattenFields(oldTypes, renames);\n const newFields = flattenFields(newTypes, new Map());\n const diff: StateShapeDiff = {\n addedFields: [],\n removedFields: [],\n changedFields: [],\n };\n for (const [key, newType] of newFields) {\n const oldType = oldFields.get(key);\n if (oldType === undefined) {\n diff.addedFields.push(key);\n } else if (oldType !== newType) {\n diff.changedFields.push(`${key}: ${oldType} → ${newType}`);\n }\n }\n for (const key of oldFields.keys()) {\n if (!newFields.has(key)) {\n diff.removedFields.push(key);\n }\n }\n return diff;\n}\n\nexport type ActionClassification =\n | { kind: \"safe\" }\n | { kind: \"version-relevant\"; reason: string; diff?: StateShapeDiff };\n\nconst SAFE: ActionClassification = { kind: \"safe\" };\n\nfunction isBlank(value: string | null | undefined): boolean {\n return !value || !value.trim() || value.trim() === \"{}\";\n}\n\n/**\n * True for a blank SDL, or an SDL whose types contain nothing but the\n * `_placeholder` field the editor seeds new state/operation schemas with\n * (see `makeInitialSchemaDoc` / `makeOperationInitialDoc` in ./helpers.ts).\n * Replacing a placeholder-only schema with real fields is a user's first\n * edit on a brand-new model, not a version-relevant change.\n */\nfunction isPlaceholderOnlySchema(sdl: string): boolean {\n if (isBlank(sdl)) return true;\n let doc: DocumentNode;\n try {\n doc = parse(sdl);\n } catch {\n return false;\n }\n const types = collectTypeFields(doc);\n return [...types.values()].every(\n (fields) =>\n fields.size === 0 || (fields.size === 1 && fields.has(\"_placeholder\")),\n );\n}\n\nfunction findOperation(\n spec: DocumentSpecification,\n operationId: string,\n): OperationSpecification | undefined {\n for (const module of spec.modules) {\n const operation = module.operations.find((op) => op.id === operationId);\n if (operation) return operation;\n }\n return undefined;\n}\n\nfunction addedSinceLastRelease(\n operationId: string,\n previousSpec: DocumentSpecification | undefined,\n): boolean {\n return (\n previousSpec !== undefined && !findOperation(previousSpec, operationId)\n );\n}\n\nfunction classifySetStateSchema(\n input: { schema: string; scope: string },\n latestSpec: DocumentSpecification,\n): ActionClassification {\n const currentSchema =\n input.scope === \"local\"\n ? latestSpec.state.local.schema\n : latestSpec.state.global.schema;\n if (isPlaceholderOnlySchema(currentSchema)) return SAFE;\n const diff = diffSdlShapes(currentSchema, input.schema);\n if (!hasShapeChange(diff)) return SAFE;\n return {\n kind: \"version-relevant\",\n reason:\n input.scope === \"local\"\n ? `You're changing the local fields that version ${latestSpec.version} documents store.`\n : `You're changing the fields that version ${latestSpec.version} documents store.`,\n diff,\n };\n}\n\n/**\n * The editor pre-fills a fresh model's initial value from the placeholder\n * schema, so a value that is blank or carries only the `_placeholder` key is\n * still being initialized rather than changed.\n */\nfunction isPlaceholderOnlyInitialValue(value: string): boolean {\n if (isBlank(value)) return true;\n let parsed: unknown;\n try {\n parsed = JSON.parse(value);\n } catch {\n return false;\n }\n if (typeof parsed !== \"object\" || parsed === null) return false;\n return Object.keys(parsed).every((key) => key === \"_placeholder\");\n}\n\nfunction classifySetInitialState(\n input: { initialValue: string; scope: string },\n latestSpec: DocumentSpecification,\n): ActionClassification {\n const currentValue =\n input.scope === \"local\"\n ? latestSpec.state.local.initialValue\n : latestSpec.state.global.initialValue;\n if (isPlaceholderOnlyInitialValue(currentValue)) return SAFE;\n if (compareStringsWithoutWhitespace(currentValue, input.initialValue)) {\n return SAFE;\n }\n return {\n kind: \"version-relevant\",\n reason: `You're changing the starting content that version ${latestSpec.version} documents are built on.`,\n };\n}\n\nfunction classifyOperationChange(\n action: DocumentModelAction,\n operationId: string,\n latestSpec: DocumentSpecification,\n previousSpec: DocumentSpecification | undefined,\n): ActionClassification {\n if (addedSinceLastRelease(operationId, previousSpec)) return SAFE;\n const operation = findOperation(latestSpec, operationId);\n if (!operation) return SAFE;\n const operationLabel = operation.name || \"an operation\";\n switch (action.type) {\n case \"DELETE_OPERATION\":\n return {\n kind: \"version-relevant\",\n reason: `You're removing the \"${operationLabel}\" operation from version ${latestSpec.version}.`,\n };\n case \"SET_OPERATION_NAME\": {\n if (isBlank(operation.name)) return SAFE;\n return {\n kind: \"version-relevant\",\n reason: `You're renaming the \"${operationLabel}\" operation in version ${latestSpec.version}.`,\n };\n }\n case \"SET_OPERATION_SCHEMA\": {\n if (isPlaceholderOnlySchema(operation.schema ?? \"\")) return SAFE;\n if (isBlank(action.input.schema)) {\n return {\n kind: \"version-relevant\",\n reason: `You're changing the information that the \"${operationLabel}\" operation accepts in version ${latestSpec.version}.`,\n };\n }\n const diff = diffSdlShapes(\n operation.schema ?? \"\",\n action.input.schema ?? \"\",\n );\n if (!hasShapeChange(diff)) return SAFE;\n return {\n kind: \"version-relevant\",\n reason: `You're changing the information that the \"${operationLabel}\" operation accepts in version ${latestSpec.version}.`,\n diff,\n };\n }\n default:\n return SAFE;\n }\n}\n\nfunction classifyDeleteModule(\n moduleId: string,\n latestSpec: DocumentSpecification,\n previousSpec: DocumentSpecification | undefined,\n): ActionClassification {\n const module: ModuleSpecification | undefined = latestSpec.modules.find(\n (candidate) => candidate.id === moduleId,\n );\n if (!module || module.operations.length === 0) return SAFE;\n const allAddedSinceRelease = module.operations.every((operation) =>\n addedSinceLastRelease(operation.id, previousSpec),\n );\n if (allAddedSinceRelease) return SAFE;\n return {\n kind: \"version-relevant\",\n reason: `You're removing the \"${module.name}\" module and all of its operations from version ${latestSpec.version}.`,\n };\n}\n\n/**\n * Classifies a document-model action as version-relevant (would break\n * documents created with the current version) or safe. `previousSpec` is the\n * last released specification, used to exempt operations added since the\n * release.\n */\nexport function classifyDocumentModelAction(\n action: DocumentModelAction,\n latestSpec: DocumentSpecification,\n previousSpec?: DocumentSpecification,\n): ActionClassification {\n switch (action.type) {\n case \"SET_STATE_SCHEMA\":\n return classifySetStateSchema(action.input, latestSpec);\n case \"SET_INITIAL_STATE\":\n return classifySetInitialState(action.input, latestSpec);\n case \"DELETE_OPERATION\":\n case \"SET_OPERATION_NAME\":\n case \"SET_OPERATION_SCHEMA\":\n return classifyOperationChange(\n action,\n action.input.id,\n latestSpec,\n previousSpec,\n );\n case \"DELETE_MODULE\":\n return classifyDeleteModule(action.input.id, latestSpec, previousSpec);\n default:\n return SAFE;\n }\n}\n\nexport type DispatchDecision =\n | { kind: \"dispatch\" }\n | { kind: \"prompt\"; reason: string; diff?: StateShapeDiff };\n\n/**\n * Pure decision core of the version advisory: given the actions about to be\n * dispatched, decide whether to dispatch immediately or prompt the user.\n */\nexport function decideDispatch(\n actions: DocumentModelAction[],\n latestSpec: DocumentSpecification,\n previousSpec: DocumentSpecification | undefined,\n hasSessionChoice: boolean,\n): DispatchDecision {\n if (hasSessionChoice) return { kind: \"dispatch\" };\n for (const action of actions) {\n const classification = classifyDocumentModelAction(\n action,\n latestSpec,\n previousSpec,\n );\n if (classification.kind === \"version-relevant\") {\n return {\n kind: \"prompt\",\n reason: classification.reason,\n diff: classification.diff,\n };\n }\n }\n return { kind: \"dispatch\" };\n}\n","import type {\n DocumentModelAction,\n DocumentSpecification,\n} from \"@powerhousedao/shared/document-model\";\nimport { releaseNewVersion } from \"@powerhousedao/shared/document-model\";\nimport { useRef, useState } from \"react\";\nimport type { StateShapeDiff } from \"../utils/change-classification.js\";\nimport { decideDispatch } from \"../utils/change-classification.js\";\nimport type { useSelectedDocumentModelDocument } from \"./useDocumentModelDocument.js\";\n\nexport type DocumentModelDispatch = NonNullable<\n ReturnType<typeof useSelectedDocumentModelDocument>[1]\n>;\n\nexport type VersionAdvisoryPrompt = {\n version: number;\n reason: string;\n diff?: StateShapeDiff;\n};\n\n/**\n * Versions the user has confirmed as \"still in development\" (or that were\n * just created via an explicit release) for this browser session. Keyed by\n * `${documentId}:${version}`. Deliberately in-memory: a publisher returning\n * in a later session is asked again, which is when the reminder matters.\n */\nconst sessionVersionChoices = new Set<string>();\n\nexport function useVersionAdvisory(args: {\n documentId: string;\n latestSpec: DocumentSpecification;\n previousSpec?: DocumentSpecification;\n dispatch: DocumentModelDispatch;\n onReleaseError?: (message: string) => void;\n}): {\n guardedDispatch: DocumentModelDispatch;\n prompt: VersionAdvisoryPrompt | undefined;\n releaseFirst: () => void;\n keepEditing: () => void;\n cancelAdvisory: () => void;\n markVersionInDevelopment: (version: number) => void;\n} {\n const { documentId, latestSpec, previousSpec, dispatch, onReleaseError } =\n args;\n const [prompt, setPrompt] = useState<VersionAdvisoryPrompt | undefined>(\n undefined,\n );\n const pendingRef = useRef<Parameters<DocumentModelDispatch> | undefined>(\n undefined,\n );\n const choiceKey = `${documentId}:${latestSpec.version}`;\n\n const guardedDispatch: DocumentModelDispatch = (...dispatchArgs) => {\n const [action] = dispatchArgs;\n const actionList = Array.isArray(action) ? action : [action];\n const actions = actionList.filter(\n (candidate): candidate is DocumentModelAction => candidate !== undefined,\n );\n const decision = decideDispatch(\n actions,\n latestSpec,\n previousSpec,\n sessionVersionChoices.has(choiceKey),\n );\n if (decision.kind === \"dispatch\") {\n dispatch(...dispatchArgs);\n return;\n }\n pendingRef.current = dispatchArgs;\n setPrompt({\n version: latestSpec.version,\n reason: decision.reason,\n diff: decision.diff,\n });\n };\n\n const flushPending = () => {\n const pending = pendingRef.current;\n pendingRef.current = undefined;\n if (pending) {\n dispatch(...pending);\n }\n };\n\n const releaseFirst = () => {\n setPrompt(undefined);\n if (!pendingRef.current) return;\n dispatch(\n releaseNewVersion(),\n (errors) => {\n if (errors.length > 0) {\n pendingRef.current = undefined;\n onReleaseError?.(errors[0].message);\n }\n },\n () => {\n if (!pendingRef.current) return;\n sessionVersionChoices.add(`${documentId}:${latestSpec.version + 1}`);\n flushPending();\n },\n );\n };\n\n const keepEditing = () => {\n sessionVersionChoices.add(choiceKey);\n setPrompt(undefined);\n flushPending();\n };\n\n const cancelAdvisory = () => {\n pendingRef.current = undefined;\n setPrompt(undefined);\n };\n\n const markVersionInDevelopment = (version: number) => {\n sessionVersionChoices.add(`${documentId}:${version}`);\n };\n\n return {\n guardedDispatch,\n prompt,\n releaseFirst,\n keepEditing,\n cancelAdvisory,\n markVersionInDevelopment,\n };\n}\n","import { DocumentToolbar } from \"@powerhousedao/design-system/connect\";\nimport {\n usePHToast,\n useSetPHDocumentEditorConfig,\n} from \"@powerhousedao/reactor-browser\";\nimport { pascalCase } from \"change-case\";\nimport { generateId } from \"@powerhousedao/shared/document-model\";\nimport {\n addModule,\n addOperation,\n addOperationError,\n deleteModule,\n deleteOperation,\n deleteOperationError,\n releaseNewVersion,\n setAuthorName,\n setAuthorWebsite,\n setInitialState,\n setModelDescription,\n setModelExtension,\n setModelId,\n setModelName,\n setModuleName,\n setOperationDescription,\n setOperationErrorName,\n setOperationName,\n setOperationSchema,\n setStateSchema,\n} from \"@powerhousedao/shared/document-model\";\nimport { lazy, Suspense, useEffect, useRef, useState } from \"react\";\nimport { Divider } from \"./components/divider.js\";\nimport ModelMetadata from \"./components/model-metadata-form.js\";\nimport Modules from \"./components/modules.js\";\nimport {\n FrozenVersionBanner,\n VersionControls,\n} from \"./components/version-controls.js\";\nimport { VersionAdvisoryModal } from \"./components/version-advisory-modal.js\";\nimport { editorConfig } from \"./config.js\";\nimport { SchemaContextProvider } from \"./context/schema-context.js\";\nimport { useSelectedDocumentModelDocument } from \"./hooks/useDocumentModelDocument.js\";\nimport { useVersionAdvisory } from \"./hooks/useVersionAdvisory.js\";\nimport type { Scope } from \"./types/documents.js\";\nimport {\n compareStringsWithoutWhitespace,\n initializeModelSchema,\n makeEmptyOperationSchema,\n makeOperationInitialDoc,\n} from \"./utils/helpers.js\";\nconst StateSchemas = lazy(() => import(\"./components/state-schemas.js\"));\n\n// Module-level no-ops so StateSchemas' props are stable across renders while\n// a frozen (non-latest) version is being viewed. They intentionally do\n// nothing: mutating handlers baseline on latestSpec, so if StateSchemas'\n// internal auto-sync effect were to fire while viewing an old version, it\n// would otherwise copy that old version's content into the latest spec.\nconst noopSetStateSchema: (schema: string, scope: Scope) => void = () =>\n undefined;\nconst noopSetInitialState: (initialValue: string, scope: Scope) => void = () =>\n undefined;\n\nexport default function Editor() {\n useSetPHDocumentEditorConfig(editorConfig);\n const toast = usePHToast();\n const [document, dispatch] = useSelectedDocumentModelDocument();\n const [scope, setScope] = useState<Scope>(\"global\");\n const documentNodeName = document.header.name;\n const {\n name: modelName,\n id: documentType,\n extension,\n description,\n author: { name: authorName, website: authorWebsite },\n } = document.state.global;\n const specifications = document.state.global.specifications;\n const latestSpec = specifications[specifications.length - 1];\n const previousSpec =\n specifications.length >= 2\n ? specifications[specifications.length - 2]\n : undefined;\n const [viewedVersion, setViewedVersion] = useState<number | \"latest\">(\n \"latest\",\n );\n const viewedSpec =\n viewedVersion === \"latest\"\n ? latestSpec\n : (specifications.find((spec) => spec.version === viewedVersion) ??\n latestSpec);\n const isViewingFrozenVersion = viewedSpec.version !== latestSpec.version;\n const {\n state: {\n global: {\n schema: globalStateSchema,\n initialValue: globalStateInitialValue,\n },\n local: { schema: localStateSchema, initialValue: localStateInitialValue },\n },\n modules,\n } = viewedSpec;\n const operations = modules.flatMap((module) => module.operations);\n const {\n state: {\n global: {\n schema: latestGlobalStateSchema,\n initialValue: latestGlobalStateInitialValue,\n },\n local: {\n schema: latestLocalStateSchema,\n initialValue: latestLocalStateInitialValue,\n },\n },\n modules: latestModules,\n } = latestSpec;\n const latestOperations = latestModules.flatMap((module) => module.operations);\n const shouldSetInitialName = useRef(\n !modelName && !!documentNodeName && latestOperations.length === 0,\n );\n\n useEffect(() => {\n if (!shouldSetInitialName.current || !documentNodeName) return;\n\n const initialSchemaDoc = initializeModelSchema(documentNodeName);\n const actions = [\n setModelName({ name: documentNodeName }),\n setStateSchema({ schema: initialSchemaDoc, scope: \"global\" }),\n ];\n dispatch(actions);\n shouldSetInitialName.current = false;\n }, [documentNodeName, dispatch]);\n\n const {\n guardedDispatch,\n prompt,\n releaseFirst,\n keepEditing,\n cancelAdvisory,\n markVersionInDevelopment,\n } = useVersionAdvisory({\n documentId: document.header.id,\n latestSpec,\n previousSpec,\n dispatch,\n onReleaseError: (message) => {\n if (toast) toast(message, { type: \"connect-warning\" });\n },\n });\n\n const handleReleaseNewVersion = () => {\n const nextVersion = latestSpec.version + 1;\n dispatch(\n releaseNewVersion(),\n (errors) => {\n if (errors.length > 0 && toast) {\n toast(errors[0].message, { type: \"connect-warning\" });\n }\n },\n () => {\n markVersionInDevelopment(nextVersion);\n setViewedVersion(\"latest\");\n },\n );\n };\n\n const operationSchemasSdl = operations\n .flatMap((operation) => operation.schema ?? [])\n .join(\"\\n\");\n\n const handleSetModelId = (id: string) => {\n if (compareStringsWithoutWhitespace(id, documentType)) return;\n guardedDispatch([setModelId({ id })]);\n };\n\n const handleSetModelDescription = (newDescription: string) => {\n if (compareStringsWithoutWhitespace(newDescription, description)) return;\n guardedDispatch(setModelDescription({ description: newDescription }));\n };\n\n const handleSetModelExtension = (newExtension: string) => {\n if (compareStringsWithoutWhitespace(newExtension, extension)) return;\n guardedDispatch(setModelExtension({ extension: newExtension }));\n };\n\n const handleSetModelName = (newName: string) => {\n if (compareStringsWithoutWhitespace(newName, modelName)) return;\n guardedDispatch(setModelName({ name: newName }));\n };\n\n const handleSetAuthorName = (newAuthorName: string) => {\n if (compareStringsWithoutWhitespace(newAuthorName, authorName)) return;\n guardedDispatch(setAuthorName({ authorName: newAuthorName }));\n };\n\n const handleSetAuthorWebsite = (newAuthorWebsite: string) => {\n if (compareStringsWithoutWhitespace(newAuthorWebsite, authorWebsite ?? \"\"))\n return;\n guardedDispatch(setAuthorWebsite({ authorWebsite: newAuthorWebsite }));\n };\n\n const handleSetStateSchema = (newSchema: string, scope: Scope) => {\n const oldSchema =\n scope === \"global\" ? latestGlobalStateSchema : latestLocalStateSchema;\n if (compareStringsWithoutWhitespace(newSchema, oldSchema)) return;\n guardedDispatch(setStateSchema({ schema: newSchema, scope }));\n };\n\n const handleSetInitialState = (newInitialValue: string, scope: Scope) => {\n const oldInitialValue =\n scope === \"global\"\n ? latestGlobalStateInitialValue\n : latestLocalStateInitialValue;\n if (compareStringsWithoutWhitespace(newInitialValue, oldInitialValue))\n return;\n guardedDispatch(setInitialState({ initialValue: newInitialValue, scope }));\n };\n\n const handleAddModule = (name: string): Promise<string | undefined> => {\n return new Promise((resolve) => {\n try {\n if (\n latestModules.some((module) =>\n compareStringsWithoutWhitespace(module.name, name),\n )\n ) {\n resolve(undefined);\n return;\n }\n const id = generateId();\n guardedDispatch(addModule({ id, name }));\n resolve(id);\n } catch (error) {\n console.error(\"Failed to add module:\", error);\n resolve(undefined);\n }\n });\n };\n\n const handleSetModuleName = (id: string, name: string) => {\n if (\n latestModules.some((module) =>\n compareStringsWithoutWhitespace(module.name, name),\n )\n )\n return;\n guardedDispatch(setModuleName({ id, name }));\n };\n\n const handleDeleteModule = (id: string) => {\n guardedDispatch(deleteModule({ id }));\n };\n\n const handleAddOperation = (\n moduleId: string,\n name: string,\n ): Promise<string | undefined> => {\n return new Promise((resolve) => {\n const id = generateId();\n guardedDispatch(\n addOperation({ id, moduleId, name, scope }),\n (errors) => {\n if (errors.length > 0) {\n if (toast) {\n toast(errors[0].message, { type: \"connect-warning\" });\n }\n resolve(undefined);\n } else {\n resolve(id);\n }\n },\n () => resolve(id),\n );\n });\n };\n\n const handleSetOperationName = (id: string, name: string) => {\n guardedDispatch(setOperationName({ id, name }), (errors) => {\n if (errors.length > 0 && toast) {\n toast(errors[0].message, { type: \"connect-warning\" });\n }\n });\n };\n\n const handleSetOperationSchema = (id: string, newSchema: string) => {\n const operation = latestOperations.find((operation) => operation.id === id);\n if (\n operation?.schema &&\n compareStringsWithoutWhitespace(newSchema, operation.schema)\n )\n return;\n guardedDispatch(setOperationSchema({ id, schema: newSchema }));\n };\n\n const handleToggleNoInputRequired = (\n id: string,\n noInputRequired: boolean,\n ) => {\n const operation = latestOperations.find((op) => op.id === id);\n if (!operation?.name) return;\n\n if (noInputRequired) {\n guardedDispatch(\n setOperationSchema({\n id,\n schema: makeEmptyOperationSchema(operation.name),\n }),\n );\n } else {\n guardedDispatch(\n setOperationSchema({\n id,\n schema: makeOperationInitialDoc(operation.name),\n }),\n );\n }\n };\n\n const handleSetOperationDescription = (\n id: string,\n newDescription: string,\n ) => {\n const operationDescription =\n latestOperations.find((operation) => operation.id === id)?.description ??\n \"\";\n if (compareStringsWithoutWhitespace(operationDescription, newDescription))\n return;\n guardedDispatch(\n setOperationDescription({ id, description: newDescription }),\n );\n };\n\n const handleDeleteOperation = (id: string) => {\n guardedDispatch(deleteOperation({ id }));\n };\n\n const handleAddOperationError = (\n operationId: string,\n errorName: string,\n ): Promise<string | undefined> => {\n return new Promise((resolve) => {\n try {\n const operation = latestOperations.find(\n (operation) => operation.id === operationId,\n );\n const operationErrorNames =\n operation?.errors.map((error) => error.name).filter(Boolean) ?? [];\n if (\n operationErrorNames.some((name) =>\n compareStringsWithoutWhitespace(name, errorName),\n )\n ) {\n resolve(undefined);\n return;\n }\n const id = generateId();\n const errorCode = pascalCase(errorName);\n guardedDispatch(\n addOperationError({ id, operationId, errorName, errorCode }),\n );\n resolve(id);\n } catch (error) {\n console.error(\"Failed to add operation error:\", error);\n resolve(undefined);\n }\n });\n };\n\n const handleDeleteOperationError = (id: string) => {\n guardedDispatch(deleteOperationError({ id }));\n };\n\n const handleSetOperationErrorName = (\n operationId: string,\n errorId: string,\n errorName: string,\n ) => {\n const operation = latestOperations.find(\n (operation) => operation.id === operationId,\n );\n const operationErrorNames =\n operation?.errors.map((error) => error.name).filter(Boolean) ?? [];\n if (\n operationErrorNames.some((name) =>\n compareStringsWithoutWhitespace(name, errorName),\n )\n )\n return;\n guardedDispatch(setOperationErrorName({ id: errorId, errorName }));\n };\n\n const addOperationAndInitialSchema = async (\n moduleId: string,\n name: string,\n ): Promise<string | undefined> => {\n try {\n const id = await handleAddOperation(moduleId, name);\n if (!id) return undefined;\n try {\n handleSetOperationSchema(id, makeOperationInitialDoc(name));\n return id;\n } catch (error) {\n console.error(\"Failed to update operation schema:\", error);\n return undefined;\n }\n } catch (error) {\n console.error(\"Failed to add operation and schema:\", error);\n return undefined;\n }\n };\n\n return (\n <main className=\"min-h-dvh bg-background p-6\">\n <DocumentToolbar />\n <SchemaContextProvider\n globalStateSchemaSdl={globalStateSchema}\n localStateSchemaSdl={localStateSchema}\n operationSchemasSdl={operationSchemasSdl}\n >\n <div className=\"mx-auto max-w-6xl px-4 pt-8\">\n <VersionControls\n specifications={specifications}\n viewedVersion={viewedSpec.version}\n onViewVersion={setViewedVersion}\n onReleaseNewVersion={handleReleaseNewVersion}\n />\n <ModelMetadata\n name={modelName}\n documentType={documentType}\n extension={extension}\n description={description}\n authorName={authorName}\n authorWebsite={authorWebsite ?? \"\"}\n globalStateSchema={latestGlobalStateSchema}\n localStateSchema={latestLocalStateSchema}\n setModelId={handleSetModelId}\n setModelDescription={handleSetModelDescription}\n setModelExtension={handleSetModelExtension}\n setModelName={handleSetModelName}\n setAuthorName={handleSetAuthorName}\n setAuthorWebsite={handleSetAuthorWebsite}\n setStateSchema={handleSetStateSchema}\n />\n <Divider />\n {isViewingFrozenVersion && (\n <FrozenVersionBanner\n latestVersion={latestSpec.version}\n viewedVersion={viewedSpec.version}\n />\n )}\n <div\n className={\n isViewingFrozenVersion\n ? \"pointer-events-none opacity-80 select-none\"\n : undefined\n }\n inert={isViewingFrozenVersion || undefined}\n >\n <Suspense>\n <StateSchemas\n modelName={modelName}\n globalStateSchema={globalStateSchema}\n globalStateInitialValue={globalStateInitialValue}\n localStateSchema={localStateSchema}\n localStateInitialValue={localStateInitialValue}\n setStateSchema={\n isViewingFrozenVersion\n ? noopSetStateSchema\n : handleSetStateSchema\n }\n setInitialState={\n isViewingFrozenVersion\n ? noopSetInitialState\n : handleSetInitialState\n }\n currentScope={scope}\n onScopeChange={setScope}\n />\n </Suspense>\n <Divider />\n <h3 className=\"mb-6 text-lg text-foreground capitalize\">\n {scope} Operations\n </h3>\n <Modules\n modules={modules.map((module) => ({\n ...module,\n operations: module.operations.filter(\n (op) => op.scope === scope,\n ),\n }))}\n allOperations={operations}\n addModule={handleAddModule}\n updateModuleName={handleSetModuleName}\n deleteModule={handleDeleteModule}\n updateOperationName={handleSetOperationName}\n updateOperationSchema={handleSetOperationSchema}\n setOperationDescription={handleSetOperationDescription}\n deleteOperation={handleDeleteOperation}\n addOperationError={handleAddOperationError}\n deleteOperationError={handleDeleteOperationError}\n setOperationErrorName={handleSetOperationErrorName}\n addOperationAndInitialSchema={addOperationAndInitialSchema}\n toggleNoInputRequired={handleToggleNoInputRequired}\n />\n </div>\n </div>\n </SchemaContextProvider>\n <VersionAdvisoryModal\n prompt={prompt}\n onReleaseFirst={releaseFirst}\n onKeepEditing={keepEditing}\n onCancel={cancelAdvisory}\n />\n </main>\n );\n}\n"],"x_google_ignoreList":[0,1,2,4,5,9],"mappings":";;;;;;;;;;;;;;;AAAA,SAASA,IAAE,GAAE;CAAC,IAAI,GAAE,GAAE,IAAE;AAAG,KAAG,YAAU,OAAO,KAAG,YAAU,OAAO,EAAE,MAAG;UAAU,YAAU,OAAO,EAAE,KAAG,MAAM,QAAQ,EAAE,CAAC,MAAI,IAAE,GAAE,IAAE,EAAE,QAAO,IAAI,GAAE,OAAK,IAAEA,IAAE,EAAE,GAAG,MAAI,MAAI,KAAG,MAAK,KAAG;KAAQ,MAAI,KAAK,EAAE,GAAE,OAAK,MAAI,KAAG,MAAK,KAAG;AAAG,QAAO;;AAAE,SAAgB,OAAM;AAAC,MAAI,IAAI,GAAE,GAAE,IAAE,GAAE,IAAE,IAAG,IAAE,UAAU,QAAQ,EAAC,IAAE,UAAU,UAAQ,IAAEA,IAAE,EAAE,MAAI,MAAI,KAAG,MAAK,KAAG;AAAG,QAAO;;;;ACChW,MAAM,iBAAiB,UAAQ,OAAO,UAAU,YAAY,GAAG,OAAO,MAAM,GAAG,UAAU,IAAI,MAAM;AACnG,MAAa,KAAK;AAClB,MAAa,OAAO,MAAM,WAAS;AAC/B,SAAQ,UAAQ;EACZ,IAAI;AACJ,OAAK,WAAW,QAAQ,WAAW,KAAK,IAAI,KAAK,IAAI,OAAO,aAAa,KAAM,QAAO,GAAG,MAAM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AAA;MAEJ,qBAAC,OAAD;OACE,WACE,yBACI,+CACA,KAAA;OAEN,OAAO,0BAA0B,KAAA;iBANnC;QAQE,oBAAC,UAAD,EAAA,UACE,oBAAC,cAAD;SACa;SACQ;SACM;SACP;SACM;SACxB,gBACE,yBACI,qBACA;SAEN,iBACE,yBACI,sBACA;SAEN,cAAc;SACd,eAAe;SACf,CAAA,EACO,CAAA;QACX,oBAAC,SAAD,EAAW,CAAA;QACX,qBAAC,MAAD;SAAI,WAAU;mBAAd,CACG,OAAM,cACJ;;QACL,oBAAC,SAAD;SACE,SAAS,QAAQ,KAAK,YAAY;UAChC,GAAG;UACH,YAAY,OAAO,WAAW,QAC3B,OAAO,GAAG,UAAU,MACtB;UACF,EAAE;SACH,eAAe;SACf,WAAW;SACX,kBAAkB;SAClB,cAAc;SACd,qBAAqB;SACrB,uBAAuB;SACvB,yBAAyB;SACzB,iBAAiB;SACjB,mBAAmB;SACnB,sBAAsB;SACtB,uBAAuB;SACO;SAC9B,uBAAuB;SACvB,CAAA;QACE;;MACF;;IACgB,CAAA;GACxB,oBAAC,sBAAD;IACU;IACR,gBAAgB;IAChB,eAAe;IACf,UAAU;IACV,CAAA;GACG"}
|
|
1
|
+
{"version":3,"file":"editor-CQ4wUFK5.js","names":["r","e","s","i","t","n","o","r","e","Label","React","React","LabelPrimitive.Root","React","zodResolver","compactButtonStyle"],"sources":["../../../../node_modules/.pnpm/clsx@2.0.0/node_modules/clsx/dist/clsx.mjs","../../../../node_modules/.pnpm/class-variance-authority@0.7.0/node_modules/class-variance-authority/dist/index.mjs","../../../../node_modules/.pnpm/react-hook-form@7.71.2_react@19.2.6/node_modules/react-hook-form/dist/index.esm.mjs","../../editors/document-model-editor/components/divider.tsx","../../../../node_modules/.pnpm/@hookform+resolvers@5.2.2_react-hook-form@7.71.2_react@19.2.6_/node_modules/@hookform/resolvers/dist/resolvers.mjs","../../../../node_modules/.pnpm/@hookform+resolvers@5.2.2_react-hook-form@7.71.2_react@19.2.6_/node_modules/@hookform/resolvers/zod/dist/zod.mjs","../../editors/document-model-editor/schemas/inputs.ts","../../editors/document-model-editor/context/form-context.ts","../../editors/document-model-editor/hooks/useFormField.ts","../../../../node_modules/.pnpm/@radix-ui+react-label@2.1.8_@types+react-dom@19.2.3_@types+react@19.2.14__@types+react@_8d35ec453e0b59eefe06771bb1432577/node_modules/@radix-ui/react-label/dist/index.mjs","../../editors/document-model-editor/components/label.tsx","../../editors/document-model-editor/components/form.tsx","../../editors/document-model-editor/components/text-area.tsx","../../editors/document-model-editor/components/text-field.tsx","../../editors/document-model-editor/components/model-metadata-form.tsx","../../editors/document-model-editor/components/module-form.tsx","../../editors/document-model-editor/components/operation-form.tsx","../../editors/document-model-editor/components/operation-description-form.tsx","../../editors/document-model-editor/components/operation-error-form.tsx","../../editors/document-model-editor/components/operation-errors.tsx","../../editors/document-model-editor/components/operation.tsx","../../editors/document-model-editor/components/operations.tsx","../../editors/document-model-editor/components/module.tsx","../../editors/document-model-editor/components/modules.tsx","../../editors/document-model-editor/components/version-controls.tsx","../../editors/document-model-editor/components/version-advisory-modal.tsx","../../editors/document-model-editor/config.ts","../../editors/document-model-editor/hooks/useDocumentModelDocument.ts","../../editors/document-model-editor/utils/change-classification.ts","../../editors/document-model-editor/hooks/useVersionAdvisory.ts","../../editors/document-model-editor/editor.tsx"],"sourcesContent":["function r(e){var t,f,n=\"\";if(\"string\"==typeof e||\"number\"==typeof e)n+=e;else if(\"object\"==typeof e)if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=\" \"),n+=f);else for(t in e)e[t]&&(n&&(n+=\" \"),n+=t);return n}export function clsx(){for(var e,t,f=0,n=\"\";f<arguments.length;)(e=arguments[f++])&&(t=r(e))&&(n&&(n+=\" \"),n+=t);return n}export default clsx;","import { clsx } from \"clsx\";\nconst falsyToString = (value)=>typeof value === \"boolean\" ? \"\".concat(value) : value === 0 ? \"0\" : value;\nexport const cx = clsx;\nexport const cva = (base, config)=>{\n return (props)=>{\n var ref;\n if ((config === null || config === void 0 ? void 0 : config.variants) == null) return cx(base, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);\n const { variants , defaultVariants } = config;\n const getVariantClassNames = Object.keys(variants).map((variant)=>{\n const variantProp = props === null || props === void 0 ? void 0 : props[variant];\n const defaultVariantProp = defaultVariants === null || defaultVariants === void 0 ? void 0 : defaultVariants[variant];\n if (variantProp === null) return null;\n const variantKey = falsyToString(variantProp) || falsyToString(defaultVariantProp);\n return variants[variant][variantKey];\n });\n const propsWithoutUndefined = props && Object.entries(props).reduce((acc, param)=>{\n let [key, value] = param;\n if (value === undefined) {\n return acc;\n }\n acc[key] = value;\n return acc;\n }, {});\n const getCompoundVariantClassNames = config === null || config === void 0 ? void 0 : (ref = config.compoundVariants) === null || ref === void 0 ? void 0 : ref.reduce((acc, param1)=>{\n let { class: cvClass , className: cvClassName , ...compoundVariantOptions } = param1;\n return Object.entries(compoundVariantOptions).every((param)=>{\n let [key, value] = param;\n return Array.isArray(value) ? value.includes({\n ...defaultVariants,\n ...propsWithoutUndefined\n }[key]) : ({\n ...defaultVariants,\n ...propsWithoutUndefined\n })[key] === value;\n }) ? [\n ...acc,\n cvClass,\n cvClassName\n ] : acc;\n }, []);\n return cx(base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);\n };\n};\n\n\n//# sourceMappingURL=index.mjs.map","import React from 'react';\n\nvar isCheckBoxInput = (element) => element.type === 'checkbox';\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 : event.target.value\n : event;\n\nvar getNodeParentName = (name) => name.substring(0, name.search(/\\.\\d+(\\.|$)/)) || name;\n\nvar isNameInFieldArray = (names, name) => names.has(getNodeParentName(name));\n\nvar isPlainObject = (tempObject) => {\n const prototypeCopy = tempObject.constructor && tempObject.constructor.prototype;\n return (isObject(prototypeCopy) && prototypeCopy.hasOwnProperty('isPrototypeOf'));\n};\n\nvar isWeb = typeof window !== 'undefined' &&\n typeof window.HTMLElement !== 'undefined' &&\n typeof document !== 'undefined';\n\nfunction cloneObject(data) {\n if (data instanceof Date) {\n return new Date(data);\n }\n const isFileListInstance = typeof FileList !== 'undefined' && data instanceof FileList;\n if (isWeb && (data instanceof Blob || isFileListInstance)) {\n return data;\n }\n const isArray = Array.isArray(data);\n if (!isArray && !(isObject(data) && isPlainObject(data))) {\n return data;\n }\n const copy = isArray ? [] : Object.create(Object.getPrototypeOf(data));\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\nvar isKey = (value) => /^\\w*$/.test(value);\n\nvar isUndefined = (val) => val === undefined;\n\nvar compact = (value) => Array.isArray(value) ? value.filter(Boolean) : [];\n\nvar stringToPath = (input) => compact(input.replace(/[\"|']|\\]/g, '').split(/\\.|\\[/));\n\nvar get = (object, path, defaultValue) => {\n if (!path || !isObject(object)) {\n return defaultValue;\n }\n const result = (isKey(path) ? [path] : stringToPath(path)).reduce((result, key) => isNullOrUndefined(result) ? result : result[key], 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 (key === '__proto__' || key === 'constructor' || key === 'prototype') {\n return;\n }\n object[key] = newValue;\n object = object[key];\n }\n};\n\nconst EVENTS = {\n BLUR: 'blur',\n FOCUS_OUT: 'focusout',\n CHANGE: 'change',\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};\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 defaultValues: control._defaultValues,\n };\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 = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;\n\n/**\n * This custom hook allows you to subscribe to each form state, and isolate the re-render at the custom hook level. It has its scope in terms of form state subscription, so it would not affect other useFormState and useForm. Using this hook can reduce the re-render impact on large and complex form application.\n *\n * @remarks\n * [API](https://react-hook-form.com/docs/useformstate) • [Demo](https://codesandbox.io/s/useformstate-75xly)\n *\n * @param props - include options on specify fields to subscribe. {@link UseFormStateReturn}\n *\n * @example\n * ```tsx\n * function App() {\n * const { register, handleSubmit, control } = useForm({\n * defaultValues: {\n * firstName: \"firstName\"\n * }});\n * const { dirtyFields } = useFormState({\n * control\n * });\n * const onSubmit = (data) => console.log(data);\n *\n * return (\n * <form onSubmit={handleSubmit(onSubmit)}>\n * <input {...register(\"firstName\")} placeholder=\"First Name\" />\n * {dirtyFields.firstName && <p>Field is dirty.</p>}\n * <input type=\"submit\" />\n * </form>\n * );\n * }\n * ```\n */\nfunction useFormState(props) {\n const formControl = useFormControlContext();\n const { control = formControl, disabled, name, exact } = props || {};\n const [formState, updateFormState] = React.useState(control._formState);\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 useIsomorphicLayoutEffect(() => control._subscribe({\n name,\n formState: _localProxyFormState.current,\n exact,\n callback: (formState) => {\n !disabled &&\n updateFormState({\n ...control._formState,\n ...formState,\n });\n },\n }), [name, disabled, exact]);\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)));\n }\n isGlobal && (_names.watchAll = true);\n return formValues;\n};\n\nvar isPrimitive = (value) => isNullOrUndefined(value) || !isObjectType(value);\n\nfunction deepEqual(object1, object2, _internal_visited = new WeakSet()) {\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 const keys1 = Object.keys(object1);\n const keys2 = Object.keys(object2);\n if (keys1.length !== keys2.length) {\n return false;\n }\n if (_internal_visited.has(object1) || _internal_visited.has(object2)) {\n return true;\n }\n _internal_visited.add(object1);\n _internal_visited.add(object2);\n for (const key of keys1) {\n const val1 = object1[key];\n if (!keys2.includes(key)) {\n return false;\n }\n if (key !== 'ref') {\n const val2 = object2[key];\n if ((isDateObject(val1) && isDateObject(val2)) ||\n (isObject(val1) && isObject(val2)) ||\n (Array.isArray(val1) && Array.isArray(val2))\n ? !deepEqual(val1, val2, _internal_visited)\n : !Object.is(val1, val2)) {\n return false;\n }\n }\n }\n return true;\n}\n\n/**\n * Custom hook to subscribe to field change and isolate re-rendering at the component level.\n *\n * @remarks\n *\n * [API](https://react-hook-form.com/docs/usewatch) • [Demo](https://codesandbox.io/s/react-hook-form-v7-ts-usewatch-h9i5e)\n *\n * @example\n * ```tsx\n * const { control } = useForm();\n * const values = useWatch({\n * name: \"fieldName\"\n * control,\n * })\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 _computeFormValues = React.useRef(undefined);\n const _prevControl = React.useRef(control);\n const _prevName = React.useRef(name);\n _compute.current = compute;\n const [value, updateValue] = React.useState(() => {\n const defaultValue = control._getWatch(name, _defaultValue.current);\n return _compute.current ? _compute.current(defaultValue) : defaultValue;\n });\n const getCurrentOutput = React.useCallback((values) => {\n const formValues = generateWatchOutput(name, control._names, values || control._formValues, false, _defaultValue.current);\n return _compute.current ? _compute.current(formValues) : 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 useIsomorphicLayoutEffect(() => {\n if (_prevControl.current !== control ||\n !deepEqual(_prevName.current, name)) {\n _prevControl.current = control;\n _prevName.current = name;\n refreshValue();\n }\n return control._subscribe({\n name,\n formState: {\n values: true,\n },\n exact,\n callback: (formState) => {\n refreshValue(formState.values);\n },\n });\n }, [control, exact, name, refreshValue]);\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 // Cache the computed output to avoid duplicate calls within the same render\n // We include shouldReturnImmediate in deps to ensure proper recomputation\n const computedOutput = React.useMemo(() => {\n if (disabled) {\n return null;\n }\n const nameChanged = !controlChanged && !deepEqual(prevName, name);\n const shouldReturnImmediate = controlChanged || nameChanged;\n return shouldReturnImmediate ? getCurrentOutput() : null;\n }, [disabled, controlChanged, name, prevName, getCurrentOutput]);\n return computedOutput !== null ? computedOutput : value;\n}\n\n/**\n * Custom hook to work with controlled component, this function provide you with both form and field level state. Re-render is isolated at the hook level.\n *\n * @remarks\n * [API](https://react-hook-form.com/docs/usecontroller) • [Demo](https://codesandbox.io/s/usecontroller-0o8px)\n *\n * @param props - the path name to the form field value, and validation rules.\n *\n * @returns field properties, field and form state. {@link UseControllerReturn}\n *\n * @example\n * ```tsx\n * function Input(props) {\n * const { field, fieldState, formState } = useController(props);\n * return (\n * <div>\n * <input {...field} placeholder={props.name} />\n * <p>{fieldState.isTouched && \"Touched\"}</p>\n * <p>{formState.isSubmitted ? \"submitted\" : \"\"}</p>\n * </div>\n * );\n * }\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(() => get(control._formValues, name, get(control._defaultValues, name, defaultValue)), [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 _previousNameRef = React.useRef(undefined);\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) => _registerProps.current.onChange({\n target: {\n value: getEventValue(event),\n name: name,\n },\n type: EVENTS.CHANGE,\n }), [name]);\n const onBlur = React.useCallback(() => _registerProps.current.onBlur({\n target: {\n value: get(control._formValues, name),\n name: name,\n },\n type: EVENTS.BLUR,\n }), [name, control._formValues]);\n const ref = React.useCallback((elm) => {\n const field = get(control._fields, name);\n if (field && field._f && elm) {\n field._f.ref = {\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 }, [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 const previousName = _previousNameRef.current;\n if (previousName && previousName !== name && !isArrayField) {\n control.unregister(previousName);\n }\n 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 }\n };\n updateMounted(name, true);\n if (_shouldUnregisterField) {\n const value = cloneObject(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 && control.register(name);\n _previousNameRef.current = name;\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 based on `useController` hook to work with controlled component.\n *\n * @remarks\n * [API](https://react-hook-form.com/docs/usecontroller/controller) • [Demo](https://codesandbox.io/s/react-hook-form-v6-controller-ts-jwyzw) • [Video](https://www.youtube.com/watch?v=N2UNk_UCVyA)\n *\n * @param props - the path name to the form field value, and validation rules.\n *\n * @returns provide field handler functions, field and form state.\n *\n * @example\n * ```tsx\n * function App() {\n * const { control } = useForm<FormValues>({\n * defaultValues: {\n * test: \"\"\n * }\n * });\n *\n * return (\n * <form>\n * <Controller\n * control={control}\n * name=\"test\"\n * render={({ field: { onChange, onBlur, value, ref }, formState, fieldState }) => (\n * <>\n * <input\n * onChange={onChange} // send value to hook form\n * onBlur={onBlur} // notify when input is touched\n * value={value} // return updated value\n * ref={ref} // set ref for focus management\n * />\n * <p>{formState.isSubmitted ? \"submitted\" : \"\"}</p>\n * <p>{fieldState.isTouched ? \"touched\" : \"\"}</p>\n * </>\n * )}\n * />\n * </form>\n * );\n * }\n * ```\n */\nconst Controller = (props) => props.render(useController(props));\n\nconst flatten = (obj) => {\n const output = {};\n for (const key of Object.keys(obj)) {\n if (isObjectType(obj[key]) && obj[key] !== null) {\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\nconst HookFormContext = React.createContext(null);\nHookFormContext.displayName = 'HookFormContext';\n/**\n * This custom hook allows you to access the form context. useFormContext is intended to be used in deeply nested structures, where it would become inconvenient to pass the context as a prop. To be used with {@link FormProvider}.\n *\n * @remarks\n * [API](https://react-hook-form.com/docs/useformcontext) • [Demo](https://codesandbox.io/s/react-hook-form-v7-form-context-ytudi)\n *\n * @returns return all useForm methods\n *\n * @example\n * ```tsx\n * function App() {\n * const methods = useForm();\n * const onSubmit = data => console.log(data);\n *\n * return (\n * <FormProvider {...methods} >\n * <form onSubmit={methods.handleSubmit(onSubmit)}>\n * <NestedInput />\n * <input type=\"submit\" />\n * </form>\n * </FormProvider>\n * );\n * }\n *\n * function NestedInput() {\n * const { register } = useFormContext(); // retrieve all hook methods\n * return <input {...register(\"test\")} />;\n * }\n * ```\n */\nconst useFormContext = () => React.useContext(HookFormContext);\n/**\n * A provider component that propagates the `useForm` methods to all children components via [React Context](https://react.dev/reference/react/useContext) API. To be used with {@link useFormContext}.\n *\n * @remarks\n * [API](https://react-hook-form.com/docs/useformcontext) • [Demo](https://codesandbox.io/s/react-hook-form-v7-form-context-ytudi)\n *\n * @param props - all useForm methods\n *\n * @example\n * ```tsx\n * function App() {\n * const methods = useForm();\n * const onSubmit = data => console.log(data);\n *\n * return (\n * <FormProvider {...methods} >\n * <form onSubmit={methods.handleSubmit(onSubmit)}>\n * <NestedInput />\n * <input type=\"submit\" />\n * </form>\n * </FormProvider>\n * );\n * }\n *\n * function NestedInput() {\n * const { register } = useFormContext(); // retrieve all hook methods\n * return <input {...register(\"test\")} />;\n * }\n * ```\n */\nconst FormProvider = (props) => {\n const { children, watch, getValues, getFieldState, setError, clearErrors, setValue, trigger, formState, resetField, reset, handleSubmit, unregister, control, register, setFocus, subscribe, } = props;\n return (React.createElement(HookFormContext.Provider, { value: React.useMemo(() => ({\n watch,\n getValues,\n getFieldState,\n setError,\n clearErrors,\n setValue,\n trigger,\n formState,\n resetField,\n reset,\n handleSubmit,\n unregister,\n control,\n register,\n setFocus,\n subscribe,\n }), [\n clearErrors,\n control,\n formState,\n getFieldState,\n getValues,\n handleSubmit,\n register,\n reset,\n resetField,\n setError,\n setFocus,\n setValue,\n subscribe,\n trigger,\n unregister,\n watch,\n ]) },\n React.createElement(HookFormControlContext.Provider, { value: control }, children)));\n};\n\nconst POST_REQUEST = 'post';\n/**\n * Form component to manage submission.\n *\n * @param props - to setup submission detail. {@link FormProps}\n *\n * @returns form component or headless render prop.\n *\n * @example\n * ```tsx\n * function App() {\n * const { control, formState: { errors } } = useForm();\n *\n * return (\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 * }\n * ```\n */\nfunction Form(props) {\n const methods = useFormContext();\n const [mounted, setMounted] = React.useState(false);\n const { control = methods.control, onSubmit, children, action, method = POST_REQUEST, headers, encType, onError, render, onSuccess, validateStatus, ...rest } = props;\n const submit = async (event) => {\n let hasError = false;\n let type = '';\n await control.handleSubmit(async (data) => {\n const formData = new FormData();\n let formDataJson = '';\n try {\n formDataJson = JSON.stringify(data);\n }\n catch (_a) { }\n const flattenFormValues = flatten(control._formValues);\n for (const key in flattenFormValues) {\n formData.append(key, flattenFormValues[key]);\n }\n if (onSubmit) {\n await onSubmit({\n data,\n event,\n method,\n formData,\n formDataJson,\n });\n }\n if (action) {\n try {\n const shouldStringifySubmissionData = [\n headers && headers['Content-Type'],\n encType,\n ].some((value) => value && value.includes('json'));\n const response = await fetch(String(action), {\n method,\n headers: {\n ...headers,\n ...(encType && encType !== 'multipart/form-data'\n ? { 'Content-Type': encType }\n : {}),\n },\n body: shouldStringifySubmissionData ? formDataJson : formData,\n });\n if (response &&\n (validateStatus\n ? !validateStatus(response.status)\n : response.status < 200 || response.status >= 300)) {\n hasError = true;\n onError && onError({ response });\n type = String(response.status);\n }\n else {\n onSuccess && onSuccess({ response });\n }\n }\n catch (error) {\n hasError = true;\n onError && onError({ error });\n }\n }\n })(event);\n if (hasError && props.control) {\n props.control._subjects.state.next({\n isSubmitSuccessful: false,\n });\n props.control.setError('root.server', {\n type,\n });\n }\n };\n React.useEffect(() => {\n setMounted(true);\n }, []);\n return render ? (React.createElement(React.Fragment, null, render({\n submit,\n }))) : (React.createElement(\"form\", { noValidate: mounted, action: action, method: method, encType: encType, onSubmit: submit, ...rest }, children));\n}\n\nconst FormStateSubscribe = ({ control, disabled, exact, name, render, }) => render(useFormState({ control, name, disabled, exact }));\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\nvar convertToArrayPayload = (value) => (Array.isArray(value) ? value : [value]);\n\nvar createSubject = () => {\n let _observers = [];\n const next = (value) => {\n for (const observer of _observers) {\n observer.next && observer.next(value);\n }\n };\n const subscribe = (observer) => {\n _observers.push(observer);\n return {\n unsubscribe: () => {\n _observers = _observers.filter((o) => o !== observer);\n },\n };\n };\n const unsubscribe = () => {\n _observers = [];\n };\n return {\n get observers() {\n return _observers;\n },\n next,\n subscribe,\n unsubscribe,\n };\n};\n\nfunction extractFormValues(fieldsState, formValues) {\n const values = {};\n for (const key in fieldsState) {\n if (fieldsState.hasOwnProperty(key)) {\n const fieldState = fieldsState[key];\n const fieldValue = formValues[key];\n if (fieldState && isObject(fieldState) && fieldValue) {\n const nestedFieldsState = extractFormValues(fieldState, fieldValue);\n if (isObject(nestedFieldsState)) {\n values[key] = nestedFieldsState;\n }\n }\n else if (fieldsState[key]) {\n values[key] = fieldValue;\n }\n }\n }\n return values;\n}\n\nvar isEmptyObject = (value) => isObject(value) && !Object.keys(value).length;\n\nvar isFileInput = (element) => element.type === 'file';\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 isMultipleSelect = (element) => element.type === `select-multiple`;\n\nvar isRadioInput = (element) => element.type === 'radio';\n\nvar isRadioOrCheckbox = (ref) => isRadioInput(ref) || isCheckBoxInput(ref);\n\nvar live = (ref) => isHTMLElement(ref) && ref.isConnected;\n\nfunction baseGet(object, updatePath) {\n const length = updatePath.slice(0, -1).length;\n let index = 0;\n while (index < length) {\n object = isUndefined(object) ? index++ : object[updatePath[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 const paths = Array.isArray(path)\n ? path\n : isKey(path)\n ? [path]\n : stringToPath(path);\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 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 markFieldsDirty(data, fields = {}) {\n for (const key in data) {\n const value = data[key];\n if (isTraversable(value)) {\n fields[key] = Array.isArray(value) ? [] : {};\n markFieldsDirty(value, fields[key]);\n }\n else if (!isUndefined(value)) {\n fields[key] = true;\n }\n }\n return fields;\n}\nfunction getDirtyFields(data, formValues, dirtyFieldsFromValues) {\n if (!dirtyFieldsFromValues) {\n dirtyFieldsFromValues = markFieldsDirty(formValues);\n }\n for (const key in data) {\n const value = data[key];\n if (isTraversable(value)) {\n if (isUndefined(formValues) || isPrimitive(dirtyFieldsFromValues[key])) {\n dirtyFieldsFromValues[key] = markFieldsDirty(value, Array.isArray(value) ? [] : {});\n }\n else {\n getDirtyFields(value, isNullOrUndefined(formValues) ? {} : formValues[key], dirtyFieldsFromValues[key]);\n }\n }\n else {\n const formValue = formValues[key];\n dirtyFieldsFromValues[key] = !deepEqual(value, formValue);\n }\n }\n return dirtyFieldsFromValues;\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 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 return options[0].checked && !options[0].disabled\n ? // @ts-expect-error expected to work in the browser\n options[0].attributes && !isUndefined(options[0].attributes.value)\n ? isUndefined(options[0].value) || options[0].value === ''\n ? validResult\n : { value: options[0].value, isValid: true }\n : validResult\n : defaultResult;\n }\n return defaultResult;\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\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 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(isUndefined(ref.value) ? _f.ref.value : 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 isRegex = (value) => value instanceof RegExp;\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\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\nconst ASYNC_FUNCTION = 'AsyncFunction';\nvar hasPromiseValidation = (fieldReference) => !!fieldReference &&\n !!fieldReference.validate &&\n !!((isFunction(fieldReference.validate) &&\n fieldReference.validate.constructor.name === ASYNC_FUNCTION) ||\n (isObject(fieldReference.validate) &&\n Object.values(fieldReference.validate).find((validateFunction) => validateFunction.constructor.name === ASYNC_FUNCTION)));\n\nvar hasValidation = (options) => options.mount &&\n (options.required ||\n options.min ||\n options.max ||\n options.maxLength ||\n options.minLength ||\n options.pattern ||\n options.validate);\n\nvar isWatched = (name, _names, isBlurEvent) => !isBlurEvent &&\n (_names.watchAll ||\n _names.watch.has(name) ||\n [..._names.watch].some((watchName) => name.startsWith(watchName) &&\n /^\\.\\w+/.test(name.slice(watchName.length))));\n\nconst iterateFieldsByAction = (fields, action, fieldsNames, abortEarly) => {\n for (const key of fieldsNames || Object.keys(fields)) {\n const field = get(fields, key);\n if (field) {\n const { _f, ...currentField } = field;\n if (_f) {\n if (_f.refs && _f.refs[0] && action(_f.refs[0], key) && !abortEarly) {\n return true;\n }\n else if (_f.ref && action(_f.ref, _f.name) && !abortEarly) {\n return true;\n }\n else {\n if (iterateFieldsByAction(currentField, action)) {\n break;\n }\n }\n }\n else if (isObject(currentField)) {\n if (iterateFieldsByAction(currentField, action)) {\n break;\n }\n }\n }\n }\n return;\n};\n\nfunction schemaErrorLookup(errors, _fields, name) {\n const error = get(errors, name);\n if (error || isKey(name)) {\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, updateFormState, isRoot) => {\n updateFormState(formStateData);\n const { name, ...formState } = formStateData;\n return (isEmptyObject(formState) ||\n Object.keys(formState).length >= Object.keys(_proxyFormState).length ||\n Object.keys(formState).find((key) => _proxyFormState[key] ===\n (!isRoot || VALIDATION_MODE.all)));\n};\n\nvar shouldSubscribeByName = (name, signalName, exact) => !name ||\n !signalName ||\n name === signalName ||\n convertToArrayPayload(name).some((currentName) => currentName &&\n (exact\n ? currentName === signalName\n : currentName.startsWith(signalName) ||\n signalName.startsWith(currentName)));\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) => !compact(get(ref, name)).length && unset(ref, name);\n\nvar updateFieldArrayRootError = (errors, error, name) => {\n const fieldArrayErrors = convertToArrayPayload(get(errors, name));\n set(fieldArrayErrors, 'root', error[name]);\n set(errors, name, fieldArrayErrors);\n return errors;\n};\n\nfunction getValidateError(result, ref, type = 'validate') {\n if (isString(result) ||\n (Array.isArray(result) && 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, } = 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 inputRef.setCustomValidity(isBoolean(message) ? '' : message || '');\n inputRef.reportValidity();\n }\n };\n const error = {};\n const isRadio = isRadioInput(ref);\n const isCheckBox = 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 === '') ||\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) && !isNaN(inputValue)) {\n const valueNumber = 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 = ref.valueAsDate || 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 ((maxLength || 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 setCustomValidity(validateError.message);\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 setCustomValidity(true);\n return error;\n};\n\nconst defaultOptions = {\n mode: VALIDATION_MODE.onSubmit,\n reValidateMode: VALIDATION_MODE.onChange,\n shouldFocusError: true,\n};\nfunction createFormControl(props = {}) {\n let _options = {\n ...defaultOptions,\n ...props,\n };\n let _formState = {\n submitCount: 0,\n isDirty: false,\n isReady: false,\n isLoading: isFunction(_options.defaultValues),\n isValidating: false,\n isSubmitted: false,\n isSubmitting: false,\n isSubmitSuccessful: false,\n isValid: false,\n touchedFields: {},\n dirtyFields: {},\n validatingFields: {},\n errors: _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 mount: false,\n watch: false,\n keepIsValid: false,\n };\n let _names = {\n mount: new Set(),\n disabled: new Set(),\n unMount: new Set(),\n array: new Set(),\n watch: new Set(),\n };\n let delayErrorCallback;\n let timer = 0;\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 let _proxySubscribeFormState = {\n ..._proxyFormState,\n };\n const _subjects = {\n array: createSubject(),\n state: createSubject(),\n };\n const shouldDisplayAllAssociatedErrors = _options.criteriaMode === VALIDATION_MODE.all;\n const debounce = (callback) => (wait) => {\n clearTimeout(timer);\n timer = setTimeout(callback, wait);\n };\n const _setValid = async (shouldUpdateValid) => {\n if (_state.keepIsValid) {\n return;\n }\n if (!_options.disabled &&\n (_proxyFormState.isValid ||\n _proxySubscribeFormState.isValid ||\n shouldUpdateValid)) {\n let isValid;\n if (_options.resolver) {\n isValid = isEmptyObject((await _runSchema()).errors);\n _updateIsValidating();\n }\n else {\n isValid = await executeBuiltInValidation(_fields, true);\n }\n if (isValid !== _formState.isValid) {\n _subjects.state.next({\n isValid,\n });\n }\n }\n };\n const _updateIsValidating = (names, isValidating) => {\n if (!_options.disabled &&\n (_proxyFormState.isValidating ||\n _proxyFormState.validatingFields ||\n _proxySubscribeFormState.isValidating ||\n _proxySubscribeFormState.validatingFields)) {\n (names || Array.from(_names.mount)).forEach((name) => {\n if (name) {\n isValidating\n ? set(_formState.validatingFields, name, isValidating)\n : unset(_formState.validatingFields, name);\n }\n });\n _subjects.state.next({\n validatingFields: _formState.validatingFields,\n isValidating: !isEmptyObject(_formState.validatingFields),\n });\n }\n };\n const _setFieldArray = (name, values = [], method, args, shouldSetValues = true, shouldUpdateFieldsAndState = true) => {\n if (args && method && !_options.disabled) {\n _state.action = true;\n if (shouldUpdateFieldsAndState && Array.isArray(get(_fields, name))) {\n const fieldValues = method(get(_fields, name), args.argA, args.argB);\n shouldSetValues && set(_fields, name, fieldValues);\n }\n if (shouldUpdateFieldsAndState &&\n Array.isArray(get(_formState.errors, name))) {\n const errors = method(get(_formState.errors, name), args.argA, args.argB);\n shouldSetValues && set(_formState.errors, name, errors);\n unsetEmptyArray(_formState.errors, name);\n }\n if ((_proxyFormState.touchedFields ||\n _proxySubscribeFormState.touchedFields) &&\n shouldUpdateFieldsAndState &&\n Array.isArray(get(_formState.touchedFields, name))) {\n const touchedFields = method(get(_formState.touchedFields, name), args.argA, args.argB);\n shouldSetValues && set(_formState.touchedFields, name, touchedFields);\n }\n if (_proxyFormState.dirtyFields || _proxySubscribeFormState.dirtyFields) {\n _formState.dirtyFields = getDirtyFields(_defaultValues, _formValues);\n }\n _subjects.state.next({\n name,\n isDirty: _getDirty(name, values),\n dirtyFields: _formState.dirtyFields,\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 _subjects.state.next({\n errors: _formState.errors,\n });\n };\n const _setErrors = (errors) => {\n _formState.errors = errors;\n _subjects.state.next({\n errors: _formState.errors,\n isValid: false,\n });\n };\n const updateValidAndValue = (name, shouldSkipSetValueAs, value, ref) => {\n const field = get(_fields, name);\n if (field) {\n const defaultValue = get(_formValues, name, isUndefined(value) ? get(_defaultValues, name) : value);\n isUndefined(defaultValue) ||\n (ref && ref.defaultChecked) ||\n shouldSkipSetValueAs\n ? set(_formValues, name, shouldSkipSetValueAs ? defaultValue : getFieldValue(field._f))\n : setFieldValue(name, defaultValue);\n _state.mount && !_state.action && _setValid();\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) {\n if (!isBlurEvent || shouldDirty) {\n if (_proxyFormState.isDirty || _proxySubscribeFormState.isDirty) {\n isPreviousDirty = _formState.isDirty;\n _formState.isDirty = output.isDirty = _getDirty();\n shouldUpdateField = isPreviousDirty !== output.isDirty;\n }\n const isCurrentFieldPristine = deepEqual(get(_defaultValues, name), fieldValue);\n isPreviousDirty = !!get(_formState.dirtyFields, name);\n isCurrentFieldPristine\n ? unset(_formState.dirtyFields, name)\n : set(_formState.dirtyFields, name, true);\n output.dirtyFields = _formState.dirtyFields;\n shouldUpdateField =\n shouldUpdateField ||\n ((_proxyFormState.dirtyFields ||\n _proxySubscribeFormState.dirtyFields) &&\n isPreviousDirty !== !isCurrentFieldPristine);\n }\n if (isBlurEvent) {\n const isPreviousFieldTouched = get(_formState.touchedFields, name);\n if (!isPreviousFieldTouched) {\n set(_formState.touchedFields, name, isBlurEvent);\n output.touchedFields = _formState.touchedFields;\n shouldUpdateField =\n shouldUpdateField ||\n ((_proxyFormState.touchedFields ||\n _proxySubscribeFormState.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 = (_proxyFormState.isValid || _proxySubscribeFormState.isValid) &&\n isBoolean(isValid) &&\n _formState.isValid !== isValid;\n if (_options.delayError && error) {\n delayErrorCallback = debounce(() => updateErrors(name, error));\n delayErrorCallback(_options.delayError);\n }\n else {\n clearTimeout(timer);\n delayErrorCallback = null;\n error\n ? set(_formState.errors, name, error)\n : unset(_formState.errors, name);\n }\n if ((error ? !deepEqual(previousFieldError, error) : previousFieldError) ||\n !isEmptyObject(fieldState) ||\n shouldUpdateValid) {\n const updatedFormState = {\n ...fieldState,\n ...(shouldUpdateValid && isBoolean(isValid) ? { isValid } : {}),\n errors: _formState.errors,\n name,\n };\n _formState = {\n ..._formState,\n ...updatedFormState,\n };\n _subjects.state.next(updatedFormState);\n }\n };\n const _runSchema = async (name) => {\n _updateIsValidating(name, true);\n const result = await _options.resolver(_formValues, _options.context, getResolverOptions(name || _names.mount, _fields, _options.criteriaMode, _options.shouldUseNativeValidation));\n return result;\n };\n const executeSchemaAndUpdateState = async (names) => {\n const { errors } = await _runSchema(names);\n _updateIsValidating(names);\n if (names) {\n for (const name of names) {\n const error = get(errors, name);\n error\n ? set(_formState.errors, name, error)\n : unset(_formState.errors, name);\n }\n }\n else {\n _formState.errors = errors;\n }\n return errors;\n };\n const executeBuiltInValidation = async (fields, shouldOnlyCheckValid, context = {\n valid: true,\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 if (isPromiseFunction && _proxyFormState.validatingFields) {\n _updateIsValidating([_f.name], true);\n }\n const fieldError = await validateField(field, _names.disabled, _formValues, shouldDisplayAllAssociatedErrors, _options.shouldUseNativeValidation && !shouldOnlyCheckValid, isFieldArrayRoot);\n if (isPromiseFunction && _proxyFormState.validatingFields) {\n _updateIsValidating([_f.name]);\n }\n if (fieldError[_f.name]) {\n context.valid = false;\n if (shouldOnlyCheckValid || props.shouldUseNativeValidation) {\n break;\n }\n }\n !shouldOnlyCheckValid &&\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 !isEmptyObject(fieldValue) &&\n (await executeBuiltInValidation(fieldValue, shouldOnlyCheckValid, context));\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) => !_options.disabled &&\n (name && data && set(_formValues, name, data),\n !deepEqual(getValues(), _defaultValues));\n const _getWatch = (names, defaultValue, isGlobal) => generateWatchOutput(names, _names, {\n ...(_state.mount\n ? _formValues\n : isUndefined(defaultValue)\n ? _defaultValues\n : isString(names)\n ? { [names]: defaultValue }\n : defaultValue),\n }, isGlobal, defaultValue);\n const _getFieldArray = (name) => compact(get(_state.mount ? _formValues : _defaultValues, name, _options.shouldUnregister ? get(_defaultValues, name, []) : []));\n const setFieldValue = (name, value, options = {}) => {\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) {\n _subjects.state.next({\n name,\n values: cloneObject(_formValues),\n });\n }\n }\n }\n }\n (options.shouldDirty || options.shouldTouch) &&\n updateTouchAndDirty(name, fieldValue, options.shouldTouch, options.shouldDirty, true);\n options.shouldValidate && trigger(name);\n };\n const setValues = (name, value, options) => {\n for (const fieldKey in value) {\n if (!value.hasOwnProperty(fieldKey)) {\n return;\n }\n const fieldValue = value[fieldKey];\n const fieldName = name + '.' + fieldKey;\n const field = get(_fields, fieldName);\n (_names.array.has(name) ||\n isObject(fieldValue) ||\n (field && !field._f)) &&\n !isDateObject(fieldValue)\n ? setValues(fieldName, fieldValue, options)\n : setFieldValue(fieldName, fieldValue, options);\n }\n };\n const setValue = (name, value, options = {}) => {\n const field = get(_fields, name);\n const isFieldArray = _names.array.has(name);\n const cloneValue = cloneObject(value);\n set(_formValues, name, cloneValue);\n if (isFieldArray) {\n _subjects.array.next({\n name,\n values: cloneObject(_formValues),\n });\n if ((_proxyFormState.isDirty ||\n _proxyFormState.dirtyFields ||\n _proxySubscribeFormState.isDirty ||\n _proxySubscribeFormState.dirtyFields) &&\n options.shouldDirty) {\n _subjects.state.next({\n name,\n dirtyFields: getDirtyFields(_defaultValues, _formValues),\n isDirty: _getDirty(name, cloneValue),\n });\n }\n }\n else {\n field && !field._f && !isNullOrUndefined(cloneValue)\n ? setValues(name, cloneValue, options)\n : setFieldValue(name, cloneValue, options);\n }\n if (isWatched(name, _names)) {\n _subjects.state.next({\n ..._formState,\n name,\n values: cloneObject(_formValues),\n });\n }\n else {\n _subjects.state.next({\n name: _state.mount ? name : undefined,\n values: cloneObject(_formValues),\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 _updateIsFieldValueUpdated = (fieldValue) => {\n isFieldValueUpdated =\n Number.isNaN(fieldValue) ||\n (isDateObject(fieldValue) && isNaN(fieldValue.getTime())) ||\n deepEqual(fieldValue, get(_formValues, name, fieldValue));\n };\n const validationModeBeforeSubmit = getValidationModes(_options.mode);\n const validationModeAfterSubmit = getValidationModes(_options.reValidateMode);\n if (field) {\n let error;\n let isValid;\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 shouldSkipValidation = (!hasValidation(field._f) &&\n !_options.resolver &&\n !get(_formState.errors, name) &&\n !field._f.deps) ||\n skipValidation(isBlurEvent, get(_formState.touchedFields, name), _formState.isSubmitted, validationModeAfterSubmit, validationModeBeforeSubmit);\n const watched = isWatched(name, _names, isBlurEvent);\n set(_formValues, name, fieldValue);\n if (isBlurEvent) {\n if (!target || !target.readOnly) {\n field._f.onBlur && field._f.onBlur(event);\n delayErrorCallback && delayErrorCallback(0);\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 values: cloneObject(_formValues),\n });\n if (shouldSkipValidation) {\n if (_proxyFormState.isValid || _proxySubscribeFormState.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 !isBlurEvent && watched && _subjects.state.next({ ..._formState });\n if (_options.resolver) {\n const { errors } = await _runSchema([name]);\n _updateIsValidating([name]);\n _updateIsFieldValueUpdated(fieldValue);\n if (isFieldValueUpdated) {\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 }\n else {\n _updateIsValidating([name], true);\n error = (await validateField(field, _names.disabled, _formValues, shouldDisplayAllAssociatedErrors, _options.shouldUseNativeValidation))[name];\n _updateIsValidating([name]);\n _updateIsFieldValueUpdated(fieldValue);\n if (isFieldValueUpdated) {\n if (error) {\n isValid = false;\n }\n else if (_proxyFormState.isValid ||\n _proxySubscribeFormState.isValid) {\n isValid = await executeBuiltInValidation(_fields, true);\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 }\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 let isValid;\n let validationResult;\n const fieldNames = convertToArrayPayload(name);\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(field && field._f ? { [fieldName]: field } : field);\n }))).every(Boolean);\n !(!validationResult && !_formState.isValid) && _setValid();\n }\n else {\n validationResult = isValid = await executeBuiltInValidation(_fields);\n }\n _subjects.state.next({\n ...(!isString(name) ||\n ((_proxyFormState.isValid || _proxySubscribeFormState.isValid) &&\n isValid !== _formState.isValid)\n ? {}\n : { name }),\n ...(_options.resolver || !name ? { isValid } : {}),\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 = {\n ...(_state.mount ? _formValues : _defaultValues),\n };\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 getFieldState = (name, formState) => ({\n invalid: !!get((formState || _formState).errors, name),\n isDirty: !!get((formState || _formState).dirtyFields, name),\n error: get((formState || _formState).errors, name),\n isValidating: !!get(_formState.validatingFields, name),\n isTouched: !!get((formState || _formState).touchedFields, name),\n });\n const clearErrors = (name) => {\n const names = name ? convertToArrayPayload(name) : undefined;\n names === null || names === void 0 ? void 0 : names.forEach((inputName) => unset(_formState.errors, inputName));\n if (names) {\n // Emit for each cleared field with the field name so that\n // shouldSubscribeByName can filter and avoid broad re-renders\n names.forEach((inputName) => {\n _subjects.state.next({\n name: inputName,\n errors: _formState.errors,\n });\n });\n }\n else {\n // Clear all errors - emit without name to notify all subscribers\n _subjects.state.next({\n errors: {},\n });\n }\n };\n const setError = (name, error, options) => {\n const ref = (get(_fields, name, { _f: {} })._f || {}).ref;\n const currentError = get(_formState.errors, name) || {};\n // Don't override existing error messages elsewhere in the object tree.\n const { ref: currentRef, message, type, ...restOfErrorTree } = currentError;\n set(_formState.errors, name, {\n ...restOfErrorTree,\n ...error,\n ref,\n });\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) => isFunction(name)\n ? _subjects.state.subscribe({\n next: (payload) => 'values' in payload &&\n name(_getWatch(undefined, defaultValue), payload),\n })\n : _getWatch(name, defaultValue, true);\n const _subscribe = (props) => _subjects.state.subscribe({\n next: (formState) => {\n if (shouldSubscribeByName(props.name, formState.name, props.exact) &&\n shouldRenderFormState(formState, props.formState || _proxyFormState, _setFormState, props.reRenderRoot)) {\n props.callback({\n values: { ..._formValues },\n ..._formState,\n ...formState,\n defaultValues: _defaultValues,\n });\n }\n },\n }).unsubscribe;\n const subscribe = (props) => {\n _state.mount = true;\n _proxySubscribeFormState = {\n ..._proxySubscribeFormState,\n ...props.formState,\n };\n return _subscribe({\n ...props,\n formState: {\n ...defaultProxyFormState,\n ...props.formState,\n },\n });\n };\n const unregister = (name, options = {}) => {\n for (const fieldName of name ? convertToArrayPayload(name) : _names.mount) {\n _names.mount.delete(fieldName);\n _names.array.delete(fieldName);\n if (!options.keepValue) {\n unset(_fields, fieldName);\n unset(_formValues, fieldName);\n }\n !options.keepError && unset(_formState.errors, fieldName);\n !options.keepDirty && unset(_formState.dirtyFields, fieldName);\n !options.keepTouched && unset(_formState.touchedFields, fieldName);\n !options.keepIsValidating &&\n unset(_formState.validatingFields, fieldName);\n !_options.shouldUnregister &&\n !options.keepDefaultValue &&\n unset(_defaultValues, fieldName);\n }\n _subjects.state.next({\n values: cloneObject(_formValues),\n });\n _subjects.state.next({\n ..._formState,\n ...(!options.keepDirty ? {} : { isDirty: _getDirty() }),\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 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) {\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: !!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 register(name, options);\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 set(_fields, name, {\n _f: {\n ...field._f,\n ...(radioOrCheckbox\n ? {\n refs: [\n ...refs.filter(live),\n fieldRef,\n ...(Array.isArray(get(_defaultValues, name)) ? [{}] : []),\n ],\n ref: { type: fieldRef.type, name },\n }\n : { ref: fieldRef }),\n },\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 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, false);\n }\n };\n const handleSubmit = (onValid, onInvalid) => async (e) => {\n let onValidError = undefined;\n if (e) {\n e.preventDefault && e.preventDefault();\n e.persist &&\n e.persist();\n }\n let fieldValues = cloneObject(_formValues);\n _subjects.state.next({\n isSubmitting: true,\n });\n if (_options.resolver) {\n const { errors, values } = await _runSchema();\n _updateIsValidating();\n _formState.errors = errors;\n fieldValues = cloneObject(values);\n }\n else {\n await executeBuiltInValidation(_fields);\n }\n if (_names.disabled.size) {\n for (const name of _names.disabled) {\n unset(fieldValues, name);\n }\n }\n unset(_formState.errors, 'root');\n if (isEmptyObject(_formState.errors)) {\n _subjects.state.next({\n errors: {},\n });\n try {\n await onValid(fieldValues, e);\n }\n catch (error) {\n onValidError = error;\n }\n }\n else {\n if (onInvalid) {\n await onInvalid({ ..._formState.errors }, e);\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 };\n const resetField = (name, options = {}) => {\n if (get(_fields, 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 = options.defaultValue\n ? _getDirty(name, cloneObject(get(_defaultValues, name)))\n : _getDirty();\n }\n if (!options.keepError) {\n unset(_formState.errors, name);\n _proxyFormState.isValid && _setValid();\n }\n _subjects.state.next({ ..._formState });\n }\n };\n const _reset = (formValues, keepStateOptions = {}) => {\n const updatedValues = formValues ? cloneObject(formValues) : _defaultValues;\n const cloneUpdatedValues = cloneObject(updatedValues);\n const isEmptyResetValues = isEmptyObject(formValues);\n const values = isEmptyResetValues ? _defaultValues : cloneUpdatedValues;\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 ...Object.keys(getDirtyFields(_defaultValues, _formValues)),\n ]);\n for (const fieldName of Array.from(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 _formValues = _options.shouldUnregister\n ? keepStateOptions.keepDefaultValues\n ? cloneObject(_defaultValues)\n : {}\n : cloneObject(values);\n _subjects.array.next({\n values: { ...values },\n });\n _subjects.state.next({\n values: { ...values },\n });\n }\n _names = {\n mount: keepStateOptions.keepDirtyValues ? _names.mount : new Set(),\n unMount: new Set(),\n array: new Set(),\n disabled: 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 // Clear errors synchronously to prevent validation errors on subsequent submissions\n // This fixes the issue where form.reset() causes validation errors on subsequent\n // submissions in Next.js 16 with Server Actions\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.keepDefaultValues &&\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)\n : _formState.dirtyFields\n : keepStateOptions.keepDefaultValues && formValues\n ? getDirtyFields(_defaultValues, formValues)\n : keepStateOptions.keepDirty\n ? _formState.dirtyFields\n : {},\n touchedFields: keepStateOptions.keepTouched\n ? _formState.touchedFields\n : {},\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)\n ? formValues(_formValues)\n : formValues, { ..._options.resetOptions, ...keepStateOptions });\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\n ? fieldReference.refs[0]\n : fieldReference.ref;\n if (fieldRef.focus) {\n // Use setTimeout to ensure focus happens after any pending state updates\n // This fixes the issue where setFocus doesn't work immediately after setError\n setTimeout(() => {\n fieldRef.focus();\n options.shouldSelect &&\n isFunction(fieldRef.select) &&\n fieldRef.select();\n });\n }\n }\n };\n const _setFormState = (updatedFormState) => {\n _formState = {\n ..._formState,\n ...updatedFormState,\n };\n };\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 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 },\n },\n subscribe,\n trigger,\n register,\n handleSubmit,\n watch,\n setValue,\n getValues,\n reset,\n resetField,\n clearErrors,\n unregister,\n setError,\n setFocus,\n getFieldState,\n };\n return {\n ...methods,\n formControl: methods,\n };\n}\n\nvar generateId = () => {\n if (typeof crypto !== 'undefined' && crypto.randomUUID) {\n return crypto.randomUUID();\n }\n const d = typeof performance === 'undefined' ? Date.now() : performance.now() * 1000;\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = ((Math.random() * 16 + d) % 16) | 0;\n return (c == 'x' ? r : (r & 0x3) | 0x8).toString(16);\n });\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 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\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, convertToArrayPayload(index).sort((a, b) => a - b));\n\nvar swapArrayAt = (data, indexA, indexB) => {\n [data[indexA], data[indexB]] = [data[indexB], data[indexA]];\n};\n\nvar updateAt = (fieldValues, index, value) => {\n fieldValues[index] = value;\n return fieldValues;\n};\n\n/**\n * A custom hook that exposes convenient methods to perform operations with a list of dynamic inputs that need to be appended, updated, removed etc. • [Demo](https://codesandbox.io/s/react-hook-form-usefieldarray-ssugn) • [Video](https://youtu.be/4MrbfGSFY2A)\n *\n * @remarks\n * [API](https://react-hook-form.com/docs/usefieldarray) • [Demo](https://codesandbox.io/s/react-hook-form-usefieldarray-ssugn)\n *\n * @param props - useFieldArray props\n *\n * @returns methods - functions to manipulate with the Field Arrays (dynamic inputs) {@link UseFieldArrayReturn}\n *\n * @example\n * ```tsx\n * function App() {\n * const { register, control, handleSubmit, reset, trigger, setError } = useForm({\n * defaultValues: {\n * test: []\n * }\n * });\n * const { fields, append } = useFieldArray({\n * control,\n * name: \"test\"\n * });\n *\n * return (\n * <form onSubmit={handleSubmit(data => console.log(data))}>\n * {fields.map((item, index) => (\n * <input key={item.id} {...register(`test.${index}.firstName`)} />\n * ))}\n * <button type=\"button\" onClick={() => append({ firstName: \"bill\" })}>\n * append\n * </button>\n * <input type=\"submit\" />\n * </form>\n * );\n * }\n * ```\n */\nfunction useFieldArray(props) {\n const formControl = useFormControlContext();\n const { control = formControl, name, keyName = 'id', shouldUnregister, rules, } = props;\n const [fields, setFields] = React.useState(control._getFieldArray(name));\n const ids = React.useRef(control._getFieldArray(name).map(generateId));\n const _actioned = React.useRef(false);\n control._names.array.add(name);\n React.useMemo(() => rules &&\n fields.length >= 0 &&\n control.register(name, rules), [control, name, fields.length, rules]);\n useIsomorphicLayoutEffect(() => 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 }\n },\n }).unsubscribe, [control, name]);\n const updateValues = React.useCallback((updatedFieldArrayValues) => {\n _actioned.current = true;\n control._setFieldArray(name, updatedFieldArrayValues);\n }, [control, name]);\n const append = (value, options) => {\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 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 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 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 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 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 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: updateValue,\n }, true, false);\n };\n const replace = (value) => {\n const updatedFieldArrayValues = convertToArrayPayload(cloneObject(value));\n ids.current = updatedFieldArrayValues.map(generateId);\n updateValues([...updatedFieldArrayValues]);\n setFields([...updatedFieldArrayValues]);\n control._setFieldArray(name, [...updatedFieldArrayValues], (data) => data, {}, true, false);\n };\n React.useEffect(() => {\n control._state.action = false;\n isWatched(name, control._names) &&\n control._subjects.state.next({\n ...control._formState,\n });\n if (_actioned.current &&\n (!getValidationModes(control._options.mode).isOnSubmit ||\n control._formState.isSubmitted) &&\n !getValidationModes(control._options.reValidateMode).isOnSubmit) {\n if (control._options.resolver) {\n control._runSchema([name]).then((result) => {\n control._updateIsValidating([name]);\n const error = get(result.errors, name);\n const existingError = get(control._formState.errors, name);\n if (existingError\n ? (!error && existingError.type) ||\n (error &&\n (existingError.type !== error.type ||\n existingError.message !== error.message))\n : error && error.type) {\n error\n ? set(control._formState.errors, name, error)\n : unset(control._formState.errors, name);\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 &&\n field._f &&\n !(getValidationModes(control._options.reValidateMode).isOnSubmit &&\n getValidationModes(control._options.mode).isOnSubmit)) {\n validateField(field, control._names.disabled, control._formValues, control._options.criteriaMode === VALIDATION_MODE.all, control._options.shouldUseNativeValidation, true).then((error) => !isEmptyObject(error) &&\n control._subjects.state.next({\n errors: updateFieldArrayRootError(control._formState.errors, error, name),\n }));\n }\n }\n }\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]);\n React.useEffect(() => {\n !get(control._formValues, name) && control._setFieldArray(name);\n return () => {\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 control._options.shouldUnregister || shouldUnregister\n ? control.unregister(name)\n : updateMounted(name, false);\n };\n }, [name, control, keyName, shouldUnregister]);\n return {\n swap: React.useCallback(swap, [updateValues, name, control]),\n move: React.useCallback(move, [updateValues, name, control]),\n prepend: React.useCallback(prepend, [updateValues, name, control]),\n append: React.useCallback(append, [updateValues, name, control]),\n remove: React.useCallback(remove, [updateValues, name, control]),\n insert: React.useCallback(insert$1, [updateValues, name, control]),\n update: React.useCallback(update, [updateValues, name, control]),\n replace: React.useCallback(replace, [updateValues, name, control]),\n fields: React.useMemo(() => fields.map((field, index) => ({\n ...field,\n [keyName]: ids.current[index] || generateId(),\n })), [fields, keyName]),\n };\n}\n\n/**\n * Custom hook to manage the entire form.\n *\n * @remarks\n * [API](https://react-hook-form.com/docs/useform) • [Demo](https://codesandbox.io/s/react-hook-form-get-started-ts-5ksmm) • [Video](https://www.youtube.com/watch?v=RkXv4AXXC_4)\n *\n * @param props - form configuration and validation parameters.\n *\n * @returns methods - individual functions to manage the form state. {@link UseFormReturn}\n *\n * @example\n * ```tsx\n * function App() {\n * const { register, handleSubmit, watch, formState: { errors } } = useForm();\n * const onSubmit = data => console.log(data);\n *\n * console.log(watch(\"example\"));\n *\n * return (\n * <form onSubmit={handleSubmit(onSubmit)}>\n * <input defaultValue=\"test\" {...register(\"example\")} />\n * <input {...register(\"exampleRequired\", { required: true })} />\n * {errors.exampleRequired && <span>This field is required</span>}\n * <button>Submit</button>\n * </form>\n * );\n * }\n * ```\n */\nfunction useForm(props = {}) {\n const _formControl = React.useRef(undefined);\n const _values = React.useRef(undefined);\n const [formState, updateFormState] = React.useState({\n isDirty: false,\n isValidating: false,\n isLoading: isFunction(props.defaultValues),\n isSubmitted: false,\n isSubmitting: false,\n isSubmitSuccessful: false,\n isValid: false,\n submitCount: 0,\n dirtyFields: {},\n touchedFields: {},\n validatingFields: {},\n errors: props.errors || {},\n disabled: props.disabled || false,\n isReady: false,\n defaultValues: isFunction(props.defaultValues)\n ? undefined\n : props.defaultValues,\n });\n if (!_formControl.current) {\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 control._options = props;\n useIsomorphicLayoutEffect(() => {\n const sub = control._subscribe({\n formState: control._proxyFormState,\n callback: () => updateFormState({ ...control._formState }),\n reRenderRoot: true,\n });\n updateFormState((data) => ({\n ...data,\n isReady: true,\n }));\n control._formState.isReady = true;\n return sub;\n }, [control]);\n React.useEffect(() => control._disableForm(props.disabled), [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 }, [control, props.errors]);\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 var _a;\n if (props.values && !deepEqual(props.values, _values.current)) {\n control._reset(props.values, {\n keepFieldsRef: true,\n ...control._options.resetOptions,\n });\n if (!((_a = control._options.resetOptions) === null || _a === void 0 ? void 0 : _a.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) {\n control._setValid();\n control._state.mount = true;\n }\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\n/**\n * Watch component that subscribes to form field changes and re-renders when watched fields update.\n *\n * @param control - The form control object from useForm\n * @param name - Can be field name, array of field names, or undefined to watch the entire form\n * @param disabled - Disable subscription\n * @param exact - Whether to watch exact field names or not\n * @param defaultValue - The default value to use if the field is not yet set\n * @param compute - Function to compute derived values from watched fields\n * @param render - The function that receives watched values and returns ReactNode\n * @returns The result of calling render function with watched values\n *\n * @example\n * The `Watch` component only re-render when the values of `foo`, `bar`, and `baz.qux` change.\n * The types of `foo`, `bar`, and `baz.qux` are precisely inferred.\n *\n * ```tsx\n * const { control } = useForm();\n *\n * <Watch\n * control={control}\n * names={['foo', 'bar', 'baz.qux']}\n * render={([foo, bar, baz_qux]) => <div>{foo}{bar}{baz_qux}</div>}\n * />\n * ```\n */\nconst Watch = (props) => props.render(useWatch({ name: props.names, ...props }));\n\nexport { Controller, Form, FormProvider, FormStateSubscribe, Watch, appendErrors, createFormControl, get, set, useController, useFieldArray, useForm, useFormContext, useFormState, useWatch };\n//# sourceMappingURL=index.esm.mjs.map\n","import { twMerge } from \"tailwind-merge\";\n\ntype Props = {\n className?: string;\n size?: \"sm\" | \"md\" | \"lg\";\n margin?: \"sm\" | \"md\" | \"lg\";\n};\nexport function Divider({ className, size = \"sm\", margin = \"md\" }: Props) {\n function getSize() {\n if (size === \"sm\") return \"h-px\";\n if (size === \"md\") return \"h-1\";\n return \"h-1.5\";\n }\n\n function getMargin() {\n if (margin === \"sm\") return \"my-4\";\n if (margin === \"md\") return \"my-6\";\n return \"my-8\";\n }\n\n const sizeClass = getSize();\n const marginClass = getMargin();\n return (\n <div\n className={twMerge(\"bg-secondary\", sizeClass, marginClass, className)}\n />\n );\n}\n","import{get as e,set as t}from\"react-hook-form\";const r=(t,r,o)=>{if(t&&\"reportValidity\"in t){const s=e(o,r);t.setCustomValidity(s&&s.message||\"\"),t.reportValidity()}},o=(e,t)=>{for(const o in t.fields){const s=t.fields[o];s&&s.ref&&\"reportValidity\"in s.ref?r(s.ref,o,e):s&&s.refs&&s.refs.forEach(t=>r(t,o,e))}},s=(r,s)=>{s.shouldUseNativeValidation&&o(r,s);const n={};for(const o in r){const f=e(s.fields,o),c=Object.assign(r[o]||{},{ref:f&&f.ref});if(i(s.names||Object.keys(r),o)){const r=Object.assign({},e(n,o));t(r,\"root\",c),t(n,o,r)}else t(n,o,c)}return n},i=(e,t)=>{const r=n(t);return e.some(e=>n(e).match(`^${r}\\\\.\\\\d+`))};function n(e){return e.replace(/\\]|\\[/g,\"\")}export{s as toNestErrors,o as validateFieldsNatively};\n//# sourceMappingURL=resolvers.mjs.map\n","import{validateFieldsNatively as r,toNestErrors as e}from\"@hookform/resolvers\";import{appendErrors as o}from\"react-hook-form\";import*as n from\"zod/v4/core\";function t(r,e){try{var o=r()}catch(r){return e(r)}return o&&o.then?o.then(void 0,e):o}function s(r,e){for(var n={};r.length;){var t=r[0],s=t.code,i=t.message,a=t.path.join(\".\");if(!n[a])if(\"unionErrors\"in t){var u=t.unionErrors[0].errors[0];n[a]={message:u.message,type:u.code}}else n[a]={message:i,type:s};if(\"unionErrors\"in t&&t.unionErrors.forEach(function(e){return e.errors.forEach(function(e){return r.push(e)})}),e){var c=n[a].types,f=c&&c[t.code];n[a]=o(a,e,n,s,f?[].concat(f,t.message):t.message)}r.shift()}return n}function i(r,e){for(var n={};r.length;){var t=r[0],s=t.code,i=t.message,a=t.path.join(\".\");if(!n[a])if(\"invalid_union\"===t.code&&t.errors.length>0){var u=t.errors[0][0];n[a]={message:u.message,type:u.code}}else n[a]={message:i,type:s};if(\"invalid_union\"===t.code&&t.errors.forEach(function(e){return e.forEach(function(e){return r.push(e)})}),e){var c=n[a].types,f=c&&c[t.code];n[a]=o(a,e,n,s,f?[].concat(f,t.message):t.message)}r.shift()}return n}function a(o,a,u){if(void 0===u&&(u={}),function(r){return\"_def\"in r&&\"object\"==typeof r._def&&\"typeName\"in r._def}(o))return function(n,i,c){try{return Promise.resolve(t(function(){return Promise.resolve(o[\"sync\"===u.mode?\"parse\":\"parseAsync\"](n,a)).then(function(e){return c.shouldUseNativeValidation&&r({},c),{errors:{},values:u.raw?Object.assign({},n):e}})},function(r){if(function(r){return Array.isArray(null==r?void 0:r.issues)}(r))return{values:{},errors:e(s(r.errors,!c.shouldUseNativeValidation&&\"all\"===c.criteriaMode),c)};throw r}))}catch(r){return Promise.reject(r)}};if(function(r){return\"_zod\"in r&&\"object\"==typeof r._zod}(o))return function(s,c,f){try{return Promise.resolve(t(function(){return Promise.resolve((\"sync\"===u.mode?n.parse:n.parseAsync)(o,s,a)).then(function(e){return f.shouldUseNativeValidation&&r({},f),{errors:{},values:u.raw?Object.assign({},s):e}})},function(r){if(function(r){return r instanceof n.$ZodError}(r))return{values:{},errors:e(i(r.issues,!f.shouldUseNativeValidation&&\"all\"===f.criteriaMode),f)};throw r}))}catch(r){return Promise.reject(r)}};throw new Error(\"Invalid input: not a Zod schema\")}export{a as zodResolver};\n//# sourceMappingURL=zod.module.js.map\n","import { z } from \"zod\";\nimport { snakeCase, constantCase } from \"change-case\";\n\nconst isUppercase = (value: string) => !/\\p{Ll}/u.test(value);\nconst isLowercase = (value: string) => !/\\p{Lu}/u.test(value);\n\nconst whitespaceRegex = /\\s+/g;\n\nexport function containsSpaces(s: string) {\n return whitespaceRegex.test(s);\n}\n\nexport function replaceSpaces(s: string) {\n return s.replace(whitespaceRegex, \"_\");\n}\n\ntype SchemaOptions = {\n required?: boolean;\n allowEmpty?: boolean;\n unique?: string[];\n};\n\nexport function createNameSchema(options: SchemaOptions = {}) {\n const { required = false, allowEmpty = false, unique = [] } = options;\n\n const baseSchema = allowEmpty ? z.string() : z.string().min(1);\n\n const uniqueRefinement = baseSchema.refine(\n (value) => {\n if (!value && allowEmpty) return true;\n return !unique\n .map((n) => n.toLowerCase())\n .includes(value.replace(/^\\s+|\\s+$/g, \"_\").toLowerCase());\n },\n { message: \"Item with this name already exists\" },\n );\n\n if (!required) {\n return unique.length > 0\n ? z\n .string()\n .optional()\n .refine(\n (value) => {\n if (value === undefined) return true;\n if (!value && allowEmpty) return true;\n return !unique\n .map((n) => n.toLowerCase())\n .includes(value.replace(/^\\s+|\\s+$/g, \"_\").toLowerCase());\n },\n { message: \"Item with this name already exists\" },\n )\n : z.string().optional();\n }\n\n return unique.length > 0 ? uniqueRefinement : baseSchema;\n}\n\nexport function createConstantCaseSchema(options: SchemaOptions = {}) {\n return createNameSchema(options)\n .transform((value) => (value ? value.toUpperCase() : value))\n .refine((value) => !value || isUppercase(value), {\n message: \"Must be uppercase\",\n });\n}\n\nexport function createLowercaseSnakeCaseSchema(options: SchemaOptions = {}) {\n return createNameSchema(options)\n .transform((value) => (value ? value.toLowerCase() : value))\n .refine((value) => !value || isLowercase(value), {\n message: \"Must be lowercase\",\n });\n}\n\nexport function toLowercaseSnakeCase(\n value: string,\n options: SchemaOptions = {},\n) {\n return createLowercaseSnakeCaseSchema(options).parse(\n snakeCase(value),\n ) as LowercaseSnakeCase;\n}\n\nexport function toConstantCase(value: string, options: SchemaOptions = {}) {\n return createConstantCaseSchema(options).parse(\n constantCase(value),\n ) as ConstantCase;\n}\n\nexport type SnakeCase = `${string}_${string}`;\nexport type LowercaseSnakeCase = Lowercase<SnakeCase>;\nexport type ConstantCase = Uppercase<SnakeCase>;\nexport type Prettify<T> = {\n [K in keyof T]: T[K];\n} & {};\n\nexport const AuthorSchema = z\n .object({\n name: createNameSchema({ allowEmpty: true }),\n website: z\n .union([z.url(), z.literal(\"\")])\n .optional()\n .default(\"\"),\n })\n .default({\n name: \"\",\n website: \"\",\n });\n","import React from \"react\";\nimport type { FieldValues, FieldPath } from \"react-hook-form\";\n\nexport type FormFieldContextValue<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> = {\n name: TName;\n};\n\nexport const FormFieldContext = React.createContext<FormFieldContextValue>(\n {} as FormFieldContextValue,\n);\n\nexport type FormItemContextValue = {\n id: string;\n};\n\nexport const FormItemContext = React.createContext<FormItemContextValue>(\n {} as FormItemContextValue,\n);\n","import React from \"react\";\nimport { useFormContext } from \"react-hook-form\";\nimport { FormFieldContext, FormItemContext } from \"../context/form-context.js\";\n\nexport const useFormField = () => {\n const fieldContext = React.useContext(FormFieldContext);\n const itemContext = React.useContext(FormItemContext);\n const { getFieldState, formState } = useFormContext();\n\n const fieldState = getFieldState(fieldContext.name, formState);\n\n if (!fieldContext) {\n throw new Error(\"useFormField should be used within <FormField>\");\n }\n\n const { id } = itemContext;\n\n return {\n id,\n name: fieldContext.name,\n formItemId: `${id}-form-item`,\n formDescriptionId: `${id}-form-item-description`,\n formMessageId: `${id}-form-item-message`,\n ...fieldState,\n };\n};\n","\"use client\";\n\n// src/label.tsx\nimport * as React from \"react\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { jsx } from \"react/jsx-runtime\";\nvar NAME = \"Label\";\nvar Label = React.forwardRef((props, forwardedRef) => {\n return /* @__PURE__ */ jsx(\n Primitive.label,\n {\n ...props,\n ref: forwardedRef,\n onMouseDown: (event) => {\n const target = event.target;\n if (target.closest(\"button, input, select, textarea\")) return;\n props.onMouseDown?.(event);\n if (!event.defaultPrevented && event.detail > 1) event.preventDefault();\n }\n }\n );\n});\nLabel.displayName = NAME;\nvar Root = Label;\nexport {\n Label,\n Root\n};\n//# sourceMappingURL=index.mjs.map\n","import * as React from \"react\";\nimport * as LabelPrimitive from \"@radix-ui/react-label\";\nimport type { VariantProps } from \"class-variance-authority\";\nimport { cva } from \"class-variance-authority\";\nimport { twMerge } from \"tailwind-merge\";\n\nconst labelVariants = cva(\n \"text-sm leading-none font-medium peer-disabled:disabled-effect\",\n);\n\nconst Label = React.forwardRef<\n React.ElementRef<typeof LabelPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &\n VariantProps<typeof labelVariants>\n>(({ className, ...props }, ref) => (\n <LabelPrimitive.Root\n ref={ref}\n className={twMerge(labelVariants(), className)}\n {...props}\n />\n));\nLabel.displayName = LabelPrimitive.Root.displayName;\n\nexport { Label };\n","import * as React from \"react\";\nimport type * as LabelPrimitive from \"@radix-ui/react-label\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport type { ControllerProps, FieldPath, FieldValues } from \"react-hook-form\";\nimport { Controller, FormProvider } from \"react-hook-form\";\nimport { FormFieldContext, FormItemContext } from \"../context/form-context.js\";\nimport { useFormField } from \"../hooks/useFormField.js\";\nimport { twMerge } from \"tailwind-merge\";\nimport { Label } from \"./label.js\";\n\nconst Form = FormProvider;\n\nconst FormField = <\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>({\n ...props\n}: ControllerProps<TFieldValues, TName>) => {\n return (\n <FormFieldContext.Provider value={{ name: props.name }}>\n <Controller {...props} />\n </FormFieldContext.Provider>\n );\n};\n\nconst FormItem = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, ...props }, ref) => {\n const id = React.useId();\n\n return (\n <FormItemContext.Provider value={{ id }}>\n <div ref={ref} className={className} {...props} />\n </FormItemContext.Provider>\n );\n});\nFormItem.displayName = \"FormItem\";\n\nconst FormLabel = React.forwardRef<\n React.ElementRef<typeof LabelPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>\n>(({ className, ...props }, ref) => {\n const { error, formItemId } = useFormField();\n\n return (\n <Label\n ref={ref}\n className={twMerge(error && \"text-destructive\", className)}\n htmlFor={formItemId}\n {...props}\n />\n );\n});\nFormLabel.displayName = \"FormLabel\";\n\nconst FormControl = React.forwardRef<\n React.ElementRef<typeof Slot>,\n React.ComponentPropsWithoutRef<typeof Slot>\n>(({ ...props }, ref) => {\n const { error, formItemId, formDescriptionId, formMessageId } =\n useFormField();\n\n return (\n <Slot\n ref={ref}\n id={formItemId}\n aria-describedby={\n !error ? formDescriptionId : `${formDescriptionId} ${formMessageId}`\n }\n aria-invalid={!!error}\n {...props}\n />\n );\n});\nFormControl.displayName = \"FormControl\";\n\nconst FormDescription = React.forwardRef<\n HTMLParagraphElement,\n React.HTMLAttributes<HTMLParagraphElement>\n>(({ className, ...props }, ref) => {\n const { formDescriptionId } = useFormField();\n\n return (\n <p\n ref={ref}\n id={formDescriptionId}\n className={twMerge(\"text-sm text-foreground\", className)}\n {...props}\n />\n );\n});\nFormDescription.displayName = \"FormDescription\";\n\nconst FormMessage = React.forwardRef<\n HTMLParagraphElement,\n React.HTMLAttributes<HTMLParagraphElement>\n>(({ className, children, ...props }, ref) => {\n const { error, formMessageId } = useFormField();\n const body = error ? String(error.message) : children;\n\n if (!body) {\n return null;\n }\n\n return (\n <p\n ref={ref}\n id={formMessageId}\n className={twMerge(\"text-sm font-medium text-destructive\", className)}\n {...props}\n >\n {body}\n </p>\n );\n});\nFormMessage.displayName = \"FormMessage\";\n\nexport {\n Form,\n FormItem,\n FormLabel,\n FormControl,\n FormDescription,\n FormMessage,\n FormField,\n};\n","import * as React from \"react\";\nimport { forwardRef, useCallback, useImperativeHandle, useRef } from \"react\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport interface TextareaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {}\n\nexport interface TextareaHandle {\n focus: () => void;\n element: HTMLTextAreaElement | null;\n}\n\nexport const Textarea = forwardRef<TextareaHandle, TextareaProps>(\n ({ className, ...props }, ref) => {\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n\n const adjustHeight = useCallback((textarea: HTMLTextAreaElement) => {\n textarea.style.height = \"auto\";\n const newHeight = Math.max(textarea.scrollHeight, textarea.offsetHeight);\n textarea.style.height = `${newHeight}px`;\n }, []);\n\n const handleInput = useCallback(\n (e: React.FormEvent<HTMLTextAreaElement>) => {\n adjustHeight(e.currentTarget);\n },\n [adjustHeight],\n );\n\n React.useEffect(() => {\n if (textareaRef.current) {\n adjustHeight(textareaRef.current);\n }\n }, [adjustHeight]);\n\n useImperativeHandle(ref, () => ({\n focus: () => textareaRef.current?.focus(),\n element: textareaRef.current,\n }));\n\n return (\n <textarea\n {...props}\n className={twMerge(\n \"min-h-10 w-full resize-none rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground focus-visible:outline-none disabled:disabled-effect\",\n className,\n )}\n ref={textareaRef}\n onInput={handleInput}\n />\n );\n },\n);\nTextarea.displayName = \"Textarea\";\n","import { zodResolver } from \"@hookform/resolvers/zod\";\nimport {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useImperativeHandle,\n useRef,\n} from \"react\";\nimport type { FieldValues, Resolver } from \"react-hook-form\";\nimport { useForm } from \"react-hook-form\";\nimport { z } from \"zod\";\nimport { createNameSchema } from \"../schemas/inputs.js\";\nimport { compareStringsWithoutWhitespace } from \"../utils/helpers.js\";\nimport {\n Form,\n FormControl,\n FormField,\n FormItem,\n FormLabel,\n FormMessage,\n} from \"./form.js\";\nimport type { TextareaHandle } from \"./text-area.js\";\nimport { Textarea } from \"./text-area.js\";\n\ntype TextFieldProps = {\n name: string;\n value: string | null | undefined;\n onSubmit: (value: string) => void;\n label?: string;\n placeholder?: string;\n className?: string;\n rows?: number;\n focusOnMount?: boolean;\n required?: boolean;\n allowEmpty?: boolean;\n unique?: string[];\n shouldReset?: boolean;\n onChange?: (value: string) => void;\n};\n\ntype TextFieldHandle = {\n focus: () => void;\n};\n\nexport const TextField = forwardRef<TextFieldHandle, TextFieldProps>(\n (\n {\n name,\n value,\n onSubmit,\n label,\n placeholder,\n unique,\n className = \"\",\n rows = 1,\n focusOnMount = false,\n required = false,\n allowEmpty = false,\n shouldReset = false,\n onChange,\n },\n ref,\n ) => {\n const textareaRef = useRef<TextareaHandle | null>(null);\n const id = useId();\n useEffect(() => {\n if (focusOnMount && textareaRef.current) {\n textareaRef.current.focus();\n }\n }, [focusOnMount]);\n\n const fieldSchema = z.object({\n [name]: createNameSchema({ required, allowEmpty, unique }),\n });\n\n const form = useForm({\n resolver: zodResolver(\n fieldSchema as unknown as Parameters<typeof zodResolver>[0],\n ) as Resolver<FieldValues>,\n defaultValues: {\n [name]: value ?? \"\",\n },\n });\n\n const handleSubmit = useCallback(\n (values: FieldValues) => {\n const newValue = values[name] as string | undefined;\n if (newValue === undefined || value === newValue) return;\n onSubmit(newValue);\n if (shouldReset) form.reset({ [name]: \"\" });\n },\n [name, value, onSubmit, form, shouldReset],\n );\n\n const handleBlur = useCallback(async () => {\n const currentValue = (form.getValues()[name] as string | undefined) ?? \"\";\n\n if (value === null || value === undefined) {\n if (!currentValue || currentValue.trim() === \"\") return;\n }\n\n if (compareStringsWithoutWhitespace(currentValue, value ?? \"\")) return;\n\n try {\n await form.trigger(); // Trigger validation\n if (form.formState.isValid) {\n await form.handleSubmit(handleSubmit)();\n }\n } catch (_e) {\n // Allow blur to proceed even if validation fails\n }\n }, [form, handleSubmit, name, value]);\n\n const onEnterKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n (e.target as HTMLTextAreaElement).blur();\n }\n },\n [],\n );\n\n const handleChange = useCallback(\n (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n const newValue = e.target.value;\n onChange?.(newValue);\n },\n [onChange],\n );\n\n useImperativeHandle(ref, () => ({\n focus: () => textareaRef.current?.focus(),\n }));\n\n useEffect(() => {\n form.reset({ [name]: value ?? \"\" });\n }, [form, name, value]);\n\n return (\n <Form {...form}>\n <FormField\n control={form.control}\n name={name}\n render={({ field }) => (\n <FormItem className=\"grid h-full grid-rows-[auto,1fr] gap-2 overflow-visible\">\n {!!label && (\n <FormLabel\n htmlFor={name}\n className=\"text-sm font-medium text-foreground\"\n >\n {label}\n </FormLabel>\n )}\n <FormControl>\n <Textarea\n {...field}\n id={id}\n name={name}\n ref={(node) => {\n if (node) {\n field.ref(node.element);\n textareaRef.current = node;\n }\n }}\n placeholder={placeholder}\n onBlur={() => void handleBlur()}\n onChange={(e) => {\n field.onChange(e);\n handleChange(e);\n }}\n onKeyDown={onEnterKeyDown}\n rows={rows}\n className={className}\n />\n </FormControl>\n <FormMessage />\n </FormItem>\n )}\n />\n </Form>\n );\n },\n);\n\nTextField.displayName = \"TextField\";\n","import { useCallback } from \"react\";\nimport { z } from \"zod\";\nimport type { Scope } from \"../types/documents.js\";\nimport {\n handleModelNameChange,\n makeInitialSchemaDoc,\n renameSchemaType,\n} from \"../utils/helpers.js\";\nimport { TextField } from \"./text-field.js\";\n\nexport const MetadataFormSchema = z.object({\n name: z.string(),\n documentType: z.string(),\n extension: z.string().optional().default(\"\"),\n description: z.string(),\n authorName: z.string(),\n authorWebsite: z.string(),\n});\n\nexport type MetadataFormValues = z.infer<typeof MetadataFormSchema>;\n\ntype Props = MetadataFormValues & {\n globalStateSchema: string;\n localStateSchema: string;\n setModelName: (name: string) => void;\n setModelId: (id: string) => void;\n setModelExtension: (extension: string) => void;\n setModelDescription: (description: string) => void;\n setAuthorName: (authorName: string) => void;\n setAuthorWebsite: (authorWebsite: string) => void;\n setStateSchema: (schema: string, scope: Scope) => void;\n};\n\nexport default function ModelMetadata(props: Props) {\n return (\n <div>\n <ModelNameForm {...props} />\n <div className=\"flex h-full flex-col gap-4\">\n <div className=\"grid flex-1 grid-cols-3 items-start gap-4\">\n <div className=\"col-span-2 flex h-full flex-col gap-4\">\n <div className=\"shrink-0\">\n <DocumentTypeForm {...props} />\n </div>\n <div className=\"min-h-0 flex-1\">\n <DescriptionForm {...props} />\n </div>\n </div>\n <div className=\"col-span-1 flex flex-col gap-4\">\n <AuthorNameForm {...props} />\n <AuthorWebsiteForm {...props} />\n <ModelExtensionForm {...props} />\n </div>\n </div>\n </div>\n </div>\n );\n}\n\nexport function ModelNameForm(props: Props) {\n const {\n name,\n globalStateSchema,\n localStateSchema,\n setModelName,\n setStateSchema,\n } = props;\n\n const onSubmit = useCallback(\n (newName: string) => {\n if (name === newName) {\n return;\n }\n setModelName(newName);\n\n const hasExistingSchema = !!globalStateSchema;\n\n if (!hasExistingSchema) {\n const initialSchemaDoc = makeInitialSchemaDoc(newName, \"global\");\n setStateSchema(initialSchemaDoc, \"global\");\n return;\n }\n const newSchema = renameSchemaType(\n globalStateSchema,\n name,\n newName,\n \"global\",\n );\n setStateSchema(newSchema, \"global\");\n\n if (localStateSchema) {\n const newLocalStateSchema = renameSchemaType(\n localStateSchema,\n name,\n newName,\n \"local\",\n );\n setStateSchema(newLocalStateSchema, \"local\");\n }\n handleModelNameChange({\n oldName: name,\n newName,\n globalStateSchema,\n localStateSchema,\n setStateSchema,\n });\n },\n [name, globalStateSchema, localStateSchema, setStateSchema, setModelName],\n );\n\n return (\n <TextField\n name=\"name\"\n value={name}\n onSubmit={onSubmit}\n placeholder=\"Model name\"\n className=\"border-none pl-0 text-xl font-bold text-foreground\"\n required\n focusOnMount\n />\n );\n}\n\nexport function DocumentTypeForm(props: Props) {\n const { documentType, setModelId } = props;\n\n return (\n <TextField\n label=\"Document Type *\"\n name=\"powerhouse/document-model\"\n value={documentType}\n onSubmit={setModelId}\n placeholder=\"Document Type\"\n required\n />\n );\n}\n\nexport function ModelExtensionForm(props: Props) {\n const { extension, setModelExtension } = props;\n\n return (\n <TextField\n name=\"extension\"\n value={extension}\n onSubmit={setModelExtension}\n label=\"Model Extension\"\n placeholder=\"Example .phdm\"\n allowEmpty\n />\n );\n}\n\nexport function DescriptionForm(props: Props) {\n const { description, setModelDescription } = props;\n\n return (\n <TextField\n name=\"description\"\n label=\"Model Description\"\n value={description}\n onSubmit={setModelDescription}\n placeholder=\"Describe your document to others\"\n allowEmpty\n className=\"h-full\"\n />\n );\n}\n\nexport function AuthorNameForm(props: Props) {\n const { authorName, setAuthorName } = props;\n\n return (\n <TextField\n name=\"authorName\"\n value={authorName}\n onSubmit={setAuthorName}\n label=\"Author Name\"\n placeholder=\"Username or organisation\"\n allowEmpty\n />\n );\n}\n\nexport function AuthorWebsiteForm(props: Props) {\n const { authorWebsite, setAuthorWebsite } = props;\n\n return (\n <TextField\n name=\"authorWebsite\"\n value={authorWebsite}\n label=\"Website URL\"\n onSubmit={(newAuthorWebsite) => {\n if (!!authorWebsite && !newAuthorWebsite) return;\n setAuthorWebsite(newAuthorWebsite);\n }}\n placeholder=\"https://www.powerhouse.inc/\"\n allowEmpty\n />\n );\n}\n","import type { ModuleSpecification } from \"@powerhousedao/shared/document-model\";\nimport { toLowercaseSnakeCase } from \"../schemas/inputs.js\";\nimport { TextField } from \"./text-field.js\";\n\ntype Props = {\n modules?: ModuleSpecification[];\n module?: ModuleSpecification;\n onAddModule: (name: string) => Promise<string | undefined>;\n updateModuleName: (id: string, name: string) => void;\n};\n\nexport function ModuleForm({\n module,\n onAddModule,\n updateModuleName,\n modules = [],\n}: Props) {\n const isEdit = !!module;\n const moduleNames = modules.map((m) => m.name);\n\n const handleSubmit = async (name: string) => {\n const formattedName = toLowercaseSnakeCase(name);\n if (!formattedName.length) return;\n\n if (isEdit) {\n if (formattedName !== module.name) {\n updateModuleName(module.id, formattedName);\n }\n } else {\n await onAddModule(formattedName);\n }\n };\n\n return (\n <TextField\n key={module?.id ?? \"new\"}\n name=\"name\"\n label={isEdit ? \"Module name *\" : \"Add module *\"}\n value={module?.name}\n onSubmit={(name) => void handleSubmit(name)}\n placeholder=\"Add module\"\n unique={moduleNames}\n shouldReset={!isEdit}\n required\n />\n );\n}\n","import type { ModuleSpecification } from \"@powerhousedao/shared/document-model\";\nimport { toConstantCase } from \"../schemas/inputs.js\";\nimport { TextField } from \"./text-field.js\";\n\ntype Props = {\n module: ModuleSpecification;\n operation?: ModuleSpecification[\"operations\"][number];\n focusOnMount?: boolean;\n allOperationNames: string[];\n onAddOperationAndInitialSchema: (\n moduleId: string,\n name: string,\n ) => Promise<string | undefined>;\n updateOperationName: (id: string, name: string) => void;\n deleteOperation: (id: string) => void;\n};\n\nexport function OperationForm({\n operation,\n module,\n focusOnMount,\n allOperationNames,\n onAddOperationAndInitialSchema,\n updateOperationName,\n deleteOperation,\n}: Props) {\n const isEdit = !!operation;\n\n const handleSubmit = async (name: string) => {\n if (isEdit && name === \"\") {\n deleteOperation(operation.id);\n return;\n }\n\n const formattedName = toConstantCase(name);\n\n if (isEdit) {\n if (formattedName !== operation.name) {\n updateOperationName(operation.id, formattedName);\n }\n } else {\n await onAddOperationAndInitialSchema(module.id, formattedName);\n }\n };\n\n const handleChange = (value: string) => {\n if (isEdit && value === \"\") {\n deleteOperation(operation.id);\n }\n };\n\n return (\n <TextField\n name=\"name\"\n value={operation?.name}\n label={isEdit ? \"Operation name *\" : \"Add operation *\"}\n onSubmit={(name) => void handleSubmit(name)}\n onChange={handleChange}\n placeholder=\"Add operation\"\n required={!isEdit}\n allowEmpty={!isEdit}\n shouldReset={!isEdit}\n focusOnMount={focusOnMount}\n unique={allOperationNames}\n />\n );\n}\n","import type { ModuleSpecification } from \"@powerhousedao/shared/document-model\";\nimport { useEffect, useRef } from \"react\";\nimport { TextField } from \"./text-field.js\";\n\ntype Props = {\n operation: ModuleSpecification[\"operations\"][number];\n focusOnMount?: boolean;\n setOperationDescription: (id: string, description: string) => void;\n};\n\nexport function OperationDescriptionForm({\n operation,\n focusOnMount,\n setOperationDescription,\n}: Props) {\n const textFieldRef = useRef<{ focus: () => void } | null>(null);\n\n useEffect(() => {\n if (focusOnMount && textFieldRef.current) {\n textFieldRef.current.focus();\n }\n }, [focusOnMount]);\n\n return (\n <TextField\n ref={textFieldRef}\n name=\"description\"\n value={operation.description}\n onSubmit={(newDescription) =>\n setOperationDescription(operation.id, newDescription)\n }\n label=\"Operation description\"\n allowEmpty\n placeholder=\"Operation Description\"\n />\n );\n}\n","import type {\n ModuleSpecification,\n OperationErrorSpecification,\n} from \"@powerhousedao/shared/document-model\";\nimport { pascalCase } from \"change-case\";\nimport { useRef } from \"react\";\nimport { TextField } from \"./text-field.js\";\n\ntype Props = {\n operation: ModuleSpecification[\"operations\"][number];\n error?: OperationErrorSpecification;\n focusOnMount?: boolean;\n onSubmit?: () => void;\n onAddOperationError: (\n operationId: string,\n errorName: string,\n ) => Promise<string | undefined>;\n deleteOperationError: (id: string) => void;\n setOperationErrorName: (\n operationId: string,\n errorId: string,\n name: string,\n ) => void;\n};\n\nexport function OperationErrorForm({\n operation,\n error,\n focusOnMount,\n onSubmit,\n onAddOperationError,\n deleteOperationError,\n setOperationErrorName,\n}: Props) {\n const textFieldRef = useRef<{ focus: () => void } | null>(null);\n const isEdit = !!error;\n const allOperationErrorNames = operation.errors\n .map((o) => o.name)\n .filter((n) => n !== null);\n\n const handleSubmit = (name: string) => {\n if (isEdit && name === \"\") {\n deleteOperationError(error.id);\n return;\n }\n\n const formattedName = pascalCase(name);\n\n if (isEdit) {\n setOperationErrorName(operation.id, error.id, formattedName);\n } else {\n void onAddOperationError(operation.id, formattedName);\n }\n onSubmit?.();\n };\n\n const handleChange = (value: string) => {\n if (isEdit && value === \"\") {\n deleteOperationError(error.id);\n }\n };\n\n return (\n <TextField\n ref={textFieldRef}\n name=\"name\"\n value={error?.name}\n onSubmit={handleSubmit}\n onChange={handleChange}\n placeholder=\"Add exception\"\n required={!isEdit}\n allowEmpty={!isEdit}\n shouldReset={!isEdit}\n unique={allOperationErrorNames}\n focusOnMount={focusOnMount}\n />\n );\n}\n","import type { ModuleSpecification } from \"@powerhousedao/shared/document-model\";\nimport { useCallback, useId, useState } from \"react\";\nimport { OperationErrorForm } from \"./operation-error-form.js\";\n\ntype Props = {\n operation: ModuleSpecification[\"operations\"][number];\n addOperationError: (\n operationId: string,\n errorName: string,\n ) => Promise<string | undefined>;\n deleteOperationError: (id: string) => void;\n setOperationErrorName: (\n operationId: string,\n errorId: string,\n name: string,\n ) => void;\n};\n\nexport function OperationErrors({\n operation,\n addOperationError,\n deleteOperationError,\n setOperationErrorName,\n}: Props) {\n const addErrorFormId = useId();\n const [shouldFocusAddForm, setShouldFocusAddForm] = useState(false);\n\n const onAddOperationError = useCallback(\n async (operationId: string, error: string) => {\n const errorId = await addOperationError(operationId, error);\n if (errorId) {\n setShouldFocusAddForm(true);\n }\n return errorId;\n },\n [addOperationError, setShouldFocusAddForm],\n );\n\n const onAddOperationErrorSubmit = useCallback(\n () => setShouldFocusAddForm(false),\n [setShouldFocusAddForm],\n );\n\n return (\n <ul className=\"ml-4 list-disc\">\n {operation.errors.map((error) => (\n <li key={error.id}>\n <OperationErrorForm\n error={error}\n operation={operation}\n onAddOperationError={onAddOperationError}\n deleteOperationError={deleteOperationError}\n setOperationErrorName={setOperationErrorName}\n />\n </li>\n ))}\n <li>\n <OperationErrorForm\n operation={operation}\n onAddOperationError={onAddOperationError}\n deleteOperationError={deleteOperationError}\n setOperationErrorName={setOperationErrorName}\n key={`${addErrorFormId}-${shouldFocusAddForm}`}\n focusOnMount={shouldFocusAddForm}\n onSubmit={onAddOperationErrorSubmit}\n />\n </li>\n </ul>\n );\n}\n","import type { ModuleSpecification } from \"@powerhousedao/shared/document-model\";\nimport { lazy, Suspense, useCallback } from \"react\";\nimport type { DocumentActionHandlers } from \"../types/documents.js\";\nimport { isEmptyOperationSchema } from \"../utils/helpers.js\";\nimport { ensureValidOperationSchemaInputName } from \"../utils/linting.js\";\nimport { OperationDescriptionForm } from \"./operation-description-form.js\";\nimport { OperationErrors } from \"./operation-errors.js\";\nimport { OperationForm } from \"./operation-form.js\";\nconst GraphqlEditor = lazy(() => import(\"./code-editors/graphql-editor.js\"));\nexport type WrappedHandlers = DocumentActionHandlers & {\n addOperationAndInitialSchema: (\n moduleId: string,\n name: string,\n ) => Promise<string | undefined>;\n};\ntype Props = {\n lastCreatedOperationId: string | null;\n operation: ModuleSpecification[\"operations\"][number];\n module: ModuleSpecification;\n allOperationNames: string[];\n onAddOperationAndInitialSchema: (\n moduleId: string,\n name: string,\n ) => Promise<string | undefined>;\n updateOperationName: (id: string, name: string) => void;\n deleteOperation: (id: string) => void;\n updateOperationSchema: (id: string, newDoc: string) => void;\n setOperationDescription: (id: string, description: string) => void;\n addOperationError: (\n operationId: string,\n errorName: string,\n ) => Promise<string | undefined>;\n deleteOperationError: (id: string) => void;\n setOperationErrorName: (\n operationId: string,\n errorId: string,\n name: string,\n ) => void;\n toggleNoInputRequired: (id: string, noInputRequired: boolean) => void;\n};\nexport function Operation(props: Props) {\n const {\n operation,\n module,\n allOperationNames,\n lastCreatedOperationId,\n onAddOperationAndInitialSchema,\n updateOperationName,\n deleteOperation,\n updateOperationSchema,\n setOperationDescription,\n addOperationError,\n deleteOperationError,\n setOperationErrorName,\n toggleNoInputRequired,\n } = props;\n\n const noInputRequired = isEmptyOperationSchema(operation.schema);\n\n const handleToggleNoInput = useCallback(\n (checked: boolean) => toggleNoInputRequired(operation.id, checked),\n [operation.id, toggleNoInputRequired],\n );\n\n const handleUpdateDocument = useCallback(\n (newDoc: string) => updateOperationSchema(operation.id, newDoc),\n [operation.id, updateOperationSchema],\n );\n\n const customLinter = useCallback(\n (doc: string) =>\n operation.name\n ? ensureValidOperationSchemaInputName(doc, operation.name)\n : [],\n [operation.name],\n );\n\n return (\n <div\n className=\"mt-4 grid grid-cols-2 gap-x-12\"\n style={{\n gridTemplateAreas: `\n \"left editor\"\n \"errors editor\"\n `,\n gridTemplateRows: \"auto 1fr\",\n }}\n >\n <div className=\"flex flex-col gap-2\" style={{ gridArea: \"left\" }}>\n <OperationForm\n operation={operation}\n onAddOperationAndInitialSchema={onAddOperationAndInitialSchema}\n updateOperationName={updateOperationName}\n deleteOperation={deleteOperation}\n module={module}\n allOperationNames={allOperationNames}\n />\n <OperationDescriptionForm\n operation={operation}\n focusOnMount={operation.id === lastCreatedOperationId}\n setOperationDescription={setOperationDescription}\n />\n </div>\n\n <div className=\"relative top-8\" style={{ gridArea: \"editor\" }}>\n <label className=\"mb-2 flex cursor-pointer items-center gap-2\">\n <input\n type=\"checkbox\"\n checked={noInputRequired}\n onChange={(e) => handleToggleNoInput(e.target.checked)}\n className=\"size-4 rounded-sm border-border\"\n />\n <span className=\"text-sm text-foreground\">\n Operation with no inputs\n </span>\n </label>\n {!noInputRequired && (\n <Suspense>\n <GraphqlEditor\n doc={operation.schema ?? \"\"}\n updateDocumentInModel={handleUpdateDocument}\n customLinter={customLinter}\n />\n </Suspense>\n )}\n </div>\n\n <div style={{ gridArea: \"errors\" }}>\n <h3 className=\"my-2 text-sm font-medium text-foreground\">\n Reducer Exceptions\n </h3>\n <OperationErrors\n operation={operation}\n addOperationError={addOperationError}\n deleteOperationError={deleteOperationError}\n setOperationErrorName={setOperationErrorName}\n />\n </div>\n </div>\n );\n}\n","import { OperationForm } from \"./operation-form.js\";\nimport type { ModuleSpecification } from \"@powerhousedao/shared/document-model\";\nimport { useCallback, useId, useState } from \"react\";\nimport { Operation } from \"./operation.js\";\n\ntype Props = {\n module: ModuleSpecification;\n allOperations: ModuleSpecification[\"operations\"];\n shouldFocusNewOperation: boolean;\n updateOperationName: (id: string, name: string) => void;\n deleteOperation: (id: string) => void;\n addOperationAndInitialSchema: (\n moduleId: string,\n name: string,\n ) => Promise<string | undefined>;\n updateOperationSchema: (id: string, newDoc: string) => void;\n setOperationDescription: (id: string, description: string) => void;\n addOperationError: (\n operationId: string,\n errorName: string,\n ) => Promise<string | undefined>;\n deleteOperationError: (id: string) => void;\n setOperationErrorName: (\n operationId: string,\n errorId: string,\n name: string,\n ) => void;\n toggleNoInputRequired: (id: string, noInputRequired: boolean) => void;\n};\nexport function Operations({\n module,\n allOperations,\n shouldFocusNewOperation,\n updateOperationName,\n deleteOperation,\n addOperationAndInitialSchema,\n addOperationError,\n deleteOperationError,\n setOperationErrorName,\n updateOperationSchema,\n setOperationDescription,\n toggleNoInputRequired,\n}: Props) {\n const [lastCreatedOperationId, setLastCreatedOperationId] = useState<\n string | null\n >(null);\n const addOperationFormId = useId();\n const allOperationNames = allOperations\n .map((o) => o.name)\n .filter((n) => n !== null);\n\n const onAddOperationAndInitialSchema = useCallback(\n async (moduleId: string, name: string) => {\n const operationId = await addOperationAndInitialSchema(moduleId, name);\n if (operationId) {\n setLastCreatedOperationId(operationId);\n }\n return operationId;\n },\n [addOperationAndInitialSchema, setLastCreatedOperationId],\n );\n\n return (\n <div>\n {module.operations.map((operation) => (\n <div key={operation.id}>\n <Operation\n operation={operation}\n module={module}\n lastCreatedOperationId={lastCreatedOperationId}\n allOperationNames={allOperationNames}\n addOperationError={addOperationError}\n deleteOperationError={deleteOperationError}\n setOperationErrorName={setOperationErrorName}\n onAddOperationAndInitialSchema={onAddOperationAndInitialSchema}\n updateOperationName={updateOperationName}\n deleteOperation={deleteOperation}\n updateOperationSchema={updateOperationSchema}\n setOperationDescription={setOperationDescription}\n toggleNoInputRequired={toggleNoInputRequired}\n />\n </div>\n ))}\n <div className=\"mt-6 w-1/2 pr-6\">\n <OperationForm\n key={addOperationFormId}\n onAddOperationAndInitialSchema={onAddOperationAndInitialSchema}\n updateOperationName={updateOperationName}\n deleteOperation={deleteOperation}\n module={module}\n allOperationNames={allOperationNames}\n focusOnMount={shouldFocusNewOperation}\n />\n </div>\n </div>\n );\n}\n","import type { ModuleSpecification as TModule } from \"@powerhousedao/shared/document-model\";\nimport { ModuleForm } from \"./module-form.js\";\nimport { Operations } from \"./operations.js\";\ntype Props = {\n module?: TModule;\n modules?: TModule[];\n allOperations: TModule[\"operations\"];\n lastCreatedModuleId: string | null;\n onAddModule: (name: string) => Promise<string | undefined>;\n updateModuleName: (id: string, name: string) => void;\n deleteModule: (id: string) => void;\n updateOperationName: (id: string, name: string) => void;\n deleteOperation: (id: string) => void;\n addOperationAndInitialSchema: (\n moduleId: string,\n name: string,\n ) => Promise<string | undefined>;\n updateOperationSchema: (id: string, newDoc: string) => void;\n setOperationDescription: (id: string, description: string) => void;\n addOperationError: (\n operationId: string,\n errorName: string,\n ) => Promise<string | undefined>;\n deleteOperationError: (id: string) => void;\n setOperationErrorName: (\n operationId: string,\n errorId: string,\n name: string,\n ) => void;\n toggleNoInputRequired: (id: string, noInputRequired: boolean) => void;\n};\nexport function Module(props: Props) {\n const {\n module,\n modules,\n allOperations,\n lastCreatedModuleId,\n onAddModule,\n updateModuleName,\n deleteModule,\n updateOperationName,\n deleteOperation,\n addOperationAndInitialSchema,\n updateOperationSchema,\n setOperationDescription,\n addOperationError,\n deleteOperationError,\n setOperationErrorName,\n toggleNoInputRequired,\n } = props;\n return (\n <div className=\"relative rounded-3xl bg-muted p-6\">\n <div className=\"mb-2 w-1/2 pr-6\">\n <ModuleForm\n modules={modules}\n module={module}\n onAddModule={onAddModule}\n updateModuleName={updateModuleName}\n />\n {!!module && (\n <button\n aria-label=\"Delete module\"\n tabIndex={-1}\n className=\"absolute top-1 right-1 p-2 text-foreground transition-colors hover:hover-effect\"\n onClick={() => {\n deleteModule(module.id);\n }}\n >\n <svg className=\"size-6\" viewBox=\"0 0 24 24\" fill=\"currentcolor\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M16.9993 8.51506L15.4844 7L11.9994 10.4852L8.51497 7.00057L7 8.51562L10.4844 12.0003L7.00056 15.4843L8.51552 16.9994L11.9994 13.5153L15.4838 17L16.9988 15.4849L13.5144 12.0003L16.9993 8.51506Z\"\n />\n </svg>\n </button>\n )}\n </div>\n {!!module && (\n <Operations\n module={module}\n allOperations={allOperations}\n shouldFocusNewOperation={module.id === lastCreatedModuleId}\n updateOperationName={updateOperationName}\n deleteOperation={deleteOperation}\n addOperationAndInitialSchema={addOperationAndInitialSchema}\n updateOperationSchema={updateOperationSchema}\n setOperationDescription={setOperationDescription}\n addOperationError={addOperationError}\n deleteOperationError={deleteOperationError}\n setOperationErrorName={setOperationErrorName}\n toggleNoInputRequired={toggleNoInputRequired}\n />\n )}\n </div>\n );\n}\n","import type { ModuleSpecification as TModule } from \"@powerhousedao/shared/document-model\";\nimport { useCallback, useRef, useState } from \"react\";\nimport { Module } from \"./module.js\";\n\ntype Props = {\n modules: TModule[];\n allOperations: TModule[\"operations\"];\n addModule: (name: string) => Promise<string | undefined>;\n updateModuleName: (id: string, name: string) => void;\n deleteModule: (id: string) => void;\n updateOperationName: (id: string, name: string) => void;\n deleteOperation: (id: string) => void;\n addOperationAndInitialSchema: (\n moduleId: string,\n name: string,\n ) => Promise<string | undefined>;\n updateOperationSchema: (id: string, newDoc: string) => void;\n setOperationDescription: (id: string, description: string) => void;\n addOperationError: (\n operationId: string,\n errorName: string,\n ) => Promise<string | undefined>;\n deleteOperationError: (id: string) => void;\n setOperationErrorName: (\n operationId: string,\n errorId: string,\n name: string,\n ) => void;\n toggleNoInputRequired: (id: string, noInputRequired: boolean) => void;\n};\nexport default function Modules({\n modules,\n allOperations,\n addModule,\n updateModuleName,\n deleteModule,\n updateOperationName,\n deleteOperation,\n addOperationAndInitialSchema,\n updateOperationSchema,\n setOperationDescription,\n addOperationError,\n deleteOperationError,\n setOperationErrorName,\n toggleNoInputRequired,\n}: Props) {\n const [lastCreatedModuleId, setLastCreatedModuleId] = useState<string | null>(\n null,\n );\n const focusTrapRef = useRef<HTMLDivElement>(null);\n\n const onAddModule = useCallback(\n async (name: string) => {\n const moduleId = await addModule(name);\n if (moduleId) {\n setLastCreatedModuleId(moduleId);\n focusTrapRef.current?.focus();\n }\n return moduleId;\n },\n [addModule, setLastCreatedModuleId],\n );\n\n return (\n <div className=\"flex flex-col gap-2\">\n {modules.map((module) => (\n <Module\n key={module.id}\n module={module}\n modules={modules}\n allOperations={allOperations}\n lastCreatedModuleId={lastCreatedModuleId}\n onAddModule={onAddModule}\n updateModuleName={updateModuleName}\n deleteModule={deleteModule}\n updateOperationName={updateOperationName}\n deleteOperation={deleteOperation}\n addOperationAndInitialSchema={addOperationAndInitialSchema}\n updateOperationSchema={updateOperationSchema}\n setOperationDescription={setOperationDescription}\n addOperationError={addOperationError}\n deleteOperationError={deleteOperationError}\n setOperationErrorName={setOperationErrorName}\n toggleNoInputRequired={toggleNoInputRequired}\n />\n ))}\n <Module\n key=\"add-module\"\n modules={modules}\n allOperations={allOperations}\n lastCreatedModuleId={lastCreatedModuleId}\n onAddModule={onAddModule}\n updateModuleName={updateModuleName}\n deleteModule={deleteModule}\n updateOperationName={updateOperationName}\n deleteOperation={deleteOperation}\n addOperationAndInitialSchema={addOperationAndInitialSchema}\n updateOperationSchema={updateOperationSchema}\n setOperationDescription={setOperationDescription}\n addOperationError={addOperationError}\n deleteOperationError={deleteOperationError}\n setOperationErrorName={setOperationErrorName}\n toggleNoInputRequired={toggleNoInputRequired}\n />\n {/* Focus trap to prevent tabbing out of the editor */}\n <div\n ref={focusTrapRef}\n tabIndex={0}\n className=\"size-0 overflow-hidden\"\n aria-hidden=\"true\"\n />\n </div>\n );\n}\n","import { Modal } from \"@powerhousedao/design-system\";\nimport {\n ConnectSelect,\n ModalButton,\n} from \"@powerhousedao/design-system/connect\";\nimport type { DocumentSpecification } from \"@powerhousedao/shared/document-model\";\nimport { useState } from \"react\";\nimport { Button } from \"./button.js\";\n\nconst compactButtonStyle =\n \"min-h-0 min-w-0 flex-none rounded-lg px-6 py-1.5 text-sm whitespace-nowrap\";\n\ntype VersionControlsProps = {\n specifications: DocumentSpecification[];\n viewedVersion: number;\n onViewVersion: (version: number | \"latest\") => void;\n onReleaseNewVersion: () => void;\n};\n\nexport function VersionControls(props: VersionControlsProps) {\n const { specifications, viewedVersion, onViewVersion, onReleaseNewVersion } =\n props;\n const [showReleaseModal, setShowReleaseModal] = useState(false);\n const latestVersion = specifications[specifications.length - 1].version;\n const nextVersion = latestVersion + 1;\n\n return (\n <div className=\"mb-4 flex items-center justify-between gap-4\">\n <div className=\"flex items-center gap-2\">\n <span\n className=\"rounded-md bg-muted px-2 py-0.5 font-mono text-xs text-foreground\"\n data-testid=\"model-version-badge\"\n >\n Version {viewedVersion}\n </span>\n {specifications.length >= 2 && (\n <div\n aria-label=\"Document model version\"\n data-testid=\"model-version-switcher\"\n >\n <ConnectSelect\n absolutePositionMenu\n containerClassName=\"z-10 [&_svg]:size-4\"\n id=\"model-version-switcher\"\n itemClassName=\"gap-1 px-2 py-1 font-mono text-xs leading-none [&_p:empty]:hidden\"\n items={specifications.map((spec) => ({\n value: String(spec.version),\n displayValue: (\n <span className=\"normal-case\">\n {spec.version === latestVersion\n ? `v${spec.version} (latest)`\n : `v${spec.version} (frozen)`}\n </span>\n ),\n }))}\n listClassName=\"border border-t-0 border-border shadow-md\"\n menuClassName=\"min-w-0 pr-1.5\"\n onChange={(value) => {\n const version = Number(value);\n onViewVersion(version === latestVersion ? \"latest\" : version);\n }}\n value={String(viewedVersion)}\n />\n </div>\n )}\n </div>\n <Button\n className=\"inline-flex h-8 items-center justify-center py-0\"\n data-testid=\"release-new-version-button\"\n onClick={() => setShowReleaseModal(true)}\n type=\"button\"\n >\n Release new version\n </Button>\n <Modal\n open={showReleaseModal}\n onOpenChange={(status: boolean) => {\n if (!status) setShowReleaseModal(false);\n }}\n >\n <div className=\"w-[440px] p-6\">\n <div className=\"pb-2 text-2xl font-bold text-foreground\">\n Release version {nextVersion}\n </div>\n <div className=\"my-4 rounded-md bg-background p-4 text-left text-sm text-foreground\">\n <p>\n Version {latestVersion} will be frozen as-is. Version{\" \"}\n {nextVersion} starts as an identical copy, and all further edits\n apply to version {nextVersion}.\n </p>\n <p className=\"mt-3\">\n Existing version {latestVersion} documents will be upgradeable\n once you define the migration.\n </p>\n </div>\n <div className=\"mt-4 flex justify-between gap-3\">\n <ModalButton\n className={compactButtonStyle}\n onClick={() => setShowReleaseModal(false)}\n variant=\"cancel\"\n >\n Cancel\n </ModalButton>\n <ModalButton\n className={compactButtonStyle}\n data-testid=\"confirm-release-button\"\n onClick={() => {\n setShowReleaseModal(false);\n onReleaseNewVersion();\n }}\n variant=\"confirm\"\n >\n Release version {nextVersion}\n </ModalButton>\n </div>\n </div>\n </Modal>\n </div>\n );\n}\n\nexport function FrozenVersionBanner(props: {\n viewedVersion: number;\n latestVersion: number;\n}) {\n const { viewedVersion, latestVersion } = props;\n return (\n <div\n className=\"mb-4 rounded-md border border-border bg-muted p-3 text-sm text-foreground\"\n data-testid=\"frozen-version-banner\"\n >\n Version {viewedVersion} is frozen. You're viewing it read-only. Edits\n go to version {latestVersion}.\n </div>\n );\n}\n","import { Modal } from \"@powerhousedao/design-system\";\nimport { ModalButton } from \"@powerhousedao/design-system/connect\";\nimport type { VersionAdvisoryPrompt } from \"../hooks/useVersionAdvisory.js\";\n\nconst compactButtonStyle =\n \"min-h-0 min-w-0 flex-none rounded-lg px-4 py-1.5 text-sm whitespace-nowrap\";\n\nfunction FieldDiffList(props: { label: string; fields: string[] }) {\n const { label, fields } = props;\n if (fields.length === 0) return null;\n return (\n <div className=\"mt-3\">\n <p className=\"mb-1.5\">{label}</p>\n <div className=\"flex flex-col items-start gap-1\">\n {fields.map((field) => (\n <span\n className=\"rounded-md bg-muted px-2 py-0.5 font-mono text-xs text-foreground\"\n key={field}\n >\n {field}\n </span>\n ))}\n </div>\n </div>\n );\n}\n\ntype VersionAdvisoryModalProps = {\n prompt: VersionAdvisoryPrompt | undefined;\n onReleaseFirst: () => void;\n onKeepEditing: () => void;\n onCancel: () => void;\n};\n\nexport function VersionAdvisoryModal(props: VersionAdvisoryModalProps) {\n const { prompt, onReleaseFirst, onKeepEditing, onCancel } = props;\n if (!prompt) return null;\n const { version, reason, diff } = prompt;\n const nextVersion = version + 1;\n\n return (\n <Modal\n open\n onOpenChange={(status: boolean) => {\n if (!status) onCancel();\n }}\n >\n <div className=\"w-[440px] p-6\" data-testid=\"version-advisory-modal\">\n <div className=\"pb-2 text-2xl font-bold text-foreground\">\n Is version {version} of this model already in use?\n </div>\n <div className=\"my-4 rounded-md bg-background p-4 text-left text-sm text-foreground\">\n <p>\n {reason} Documents that were already created with version {version}{\" \"}\n may stop working correctly.\n </p>\n {diff && (\n <>\n <FieldDiffList fields={diff.addedFields} label=\"New fields:\" />\n <FieldDiffList\n fields={diff.removedFields}\n label=\"Removed fields:\"\n />\n <FieldDiffList\n fields={diff.changedFields}\n label=\"Changed fields:\"\n />\n </>\n )}\n <p className=\"mt-3\">\n If others are already using version {version}, release version{\" \"}\n {nextVersion} first. Your change will go into version {nextVersion},\n and existing documents can be updated safely.\n </p>\n </div>\n <div className=\"mt-4 flex flex-col gap-2\">\n <ModalButton\n className={compactButtonStyle}\n data-testid=\"advisory-release-first\"\n onClick={onReleaseFirst}\n variant=\"confirm\"\n >\n {`It's in use — release v${nextVersion} first`}\n </ModalButton>\n <ModalButton\n className={compactButtonStyle}\n data-testid=\"advisory-keep-editing\"\n onClick={onKeepEditing}\n variant=\"cancel\"\n >\n Still in development — keep editing v{version}\n </ModalButton>\n </div>\n </div>\n </Modal>\n );\n}\n","import type { PHDocumentEditorConfig } from \"@powerhousedao/reactor-browser\";\n\nexport const editorConfig: PHDocumentEditorConfig = {\n isExternalControlsEnabled: false,\n};\n","import {\n useDocumentOfType,\n useSelectedDocumentOfType,\n} from \"@powerhousedao/reactor-browser\";\nimport type {\n DocumentModelAction,\n DocumentModelDocument,\n} from \"@powerhousedao/shared/document-model\";\n\nexport function useDocumentModelDocument(\n documentId: string | undefined | null,\n): ReturnType<\n typeof useDocumentOfType<DocumentModelDocument, DocumentModelAction>\n> {\n return useDocumentOfType<DocumentModelDocument, DocumentModelAction>(\n documentId,\n \"powerhouse/document-model\",\n );\n}\n\nexport function useSelectedDocumentModelDocument(): ReturnType<\n typeof useSelectedDocumentOfType<DocumentModelDocument, DocumentModelAction>\n> {\n return useSelectedDocumentOfType<DocumentModelDocument, DocumentModelAction>(\n \"powerhouse/document-model\",\n );\n}\n","import type {\n DefinitionNode,\n DocumentNode,\n EnumTypeDefinitionNode,\n InputObjectTypeDefinitionNode,\n ObjectTypeDefinitionNode,\n} from \"graphql\";\nimport { Kind, parse, print } from \"graphql\";\nimport type {\n DocumentModelAction,\n DocumentSpecification,\n ModuleSpecification,\n OperationSpecification,\n} from \"@powerhousedao/shared/document-model\";\nimport { compareStringsWithoutWhitespace } from \"./helpers.js\";\n\nexport type StateShapeDiff = {\n addedFields: string[];\n removedFields: string[];\n changedFields: string[];\n};\n\ntype FieldMap = Map<string, string>;\ntype TypeFields = Map<string, Map<string, string>>;\n\ntype ShapeTypeNode =\n | ObjectTypeDefinitionNode\n | InputObjectTypeDefinitionNode\n | EnumTypeDefinitionNode;\n\nfunction isShapeTypeNode(node: DefinitionNode): node is ShapeTypeNode {\n return (\n node.kind === Kind.OBJECT_TYPE_DEFINITION ||\n node.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION ||\n node.kind === Kind.ENUM_TYPE_DEFINITION\n );\n}\n\nfunction collectTypeFields(doc: DocumentNode): TypeFields {\n const types: TypeFields = new Map();\n for (const definition of doc.definitions) {\n if (!isShapeTypeNode(definition)) continue;\n const fields = new Map<string, string>();\n if (definition.kind === Kind.ENUM_TYPE_DEFINITION) {\n for (const value of definition.values ?? []) {\n fields.set(value.name.value, \"value\");\n }\n } else {\n for (const field of definition.fields ?? []) {\n fields.set(field.name.value, print(field.type));\n }\n }\n types.set(definition.name.value, fields);\n }\n return types;\n}\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nfunction replaceTypeName(\n printedType: string,\n oldName: string,\n newName: string,\n): string {\n return printedType.replace(\n new RegExp(`\\\\b${escapeRegExp(oldName)}\\\\b`, \"g\"),\n newName,\n );\n}\n\nfunction typeSignature(name: string, fields: Map<string, string>): string {\n return [...fields.entries()]\n .map(\n ([field, type]) => `${field}:${replaceTypeName(type, name, \"__SELF__\")}`,\n )\n .sort()\n .join(\"|\");\n}\n\nfunction detectTypeRenames(\n oldTypes: TypeFields,\n newTypes: TypeFields,\n): Map<string, string> {\n const renames = new Map<string, string>();\n const removed = [...oldTypes.keys()].filter((name) => !newTypes.has(name));\n const added = new Set(\n [...newTypes.keys()].filter((name) => !oldTypes.has(name)),\n );\n for (const oldName of removed) {\n const oldSignature = typeSignature(oldName, oldTypes.get(oldName)!);\n for (const newName of added) {\n if (typeSignature(newName, newTypes.get(newName)!) === oldSignature) {\n renames.set(oldName, newName);\n added.delete(newName);\n break;\n }\n }\n }\n return renames;\n}\n\nfunction flattenFields(\n types: TypeFields,\n renames: Map<string, string>,\n): FieldMap {\n const fields: FieldMap = new Map();\n for (const [typeName, typeFields] of types) {\n const resolvedTypeName = renames.get(typeName) ?? typeName;\n for (const [fieldName, printedType] of typeFields) {\n let resolvedType = printedType;\n for (const [oldName, newName] of renames) {\n resolvedType = replaceTypeName(resolvedType, oldName, newName);\n }\n fields.set(`${resolvedTypeName}.${fieldName}`, resolvedType);\n }\n }\n return fields;\n}\n\nexport function hasShapeChange(diff: StateShapeDiff): boolean {\n return (\n diff.addedFields.length > 0 ||\n diff.removedFields.length > 0 ||\n diff.changedFields.length > 0\n );\n}\n\nexport function diffSdlShapes(oldSdl: string, newSdl: string): StateShapeDiff {\n const empty: StateShapeDiff = {\n addedFields: [],\n removedFields: [],\n changedFields: [],\n };\n let oldDoc: DocumentNode;\n let newDoc: DocumentNode;\n try {\n oldDoc = parse(oldSdl);\n newDoc = parse(newSdl);\n } catch {\n return empty;\n }\n const oldTypes = collectTypeFields(oldDoc);\n const newTypes = collectTypeFields(newDoc);\n const renames = detectTypeRenames(oldTypes, newTypes);\n const oldFields = flattenFields(oldTypes, renames);\n const newFields = flattenFields(newTypes, new Map());\n const diff: StateShapeDiff = {\n addedFields: [],\n removedFields: [],\n changedFields: [],\n };\n for (const [key, newType] of newFields) {\n const oldType = oldFields.get(key);\n if (oldType === undefined) {\n diff.addedFields.push(key);\n } else if (oldType !== newType) {\n diff.changedFields.push(`${key}: ${oldType} → ${newType}`);\n }\n }\n for (const key of oldFields.keys()) {\n if (!newFields.has(key)) {\n diff.removedFields.push(key);\n }\n }\n return diff;\n}\n\nexport type ActionClassification =\n | { kind: \"safe\" }\n | { kind: \"version-relevant\"; reason: string; diff?: StateShapeDiff };\n\nconst SAFE: ActionClassification = { kind: \"safe\" };\n\nfunction isBlank(value: string | null | undefined): boolean {\n return !value || !value.trim() || value.trim() === \"{}\";\n}\n\n/**\n * True for a blank SDL, or an SDL whose types contain nothing but the\n * `_placeholder` field the editor seeds new state/operation schemas with\n * (see `makeInitialSchemaDoc` / `makeOperationInitialDoc` in ./helpers.ts).\n * Replacing a placeholder-only schema with real fields is a user's first\n * edit on a brand-new model, not a version-relevant change.\n */\nfunction isPlaceholderOnlySchema(sdl: string): boolean {\n if (isBlank(sdl)) return true;\n let doc: DocumentNode;\n try {\n doc = parse(sdl);\n } catch {\n return false;\n }\n const types = collectTypeFields(doc);\n return [...types.values()].every(\n (fields) =>\n fields.size === 0 || (fields.size === 1 && fields.has(\"_placeholder\")),\n );\n}\n\nfunction findOperation(\n spec: DocumentSpecification,\n operationId: string,\n): OperationSpecification | undefined {\n for (const module of spec.modules) {\n const operation = module.operations.find((op) => op.id === operationId);\n if (operation) return operation;\n }\n return undefined;\n}\n\nfunction addedSinceLastRelease(\n operationId: string,\n previousSpec: DocumentSpecification | undefined,\n): boolean {\n return (\n previousSpec !== undefined && !findOperation(previousSpec, operationId)\n );\n}\n\nfunction classifySetStateSchema(\n input: { schema: string; scope: string },\n latestSpec: DocumentSpecification,\n): ActionClassification {\n const currentSchema =\n input.scope === \"local\"\n ? latestSpec.state.local.schema\n : latestSpec.state.global.schema;\n if (isPlaceholderOnlySchema(currentSchema)) return SAFE;\n const diff = diffSdlShapes(currentSchema, input.schema);\n if (!hasShapeChange(diff)) return SAFE;\n return {\n kind: \"version-relevant\",\n reason:\n input.scope === \"local\"\n ? `You're changing the local fields that version ${latestSpec.version} documents store.`\n : `You're changing the fields that version ${latestSpec.version} documents store.`,\n diff,\n };\n}\n\n/**\n * The editor pre-fills a fresh model's initial value from the placeholder\n * schema, so a value that is blank or carries only the `_placeholder` key is\n * still being initialized rather than changed.\n */\nfunction isPlaceholderOnlyInitialValue(value: string): boolean {\n if (isBlank(value)) return true;\n let parsed: unknown;\n try {\n parsed = JSON.parse(value);\n } catch {\n return false;\n }\n if (typeof parsed !== \"object\" || parsed === null) return false;\n return Object.keys(parsed).every((key) => key === \"_placeholder\");\n}\n\nfunction classifySetInitialState(\n input: { initialValue: string; scope: string },\n latestSpec: DocumentSpecification,\n): ActionClassification {\n const currentValue =\n input.scope === \"local\"\n ? latestSpec.state.local.initialValue\n : latestSpec.state.global.initialValue;\n if (isPlaceholderOnlyInitialValue(currentValue)) return SAFE;\n if (compareStringsWithoutWhitespace(currentValue, input.initialValue)) {\n return SAFE;\n }\n return {\n kind: \"version-relevant\",\n reason: `You're changing the starting content that version ${latestSpec.version} documents are built on.`,\n };\n}\n\nfunction classifyOperationChange(\n action: DocumentModelAction,\n operationId: string,\n latestSpec: DocumentSpecification,\n previousSpec: DocumentSpecification | undefined,\n): ActionClassification {\n if (addedSinceLastRelease(operationId, previousSpec)) return SAFE;\n const operation = findOperation(latestSpec, operationId);\n if (!operation) return SAFE;\n const operationLabel = operation.name || \"an operation\";\n switch (action.type) {\n case \"DELETE_OPERATION\":\n return {\n kind: \"version-relevant\",\n reason: `You're removing the \"${operationLabel}\" operation from version ${latestSpec.version}.`,\n };\n case \"SET_OPERATION_NAME\": {\n if (isBlank(operation.name)) return SAFE;\n return {\n kind: \"version-relevant\",\n reason: `You're renaming the \"${operationLabel}\" operation in version ${latestSpec.version}.`,\n };\n }\n case \"SET_OPERATION_SCHEMA\": {\n if (isPlaceholderOnlySchema(operation.schema ?? \"\")) return SAFE;\n if (isBlank(action.input.schema)) {\n return {\n kind: \"version-relevant\",\n reason: `You're changing the information that the \"${operationLabel}\" operation accepts in version ${latestSpec.version}.`,\n };\n }\n const diff = diffSdlShapes(\n operation.schema ?? \"\",\n action.input.schema ?? \"\",\n );\n if (!hasShapeChange(diff)) return SAFE;\n return {\n kind: \"version-relevant\",\n reason: `You're changing the information that the \"${operationLabel}\" operation accepts in version ${latestSpec.version}.`,\n diff,\n };\n }\n default:\n return SAFE;\n }\n}\n\nfunction classifyDeleteModule(\n moduleId: string,\n latestSpec: DocumentSpecification,\n previousSpec: DocumentSpecification | undefined,\n): ActionClassification {\n const module: ModuleSpecification | undefined = latestSpec.modules.find(\n (candidate) => candidate.id === moduleId,\n );\n if (!module || module.operations.length === 0) return SAFE;\n const allAddedSinceRelease = module.operations.every((operation) =>\n addedSinceLastRelease(operation.id, previousSpec),\n );\n if (allAddedSinceRelease) return SAFE;\n return {\n kind: \"version-relevant\",\n reason: `You're removing the \"${module.name}\" module and all of its operations from version ${latestSpec.version}.`,\n };\n}\n\n/**\n * Classifies a document-model action as version-relevant (would break\n * documents created with the current version) or safe. `previousSpec` is the\n * last released specification, used to exempt operations added since the\n * release.\n */\nexport function classifyDocumentModelAction(\n action: DocumentModelAction,\n latestSpec: DocumentSpecification,\n previousSpec?: DocumentSpecification,\n): ActionClassification {\n switch (action.type) {\n case \"SET_STATE_SCHEMA\":\n return classifySetStateSchema(action.input, latestSpec);\n case \"SET_INITIAL_STATE\":\n return classifySetInitialState(action.input, latestSpec);\n case \"DELETE_OPERATION\":\n case \"SET_OPERATION_NAME\":\n case \"SET_OPERATION_SCHEMA\":\n return classifyOperationChange(\n action,\n action.input.id,\n latestSpec,\n previousSpec,\n );\n case \"DELETE_MODULE\":\n return classifyDeleteModule(action.input.id, latestSpec, previousSpec);\n default:\n return SAFE;\n }\n}\n\nexport type DispatchDecision =\n | { kind: \"dispatch\" }\n | { kind: \"prompt\"; reason: string; diff?: StateShapeDiff };\n\n/**\n * Pure decision core of the version advisory: given the actions about to be\n * dispatched, decide whether to dispatch immediately or prompt the user.\n */\nexport function decideDispatch(\n actions: DocumentModelAction[],\n latestSpec: DocumentSpecification,\n previousSpec: DocumentSpecification | undefined,\n hasSessionChoice: boolean,\n): DispatchDecision {\n if (hasSessionChoice) return { kind: \"dispatch\" };\n for (const action of actions) {\n const classification = classifyDocumentModelAction(\n action,\n latestSpec,\n previousSpec,\n );\n if (classification.kind === \"version-relevant\") {\n return {\n kind: \"prompt\",\n reason: classification.reason,\n diff: classification.diff,\n };\n }\n }\n return { kind: \"dispatch\" };\n}\n","import type {\n DocumentModelAction,\n DocumentSpecification,\n} from \"@powerhousedao/shared/document-model\";\nimport { releaseNewVersion } from \"@powerhousedao/shared/document-model\";\nimport { useRef, useState } from \"react\";\nimport type { StateShapeDiff } from \"../utils/change-classification.js\";\nimport { decideDispatch } from \"../utils/change-classification.js\";\nimport type { useSelectedDocumentModelDocument } from \"./useDocumentModelDocument.js\";\n\nexport type DocumentModelDispatch = NonNullable<\n ReturnType<typeof useSelectedDocumentModelDocument>[1]\n>;\n\nexport type VersionAdvisoryPrompt = {\n version: number;\n reason: string;\n diff?: StateShapeDiff;\n};\n\n/**\n * Versions the user has confirmed as \"still in development\" (or that were\n * just created via an explicit release) for this browser session. Keyed by\n * `${documentId}:${version}`. Deliberately in-memory: a publisher returning\n * in a later session is asked again, which is when the reminder matters.\n */\nconst sessionVersionChoices = new Set<string>();\n\nexport function useVersionAdvisory(args: {\n documentId: string;\n latestSpec: DocumentSpecification;\n previousSpec?: DocumentSpecification;\n dispatch: DocumentModelDispatch;\n onReleaseError?: (message: string) => void;\n}): {\n guardedDispatch: DocumentModelDispatch;\n prompt: VersionAdvisoryPrompt | undefined;\n releaseFirst: () => void;\n keepEditing: () => void;\n cancelAdvisory: () => void;\n markVersionInDevelopment: (version: number) => void;\n} {\n const { documentId, latestSpec, previousSpec, dispatch, onReleaseError } =\n args;\n const [prompt, setPrompt] = useState<VersionAdvisoryPrompt | undefined>(\n undefined,\n );\n const pendingRef = useRef<Parameters<DocumentModelDispatch> | undefined>(\n undefined,\n );\n const choiceKey = `${documentId}:${latestSpec.version}`;\n\n const guardedDispatch: DocumentModelDispatch = (...dispatchArgs) => {\n const [action] = dispatchArgs;\n const actionList = Array.isArray(action) ? action : [action];\n const actions = actionList.filter(\n (candidate): candidate is DocumentModelAction => candidate !== undefined,\n );\n const decision = decideDispatch(\n actions,\n latestSpec,\n previousSpec,\n sessionVersionChoices.has(choiceKey),\n );\n if (decision.kind === \"dispatch\") {\n dispatch(...dispatchArgs);\n return;\n }\n pendingRef.current = dispatchArgs;\n setPrompt({\n version: latestSpec.version,\n reason: decision.reason,\n diff: decision.diff,\n });\n };\n\n const flushPending = () => {\n const pending = pendingRef.current;\n pendingRef.current = undefined;\n if (pending) {\n dispatch(...pending);\n }\n };\n\n const releaseFirst = () => {\n setPrompt(undefined);\n if (!pendingRef.current) return;\n dispatch(\n releaseNewVersion(),\n (errors) => {\n if (errors.length > 0) {\n pendingRef.current = undefined;\n onReleaseError?.(errors[0].message);\n }\n },\n () => {\n if (!pendingRef.current) return;\n sessionVersionChoices.add(`${documentId}:${latestSpec.version + 1}`);\n flushPending();\n },\n );\n };\n\n const keepEditing = () => {\n sessionVersionChoices.add(choiceKey);\n setPrompt(undefined);\n flushPending();\n };\n\n const cancelAdvisory = () => {\n pendingRef.current = undefined;\n setPrompt(undefined);\n };\n\n const markVersionInDevelopment = (version: number) => {\n sessionVersionChoices.add(`${documentId}:${version}`);\n };\n\n return {\n guardedDispatch,\n prompt,\n releaseFirst,\n keepEditing,\n cancelAdvisory,\n markVersionInDevelopment,\n };\n}\n","import { DocumentToolbar } from \"@powerhousedao/design-system/connect\";\nimport {\n usePHToast,\n useSetPHDocumentEditorConfig,\n} from \"@powerhousedao/reactor-browser\";\nimport { pascalCase } from \"change-case\";\nimport { generateId } from \"@powerhousedao/shared/document-model\";\nimport {\n addModule,\n addOperation,\n addOperationError,\n deleteModule,\n deleteOperation,\n deleteOperationError,\n releaseNewVersion,\n setAuthorName,\n setAuthorWebsite,\n setInitialState,\n setModelDescription,\n setModelExtension,\n setModelId,\n setModelName,\n setModuleName,\n setOperationDescription,\n setOperationErrorName,\n setOperationName,\n setOperationSchema,\n setStateSchema,\n} from \"@powerhousedao/shared/document-model\";\nimport { lazy, Suspense, useEffect, useRef, useState } from \"react\";\nimport { Divider } from \"./components/divider.js\";\nimport ModelMetadata from \"./components/model-metadata-form.js\";\nimport Modules from \"./components/modules.js\";\nimport {\n FrozenVersionBanner,\n VersionControls,\n} from \"./components/version-controls.js\";\nimport { VersionAdvisoryModal } from \"./components/version-advisory-modal.js\";\nimport { editorConfig } from \"./config.js\";\nimport { SchemaContextProvider } from \"./context/schema-context.js\";\nimport { useSelectedDocumentModelDocument } from \"./hooks/useDocumentModelDocument.js\";\nimport { useVersionAdvisory } from \"./hooks/useVersionAdvisory.js\";\nimport type { Scope } from \"./types/documents.js\";\nimport {\n compareStringsWithoutWhitespace,\n initializeModelSchema,\n makeEmptyOperationSchema,\n makeOperationInitialDoc,\n} from \"./utils/helpers.js\";\nconst StateSchemas = lazy(() => import(\"./components/state-schemas.js\"));\n\n// Module-level no-ops so StateSchemas' props are stable across renders while\n// a frozen (non-latest) version is being viewed. They intentionally do\n// nothing: mutating handlers baseline on latestSpec, so if StateSchemas'\n// internal auto-sync effect were to fire while viewing an old version, it\n// would otherwise copy that old version's content into the latest spec.\nconst noopSetStateSchema: (schema: string, scope: Scope) => void = () =>\n undefined;\nconst noopSetInitialState: (initialValue: string, scope: Scope) => void = () =>\n undefined;\n\nexport default function Editor() {\n useSetPHDocumentEditorConfig(editorConfig);\n const toast = usePHToast();\n const [document, dispatch] = useSelectedDocumentModelDocument();\n const [scope, setScope] = useState<Scope>(\"global\");\n const documentNodeName = document.header.name;\n const {\n name: modelName,\n id: documentType,\n extension,\n description,\n author: { name: authorName, website: authorWebsite },\n } = document.state.global;\n const specifications = document.state.global.specifications;\n const latestSpec = specifications[specifications.length - 1];\n const previousSpec =\n specifications.length >= 2\n ? specifications[specifications.length - 2]\n : undefined;\n const [viewedVersion, setViewedVersion] = useState<number | \"latest\">(\n \"latest\",\n );\n const viewedSpec =\n viewedVersion === \"latest\"\n ? latestSpec\n : (specifications.find((spec) => spec.version === viewedVersion) ??\n latestSpec);\n const isViewingFrozenVersion = viewedSpec.version !== latestSpec.version;\n const {\n state: {\n global: {\n schema: globalStateSchema,\n initialValue: globalStateInitialValue,\n },\n local: { schema: localStateSchema, initialValue: localStateInitialValue },\n },\n modules,\n } = viewedSpec;\n const operations = modules.flatMap((module) => module.operations);\n const {\n state: {\n global: {\n schema: latestGlobalStateSchema,\n initialValue: latestGlobalStateInitialValue,\n },\n local: {\n schema: latestLocalStateSchema,\n initialValue: latestLocalStateInitialValue,\n },\n },\n modules: latestModules,\n } = latestSpec;\n const latestOperations = latestModules.flatMap((module) => module.operations);\n const shouldSetInitialName = useRef(\n !modelName && !!documentNodeName && latestOperations.length === 0,\n );\n\n useEffect(() => {\n if (!shouldSetInitialName.current || !documentNodeName) return;\n\n const initialSchemaDoc = initializeModelSchema(documentNodeName);\n const actions = [\n setModelName({ name: documentNodeName }),\n setStateSchema({ schema: initialSchemaDoc, scope: \"global\" }),\n ];\n dispatch(actions);\n shouldSetInitialName.current = false;\n }, [documentNodeName, dispatch]);\n\n const {\n guardedDispatch,\n prompt,\n releaseFirst,\n keepEditing,\n cancelAdvisory,\n markVersionInDevelopment,\n } = useVersionAdvisory({\n documentId: document.header.id,\n latestSpec,\n previousSpec,\n dispatch,\n onReleaseError: (message) => {\n if (toast) toast(message, { type: \"connect-warning\" });\n },\n });\n\n const handleReleaseNewVersion = () => {\n const nextVersion = latestSpec.version + 1;\n dispatch(\n releaseNewVersion(),\n (errors) => {\n if (errors.length > 0 && toast) {\n toast(errors[0].message, { type: \"connect-warning\" });\n }\n },\n () => {\n markVersionInDevelopment(nextVersion);\n setViewedVersion(\"latest\");\n },\n );\n };\n\n const operationSchemasSdl = operations\n .flatMap((operation) => operation.schema ?? [])\n .join(\"\\n\");\n\n const handleSetModelId = (id: string) => {\n if (compareStringsWithoutWhitespace(id, documentType)) return;\n guardedDispatch([setModelId({ id })]);\n };\n\n const handleSetModelDescription = (newDescription: string) => {\n if (compareStringsWithoutWhitespace(newDescription, description)) return;\n guardedDispatch(setModelDescription({ description: newDescription }));\n };\n\n const handleSetModelExtension = (newExtension: string) => {\n if (compareStringsWithoutWhitespace(newExtension, extension)) return;\n guardedDispatch(setModelExtension({ extension: newExtension }));\n };\n\n const handleSetModelName = (newName: string) => {\n if (compareStringsWithoutWhitespace(newName, modelName)) return;\n guardedDispatch(setModelName({ name: newName }));\n };\n\n const handleSetAuthorName = (newAuthorName: string) => {\n if (compareStringsWithoutWhitespace(newAuthorName, authorName)) return;\n guardedDispatch(setAuthorName({ authorName: newAuthorName }));\n };\n\n const handleSetAuthorWebsite = (newAuthorWebsite: string) => {\n if (compareStringsWithoutWhitespace(newAuthorWebsite, authorWebsite ?? \"\"))\n return;\n guardedDispatch(setAuthorWebsite({ authorWebsite: newAuthorWebsite }));\n };\n\n const handleSetStateSchema = (newSchema: string, scope: Scope) => {\n const oldSchema =\n scope === \"global\" ? latestGlobalStateSchema : latestLocalStateSchema;\n if (compareStringsWithoutWhitespace(newSchema, oldSchema)) return;\n guardedDispatch(setStateSchema({ schema: newSchema, scope }));\n };\n\n const handleSetInitialState = (newInitialValue: string, scope: Scope) => {\n const oldInitialValue =\n scope === \"global\"\n ? latestGlobalStateInitialValue\n : latestLocalStateInitialValue;\n if (compareStringsWithoutWhitespace(newInitialValue, oldInitialValue))\n return;\n guardedDispatch(setInitialState({ initialValue: newInitialValue, scope }));\n };\n\n const handleAddModule = (name: string): Promise<string | undefined> => {\n return new Promise((resolve) => {\n try {\n if (\n latestModules.some((module) =>\n compareStringsWithoutWhitespace(module.name, name),\n )\n ) {\n resolve(undefined);\n return;\n }\n const id = generateId();\n guardedDispatch(addModule({ id, name }));\n resolve(id);\n } catch (error) {\n console.error(\"Failed to add module:\", error);\n resolve(undefined);\n }\n });\n };\n\n const handleSetModuleName = (id: string, name: string) => {\n if (\n latestModules.some((module) =>\n compareStringsWithoutWhitespace(module.name, name),\n )\n )\n return;\n guardedDispatch(setModuleName({ id, name }));\n };\n\n const handleDeleteModule = (id: string) => {\n guardedDispatch(deleteModule({ id }));\n };\n\n const handleAddOperation = (\n moduleId: string,\n name: string,\n ): Promise<string | undefined> => {\n return new Promise((resolve) => {\n const id = generateId();\n guardedDispatch(\n addOperation({ id, moduleId, name, scope }),\n (errors) => {\n if (errors.length > 0) {\n if (toast) {\n toast(errors[0].message, { type: \"connect-warning\" });\n }\n resolve(undefined);\n } else {\n resolve(id);\n }\n },\n () => resolve(id),\n );\n });\n };\n\n const handleSetOperationName = (id: string, name: string) => {\n guardedDispatch(setOperationName({ id, name }), (errors) => {\n if (errors.length > 0 && toast) {\n toast(errors[0].message, { type: \"connect-warning\" });\n }\n });\n };\n\n const handleSetOperationSchema = (id: string, newSchema: string) => {\n const operation = latestOperations.find((operation) => operation.id === id);\n if (\n operation?.schema &&\n compareStringsWithoutWhitespace(newSchema, operation.schema)\n )\n return;\n guardedDispatch(setOperationSchema({ id, schema: newSchema }));\n };\n\n const handleToggleNoInputRequired = (\n id: string,\n noInputRequired: boolean,\n ) => {\n const operation = latestOperations.find((op) => op.id === id);\n if (!operation?.name) return;\n\n if (noInputRequired) {\n guardedDispatch(\n setOperationSchema({\n id,\n schema: makeEmptyOperationSchema(operation.name),\n }),\n );\n } else {\n guardedDispatch(\n setOperationSchema({\n id,\n schema: makeOperationInitialDoc(operation.name),\n }),\n );\n }\n };\n\n const handleSetOperationDescription = (\n id: string,\n newDescription: string,\n ) => {\n const operationDescription =\n latestOperations.find((operation) => operation.id === id)?.description ??\n \"\";\n if (compareStringsWithoutWhitespace(operationDescription, newDescription))\n return;\n guardedDispatch(\n setOperationDescription({ id, description: newDescription }),\n );\n };\n\n const handleDeleteOperation = (id: string) => {\n guardedDispatch(deleteOperation({ id }));\n };\n\n const handleAddOperationError = (\n operationId: string,\n errorName: string,\n ): Promise<string | undefined> => {\n return new Promise((resolve) => {\n try {\n const operation = latestOperations.find(\n (operation) => operation.id === operationId,\n );\n const operationErrorNames =\n operation?.errors.map((error) => error.name).filter(Boolean) ?? [];\n if (\n operationErrorNames.some((name) =>\n compareStringsWithoutWhitespace(name, errorName),\n )\n ) {\n resolve(undefined);\n return;\n }\n const id = generateId();\n const errorCode = pascalCase(errorName);\n guardedDispatch(\n addOperationError({ id, operationId, errorName, errorCode }),\n );\n resolve(id);\n } catch (error) {\n console.error(\"Failed to add operation error:\", error);\n resolve(undefined);\n }\n });\n };\n\n const handleDeleteOperationError = (id: string) => {\n guardedDispatch(deleteOperationError({ id }));\n };\n\n const handleSetOperationErrorName = (\n operationId: string,\n errorId: string,\n errorName: string,\n ) => {\n const operation = latestOperations.find(\n (operation) => operation.id === operationId,\n );\n const operationErrorNames =\n operation?.errors.map((error) => error.name).filter(Boolean) ?? [];\n if (\n operationErrorNames.some((name) =>\n compareStringsWithoutWhitespace(name, errorName),\n )\n )\n return;\n guardedDispatch(setOperationErrorName({ id: errorId, errorName }));\n };\n\n const addOperationAndInitialSchema = async (\n moduleId: string,\n name: string,\n ): Promise<string | undefined> => {\n try {\n const id = await handleAddOperation(moduleId, name);\n if (!id) return undefined;\n try {\n handleSetOperationSchema(id, makeOperationInitialDoc(name));\n return id;\n } catch (error) {\n console.error(\"Failed to update operation schema:\", error);\n return undefined;\n }\n } catch (error) {\n console.error(\"Failed to add operation and schema:\", error);\n return undefined;\n }\n };\n\n return (\n <main className=\"min-h-dvh bg-background p-6\">\n <DocumentToolbar />\n <SchemaContextProvider\n globalStateSchemaSdl={globalStateSchema}\n localStateSchemaSdl={localStateSchema}\n operationSchemasSdl={operationSchemasSdl}\n >\n <div className=\"mx-auto max-w-6xl px-4 pt-8\">\n <VersionControls\n specifications={specifications}\n viewedVersion={viewedSpec.version}\n onViewVersion={setViewedVersion}\n onReleaseNewVersion={handleReleaseNewVersion}\n />\n <ModelMetadata\n name={modelName}\n documentType={documentType}\n extension={extension}\n description={description}\n authorName={authorName}\n authorWebsite={authorWebsite ?? \"\"}\n globalStateSchema={latestGlobalStateSchema}\n localStateSchema={latestLocalStateSchema}\n setModelId={handleSetModelId}\n setModelDescription={handleSetModelDescription}\n setModelExtension={handleSetModelExtension}\n setModelName={handleSetModelName}\n setAuthorName={handleSetAuthorName}\n setAuthorWebsite={handleSetAuthorWebsite}\n setStateSchema={handleSetStateSchema}\n />\n <Divider />\n {isViewingFrozenVersion && (\n <FrozenVersionBanner\n latestVersion={latestSpec.version}\n viewedVersion={viewedSpec.version}\n />\n )}\n <div\n className={\n isViewingFrozenVersion\n ? \"pointer-events-none opacity-80 select-none\"\n : undefined\n }\n inert={isViewingFrozenVersion || undefined}\n >\n <Suspense>\n <StateSchemas\n modelName={modelName}\n globalStateSchema={globalStateSchema}\n globalStateInitialValue={globalStateInitialValue}\n localStateSchema={localStateSchema}\n localStateInitialValue={localStateInitialValue}\n setStateSchema={\n isViewingFrozenVersion\n ? noopSetStateSchema\n : handleSetStateSchema\n }\n setInitialState={\n isViewingFrozenVersion\n ? noopSetInitialState\n : handleSetInitialState\n }\n currentScope={scope}\n onScopeChange={setScope}\n />\n </Suspense>\n <Divider />\n <h3 className=\"mb-6 text-lg text-foreground capitalize\">\n {scope} Operations\n </h3>\n <Modules\n modules={modules.map((module) => ({\n ...module,\n operations: module.operations.filter(\n (op) => op.scope === scope,\n ),\n }))}\n allOperations={operations}\n addModule={handleAddModule}\n updateModuleName={handleSetModuleName}\n deleteModule={handleDeleteModule}\n updateOperationName={handleSetOperationName}\n updateOperationSchema={handleSetOperationSchema}\n setOperationDescription={handleSetOperationDescription}\n deleteOperation={handleDeleteOperation}\n addOperationError={handleAddOperationError}\n deleteOperationError={handleDeleteOperationError}\n setOperationErrorName={handleSetOperationErrorName}\n addOperationAndInitialSchema={addOperationAndInitialSchema}\n toggleNoInputRequired={handleToggleNoInputRequired}\n />\n </div>\n </div>\n </SchemaContextProvider>\n <VersionAdvisoryModal\n prompt={prompt}\n onReleaseFirst={releaseFirst}\n onKeepEditing={keepEditing}\n onCancel={cancelAdvisory}\n />\n </main>\n );\n}\n"],"x_google_ignoreList":[0,1,2,4,5,9],"mappings":";;;;;;;;;;;;;;;AAAA,SAASA,IAAE,GAAE;CAAC,IAAI,GAAE,GAAE,IAAE;AAAG,KAAG,YAAU,OAAO,KAAG,YAAU,OAAO,EAAE,MAAG;UAAU,YAAU,OAAO,EAAE,KAAG,MAAM,QAAQ,EAAE,CAAC,MAAI,IAAE,GAAE,IAAE,EAAE,QAAO,IAAI,GAAE,OAAK,IAAEA,IAAE,EAAE,GAAG,MAAI,MAAI,KAAG,MAAK,KAAG;KAAQ,MAAI,KAAK,EAAE,GAAE,OAAK,MAAI,KAAG,MAAK,KAAG;AAAG,QAAO;;AAAE,SAAgB,OAAM;AAAC,MAAI,IAAI,GAAE,GAAE,IAAE,GAAE,IAAE,IAAG,IAAE,UAAU,QAAQ,EAAC,IAAE,UAAU,UAAQ,IAAEA,IAAE,EAAE,MAAI,MAAI,KAAG,MAAK,KAAG;AAAG,QAAO;;;;ACChW,MAAM,iBAAiB,UAAQ,OAAO,UAAU,YAAY,GAAG,OAAO,MAAM,GAAG,UAAU,IAAI,MAAM;AACnG,MAAa,KAAK;AAClB,MAAa,OAAO,MAAM,WAAS;AAC/B,SAAQ,UAAQ;EACZ,IAAI;AACJ,OAAK,WAAW,QAAQ,WAAW,KAAK,IAAI,KAAK,IAAI,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