import{T as s}from"./p-eb6e2a8b.js";import{D as i}from"./p-3c3b4f3f.js";import{C as t}from"./p-d343a062.js";import{r as h,c as r}from"./p-f46dff5e.js";class o{constructor(s,i,t,h,r,o){this.apiData=s,this.callback=o,this.params=i,this.table=t,this.fields=r,this.query=h}fetchData(o){var a;if(o.isPending)return;this.callback(o.beforeFetch());const{name:f}=this.table,e=(null===(a=this.query)||void 0===a?void 0:a.filter)?h(r(this.query.filter),this.params):{comparison:t.Eq,id:"_id",value:this.params.itemId};this.apiData.query(f,{fields:[...this.fields,new s("_id","ID")],filter:e,limit:1,skip:0}).then((s=>{this.callback(o.afterFetch(s.results.length>0?s.results[0]:new i))}),(s=>{this.callback(o.afterFetchError(s))}))}}export{o as I}