/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/@3plus/redux-api@1.1.5/lib/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";import reducerFn from"./reducerFn";import actionFn from"./actionFn";import transformers from"./transformers";import cacheManager from"./utils/cache";export{transformers};const defaultEndpointConfig={transformer:transformers.object},PREFIX="@@redux-api";export default function reduxApi(e,r){e||(e={});const t={fetch:null,server:!1,rootUrl:null,middlewareParser:null,options:{},responseHandler:null},n={use(e,r){return t[e]=r,this},init(e,r=!1,t){return console.warn("Deprecated method, use `use` method"),this.use("fetch",e),this.use("server",r),this.use("rootUrl",t),this},actions:{},reducers:{},events:{}};return Object.keys(e).reduce(((n,c)=>function(e,n,c){const o="object"==typeof n?{...defaultEndpointConfig,reducerName:c,...n}:{...defaultEndpointConfig,reducerName:c,url:n};void 0!==o.broadcast&&console.warn("Deprecated `broadcast` option. you shoud use `events`to catch redux-api events (see https://github.com/3plus/redux-api/blob/master/DOCS.md#Events)");const{url:s,urlOptions:a,options:i,transformer:u,broadcast:d,crud:l,reducerName:f,prefetch:h,postfetch:p,validation:m,helpers:$}=o,F=r&&r.prefix||"",b={actionFetch:`${PREFIX}@${F}${f}`,actionSuccess:`${PREFIX}@${F}${f}_success`,actionFail:`${PREFIX}@${F}${f}_fail`,actionReset:`${PREFIX}@${F}${f}_delete`,actionCache:`${PREFIX}@${F}${f}_cache`,actionAbort:`${PREFIX}@${F}${f}_abort`},v=o.fetch?o.fetch:function(...e){return t.fetch.apply(this,e)},E={holder:t,virtual:!!o.virtual,actions:e.actions,cache:cacheManager(o.cache),urlOptions:a,fetch:v,broadcast:d,reducerName:f,prefetch:h,postfetch:p,validation:m,helpers:$,transformer:u,prefix:F,crud:l};if(e.actions[c]=actionFn(s,c,i,b,E),!E.virtual&&!e.reducers[f]){const r=u(),t=!1,n=!1,c=!1,s=o.cache?{sync:t,syncing:n,loading:c,data:r,cache:{},request:null}:{sync:t,syncing:n,loading:c,data:r,request:null},a=o.reducer?o.reducer.bind(e):null;e.reducers[f]=reducerFn(s,b,a)}return e.events[f]=b,e}(n,e[c],c)),n)}
//# sourceMappingURL=/sm/e5ccf5fc1cb48c3587c945382a12cc0f1f21d404c9ae27612dcca02a785441c7.map