var __spreadArray=this&&this.__spreadArray||function(t,e){for(var a=0,r=e.length,n=t.length;a<r;a++,n++)t[n]=e[a];return t};import{D as DataModel}from"./data-model-f5160369.js";var ListFetchState=function(){function t(e,a,r,n){var i=this;if(r===void 0){r=false}this.beforeFetch=function(){return new t(i.data,i.meta,true,undefined)};this.afterFetch=function(e,a){if(a===void 0){a=true}var r;var n=i.data&&a?__spreadArray(__spreadArray([],i.data),DataModel.decodeList(e.results)):DataModel.decodeList(e.results);var s=i.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:n.length}}return new t(n,s,false,undefined)};this.afterFetchError=function(e){return new t(i.data,i.meta,false,e)};this.afterUpdateItem=function(e,a){return new t(i.data?__spreadArray([],i.data).map((function(t){if(t._id===e){return Object.assign(Object.assign({},t),a)}return t})):i.data,i.meta,false,undefined)};this.isEndReached=function(){return i.data&&i.meta?i.data.length>=i.meta.total:false};this.data=e;this.error=n;this.isPending=r;this.meta=a}return t}();ListFetchState.init=function(){return new ListFetchState};export{ListFetchState as L};