var __spreadArray=this&&this.__spreadArray||function(t,e,a){if(a||arguments.length===2)for(var r=0,i=e.length,n;r<i;r++){if(n||!(r in e)){if(!n)n=Array.prototype.slice.call(e,0,r);n[r]=e[r]}}return t.concat(n||Array.prototype.slice.call(e))};import{D as DataModel}from"./data-model-88af49fc.js";var ListFetchState=function(){function t(e,a,r,i){var n=this;if(r===void 0){r=false}this.beforeFetch=function(){return new t(n.data,n.meta,true,undefined)};this.afterFetch=function(e,a){if(a===void 0){a=true}var r;var i=n.data&&a?__spreadArray(__spreadArray([],n.data,true),DataModel.decodeList(e.results),true):DataModel.decodeList(e.results);var s=n.meta;if((r=e.meta)===null||r===void 0?void 0:r.total){s=e.meta}else if(!s&&e.results.length===0){s={total:i.length}}return new t(i,s,false,undefined)};this.afterFetchError=function(e){return new t(n.data,n.meta,false,e)};this.afterUpdateItem=function(e,a){return new t(n.data?__spreadArray([],n.data,true).map((function(t){if(t._id===e){return Object.assign(Object.assign({},t),a)}return t})):n.data,n.meta,false,undefined)};this.isEndReached=function(){return n.data&&n.meta?n.data.length>=n.meta.total:false};this.data=e;this.error=i;this.isPending=r;this.meta=a}return t}();ListFetchState.init=function(){return new ListFetchState};export{ListFetchState as L};