{"version":3,"file":"index.cjs","names":["comparer"],"sources":["../src/contexts/active-view-context.ts","../src/contexts/view-models-context.ts","../src/components/active-view-model-provider.tsx","../../../node_modules/.pnpm/yummies@7.20.1_mobx@6.15.0_react@19.2.5/node_modules/yummies/mobx.js","../src/lib/hooks/use-isomorphic-layout-effect.ts","../src/lib/hooks/use-value.ts","../src/hooks/use-create-view-model.ts","../src/hooks/use-view-model.ts","../src/components/only-view-model.tsx","../src/components/view-models-provider.tsx","../src/hoc/with-view-model.tsx","../src/hoc/with-props-view-model.tsx"],"sourcesContent":["import type { AnyViewModel, AnyViewModelSimple } from 'mobx-view-model';\nimport { createContext } from 'react';\n\n// will contains the view model\nexport const ActiveViewModelContext = createContext<\n  AnyViewModel | AnyViewModelSimple\n>(null as any);\n\nif (process.env.NODE_ENV !== 'production') {\n  ActiveViewModelContext.displayName = 'ActiveViewModelContext';\n}\n","import type { ViewModelStore } from 'mobx-view-model';\nimport { createContext } from 'react';\n\n/**\n * Context which contains the view models store instance.\n * This context is used to access the view models store inside the React components.\n * @see {@link ViewModelStore}\n */\nexport const ViewModelsContext = createContext<ViewModelStore>(\n  null as unknown as ViewModelStore,\n);\n","import type { AnyViewModel, AnyViewModelSimple } from 'mobx-view-model';\nimport { ActiveViewModelContext } from '../contexts/index.js';\nimport { RComponentType, RReactNode } from \"../lib/react-types.js\";\n\n/**\n * This is a provider for the `ActiveViewModelContext`.\n * This HOC is not recommended for public usage.\n * Better to use `withViewModel` HOC.\n */\nexport const ActiveViewModelProvider =\n  ActiveViewModelContext.Provider as unknown as RComponentType<{\n    value: AnyViewModel | AnyViewModelSimple;\n    children?: RReactNode;\n  }>;\n","import { typeGuard } from \"yummies/type-guard\";\nimport { $mobx, _getGlobalState, action, comparer, computed, createAtom, makeObservable, observable, onBecomeObserved, onBecomeUnobserved, runInAction } from \"mobx\";\n//#region src/mobx/annotation.ts\n/**\n* ---header-docs-section---\n* # yummies/mobx\n*\n* ## Description\n*\n* **`annotation`** — factories for `makeObservable` maps and {@link applyObservable} tuples:\n* `observable.*` flavours, `computed` with shorthand `equals` (`struct`, `shallow`, reference), custom\n* comparators, and `false` to skip a field.\n*\n* ## Usage\n*\n* ```ts\n* import { annotation } from \"yummies/mobx\";\n* ```\n*/\nvar computedEqualsResolvers = {\n\ttrue: comparer.default,\n\tshallow: comparer.shallow,\n\tstruct: comparer.structural\n};\nvar annotation = {\n\tcomputed: (value, options) => {\n\t\tif (value === false) return false;\n\t\treturn computed({\n\t\t\t...options,\n\t\t\tequals: typeof value === \"function\" ? value : computedEqualsResolvers[value] ?? comparer.default\n\t\t});\n\t},\n\tobservable: (value) => {\n\t\tif (value === false) return false;\n\t\tif (value === void 0 || value === true) return observable;\n\t\treturn observable[value];\n\t}\n};\n//#endregion\n//#region src/mobx/apply-observable.ts\n/**\n* ---header-docs-section---\n* # yummies/mobx\n*\n* ## Description\n*\n* Compact **MobX `makeObservable`** wiring from tuple lists of annotations and keys. Reduces boilerplate\n* when many fields share `observable`, `action`, or `computed` decorators and you want one call site\n* instead of sprawling annotation maps across large stores.\n*\n* ## Usage\n*\n* ```ts\n* import { applyObservable } from \"yummies/mobx\";\n* ```\n*/\n/**\n* Applies a compact list of MobX annotations to an object using either\n* decorator-style invocation or the annotation map form accepted by `makeObservable`.\n*\n* @template T Target object type.\n* @param context Object that should become observable.\n* @param annotationsArray Tuples of annotation followed by annotated field names.\n* @param useDecorators Enables decorator-style application before calling `makeObservable`.\n*\n* @example\n* ```ts\n* applyObservable(store, [[observable, 'items'], [action, 'setItems']]);\n* ```\n*\n* @example\n* ```ts\n* applyObservable(viewModel, [[computed, 'fullName']], true);\n* ```\n*/\nvar applyObservable = (context, annotationsArray, useDecorators) => {\n\tif (useDecorators) {\n\t\tannotationsArray.forEach(([annotation, ...fields]) => {\n\t\t\tfields.forEach((field) => {\n\t\t\t\tannotation(context, field);\n\t\t\t});\n\t\t});\n\t\tmakeObservable(context);\n\t} else {\n\t\tconst annotationsObject = {};\n\t\tannotationsArray.forEach(([annotation, ...fields]) => {\n\t\t\tfields.forEach((field) => {\n\t\t\t\tannotationsObject[field] = annotation;\n\t\t\t});\n\t\t});\n\t\tmakeObservable(context, annotationsObject);\n\t}\n};\n//#endregion\n//#region src/mobx/create-enhanced-atom.ts\n/**\n* ---header-docs-section---\n* # yummies/mobx\n*\n* ## Description\n*\n* **`createAtom` wrapper** that attaches arbitrary metadata and keeps MobX’s observed/unobserved\n* hooks in one place. Useful for custom reactive primitives, async resources, or debugging atoms\n* where the stock API is too bare.\n*\n* ## Usage\n*\n* ```ts\n* import { createEnhancedAtom } from \"yummies/mobx\";\n* ```\n*/\n/**\n* Creates a MobX atom extended with metadata and bound reporting methods.\n*\n* @template TMeta Metadata object stored on the atom.\n* @param name Atom name used by MobX for debugging.\n* @param onBecomeObservedHandler Callback fired when the atom becomes observed.\n* @param onBecomeUnobservedHandler Callback fired when the atom is no longer observed.\n* @param meta Optional metadata attached to the atom.\n* @returns Atom instance with `meta`, `reportChanged` and `reportObserved`.\n*\n* @example\n* ```ts\n* const atom = createEnhancedAtom('user-status');\n* atom.reportChanged();\n* ```\n*\n* @example\n* ```ts\n* const atom = createEnhancedAtom('cache', undefined, undefined, { scope: 'users' });\n* atom.meta.scope;\n* ```\n*/\nvar createEnhancedAtom = (name, onBecomeObservedHandler, onBecomeUnobservedHandler, meta) => {\n\tconst atom = createAtom(name, onBecomeObservedHandler && (() => onBecomeObservedHandler(atom)), onBecomeUnobservedHandler && (() => onBecomeUnobservedHandler(atom)));\n\tatom.meta = meta ?? {};\n\tatom.reportChanged = atom.reportChanged.bind(atom);\n\tatom.reportObserved = atom.reportObserved.bind(atom);\n\treturn atom;\n};\n//#endregion\n//#region src/mobx/create-ref.ts\n/**\n* ---header-docs-section---\n* # yummies/mobx\n*\n* ## Description\n*\n* **Observable ref** pattern for MobX: boxed mutable references with change listeners, metadata,\n* and optional custom equality. Bridges React-style ref holders and MobX reactivity when a single\n* mutable cell must notify dependents without replacing the whole parent object graph.\n*\n* ## Usage\n*\n* ```ts\n* import { createRef } from \"yummies/mobx\";\n* ```\n*/\n/**\n* Creates a MobX-aware ref that behaves like a callback ref and exposes\n* observable `current` and `meta` fields.\n*\n* @template T Referenced value type.\n* @template TMeta Additional observable metadata stored on the ref.\n* @param cfg Optional callbacks, initial value and comparer configuration.\n* @returns Observable ref function object.\n*\n* @example\n* ```ts\n* const inputRef = createRef<HTMLInputElement>();\n* inputRef.set(document.createElement('input'));\n* ```\n*\n* @example\n* ```ts\n* const ref = createRef<number>();\n* ref(3);\n* ref.current; // 3\n* ```\n*\n* @example\n* ```ts\n* const nodeRef = createRef({\n*   onUnset: () => console.log('detached'),\n*   meta: { mounted: false },\n* });\n* ```\n*/\nvar createRef = (cfg) => {\n\tlet lastValue;\n\tconst comparer$1 = cfg?.comparer ?? comparer.default;\n\tconst setValue = (value) => {\n\t\tconst nextValue = value ?? null;\n\t\tif (comparer$1(ref.current, nextValue)) return;\n\t\trunInAction(() => {\n\t\t\tconst prevLastValue = lastValue;\n\t\t\tlastValue = ref.current ?? void 0;\n\t\t\tref.current = nextValue;\n\t\t\tlet isNextValueIgnored = false;\n\t\t\tref.listeners.forEach((listener) => {\n\t\t\t\tif (listener(ref.current, lastValue) === false) isNextValueIgnored = true;\n\t\t\t});\n\t\t\tif (isNextValueIgnored) {\n\t\t\t\tlastValue = prevLastValue;\n\t\t\t\tref.current = lastValue ?? null;\n\t\t\t} else if (ref.current === null && lastValue !== void 0) lastValue = void 0;\n\t\t});\n\t};\n\tconst ref = setValue;\n\tref.set = setValue;\n\tref.listeners = new Set(cfg?.onChange ? [cfg.onChange] : []);\n\tif (cfg?.onSet || cfg?.onUnset) ref.listeners.add((value, prevValue) => {\n\t\tif (value) cfg.onSet?.(value, prevValue);\n\t\telse cfg.onUnset?.(prevValue);\n\t});\n\tref.current = cfg?.initial ?? null;\n\tref.meta = cfg?.meta ?? {};\n\tmakeObservable(ref, {\n\t\tcurrent: observable.ref,\n\t\tmeta: observable\n\t});\n\treturn ref;\n};\n/**\n* Checks whether the provided value is a ref created by `createRef`.\n*\n* @template T Referenced value type.\n* @template TMeta Ref metadata type.\n* @param value Value to inspect.\n* @returns `true` when the value is a ref-like function with `current`.\n*\n* @example\n* ```ts\n* const ref = createRef<number>();\n* isRef(ref); // true\n* ```\n*\n* @example\n* ```ts\n* isRef({ current: 1 }); // false\n* ```\n*/\nvar isRef = (value) => {\n\treturn typeof value === \"function\" && \"current\" in value;\n};\n/**\n* Normalizes a plain value or an existing ref into a `Ref` instance.\n*\n* @template T Referenced value type.\n* @template TMeta Ref metadata type.\n* @param value Existing ref or initial plain value.\n* @param cfg Optional ref configuration applied when a new ref is created.\n* @returns Existing ref or a newly created ref initialized with `value`.\n*\n* @example\n* ```ts\n* const ref = toRef(document.body);\n* ref.current === document.body;\n* ```\n*\n* @example\n* ```ts\n* const existingRef = createRef<number>();\n* const sameRef = toRef(existingRef);\n* ```\n*/\nvar toRef = (value, cfg) => {\n\treturn isRef(value) ? value : createRef({\n\t\tinitial: value,\n\t\t...cfg\n\t});\n};\n//#endregion\n//#region src/mobx/deep-observable-struct.ts\n/**\n* ---header-docs-section---\n* # yummies/mobx\n*\n* ## Description\n*\n* **Deep observable object** with structural `set` patches that reuse nested observables when keys\n* overlap. Helps store trees (forms, filters, entities) under MobX without wholesale replacement\n* and without manual `observable.map` wiring for every level.\n*\n* ## Usage\n*\n* ```ts\n* import { DeepObservableStruct } from \"yummies/mobx\";\n* ```\n*/\n/**\n* Wraps a plain object into a deeply observable structure and allows\n* patch-like updates while preserving nested observable references where possible.\n*\n* @template TData Observable object shape.\n*\n* @example\n* ```ts\n* const state = new DeepObservableStruct({ user: { name: 'Ann' } });\n* state.set({ user: { name: 'Bob' } });\n* ```\n*\n* @example\n* ```ts\n* const state = new DeepObservableStruct({ filters: { active: true } });\n* state.set({ filters: { active: false, archived: true } });\n* ```\n*/\nvar DeepObservableStruct = class {\n\tdata;\n\tconstructor(data) {\n\t\tthis.data = data;\n\t\tmakeObservable(this, {\n\t\t\tdata: observable.deep,\n\t\t\tset: action\n\t\t});\n\t}\n\tset(newData) {\n\t\tconst stack = Object.keys(this.data).map((key) => [\n\t\t\tkey,\n\t\t\tthis.data,\n\t\t\tnewData\n\t\t]);\n\t\tlet currentIndex = 0;\n\t\tlet stackLength = stack.length;\n\t\twhile (currentIndex < stackLength) {\n\t\t\tconst [key, currObservableData, newData] = stack[currentIndex];\n\t\t\tconst newValue = newData[key];\n\t\t\tconst currValue = currObservableData[key];\n\t\t\tcurrentIndex++;\n\t\t\tif (key in newData) {\n\t\t\t\tif (typeGuard.isObject(newValue) && typeGuard.isObject(currValue)) {\n\t\t\t\t\tconst newValueKeys = Object.keys(newValue);\n\t\t\t\t\tObject.keys(currValue).forEach((childKey) => {\n\t\t\t\t\t\tif (!(childKey in newValue)) delete currObservableData[key][childKey];\n\t\t\t\t\t});\n\t\t\t\t\tnewValueKeys.forEach((childKey) => {\n\t\t\t\t\t\tstackLength = stack.push([\n\t\t\t\t\t\t\tchildKey,\n\t\t\t\t\t\t\tcurrObservableData[key],\n\t\t\t\t\t\t\tnewValue\n\t\t\t\t\t\t]);\n\t\t\t\t\t});\n\t\t\t\t} else if (newValue !== currValue) currObservableData[key] = newValue;\n\t\t\t} else delete currObservableData[key];\n\t\t}\n\t\tObject.keys(newData).forEach((newDataKey) => {\n\t\t\tif (!this.data[newDataKey]) this.data[newDataKey] = newData[newDataKey];\n\t\t});\n\t}\n};\n//#endregion\n//#region src/mobx/flush-pending-reactions.ts\n/** Same cap as MobX's internal `MAX_REACTION_ITERATIONS` (not exported from the package). */\nvar DEFAULT_MAX_REACTION_ITERATIONS = 100;\n/**\n* Synchronously runs MobX reactions from the internal `pendingReactions` queue when they piled up\n* during a batch (`inBatch > 0`, e.g. inside `runInAction`).\n*\n* While a batch is open, MobX only enqueues reactions; this call temporarily resets the batch\n* counter, drains the queue, and restores state—useful in tests and when you need side effects\n* before leaving the action.\n*\n* If there are no pending reactions, a reaction run is already in progress (`isRunningReactions`),\n* or the iteration cap is hit (cycle guard), there is no extra work; when the cap is exceeded the\n* queue is cleared, matching MobX's internal safety behavior.\n*\n* @param maxCount - Maximum iterations of the outer drain loop (default 100, same idea as MobX's internal limit).\n*   Pass `Number.POSITIVE_INFINITY` to disable this cap only when you trust the reaction graph to settle;\n*   a non-converging cycle will then keep looping until the queue empties (or effectively hang).\n*\n* @example\n* ```ts\n* import { observable, reaction, runInAction } from \"mobx\";\n* import { flushPendingReactions } from \"yummies/mobx\";\n*\n* const state = observable({ count: 0 });\n* const log: number[] = [];\n* reaction(() => state.count, (n) => log.push(n));\n*\n* runInAction(() => {\n*   state.count = 1;\n*   flushPendingReactions();\n* });\n*\n* // log === [1] — the reaction ran before the action finished\n* ```\n*/\nfunction flushPendingReactions(maxCount = DEFAULT_MAX_REACTION_ITERATIONS) {\n\tconst gs = _getGlobalState();\n\tif (!maxCount || gs.isRunningReactions || gs.pendingReactions.length === 0) return;\n\tconst savedInBatch = gs.inBatch;\n\tgs.inBatch = 0;\n\ttry {\n\t\tgs.isRunningReactions = true;\n\t\tconst queue = gs.pendingReactions;\n\t\tlet iterations = 0;\n\t\twhile (queue.length > 0) {\n\t\t\tif (++iterations === maxCount) {\n\t\t\t\tqueue.splice(0);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tconst batch = queue.splice(0);\n\t\t\tfor (let i = 0; i < batch.length; i++) batch[i].runReaction_();\n\t\t}\n\t} finally {\n\t\tgs.isRunningReactions = false;\n\t\tgs.inBatch = savedInBatch;\n\t}\n}\n//#endregion\n//#region src/mobx/get-mobx-administration.ts\n/**\n* ---header-docs-section---\n* # yummies/mobx\n*\n* ## Description\n*\n* Typed access to MobX **internal administration** (`$mobx`) for advanced tooling, migration scripts,\n* or introspection. Prefer public MobX APIs in application code; reach for this when you must align\n* with library internals or patch behavior at the administration layer.\n*\n* ## Usage\n*\n* ```ts\n* import { getMobxAdministration } from \"yummies/mobx\";\n* ```\n*/\n/**\n* Returns the internal MobX administration object associated with an observable target.\n*\n* @param context Observable object instance.\n* @returns MobX administration internals stored under `$mobx`.\n*\n* @example\n* ```ts\n* const admin = getMobxAdministration(store);\n* admin.name_;\n* ```\n*\n* @example\n* ```ts\n* const values = getMobxAdministration(formState).values_;\n* ```\n*/\nvar getMobxAdministration = (context) => context[$mobx];\n//#endregion\n//#region src/mobx/lazy-observe.ts\n/**\n* ---header-docs-section---\n* # yummies/mobx\n*\n* ## Description\n*\n* **Lazy subscriptions** tied to MobX observation: start work when the first reaction observes\n* tracked keys, stop when nothing listens anymore (optionally after a delay). Ideal for polling,\n* WebSocket feeds, or expensive caches that should idle when the UI is not mounted.\n*\n* ## Usage\n*\n* ```ts\n* import { lazyObserve } from \"yummies/mobx\";\n* ```\n*/\n/**\n* Starts side effects only while one or more MobX observables are being observed.\n*\n* When the first property becomes observed, `onStart` is called. When all tracked\n* properties become unobserved, `onEnd` is called with the value returned by\n* `onStart`. Cleanup can be delayed via `endDelay`.\n*\n* It uses MobX `onBecomeObserved` and `onBecomeUnobserved` hooks to perform\n* lazy subscription management.\n*\n* @template TMetaData Data returned from `onStart` and forwarded to `onEnd`.\n* @param config Configuration for tracked properties and lifecycle callbacks.\n* @returns Cleanup function that clears the tracked state and runs `onEnd`.\n*\n* @example\n* ```ts\n* const stop = lazyObserve({\n*   context: store,\n*   property: 'items',\n*   onStart: () => api.subscribe(),\n*   onEnd: (subscription) => subscription.unsubscribe(),\n* });\n* ```\n*\n* @example\n* ```ts\n* lazyObserve({\n*   property: [boxA, boxB],\n*   onStart: () => console.log('observed'),\n*   endDelay: 300,\n* });\n* ```\n*/\nvar lazyObserve = ({ context, property, onStart, onEnd, endDelay = false }) => {\n\tlet timeoutId;\n\tlet metaData;\n\tconst observingProps = /* @__PURE__ */ new Set();\n\tconst properties = Array.isArray(property) ? property : [property];\n\tconst cleanup = () => {\n\t\tobservingProps.clear();\n\t\tif (endDelay === false) {\n\t\t\tonEnd?.(metaData, cleanup);\n\t\t\tmetaData = void 0;\n\t\t\treturn;\n\t\t}\n\t\tif (timeoutId) {\n\t\t\tclearTimeout(timeoutId);\n\t\t\ttimeoutId = void 0;\n\t\t}\n\t\ttimeoutId = setTimeout(() => {\n\t\t\tonEnd?.(metaData, cleanup);\n\t\t\ttimeoutId = void 0;\n\t\t\tmetaData = void 0;\n\t\t}, endDelay);\n\t};\n\tconst start = (property) => {\n\t\tconst isAlreadyObserving = observingProps.size > 0;\n\t\tobservingProps.add(property);\n\t\tif (isAlreadyObserving) return;\n\t\tif (timeoutId) {\n\t\t\tclearTimeout(timeoutId);\n\t\t\ttimeoutId = void 0;\n\t\t}\n\t\tmetaData = onStart?.();\n\t};\n\tconst stop = (property) => {\n\t\tconst isAlreadyNotObserving = !observingProps.size;\n\t\tobservingProps.delete(property);\n\t\tconst isObserving = observingProps.size > 0;\n\t\tif (isAlreadyNotObserving || isObserving) return;\n\t\tcleanup();\n\t};\n\tproperties.forEach((property) => {\n\t\tif (context) {\n\t\t\tonBecomeObserved(context, property, () => start(property));\n\t\t\tonBecomeUnobserved(context, property, () => stop(property));\n\t\t} else {\n\t\t\tonBecomeObserved(property, () => start(property));\n\t\t\tonBecomeUnobserved(property, () => stop(property));\n\t\t}\n\t});\n\treturn cleanup;\n};\n//#endregion\nexport { DeepObservableStruct, annotation, applyObservable, createEnhancedAtom, createRef, flushPendingReactions, getMobxAdministration, isRef, lazyObserve, toRef };\n\n//# sourceMappingURL=mobx.js.map","import { useEffect, useLayoutEffect } from 'react';\n\n/**\n * On the **client**, this is `useLayoutEffect` (runs before paint). That is not\n * redundant: attach/detach still run here after the synchronous first-pass attach\n * so clean-up and async `attach()` stay correct. On the **server**, React maps\n * this to `useEffect` only to avoid `useLayoutEffect` warnings; neither hook runs\n * during SSR.\n */\nexport const useIsomorphicLayoutEffect =\n  typeof window === 'undefined' ? useEffect : useLayoutEffect;\n","import { useRef } from 'react';\nimport type { AnyObject } from 'yummies/types';\n\ntype UseValueHook = <TValue extends AnyObject>(\n  getValue: () => TValue,\n) => TValue;\n\n/**\n * This hook accept `getValue` function and returns it result.\n *\n * `getValue` _should_ executes **ONLY ONCE**.\n * But in HMR it can executes more than 1 time\n *\n * Previously, the dev mode used `useMemo(getValue, [])` for better HMR support,\n * but React 19 may \"forget\" memoized values and recompute `useMemo` on re-render.\n * This caused an infinite loop: new VM instance → `attach()` modifies MobX\n * observables → `observer` re-renders → `useMemo` recomputes → new VM → repeat.\n * Using `useRef` is guaranteed to be stable across re-renders, breaking the cycle.\n *\n * @example\n * ```\n * const num = useValue(() => 1); // 1\n * ```\n */\nexport const useValue: UseValueHook = (getValue) => {\n  const valueRef = useRef<AnyObject | null>(null);\n\n  if (!valueRef.current) {\n    valueRef.current = getValue();\n  }\n\n  return valueRef.current as ReturnType<typeof getValue>;\n};\n","import type {\n  AnyViewModel,\n  AnyViewModelSimple,\n  ViewModelCreateConfig,\n  ViewModelSimple,\n  ViewModelsConfig,\n} from 'mobx-view-model';\nimport { viewModelsConfig } from 'mobx-view-model';\nimport { use, useContext, useId, useRef } from 'react';\nimport { flushPendingReactions } from 'yummies/mobx';\nimport type { AnyObject, Class, IsPartial, Maybe } from 'yummies/types';\nimport { isViewModelClass } from 'mobx-view-model';\nimport {\n  ActiveViewModelContext,\n  ViewModelsContext,\n} from '../contexts/index.js';\nimport { useIsomorphicLayoutEffect, useValue } from '../lib/hooks/index.js';\n\nexport interface UseCreateViewModelConfig<TViewModel extends AnyViewModel>\n  extends Pick<\n    ViewModelCreateConfig<TViewModel>,\n    'vmConfig' | 'ctx' | 'component' | 'anchors' | 'props'\n  > {\n  /**\n   * Unique identifier for the view\n   *\n   * [**Documentation**](https://js2me.github.io/mobx-view-model/react/api/with-view-model.html#id)\n   */\n  id?: Maybe<string>;\n\n  /**\n   * Function to generate an identifier for the view model\n   *\n   * [**Documentation**](https://js2me.github.io/mobx-view-model/react/api/with-view-model.html#generateid)\n   */\n  generateId?: ViewModelsConfig<TViewModel>['generateId'];\n\n  /**\n   * Function to create an instance of the VM class\n   *\n   * [**Documentation**](https://js2me.github.io/mobx-view-model/react/api/with-view-model.html#factory)\n   */\n  factory?: ViewModelsConfig<TViewModel>['factory'];\n}\n\n/**\n * Creates new instance of ViewModel\n *\n * [**Documentation**](https://js2me.github.io/mobx-view-model/react/api/use-create-view-model.html)\n */\nexport function useCreateViewModel<TViewModel extends AnyViewModel>(\n  VM: Class<TViewModel>,\n  ...args: IsPartial<TViewModel['payload']> extends true\n    ? [\n        payload?: TViewModel['payload'],\n        config?: UseCreateViewModelConfig<TViewModel>,\n      ]\n    : [\n        payload: TViewModel['payload'],\n        config?: UseCreateViewModelConfig<TViewModel>,\n      ]\n): TViewModel;\n\n/**\n * Creates new instance of ViewModelSimple\n *\n * [**Documentation**](https://js2me.github.io/mobx-view-model/react/api/use-create-view-model.html)\n */\nexport function useCreateViewModel<\n  TPayload extends AnyObject,\n  TViewModelSimple extends ViewModelSimple<TPayload>,\n>(\n  VM: Class<TViewModelSimple>,\n  ...args: IsPartial<TPayload> extends true\n    ? [payload?: TPayload]\n    : [payload: TPayload]\n): TViewModelSimple;\n\n/**\n * Creates new instance of ViewModelSimple\n *\n * [**Documentation**](https://js2me.github.io/mobx-view-model/react/api/use-create-view-model.html)\n */\nexport function useCreateViewModel<TViewModelSimple>(\n  VM: Class<TViewModelSimple>,\n): TViewModelSimple;\n\n/**\n * Creates new instance of ViewModel\n *\n * [**Documentation**](https://js2me.github.io/mobx-view-model/react/api/use-create-view-model.html)\n */\nexport function useCreateViewModel(\n  VM: Class<any>,\n  payload?: any,\n  config?: any,\n) {\n  if (isViewModelClass(VM)) {\n    // scenario for ViewModelBase\n    return useCreateViewModelBase(VM, payload, config);\n  }\n\n  // scenario for ViewModelSimple\n  return useCreateViewModelSimple(VM, payload);\n}\n\nconst useCreateViewModelBase = (\n  VM: Class<AnyViewModel>,\n  payload?: any,\n  config?: Maybe<UseCreateViewModelConfig<AnyViewModel>>,\n) => {\n  const viewModels = useContext(ViewModelsContext);\n  const parentViewModel = useContext(ActiveViewModelContext);\n  /** Last VM this hook instance attached in render; per-hook, not keyed by `instance.id`. */\n  const lastAttachedInstanceRef = useRef<AnyViewModel | null>(null);\n\n  const ctx = config?.ctx ?? {};\n\n  const useReactIds = config?.vmConfig?.useReactIds ?? viewModels?.vmConfig?.useReactIds ?? viewModelsConfig.useReactIds;\n  const renderId = useReactIds ? useId() : undefined;\n\n  const instance = useValue(() => {\n    const id =\n      viewModels?.generateViewModelId({\n        ...config,\n        ctx,\n        VM,\n        renderId,\n        parentViewModelId: parentViewModel?.id ?? null,\n      }) ??\n      config?.id ??\n      viewModelsConfig.generateId({\n        ...ctx,\n        renderId,\n      });\n\n    const instanceFromStore = viewModels?.get(id);\n\n    if (instanceFromStore) {\n      return instanceFromStore as AnyViewModel;\n    } else {\n      const configCreate: ViewModelCreateConfig<any> = {\n        ...config,\n        vmConfig: config?.vmConfig,\n        id,\n        parentViewModelId: parentViewModel?.id,\n        payload: payload ?? {},\n        VM,\n        viewModels,\n        parentViewModel,\n        ctx,\n      };\n\n      viewModels?.processCreateConfig(configCreate);\n\n      const instance: AnyViewModel =\n        config?.factory?.(configCreate) ??\n        viewModels?.createViewModel<any>(configCreate) ??\n        viewModelsConfig.factory(configCreate);\n\n      flushPendingReactions(viewModelsConfig.flushPendingReactions);\n\n      viewModels?.markToBeAttached(instance);\n\n      return instance;\n    }\n  });\n\n  useIsomorphicLayoutEffect(() => {\n    const id = instance.id;\n    const vm = instance;\n    if (viewModels) {\n      return () => {\n        void viewModels.detach(id);\n        if (lastAttachedInstanceRef.current === vm) {\n          lastAttachedInstanceRef.current = null;\n        }\n      };\n    }\n    return () => {\n      vm.unmount();\n      if (lastAttachedInstanceRef.current === vm) {\n        lastAttachedInstanceRef.current = null;\n      }\n    };\n  }, [instance]);\n\n  // Same render pass as attach (SSR + first client frame). `flushPendingMobxReactions` is\n  // required when the VM is created under mobx-react `observer`: nested `reaction()` otherwise\n  // runs after `mount()` in the same tick.\n  if (lastAttachedInstanceRef.current !== instance) {\n    if (viewModels) {\n      void viewModels.attach(instance);\n    } else {\n      void instance.mount();\n    }\n    lastAttachedInstanceRef.current = instance;\n  }\n\n  instance.setPayload(payload ?? {});\n\n  const suspendUntil =\n    config?.vmConfig?.suspendUntil ??\n    viewModels?.vmConfig?.suspendUntil ??\n    viewModelsConfig.suspendUntil;\n\n  if (suspendUntil != null) {\n    const usable = suspendUntil(instance);\n    if (usable) {\n      use(usable);\n    }\n  }\n\n  return instance;\n};\n\nconst useCreateViewModelSimple = (\n  VM: Class<AnyViewModelSimple>,\n  payload?: any,\n) => {\n  const viewModels = useContext(ViewModelsContext);\n  const parentViewModel = useContext(ActiveViewModelContext);\n  /** Last VM this hook instance attached in render; per-hook, not keyed by `instance.id`. */\n  const lastAttachedInstanceRef = useRef<AnyViewModelSimple | null>(null);\n\n  const instance = useValue(() => {\n    const instance = new VM();\n\n    instance.parentViewModel =\n      parentViewModel as unknown as (typeof instance)['parentViewModel'];\n\n    flushPendingReactions(viewModelsConfig.flushPendingReactions);\n\n    viewModels?.markToBeAttached(instance);\n\n    return instance;\n  });\n\n  useIsomorphicLayoutEffect(() => {\n    const id = instance.id;\n    const vm = instance;\n    if (viewModels) {\n      return () => {\n        void viewModels.detach(id);\n        if (lastAttachedInstanceRef.current === vm) {\n          lastAttachedInstanceRef.current = null;\n        }\n      };\n    }\n    return () => {\n      vm.unmount?.();\n      if (lastAttachedInstanceRef.current === vm) {\n        lastAttachedInstanceRef.current = null;\n      }\n    };\n  }, [instance]);\n\n  if (lastAttachedInstanceRef.current !== instance) {\n    if (viewModels) {\n      void viewModels.attach(instance);\n    } else {\n      void instance.mount?.();\n    }\n    lastAttachedInstanceRef.current = instance;\n  }\n\n  instance.setPayload?.(payload);\n\n  const suspendUntil =\n    viewModels?.vmConfig?.suspendUntil ?? viewModelsConfig.suspendUntil;\n\n  if (suspendUntil != null) {\n    const usable = suspendUntil(instance);\n    if (usable) {\n      use(usable);\n    }\n  }\n\n  return instance;\n};\n","import type {\n  AnyViewModel,\n  AnyViewModelSimple,\n  ViewModelLookup,\n} from 'mobx-view-model';\nimport { useContext, useRef } from 'react';\nimport type { AnyObject } from 'yummies/types';\nimport {\n  ActiveViewModelContext,\n  ViewModelsContext,\n} from '../contexts/index.js';\n\n/**\n * Get access to **already created** instance of ViewModel\n *\n * [**Documentation**](https://js2me.github.io/mobx-view-model/react/api/use-view-model.html)\n */\nexport const useViewModel = <T extends AnyViewModel | AnyViewModelSimple>(\n  vmLookup?: ViewModelLookup<T>,\n): T => {\n  const viewModels = useContext(ViewModelsContext);\n  const activeViewModel = useContext(ActiveViewModelContext);\n  const model = viewModels?.get(vmLookup);\n\n  // This ref is needed only for development\n  // support better HMR in vite\n  let devModeModelRef = undefined as unknown as React.MutableRefObject<any>;\n\n  if (process.env.NODE_ENV !== 'production') {\n    devModeModelRef = useRef<any>(undefined);\n  }\n\n  if (vmLookup == null || !viewModels) {\n    if (process.env.NODE_ENV !== 'production' && !viewModels) {\n      console.warn(\n        'Warning #1: ViewModelStore not found.\\n',\n        'Unable to get access to view model by id or class name without using ViewModelStore\\n',\n        'Last active view model will be returned.\\n',\n        'More info: https://js2me.github.io/mobx-view-model/warnings/1',\n      );\n    }\n\n    if (!activeViewModel) {\n      if (process.env.NODE_ENV !== 'production') {\n        throw new Error(\n          'Error #1: Active ViewModel not found.\\n' +\n            'This happened because \"vmLookup\" for hook \"useViewModel\" is not provided and hook trying to lookup active view model using ActiveViewModelContext which works only with using \"withViewModel\" HOC.\\n' +\n            'Please provide \"vmLookup\" (first argument for \"useViewModel\" hook) or use \"withViewModel\" HOC.\\n' +\n            'More info: https://js2me.github.io/mobx-view-model/errors/1',\n        );\n      }\n      throw new Error(\n        'Error #1: https://js2me.github.io/mobx-view-model/errors/1',\n      );\n    }\n\n    if (process.env.NODE_ENV !== 'production') {\n      devModeModelRef.current = activeViewModel;\n    }\n\n    return activeViewModel as unknown as T;\n  }\n\n  if (!model) {\n    let displayName: string = '';\n\n    if (typeof vmLookup === 'string') {\n      displayName = vmLookup;\n    } else if ('name' in vmLookup) {\n      displayName = vmLookup.name;\n    } else {\n      displayName = (vmLookup as AnyObject).displayName;\n    }\n\n    if (process.env.NODE_ENV !== 'production') {\n      if (devModeModelRef.current) {\n        return devModeModelRef.current;\n      } else {\n        throw new Error(\n          `Error #2: View model not found for ${displayName}.\\n` +\n            'This happened because your \"vmLookup\" provided for hook \"useViewModel\" is not found in \"ViewModelStore\".\\n' +\n            'More info: https://js2me.github.io/mobx-view-model/errors/2',\n        );\n      }\n    } else {\n      throw new Error(\n        'Error #2: https://js2me.github.io/mobx-view-model/errors/2',\n      );\n    }\n  }\n\n  if (process.env.NODE_ENV !== 'production') {\n    devModeModelRef.current = activeViewModel;\n  }\n\n  return model;\n};\n","import { observer } from 'mobx-react-lite';\nimport type { AnyViewModel } from 'mobx-view-model';\nimport type { Class, IsPartial } from 'yummies/types';\nimport {\n  type UseCreateViewModelConfig,\n  useCreateViewModel,\n} from '../hooks/index.js';\nimport { RReactNode } from \"../lib/react-types.js\";\n\nexport type OnlyViewModelProps<TViewModel extends AnyViewModel> = {\n  model: Class<TViewModel>;\n  children?: RReactNode | ((model: TViewModel) => RReactNode);\n} & (IsPartial<TViewModel['payload']> extends true\n  ? {\n      payload?: TViewModel['payload'];\n      config?: UseCreateViewModelConfig<TViewModel>;\n    }\n  : {\n      payload: TViewModel['payload'];\n      config?: UseCreateViewModelConfig<TViewModel>;\n    });\n\nexport const OnlyViewModel = observer(\n  <TViewModel extends AnyViewModel>({\n    model,\n    config,\n    payload,\n    children,\n  }: OnlyViewModelProps<TViewModel>) => {\n    const vm = useCreateViewModel(model, payload, config);\n\n    if (!vm.isMounted) {\n      return null;\n    }\n\n    if (typeof children === 'function') {\n      return children(vm);\n    }\n    return <>{children}</>;\n  },\n);\n","import type { ViewModelStore } from 'mobx-view-model';\nimport { ViewModelsContext } from '../contexts/index.js';\n \nimport { RComponentType, RReactNode } from \"../lib/react-types.js\";\n\nexport const ViewModelsProvider =\n  ViewModelsContext.Provider as unknown as RComponentType<{\n    value: ViewModelStore;\n    children?: RReactNode;\n  }>;\n","import { observer } from 'mobx-react-lite';\nimport type {\n  AnyViewModel,\n  AnyViewModelSimple,\n  ViewModel,\n  ViewModelSimple,\n  ViewModelStore,\n} from 'mobx-view-model';\nimport { viewModelsConfig } from 'mobx-view-model';\nimport { forwardRef, useContext } from 'react';\nimport type {\n  AnyObject,\n  Class,\n  Defined,\n  EmptyObject,\n  HasKey,\n  IsAny,\n  IsPartial,\n  IsUnknown,\n  Maybe,\n} from 'yummies/types';\nimport { ActiveViewModelProvider } from '../components/index.js';\nimport { ViewModelsContext } from '../contexts/index.js';\nimport {\n  type UseCreateViewModelConfig,\n  useCreateViewModel,\n} from '../hooks/index.js';\nimport {\n  RComponentClass,\n  RComponentType,\n  RForwardedRef,\n  RLegacyRef,\n  RReactNode,\n} from '../lib/react-types.js';\n\nexport type FixedComponentType<P extends AnyObject = {}> =\n  /**\n   * Fixes typings loss with use `withViewModel` with inline function component\n   */\n  ((props: P) => RReactNode) | RComponentClass<P>;\n\ndeclare const process: { env: { NODE_ENV?: string } };\n\nexport type ExtractReactRef<T> = Defined<T> extends RForwardedRef<\n  infer TForwardedRef\n>\n  ? TForwardedRef\n  : Defined<T> extends RLegacyRef<infer TRef>\n    ? TRef\n    : T;\n\n/**\n * This type is needed to declare prop types for your View component wrapped into `withViewModel` HOC\n *\n * Use second generic type add typings for `forwardedRef` prop\n */\nexport type ViewModelProps<\n  VM,\n  TForwardedRef = unknown,\n> = IsAny<TForwardedRef> extends true\n  ? { model: VM; forwardedRef?: RForwardedRef<TForwardedRef> }\n  : IsUnknown<TForwardedRef> extends true\n    ? { model: VM }\n    : { model: VM; forwardedRef?: RForwardedRef<TForwardedRef> };\n\nexport type ViewModelPropsChargedProps<\n  TComponentOriginProps extends AnyObject,\n  TViewModel,\n  TForwardedRef = unknown,\n> = HasKey<TComponentOriginProps, 'ref'> extends true\n  ? Omit<TComponentOriginProps, 'ref'> &\n      ViewModelProps<TViewModel, ExtractReactRef<TComponentOriginProps['ref']>>\n  : HasKey<TComponentOriginProps, 'forwardedRef'> extends true\n    ? TComponentOriginProps\n    : TComponentOriginProps &\n        ViewModelProps<\n          TViewModel,\n          IsUnknown<TForwardedRef> extends true ? any : TForwardedRef\n        >;\n\ntype VMInputPayloadPropObj<VM> = VM extends ViewModel<infer TPayload, any>\n  ? TPayload extends EmptyObject\n    ? {}\n    : IsPartial<TPayload> extends true\n      ? {\n          payload?: TPayload;\n        }\n      : {\n          payload: TPayload;\n        }\n  : VM extends ViewModelSimple<infer TPayload>\n    ? TPayload extends EmptyObject\n      ? {}\n      : IsPartial<TPayload> extends true\n        ? {\n            payload?: TPayload;\n          }\n        : {\n            payload: TPayload;\n          }\n    : {};\n\nexport type WithViewModelReactHook = (\n  allProps: AnyObject,\n  ctx: AnyObject,\n  viewModels: Maybe<ViewModelStore>,\n  ref?: any,\n) => void;\n\nexport interface ViewModelHocConfig<VM extends AnyViewModel>\n  extends Omit<UseCreateViewModelConfig<VM>, 'component' | 'componentProps'> {\n  /**\n   * Component to render if the view model initialization takes too long\n   *\n   * [**Documentation**](https://js2me.github.io/mobx-view-model/react/api/with-view-model.html#fallback)\n   */\n  fallback?: RComponentType;\n\n  /**\n   * Function to invoke additional React hooks in the resulting component\n   *\n   * [**Documentation**](https://js2me.github.io/mobx-view-model/react/api/with-view-model.html#reacthook)\n   */\n  reactHook?: WithViewModelReactHook;\n\n  /**\n   * Function that should return the payload for the VM\n   * by default, it is - (props) => props.payload\n   *\n   * [**Documentation**](https://js2me.github.io/mobx-view-model/react/api/with-view-model.html#getpayload)\n   */\n  getPayload?: (allProps: any) => any;\n\n  /**\n   * Forwards ref using `RforwardRef` but pass it to props as prop `ref`\n   *\n   * [**Documentation**](https://js2me.github.io/mobx-view-model/react/api/with-view-model.html#forwardref)\n   */\n  forwardRef?: boolean;\n\n  /**\n   * Additional component anchors for the same VM instance.\n   * useViewModel(AnchorComponent) will return this VM when the connected component is mounted.\n   */\n  anchors?: RComponentType[];\n}\n\nexport interface ViewModelSimpleHocConfig<_VM> {\n  /**\n   * Component to render if the view model initialization takes too long\n   *\n   * [**Documentation**](https://js2me.github.io/mobx-view-model/react/api/with-view-model.html#fallback)\n   */\n  fallback?: RComponentType;\n\n  /**\n   * Function to invoke additional React hooks in the resulting component\n   *\n   * [**Documentation**](https://js2me.github.io/mobx-view-model/react/api/with-view-model.html#reacthook)\n   */\n  reactHook?: WithViewModelReactHook;\n\n  /**\n   * Function that should return the payload for the VM\n   * by default, it is - (props) => props.payload\n   *\n   * [**Documentation**](https://js2me.github.io/mobx-view-model/react/api/with-view-model.html#getpayload)\n   */\n  getPayload?: (allProps: any) => any;\n\n  /**\n   * Forwards ref using `RforwardRef` but pass it to props as prop `ref`\n   *\n   * [**Documentation**](https://js2me.github.io/mobx-view-model/react/api/with-view-model.html#forwardref)\n   */\n  forwardRef?: boolean;\n\n  /**\n   * Additional component anchors for the same VM instance.\n   * useViewModel(AnchorComponent) will return this VM when the connected component is mounted.\n   */\n  anchors?: RComponentType[];\n}\n\nexport type AllViewModelPropsKeys = keyof Required<ViewModelProps<any, any>>;\n\nexport type VMComponentProps<\n  TViewModel,\n  TComponentOriginProps extends AnyObject = AnyObject,\n  TForwardedRef = unknown,\n> = Omit<TComponentOriginProps, AllViewModelPropsKeys> &\n  VMInputPayloadPropObj<TViewModel> &\n  (HasKey<TComponentOriginProps, 'ref'> extends true\n    ? {}\n    : HasKey<TComponentOriginProps, 'forwardedRef'> extends true\n      ? Required<TComponentOriginProps>['forwardedRef'] extends RLegacyRef<any>\n        ? {\n            ref?: TComponentOriginProps['forwardedRef'];\n          }\n        : Pick<TComponentOriginProps, 'forwardedRef'>\n      : IsUnknown<TForwardedRef> extends true\n        ? {}\n        : { ref?: RLegacyRef<TForwardedRef> });\n\nexport interface VMComponent<\n  TViewModel,\n  TComponentOriginProps extends AnyObject = AnyObject,\n  TForwardedRef = unknown,\n> {\n  (\n    props: VMComponentProps<TViewModel, TComponentOriginProps, TForwardedRef>,\n  ): RReactNode;\n\n  /**\n   * Registers an anchor component for the same VM instance.\n   * `useViewModel(anchor)` will return this VM when the connected component is mounted.\n   * Anchors are stored in config.anchors and passed to the store's link() during processCreateConfig.\n   * @param anchor - React component to use as lookup key for useViewModel\n   */\n  connect(\n    anchor: RComponentType<any>,\n  ): VMComponent<TViewModel, TComponentOriginProps, TForwardedRef>;\n}\n\n/**\n * A Higher-Order Component that connects React components to their ViewModels, providing seamless MobX integration.\n *\n * [**Documentation**](https://js2me.github.io/mobx-view-model/react/api/with-view-model.html)\n */\nexport function withViewModel<\n  TViewModel extends AnyViewModel,\n  TComponentOriginProps extends AnyObject = AnyObject,\n  TForwardedRef = unknown,\n>(\n  model: Class<TViewModel>,\n  component: RComponentType<\n    ViewModelPropsChargedProps<TComponentOriginProps, TViewModel, TForwardedRef>\n  >,\n  config?: ViewModelHocConfig<TViewModel>,\n): VMComponent<TViewModel, TComponentOriginProps, TForwardedRef>;\n\n/**\n * A Higher-Order Component that connects React components to their ViewModels, providing seamless MobX integration.\n *\n * [**Documentation**](https://js2me.github.io/mobx-view-model/react/api/with-view-model.html)\n */\nexport function withViewModel<\n  TViewModel extends AnyViewModel,\n  TForwardedRef = unknown,\n>(\n  model: Class<TViewModel>,\n  config?: ViewModelHocConfig<TViewModel>,\n): <TComponentOriginProps extends AnyObject = ViewModelProps<TViewModel>>(\n  Component?: RComponentType<\n    ViewModelPropsChargedProps<TComponentOriginProps, TViewModel, TForwardedRef>\n  >,\n) => VMComponent<TViewModel, TComponentOriginProps, TForwardedRef>;\n\n/**\n * A Higher-Order Component that connects React components to their ViewModels, providing seamless MobX integration.\n *\n * [**Documentation**](https://js2me.github.io/mobx-view-model/react/api/with-view-model.html)\n */\nexport function withViewModel<TViewModel, TForwardedRef = unknown>(\n  model: Class<TViewModel>,\n  config?: ViewModelSimpleHocConfig<TViewModel>,\n): <TComponentOriginProps extends AnyObject = ViewModelProps<TViewModel>>(\n  Component?: FixedComponentType<\n    ViewModelPropsChargedProps<TComponentOriginProps, TViewModel, TForwardedRef>\n  >,\n) => VMComponent<TViewModel, TComponentOriginProps, TForwardedRef>;\n\n/**\n * A Higher-Order Component that connects React components to their ViewModels, providing seamless MobX integration.\n *\n * [**Documentation**](https://js2me.github.io/mobx-view-model/react/api/with-view-model.html)\n */\nexport function withViewModel<\n  TViewModel extends AnyViewModelSimple,\n  TComponentOriginProps extends AnyObject = AnyObject,\n  TForwardedRef = unknown,\n>(\n  model: Class<TViewModel>,\n  component: FixedComponentType<\n    ViewModelPropsChargedProps<TComponentOriginProps, TViewModel, TForwardedRef>\n  >,\n  config?: ViewModelSimpleHocConfig<TViewModel>,\n): VMComponent<TViewModel, TComponentOriginProps, TForwardedRef>;\n\n/**\n * A Higher-Order Component that connects React components to their ViewModels, providing seamless MobX integration.\n *\n * [**Documentation**](https://js2me.github.io/mobx-view-model/react/api/with-view-model.html)\n */\nexport function withViewModel<\n  TViewModel,\n  TComponentOriginProps extends AnyObject = ViewModelProps<TViewModel>,\n  TForwardedRef = unknown,\n>(\n  model: Class<TViewModel>,\n  component: FixedComponentType<\n    ViewModelPropsChargedProps<TComponentOriginProps, TViewModel, TForwardedRef>\n  >,\n  config?: ViewModelSimpleHocConfig<TViewModel>,\n): VMComponent<TViewModel, TComponentOriginProps, TForwardedRef>;\n\n/**\n * Creates new instance of ViewModel\n *\n * [**Documentation**](https://js2me.github.io/mobx-view-model/react/api/with-view-model.html)\n */\nexport function withViewModel(\n  VM: Class<any>,\n  configOrComponent?: any,\n  configOrNothing?: any,\n): any {\n  if (\n    typeof configOrComponent === 'function' ||\n    (configOrComponent && configOrComponent.$$typeof !== undefined)\n  ) {\n    const config = configOrNothing ?? {};\n    return withViewModelWrapper(\n      VM,\n      {\n        ...config,\n        ctx: {\n          VM,\n          generateId: config.generateId,\n          ...config.ctx,\n        },\n      },\n      configOrComponent,\n    );\n  } else {\n    const config = configOrComponent ?? {};\n    const finalConfig = {\n      ...config,\n      ctx: {\n        VM,\n        generateId: config.generateId,\n        ...config.ctx,\n      },\n    };\n\n    return (Component: RComponentType<any>) =>\n      withViewModelWrapper(VM, finalConfig, Component);\n  }\n}\n\nconst REACT_MEMO_SYMBOL = Symbol.for('react.memo');\n\nconst withViewModelWrapper = (\n  VM: Class<any>,\n  config: ViewModelHocConfig<any>,\n  OriginalComponent?: RComponentType<any>,\n) => {\n  const processViewComponent =\n    config.vmConfig?.processViewComponent ??\n    viewModelsConfig.processViewComponent;\n\n  const wrapViewsInObserver =\n    config.vmConfig?.wrapViewsInObserver ??\n    viewModelsConfig.wrapViewsInObserver;\n\n  let Component =\n    processViewComponent?.(OriginalComponent, VM, config) ?? OriginalComponent;\n\n\n  if (process.env.NODE_ENV !== 'production' && Component) {\n    Component.displayName = `ConnectedViewModel(${VM.name}->${Component.name || 'View'})`;\n  }\n\n  if (\n    wrapViewsInObserver &&\n    Component &&\n    (Component as any).$$typeof !== REACT_MEMO_SYMBOL\n  ) {\n    // `observer` плохо выводит типы для union (FunctionComponent | ComponentClass),\n    // поэтому здесь используем безопасный runtime-cast, чтобы не ломать `tsc`.\n    Component = observer(Component as any) as any;\n  }\n\n  const reactHook = config.reactHook ?? viewModelsConfig.reactHook;\n  const getPayload = config.getPayload;\n  const FallbackComponent =\n    config.fallback ?? viewModelsConfig.fallbackComponent;\n\n  const RawComponent = (allProps: any, ref: any) => {\n    const viewModels = useContext(ViewModelsContext);\n\n    reactHook?.(allProps, config.ctx!, viewModels, ref);\n\n    const { payload: rawPayload, ...componentProps } = allProps;\n    const payload = getPayload?.(allProps) ?? rawPayload;\n\n    if (config.forwardRef && !('forwardedRef' in componentProps)) {\n      componentProps.forwardedRef = ref;\n    }\n\n    const model = useCreateViewModel(VM, payload, {\n      ...config,\n      props: componentProps,\n    }) as unknown as AnyViewModel | AnyViewModelSimple;\n\n    const isRenderAllowedByStore =\n      !viewModels || viewModels.isAbleToRenderView(model.id);\n\n    // This condition is works for AnyViewModelSimple too\n    // All other variants will be bad for performance\n    const isRenderAllowed =\n      isRenderAllowedByStore && (model as AnyViewModel).isMounted !== false;\n\n    if (isRenderAllowed) {\n      return (\n        <ActiveViewModelProvider value={model}>\n          {Component && <Component {...componentProps} model={model} />}\n        </ActiveViewModelProvider>\n      );\n    }\n\n    return (\n      FallbackComponent && <FallbackComponent {...allProps} payload={payload} />\n    );\n  };\n\n  let ConnectedViewModel = RawComponent;\n\n  if (config.forwardRef) {\n    ConnectedViewModel = forwardRef(ConnectedViewModel) as any;\n  }\n\n  ConnectedViewModel = observer(ConnectedViewModel);\n\n  if (process.env.NODE_ENV !== 'production') {\n    (ConnectedViewModel as RComponentType).displayName =\n      `ConnectedViewModel(${VM.name}->Observer)`;\n  }\n\n  // There is no problem to just assign it here to config\n  // This property is needed to pass in `useCreateViewModel()` hook\n  // @ts-expect-error\n  config.component = ConnectedViewModel as unknown as VMComponent<\n    AnyViewModel,\n    any\n  >;\n\n  config.anchors ??= [];\n\n  const anchors = config.anchors;\n\n  const ConnectedWithConnect =\n    ConnectedViewModel as typeof ConnectedViewModel & {\n      connect: (anchor: RComponentType) => typeof ConnectedWithConnect;\n    };\n  /**\n   * Registers an anchor component for the same VM instance.\n   * Adds the anchor to config.anchors — useViewModel(anchor) will return this VM when mounted.\n   */\n  ConnectedWithConnect.connect = (anchor: RComponentType) => {\n    if (!anchors.includes(anchor)) {\n      anchors.push(anchor);\n    }\n    return ConnectedWithConnect;\n  };\n\n  return ConnectedWithConnect;\n};\n","import type {\n  AnyViewModel,\n  ViewModelSimple,\n} from 'mobx-view-model';\nimport type { AnyObject, Class, EmptyObject, HasKey, IsUnknown } from 'yummies/types';\nimport {\n  RComponentType,\n  RForwardedRef,\n  RLegacyRef,\n  RReactNode,\n} from '../lib/react-types.js';\nimport {\n  type AllViewModelPropsKeys,\n  type FixedComponentType,\n  type ViewModelHocConfig,\n  type ViewModelPropsChargedProps,\n  type ViewModelSimpleHocConfig,\n  withViewModel,\n} from './with-view-model.js';\n\ntype InferPropsViewModelPayload<TViewModel> = TViewModel extends AnyViewModel\n  ? TViewModel['payload']\n  : TViewModel extends {\n        setPayload(payload: infer TPayload extends AnyObject): any;\n      }\n    ? TPayload\n    : TViewModel extends ViewModelSimple<infer TPayload extends AnyObject>\n      ? TPayload\n      : EmptyObject;\n\ntype ExtractVMPayload<VM> = InferPropsViewModelPayload<VM>;\n\nexport type PropsVMComponentProps<\n  TViewModel,\n  TComponentOriginProps extends AnyObject = ExtractVMPayload<TViewModel>,\n  TForwardedRef = unknown,\n> = ExtractVMPayload<TViewModel> &\n  Omit<\n    TComponentOriginProps,\n    AllViewModelPropsKeys | keyof ExtractVMPayload<TViewModel>\n  > &\n  (HasKey<TComponentOriginProps, 'ref'> extends true\n    ? {}\n    : HasKey<TComponentOriginProps, 'forwardedRef'> extends true\n      ? Required<TComponentOriginProps>['forwardedRef'] extends RForwardedRef<\n          infer R\n        >\n        ? {\n            ref?: RLegacyRef<R>;\n          }\n        : Required<TComponentOriginProps>['forwardedRef'] extends RLegacyRef<any>\n          ? {\n              ref?: TComponentOriginProps['forwardedRef'];\n            }\n          : Pick<TComponentOriginProps, 'forwardedRef'>\n      : IsUnknown<TForwardedRef> extends true\n        ? {}\n        : { ref?: RLegacyRef<TForwardedRef> });\n\nexport interface PropsVMComponent<\n  TViewModel,\n  TComponentOriginProps extends AnyObject = ExtractVMPayload<TViewModel>,\n  TForwardedRef = unknown,\n> {\n  (\n    props: PropsVMComponentProps<TViewModel, TComponentOriginProps, TForwardedRef>,\n  ): RReactNode;\n\n  connect(\n    anchor: RComponentType<any>,\n  ): PropsVMComponent<TViewModel, TComponentOriginProps, TForwardedRef>;\n}\n\nexport type PropsViewModelHocConfig<VM extends AnyViewModel> = Omit<\n  ViewModelHocConfig<VM>,\n  'getPayload'\n>;\n\nexport type PropsViewModelSimpleHocConfig<VM> = Omit<\n  ViewModelSimpleHocConfig<VM>,\n  'getPayload'\n>;\n\nconst allPropsAsPayload = (props: AnyObject) => props;\n\n/**\n * Like `withViewModel`, but treats all component props as the ViewModel payload.\n * The resulting component does not require a separate `payload` prop.\n *\n * [**Documentation**](https://js2me.github.io/mobx-view-model/react/api/with-props-view-model.html)\n */\nexport function withPropsViewModel<\n  TViewModel,\n  TComponentOriginProps extends AnyObject = InferPropsViewModelPayload<TViewModel>,\n  TForwardedRef = unknown,\n>(\n  model: Class<TViewModel>,\n  component: FixedComponentType<\n    ViewModelPropsChargedProps<TComponentOriginProps, TViewModel, TForwardedRef>\n  >,\n  config?: TViewModel extends AnyViewModel\n    ? PropsViewModelHocConfig<TViewModel>\n    : PropsViewModelSimpleHocConfig<TViewModel>,\n): PropsVMComponent<TViewModel, TComponentOriginProps, TForwardedRef> {\n  return withViewModel(model, component, {\n    ...config,\n    getPayload: allPropsAsPayload,\n  }) as unknown as PropsVMComponent<TViewModel, TComponentOriginProps, TForwardedRef>;\n}\n"],"x_google_ignoreList":[3],"mappings":";;;;;;;AAIA,IAAa,0BAAA,GAAA,MAAA,eAEX,IAAW;AAEb,IAAA,QAAA,IAAA,aAA6B,cAC3B,uBAAuB,cAAc;;;;;;;;ACDvC,IAAa,qBAAA,GAAA,MAAA,eACX,IACF;;;;;;;;ACDA,IAAa,0BACX,uBAAuB;ACUlBA,KAAAA,SAAS,SACNA,KAAAA,SAAS,SACVA,KAAAA,SAAS;;AA4UlB,IAAI,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCtC,SAAS,sBAAsB,WAAW,iCAAiC;CAC1E,MAAM,MAAA,GAAA,KAAA,iBAAqB;CAC3B,IAAI,CAAC,YAAY,GAAG,sBAAsB,GAAG,iBAAiB,WAAW,GAAG;CAC5E,MAAM,eAAe,GAAG;CACxB,GAAG,UAAU;CACb,IAAI;EACH,GAAG,qBAAqB;EACxB,MAAM,QAAQ,GAAG;EACjB,IAAI,aAAa;EACjB,OAAO,MAAM,SAAS,GAAG;GACxB,IAAI,EAAE,eAAe,UAAU;IAC9B,MAAM,OAAO,CAAC;IACd;GACD;GACA,MAAM,QAAQ,MAAM,OAAO,CAA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