You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
38 KiB
1 lines
38 KiB
{"version":3,"file":"immer.umd.js","sources":["../src/common.js","../src/patches.js","../src/es5.js","../src/proxy.js","../src/immer.js","../src/index.js"],"sourcesContent":["export const NOTHING =\n typeof Symbol !== \"undefined\"\n ? Symbol(\"immer-nothing\")\n : {[\"immer-nothing\"]: true}\n\nexport const DRAFT_STATE =\n typeof Symbol !== \"undefined\" ? Symbol(\"immer-state\") : \"__$immer_state\"\n\nexport function isDraft(value) {\n return !!value && !!value[DRAFT_STATE]\n}\n\nexport function isDraftable(value) {\n if (!value) return false\n if (typeof value !== \"object\") return false\n if (Array.isArray(value)) return true\n const proto = Object.getPrototypeOf(value)\n return proto === null || proto === Object.prototype\n}\n\nexport function original(value) {\n if (value && value[DRAFT_STATE]) {\n return value[DRAFT_STATE].base\n }\n // otherwise return undefined\n}\n\nexport const assign =\n Object.assign ||\n function assign(target, value) {\n for (let key in value) {\n if (has(value, key)) {\n target[key] = value[key]\n }\n }\n return target\n }\n\nexport function shallowCopy(value) {\n if (Array.isArray(value)) return value.slice()\n const target = value.__proto__ === undefined ? Object.create(null) : {}\n return assign(target, value)\n}\n\nexport function each(value, cb) {\n if (Array.isArray(value)) {\n for (let i = 0; i < value.length; i++) cb(i, value[i], value)\n } else {\n for (let key in value) cb(key, value[key], value)\n }\n}\n\nexport function has(thing, prop) {\n return Object.prototype.hasOwnProperty.call(thing, prop)\n}\n\nexport function is(x, y) {\n // From: https://github.com/facebook/fbjs/blob/c69904a511b900266935168223063dd8772dfc40/packages/fbjs/src/core/shallowEqual.js\n if (x === y) {\n return x !== 0 || 1 / x === 1 / y\n } else {\n return x !== x && y !== y\n }\n}\n","import {each} from \"./common\"\n\nexport function generatePatches(state, basePath, patches, inversePatches) {\n Array.isArray(state.base)\n ? generateArrayPatches(state, basePath, patches, inversePatches)\n : generateObjectPatches(state, basePath, patches, inversePatches)\n}\n\nexport function generateArrayPatches(state, basePath, patches, inversePatches) {\n const {base, copy, assigned} = state\n const minLength = Math.min(base.length, copy.length)\n\n // Look for replaced indices.\n for (let i = 0; i < minLength; i++) {\n if (assigned[i] && base[i] !== copy[i]) {\n const path = basePath.concat(i)\n patches.push({op: \"replace\", path, value: copy[i]})\n inversePatches.push({op: \"replace\", path, value: base[i]})\n }\n }\n\n // Did the array expand?\n if (minLength < copy.length) {\n for (let i = minLength; i < copy.length; i++) {\n patches.push({\n op: \"add\",\n path: basePath.concat(i),\n value: copy[i]\n })\n }\n inversePatches.push({\n op: \"replace\",\n path: basePath.concat(\"length\"),\n value: base.length\n })\n }\n\n // ...or did it shrink?\n else if (minLength < base.length) {\n patches.push({\n op: \"replace\",\n path: basePath.concat(\"length\"),\n value: copy.length\n })\n for (let i = minLength; i < base.length; i++) {\n inversePatches.push({\n op: \"add\",\n path: basePath.concat(i),\n value: base[i]\n })\n }\n }\n}\n\nfunction generateObjectPatches(state, basePath, patches, inversePatches) {\n const {base, copy} = state\n each(state.assigned, (key, assignedValue) => {\n const origValue = base[key]\n const value = copy[key]\n const op = !assignedValue ? \"remove\" : key in base ? \"replace\" : \"add\"\n if (origValue === base && op === \"replace\") return\n const path = basePath.concat(key)\n patches.push(op === \"remove\" ? {op, path} : {op, path, value})\n inversePatches.push(\n op === \"add\"\n ? {op: \"remove\", path}\n : op === \"remove\"\n ? {op: \"add\", path, value: origValue}\n : {op: \"replace\", path, value: origValue}\n )\n })\n}\n\nexport function applyPatches(draft, patches) {\n for (let i = 0; i < patches.length; i++) {\n const patch = patches[i]\n const {path} = patch\n if (path.length === 0 && patch.op === \"replace\") {\n draft = patch.value\n } else {\n let base = draft\n for (let i = 0; i < path.length - 1; i++) {\n base = base[path[i]]\n if (!base || typeof base !== \"object\")\n throw new Error(\"Cannot apply patch, path doesn't resolve: \" + path.join(\"/\")) // prettier-ignore\n }\n const key = path[path.length - 1]\n switch (patch.op) {\n case \"replace\":\n case \"add\":\n // TODO: add support is not extensive, it does not support insertion or `-` atm!\n base[key] = patch.value\n break\n case \"remove\":\n if (Array.isArray(base)) {\n if (key !== base.length - 1)\n throw new Error(`Only the last index of an array can be removed, index: ${key}, length: ${base.length}`) // prettier-ignore\n base.length -= 1\n } else {\n delete base[key]\n }\n break\n default:\n throw new Error(\"Unsupported patch operation: \" + patch.op)\n }\n }\n }\n return draft\n}\n","\"use strict\"\n// @ts-check\n\nimport {\n each,\n has,\n is,\n isDraft,\n isDraftable,\n shallowCopy,\n DRAFT_STATE\n} from \"./common\"\n\nconst descriptors = {}\n\n// For nested produce calls:\nexport const scopes = []\nexport const currentScope = () => scopes[scopes.length - 1]\n\nexport function willFinalize(result, baseDraft, needPatches) {\n const scope = currentScope()\n scope.forEach(state => (state.finalizing = true))\n if (result === undefined || result === baseDraft) {\n if (needPatches) markChangesRecursively(baseDraft)\n // This is faster when we don't care about which attributes changed.\n markChangesSweep(scope)\n }\n}\n\nexport function createDraft(base, parent) {\n let draft\n if (isDraft(base)) {\n const state = base[DRAFT_STATE]\n // Avoid creating new drafts when copying.\n state.finalizing = true\n draft = shallowCopy(state.draft)\n state.finalizing = false\n } else {\n draft = shallowCopy(base)\n }\n each(base, prop => {\n Object.defineProperty(draft, \"\" + prop, createPropertyProxy(\"\" + prop))\n })\n\n // See \"proxy.js\" for property documentation.\n const state = {\n scope: parent ? parent.scope : currentScope(),\n modified: false,\n finalizing: false, // es5 only\n finalized: false,\n assigned: {},\n parent,\n base,\n draft,\n copy: null,\n revoke,\n revoked: false // es5 only\n }\n\n createHiddenProperty(draft, DRAFT_STATE, state)\n state.scope.push(state)\n return draft\n}\n\nfunction revoke() {\n this.revoked = true\n}\n\nfunction source(state) {\n return state.copy || state.base\n}\n\nfunction get(state, prop) {\n assertUnrevoked(state)\n const value = source(state)[prop]\n // Drafts are only created for proxyable values that exist in the base state.\n if (!state.finalizing && value === state.base[prop] && isDraftable(value)) {\n prepareCopy(state)\n return (state.copy[prop] = createDraft(value, state))\n }\n return value\n}\n\nfunction set(state, prop, value) {\n assertUnrevoked(state)\n state.assigned[prop] = true\n if (!state.modified) {\n if (is(source(state)[prop], value)) return\n markChanged(state)\n prepareCopy(state)\n }\n state.copy[prop] = value\n}\n\nfunction markChanged(state) {\n if (!state.modified) {\n state.modified = true\n if (state.parent) markChanged(state.parent)\n }\n}\n\nfunction prepareCopy(state) {\n if (!state.copy) state.copy = shallowCopy(state.base)\n}\n\nfunction createPropertyProxy(prop) {\n return (\n descriptors[prop] ||\n (descriptors[prop] = {\n configurable: true,\n enumerable: true,\n get() {\n return get(this[DRAFT_STATE], prop)\n },\n set(value) {\n set(this[DRAFT_STATE], prop, value)\n }\n })\n )\n}\n\nfunction assertUnrevoked(state) {\n if (state.revoked === true)\n throw new Error(\n \"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? \" +\n JSON.stringify(state.copy || state.base)\n )\n}\n\n// This looks expensive, but only proxies are visited, and only objects without known changes are scanned.\nfunction markChangesSweep(scope) {\n // The natural order of drafts in the `scope` array is based on when they\n // were accessed. By processing drafts in reverse natural order, we have a\n // better chance of processing leaf nodes first. When a leaf node is known to\n // have changed, we can avoid any traversal of its ancestor nodes.\n for (let i = scope.length - 1; i >= 0; i--) {\n const state = scope[i]\n if (state.modified === false) {\n if (Array.isArray(state.base)) {\n if (hasArrayChanges(state)) markChanged(state)\n } else if (hasObjectChanges(state)) markChanged(state)\n }\n }\n}\n\nfunction markChangesRecursively(object) {\n if (!object || typeof object !== \"object\") return\n const state = object[DRAFT_STATE]\n if (!state) return\n const {base, draft, assigned} = state\n if (!Array.isArray(object)) {\n // Look for added keys.\n Object.keys(draft).forEach(key => {\n // The `undefined` check is a fast path for pre-existing keys.\n if (base[key] === undefined && !has(base, key)) {\n assigned[key] = true\n markChanged(state)\n } else if (!assigned[key]) {\n // Only untouched properties trigger recursion.\n markChangesRecursively(draft[key])\n }\n })\n // Look for removed keys.\n Object.keys(base).forEach(key => {\n // The `undefined` check is a fast path for pre-existing keys.\n if (draft[key] === undefined && !has(draft, key)) {\n assigned[key] = false\n markChanged(state)\n }\n })\n } else if (hasArrayChanges(state)) {\n markChanged(state)\n assigned.length = true\n if (draft.length < base.length) {\n for (let i = draft.length; i < base.length; i++) assigned[i] = false\n } else {\n for (let i = base.length; i < draft.length; i++) assigned[i] = true\n }\n for (let i = 0; i < draft.length; i++) {\n // Only untouched indices trigger recursion.\n if (assigned[i] === undefined) markChangesRecursively(draft[i])\n }\n }\n}\n\nfunction hasObjectChanges(state) {\n const {base, draft} = state\n\n // Search for added keys. Start at the back, because non-numeric keys\n // are ordered by time of definition on the object.\n const keys = Object.keys(draft)\n for (let i = keys.length - 1; i >= 0; i--) {\n // The `undefined` check is a fast path for pre-existing keys.\n if (base[keys[i]] === undefined && !has(base, keys[i])) {\n return true\n }\n }\n\n // Since no keys have been added, we can compare lengths to know if an\n // object has been deleted.\n return keys.length !== Object.keys(base).length\n}\n\nfunction hasArrayChanges(state) {\n const {draft} = state\n if (draft.length !== state.base.length) return true\n // See #116\n // If we first shorten the length, our array interceptors will be removed.\n // If after that new items are added, result in the same original length,\n // those last items will have no intercepting property.\n // So if there is no own descriptor on the last position, we know that items were removed and added\n // N.B.: splice, unshift, etc only shift values around, but not prop descriptors, so we only have to check\n // the last one\n const descriptor = Object.getOwnPropertyDescriptor(draft, draft.length - 1)\n // descriptor can be null, but only for newly created sparse arrays, eg. new Array(10)\n if (descriptor && !descriptor.get) return true\n // For all other cases, we don't have to compare, as they would have been picked up by the index setters\n return false\n}\n\nfunction createHiddenProperty(target, prop, value) {\n Object.defineProperty(target, prop, {\n value: value,\n enumerable: false,\n writable: true\n })\n}\n","\"use strict\"\n// @ts-check\n\nimport {\n assign,\n each,\n has,\n is,\n isDraftable,\n isDraft,\n shallowCopy,\n DRAFT_STATE\n} from \"./common\"\n\n// For nested produce calls:\nexport const scopes = []\nexport const currentScope = () => scopes[scopes.length - 1]\n\n// Do nothing before being finalized.\nexport function willFinalize() {}\n\nexport function createDraft(base, parent) {\n const state = {\n // Track which produce call this is associated with.\n scope: parent ? parent.scope : currentScope(),\n // True for both shallow and deep changes.\n modified: false,\n // Used during finalization.\n finalized: false,\n // Track which properties have been assigned (true) or deleted (false).\n assigned: {},\n // The parent draft state.\n parent,\n // The base state.\n base,\n // The base proxy.\n draft: null,\n // Any property proxies.\n drafts: {},\n // The base copy with any updated values.\n copy: null,\n // Called by the `produce` function.\n revoke: null\n }\n\n const {revoke, proxy} = Array.isArray(base)\n ? Proxy.revocable([state], arrayTraps)\n : Proxy.revocable(state, objectTraps)\n\n state.draft = proxy\n state.revoke = revoke\n\n state.scope.push(state)\n return proxy\n}\n\nconst objectTraps = {\n get,\n has(target, prop) {\n return prop in source(target)\n },\n ownKeys(target) {\n return Reflect.ownKeys(source(target))\n },\n set,\n deleteProperty,\n getOwnPropertyDescriptor,\n defineProperty,\n setPrototypeOf() {\n throw new Error(\"Immer does not support `setPrototypeOf()`.\")\n }\n}\n\nconst arrayTraps = {}\neach(objectTraps, (key, fn) => {\n arrayTraps[key] = function() {\n arguments[0] = arguments[0][0]\n return fn.apply(this, arguments)\n }\n})\narrayTraps.deleteProperty = function(state, prop) {\n if (isNaN(parseInt(prop)))\n throw new Error(\n \"Immer does not support deleting properties from arrays: \" + prop\n )\n return objectTraps.deleteProperty.call(this, state[0], prop)\n}\narrayTraps.set = function(state, prop, value) {\n if (prop !== \"length\" && isNaN(parseInt(prop)))\n throw new Error(\n \"Immer does not support setting non-numeric properties on arrays: \" +\n prop\n )\n return objectTraps.set.call(this, state[0], prop, value)\n}\n\nfunction source(state) {\n return state.copy || state.base\n}\n\nfunction get(state, prop) {\n if (prop === DRAFT_STATE) return state\n let {drafts} = state\n\n // Check for existing draft in unmodified state.\n if (!state.modified && has(drafts, prop)) {\n return drafts[prop]\n }\n\n const value = source(state)[prop]\n if (state.finalized || !isDraftable(value)) return value\n\n // Check for existing draft in modified state.\n if (state.modified) {\n // Assigned values are never drafted. This catches any drafts we created, too.\n if (value !== state.base[prop]) return value\n // Store drafts on the copy (when one exists).\n drafts = state.copy\n }\n\n return (drafts[prop] = createDraft(value, state))\n}\n\nfunction set(state, prop, value) {\n if (!state.modified) {\n // Optimize based on value's truthiness. Truthy values are guaranteed to\n // never be undefined, so we can avoid the `in` operator. Lastly, truthy\n // values may be drafts, but falsy values are never drafts.\n const isUnchanged = value\n ? is(state.base[prop], value) || value === state.drafts[prop]\n : is(state.base[prop], value) && prop in state.base\n if (isUnchanged) return true\n markChanged(state)\n }\n state.assigned[prop] = true\n state.copy[prop] = value\n return true\n}\n\nfunction deleteProperty(state, prop) {\n // The `undefined` check is a fast path for pre-existing keys.\n if (state.base[prop] !== undefined || prop in state.base) {\n state.assigned[prop] = false\n markChanged(state)\n }\n if (state.copy) delete state.copy[prop]\n return true\n}\n\nfunction getOwnPropertyDescriptor(state, prop) {\n const owner = state.modified\n ? state.copy\n : has(state.drafts, prop)\n ? state.drafts\n : state.base\n const descriptor = Reflect.getOwnPropertyDescriptor(owner, prop)\n if (descriptor && !(Array.isArray(owner) && prop === \"length\"))\n descriptor.configurable = true\n return descriptor\n}\n\nfunction defineProperty() {\n throw new Error(\n \"Immer does not support defining properties on draft objects.\"\n )\n}\n\nfunction markChanged(state) {\n if (!state.modified) {\n state.modified = true\n state.copy = assign(shallowCopy(state.base), state.drafts)\n state.drafts = null\n if (state.parent) markChanged(state.parent)\n }\n}\n","import * as legacyProxy from \"./es5\"\nimport * as modernProxy from \"./proxy\"\nimport {generatePatches} from \"./patches\"\nimport {\n assign,\n each,\n is,\n isDraft,\n isDraftable,\n shallowCopy,\n DRAFT_STATE,\n NOTHING\n} from \"./common\"\n\nfunction verifyMinified() {}\n\nconst configDefaults = {\n useProxies: typeof Proxy !== \"undefined\" && typeof Reflect !== \"undefined\",\n autoFreeze:\n typeof process !== \"undefined\"\n ? process.env.NODE_ENV !== \"production\"\n : verifyMinified.name === \"verifyMinified\",\n onAssign: null,\n onDelete: null,\n onCopy: null\n}\n\nexport class Immer {\n constructor(config) {\n assign(this, configDefaults, config)\n this.setUseProxies(this.useProxies)\n this.produce = this.produce.bind(this)\n }\n produce(base, recipe, patchListener) {\n // curried invocation\n if (typeof base === \"function\" && typeof recipe !== \"function\") {\n const defaultBase = recipe\n recipe = base\n\n // prettier-ignore\n return (base = defaultBase, ...args) =>\n this.produce(base, draft => recipe.call(draft, draft, ...args))\n }\n\n // prettier-ignore\n {\n if (typeof recipe !== \"function\") throw new Error(\"if first argument is not a function, the second argument to produce should be a function\")\n if (patchListener !== undefined && typeof patchListener !== \"function\") throw new Error(\"the third argument of a producer should not be set or a function\")\n }\n\n let result\n // Only create proxies for plain objects/arrays.\n if (!isDraftable(base)) {\n result = recipe(base)\n if (result === undefined) return base\n }\n // See #100, don't nest producers\n else if (isDraft(base)) {\n result = recipe.call(base, base)\n if (result === undefined) return base\n }\n // The given value must be proxied.\n else {\n this.scopes.push([])\n const baseDraft = this.createDraft(base)\n try {\n result = recipe.call(baseDraft, baseDraft)\n this.willFinalize(result, baseDraft, !!patchListener)\n\n // Never generate patches when no listener exists.\n var patches = patchListener && [],\n inversePatches = patchListener && []\n\n // Finalize the modified draft...\n if (result === undefined || result === baseDraft) {\n result = this.finalize(\n baseDraft,\n [],\n patches,\n inversePatches\n )\n }\n // ...or use a replacement value.\n else {\n // Users must never modify the draft _and_ return something else.\n if (baseDraft[DRAFT_STATE].modified)\n throw new Error(\"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.\") // prettier-ignore\n\n // Finalize the replacement in case it contains (or is) a subset of the draft.\n if (isDraftable(result)) result = this.finalize(result)\n\n if (patchListener) {\n patches.push({\n op: \"replace\",\n path: [],\n value: result\n })\n inversePatches.push({\n op: \"replace\",\n path: [],\n value: base\n })\n }\n }\n } finally {\n this.currentScope().forEach(state => state.revoke())\n this.scopes.pop()\n }\n patchListener && patchListener(patches, inversePatches)\n }\n // Normalize the result.\n return result === NOTHING ? undefined : result\n }\n setAutoFreeze(value) {\n this.autoFreeze = value\n }\n setUseProxies(value) {\n this.useProxies = value\n assign(this, value ? modernProxy : legacyProxy)\n }\n /**\n * @internal\n * Finalize a draft, returning either the unmodified base state or a modified\n * copy of the base state.\n */\n finalize(draft, path, patches, inversePatches) {\n const state = draft[DRAFT_STATE]\n if (!state) {\n if (Object.isFrozen(draft)) return draft\n return this.finalizeTree(draft)\n }\n // Never finalize drafts owned by an outer scope.\n if (state.scope !== this.currentScope()) {\n return draft\n }\n if (!state.modified) return state.base\n if (!state.finalized) {\n state.finalized = true\n this.finalizeTree(state.draft, path, patches, inversePatches)\n if (this.onDelete) {\n const {assigned} = state\n for (const prop in assigned)\n assigned[prop] || this.onDelete(state, prop)\n }\n if (this.onCopy) this.onCopy(state)\n\n // Nested producers must never auto-freeze their result,\n // because it may contain drafts from parent producers.\n if (this.autoFreeze && this.scopes.length === 1) {\n Object.freeze(state.copy)\n }\n\n if (patches) generatePatches(state, path, patches, inversePatches)\n }\n return state.copy\n }\n /**\n * @internal\n * Finalize all drafts in the given state tree.\n */\n finalizeTree(root, path, patches, inversePatches) {\n const state = root[DRAFT_STATE]\n if (state) {\n root = this.useProxies\n ? state.copy\n : (state.copy = shallowCopy(state.draft))\n }\n\n const {onAssign} = this\n const finalizeProperty = (prop, value, parent) => {\n // Only `root` can be a draft in here.\n const inDraft = !!state && parent === root\n\n if (isDraft(value)) {\n // prettier-ignore\n parent[prop] = value =\n // Patches are never generated for assigned properties.\n patches && inDraft && !state.assigned[prop]\n ? this.finalize(value, path.concat(prop), patches, inversePatches)\n : this.finalize(value)\n\n // Unchanged drafts are ignored.\n if (inDraft && value === state.base[prop]) return\n }\n // Unchanged draft properties are ignored.\n else if (inDraft && is(value, state.base[prop])) {\n return\n }\n // Search new objects for unfinalized drafts. Frozen objects should never contain drafts.\n else if (isDraftable(value) && !Object.isFrozen(value)) {\n each(value, finalizeProperty)\n }\n\n if (inDraft && onAssign) {\n onAssign(state, prop, value)\n }\n }\n\n each(root, finalizeProperty)\n return root\n }\n}\n","import {applyPatches as applyPatchesImpl} from \"./patches\"\nimport {Immer} from \"./immer\"\n\nconst immer = new Immer()\n\n/**\n * The `produce` function takes a value and a \"recipe function\" (whose\n * return value often depends on the base state). The recipe function is\n * free to mutate its first argument however it wants. All mutations are\n * only ever applied to a __copy__ of the base state.\n *\n * Pass only a function to create a \"curried producer\" which relieves you\n * from passing the recipe function every time.\n *\n * Only plain objects and arrays are made mutable. All other objects are\n * considered uncopyable.\n *\n * Note: This function is __bound__ to its `Immer` instance.\n *\n * @param {any} base - the initial state\n * @param {Function} producer - function that receives a proxy of the base state as first argument and which can be freely modified\n * @param {Function} patchListener - optional function that will be called with all the patches produced here\n * @returns {any} a new state, or the initial state if nothing was modified\n */\nexport const produce = immer.produce\nexport default produce\n\n/**\n * Pass true to automatically freeze all copies created by Immer.\n *\n * By default, auto-freezing is disabled in production.\n */\nexport const setAutoFreeze = value => immer.setAutoFreeze(value)\n\n/**\n * Pass true to use the ES2015 `Proxy` class when creating drafts, which is\n * always faster than using ES5 proxies.\n *\n * By default, feature detection is used, so calling this is rarely necessary.\n */\nexport const setUseProxies = value => immer.setUseProxies(value)\n\n/**\n * Apply an array of Immer patches to the first argument.\n *\n * This function is a producer, which means copy-on-write is in effect.\n */\nexport const applyPatches = produce(applyPatchesImpl)\n\nexport {original, isDraft, NOTHING as nothing} from \"./common\"\n\nexport {Immer}\n"],"names":["NOTHING","Symbol","DRAFT_STATE","isDraft","value","isDraftable","Array","isArray","proto","Object","getPrototypeOf","prototype","assign","target","key","has","shallowCopy","slice","undefined","__proto__","create","each","cb","i","length","thing","prop","hasOwnProperty","call","is","x","y","generatePatches","state","basePath","patches","inversePatches","base","copy","assigned","minLength","Math","min","path","concat","push","op","generateArrayPatches","assignedValue","origValue","generateObjectPatches","descriptors","scopes","currentScope","createDraft","parent","draft","finalizing","defineProperty","source","get","this","modified","createPropertyProxy","scope","revoke","revoked","markChanged","prepareCopy","assertUnrevoked","Error","JSON","stringify","hasObjectChanges","keys","hasArrayChanges","descriptor","getOwnPropertyDescriptor","result","baseDraft","needPatches","forEach","markChangesRecursively","object","Proxy","revocable","arrayTraps","objectTraps","proxy","drafts","finalized","Reflect","ownKeys","isUnchanged","owner","configurable","fn","arguments","apply","deleteProperty","isNaN","parseInt","set","configDefaults","process","env","NODE_ENV","name","Immer","config","setUseProxies","useProxies","produce","bind","recipe","patchListener","defaultBase","args","_this","willFinalize","finalize","pop","autoFreeze","modernProxy","legacyProxy","isFrozen","finalizeTree","onDelete","onCopy","freeze","root","onAssign","finalizeProperty","inDraft","_this2","immer","applyPatches","patch","join","setAutoFreeze"],"mappings":"olBAAaA,EACS,oBAAXC,OACDA,OAAO,qBACa,KAAlB,kHAECC,EACS,oBAAXD,OAAyBA,OAAO,eAAiB,iBAE5D,SAAgBE,EAAQC,WACXA,KAAWA,EAAMF,GAG9B,SAAgBG,EAAYD,OACnBA,EAAO,OAAO,KACE,qBAAVA,gBAAAA,IAAoB,OAAO,KAClCE,MAAMC,QAAQH,GAAQ,OAAO,MAC3BI,EAAQC,OAAOC,eAAeN,UACnB,OAAVI,GAAkBA,IAAUC,OAAOE,UAU9C,IAAaC,EACTH,OAAOG,QACP,SAAgBC,EAAQT,OACf,IAAIU,KAAOV,EACRW,EAAIX,EAAOU,OACJA,GAAOV,EAAMU,WAGrBD,GAGf,SAAgBG,EAAYZ,MACpBE,MAAMC,QAAQH,GAAQ,OAAOA,EAAMa,YACjCJ,OAA6BK,IAApBd,EAAMe,UAA0BV,OAAOW,OAAO,gBACtDR,EAAOC,EAAQT,GAG1B,SAAgBiB,EAAKjB,EAAOkB,MACpBhB,MAAMC,QAAQH,OACT,IAAImB,EAAI,EAAGA,EAAInB,EAAMoB,OAAQD,MAAQA,EAAGnB,EAAMmB,GAAInB,YAElD,IAAIU,KAAOV,IAAUU,EAAKV,EAAMU,GAAMV,GAInD,SAAgBW,EAAIU,EAAOC,UAChBjB,OAAOE,UAAUgB,eAAeC,KAAKH,EAAOC,GAGvD,SAAgBG,EAAGC,EAAGC,UAEdD,IAAMC,EACO,IAAND,G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