2 lines
13 KiB
JavaScript
2 lines
13 KiB
JavaScript
"use strict";var ae=Object.defineProperty;var Ie=Object.getOwnPropertyDescriptor;var Te=Object.getOwnPropertyNames;var Ae=Object.prototype.hasOwnProperty;var De=(e,t)=>{for(var r in t)ae(e,r,{get:t[r],enumerable:!0})},Oe=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Te(t))!Ae.call(e,o)&&o!==r&&ae(e,o,{get:()=>t[o],enumerable:!(n=Ie(t,o))||n.enumerable});return e};var Me=e=>Oe(ae({},"__esModule",{value:!0}),e);var He={};De(He,{Immer:()=>J,applyPatches:()=>ke,castDraft:()=>We,castImmutable:()=>Be,createDraft:()=>Ke,current:()=>ne,enableMapSet:()=>ge,enablePatches:()=>be,finishDraft:()=>Ue,freeze:()=>K,immerable:()=>j,isDraft:()=>M,isDraftable:()=>T,nothing:()=>z,original:()=>de,produce:()=>Ne,produceWithPatches:()=>ze,setAutoFreeze:()=>Ce,setUseStrictIteration:()=>Re,setUseStrictShallowCopy:()=>ve});module.exports=Me(He);var z=Symbol.for("immer-nothing"),j=Symbol.for("immer-draftable"),u=Symbol.for("immer-state");function h(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var C=Object.getPrototypeOf;function M(e){return!!e&&!!e[u]}function T(e){return e?pe(e)||Array.isArray(e)||!!e[j]||!!e.constructor?.[j]||N(e)||k(e):!1}var _e=Object.prototype.constructor.toString(),le=new WeakMap;function pe(e){if(!e||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);if(t===null||t===Object.prototype)return!0;let r=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;if(r===Object)return!0;if(typeof r!="function")return!1;let n=le.get(r);return n===void 0&&(n=Function.toString.call(r),le.set(r,n)),n===_e}function de(e){return M(e)||h(15,e),e[u].t}function _(e,t,r=!0){v(e)===0?(r?Reflect.ownKeys(e):Object.keys(e)).forEach(o=>{t(o,e[o],e)}):e.forEach((n,o)=>t(o,n,e))}function v(e){let t=e[u];return t?t.o:Array.isArray(e)?1:N(e)?2:k(e)?3:0}function R(e,t){return v(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Q(e,t){return v(e)===2?e.get(t):e[t]}function Y(e,t,r){let n=v(e);n===2?e.set(t,r):n===3?e.add(r):e[t]=r}function he(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function N(e){return e instanceof Map}function k(e){return e instanceof Set}function I(e){return e.e||e.t}function G(e,t){if(N(e))return new Map(e);if(k(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let r=pe(e);if(t===!0||t==="class_only"&&!r){let n=Object.getOwnPropertyDescriptors(e);delete n[u];let o=Reflect.ownKeys(n);for(let c=0;c<o.length;c++){let y=o[c],s=n[y];s.writable===!1&&(s.writable=!0,s.configurable=!0),(s.get||s.set)&&(n[y]={configurable:!0,writable:!0,enumerable:s.enumerable,value:e[y]})}return Object.create(C(e),n)}else{let n=C(e);if(n!==null&&r)return{...e};let o=Object.create(n);return Object.assign(o,e)}}function K(e,t=!1){return H(e)||M(e)||!T(e)||(v(e)>1&&Object.defineProperties(e,{set:X,add:X,clear:X,delete:X}),Object.freeze(e),t&&Object.values(e).forEach(r=>K(r,!0))),e}function we(){h(2)}var X={value:we};function H(e){return e===null||typeof e!="object"?!0:Object.isFrozen(e)}var oe={};function w(e){let t=oe[e];return t||h(0,e),t}function Z(e,t){oe[e]||(oe[e]=t)}var L;function U(){return L}function Ee(e,t){return{a:[],i:e,f:t,P:!0,d:0}}function ie(e,t){t&&(w("Patches"),e.u=[],e.h=[],e.I=t)}function q(e){ee(e),e.a.forEach(Fe),e.a=null}function ee(e){e===L&&(L=e.i)}function se(e){return L=Ee(L,e)}function Fe(e){let t=e[u];t.o===0||t.o===1?t.x():t.m=!0}function ce(e,t){t.d=t.a.length;let r=t.a[0];return e!==void 0&&e!==r?(r[u].s&&(q(t),h(4)),T(e)&&(e=te(t,e),t.i||re(t,e)),t.u&&w("Patches").T(r[u].t,e,t.u,t.h)):e=te(t,r,[]),q(t),t.u&&t.I(t.u,t.h),e!==z?e:void 0}function te(e,t,r){if(H(t))return t;let n=e.f.shouldUseStrictIteration(),o=t[u];if(!o)return _(t,(c,y)=>me(e,o,t,c,y,r),n),t;if(o.n!==e)return t;if(!o.s)return re(e,o.t,!0),o.t;if(!o.c){o.c=!0,o.n.d--;let c=o.e,y=c,s=!1;o.o===3&&(y=new Set(c),c.clear(),s=!0),_(y,(g,a)=>me(e,o,c,g,a,r,s),n),re(e,c,!1),r&&e.u&&w("Patches").g(o,r,e.u,e.h)}return o.e}function me(e,t,r,n,o,c,y){if(o==null||typeof o!="object"&&!y)return;let s=H(o);if(!(s&&!y)){if(M(o)){let g=c&&t&&t.o!==3&&!R(t.r,n)?c.concat(n):void 0,a=te(e,o,g);if(Y(r,n,a),M(a))e.P=!1;else return}else y&&r.add(o);if(T(o)&&!s){if(!e.f.y&&e.d<1||t&&t.t&&t.t[n]===o&&s)return;te(e,o),(!t||!t.n.i)&&typeof n!="symbol"&&(N(r)?r.has(n):Object.prototype.propertyIsEnumerable.call(r,n))&&re(e,o)}}}function re(e,t,r=!1){!e.i&&e.f.y&&e.P&&K(t,r)}function Se(e,t){let r=Array.isArray(e),n={o:r?1:0,n:t?t.n:U(),s:!1,c:!1,r:{},i:t,t:e,p:null,e:null,x:null,l:!1},o=n,c=ye;r&&(o=[n],c=V);let{revoke:y,proxy:s}=Proxy.revocable(o,c);return n.p=s,n.x=y,s}var ye={get(e,t){if(t===u)return e;let r=I(e);if(!R(r,t))return je(e,r,t);let n=r[t];return e.c||!T(n)?n:n===fe(e.t,t)?(ue(e),e.e[t]=W(n,e)):n},has(e,t){return t in I(e)},ownKeys(e){return Reflect.ownKeys(I(e))},set(e,t,r){let n=Pe(I(e),t);if(n?.set)return n.set.call(e.p,r),!0;if(!e.s){let o=fe(I(e),t),c=o?.[u];if(c&&c.t===r)return e.e[t]=r,e.r[t]=!1,!0;if(he(r,o)&&(r!==void 0||R(e.t,t)))return!0;ue(e),E(e)}return e.e[t]===r&&(r!==void 0||t in e.e)||Number.isNaN(r)&&Number.isNaN(e.e[t])||(e.e[t]=r,e.r[t]=!0),!0},deleteProperty(e,t){return fe(e.t,t)!==void 0||t in e.t?(e.r[t]=!1,ue(e),E(e)):delete e.r[t],e.e&&delete e.e[t],!0},getOwnPropertyDescriptor(e,t){let r=I(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n&&{writable:!0,configurable:e.o!==1||t!=="length",enumerable:n.enumerable,value:r[t]}},defineProperty(){h(11)},getPrototypeOf(e){return C(e.t)},setPrototypeOf(){h(12)}},V={};_(ye,(e,t)=>{V[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});V.deleteProperty=function(e,t){return V.set.call(this,e,t,void 0)};V.set=function(e,t,r){return ye.set.call(this,e[0],t,r,e[0])};function fe(e,t){let r=e[u];return(r?I(r):e)[t]}function je(e,t,r){let n=Pe(t,r);return n?"value"in n?n.value:n.get?.call(e.p):void 0}function Pe(e,t){if(!(t in e))return;let r=C(e);for(;r;){let n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=C(r)}}function E(e){e.s||(e.s=!0,e.i&&E(e.i))}function ue(e){e.e||(e.e=G(e.t,e.n.f.S))}var J=class{constructor(t){this.y=!0;this.S=!1;this.b=!0;this.produce=(t,r,n)=>{if(typeof t=="function"&&typeof r!="function"){let c=r;r=t;let y=this;return function(g=c,...a){return y.produce(g,i=>r.call(this,i,...a))}}typeof r!="function"&&h(6),n!==void 0&&typeof n!="function"&&h(7);let o;if(T(t)){let c=se(this),y=W(t,void 0),s=!0;try{o=r(y),s=!1}finally{s?q(c):ee(c)}return ie(c,n),ce(o,c)}else if(!t||typeof t!="object"){if(o=r(t),o===void 0&&(o=t),o===z&&(o=void 0),this.y&&K(o,!0),n){let c=[],y=[];w("Patches").T(t,o,c,y),n(c,y)}return o}else h(1,t)};this.produceWithPatches=(t,r)=>{if(typeof t=="function")return(y,...s)=>this.produceWithPatches(y,g=>t(g,...s));let n,o;return[this.produce(t,r,(y,s)=>{n=y,o=s}),n,o]};typeof t?.autoFreeze=="boolean"&&this.setAutoFreeze(t.autoFreeze),typeof t?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),typeof t?.useStrictIteration=="boolean"&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){T(t)||h(8),M(t)&&(t=ne(t));let r=se(this),n=W(t,void 0);return n[u].l=!0,ee(r),n}finishDraft(t,r){let n=t&&t[u];(!n||!n.l)&&h(9);let{n:o}=n;return ie(o,r),ce(void 0,o)}setAutoFreeze(t){this.y=t}setUseStrictShallowCopy(t){this.S=t}setUseStrictIteration(t){this.b=t}shouldUseStrictIteration(){return this.b}applyPatches(t,r){let n;for(n=r.length-1;n>=0;n--){let c=r[n];if(c.path.length===0&&c.op==="replace"){t=c.value;break}}n>-1&&(r=r.slice(n+1));let o=w("Patches").A;return M(t)?o(t,r):this.produce(t,c=>o(c,r))}};function W(e,t){let r=N(e)?w("MapSet").D(e,t):k(e)?w("MapSet").R(e,t):Se(e,t);return(t?t.n:U()).a.push(r),r}function ne(e){return M(e)||h(10,e),xe(e)}function xe(e){if(!T(e)||H(e))return e;let t=e[u],r,n=!0;if(t){if(!t.s)return t.t;t.c=!0,r=G(e,t.n.f.S),n=t.n.f.shouldUseStrictIteration()}else r=G(e,!0);return _(r,(o,c)=>{Y(r,o,xe(c))},n),t&&(t.c=!1),r}function be(){let t="replace",r="add",n="remove";function o(f,S,m,x){switch(f.o){case 0:case 2:return y(f,S,m,x);case 1:return c(f,S,m,x);case 3:return s(f,S,m,x)}}function c(f,S,m,x){let{t:A,r:P}=f,b=f.e;b.length<A.length&&([A,b]=[b,A],[m,x]=[x,m]);for(let l=0;l<A.length;l++)if(P[l]&&b[l]!==A[l]){let d=S.concat([l]);m.push({op:t,path:d,value:p(b[l])}),x.push({op:t,path:d,value:p(A[l])})}for(let l=A.length;l<b.length;l++){let d=S.concat([l]);m.push({op:r,path:d,value:p(b[l])})}for(let l=b.length-1;A.length<=l;--l){let d=S.concat([l]);x.push({op:n,path:d})}}function y(f,S,m,x){let{t:A,e:P}=f;_(f.r,(b,l)=>{let d=Q(A,b),B=Q(P,b),F=l?R(A,b)?t:r:n;if(d===B&&F===t)return;let O=S.concat(b);m.push(F===n?{op:F,path:O}:{op:F,path:O,value:B}),x.push(F===r?{op:n,path:O}:F===n?{op:r,path:O,value:p(d)}:{op:t,path:O,value:p(d)})})}function s(f,S,m,x){let{t:A,e:P}=f,b=0;A.forEach(l=>{if(!P.has(l)){let d=S.concat([b]);m.push({op:n,path:d,value:l}),x.unshift({op:r,path:d,value:l})}b++}),b=0,P.forEach(l=>{if(!A.has(l)){let d=S.concat([b]);m.push({op:r,path:d,value:l}),x.unshift({op:n,path:d,value:l})}b++})}function g(f,S,m,x){m.push({op:t,path:[],value:S===z?void 0:S}),x.push({op:t,path:[],value:f})}function a(f,S){return S.forEach(m=>{let{path:x,op:A}=m,P=f;for(let B=0;B<x.length-1;B++){let F=v(P),O=x[B];typeof O!="string"&&typeof O!="number"&&(O=""+O),(F===0||F===1)&&(O==="__proto__"||O==="constructor")&&h(16+3),typeof P=="function"&&O==="prototype"&&h(16+3),P=Q(P,O),typeof P!="object"&&h(16+2,x.join("/"))}let b=v(P),l=i(m.value),d=x[x.length-1];switch(A){case t:switch(b){case 2:return P.set(d,l);case 3:h(16);default:return P[d]=l}case r:switch(b){case 1:return d==="-"?P.push(l):P.splice(d,0,l);case 2:return P.set(d,l);case 3:return P.add(l);default:return P[d]=l}case n:switch(b){case 1:return P.splice(d,1);case 2:return P.delete(d);case 3:return P.delete(m.value);default:return delete P[d]}default:h(16+1,A)}}),f}function i(f){if(!T(f))return f;if(Array.isArray(f))return f.map(i);if(N(f))return new Map(Array.from(f.entries()).map(([m,x])=>[m,i(x)]));if(k(f))return new Set(Array.from(f).map(i));let S=Object.create(C(f));for(let m in f)S[m]=i(f[m]);return R(f,j)&&(S[j]=f[j]),S}function p(f){return M(f)?i(f):f}Z("Patches",{A:a,g:o,T:g})}function ge(){class e extends Map{constructor(a,i){super();this[u]={o:2,i,n:i?i.n:U(),s:!1,c:!1,e:void 0,r:void 0,t:a,p:this,l:!1,m:!1}}get size(){return I(this[u]).size}has(a){return I(this[u]).has(a)}set(a,i){let p=this[u];return y(p),(!I(p).has(a)||I(p).get(a)!==i)&&(r(p),E(p),p.r.set(a,!0),p.e.set(a,i),p.r.set(a,!0)),this}delete(a){if(!this.has(a))return!1;let i=this[u];return y(i),r(i),E(i),i.t.has(a)?i.r.set(a,!1):i.r.delete(a),i.e.delete(a),!0}clear(){let a=this[u];y(a),I(a).size&&(r(a),E(a),a.r=new Map,_(a.t,i=>{a.r.set(i,!1)}),a.e.clear())}forEach(a,i){let p=this[u];I(p).forEach((f,S,m)=>{a.call(i,this.get(S),S,this)})}get(a){let i=this[u];y(i);let p=I(i).get(a);if(i.c||!T(p)||p!==i.t.get(a))return p;let f=W(p,i);return r(i),i.e.set(a,f),f}keys(){return I(this[u]).keys()}values(){let a=this.keys();return{[Symbol.iterator]:()=>this.values(),next:()=>{let i=a.next();return i.done?i:{done:!1,value:this.get(i.value)}}}}entries(){let a=this.keys();return{[Symbol.iterator]:()=>this.entries(),next:()=>{let i=a.next();if(i.done)return i;let p=this.get(i.value);return{done:!1,value:[i.value,p]}}}}[(u,Symbol.iterator)](){return this.entries()}}function t(s,g){return new e(s,g)}function r(s){s.e||(s.r=new Map,s.e=new Map(s.t))}class n extends Set{constructor(a,i){super();this[u]={o:3,i,n:i?i.n:U(),s:!1,c:!1,e:void 0,t:a,p:this,a:new Map,m:!1,l:!1}}get size(){return I(this[u]).size}has(a){let i=this[u];return y(i),i.e?!!(i.e.has(a)||i.a.has(a)&&i.e.has(i.a.get(a))):i.t.has(a)}add(a){let i=this[u];return y(i),this.has(a)||(c(i),E(i),i.e.add(a)),this}delete(a){if(!this.has(a))return!1;let i=this[u];return y(i),c(i),E(i),i.e.delete(a)||(i.a.has(a)?i.e.delete(i.a.get(a)):!1)}clear(){let a=this[u];y(a),I(a).size&&(c(a),E(a),a.e.clear())}values(){let a=this[u];return y(a),c(a),a.e.values()}entries(){let a=this[u];return y(a),c(a),a.e.entries()}keys(){return this.values()}[(u,Symbol.iterator)](){return this.values()}forEach(a,i){let p=this.values(),f=p.next();for(;!f.done;)a.call(i,f.value,f.value,this),f=p.next()}}function o(s,g){return new n(s,g)}function c(s){s.e||(s.e=new Set,s.t.forEach(g=>{if(T(g)){let a=W(g,s);s.a.set(g,a),s.e.add(a)}else s.e.add(g)}))}function y(s){s.m&&h(3,JSON.stringify(I(s)))}Z("MapSet",{D:t,R:o})}var D=new J,Ne=D.produce,ze=D.produceWithPatches.bind(D),Ce=D.setAutoFreeze.bind(D),ve=D.setUseStrictShallowCopy.bind(D),Re=D.setUseStrictIteration.bind(D),ke=D.applyPatches.bind(D),Ke=D.createDraft.bind(D),Ue=D.finishDraft.bind(D);function We(e){return e}function Be(e){return e}0&&(module.exports={Immer,applyPatches,castDraft,castImmutable,createDraft,current,enableMapSet,enablePatches,finishDraft,freeze,immerable,isDraft,isDraftable,nothing,original,produce,produceWithPatches,setAutoFreeze,setUseStrictIteration,setUseStrictShallowCopy});
|
|
//# sourceMappingURL=immer.cjs.production.js.map
|