import{r as i,e as t,B as s,h as o,H as n}from"./p-a89095f5.js";const h=class{constructor(s){i(this,s),this.fireenjinFetch=t(this,"fireenjinFetch",7),this.endpoint=void 0,this.name=void 0,this.dataPropsMap=void 0,this.params={},this.resultsKey=void 0,this.error=void 0,this.success=void 0}async onError(i){var t;if(i.detail.name===this.name){let s=(null===(t=null==i?void 0:i.detail)||void 0===t?void 0:t.data)||null;"function"==typeof this.error&&this.error(s)}}async onSuccess(i){var t;if(i.detail.name===this.name){let s=(null===(t=null==i?void 0:i.detail)||void 0===t?void 0:t.data)||[];if(this.resultsKey)try{s=this.resultsKey.split(".").reduce(((i,t)=>i[t]),i.detail.data)}catch(t){console.log("Error getting results",i.detail,this.resultsKey)}"function"==typeof this.success&&this.success(s)}}async fetch(){this.fireenjinFetch.emit({name:this.name,endpoint:this.endpoint,dataPropsMap:this.dataPropsMap?this.dataPropsMap:null,params:this.params||{}})}componentDidLoad(){(null==s?void 0:s.isBrowser)&&(this.name||(this.name=this.endpoint),this.fetch())}render(){return o(n,null,o("slot",null))}};export{h as fireenjin_query}