intlayer-editor 7.5.14 → 7.6.0-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34073,7 +34073,7 @@ const CodeDefault = ({ children }) => /* @__PURE__ */ jsxRuntimeExports.jsx("div
34073
34073
  }, `line-${index2}-${line.slice(0, 10)}`)) })
34074
34074
  })
34075
34075
  });
34076
- const CodeBlockShiki = reactExports.lazy(() => __vitePreload(() => import("./CodeBlockShiki-BDR2UPKI.js"), true ? [] : void 0).then((mod) => ({ default: mod.CodeBlockShiki })));
34076
+ const CodeBlockShiki = reactExports.lazy(() => __vitePreload(() => import("./CodeBlockShiki-B2XQ3ZO_.js"), true ? [] : void 0).then((mod) => ({ default: mod.CodeBlockShiki })));
34077
34077
  const CodeBlock = ({ className, onChange, isEditable, children, lang, isDarkMode, ...props }) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", {
34078
34078
  className: cn$2("flex w-full min-w-0 max-w-full overflow-x-auto", className),
34079
34079
  ...props,
@@ -45979,7 +45979,7 @@ const contentPaddingVariants = {
45979
45979
  "2xl": "px-10 py-12"
45980
45980
  };
45981
45981
  const MotionModal = motion.create(Container);
