UNPKG

18.2 kBJavaScriptView Raw
1var e=Object.defineProperty,t=Object.defineProperties,n=Object.getOwnPropertyDescriptors,r=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,a=(t,n,r)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r,c=(e,t)=>{for(var n in t||(t={}))o.call(t,n)&&a(e,n,t[n]);if(r)for(var n of r(t))i.call(t,n)&&a(e,n,t[n]);return e},s=(e,r)=>t(e,n(r));import{enableES5 as u}from"immer";export*from"redux";import{default as l,current as f,freeze as d,original as p,isDraft as m}from"immer";import{createSelector as y}from"reselect";import{current as h,isDraft as g}from"immer";import{createSelector as b}from"reselect";var w=(...e)=>{const t=b(...e);return(e,...n)=>t(g(e)?h(e):e,...n)};import{createStore as v,compose as O,applyMiddleware as j,combineReducers as E}from"redux";import{compose as S}from"redux";var A="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?S:S.apply(null,arguments)};function P(e){if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);if(null===t)return!0;let n=t;for(;null!==Object.getPrototypeOf(n);)n=Object.getPrototypeOf(n);return t===n}"undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__&&window;import k from"redux-thunk";import x,{isDraftable as I}from"immer";var _=class extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,_.prototype)}static get[Symbol.species](){return _}concat(...e){return super.concat.apply(this,e)}prepend(...e){return 1===e.length&&Array.isArray(e[0])?new _(...e[0].concat(this)):new _(...e.concat(this))}};function C(e){return I(e)?x(e,(()=>{})):e}function M(e){return"object"!=typeof e||null==e||Object.isFrozen(e)}function T(e={}){return()=>e=>t=>e(t)}function q(e){const t=typeof e;return null==e||"string"===t||"boolean"===t||"number"===t||Array.isArray(e)||P(e)}function D(e,t="",n=q,r,o=[],i){let a;if(!n(e))return{keyPath:t||"<root>",value:e};if("object"!=typeof e||null===e)return!1;if(null==i?void 0:i.has(e))return!1;const c=null!=r?r(e):Object.entries(e),s=o.length>0;for(const[e,u]of c){const c=t?t+"."+e:e;if(!s||!o.some((e=>e instanceof RegExp?e.test(c):c===e))){if(!n(u))return{keyPath:c,value:u};if("object"==typeof u&&(a=D(u,c,n,r,o,i),a))return a}}return i&&R(e)&&i.add(e),!1}function R(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if("object"==typeof t&&null!==t&&!R(t))return!1;return!0}function L(e={}){return()=>e=>t=>e(t)}function $(e={}){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:r=!0}=e;let o=new _;return t&&o.push("boolean"==typeof t?k:k.withExtraArgument(t.extraArgument)),o}function B(e){const t=function(e){return $(e)},{reducer:n,middleware:r=t(),devTools:o=!0,preloadedState:i,enhancers:a}=e||{};let s;if("function"==typeof n)s=n;else{if(!P(n))throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');s=E(n)}let u=r;"function"==typeof u&&(u=u(t));const l=j(...u);let f=O;o&&(f=A(c({trace:!1},"object"==typeof o&&o)));let d=[l];Array.isArray(a)?d=[l,...a]:"function"==typeof a&&(d=a(d));const p=f(...d);return v(s,i,p)}function N(e,t){function n(...n){if(t){let r=t(...n);if(!r)throw new Error("prepareAction did not return an object");return c(c({type:e,payload:r.payload},"meta"in r&&{meta:r.meta}),"error"in r&&{error:r.error})}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>t.type===e,n}function V(e){return["type","payload","error","meta"].indexOf(e)>-1}function z(e){return`${e}`}import X,{isDraft as W,isDraftable as F}from"immer";function U(e){const t={},n=[];let r;const o={addCase(e,n){const r="string"==typeof e?e:e.type;if(r in t)throw new Error("addCase cannot be called with two reducers for the same action type");return t[r]=n,o},addMatcher:(e,t)=>(n.push({matcher:e,reducer:t}),o),addDefaultCase:e=>(r=e,o)};return e(o),[t,n,r]}function K(e,t,n=[],r){let o,[i,a,c]="function"==typeof t?U(t):[t,n,r];if("function"==typeof e)o=()=>C(e());else{const t=C(e);o=()=>t}function s(e=o(),t){let n=[i[t.type],...a.filter((({matcher:e})=>e(t))).map((({reducer:e})=>e))];return 0===n.filter((e=>!!e)).length&&(n=[c]),n.reduce(((e,n)=>{if(n){if(W(e)){const r=n(e,t);return void 0===r?e:r}if(F(e))return X(e,(e=>n(e,t)));{const r=n(e,t);if(void 0===r){if(null===e)return e;throw Error("A case reducer on a non-draftable value must not return undefined")}return r}}return e}),e)}return s.getInitialState=o,s}function G(e){const{name:t}=e;if(!t)throw new Error("`name` is a required option for createSlice");const n="function"==typeof e.initialState?e.initialState:C(e.initialState),r=e.reducers||{},o=Object.keys(r),i={},a={},s={};function u(){const[t={},r=[],o]="function"==typeof e.extraReducers?U(e.extraReducers):[e.extraReducers],i=c(c({},t),a);return K(n,(e=>{for(let t in i)e.addCase(t,i[t]);for(let t of r)e.addMatcher(t.matcher,t.reducer);o&&e.addDefaultCase(o)}))}let l;return o.forEach((e=>{const n=r[e],o=`${t}/${e}`;let c,u;"reducer"in n?(c=n.reducer,u=n.prepare):c=n,i[e]=c,a[o]=c,s[e]=u?N(o,u):N(o)})),{name:t,reducer:(e,t)=>(l||(l=u()),l(e,t)),actions:s,caseReducers:i,getInitialState:()=>(l||(l=u()),l.getInitialState())}}import H,{isDraft as J}from"immer";function Q(e){const t=Y(((t,n)=>e(n)));return function(e){return t(e,void 0)}}function Y(e){return function(t,n){const r=t=>{var r;P(r=n)&&"string"==typeof r.type&&Object.keys(r).every(V)?e(n.payload,t):e(n,t)};return J(t)?(r(t),t):H(t,r)}}function Z(e,t){return t(e)}function ee(e){return Array.isArray(e)||(e=Object.values(e)),e}function te(e,t,n){e=ee(e);const r=[],o=[];for(const i of e){const e=Z(i,t);e in n.entities?o.push({id:e,changes:i}):r.push(i)}return[r,o]}function ne(e){function t(t,n){const r=Z(t,e);r in n.entities||(n.ids.push(r),n.entities[r]=t)}function n(e,n){e=ee(e);for(const r of e)t(r,n)}function r(t,n){const r=Z(t,e);r in n.entities||n.ids.push(r),n.entities[r]=t}function o(e,t){let n=!1;e.forEach((e=>{e in t.entities&&(delete t.entities[e],n=!0)})),n&&(t.ids=t.ids.filter((e=>e in t.entities)))}function i(t,n){const r={},o={};if(t.forEach((e=>{e.id in n.entities&&(o[e.id]={id:e.id,changes:c(c({},o[e.id]?o[e.id].changes:null),e.changes)})})),(t=Object.values(o)).length>0){const o=t.filter((t=>function(t,n,r){const o=Object.assign({},r.entities[n.id],n.changes),i=Z(o,e),a=i!==n.id;return a&&(t[n.id]=i,delete r.entities[n.id]),r.entities[i]=o,a}(r,t,n))).length>0;o&&(n.ids=Object.keys(n.entities))}}function a(t,r){const[o,a]=te(t,e,r);i(a,r),n(o,r)}return{removeAll:Q((function(e){Object.assign(e,{ids:[],entities:{}})})),addOne:Y(t),addMany:Y(n),setOne:Y(r),setMany:Y((function(e,t){e=ee(e);for(const n of e)r(n,t)})),setAll:Y((function(e,t){e=ee(e),t.ids=[],t.entities={},n(e,t)})),updateOne:Y((function(e,t){return i([e],t)})),updateMany:Y(i),upsertOne:Y((function(e,t){return a([e],t)})),upsertMany:Y(a),removeOne:Y((function(e,t){return o([e],t)})),removeMany:Y(o)}}function re(e={}){const{selectId:t,sortComparer:n}=c({sortComparer:!1,selectId:e=>e.id},e),r={getInitialState:function(e={}){return Object.assign({ids:[],entities:{}},e)}},o={getSelectors:function(e){const t=e=>e.ids,n=e=>e.entities,r=w(t,n,((e,t)=>e.map((e=>t[e])))),o=(e,t)=>t,i=(e,t)=>e[t],a=w(t,(e=>e.length));if(!e)return{selectIds:t,selectEntities:n,selectAll:r,selectTotal:a,selectById:w(n,o,i)};const c=w(e,n);return{selectIds:w(e,t),selectEntities:c,selectAll:w(e,r),selectTotal:w(e,a),selectById:w(c,o,i)}}},i=n?function(e,t){const{removeOne:n,removeMany:r,removeAll:o}=ne(e);function i(t,n){const r=(t=ee(t)).filter((t=>!(Z(t,e)in n.entities)));0!==r.length&&u(r,n)}function a(e,t){0!==(e=ee(e)).length&&u(e,t)}function c(t,n){let r=!1;for(let o of t){const t=n.entities[o.id];if(!t)continue;r=!0,Object.assign(t,o.changes);const i=e(t);o.id!==i&&(delete n.entities[o.id],n.entities[i]=t)}r&&l(n)}function s(t,n){const[r,o]=te(t,e,n);c(o,n),i(r,n)}function u(t,n){t.forEach((t=>{n.entities[e(t)]=t})),l(n)}function l(n){const r=Object.values(n.entities);r.sort(t);const o=r.map(e),{ids:i}=n;(function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length&&n<t.length;n++)if(e[n]!==t[n])return!1;return!0})(i,o)||(n.ids=o)}return{removeOne:n,removeMany:r,removeAll:o,addOne:Y((function(e,t){return i([e],t)})),updateOne:Y((function(e,t){return c([e],t)})),upsertOne:Y((function(e,t){return s([e],t)})),setOne:Y((function(e,t){return a([e],t)})),setMany:Y(a),setAll:Y((function(e,t){e=ee(e),t.entities={},t.ids=[],i(e,t)})),addMany:Y(i),updateMany:Y(c),upsertMany:Y(s)}}(t,n):ne(t);return c(c(c({selectId:t,sortComparer:n},r),o),i)}var oe=(e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t},ie=["name","message","stack","code"],ae=class{constructor(e,t){this.payload=e,this.meta=t}},ce=class{constructor(e,t){this.payload=e,this.meta=t}},se=e=>{if("object"==typeof e&&null!==e){const t={};for(const n of ie)"string"==typeof e[n]&&(t[n]=e[n]);return t}return{message:String(e)}},ue=(()=>{function e(e,t,n){const r=N(e+"/fulfilled",((e,t,n,r)=>({payload:e,meta:s(c({},r||{}),{arg:n,requestId:t,requestStatus:"fulfilled"})}))),o=N(e+"/pending",((e,t,n)=>({payload:void 0,meta:s(c({},n||{}),{arg:t,requestId:e,requestStatus:"pending"})}))),i=N(e+"/rejected",((e,t,r,o,i)=>({payload:o,error:(n&&n.serializeError||se)(e||"Rejected"),meta:s(c({},i||{}),{arg:r,requestId:t,rejectedWithValue:!!o,requestStatus:"rejected",aborted:"AbortError"===(null==e?void 0:e.name),condition:"ConditionError"===(null==e?void 0:e.name)})}))),a="undefined"!=typeof AbortController?AbortController:class{constructor(){this.signal={aborted:!1,addEventListener(){},dispatchEvent:()=>!1,onabort(){},removeEventListener(){},reason:void 0,throwIfAborted(){}}}abort(){}};return Object.assign((function(e){return(c,s,u)=>{const l=(null==n?void 0:n.idGenerator)?n.idGenerator(e):oe(),f=new a;let d,p=!1;function m(e){d=e,f.abort()}const y=async function(){var a,y;let h;try{let i=null==(a=null==n?void 0:n.condition)?void 0:a.call(n,e,{getState:s,extra:u});if(null!==(g=i)&&"object"==typeof g&&"function"==typeof g.then&&(i=await i),!1===i||f.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};p=!0;const b=new Promise(((e,t)=>f.signal.addEventListener("abort",(()=>t({name:"AbortError",message:d||"Aborted"})))));c(o(l,e,null==(y=null==n?void 0:n.getPendingMeta)?void 0:y.call(n,{requestId:l,arg:e},{getState:s,extra:u}))),h=await Promise.race([b,Promise.resolve(t(e,{dispatch:c,getState:s,extra:u,requestId:l,signal:f.signal,abort:m,rejectWithValue:(e,t)=>new ae(e,t),fulfillWithValue:(e,t)=>new ce(e,t)})).then((t=>{if(t instanceof ae)throw t;return t instanceof ce?r(t.payload,l,e,t.meta):r(t,l,e)}))])}catch(t){h=t instanceof ae?i(null,l,e,t.payload,t.meta):i(t,l,e)}var g;return n&&!n.dispatchConditionRejection&&i.match(h)&&h.meta.condition||c(h),h}();return Object.assign(y,{abort:m,requestId:l,arg:e,unwrap:()=>y.then(le)})}}),{pending:o,rejected:i,fulfilled:r,typePrefix:e})}return e.withTypes=()=>e,e})();function le(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}var fe=(e,t)=>{return(n=e)&&"function"==typeof n.match?e.match(t):e(t);var n};function de(...e){return t=>e.some((e=>fe(e,t)))}function pe(...e){return t=>e.every((e=>fe(e,t)))}function me(e,t){if(!e||!e.meta)return!1;const n="string"==typeof e.meta.requestId,r=t.indexOf(e.meta.requestStatus)>-1;return n&&r}function ye(e){return"function"==typeof e[0]&&"pending"in e[0]&&"fulfilled"in e[0]&&"rejected"in e[0]}function he(...e){return 0===e.length?e=>me(e,["pending"]):ye(e)?t=>de(...e.map((e=>e.pending)))(t):he()(e[0])}function ge(...e){return 0===e.length?e=>me(e,["rejected"]):ye(e)?t=>de(...e.map((e=>e.rejected)))(t):ge()(e[0])}function be(...e){const t=e=>e&&e.meta&&e.meta.rejectedWithValue;return 0===e.length||ye(e)?n=>pe(ge(...e),t)(n):be()(e[0])}function we(...e){return 0===e.length?e=>me(e,["fulfilled"]):ye(e)?t=>de(...e.map((e=>e.fulfilled)))(t):we()(e[0])}function ve(...e){return 0===e.length?e=>me(e,["pending","fulfilled","rejected"]):ye(e)?t=>{const n=[];for(const t of e)n.push(t.pending,t.rejected,t.fulfilled);return de(...n)(t)}:ve()(e[0])}var Oe=(e,t)=>{if("function"!=typeof e)throw new TypeError(`${t} is not a function`)},je=()=>{},Ee=(e,t=je)=>(e.catch(t),e),Se=(e,t)=>(e.addEventListener("abort",t,{once:!0}),()=>e.removeEventListener("abort",t)),Ae=(e,t)=>{const n=e.signal;n.aborted||("reason"in n||Object.defineProperty(n,"reason",{enumerable:!0,value:t,configurable:!0,writable:!0}),e.abort(t))},Pe=class{constructor(e){this.code=e,this.name="TaskAbortError",this.message=`task cancelled (reason: ${e})`}},ke=e=>{if(e.aborted)throw new Pe(e.reason)};function xe(e,t){let n=je;return new Promise(((r,o)=>{const i=()=>o(new Pe(e.reason));e.aborted?i():(n=Se(e,i),t.finally((()=>n())).then(r,o))})).finally((()=>{n=je}))}var Ie=e=>t=>Ee(xe(e,t).then((t=>(ke(e),t)))),_e=e=>{const t=Ie(e);return e=>t(new Promise((t=>setTimeout(t,e))))},{assign:Ce}=Object,Me={},Te="listenerMiddleware",qe=e=>{let{type:t,actionCreator:n,matcher:r,predicate:o,effect:i}=e;if(t)o=N(t).match;else if(n)t=n.type,o=n.match;else if(r)o=r;else if(!o)throw new Error("Creating or removing a listener requires one of the known fields for matching an action");return Oe(i,"options.listener"),{predicate:o,type:t,effect:i}},De=e=>{e.pending.forEach((e=>{Ae(e,"listener-cancelled")}))},Re=(e,t,n)=>{try{e(t,n)}catch(e){setTimeout((()=>{throw e}),0)}},Le=N(`${Te}/add`),$e=N(`${Te}/removeAll`),Be=N(`${Te}/remove`),Ne=(...e)=>{console.error(`${Te}/error`,...e)};function Ve(e={}){const t=new Map,{extra:n,onError:r=Ne}=e;Oe(r,"onError");const o=e=>{for(const n of Array.from(t.values()))if(e(n))return n},i=e=>{let n=o((t=>t.effect===e.effect));return n||(n=(e=>{const{type:t,predicate:n,effect:r}=qe(e);return{id:oe(),effect:r,type:t,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error("Unsubscribe not initialized")}}})(e)),(e=>(e.unsubscribe=()=>t.delete(e.id),t.set(e.id,e),t=>{e.unsubscribe(),(null==t?void 0:t.cancelActive)&&De(e)}))(n)},a=e=>{const{type:t,effect:n,predicate:r}=qe(e),i=o((e=>("string"==typeof t?e.type===t:e.predicate===r)&&e.effect===n));return i&&(i.unsubscribe(),e.cancelActive&&De(i)),!!i},c=async(e,o,a,c)=>{const s=new AbortController,u=((e,t)=>(n,r)=>Ee((async(n,r)=>{ke(t);let o=()=>{};const i=[new Promise(((t,r)=>{let i=e({predicate:n,effect:(e,n)=>{n.unsubscribe(),t([e,n.getState(),n.getOriginalState()])}});o=()=>{i(),r()}}))];null!=r&&i.push(new Promise((e=>setTimeout(e,r,null))));try{const e=await xe(t,Promise.race(i));return ke(t),e}finally{o()}})(n,r)))(i,s.signal);try{e.pending.add(s),await Promise.resolve(e.effect(o,Ce({},a,{getOriginalState:c,condition:(e,t)=>u(e,t).then(Boolean),take:u,delay:_e(s.signal),pause:Ie(s.signal),extra:n,signal:s.signal,fork:(l=s.signal,e=>{Oe(e,"taskExecutor");const t=new AbortController;var n;n=t,Se(l,(()=>Ae(n,l.reason)));const r=(async(n,r)=>{try{return await Promise.resolve(),{status:"ok",value:await(async()=>{ke(l),ke(t.signal);const n=await e({pause:Ie(t.signal),delay:_e(t.signal),signal:t.signal});return ke(t.signal),n})()}}catch(e){return{status:e instanceof Pe?"cancelled":"rejected",error:e}}finally{null==r||r()}})(0,(()=>Ae(t,"task-completed")));return{result:Ie(l)(r),cancel(){Ae(t,"task-cancelled")}}}),unsubscribe:e.unsubscribe,subscribe:()=>{t.set(e.id,e)},cancelActiveListeners:()=>{e.pending.forEach(((e,t,n)=>{e!==s&&(Ae(e,"listener-cancelled"),n.delete(e))}))}})))}catch(e){e instanceof Pe||Re(r,e,{raisedBy:"effect"})}finally{Ae(s,"listener-completed"),e.pending.delete(s)}var l},s=(e=>()=>{e.forEach(De),e.clear()})(t);return{middleware:e=>n=>o=>{if(Le.match(o))return i(o.payload);if($e.match(o))return void s();if(Be.match(o))return a(o.payload);let u=e.getState();const l=()=>{if(u===Me)throw new Error(`${Te}: getOriginalState can only be called synchronously`);return u};let f;try{if(f=n(o),t.size>0){let n=e.getState();const i=Array.from(t.values());for(let t of i){let i=!1;try{i=t.predicate(o,n,u)}catch(e){i=!1,Re(r,e,{raisedBy:"predicate"})}i&&c(t,o,e,l)}}}finally{u=Me}return f},startListening:i,stopListening:a,clearListeners:s}}var ze,Xe="RTK_autoBatch",We=()=>e=>({payload:e,meta:{RTK_autoBatch:!0}}),Fe="function"==typeof queueMicrotask?queueMicrotask.bind("undefined"!=typeof window?window:"undefined"!=typeof global?global:globalThis):e=>(ze||(ze=Promise.resolve())).then(e).catch((e=>setTimeout((()=>{throw e}),0))),Ue=e=>t=>{setTimeout(t,e)},Ke="undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:Ue(10),Ge=(e={type:"raf"})=>t=>(...n)=>{const r=t(...n);let o=!0,i=!1,a=!1;const c=new Set,s="tick"===e.type?Fe:"raf"===e.type?Ke:"callback"===e.type?e.queueNotification:Ue(e.timeout),u=()=>{a=!1,i&&(i=!1,c.forEach((e=>e())))};return Object.assign({},r,{subscribe(e){const t=r.subscribe((()=>o&&e()));return c.add(e),()=>{t(),c.delete(e)}},dispatch(e){var t;try{return o=!(null==(t=null==e?void 0:e.meta)?void 0:t.RTK_autoBatch),i=!o,i&&(a||(a=!0,s(u))),r.dispatch(e)}finally{o=!0}}})};u();export{_ as MiddlewareArray,Xe as SHOULD_AUTOBATCH,Pe as TaskAbortError,Le as addListener,Ge as autoBatchEnhancer,$e as clearAllListeners,B as configureStore,N as createAction,ue as createAsyncThunk,w as createDraftSafeSelector,re as createEntityAdapter,T as createImmutableStateInvariantMiddleware,Ve as createListenerMiddleware,l as createNextState,K as createReducer,y as createSelector,L as createSerializableStateInvariantMiddleware,G as createSlice,f as current,D as findNonSerializableValue,d as freeze,$ as getDefaultMiddleware,z as getType,pe as isAllOf,de as isAnyOf,ve as isAsyncThunkAction,m as isDraft,we as isFulfilled,M as isImmutableDefault,he as isPending,q as isPlain,P as isPlainObject,ge as isRejected,be as isRejectedWithValue,se as miniSerializeError,oe as nanoid,p as original,We as prepareAutoBatched,Be as removeListener,le as unwrapResult};
2//# sourceMappingURL=redux-toolkit.modern.production.min.js.map
\No newline at end of file