import{C as t}from"./p-d343a062.js";import{L as i}from"./p-e8a169b7.js";class s{constructor(t,s,r,e,a){this.didQuickSearchChangeAfterLastFetch=!1,this.list=i.init(),this.collection=s,this.query=r,this.initialData=e,this.quickSearch=a,this.api=t}getInitialData(){return Promise.resolve(this.initialData)}getData(){const{api:s,collection:r,query:e,quickSearchText:a}=this,o=this;return new Promise(((h,n)=>{if(o.list.data&&!this.didQuickSearchChangeAfterLastFetch)return void h(o.list.data);const c=function(t,i){let s=t?t.filter:void 0;return i&&(s=t&&t.filter?{operator:"and",filters:[t.filter,i]}:i),s}(e,function(i,s){if(i&&s)return{operator:"or",filters:i.fields.map((i=>({comparison:t.Contain,id:i.fieldId,value:s})))}}(this.quickSearch,a));s.query(r,{fields:e.fields,filter:c,limit:50,skip:0,sort:e.sort}).then((t=>{o.list=i.init().afterFetch(t),this.didQuickSearchChangeAfterLastFetch=!1,h(o.list.data)}),(t=>{o.list=i.init().afterFetchError(t),n(t)}))}))}setInitialData(t){this.initialData=t}setQuickSearchText(t){this.quickSearchText=t,this.didQuickSearchChangeAfterLastFetch=!0}getQuickSearchText(){return this.quickSearchText}isQuickSearchEnabled(){return!!this.quickSearch}}export{s as D}