45982
- const Modal = ({ children, isOpen, container, disableScroll = true, onClose, hasCloseButton = false, title, size: size2 = ModalSize.MD, className, isScrollable = false, padding = "none", ...props }) => {
45982
+ const Modal = ({ children, isOpen, container, onClose, hasCloseButton = false, title, size: size2 = ModalSize.MD, className, isScrollable = false, disableScroll = true, padding = "none", ...props }) => {
45983
45983
  const containerElement = useGetElementOrWindow(container);
45984
45984
  useScrollBlockage({
45985
45985
  key: "modal",
@@ -50726,7 +50726,7 @@ const r = (t2, r2, o2) => {
50726
50726
  function n(e) {
50727
50727
  return e.replace(/\]|\[/g, "");
50728
50728
  }
50729
- function $constructor$1(name, initializer2, params) {
50729
+ function $constructor(name, initializer2, params) {
50730
50730
  function init2(inst, def) {
50731
50731
  if (!inst._zod) {
50732
50732
  Object.defineProperty(inst, "_zod", {
@@ -50777,911 +50777,165 @@ function $constructor$1(name, initializer2, params) {
50777
50777
  Object.defineProperty(_2, "name", { value: name });
50778
50778
  return _2;
50779
50779
  }
50780
- let $ZodAsyncError$1 = class $ZodAsyncError extends Error {
50780
+ class $ZodAsyncError extends Error {
50781
50781
  constructor() {
50782
50782
  super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
50783
50783
  }
50784
- };
50785
- const globalConfig$1 = {};
50786
- function config$3(newConfig) {
50787
- return globalConfig$1;
50788
50784
  }
50789
- function jsonStringifyReplacer$1(_2, value) {
50785
+ class $ZodEncodeError extends Error {
50786
+ constructor(name) {
50787
+ super(`Encountered unidirectional transform during encode: ${name}`);
50788
+ this.name = "ZodEncodeError";
50789
+ }
50790
+ }
50791
+ const globalConfig = {};
50792
+ function config$2(newConfig) {
50793
+ return globalConfig;
50794
+ }
50795
+ function getEnumValues(entries) {
50796
+ const numericValues = Object.values(entries).filter((v2) => typeof v2 === "number");
50797
+ const values = Object.entries(entries).filter(([k2, _2]) => numericValues.indexOf(+k2) === -1).map(([_2, v2]) => v2);
50798
+ return values;
50799
+ }
50800
+ function jsonStringifyReplacer(_2, value) {
50790
50801
  if (typeof value === "bigint")
50791
50802
  return value.toString();
50792
50803
  return value;
50793
50804
  }
50794
- const captureStackTrace$1 = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {
50795
- };
50796
- function unwrapMessage$1(message) {
50797
- return typeof message === "string" ? message : message?.message;
50805
+ function cached(getter) {
50806
+ return {
50807
+ get value() {
50808
+ {
50809
+ const value = getter();
50810
+ Object.defineProperty(this, "value", { value });
50811
+ return value;
50812
+ }
50813
+ }
50814
+ };
50798
50815
  }
50799
- function finalizeIssue$1(iss, ctx, config2) {
50800
- const full = { ...iss, path: iss.path ?? [] };
50801
- if (!iss.message) {
50802
- const message = unwrapMessage$1(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage$1(ctx?.error?.(iss)) ?? unwrapMessage$1(config2.customError?.(iss)) ?? unwrapMessage$1(config2.localeError?.(iss)) ?? "Invalid input";
50803
- full.message = message;
50804
- }
50805
- delete full.inst;
50806
- delete full.continue;
50807
- if (!ctx?.reportInput) {
50808
- delete full.input;
50809
- }
50810
- return full;
50816
+ function nullish(input) {
50817
+ return input === null || input === void 0;
50811
50818
  }
50812
- const initializer$2 = (inst, def) => {
50813
- inst.name = "$ZodError";
50814
- Object.defineProperty(inst, "_zod", {
50815
- value: inst._zod,
50816
- enumerable: false
50817
- });
50818
- Object.defineProperty(inst, "issues", {
50819
- value: def,
50820
- enumerable: false
50819
+ function cleanRegex(source) {
50820
+ const start = source.startsWith("^") ? 1 : 0;
50821
+ const end = source.endsWith("$") ? source.length - 1 : source.length;
50822
+ return source.slice(start, end);
50823
+ }
50824
+ const EVALUATING = /* @__PURE__ */ Symbol("evaluating");
50825
+ function defineLazy(object2, key2, getter) {
50826
+ let value = void 0;
50827
+ Object.defineProperty(object2, key2, {
50828
+ get() {
50829
+ if (value === EVALUATING) {
50830
+ return void 0;
50831
+ }
50832
+ if (value === void 0) {
50833
+ value = EVALUATING;
50834
+ value = getter();
50835
+ }
50836
+ return value;
50837
+ },
50838
+ set(v2) {
50839
+ Object.defineProperty(object2, key2, {
50840
+ value: v2
50841
+ // configurable: true,
50842
+ });
50843
+ },
50844
+ configurable: true
50821
50845
  });
50822
- inst.message = JSON.stringify(def, jsonStringifyReplacer$1, 2);
50823
- Object.defineProperty(inst, "toString", {
50824
- value: () => inst.message,
50825
- enumerable: false
50846
+ }
50847
+ function assignProp(target, prop, value) {
50848
+ Object.defineProperty(target, prop, {
50849
+ value,
50850
+ writable: true,
50851
+ enumerable: true,
50852
+ configurable: true
50826
50853
  });
50827
- };
50828
- const $ZodError$1 = $constructor$1("$ZodError", initializer$2);
50829
- const $ZodRealError$1 = $constructor$1("$ZodError", initializer$2, { Parent: Error });
50830
- const _parse$1 = (_Err) => (schema, value, _ctx, _params) => {
50831
- const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
50832
- const result = schema._zod.run({ value, issues: [] }, ctx);
50833
- if (result instanceof Promise) {
50834
- throw new $ZodAsyncError$1();
50835
- }
50836
- if (result.issues.length) {
50837
- const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue$1(iss, ctx, config$3())));
50838
- captureStackTrace$1(e, _params?.callee);
50839
- throw e;
50854
+ }
50855
+ function mergeDefs(...defs) {
50856
+ const mergedDescriptors = {};
50857
+ for (const def of defs) {
50858
+ const descriptors = Object.getOwnPropertyDescriptors(def);
50859
+ Object.assign(mergedDescriptors, descriptors);
50840
50860
  }
50841
- return result.value;
50861
+ return Object.defineProperties({}, mergedDescriptors);
50862
+ }
50863
+ function esc(str) {
50864
+ return JSON.stringify(str);
50865
+ }
50866
+ function slugify(input) {
50867
+ return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
50868
+ }
50869
+ const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {
50842
50870
  };
50843
- const parse$1 = /* @__PURE__ */ _parse$1($ZodRealError$1);
50844
- const _parseAsync$1 = (_Err) => async (schema, value, _ctx, params) => {
50845
- const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
50846
- let result = schema._zod.run({ value, issues: [] }, ctx);
50847
- if (result instanceof Promise)
50848
- result = await result;
50849
- if (result.issues.length) {
50850
- const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue$1(iss, ctx, config$3())));
50851
- captureStackTrace$1(e, params?.callee);
50852
- throw e;
50871
+ function isObject$2(data) {
50872
+ return typeof data === "object" && data !== null && !Array.isArray(data);
50873
+ }
50874
+ const allowsEval = cached(() => {
50875
+ if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
50876
+ return false;
50853
50877
  }
50854
- return result.value;
50855
- };
50856
- const parseAsync$1 = /* @__PURE__ */ _parseAsync$1($ZodRealError$1);
50857
- function t(r2, e) {
50858
50878
  try {
50859
- var o2 = r2();
50860
- } catch (r3) {
50861
- return e(r3);
50879
+ const F = Function;
50880
+ new F("");
50881
+ return true;
50882
+ } catch (_2) {
50883
+ return false;
50862
50884
  }
50863
- return o2 && o2.then ? o2.then(void 0, e) : o2;
50864
- }
50865
- function s(r2, e) {
50866
- for (var n2 = {}; r2.length; ) {
50867
- var t2 = r2[0], s2 = t2.code, i2 = t2.message, a2 = t2.path.join(".");
50868
- if (!n2[a2]) if ("unionErrors" in t2) {
50869
- var u2 = t2.unionErrors[0].errors[0];
50870
- n2[a2] = { message: u2.message, type: u2.code };
50871
- } else n2[a2] = { message: i2, type: s2 };
50872
- if ("unionErrors" in t2 && t2.unionErrors.forEach(function(e2) {
50873
- return e2.errors.forEach(function(e3) {
50874
- return r2.push(e3);
50875
- });
50876
- }), e) {
50877
- var c = n2[a2].types, f = c && c[t2.code];
50878
- n2[a2] = appendErrors(a2, e, n2, s2, f ? [].concat(f, t2.message) : t2.message);
50879
- }
50880
- r2.shift();
50885
+ });
50886
+ function isPlainObject(o2) {
50887
+ if (isObject$2(o2) === false)
50888
+ return false;
50889
+ const ctor = o2.constructor;
50890
+ if (ctor === void 0)
50891
+ return true;
50892
+ if (typeof ctor !== "function")
50893
+ return true;
50894
+ const prot = ctor.prototype;
50895
+ if (isObject$2(prot) === false)
50896
+ return false;
50897
+ if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
50898
+ return false;
50881
50899
  }
50882
- return n2;
50900
+ return true;
50883
50901
  }
50884
- function i(r2, e) {
50885
- for (var n2 = {}; r2.length; ) {
50886
- var t2 = r2[0], s2 = t2.code, i2 = t2.message, a2 = t2.path.join(".");
50887
- if (!n2[a2]) if ("invalid_union" === t2.code && t2.errors.length > 0) {
50888
- var u2 = t2.errors[0][0];
50889
- n2[a2] = { message: u2.message, type: u2.code };
50890
- } else n2[a2] = { message: i2, type: s2 };
50891
- if ("invalid_union" === t2.code && t2.errors.forEach(function(e2) {
50892
- return e2.forEach(function(e3) {
50893
- return r2.push(e3);
50894
- });
50895
- }), e) {
50896
- var c = n2[a2].types, f = c && c[t2.code];
50897
- n2[a2] = appendErrors(a2, e, n2, s2, f ? [].concat(f, t2.message) : t2.message);
50898
- }
50899
- r2.shift();
50902
+ function shallowClone(o2) {
50903
+ if (isPlainObject(o2))
50904
+ return { ...o2 };
50905
+ if (Array.isArray(o2))
50906
+ return [...o2];
50907
+ return o2;
50908
+ }
50909
+ const propertyKeyTypes = /* @__PURE__ */ new Set(["string", "number", "symbol"]);
50910
+ function escapeRegex(str) {
50911
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
50912
+ }
50913
+ function clone(inst, def, params) {
50914
+ const cl = new inst._zod.constr(def ?? inst._zod.def);
50915
+ if (!def || params?.parent)
50916
+ cl._zod.parent = inst;
50917
+ return cl;
50918
+ }
50919
+ function normalizeParams(_params) {
50920
+ const params = _params;
50921
+ if (!params)
50922
+ return {};
50923
+ if (typeof params === "string")
50924
+ return { error: () => params };
50925
+ if (params?.message !== void 0) {
50926
+ if (params?.error !== void 0)
50927
+ throw new Error("Cannot specify both `message` and `error` params");
50928
+ params.error = params.message;
50900
50929
  }
50901
- return n2;
50930
+ delete params.message;
50931
+ if (typeof params.error === "string")
50932
+ return { ...params, error: () => params.error };
50933
+ return params;
50902
50934
  }
50903
- function a(o$1, a2, u2) {
50904
- if (void 0 === u2 && (u2 = {}), (function(r2) {
50905
- return "_def" in r2 && "object" == typeof r2._def && "typeName" in r2._def;
50906
- })(o$1)) return function(n2, i2, c) {
50907
- try {
50908
- return Promise.resolve(t(function() {
50909
- return Promise.resolve(o$1["sync" === u2.mode ? "parse" : "parseAsync"](n2, a2)).then(function(e) {
50910
- return c.shouldUseNativeValidation && o({}, c), { errors: {}, values: u2.raw ? Object.assign({}, n2) : e };
50911
- });
50912
- }, function(r2) {
50913
- if ((function(r3) {
50914
- return Array.isArray(null == r3 ? void 0 : r3.issues);
50915
- })(r2)) return { values: {}, errors: s$1(s(r2.errors, !c.shouldUseNativeValidation && "all" === c.criteriaMode), c) };
50916
- throw r2;
50917
- }));
50918
- } catch (r2) {
50919
- return Promise.reject(r2);
50920
- }
50921
- };
50922
- if ((function(r2) {
50923
- return "_zod" in r2 && "object" == typeof r2._zod;
50924
- })(o$1)) return function(s2, c, f) {
50925
- try {
50926
- return Promise.resolve(t(function() {
50927
- return Promise.resolve(("sync" === u2.mode ? parse$1 : parseAsync$1)(o$1, s2, a2)).then(function(e) {
50928
- return f.shouldUseNativeValidation && o({}, f), { errors: {}, values: u2.raw ? Object.assign({}, s2) : e };
50929
- });
50930
- }, function(r2) {
50931
- if ((function(r3) {
50932
- return r3 instanceof $ZodError$1;
50933
- })(r2)) return { values: {}, errors: s$1(i(r2.issues, !f.shouldUseNativeValidation && "all" === f.criteriaMode), f) };
50934
- throw r2;
50935
- }));
50936
- } catch (r2) {
50937
- return Promise.reject(r2);
50938
- }
50939
- };
50940
- throw new Error("Invalid input: not a Zod schema");
50941
- }
50942
- const awaitFunction = async (fn) => {
50943
- if (fn && typeof fn.then === "function") return await fn;
50944
- return fn;
50945
- };
50946
- const Form$1 = ({ schema, onSubmit: onSubmitProp, onSubmitSuccess: onSubmitSuccessProp, onSubmitError: onSubmitErrorProp, className, children, autoComplete, ...props }) => {
50947
- const onSubmit = async (values) => {
50948
- const parsedValues = schema?.safeParse(values) ?? {
50949
- success: true,
50950
- data: void 0
50951
- };
50952
- await awaitFunction(onSubmitProp?.(values));
50953
- if (parsedValues.success) await awaitFunction(onSubmitSuccessProp?.(parsedValues.data));
50954
- else await awaitFunction(onSubmitErrorProp?.(new Error(parsedValues.error.issues.map((error) => error.message).join(", "))));
50955
- };
50956
- return /* @__PURE__ */ jsxRuntimeExports.jsx(FormProvider, {
50957
- ...props,
50958
- children: /* @__PURE__ */ jsxRuntimeExports.jsx("form", {
50959
- className: cn$2("flex flex-col gap-y-6", className),
50960
- onSubmit: props.handleSubmit(onSubmit),
50961
- autoComplete: autoComplete ? "on" : "off",
50962
- noValidate: true,
50963
- children
50964
- })
50965
- });
50966
- };
50967
- const useForm = (schema, props) => {
50968
- const form = useForm$1({
50969
- resolver: a(schema),
50970
- ...props
50971
- });
50972
- const { isSubmitting, isSubmitted, isLoading, isValid } = useFormState({ control: form.control });
50973
- return {
50974
- form,
50975
- isSubmitting,
50976
- isSubmitted,
50977
- isLoading,
50978
- isValid
50979
- };
50980
- };
50981
- const FormLabel = ({ className, ...props }) => {
50982
- const { error, formItemId } = useFormField();
50983
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Label$1, {
50984
- className: cn$2("mb-2", error && "text-error", className),
50985
- htmlFor: formItemId,
50986
- ...props
50987
- });
50988
- };
50989
- const RequiredStar = ({ isRequired }) => isRequired ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", {
50990
- "aria-label": "Asterisk meaning the field is required",
50991
- children: "*"
50992
- }) : /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {});
50993
- const FormLabelLayout = ({ children, isRequired, info, htmlFor, className }) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", {
50994
- className: "ml-1 flex gap-1 align-middle text-base leading-none",
50995
- children: [children && /* @__PURE__ */ jsxRuntimeExports.jsxs(FormLabel, {
50996
- htmlFor,
50997
- id: `${htmlFor}-label`,
50998
- suppressHydrationWarning: true,
50999
- className: clsx("font-bold", className),
51000
- children: [children, /* @__PURE__ */ jsxRuntimeExports.jsx(RequiredStar, { isRequired })]
51001
- }), info && /* @__PURE__ */ jsxRuntimeExports.jsx(InformationTag, { content: info })]
51002
- });
51003
- const FormItemLayout = ({ label, description, isRequired, info, children, showErrorMessage = true, htmlFor }) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Form.Item, {
51004
- className: "flex w-full flex-col flex-wrap gap-2 px-1 py-2",
51005
- children: [
51006
- (description || label) && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", {
51007
- className: "flex flex-col gap-1 p-1 leading-none",
51008
- children: [label && /* @__PURE__ */ jsxRuntimeExports.jsx(FormLabelLayout, {
51009
- isRequired,
51010
- info,
51011
- htmlFor,
51012
- children: label
51013
- }), description && /* @__PURE__ */ jsxRuntimeExports.jsx(Form.Description, { children: description })]
51014
- }),
51015
- /* @__PURE__ */ jsxRuntimeExports.jsx(Form.Control, { children }),
51016
- showErrorMessage && /* @__PURE__ */ jsxRuntimeExports.jsx(Form.Message, { "data-testid": "error-message" })
51017
- ]
51018
- });
51019
- const FormFieldElement = ({ field, name, label, Element: Element2, isRequired = false, info, description, showErrorMessage = true, ...props }) => {
51020
- const { error } = useFormField();
51021
- const { value: fieldValue, onChange: fieldOnChange, ...fieldRest } = field ?? {};
51022
- const propsAny = props;
51023
- const mergedValue = propsAny.value !== void 0 ? propsAny.value : fieldValue ?? "";
51024
- const mergedOnChange = (...args) => {
51025
- if (typeof fieldOnChange === "function") fieldOnChange(...args);
51026
- if (typeof propsAny.onChange === "function") propsAny.onChange(...args);
51027
- };
51028
- return /* @__PURE__ */ jsxRuntimeExports.jsx(FormItemLayout, {
51029
- htmlFor: name,
51030
- label,
51031
- description,
51032
- isRequired,
51033
- info,
51034
- showErrorMessage,
51035
- "aria-invalid": !!error,
51036
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(Element2, {
51037
- "data-testid": "element",
51038
- id: name,
51039
- ...fieldRest,
51040
- ...props,
51041
- value: mergedValue,
51042
- onChange: mergedOnChange,
51043
- children: props.children
51044
- })
51045
- });
51046
- };
51047
- const FormElement = (props) => {
51048
- const { control } = useFormContext();
51049
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Form.Field, {
51050
- control,
51051
- name: props.name,
51052
- render: ({ field }) => /* @__PURE__ */ jsxRuntimeExports.jsx(FormFieldElement, {
51053
- ...props,
51054
- field
51055
- })
51056
- });
51057
- };
51058
- const EditableFieldInputElement = (props) => /* @__PURE__ */ jsxRuntimeExports.jsx(FormElement, {
51059
- id: props.name,
51060
- "data-testid": props.name,
51061
- "aria-labelledby": props.label ? `${props.name}-label` : void 0,
51062
- "aria-label": props.label ? void 0 : props.name,
51063
- Element: EditableFieldInput,
51064
- ...props
51065
- });
51066
- const EditableFieldTextAreaElement = (props) => /* @__PURE__ */ jsxRuntimeExports.jsx(FormElement, {
51067
- id: props.name,
51068
- "data-testid": props.name,
51069
- "aria-labelledby": props.label ? `${props.name}-label` : void 0,
51070
- "aria-label": props.label ? void 0 : props.name,
51071
- Element: EditableFieldTextArea,
51072
- ...props
51073
- });
51074
- const InputElement = (props) => /* @__PURE__ */ jsxRuntimeExports.jsx(FormElement, {
51075
- id: props.name,
51076
- "data-testid": props.name,
51077
- Element: Input,
51078
- "aria-labelledby": props.label ? `${props.name}-label` : void 0,
51079
- "aria-label": props.label ? void 0 : props.name,
51080
- ...props
51081
- });
51082
- const InputPasswordElement = ({ autoComplete, ...props }) => /* @__PURE__ */ jsxRuntimeExports.jsx(FormElement, {
51083
- Element: InputPassword,
51084
- id: props.name,
51085
- "data-testid": props.name,
51086
- "aria-labelledby": props.label ? `${props.name}-label` : void 0,
51087
- "aria-label": props.label ? void 0 : props.name,
51088
- autoComplete,
51089
- minLength: 6,
51090
- maxLength: 255,
51091
- ...props
51092
- });
51093
- const selector = (option) => option?.getAttribute("aria-selected") === "true";
51094
- const OTPFieldContent = ({ field, name, label, description, isRequired, info, showErrorMessage, children, slots = 6, maxLength = 6, ...props }) => {
51095
- const { error } = useFormField();
51096
- const optionsRefs = reactExports.useRef([]);
51097
- const { choiceIndicatorPosition, calculatePosition } = useItemSelector(optionsRefs, {
51098
- selector,
51099
- isHoverable: true
51100
- });
51101
- reactExports.useEffect(() => {
51102
- calculatePosition();
51103
- }, []);
51104
- return /* @__PURE__ */ jsxRuntimeExports.jsx(FormItemLayout, {
51105
- htmlFor: name,
51106
- label,
51107
- description,
51108
- isRequired,
51109
- info,
51110
- showErrorMessage,
51111
- "aria-invalid": !!error,
51112
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(InputOTP, {
51113
- onChange: field.onChange,
51114
- defaultValue: field.value,
51115
- maxLength,
51116
- pattern: "^[0-9]+$",
51117
- onActiveSlotChange: calculatePosition,
51118
- ...props,
51119
- children: children ?? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
51120
- /* @__PURE__ */ jsxRuntimeExports.jsxs(InputOTPGroup, { children: [
51121
- /* @__PURE__ */ jsxRuntimeExports.jsx(InputOTPSlot, {
51122
- index: 0,
51123
- ref: (el) => {
51124
- optionsRefs.current[0] = el;
51125
- }
51126
- }),
51127
- /* @__PURE__ */ jsxRuntimeExports.jsx(InputOTPSlot, {
51128
- index: 1,
51129
- ref: (el) => {
51130
- optionsRefs.current[1] = el;
51131
- }
51132
- }),
51133
- /* @__PURE__ */ jsxRuntimeExports.jsx(InputOTPSlot, {
51134
- index: 2,
51135
- ref: (el) => {
51136
- optionsRefs.current[2] = el;
51137
- }
51138
- })
51139
- ] }),
51140
- /* @__PURE__ */ jsxRuntimeExports.jsx(InputOTPSeparator, {}),
51141
- /* @__PURE__ */ jsxRuntimeExports.jsxs(InputOTPGroup, { children: [
51142
- /* @__PURE__ */ jsxRuntimeExports.jsx(InputOTPSlot, {
51143
- index: 3,
51144
- ref: (el) => {
51145
- optionsRefs.current[3] = el;
51146
- }
51147
- }),
51148
- /* @__PURE__ */ jsxRuntimeExports.jsx(InputOTPSlot, {
51149
- index: 4,
51150
- ref: (el) => {
51151
- optionsRefs.current[4] = el;
51152
- }
51153
- }),
51154
- /* @__PURE__ */ jsxRuntimeExports.jsx(InputOTPSlot, {
51155
- index: 5,
51156
- ref: (el) => {
51157
- optionsRefs.current[5] = el;
51158
- }
51159
- })
51160
- ] }),
51161
- choiceIndicatorPosition && /* @__PURE__ */ jsxRuntimeExports.jsx(InputIndicator, { style: choiceIndicatorPosition })
51162
- ] })
51163
- })
51164
- });
51165
- };
51166
- const OTPElement = ({ name, description, label, isRequired, info, showErrorMessage, children, slots = 6, maxLength = 6, ...props }) => {
51167
- const { control } = useFormContext();
51168
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Form.Field, {
51169
- control,
51170
- name,
51171
- render: ({ field }) => /* @__PURE__ */ jsxRuntimeExports.jsx(OTPFieldContent, {
51172
- field,
51173
- name,
51174
- label,
51175
- description,
51176
- isRequired,
51177
- info,
51178
- showErrorMessage,
51179
- slots,
51180
- maxLength,
51181
- ...props,
51182
- children
51183
- })
51184
- });
51185
- };
51186
- const SearchInputElement = (props) => /* @__PURE__ */ jsxRuntimeExports.jsx(FormElement, {
51187
- id: props.name,
51188
- "data-testid": props.name,
51189
- Element: SearchInput,
51190
- "aria-labelledby": props.label ? `${props.name}-label` : void 0,
51191
- "aria-label": props.label ? void 0 : props.name,
51192
- ...props
51193
- });
51194
- const TextAreaElement = (props) => /* @__PURE__ */ jsxRuntimeExports.jsx(FormElement, {
51195
- Element: TextArea,
51196
- id: props.name,
51197
- "aria-labelledby": props.label ? `${props.name}-label` : void 0,
51198
- "aria-label": props.label ? void 0 : props.name,
51199
- "data-testid": props.name,
51200
- ...props
51201
- });
51202
- const AutoSizedTextAreaElement = (props) => /* @__PURE__ */ jsxRuntimeExports.jsx(FormElement, {
51203
- Element: AutoSizedTextArea,
51204
- id: props.name,
51205
- "data-testid": props.name,
51206
- ...props
51207
- });
51208
- const CheckboxComponent = ({ inputLabel, value, onChange, ...props }) => /* @__PURE__ */ jsxRuntimeExports.jsx(Checkbox, {
51209
- ...props,
51210
- label: inputLabel,
51211
- checked: Boolean(value),
51212
- onChange
51213
- });
51214
- const CheckboxElement = ({ autoComplete, ...props }) => /* @__PURE__ */ jsxRuntimeExports.jsx(FormElement, {
51215
- Element: CheckboxComponent,
51216
- id: props.name,
51217
- "data-testid": props.name,
51218
- autoComplete,
51219
- ...props
51220
- });
51221
- const MultiSelectFieldContent = ({ field, name, label, description, isRequired, info, showErrorMessage, children, ...props }) => {
51222
- const { error } = useFormField();
51223
- return /* @__PURE__ */ jsxRuntimeExports.jsx(FormItemLayout, {
51224
- htmlFor: name,
51225
- label,
51226
- description,
51227
- isRequired,
51228
- info,
51229
- showErrorMessage,
51230
- "aria-invalid": !!error,
51231
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(MultiSelect, {
51232
- onValueChange: field.onChange,
51233
- values: field.value,
51234
- ...props,
51235
- children
51236
- })
51237
- });
51238
- };
51239
- const MultiSelectElement = ({ name, description, label, isRequired, info, showErrorMessage, children, ...props }) => {
51240
- const { control } = useFormContext();
51241
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Form.Field, {
51242
- control,
51243
- name,
51244
- render: ({ field }) => /* @__PURE__ */ jsxRuntimeExports.jsx(MultiSelectFieldContent, {
51245
- field,
51246
- name,
51247
- label,
51248
- description,
51249
- isRequired,
51250
- info,
51251
- showErrorMessage,
51252
- ...props,
51253
- children
51254
- })
51255
- });
51256
- };
51257
- const SelectFieldContent = ({ field, name, label, description, isRequired, info, showErrorMessage, children, ...props }) => {
51258
- const { error } = useFormField();
51259
- return /* @__PURE__ */ jsxRuntimeExports.jsx(FormItemLayout, {
51260
- htmlFor: name,
51261
- label,
51262
- description,
51263
- isRequired,
51264
- info,
51265
- showErrorMessage,
51266
- "aria-invalid": !!error,
51267
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(Select, {
51268
- onValueChange: field.onChange,
51269
- defaultValue: field.value,
51270
- ...props,
51271
- children
51272
- })
51273
- });
51274
- };
51275
- const SelectElement = ({ name, description, label, isRequired, info, showErrorMessage, children, ...props }) => {
51276
- const { control } = useFormContext();
51277
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Form.Field, {
51278
- control,
51279
- name,
51280
- render: ({ field }) => /* @__PURE__ */ jsxRuntimeExports.jsx(SelectFieldContent, {
51281
- field,
51282
- name,
51283
- label,
51284
- description,
51285
- isRequired,
51286
- info,
51287
- showErrorMessage,
51288
- ...props,
51289
- children
51290
- })
51291
- });
51292
- };
51293
- const SwitchSelectorFieldContent = ({ field, name, label, description, isRequired, info, showErrorMessage, children, ...props }) => {
51294
- const { error } = useFormField();
51295
- return /* @__PURE__ */ jsxRuntimeExports.jsx(FormItemLayout, {
51296
- htmlFor: name,
51297
- label,
51298
- description,
51299
- isRequired,
51300
- info,
51301
- showErrorMessage,
51302
- "aria-invalid": !!error,
51303
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(SwitchSelector, {
51304
- ...field,
51305
- ...props,
51306
- children
51307
- })
51308
- });
51309
- };
51310
- const SwitchSelectorElement = ({ name, description, label, isRequired, info, showErrorMessage, children, ...props }) => {
51311
- const { control } = useFormContext();
51312
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Form.Field, {
51313
- control,
51314
- name,
51315
- render: ({ field }) => /* @__PURE__ */ jsxRuntimeExports.jsx(SwitchSelectorFieldContent, {
51316
- field,
51317
- name,
51318
- label,
51319
- description,
51320
- isRequired,
51321
- info,
51322
- showErrorMessage,
51323
- ...props,
51324
- children
51325
- })
51326
- });
51327
- };
51328
- var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
51329
- var use = React[" use ".trim().toString()];
51330
- function isPromiseLike(value) {
51331
- return typeof value === "object" && value !== null && "then" in value;
51332
- }
51333
- function isLazyComponent(element) {
51334
- return element != null && typeof element === "object" && "$$typeof" in element && element.$$typeof === REACT_LAZY_TYPE && "_payload" in element && isPromiseLike(element._payload);
51335
- }
51336
- // @__NO_SIDE_EFFECTS__
51337
- function createSlot(ownerName) {
51338
- const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
51339
- const Slot2 = reactExports.forwardRef((props, forwardedRef) => {
51340
- let { children, ...slotProps } = props;
51341
- if (isLazyComponent(children) && typeof use === "function") {
51342
- children = use(children._payload);
51343
- }
51344
- const childrenArray = reactExports.Children.toArray(children);
51345
- const slottable = childrenArray.find(isSlottable);
51346
- if (slottable) {
51347
- const newElement = slottable.props.children;
51348
- const newChildren = childrenArray.map((child) => {
51349
- if (child === slottable) {
51350
- if (reactExports.Children.count(newElement) > 1) return reactExports.Children.only(null);
51351
- return reactExports.isValidElement(newElement) ? newElement.props.children : null;
51352
- } else {
51353
- return child;
51354
- }
51355
- });
51356
- return /* @__PURE__ */ jsxRuntimeExports.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: reactExports.isValidElement(newElement) ? reactExports.cloneElement(newElement, void 0, newChildren) : null });
51357
- }
51358
- return /* @__PURE__ */ jsxRuntimeExports.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
51359
- });
51360
- Slot2.displayName = `${ownerName}.Slot`;
51361
- return Slot2;
51362
- }
51363
- var Slot = /* @__PURE__ */ createSlot("Slot");
51364
- // @__NO_SIDE_EFFECTS__
51365
- function createSlotClone(ownerName) {
51366
- const SlotClone = reactExports.forwardRef((props, forwardedRef) => {
51367
- let { children, ...slotProps } = props;
51368
- if (isLazyComponent(children) && typeof use === "function") {
51369
- children = use(children._payload);
51370
- }
51371
- if (reactExports.isValidElement(children)) {
51372
- const childrenRef = getElementRef(children);
51373
- const props2 = mergeProps(slotProps, children.props);
51374
- if (children.type !== reactExports.Fragment) {
51375
- props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
51376
- }
51377
- return reactExports.cloneElement(children, props2);
51378
- }
51379
- return reactExports.Children.count(children) > 1 ? reactExports.Children.only(null) : null;
51380
- });
51381
- SlotClone.displayName = `${ownerName}.SlotClone`;
51382
- return SlotClone;
51383
- }
51384
- var SLOTTABLE_IDENTIFIER = /* @__PURE__ */ Symbol("radix.slottable");
51385
- function isSlottable(child) {
51386
- return reactExports.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
51387
- }
51388
- function mergeProps(slotProps, childProps) {
51389
- const overrideProps = { ...childProps };
51390
- for (const propName in childProps) {
51391
- const slotPropValue = slotProps[propName];
51392
- const childPropValue = childProps[propName];
51393
- const isHandler = /^on[A-Z]/.test(propName);
51394
- if (isHandler) {
51395
- if (slotPropValue && childPropValue) {
51396
- overrideProps[propName] = (...args) => {
51397
- const result = childPropValue(...args);
51398
- slotPropValue(...args);
51399
- return result;
51400
- };
51401
- } else if (slotPropValue) {
51402
- overrideProps[propName] = slotPropValue;
51403
- }
51404
- } else if (propName === "style") {
51405
- overrideProps[propName] = { ...slotPropValue, ...childPropValue };
51406
- } else if (propName === "className") {
51407
- overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
51408
- }
51409
- }
51410
- return { ...slotProps, ...overrideProps };
51411
- }
51412
- function getElementRef(element) {
51413
- let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
51414
- let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
51415
- if (mayWarn) {
51416
- return element.ref;
51417
- }
51418
- getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
51419
- mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
51420
- if (mayWarn) {
51421
- return element.props.ref;
51422
- }
51423
- return element.props.ref || element.ref;
51424
- }
51425
- const FormControl = (props) => {
51426
- const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
51427
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Slot, {
51428
- id: formItemId,
51429
- "aria-describedby": !error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`,
51430
- "aria-invalid": !!error,
51431
- ...props
51432
- });
51433
- };
51434
- const FormDescription = (props) => {
51435
- const { formDescriptionId } = useFormField();
51436
- return /* @__PURE__ */ jsxRuntimeExports.jsx("p", {
51437
- className: "text-neutral text-sm",
51438
- id: formDescriptionId,
51439
- ...props
51440
- });
51441
- };
51442
- const FormMessage = ({ children, ...props }) => {
51443
- const { error, formMessageId } = useFormField();
51444
- const body = error ? String(error?.message ?? "") : children;
51445
- if (!body) return null;
51446
- return /* @__PURE__ */ jsxRuntimeExports.jsx("p", {
51447
- className: "font-medium text-error text-xs",
51448
- role: "alert",
51449
- id: formMessageId,
51450
- ...props,
51451
- children: body
51452
- });
51453
- };
51454
- const Form = Form$1;
51455
- Form.Description = FormDescription;
51456
- Form.Control = FormControl;
51457
- Form.Field = FormField;
51458
- Form.Item = FormItem;
51459
- Form.Label = FormLabelLayout;
51460
- Form.Message = FormMessage;
51461
- Form.Element = FormElement;
51462
- Form.Input = InputElement;
51463
- Form.InputPassword = InputPasswordElement;
51464
- Form.Checkbox = CheckboxElement;
51465
- Form.TextArea = TextAreaElement;
51466
- Form.AutoSizedTextArea = AutoSizedTextAreaElement;
51467
- Form.Button = Button;
51468
- Form.Select = SelectElement;
51469
- Form.MultiSelect = MultiSelectElement;
51470
- Form.EditableFieldInput = EditableFieldInputElement;
51471
- Form.EditableFieldTextArea = EditableFieldTextAreaElement;
51472
- Form.SwitchSelector = SwitchSelectorElement;
51473
- Form.OTP = OTPElement;
51474
- Form.SearchInput = SearchInputElement;
51475
- function $constructor(name, initializer2, params) {
51476
- function init2(inst, def) {
51477
- if (!inst._zod) {
51478
- Object.defineProperty(inst, "_zod", {
51479
- value: {
51480
- def,
51481
- constr: _2,
51482
- traits: /* @__PURE__ */ new Set()
51483
- },
51484
- enumerable: false
51485
- });
51486
- }
51487
- if (inst._zod.traits.has(name)) {
51488
- return;
51489
- }
51490
- inst._zod.traits.add(name);
51491
- initializer2(inst, def);
51492
- const proto = _2.prototype;
51493
- const keys = Object.keys(proto);
51494
- for (let i2 = 0; i2 < keys.length; i2++) {
51495
- const k2 = keys[i2];
51496
- if (!(k2 in inst)) {
51497
- inst[k2] = proto[k2].bind(inst);
51498
- }
51499
- }
51500
- }
51501
- const Parent = params?.Parent ?? Object;
51502
- class Definition extends Parent {
51503
- }
51504
- Object.defineProperty(Definition, "name", { value: name });
51505
- function _2(def) {
51506
- var _a2;
51507
- const inst = params?.Parent ? new Definition() : this;
51508
- init2(inst, def);
51509
- (_a2 = inst._zod).deferred ?? (_a2.deferred = []);
51510
- for (const fn of inst._zod.deferred) {
51511
- fn();
51512
- }
51513
- return inst;
51514
- }
51515
- Object.defineProperty(_2, "init", { value: init2 });
51516
- Object.defineProperty(_2, Symbol.hasInstance, {
51517
- value: (inst) => {
51518
- if (params?.Parent && inst instanceof params.Parent)
51519
- return true;
51520
- return inst?._zod?.traits?.has(name);
51521
- }
51522
- });
51523
- Object.defineProperty(_2, "name", { value: name });
51524
- return _2;
51525
- }
51526
- class $ZodAsyncError2 extends Error {
51527
- constructor() {
51528
- super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
51529
- }
51530
- }
51531
- class $ZodEncodeError extends Error {
51532
- constructor(name) {
51533
- super(`Encountered unidirectional transform during encode: ${name}`);
51534
- this.name = "ZodEncodeError";
51535
- }
51536
- }
51537
- const globalConfig = {};
51538
- function config$2(newConfig) {
51539
- return globalConfig;
51540
- }
51541
- function getEnumValues(entries) {
51542
- const numericValues = Object.values(entries).filter((v2) => typeof v2 === "number");
51543
- const values = Object.entries(entries).filter(([k2, _2]) => numericValues.indexOf(+k2) === -1).map(([_2, v2]) => v2);
51544
- return values;
51545
- }
51546
- function jsonStringifyReplacer(_2, value) {
51547
- if (typeof value === "bigint")
51548
- return value.toString();
51549
- return value;
51550
- }
51551
- function cached(getter) {
51552
- return {
51553
- get value() {
51554
- {
51555
- const value = getter();
51556
- Object.defineProperty(this, "value", { value });
51557
- return value;
51558
- }
51559
- }
51560
- };
51561
- }
51562
- function nullish(input) {
51563
- return input === null || input === void 0;
51564
- }
51565
- function cleanRegex(source) {
51566
- const start = source.startsWith("^") ? 1 : 0;
51567
- const end = source.endsWith("$") ? source.length - 1 : source.length;
51568
- return source.slice(start, end);
51569
- }
51570
- const EVALUATING = /* @__PURE__ */ Symbol("evaluating");
51571
- function defineLazy(object2, key2, getter) {
51572
- let value = void 0;
51573
- Object.defineProperty(object2, key2, {
51574
- get() {
51575
- if (value === EVALUATING) {
51576
- return void 0;
51577
- }
51578
- if (value === void 0) {
51579
- value = EVALUATING;
51580
- value = getter();
51581
- }
51582
- return value;
51583
- },
51584
- set(v2) {
51585
- Object.defineProperty(object2, key2, {
51586
- value: v2
51587
- // configurable: true,
51588
- });
51589
- },
51590
- configurable: true
51591
- });
51592
- }
51593
- function assignProp(target, prop, value) {
51594
- Object.defineProperty(target, prop, {
51595
- value,
51596
- writable: true,
51597
- enumerable: true,
51598
- configurable: true
51599
- });
51600
- }
51601
- function mergeDefs(...defs) {
51602
- const mergedDescriptors = {};
51603
- for (const def of defs) {
51604
- const descriptors = Object.getOwnPropertyDescriptors(def);
51605
- Object.assign(mergedDescriptors, descriptors);
51606
- }
51607
- return Object.defineProperties({}, mergedDescriptors);
51608
- }
51609
- function esc(str) {
51610
- return JSON.stringify(str);
51611
- }
51612
- function slugify(input) {
51613
- return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
51614
- }
51615
- const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {
51616
- };
51617
- function isObject$2(data) {
51618
- return typeof data === "object" && data !== null && !Array.isArray(data);
51619
- }
51620
- const allowsEval = cached(() => {
51621
- if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
51622
- return false;
51623
- }
51624
- try {
51625
- const F = Function;
51626
- new F("");
51627
- return true;
51628
- } catch (_2) {
51629
- return false;
51630
- }
51631
- });
51632
- function isPlainObject(o2) {
51633
- if (isObject$2(o2) === false)
51634
- return false;
51635
- const ctor = o2.constructor;
51636
- if (ctor === void 0)
51637
- return true;
51638
- if (typeof ctor !== "function")
51639
- return true;
51640
- const prot = ctor.prototype;
51641
- if (isObject$2(prot) === false)
51642
- return false;
51643
- if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
51644
- return false;
51645
- }
51646
- return true;
51647
- }
51648
- function shallowClone(o2) {
51649
- if (isPlainObject(o2))
51650
- return { ...o2 };
51651
- if (Array.isArray(o2))
51652
- return [...o2];
51653
- return o2;
51654
- }
51655
- const propertyKeyTypes = /* @__PURE__ */ new Set(["string", "number", "symbol"]);
51656
- function escapeRegex(str) {
51657
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
51658
- }
51659
- function clone(inst, def, params) {
51660
- const cl = new inst._zod.constr(def ?? inst._zod.def);
51661
- if (!def || params?.parent)
51662
- cl._zod.parent = inst;
51663
- return cl;
51664
- }
51665
- function normalizeParams(_params) {
51666
- const params = _params;
51667
- if (!params)
51668
- return {};
51669
- if (typeof params === "string")
51670
- return { error: () => params };
51671
- if (params?.message !== void 0) {
51672
- if (params?.error !== void 0)
51673
- throw new Error("Cannot specify both `message` and `error` params");
51674
- params.error = params.message;
51675
- }
51676
- delete params.message;
51677
- if (typeof params.error === "string")
51678
- return { ...params, error: () => params.error };
51679
- return params;
51680
- }
51681
- function optionalKeys(shape) {
51682
- return Object.keys(shape).filter((k2) => {
51683
- return shape[k2]._zod.optin === "optional" && shape[k2]._zod.optout === "optional";
51684
- });
50935
+ function optionalKeys(shape) {
50936
+ return Object.keys(shape).filter((k2) => {
50937
+ return shape[k2]._zod.optin === "optional" && shape[k2]._zod.optout === "optional";
50938
+ });
51685
50939
  }
51686
50940
  function pick(schema, mask) {
51687
50941
  const currDef = schema._zod.def;
@@ -51974,7 +51228,7 @@ const _parse = (_Err) => (schema, value, _ctx, _params) => {
51974
51228
  const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
51975
51229
  const result = schema._zod.run({ value, issues: [] }, ctx);
51976
51230
  if (result instanceof Promise) {
51977
- throw new $ZodAsyncError2();
51231
+ throw new $ZodAsyncError();
51978
51232
  }
51979
51233
  if (result.issues.length) {
51980
51234
  const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config$2())));
@@ -51983,6 +51237,7 @@ const _parse = (_Err) => (schema, value, _ctx, _params) => {
51983
51237
  }
51984
51238
  return result.value;
51985
51239
  };
51240
+ const parse$1 = /* @__PURE__ */ _parse($ZodRealError);
51986
51241
  const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
51987
51242
  const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
51988
51243
  let result = schema._zod.run({ value, issues: [] }, ctx);
@@ -51995,11 +51250,12 @@ const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
51995
51250
  }
51996
51251
  return result.value;
51997
51252
  };
51253
+ const parseAsync$1 = /* @__PURE__ */ _parseAsync($ZodRealError);
51998
51254
  const _safeParse = (_Err) => (schema, value, _ctx) => {
51999
51255
  const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
52000
51256
  const result = schema._zod.run({ value, issues: [] }, ctx);
52001
51257
  if (result instanceof Promise) {
52002
- throw new $ZodAsyncError2();
51258
+ throw new $ZodAsyncError();
52003
51259
  }
52004
51260
  return result.issues.length ? {
52005
51261
  success: false,
@@ -52397,7 +51653,7 @@ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
52397
51653
  const currLen = payload.issues.length;
52398
51654
  const _2 = ch._zod.check(payload);
52399
51655
  if (_2 instanceof Promise && ctx?.async === false) {
52400
- throw new $ZodAsyncError2();
51656
+ throw new $ZodAsyncError();
52401
51657
  }
52402
51658
  if (asyncResult || _2 instanceof Promise) {
52403
51659
  asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
@@ -52431,7 +51687,7 @@ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
52431
51687
  const checkResult = runChecks(payload, checks, ctx);
52432
51688
  if (checkResult instanceof Promise) {
52433
51689
  if (ctx.async === false)
52434
- throw new $ZodAsyncError2();
51690
+ throw new $ZodAsyncError();
52435
51691
  return checkResult.then((checkResult2) => inst._zod.parse(checkResult2, ctx));
52436
51692
  }
52437
51693
  return inst._zod.parse(checkResult, ctx);
@@ -52452,7 +51708,7 @@ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
52452
51708
  const result = inst._zod.parse(payload, ctx);
52453
51709
  if (result instanceof Promise) {
52454
51710
  if (ctx.async === false)
52455
- throw new $ZodAsyncError2();
51711
+ throw new $ZodAsyncError();
52456
51712
  return result.then((result2) => runChecks(result2, checks, ctx));
52457
51713
  }
52458
51714
  return runChecks(result, checks, ctx);
@@ -53243,7 +52499,7 @@ const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def)
53243
52499
  });
53244
52500
  }
53245
52501
  if (_out instanceof Promise) {
53246
- throw new $ZodAsyncError2();
52502
+ throw new $ZodAsyncError();
53247
52503
  }
53248
52504
  payload.value = _out;
53249
52505
  return payload;
@@ -54208,327 +53464,945 @@ function finalize(ctx, schema) {
54208
53464
  for (const entry of [...ctx.seen.entries()].reverse()) {
54209
53465
  flattenRef(entry[0]);
54210
53466
  }
54211
- const result = {};
54212
- if (ctx.target === "draft-2020-12") {
54213
- result.$schema = "https://json-schema.org/draft/2020-12/schema";
54214
- } else if (ctx.target === "draft-07") {
54215
- result.$schema = "http://json-schema.org/draft-07/schema#";
54216
- } else if (ctx.target === "draft-04") {
54217
- result.$schema = "http://json-schema.org/draft-04/schema#";
54218
- } else if (ctx.target === "openapi-3.0") ;
54219
- else ;
54220
- if (ctx.external?.uri) {
54221
- const id2 = ctx.external.registry.get(schema)?.id;
54222
- if (!id2)
54223
- throw new Error("Schema is missing an `id` property");
54224
- result.$id = ctx.external.uri(id2);
53467
+ const result = {};
53468
+ if (ctx.target === "draft-2020-12") {
53469
+ result.$schema = "https://json-schema.org/draft/2020-12/schema";
53470
+ } else if (ctx.target === "draft-07") {
53471
+ result.$schema = "http://json-schema.org/draft-07/schema#";
53472
+ } else if (ctx.target === "draft-04") {
53473
+ result.$schema = "http://json-schema.org/draft-04/schema#";
53474
+ } else if (ctx.target === "openapi-3.0") ;
53475
+ else ;
53476
+ if (ctx.external?.uri) {
53477
+ const id2 = ctx.external.registry.get(schema)?.id;
53478
+ if (!id2)
53479
+ throw new Error("Schema is missing an `id` property");
53480
+ result.$id = ctx.external.uri(id2);
53481
+ }
53482
+ Object.assign(result, root.def ?? root.schema);
53483
+ const defs = ctx.external?.defs ?? {};
53484
+ for (const entry of ctx.seen.entries()) {
53485
+ const seen2 = entry[1];
53486
+ if (seen2.def && seen2.defId) {
53487
+ defs[seen2.defId] = seen2.def;
53488
+ }
53489
+ }
53490
+ if (ctx.external) ;
53491
+ else {
53492
+ if (Object.keys(defs).length > 0) {
53493
+ if (ctx.target === "draft-2020-12") {
53494
+ result.$defs = defs;
53495
+ } else {
53496
+ result.definitions = defs;
53497
+ }
53498
+ }
53499
+ }
53500
+ try {
53501
+ const finalized = JSON.parse(JSON.stringify(result));
53502
+ Object.defineProperty(finalized, "~standard", {
53503
+ value: {
53504
+ ...schema["~standard"],
53505
+ jsonSchema: {
53506
+ input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
53507
+ output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
53508
+ }
53509
+ },
53510
+ enumerable: false,
53511
+ writable: false
53512
+ });
53513
+ return finalized;
53514
+ } catch (_err) {
53515
+ throw new Error("Error converting schema to JSON.");
53516
+ }
53517
+ }
53518
+ function isTransforming(_schema, _ctx) {
53519
+ const ctx = _ctx ?? { seen: /* @__PURE__ */ new Set() };
53520
+ if (ctx.seen.has(_schema))
53521
+ return false;
53522
+ ctx.seen.add(_schema);
53523
+ const def = _schema._zod.def;
53524
+ if (def.type === "transform")
53525
+ return true;
53526
+ if (def.type === "array")
53527
+ return isTransforming(def.element, ctx);
53528
+ if (def.type === "set")
53529
+ return isTransforming(def.valueType, ctx);
53530
+ if (def.type === "lazy")
53531
+ return isTransforming(def.getter(), ctx);
53532
+ if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault") {
53533
+ return isTransforming(def.innerType, ctx);
53534
+ }
53535
+ if (def.type === "intersection") {
53536
+ return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
53537
+ }
53538
+ if (def.type === "record" || def.type === "map") {
53539
+ return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
53540
+ }
53541
+ if (def.type === "pipe") {
53542
+ return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
53543
+ }
53544
+ if (def.type === "object") {
53545
+ for (const key2 in def.shape) {
53546
+ if (isTransforming(def.shape[key2], ctx))
53547
+ return true;
53548
+ }
53549
+ return false;
53550
+ }
53551
+ if (def.type === "union") {
53552
+ for (const option of def.options) {
53553
+ if (isTransforming(option, ctx))
53554
+ return true;
53555
+ }
53556
+ return false;
53557
+ }
53558
+ if (def.type === "tuple") {
53559
+ for (const item of def.items) {
53560
+ if (isTransforming(item, ctx))
53561
+ return true;
53562
+ }
53563
+ if (def.rest && isTransforming(def.rest, ctx))
53564
+ return true;
53565
+ return false;
53566
+ }
53567
+ return false;
53568
+ }
53569
+ const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
53570
+ const ctx = initializeContext({ ...params, processors });
53571
+ process$1(schema, ctx);
53572
+ extractDefs(ctx, schema);
53573
+ return finalize(ctx, schema);
53574
+ };
53575
+ const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
53576
+ const { libraryOptions, target } = params ?? {};
53577
+ const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
53578
+ process$1(schema, ctx);
53579
+ extractDefs(ctx, schema);
53580
+ return finalize(ctx, schema);
53581
+ };
53582
+ const formatMap = {
53583
+ guid: "uuid",
53584
+ url: "uri",
53585
+ datetime: "date-time",
53586
+ json_string: "json-string",
53587
+ regex: ""
53588
+ // do not set
53589
+ };
53590
+ const stringProcessor = (schema, ctx, _json, _params) => {
53591
+ const json = _json;
53592
+ json.type = "string";
53593
+ const { minimum, maximum, format: format2, patterns, contentEncoding } = schema._zod.bag;
53594
+ if (typeof minimum === "number")
53595
+ json.minLength = minimum;
53596
+ if (typeof maximum === "number")
53597
+ json.maxLength = maximum;
53598
+ if (format2) {
53599
+ json.format = formatMap[format2] ?? format2;
53600
+ if (json.format === "")
53601
+ delete json.format;
53602
+ if (format2 === "time") {
53603
+ delete json.format;
53604
+ }
53605
+ }
53606
+ if (contentEncoding)
53607
+ json.contentEncoding = contentEncoding;
53608
+ if (patterns && patterns.size > 0) {
53609
+ const regexes = [...patterns];
53610
+ if (regexes.length === 1)
53611
+ json.pattern = regexes[0].source;
53612
+ else if (regexes.length > 1) {
53613
+ json.allOf = [
53614
+ ...regexes.map((regex) => ({
53615
+ ...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
53616
+ pattern: regex.source
53617
+ }))
53618
+ ];
53619
+ }
53620
+ }
53621
+ };
53622
+ const neverProcessor = (_schema, _ctx, json, _params) => {
53623
+ json.not = {};
53624
+ };
53625
+ const unknownProcessor = (_schema, _ctx, _json, _params) => {
53626
+ };
53627
+ const enumProcessor = (schema, _ctx, json, _params) => {
53628
+ const def = schema._zod.def;
53629
+ const values = getEnumValues(def.entries);
53630
+ if (values.every((v2) => typeof v2 === "number"))
53631
+ json.type = "number";
53632
+ if (values.every((v2) => typeof v2 === "string"))
53633
+ json.type = "string";
53634
+ json.enum = values;
53635
+ };
53636
+ const customProcessor = (_schema, ctx, _json, _params) => {
53637
+ if (ctx.unrepresentable === "throw") {
53638
+ throw new Error("Custom types cannot be represented in JSON Schema");
53639
+ }
53640
+ };
53641
+ const transformProcessor = (_schema, ctx, _json, _params) => {
53642
+ if (ctx.unrepresentable === "throw") {
53643
+ throw new Error("Transforms cannot be represented in JSON Schema");
54225
53644
  }
54226
- Object.assign(result, root.def ?? root.schema);
54227
- const defs = ctx.external?.defs ?? {};
54228
- for (const entry of ctx.seen.entries()) {
54229
- const seen2 = entry[1];
54230
- if (seen2.def && seen2.defId) {
54231
- defs[seen2.defId] = seen2.def;
54232
- }
53645
+ };
53646
+ const arrayProcessor = (schema, ctx, _json, params) => {
53647
+ const json = _json;
53648
+ const def = schema._zod.def;
53649
+ const { minimum, maximum } = schema._zod.bag;
53650
+ if (typeof minimum === "number")
53651
+ json.minItems = minimum;
53652
+ if (typeof maximum === "number")
53653
+ json.maxItems = maximum;
53654
+ json.type = "array";
53655
+ json.items = process$1(def.element, ctx, { ...params, path: [...params.path, "items"] });
53656
+ };
53657
+ const objectProcessor = (schema, ctx, _json, params) => {
53658
+ const json = _json;
53659
+ const def = schema._zod.def;
53660
+ json.type = "object";
53661
+ json.properties = {};
53662
+ const shape = def.shape;
53663
+ for (const key2 in shape) {
53664
+ json.properties[key2] = process$1(shape[key2], ctx, {
53665
+ ...params,
53666
+ path: [...params.path, "properties", key2]
53667
+ });
54233
53668
  }
54234
- if (ctx.external) ;
54235
- else {
54236
- if (Object.keys(defs).length > 0) {
54237
- if (ctx.target === "draft-2020-12") {
54238
- result.$defs = defs;
54239
- } else {
54240
- result.definitions = defs;
54241
- }
53669
+ const allKeys = new Set(Object.keys(shape));
53670
+ const requiredKeys = new Set([...allKeys].filter((key2) => {
53671
+ const v2 = def.shape[key2]._zod;
53672
+ if (ctx.io === "input") {
53673
+ return v2.optin === void 0;
53674
+ } else {
53675
+ return v2.optout === void 0;
54242
53676
  }
53677
+ }));
53678
+ if (requiredKeys.size > 0) {
53679
+ json.required = Array.from(requiredKeys);
54243
53680
  }
54244
- try {
54245
- const finalized = JSON.parse(JSON.stringify(result));
54246
- Object.defineProperty(finalized, "~standard", {
54247
- value: {
54248
- ...schema["~standard"],
54249
- jsonSchema: {
54250
- input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
54251
- output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
54252
- }
54253
- },
54254
- enumerable: false,
54255
- writable: false
53681
+ if (def.catchall?._zod.def.type === "never") {
53682
+ json.additionalProperties = false;
53683
+ } else if (!def.catchall) {
53684
+ if (ctx.io === "output")
53685
+ json.additionalProperties = false;
53686
+ } else if (def.catchall) {
53687
+ json.additionalProperties = process$1(def.catchall, ctx, {
53688
+ ...params,
53689
+ path: [...params.path, "additionalProperties"]
54256
53690
  });
54257
- return finalized;
54258
- } catch (_err) {
54259
- throw new Error("Error converting schema to JSON.");
54260
53691
  }
54261
- }
54262
- function isTransforming(_schema, _ctx) {
54263
- const ctx = _ctx ?? { seen: /* @__PURE__ */ new Set() };
54264
- if (ctx.seen.has(_schema))
54265
- return false;
54266
- ctx.seen.add(_schema);
54267
- const def = _schema._zod.def;
54268
- if (def.type === "transform")
54269
- return true;
54270
- if (def.type === "array")
54271
- return isTransforming(def.element, ctx);
54272
- if (def.type === "set")
54273
- return isTransforming(def.valueType, ctx);
54274
- if (def.type === "lazy")
54275
- return isTransforming(def.getter(), ctx);
54276
- if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault") {
54277
- return isTransforming(def.innerType, ctx);
53692
+ };
53693
+ const unionProcessor = (schema, ctx, json, params) => {
53694
+ const def = schema._zod.def;
53695
+ const isExclusive = def.inclusive === false;
53696
+ const options = def.options.map((x, i2) => process$1(x, ctx, {
53697
+ ...params,
53698
+ path: [...params.path, isExclusive ? "oneOf" : "anyOf", i2]
53699
+ }));
53700
+ if (isExclusive) {
53701
+ json.oneOf = options;
53702
+ } else {
53703
+ json.anyOf = options;
54278
53704
  }
54279
- if (def.type === "intersection") {
54280
- return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
53705
+ };
53706
+ const intersectionProcessor = (schema, ctx, json, params) => {
53707
+ const def = schema._zod.def;
53708
+ const a2 = process$1(def.left, ctx, {
53709
+ ...params,
53710
+ path: [...params.path, "allOf", 0]
53711
+ });
53712
+ const b = process$1(def.right, ctx, {
53713
+ ...params,
53714
+ path: [...params.path, "allOf", 1]
53715
+ });
53716
+ const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
53717
+ const allOf = [
53718
+ ...isSimpleIntersection(a2) ? a2.allOf : [a2],
53719
+ ...isSimpleIntersection(b) ? b.allOf : [b]
53720
+ ];
53721
+ json.allOf = allOf;
53722
+ };
53723
+ const nullableProcessor = (schema, ctx, json, params) => {
53724
+ const def = schema._zod.def;
53725
+ const inner = process$1(def.innerType, ctx, params);
53726
+ const seen2 = ctx.seen.get(schema);
53727
+ if (ctx.target === "openapi-3.0") {
53728
+ seen2.ref = def.innerType;
53729
+ json.nullable = true;
53730
+ } else {
53731
+ json.anyOf = [inner, { type: "null" }];
54281
53732
  }
54282
- if (def.type === "record" || def.type === "map") {
54283
- return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
53733
+ };
53734
+ const nonoptionalProcessor = (schema, ctx, _json, params) => {
53735
+ const def = schema._zod.def;
53736
+ process$1(def.innerType, ctx, params);
53737
+ const seen2 = ctx.seen.get(schema);
53738
+ seen2.ref = def.innerType;
53739
+ };
53740
+ const defaultProcessor = (schema, ctx, json, params) => {
53741
+ const def = schema._zod.def;
53742
+ process$1(def.innerType, ctx, params);
53743
+ const seen2 = ctx.seen.get(schema);
53744
+ seen2.ref = def.innerType;
53745
+ json.default = JSON.parse(JSON.stringify(def.defaultValue));
53746
+ };
53747
+ const prefaultProcessor = (schema, ctx, json, params) => {
53748
+ const def = schema._zod.def;
53749
+ process$1(def.innerType, ctx, params);
53750
+ const seen2 = ctx.seen.get(schema);
53751
+ seen2.ref = def.innerType;
53752
+ if (ctx.io === "input")
53753
+ json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
53754
+ };
53755
+ const catchProcessor = (schema, ctx, json, params) => {
53756
+ const def = schema._zod.def;
53757
+ process$1(def.innerType, ctx, params);
53758
+ const seen2 = ctx.seen.get(schema);
53759
+ seen2.ref = def.innerType;
53760
+ let catchValue;
53761
+ try {
53762
+ catchValue = def.catchValue(void 0);
53763
+ } catch {
53764
+ throw new Error("Dynamic catch values are not supported in JSON Schema");
54284
53765
  }
54285
- if (def.type === "pipe") {
54286
- return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
53766
+ json.default = catchValue;
53767
+ };
53768
+ const pipeProcessor = (schema, ctx, _json, params) => {
53769
+ const def = schema._zod.def;
53770
+ const innerType = ctx.io === "input" ? def.in._zod.def.type === "transform" ? def.out : def.in : def.out;
53771
+ process$1(innerType, ctx, params);
53772
+ const seen2 = ctx.seen.get(schema);
53773
+ seen2.ref = innerType;
53774
+ };
53775
+ const readonlyProcessor = (schema, ctx, json, params) => {
53776
+ const def = schema._zod.def;
53777
+ process$1(def.innerType, ctx, params);
53778
+ const seen2 = ctx.seen.get(schema);
53779
+ seen2.ref = def.innerType;
53780
+ json.readOnly = true;
53781
+ };
53782
+ const optionalProcessor = (schema, ctx, _json, params) => {
53783
+ const def = schema._zod.def;
53784
+ process$1(def.innerType, ctx, params);
53785
+ const seen2 = ctx.seen.get(schema);
53786
+ seen2.ref = def.innerType;
53787
+ };
53788
+ function t(r2, e) {
53789
+ try {
53790
+ var o2 = r2();
53791
+ } catch (r3) {
53792
+ return e(r3);
54287
53793
  }
54288
- if (def.type === "object") {
54289
- for (const key2 in def.shape) {
54290
- if (isTransforming(def.shape[key2], ctx))
54291
- return true;
53794
+ return o2 && o2.then ? o2.then(void 0, e) : o2;
53795
+ }
53796
+ function s(r2, e) {
53797
+ for (var n2 = {}; r2.length; ) {
53798
+ var t2 = r2[0], s2 = t2.code, i2 = t2.message, a2 = t2.path.join(".");
53799
+ if (!n2[a2]) if ("unionErrors" in t2) {
53800
+ var u2 = t2.unionErrors[0].errors[0];
53801
+ n2[a2] = { message: u2.message, type: u2.code };
53802
+ } else n2[a2] = { message: i2, type: s2 };
53803
+ if ("unionErrors" in t2 && t2.unionErrors.forEach(function(e2) {
53804
+ return e2.errors.forEach(function(e3) {
53805
+ return r2.push(e3);
53806
+ });
53807
+ }), e) {
53808
+ var c = n2[a2].types, f = c && c[t2.code];
53809
+ n2[a2] = appendErrors(a2, e, n2, s2, f ? [].concat(f, t2.message) : t2.message);
53810
+ }
53811
+ r2.shift();
53812
+ }
53813
+ return n2;
53814
+ }
53815
+ function i(r2, e) {
53816
+ for (var n2 = {}; r2.length; ) {
53817
+ var t2 = r2[0], s2 = t2.code, i2 = t2.message, a2 = t2.path.join(".");
53818
+ if (!n2[a2]) if ("invalid_union" === t2.code && t2.errors.length > 0) {
53819
+ var u2 = t2.errors[0][0];
53820
+ n2[a2] = { message: u2.message, type: u2.code };
53821
+ } else n2[a2] = { message: i2, type: s2 };
53822
+ if ("invalid_union" === t2.code && t2.errors.forEach(function(e2) {
53823
+ return e2.forEach(function(e3) {
53824
+ return r2.push(e3);
53825
+ });
53826
+ }), e) {
53827
+ var c = n2[a2].types, f = c && c[t2.code];
53828
+ n2[a2] = appendErrors(a2, e, n2, s2, f ? [].concat(f, t2.message) : t2.message);
54292
53829
  }
54293
- return false;
53830
+ r2.shift();
54294
53831
  }
54295
- if (def.type === "union") {
54296
- for (const option of def.options) {
54297
- if (isTransforming(option, ctx))
54298
- return true;
53832
+ return n2;
53833
+ }
53834
+ function a(o$1, a2, u2) {
53835
+ if (void 0 === u2 && (u2 = {}), (function(r2) {
53836
+ return "_def" in r2 && "object" == typeof r2._def && "typeName" in r2._def;
53837
+ })(o$1)) return function(n2, i2, c) {
53838
+ try {
53839
+ return Promise.resolve(t(function() {
53840
+ return Promise.resolve(o$1["sync" === u2.mode ? "parse" : "parseAsync"](n2, a2)).then(function(e) {
53841
+ return c.shouldUseNativeValidation && o({}, c), { errors: {}, values: u2.raw ? Object.assign({}, n2) : e };
53842
+ });
53843
+ }, function(r2) {
53844
+ if ((function(r3) {
53845
+ return Array.isArray(null == r3 ? void 0 : r3.issues);
53846
+ })(r2)) return { values: {}, errors: s$1(s(r2.errors, !c.shouldUseNativeValidation && "all" === c.criteriaMode), c) };
53847
+ throw r2;
53848
+ }));
53849
+ } catch (r2) {
53850
+ return Promise.reject(r2);
54299
53851
  }
54300
- return false;
54301
- }
54302
- if (def.type === "tuple") {
54303
- for (const item of def.items) {
54304
- if (isTransforming(item, ctx))
54305
- return true;
53852
+ };
53853
+ if ((function(r2) {
53854
+ return "_zod" in r2 && "object" == typeof r2._zod;
53855
+ })(o$1)) return function(s2, c, f) {
53856
+ try {
53857
+ return Promise.resolve(t(function() {
53858
+ return Promise.resolve(("sync" === u2.mode ? parse$1 : parseAsync$1)(o$1, s2, a2)).then(function(e) {
53859
+ return f.shouldUseNativeValidation && o({}, f), { errors: {}, values: u2.raw ? Object.assign({}, s2) : e };
53860
+ });
53861
+ }, function(r2) {
53862
+ if ((function(r3) {
53863
+ return r3 instanceof $ZodError;
53864
+ })(r2)) return { values: {}, errors: s$1(i(r2.issues, !f.shouldUseNativeValidation && "all" === f.criteriaMode), f) };
53865
+ throw r2;
53866
+ }));
53867
+ } catch (r2) {
53868
+ return Promise.reject(r2);
54306
53869
  }
54307
- if (def.rest && isTransforming(def.rest, ctx))
54308
- return true;
54309
- return false;
54310
- }
54311
- return false;
53870
+ };
53871
+ throw new Error("Invalid input: not a Zod schema");
54312
53872
  }
54313
- const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
54314
- const ctx = initializeContext({ ...params, processors });
54315
- process$1(schema, ctx);
54316
- extractDefs(ctx, schema);
54317
- return finalize(ctx, schema);
53873
+ const awaitFunction = async (fn) => {
53874
+ if (fn && typeof fn.then === "function") return await fn;
53875
+ return fn;
54318
53876
  };
54319
- const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
54320
- const { libraryOptions, target } = params ?? {};
54321
- const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
54322
- process$1(schema, ctx);
54323
- extractDefs(ctx, schema);
54324
- return finalize(ctx, schema);
53877
+ const Form$1 = ({ schema, onSubmit: onSubmitProp, onSubmitSuccess: onSubmitSuccessProp, onSubmitError: onSubmitErrorProp, className, children, autoComplete, ...props }) => {
53878
+ const onSubmit = async (values) => {
53879
+ const parsedValues = schema?.safeParse(values) ?? {
53880
+ success: true,
53881
+ data: void 0
53882
+ };
53883
+ await awaitFunction(onSubmitProp?.(values));
53884
+ if (parsedValues.success) await awaitFunction(onSubmitSuccessProp?.(parsedValues.data));
53885
+ else await awaitFunction(onSubmitErrorProp?.(new Error(parsedValues.error.issues.map((error) => error.message).join(", "))));
53886
+ };
53887
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(FormProvider, {
53888
+ ...props,
53889
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("form", {
53890
+ className: cn$2("flex flex-col gap-y-6", className),
53891
+ onSubmit: props.handleSubmit(onSubmit),
53892
+ autoComplete: autoComplete ? "on" : "off",
53893
+ noValidate: true,
53894
+ children
53895
+ })
53896
+ });
54325
53897
  };
54326
- const formatMap = {
54327
- guid: "uuid",
54328
- url: "uri",
54329
- datetime: "date-time",
54330
- json_string: "json-string",
54331
- regex: ""
54332
- // do not set
53898
+ const useForm = (schema, props) => {
53899
+ const form = useForm$1({
53900
+ resolver: a(schema),
53901
+ ...props
53902
+ });
53903
+ const { isSubmitting, isSubmitted, isLoading, isValid } = useFormState({ control: form.control });
53904
+ return {
53905
+ form,
53906
+ isSubmitting,
53907
+ isSubmitted,
53908
+ isLoading,
53909
+ isValid
53910
+ };
54333
53911
  };
54334
- const stringProcessor = (schema, ctx, _json, _params) => {
54335
- const json = _json;
54336
- json.type = "string";
54337
- const { minimum, maximum, format: format2, patterns, contentEncoding } = schema._zod.bag;
54338
- if (typeof minimum === "number")
54339
- json.minLength = minimum;
54340
- if (typeof maximum === "number")
54341
- json.maxLength = maximum;
54342
- if (format2) {
54343
- json.format = formatMap[format2] ?? format2;
54344
- if (json.format === "")
54345
- delete json.format;
54346
- if (format2 === "time") {
54347
- delete json.format;
54348
- }
54349
- }
54350
- if (contentEncoding)
54351
- json.contentEncoding = contentEncoding;
54352
- if (patterns && patterns.size > 0) {
54353
- const regexes = [...patterns];
54354
- if (regexes.length === 1)
54355
- json.pattern = regexes[0].source;
54356
- else if (regexes.length > 1) {
54357
- json.allOf = [
54358
- ...regexes.map((regex) => ({
54359
- ...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
54360
- pattern: regex.source
54361
- }))
54362
- ];
54363
- }
54364
- }
53912
+ const FormLabel = ({ className, ...props }) => {
53913
+ const { error, formItemId } = useFormField();
53914
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Label$1, {
53915
+ className: cn$2("mb-2", error && "text-error", className),
53916
+ htmlFor: formItemId,
53917
+ ...props
53918
+ });
54365
53919
  };
54366
- const neverProcessor = (_schema, _ctx, json, _params) => {
54367
- json.not = {};
53920
+ const RequiredStar = ({ isRequired }) => isRequired ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", {
53921
+ "aria-label": "Asterisk meaning the field is required",
53922
+ children: "*"
53923
+ }) : /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {});
53924
+ const FormLabelLayout = ({ children, isRequired, info, htmlFor, className }) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", {
53925
+ className: "ml-1 flex gap-1 align-middle text-base leading-none",
53926
+ children: [children && /* @__PURE__ */ jsxRuntimeExports.jsxs(FormLabel, {
53927
+ htmlFor,
53928
+ id: `${htmlFor}-label`,
53929
+ suppressHydrationWarning: true,
53930
+ className: clsx("font-bold", className),
53931
+ children: [children, /* @__PURE__ */ jsxRuntimeExports.jsx(RequiredStar, { isRequired })]
53932
+ }), info && /* @__PURE__ */ jsxRuntimeExports.jsx(InformationTag, { content: info })]
53933
+ });
53934
+ const FormItemLayout = ({ label, description, isRequired, info, children, showErrorMessage = true, htmlFor }) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Form.Item, {
53935
+ className: "flex w-full flex-col flex-wrap gap-2 px-1 py-2",
53936
+ children: [
53937
+ (description || label) && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", {
53938
+ className: "flex flex-col gap-1 p-1 leading-none",
53939
+ children: [label && /* @__PURE__ */ jsxRuntimeExports.jsx(FormLabelLayout, {
53940
+ isRequired,
53941
+ info,
53942
+ htmlFor,
53943
+ children: label
53944
+ }), description && /* @__PURE__ */ jsxRuntimeExports.jsx(Form.Description, { children: description })]
53945
+ }),
53946
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Form.Control, { children }),
53947
+ showErrorMessage && /* @__PURE__ */ jsxRuntimeExports.jsx(Form.Message, { "data-testid": "error-message" })
53948
+ ]
53949
+ });
53950
+ const FormFieldElement = ({ field, name, label, Element: Element2, isRequired = false, info, description, showErrorMessage = true, ...props }) => {
53951
+ const { error } = useFormField();
53952
+ const { value: fieldValue, onChange: fieldOnChange, ...fieldRest } = field ?? {};
53953
+ const propsAny = props;
53954
+ const mergedValue = propsAny.value !== void 0 ? propsAny.value : fieldValue ?? "";
53955
+ const mergedOnChange = (...args) => {
53956
+ if (typeof fieldOnChange === "function") fieldOnChange(...args);
53957
+ if (typeof propsAny.onChange === "function") propsAny.onChange(...args);
53958
+ };
53959
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(FormItemLayout, {
53960
+ htmlFor: name,
53961
+ label,
53962
+ description,
53963
+ isRequired,
53964
+ info,
53965
+ showErrorMessage,
53966
+ "aria-invalid": !!error,
53967
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(Element2, {
53968
+ "data-testid": "element",
53969
+ id: name,
53970
+ ...fieldRest,
53971
+ ...props,
53972
+ value: mergedValue,
53973
+ onChange: mergedOnChange,
53974
+ children: props.children
53975
+ })
53976
+ });
54368
53977
  };
54369
- const unknownProcessor = (_schema, _ctx, _json, _params) => {
53978
+ const FormElement = (props) => {
53979
+ const { control } = useFormContext();
53980
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Form.Field, {
53981
+ control,
53982
+ name: props.name,
53983
+ render: ({ field }) => /* @__PURE__ */ jsxRuntimeExports.jsx(FormFieldElement, {
53984
+ ...props,
53985
+ field
53986
+ })
53987
+ });
54370
53988
  };
54371
- const enumProcessor = (schema, _ctx, json, _params) => {
54372
- const def = schema._zod.def;
54373
- const values = getEnumValues(def.entries);
54374
- if (values.every((v2) => typeof v2 === "number"))
54375
- json.type = "number";
54376
- if (values.every((v2) => typeof v2 === "string"))
54377
- json.type = "string";
54378
- json.enum = values;
53989
+ const EditableFieldInputElement = (props) => /* @__PURE__ */ jsxRuntimeExports.jsx(FormElement, {
53990
+ id: props.name,
53991
+ "data-testid": props.name,
53992
+ "aria-labelledby": props.label ? `${props.name}-label` : void 0,
53993
+ "aria-label": props.label ? void 0 : props.name,
53994
+ Element: EditableFieldInput,
53995
+ ...props
53996
+ });
53997
+ const EditableFieldTextAreaElement = (props) => /* @__PURE__ */ jsxRuntimeExports.jsx(FormElement, {
53998
+ id: props.name,
53999
+ "data-testid": props.name,
54000
+ "aria-labelledby": props.label ? `${props.name}-label` : void 0,
54001
+ "aria-label": props.label ? void 0 : props.name,
54002
+ Element: EditableFieldTextArea,
54003
+ ...props
54004
+ });
54005
+ const InputElement = (props) => /* @__PURE__ */ jsxRuntimeExports.jsx(FormElement, {
54006
+ id: props.name,
54007
+ "data-testid": props.name,
54008
+ Element: Input,
54009
+ "aria-labelledby": props.label ? `${props.name}-label` : void 0,
54010
+ "aria-label": props.label ? void 0 : props.name,
54011
+ ...props
54012
+ });
54013
+ const InputPasswordElement = ({ autoComplete, ...props }) => /* @__PURE__ */ jsxRuntimeExports.jsx(FormElement, {
54014
+ Element: InputPassword,
54015
+ id: props.name,
54016
+ "data-testid": props.name,
54017
+ "aria-labelledby": props.label ? `${props.name}-label` : void 0,
54018
+ "aria-label": props.label ? void 0 : props.name,
54019
+ autoComplete,
54020
+ minLength: 6,
54021
+ maxLength: 255,
54022
+ ...props
54023
+ });
54024
+ const selector = (option) => option?.getAttribute("aria-selected") === "true";
54025
+ const OTPFieldContent = ({ field, name, label, description, isRequired, info, showErrorMessage, children, slots = 6, maxLength = 6, ...props }) => {
54026
+ const { error } = useFormField();
54027
+ const optionsRefs = reactExports.useRef([]);
54028
+ const { choiceIndicatorPosition, calculatePosition } = useItemSelector(optionsRefs, {
54029
+ selector,
54030
+ isHoverable: true
54031
+ });
54032
+ reactExports.useEffect(() => {
54033
+ calculatePosition();
54034
+ }, []);
54035
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(FormItemLayout, {
54036
+ htmlFor: name,
54037
+ label,
54038
+ description,
54039
+ isRequired,
54040
+ info,
54041
+ showErrorMessage,
54042
+ "aria-invalid": !!error,
54043
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(InputOTP, {
54044
+ onChange: field.onChange,
54045
+ defaultValue: field.value,
54046
+ maxLength,
54047
+ pattern: "^[0-9]+$",
54048
+ onActiveSlotChange: calculatePosition,
54049
+ ...props,
54050
+ children: children ?? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
54051
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(InputOTPGroup, { children: [
54052
+ /* @__PURE__ */ jsxRuntimeExports.jsx(InputOTPSlot, {
54053
+ index: 0,
54054
+ ref: (el) => {
54055
+ optionsRefs.current[0] = el;
54056
+ }
54057
+ }),
54058
+ /* @__PURE__ */ jsxRuntimeExports.jsx(InputOTPSlot, {
54059
+ index: 1,
54060
+ ref: (el) => {
54061
+ optionsRefs.current[1] = el;
54062
+ }
54063
+ }),
54064
+ /* @__PURE__ */ jsxRuntimeExports.jsx(InputOTPSlot, {
54065
+ index: 2,
54066
+ ref: (el) => {
54067
+ optionsRefs.current[2] = el;
54068
+ }
54069
+ })
54070
+ ] }),
54071
+ /* @__PURE__ */ jsxRuntimeExports.jsx(InputOTPSeparator, {}),
54072
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(InputOTPGroup, { children: [
54073
+ /* @__PURE__ */ jsxRuntimeExports.jsx(InputOTPSlot, {
54074
+ index: 3,
54075
+ ref: (el) => {
54076
+ optionsRefs.current[3] = el;
54077
+ }
54078
+ }),
54079
+ /* @__PURE__ */ jsxRuntimeExports.jsx(InputOTPSlot, {
54080
+ index: 4,
54081
+ ref: (el) => {
54082
+ optionsRefs.current[4] = el;
54083
+ }
54084
+ }),
54085
+ /* @__PURE__ */ jsxRuntimeExports.jsx(InputOTPSlot, {
54086
+ index: 5,
54087
+ ref: (el) => {
54088
+ optionsRefs.current[5] = el;
54089
+ }
54090
+ })
54091
+ ] }),
54092
+ choiceIndicatorPosition && /* @__PURE__ */ jsxRuntimeExports.jsx(InputIndicator, { style: choiceIndicatorPosition })
54093
+ ] })
54094
+ })
54095
+ });
54379
54096
  };
54380
- const customProcessor = (_schema, ctx, _json, _params) => {
54381
- if (ctx.unrepresentable === "throw") {
54382
- throw new Error("Custom types cannot be represented in JSON Schema");
54383
- }
54097
+ const OTPElement = ({ name, description, label, isRequired, info, showErrorMessage, children, slots = 6, maxLength = 6, ...props }) => {
54098
+ const { control } = useFormContext();
54099
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Form.Field, {
54100
+ control,
54101
+ name,
54102
+ render: ({ field }) => /* @__PURE__ */ jsxRuntimeExports.jsx(OTPFieldContent, {
54103
+ field,
54104
+ name,
54105
+ label,
54106
+ description,
54107
+ isRequired,
54108
+ info,
54109
+ showErrorMessage,
54110
+ slots,
54111
+ maxLength,
54112
+ ...props,
54113
+ children
54114
+ })
54115
+ });
54384
54116
  };
54385
- const transformProcessor = (_schema, ctx, _json, _params) => {
54386
- if (ctx.unrepresentable === "throw") {
54387
- throw new Error("Transforms cannot be represented in JSON Schema");
54388
- }
54117
+ const SearchInputElement = (props) => /* @__PURE__ */ jsxRuntimeExports.jsx(FormElement, {
54118
+ id: props.name,
54119
+ "data-testid": props.name,
54120
+ Element: SearchInput,
54121
+ "aria-labelledby": props.label ? `${props.name}-label` : void 0,
54122
+ "aria-label": props.label ? void 0 : props.name,
54123
+ ...props
54124
+ });
54125
+ const TextAreaElement = (props) => /* @__PURE__ */ jsxRuntimeExports.jsx(FormElement, {
54126
+ Element: TextArea,
54127
+ id: props.name,
54128
+ "aria-labelledby": props.label ? `${props.name}-label` : void 0,
54129
+ "aria-label": props.label ? void 0 : props.name,
54130
+ "data-testid": props.name,
54131
+ ...props
54132
+ });
54133
+ const AutoSizedTextAreaElement = (props) => /* @__PURE__ */ jsxRuntimeExports.jsx(FormElement, {
54134
+ Element: AutoSizedTextArea,
54135
+ id: props.name,
54136
+ "data-testid": props.name,
54137
+ ...props
54138
+ });
54139
+ const CheckboxComponent = ({ inputLabel, value, onChange, ...props }) => /* @__PURE__ */ jsxRuntimeExports.jsx(Checkbox, {
54140
+ ...props,
54141
+ label: inputLabel,
54142
+ checked: Boolean(value),
54143
+ onChange
54144
+ });
54145
+ const CheckboxElement = ({ autoComplete, ...props }) => /* @__PURE__ */ jsxRuntimeExports.jsx(FormElement, {
54146
+ Element: CheckboxComponent,
54147
+ id: props.name,
54148
+ "data-testid": props.name,
54149
+ autoComplete,
54150
+ ...props
54151
+ });
54152
+ const MultiSelectFieldContent = ({ field, name, label, description, isRequired, info, showErrorMessage, children, ...props }) => {
54153
+ const { error } = useFormField();
54154
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(FormItemLayout, {
54155
+ htmlFor: name,
54156
+ label,
54157
+ description,
54158
+ isRequired,
54159
+ info,
54160
+ showErrorMessage,
54161
+ "aria-invalid": !!error,
54162
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(MultiSelect, {
54163
+ onValueChange: field.onChange,
54164
+ values: field.value,
54165
+ ...props,
54166
+ children
54167
+ })
54168
+ });
54389
54169
  };
54390
- const arrayProcessor = (schema, ctx, _json, params) => {
54391
- const json = _json;
54392
- const def = schema._zod.def;
54393
- const { minimum, maximum } = schema._zod.bag;
54394
- if (typeof minimum === "number")
54395
- json.minItems = minimum;
54396
- if (typeof maximum === "number")
54397
- json.maxItems = maximum;
54398
- json.type = "array";
54399
- json.items = process$1(def.element, ctx, { ...params, path: [...params.path, "items"] });
54170
+ const MultiSelectElement = ({ name, description, label, isRequired, info, showErrorMessage, children, ...props }) => {
54171
+ const { control } = useFormContext();
54172
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Form.Field, {
54173
+ control,
54174
+ name,
54175
+ render: ({ field }) => /* @__PURE__ */ jsxRuntimeExports.jsx(MultiSelectFieldContent, {
54176
+ field,
54177
+ name,
54178
+ label,
54179
+ description,
54180
+ isRequired,
54181
+ info,
54182
+ showErrorMessage,
54183
+ ...props,
54184
+ children
54185
+ })
54186
+ });
54400
54187
  };
54401
- const objectProcessor = (schema, ctx, _json, params) => {
54402
- const json = _json;
54403
- const def = schema._zod.def;
54404
- json.type = "object";
54405
- json.properties = {};
54406
- const shape = def.shape;
54407
- for (const key2 in shape) {
54408
- json.properties[key2] = process$1(shape[key2], ctx, {
54409
- ...params,
54410
- path: [...params.path, "properties", key2]
54411
- });
54412
- }
54413
- const allKeys = new Set(Object.keys(shape));
54414
- const requiredKeys = new Set([...allKeys].filter((key2) => {
54415
- const v2 = def.shape[key2]._zod;
54416
- if (ctx.io === "input") {
54417
- return v2.optin === void 0;
54418
- } else {
54419
- return v2.optout === void 0;
54420
- }
54421
- }));
54422
- if (requiredKeys.size > 0) {
54423
- json.required = Array.from(requiredKeys);
54424
- }
54425
- if (def.catchall?._zod.def.type === "never") {
54426
- json.additionalProperties = false;
54427
- } else if (!def.catchall) {
54428
- if (ctx.io === "output")
54429
- json.additionalProperties = false;
54430
- } else if (def.catchall) {
54431
- json.additionalProperties = process$1(def.catchall, ctx, {
54432
- ...params,
54433
- path: [...params.path, "additionalProperties"]
54434
- });
54435
- }
54188
+ const SelectFieldContent = ({ field, name, label, description, isRequired, info, showErrorMessage, children, ...props }) => {
54189
+ const { error } = useFormField();
54190
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(FormItemLayout, {
54191
+ htmlFor: name,
54192
+ label,
54193
+ description,
54194
+ isRequired,
54195
+ info,
54196
+ showErrorMessage,
54197
+ "aria-invalid": !!error,
54198
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(Select, {
54199
+ onValueChange: field.onChange,
54200
+ defaultValue: field.value,
54201
+ ...props,
54202
+ children
54203
+ })
54204
+ });
54436
54205
  };
54437
- const unionProcessor = (schema, ctx, json, params) => {
54438
- const def = schema._zod.def;
54439
- const isExclusive = def.inclusive === false;
54440
- const options = def.options.map((x, i2) => process$1(x, ctx, {
54441
- ...params,
54442
- path: [...params.path, isExclusive ? "oneOf" : "anyOf", i2]
54443
- }));
54444
- if (isExclusive) {
54445
- json.oneOf = options;
54446
- } else {
54447
- json.anyOf = options;
54448
- }
54206
+ const SelectElement = ({ name, description, label, isRequired, info, showErrorMessage, children, ...props }) => {
54207
+ const { control } = useFormContext();
54208
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Form.Field, {
54209
+ control,
54210
+ name,
54211
+ render: ({ field }) => /* @__PURE__ */ jsxRuntimeExports.jsx(SelectFieldContent, {
54212
+ field,
54213
+ name,
54214
+ label,
54215
+ description,
54216
+ isRequired,
54217
+ info,
54218
+ showErrorMessage,
54219
+ ...props,
54220
+ children
54221
+ })
54222
+ });
54449
54223
  };
54450
- const intersectionProcessor = (schema, ctx, json, params) => {
54451
- const def = schema._zod.def;
54452
- const a2 = process$1(def.left, ctx, {
54453
- ...params,
54454
- path: [...params.path, "allOf", 0]
54224
+ const SwitchSelectorFieldContent = ({ field, name, label, description, isRequired, info, showErrorMessage, children, ...props }) => {
54225
+ const { error } = useFormField();
54226
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(FormItemLayout, {
54227
+ htmlFor: name,
54228
+ label,
54229
+ description,
54230
+ isRequired,
54231
+ info,
54232
+ showErrorMessage,
54233
+ "aria-invalid": !!error,
54234
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(SwitchSelector, {
54235
+ ...field,
54236
+ ...props,
54237
+ children
54238
+ })
54455
54239
  });
54456
- const b = process$1(def.right, ctx, {
54457
- ...params,
54458
- path: [...params.path, "allOf", 1]
54240
+ };
54241
+ const SwitchSelectorElement = ({ name, description, label, isRequired, info, showErrorMessage, children, ...props }) => {
54242
+ const { control } = useFormContext();
54243
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Form.Field, {
54244
+ control,
54245
+ name,
54246
+ render: ({ field }) => /* @__PURE__ */ jsxRuntimeExports.jsx(SwitchSelectorFieldContent, {
54247
+ field,
54248
+ name,
54249
+ label,
54250
+ description,
54251
+ isRequired,
54252
+ info,
54253
+ showErrorMessage,
54254
+ ...props,
54255
+ children
54256
+ })
54459
54257
  });
54460
- const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
54461
- const allOf = [
54462
- ...isSimpleIntersection(a2) ? a2.allOf : [a2],
54463
- ...isSimpleIntersection(b) ? b.allOf : [b]
54464
- ];
54465
- json.allOf = allOf;
54466
54258
  };
54467
- const nullableProcessor = (schema, ctx, json, params) => {
54468
- const def = schema._zod.def;
54469
- const inner = process$1(def.innerType, ctx, params);
54470
- const seen2 = ctx.seen.get(schema);
54471
- if (ctx.target === "openapi-3.0") {
54472
- seen2.ref = def.innerType;
54473
- json.nullable = true;
54474
- } else {
54475
- json.anyOf = [inner, { type: "null" }];
54259
+ var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
54260
+ var use = React[" use ".trim().toString()];
54261
+ function isPromiseLike(value) {
54262
+ return typeof value === "object" && value !== null && "then" in value;
54263
+ }
54264
+ function isLazyComponent(element) {
54265
+ return element != null && typeof element === "object" && "$$typeof" in element && element.$$typeof === REACT_LAZY_TYPE && "_payload" in element && isPromiseLike(element._payload);
54266
+ }
54267
+ // @__NO_SIDE_EFFECTS__
54268
+ function createSlot(ownerName) {
54269
+ const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
54270
+ const Slot2 = reactExports.forwardRef((props, forwardedRef) => {
54271
+ let { children, ...slotProps } = props;
54272
+ if (isLazyComponent(children) && typeof use === "function") {
54273
+ children = use(children._payload);
54274
+ }
54275
+ const childrenArray = reactExports.Children.toArray(children);
54276
+ const slottable = childrenArray.find(isSlottable);
54277
+ if (slottable) {
54278
+ const newElement = slottable.props.children;
54279
+ const newChildren = childrenArray.map((child) => {
54280
+ if (child === slottable) {
54281
+ if (reactExports.Children.count(newElement) > 1) return reactExports.Children.only(null);
54282
+ return reactExports.isValidElement(newElement) ? newElement.props.children : null;
54283
+ } else {
54284
+ return child;
54285
+ }
54286
+ });
54287
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: reactExports.isValidElement(newElement) ? reactExports.cloneElement(newElement, void 0, newChildren) : null });
54288
+ }
54289
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
54290
+ });
54291
+ Slot2.displayName = `${ownerName}.Slot`;
54292
+ return Slot2;
54293
+ }
54294
+ var Slot = /* @__PURE__ */ createSlot("Slot");
54295
+ // @__NO_SIDE_EFFECTS__
54296
+ function createSlotClone(ownerName) {
54297
+ const SlotClone = reactExports.forwardRef((props, forwardedRef) => {
54298
+ let { children, ...slotProps } = props;
54299
+ if (isLazyComponent(children) && typeof use === "function") {
54300
+ children = use(children._payload);
54301
+ }
54302
+ if (reactExports.isValidElement(children)) {
54303
+ const childrenRef = getElementRef(children);
54304
+ const props2 = mergeProps(slotProps, children.props);
54305
+ if (children.type !== reactExports.Fragment) {
54306
+ props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
54307
+ }
54308
+ return reactExports.cloneElement(children, props2);
54309
+ }
54310
+ return reactExports.Children.count(children) > 1 ? reactExports.Children.only(null) : null;
54311
+ });
54312
+ SlotClone.displayName = `${ownerName}.SlotClone`;
54313
+ return SlotClone;
54314
+ }
54315
+ var SLOTTABLE_IDENTIFIER = /* @__PURE__ */ Symbol("radix.slottable");
54316
+ function isSlottable(child) {
54317
+ return reactExports.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
54318
+ }
54319
+ function mergeProps(slotProps, childProps) {
54320
+ const overrideProps = { ...childProps };
54321
+ for (const propName in childProps) {
54322
+ const slotPropValue = slotProps[propName];
54323
+ const childPropValue = childProps[propName];
54324
+ const isHandler = /^on[A-Z]/.test(propName);
54325
+ if (isHandler) {
54326
+ if (slotPropValue && childPropValue) {
54327
+ overrideProps[propName] = (...args) => {
54328
+ const result = childPropValue(...args);
54329
+ slotPropValue(...args);
54330
+ return result;
54331
+ };
54332
+ } else if (slotPropValue) {
54333
+ overrideProps[propName] = slotPropValue;
54334
+ }
54335
+ } else if (propName === "style") {
54336
+ overrideProps[propName] = { ...slotPropValue, ...childPropValue };
54337
+ } else if (propName === "className") {
54338
+ overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
54339
+ }
54476
54340
  }
54477
- };
54478
- const nonoptionalProcessor = (schema, ctx, _json, params) => {
54479
- const def = schema._zod.def;
54480
- process$1(def.innerType, ctx, params);
54481
- const seen2 = ctx.seen.get(schema);
54482
- seen2.ref = def.innerType;
54483
- };
54484
- const defaultProcessor = (schema, ctx, json, params) => {
54485
- const def = schema._zod.def;
54486
- process$1(def.innerType, ctx, params);
54487
- const seen2 = ctx.seen.get(schema);
54488
- seen2.ref = def.innerType;
54489
- json.default = JSON.parse(JSON.stringify(def.defaultValue));
54490
- };
54491
- const prefaultProcessor = (schema, ctx, json, params) => {
54492
- const def = schema._zod.def;
54493
- process$1(def.innerType, ctx, params);
54494
- const seen2 = ctx.seen.get(schema);
54495
- seen2.ref = def.innerType;
54496
- if (ctx.io === "input")
54497
- json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
54498
- };
54499
- const catchProcessor = (schema, ctx, json, params) => {
54500
- const def = schema._zod.def;
54501
- process$1(def.innerType, ctx, params);
54502
- const seen2 = ctx.seen.get(schema);
54503
- seen2.ref = def.innerType;
54504
- let catchValue;
54505
- try {
54506
- catchValue = def.catchValue(void 0);
54507
- } catch {
54508
- throw new Error("Dynamic catch values are not supported in JSON Schema");
54341
+ return { ...slotProps, ...overrideProps };
54342
+ }
54343
+ function getElementRef(element) {
54344
+ let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
54345
+ let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
54346
+ if (mayWarn) {
54347
+ return element.ref;
54509
54348
  }
54510
- json.default = catchValue;
54511
- };
54512
- const pipeProcessor = (schema, ctx, _json, params) => {
54513
- const def = schema._zod.def;
54514
- const innerType = ctx.io === "input" ? def.in._zod.def.type === "transform" ? def.out : def.in : def.out;
54515
- process$1(innerType, ctx, params);
54516
- const seen2 = ctx.seen.get(schema);
54517
- seen2.ref = innerType;
54349
+ getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
54350
+ mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
54351
+ if (mayWarn) {
54352
+ return element.props.ref;
54353
+ }
54354
+ return element.props.ref || element.ref;
54355
+ }
54356
+ const FormControl = (props) => {
54357
+ const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
54358
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Slot, {
54359
+ id: formItemId,
54360
+ "aria-describedby": !error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`,
54361
+ "aria-invalid": !!error,
54362
+ ...props
54363
+ });
54518
54364
  };
54519
- const readonlyProcessor = (schema, ctx, json, params) => {
54520
- const def = schema._zod.def;
54521
- process$1(def.innerType, ctx, params);
54522
- const seen2 = ctx.seen.get(schema);
54523
- seen2.ref = def.innerType;
54524
- json.readOnly = true;
54365
+ const FormDescription = (props) => {
54366
+ const { formDescriptionId } = useFormField();
54367
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("p", {
54368
+ className: "text-neutral text-sm",
54369
+ id: formDescriptionId,
54370
+ ...props
54371
+ });
54525
54372
  };
54526
- const optionalProcessor = (schema, ctx, _json, params) => {
54527
- const def = schema._zod.def;
54528
- process$1(def.innerType, ctx, params);
54529
- const seen2 = ctx.seen.get(schema);
54530
- seen2.ref = def.innerType;
54373
+ const FormMessage = ({ children, ...props }) => {
54374
+ const { error, formMessageId } = useFormField();
54375
+ const body = error ? String(error?.message ?? "") : children;
54376
+ if (!body) return null;
54377
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("p", {
54378
+ className: "font-medium text-error text-xs",
54379
+ role: "alert",
54380
+ id: formMessageId,
54381
+ ...props,
54382
+ children: body
54383
+ });
54531
54384
  };
54385
+ const Form = Form$1;
54386
+ Form.Description = FormDescription;
54387
+ Form.Control = FormControl;
54388
+ Form.Field = FormField;
54389
+ Form.Item = FormItem;
54390
+ Form.Label = FormLabelLayout;
54391
+ Form.Message = FormMessage;
54392
+ Form.Element = FormElement;
54393
+ Form.Input = InputElement;
54394
+ Form.InputPassword = InputPasswordElement;
54395
+ Form.Checkbox = CheckboxElement;
54396
+ Form.TextArea = TextAreaElement;
54397
+ Form.AutoSizedTextArea = AutoSizedTextAreaElement;
54398
+ Form.Button = Button;
54399
+ Form.Select = SelectElement;
54400
+ Form.MultiSelect = MultiSelectElement;
54401
+ Form.EditableFieldInput = EditableFieldInputElement;
54402
+ Form.EditableFieldTextArea = EditableFieldTextAreaElement;
54403
+ Form.SwitchSelector = SwitchSelectorElement;
54404
+ Form.OTP = OTPElement;
54405
+ Form.SearchInput = SearchInputElement;
54532
54406
  const ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
54533
54407
  $ZodISODateTime.init(inst, def);
54534
54408
  ZodStringFormat.init(inst, def);